]> git.ipfire.org Git - thirdparty/grsecurity-scrape.git/blob - test/grsecurity-3.0-3.15.1-201406222112.patch
Auto commit, 1 new patch{es}.
[thirdparty/grsecurity-scrape.git] / test / grsecurity-3.0-3.15.1-201406222112.patch
1 diff --git a/Documentation/dontdiff b/Documentation/dontdiff
2 index 9de9813..1462492 100644
3 --- a/Documentation/dontdiff
4 +++ b/Documentation/dontdiff
5 @@ -3,9 +3,11 @@
6 *.bc
7 *.bin
8 *.bz2
9 +*.c.[012]*.*
10 *.cis
11 *.cpio
12 *.csp
13 +*.dbg
14 *.dsp
15 *.dvi
16 *.elf
17 @@ -15,6 +17,7 @@
18 *.gcov
19 *.gen.S
20 *.gif
21 +*.gmo
22 *.grep
23 *.grp
24 *.gz
25 @@ -51,14 +54,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 @@ -72,9 +78,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 @@ -83,6 +91,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 @@ -95,32 +104,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 @@ -128,12 +145,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 @@ -148,14 +168,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 @@ -165,14 +185,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 @@ -188,6 +209,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 @@ -197,6 +220,7 @@ perf-archive
165 piggyback
166 piggy.gzip
167 piggy.S
168 +pmu-*
169 pnmtologo
170 ppc_defs.h*
171 pss_boot.h
172 @@ -206,7 +230,12 @@ r200_reg_safe.h
173 r300_reg_safe.h
174 r420_reg_safe.h
175 r600_reg_safe.h
176 +randomize_layout_hash.h
177 +randomize_layout_seed.h
178 +realmode.lds
179 +realmode.relocs
180 recordmcount
181 +regdb.c
182 relocs
183 rlim_names.h
184 rn50_reg_safe.h
185 @@ -216,8 +245,12 @@ series
186 setup
187 setup.bin
188 setup.elf
189 +signing_key*
190 +size_overflow_hash.h
191 sImage
192 +slabinfo
193 sm_tbl*
194 +sortextable
195 split-include
196 syscalltab.h
197 tables.c
198 @@ -227,6 +260,7 @@ tftpboot.img
199 timeconst.h
200 times.h*
201 trix_boot.h
202 +user_constants.h
203 utsrelease.h*
204 vdso-syms.lds
205 vdso.lds
206 @@ -238,13 +272,17 @@ vdso32.lds
207 vdso32.so.dbg
208 vdso64.lds
209 vdso64.so.dbg
210 +vdsox32.lds
211 +vdsox32-syms.lds
212 version.h*
213 vmImage
214 vmlinux
215 vmlinux-*
216 vmlinux.aout
217 vmlinux.bin.all
218 +vmlinux.bin.bz2
219 vmlinux.lds
220 +vmlinux.relocs
221 vmlinuz
222 voffset.h
223 vsyscall.lds
224 @@ -252,9 +290,12 @@ vsyscall_32.lds
225 wanxlfw.inc
226 uImage
227 unifdef
228 +utsrelease.h
229 wakeup.bin
230 wakeup.elf
231 wakeup.lds
232 +x509*
233 zImage*
234 zconf.hash.c
235 +zconf.lex.c
236 zoffset.h
237 diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt
238 index 30a8ad0d..2ed9efd 100644
239 --- a/Documentation/kernel-parameters.txt
240 +++ b/Documentation/kernel-parameters.txt
241 @@ -1103,6 +1103,10 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
242 Format: <unsigned int> such that (rxsize & ~0x1fffc0) == 0.
243 Default: 1024
244
245 + grsec_proc_gid= [GRKERNSEC_PROC_USERGROUP] Chooses GID to
246 + ignore grsecurity's /proc restrictions
247 +
248 +
249 hashdist= [KNL,NUMA] Large hashes allocated during boot
250 are distributed across NUMA nodes. Defaults on
251 for 64-bit NUMA, off otherwise.
252 @@ -2099,6 +2103,10 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
253 noexec=on: enable non-executable mappings (default)
254 noexec=off: disable non-executable mappings
255
256 + nopcid [X86-64]
257 + Disable PCID (Process-Context IDentifier) even if it
258 + is supported by the processor.
259 +
260 nosmap [X86]
261 Disable SMAP (Supervisor Mode Access Prevention)
262 even if it is supported by processor.
263 @@ -2366,6 +2374,25 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
264 the specified number of seconds. This is to be used if
265 your oopses keep scrolling off the screen.
266
267 + pax_nouderef [X86] disables UDEREF. Most likely needed under certain
268 + virtualization environments that don't cope well with the
269 + expand down segment used by UDEREF on X86-32 or the frequent
270 + page table updates on X86-64.
271 +
272 + pax_sanitize_slab=
273 + 0/1 to disable/enable slab object sanitization (enabled by
274 + default).
275 +
276 + pax_softmode= 0/1 to disable/enable PaX softmode on boot already.
277 +
278 + pax_extra_latent_entropy
279 + Enable a very simple form of latent entropy extraction
280 + from the first 4GB of memory as the bootmem allocator
281 + passes the memory pages to the buddy allocator.
282 +
283 + pax_weakuderef [X86-64] enables the weaker but faster form of UDEREF
284 + when the processor supports PCID.
285 +
286 pcbit= [HW,ISDN]
287
288 pcd. [PARIDE]
289 diff --git a/Makefile b/Makefile
290 index e2846ac..2a78f23 100644
291 --- a/Makefile
292 +++ b/Makefile
293 @@ -246,7 +246,9 @@ CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \
294 HOSTCC = gcc
295 HOSTCXX = g++
296 HOSTCFLAGS = -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 -fomit-frame-pointer
297 -HOSTCXXFLAGS = -O2
298 +HOSTCFLAGS = -Wall -W -Wmissing-prototypes -Wstrict-prototypes -Wno-unused-parameter -Wno-missing-field-initializers -O2 -fomit-frame-pointer -fno-delete-null-pointer-checks
299 +HOSTCFLAGS += $(call cc-option, -Wno-empty-body)
300 +HOSTCXXFLAGS = -O2 -Wall -W -Wno-array-bounds
301
302 ifeq ($(shell $(HOSTCC) -v 2>&1 | grep -c "clang version"), 1)
303 HOSTCFLAGS += -Wno-unused-value -Wno-unused-parameter \
304 @@ -438,8 +440,8 @@ export RCS_TAR_IGNORE := --exclude SCCS --exclude BitKeeper --exclude .svn \
305 # Rules shared between *config targets and build targets
306
307 # Basic helpers built in scripts/
308 -PHONY += scripts_basic
309 -scripts_basic:
310 +PHONY += scripts_basic gcc-plugins
311 +scripts_basic: gcc-plugins
312 $(Q)$(MAKE) $(build)=scripts/basic
313 $(Q)rm -f .tmp_quiet_recordmcount
314
315 @@ -600,6 +602,72 @@ else
316 KBUILD_CFLAGS += -O2
317 endif
318
319 +ifndef DISABLE_PAX_PLUGINS
320 +ifeq ($(call cc-ifversion, -ge, 0408, y), y)
321 +PLUGINCC := $(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-plugin.sh "$(HOSTCXX)" "$(HOSTCXX)" "$(CC)")
322 +else
323 +PLUGINCC := $(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-plugin.sh "$(HOSTCC)" "$(HOSTCXX)" "$(CC)")
324 +endif
325 +ifneq ($(PLUGINCC),)
326 +ifdef CONFIG_PAX_CONSTIFY_PLUGIN
327 +CONSTIFY_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/constify_plugin.so -DCONSTIFY_PLUGIN
328 +endif
329 +ifdef CONFIG_PAX_MEMORY_STACKLEAK
330 +STACKLEAK_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/stackleak_plugin.so -DSTACKLEAK_PLUGIN
331 +STACKLEAK_PLUGIN_CFLAGS += -fplugin-arg-stackleak_plugin-track-lowest-sp=100
332 +endif
333 +ifdef CONFIG_KALLOCSTAT_PLUGIN
334 +KALLOCSTAT_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/kallocstat_plugin.so
335 +endif
336 +ifdef CONFIG_PAX_KERNEXEC_PLUGIN
337 +KERNEXEC_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/kernexec_plugin.so
338 +KERNEXEC_PLUGIN_CFLAGS += -fplugin-arg-kernexec_plugin-method=$(CONFIG_PAX_KERNEXEC_PLUGIN_METHOD) -DKERNEXEC_PLUGIN
339 +KERNEXEC_PLUGIN_AFLAGS := -DKERNEXEC_PLUGIN
340 +endif
341 +ifdef CONFIG_GRKERNSEC_RANDSTRUCT
342 +RANDSTRUCT_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/randomize_layout_plugin.so -DRANDSTRUCT_PLUGIN
343 +ifdef CONFIG_GRKERNSEC_RANDSTRUCT_PERFORMANCE
344 +RANDSTRUCT_PLUGIN_CFLAGS += -fplugin-arg-randomize_layout_plugin-performance-mode
345 +endif
346 +endif
347 +ifdef CONFIG_CHECKER_PLUGIN
348 +ifeq ($(call cc-ifversion, -ge, 0406, y), y)
349 +CHECKER_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/checker_plugin.so -DCHECKER_PLUGIN
350 +endif
351 +endif
352 +COLORIZE_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/colorize_plugin.so
353 +ifdef CONFIG_PAX_SIZE_OVERFLOW
354 +SIZE_OVERFLOW_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/size_overflow_plugin/size_overflow_plugin.so -DSIZE_OVERFLOW_PLUGIN
355 +endif
356 +ifdef CONFIG_PAX_LATENT_ENTROPY
357 +LATENT_ENTROPY_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/latent_entropy_plugin.so -DLATENT_ENTROPY_PLUGIN
358 +endif
359 +ifdef CONFIG_PAX_MEMORY_STRUCTLEAK
360 +STRUCTLEAK_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/structleak_plugin.so -DSTRUCTLEAK_PLUGIN
361 +endif
362 +GCC_PLUGINS_CFLAGS := $(CONSTIFY_PLUGIN_CFLAGS) $(STACKLEAK_PLUGIN_CFLAGS) $(KALLOCSTAT_PLUGIN_CFLAGS)
363 +GCC_PLUGINS_CFLAGS += $(KERNEXEC_PLUGIN_CFLAGS) $(CHECKER_PLUGIN_CFLAGS) $(COLORIZE_PLUGIN_CFLAGS)
364 +GCC_PLUGINS_CFLAGS += $(SIZE_OVERFLOW_PLUGIN_CFLAGS) $(LATENT_ENTROPY_PLUGIN_CFLAGS) $(STRUCTLEAK_PLUGIN_CFLAGS)
365 +GCC_PLUGINS_CFLAGS += $(RANDSTRUCT_PLUGIN_CFLAGS)
366 +GCC_PLUGINS_AFLAGS := $(KERNEXEC_PLUGIN_AFLAGS)
367 +export PLUGINCC GCC_PLUGINS_CFLAGS GCC_PLUGINS_AFLAGS CONSTIFY_PLUGIN LATENT_ENTROPY_PLUGIN_CFLAGS
368 +ifeq ($(KBUILD_EXTMOD),)
369 +gcc-plugins:
370 + $(Q)$(MAKE) $(build)=tools/gcc
371 +else
372 +gcc-plugins: ;
373 +endif
374 +else
375 +gcc-plugins:
376 +ifeq ($(call cc-ifversion, -ge, 0405, y), y)
377 + $(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.))
378 +else
379 + $(Q)echo "warning, your gcc version does not support plugins, you should upgrade it to gcc 4.5 at least"
380 +endif
381 + $(Q)echo "PAX_MEMORY_STACKLEAK, constification, PAX_LATENT_ENTROPY and other features will be less secure. PAX_SIZE_OVERFLOW will not be active."
382 +endif
383 +endif
384 +
385 include $(srctree)/arch/$(SRCARCH)/Makefile
386
387 ifdef CONFIG_READABLE_ASM
388 @@ -816,7 +884,7 @@ export mod_sign_cmd
389
390
391 ifeq ($(KBUILD_EXTMOD),)
392 -core-y += kernel/ mm/ fs/ ipc/ security/ crypto/ block/
393 +core-y += kernel/ mm/ fs/ ipc/ security/ crypto/ block/ grsecurity/
394
395 vmlinux-dirs := $(patsubst %/,%,$(filter %/, $(init-y) $(init-m) \
396 $(core-y) $(core-m) $(drivers-y) $(drivers-m) \
397 @@ -865,6 +933,8 @@ endif
398
399 # The actual objects are generated when descending,
400 # make sure no implicit rule kicks in
401 +$(filter-out $(init-y),$(vmlinux-deps)): KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
402 +$(filter-out $(init-y),$(vmlinux-deps)): KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
403 $(sort $(vmlinux-deps)): $(vmlinux-dirs) ;
404
405 # Handle descending into subdirectories listed in $(vmlinux-dirs)
406 @@ -874,7 +944,7 @@ $(sort $(vmlinux-deps)): $(vmlinux-dirs) ;
407 # Error messages still appears in the original language
408
409 PHONY += $(vmlinux-dirs)
410 -$(vmlinux-dirs): prepare scripts
411 +$(vmlinux-dirs): gcc-plugins prepare scripts
412 $(Q)$(MAKE) $(build)=$@
413
414 define filechk_kernel.release
415 @@ -917,10 +987,13 @@ prepare1: prepare2 $(version_h) include/generated/utsrelease.h \
416
417 archprepare: archheaders archscripts prepare1 scripts_basic
418
419 +prepare0: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
420 +prepare0: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
421 prepare0: archprepare FORCE
422 $(Q)$(MAKE) $(build)=.
423
424 # All the preparing..
425 +prepare: KBUILD_CFLAGS := $(filter-out $(GCC_PLUGINS_CFLAGS),$(KBUILD_CFLAGS))
426 prepare: prepare0
427
428 # Generate some files
429 @@ -1028,6 +1101,8 @@ all: modules
430 # using awk while concatenating to the final file.
431
432 PHONY += modules
433 +modules: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
434 +modules: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
435 modules: $(vmlinux-dirs) $(if $(KBUILD_BUILTIN),vmlinux) modules.builtin
436 $(Q)$(AWK) '!x[$$0]++' $(vmlinux-dirs:%=$(objtree)/%/modules.order) > $(objtree)/modules.order
437 @$(kecho) ' Building modules, stage 2.';
438 @@ -1043,7 +1118,7 @@ modules.builtin: $(vmlinux-dirs:%=%/modules.builtin)
439
440 # Target to prepare building external modules
441 PHONY += modules_prepare
442 -modules_prepare: prepare scripts
443 +modules_prepare: gcc-plugins prepare scripts
444
445 # Target to install modules
446 PHONY += modules_install
447 @@ -1109,7 +1184,10 @@ MRPROPER_FILES += .config .config.old .version .old_version $(version_h) \
448 Module.symvers tags TAGS cscope* GPATH GTAGS GRTAGS GSYMS \
449 signing_key.priv signing_key.x509 x509.genkey \
450 extra_certificates signing_key.x509.keyid \
451 - signing_key.x509.signer include/linux/version.h
452 + signing_key.x509.signer include/linux/version.h \
453 + tools/gcc/size_overflow_plugin/size_overflow_hash_aux.h \
454 + tools/gcc/size_overflow_plugin/size_overflow_hash.h \
455 + tools/gcc/randomize_layout_seed.h
456
457 # clean - Delete most, but leave enough to build external modules
458 #
459 @@ -1148,7 +1226,7 @@ distclean: mrproper
460 @find $(srctree) $(RCS_FIND_IGNORE) \
461 \( -name '*.orig' -o -name '*.rej' -o -name '*~' \
462 -o -name '*.bak' -o -name '#*#' -o -name '.*.orig' \
463 - -o -name '.*.rej' -o -name '*%' -o -name 'core' \) \
464 + -o -name '.*.rej' -o -name '*.so' -o -name '*%' -o -name 'core' \) \
465 -type f -print | xargs rm -f
466
467
468 @@ -1309,6 +1387,8 @@ PHONY += $(module-dirs) modules
469 $(module-dirs): crmodverdir $(objtree)/Module.symvers
470 $(Q)$(MAKE) $(build)=$(patsubst _module_%,%,$@)
471
472 +modules: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
473 +modules: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
474 modules: $(module-dirs)
475 @$(kecho) ' Building modules, stage 2.';
476 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost
477 @@ -1448,17 +1528,21 @@ else
478 target-dir = $(if $(KBUILD_EXTMOD),$(dir $<),$(dir $@))
479 endif
480
481 -%.s: %.c prepare scripts FORCE
482 +%.s: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
483 +%.s: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
484 +%.s: %.c gcc-plugins prepare scripts FORCE
485 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
486 %.i: %.c prepare scripts FORCE
487 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
488 -%.o: %.c prepare scripts FORCE
489 +%.o: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
490 +%.o: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
491 +%.o: %.c gcc-plugins prepare scripts FORCE
492 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
493 %.lst: %.c prepare scripts FORCE
494 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
495 -%.s: %.S prepare scripts FORCE
496 +%.s: %.S gcc-plugins prepare scripts FORCE
497 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
498 -%.o: %.S prepare scripts FORCE
499 +%.o: %.S gcc-plugins prepare scripts FORCE
500 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
501 %.symtypes: %.c prepare scripts FORCE
502 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
503 @@ -1468,11 +1552,15 @@ endif
504 $(cmd_crmodverdir)
505 $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
506 $(build)=$(build-dir)
507 -%/: prepare scripts FORCE
508 +%/: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
509 +%/: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
510 +%/: gcc-plugins prepare scripts FORCE
511 $(cmd_crmodverdir)
512 $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
513 $(build)=$(build-dir)
514 -%.ko: prepare scripts FORCE
515 +%.ko: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
516 +%.ko: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
517 +%.ko: gcc-plugins prepare scripts FORCE
518 $(cmd_crmodverdir)
519 $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
520 $(build)=$(build-dir) $(@:.ko=.o)
521 diff --git a/arch/alpha/include/asm/atomic.h b/arch/alpha/include/asm/atomic.h
522 index 78b03ef..da28a51 100644
523 --- a/arch/alpha/include/asm/atomic.h
524 +++ b/arch/alpha/include/asm/atomic.h
525 @@ -292,6 +292,16 @@ static inline long atomic64_dec_if_positive(atomic64_t *v)
526 #define atomic_dec(v) atomic_sub(1,(v))
527 #define atomic64_dec(v) atomic64_sub(1,(v))
528
529 +#define atomic64_read_unchecked(v) atomic64_read(v)
530 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
531 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
532 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
533 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
534 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
535 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
536 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
537 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
538 +
539 #define smp_mb__before_atomic_dec() smp_mb()
540 #define smp_mb__after_atomic_dec() smp_mb()
541 #define smp_mb__before_atomic_inc() smp_mb()
542 diff --git a/arch/alpha/include/asm/cache.h b/arch/alpha/include/asm/cache.h
543 index ad368a9..fbe0f25 100644
544 --- a/arch/alpha/include/asm/cache.h
545 +++ b/arch/alpha/include/asm/cache.h
546 @@ -4,19 +4,19 @@
547 #ifndef __ARCH_ALPHA_CACHE_H
548 #define __ARCH_ALPHA_CACHE_H
549
550 +#include <linux/const.h>
551
552 /* Bytes per L1 (data) cache line. */
553 #if defined(CONFIG_ALPHA_GENERIC) || defined(CONFIG_ALPHA_EV6)
554 -# define L1_CACHE_BYTES 64
555 # define L1_CACHE_SHIFT 6
556 #else
557 /* Both EV4 and EV5 are write-through, read-allocate,
558 direct-mapped, physical.
559 */
560 -# define L1_CACHE_BYTES 32
561 # define L1_CACHE_SHIFT 5
562 #endif
563
564 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
565 #define SMP_CACHE_BYTES L1_CACHE_BYTES
566
567 #endif
568 diff --git a/arch/alpha/include/asm/elf.h b/arch/alpha/include/asm/elf.h
569 index 968d999..d36b2df 100644
570 --- a/arch/alpha/include/asm/elf.h
571 +++ b/arch/alpha/include/asm/elf.h
572 @@ -91,6 +91,13 @@ typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
573
574 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE + 0x1000000)
575
576 +#ifdef CONFIG_PAX_ASLR
577 +#define PAX_ELF_ET_DYN_BASE (current->personality & ADDR_LIMIT_32BIT ? 0x10000 : 0x120000000UL)
578 +
579 +#define PAX_DELTA_MMAP_LEN (current->personality & ADDR_LIMIT_32BIT ? 14 : 28)
580 +#define PAX_DELTA_STACK_LEN (current->personality & ADDR_LIMIT_32BIT ? 14 : 19)
581 +#endif
582 +
583 /* $0 is set by ld.so to a pointer to a function which might be
584 registered using atexit. This provides a mean for the dynamic
585 linker to call DT_FINI functions for shared libraries that have
586 diff --git a/arch/alpha/include/asm/pgalloc.h b/arch/alpha/include/asm/pgalloc.h
587 index aab14a0..b4fa3e7 100644
588 --- a/arch/alpha/include/asm/pgalloc.h
589 +++ b/arch/alpha/include/asm/pgalloc.h
590 @@ -29,6 +29,12 @@ pgd_populate(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
591 pgd_set(pgd, pmd);
592 }
593
594 +static inline void
595 +pgd_populate_kernel(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
596 +{
597 + pgd_populate(mm, pgd, pmd);
598 +}
599 +
600 extern pgd_t *pgd_alloc(struct mm_struct *mm);
601
602 static inline void
603 diff --git a/arch/alpha/include/asm/pgtable.h b/arch/alpha/include/asm/pgtable.h
604 index d8f9b7e..f6222fa 100644
605 --- a/arch/alpha/include/asm/pgtable.h
606 +++ b/arch/alpha/include/asm/pgtable.h
607 @@ -102,6 +102,17 @@ struct vm_area_struct;
608 #define PAGE_SHARED __pgprot(_PAGE_VALID | __ACCESS_BITS)
609 #define PAGE_COPY __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOW)
610 #define PAGE_READONLY __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOW)
611 +
612 +#ifdef CONFIG_PAX_PAGEEXEC
613 +# define PAGE_SHARED_NOEXEC __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOE)
614 +# define PAGE_COPY_NOEXEC __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOW | _PAGE_FOE)
615 +# define PAGE_READONLY_NOEXEC __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOW | _PAGE_FOE)
616 +#else
617 +# define PAGE_SHARED_NOEXEC PAGE_SHARED
618 +# define PAGE_COPY_NOEXEC PAGE_COPY
619 +# define PAGE_READONLY_NOEXEC PAGE_READONLY
620 +#endif
621 +
622 #define PAGE_KERNEL __pgprot(_PAGE_VALID | _PAGE_ASM | _PAGE_KRE | _PAGE_KWE)
623
624 #define _PAGE_NORMAL(x) __pgprot(_PAGE_VALID | __ACCESS_BITS | (x))
625 diff --git a/arch/alpha/kernel/module.c b/arch/alpha/kernel/module.c
626 index 2fd00b7..cfd5069 100644
627 --- a/arch/alpha/kernel/module.c
628 +++ b/arch/alpha/kernel/module.c
629 @@ -160,7 +160,7 @@ apply_relocate_add(Elf64_Shdr *sechdrs, const char *strtab,
630
631 /* The small sections were sorted to the end of the segment.
632 The following should definitely cover them. */
633 - gp = (u64)me->module_core + me->core_size - 0x8000;
634 + gp = (u64)me->module_core_rw + me->core_size_rw - 0x8000;
635 got = sechdrs[me->arch.gotsecindex].sh_addr;
636
637 for (i = 0; i < n; i++) {
638 diff --git a/arch/alpha/kernel/osf_sys.c b/arch/alpha/kernel/osf_sys.c
639 index 1402fcc..0b1abd2 100644
640 --- a/arch/alpha/kernel/osf_sys.c
641 +++ b/arch/alpha/kernel/osf_sys.c
642 @@ -1298,10 +1298,11 @@ SYSCALL_DEFINE1(old_adjtimex, struct timex32 __user *, txc_p)
643 generic version except that we know how to honor ADDR_LIMIT_32BIT. */
644
645 static unsigned long
646 -arch_get_unmapped_area_1(unsigned long addr, unsigned long len,
647 - unsigned long limit)
648 +arch_get_unmapped_area_1(struct file *filp, unsigned long addr, unsigned long len,
649 + unsigned long limit, unsigned long flags)
650 {
651 struct vm_unmapped_area_info info;
652 + unsigned long offset = gr_rand_threadstack_offset(current->mm, filp, flags);
653
654 info.flags = 0;
655 info.length = len;
656 @@ -1309,6 +1310,7 @@ arch_get_unmapped_area_1(unsigned long addr, unsigned long len,
657 info.high_limit = limit;
658 info.align_mask = 0;
659 info.align_offset = 0;
660 + info.threadstack_offset = offset;
661 return vm_unmapped_area(&info);
662 }
663
664 @@ -1341,20 +1343,24 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
665 merely specific addresses, but regions of memory -- perhaps
666 this feature should be incorporated into all ports? */
667
668 +#ifdef CONFIG_PAX_RANDMMAP
669 + if (!(current->mm->pax_flags & MF_PAX_RANDMMAP))
670 +#endif
671 +
672 if (addr) {
673 - addr = arch_get_unmapped_area_1 (PAGE_ALIGN(addr), len, limit);
674 + addr = arch_get_unmapped_area_1 (filp, PAGE_ALIGN(addr), len, limit, flags);
675 if (addr != (unsigned long) -ENOMEM)
676 return addr;
677 }
678
679 /* Next, try allocating at TASK_UNMAPPED_BASE. */
680 - addr = arch_get_unmapped_area_1 (PAGE_ALIGN(TASK_UNMAPPED_BASE),
681 - len, limit);
682 + addr = arch_get_unmapped_area_1 (filp, PAGE_ALIGN(current->mm->mmap_base), len, limit, flags);
683 +
684 if (addr != (unsigned long) -ENOMEM)
685 return addr;
686
687 /* Finally, try allocating in low memory. */
688 - addr = arch_get_unmapped_area_1 (PAGE_SIZE, len, limit);
689 + addr = arch_get_unmapped_area_1 (filp, PAGE_SIZE, len, limit, flags);
690
691 return addr;
692 }
693 diff --git a/arch/alpha/mm/fault.c b/arch/alpha/mm/fault.c
694 index 98838a0..b304fb4 100644
695 --- a/arch/alpha/mm/fault.c
696 +++ b/arch/alpha/mm/fault.c
697 @@ -53,6 +53,124 @@ __load_new_mm_context(struct mm_struct *next_mm)
698 __reload_thread(pcb);
699 }
700
701 +#ifdef CONFIG_PAX_PAGEEXEC
702 +/*
703 + * PaX: decide what to do with offenders (regs->pc = fault address)
704 + *
705 + * returns 1 when task should be killed
706 + * 2 when patched PLT trampoline was detected
707 + * 3 when unpatched PLT trampoline was detected
708 + */
709 +static int pax_handle_fetch_fault(struct pt_regs *regs)
710 +{
711 +
712 +#ifdef CONFIG_PAX_EMUPLT
713 + int err;
714 +
715 + do { /* PaX: patched PLT emulation #1 */
716 + unsigned int ldah, ldq, jmp;
717 +
718 + err = get_user(ldah, (unsigned int *)regs->pc);
719 + err |= get_user(ldq, (unsigned int *)(regs->pc+4));
720 + err |= get_user(jmp, (unsigned int *)(regs->pc+8));
721 +
722 + if (err)
723 + break;
724 +
725 + if ((ldah & 0xFFFF0000U) == 0x277B0000U &&
726 + (ldq & 0xFFFF0000U) == 0xA77B0000U &&
727 + jmp == 0x6BFB0000U)
728 + {
729 + unsigned long r27, addr;
730 + unsigned long addrh = (ldah | 0xFFFFFFFFFFFF0000UL) << 16;
731 + unsigned long addrl = ldq | 0xFFFFFFFFFFFF0000UL;
732 +
733 + addr = regs->r27 + ((addrh ^ 0x80000000UL) + 0x80000000UL) + ((addrl ^ 0x8000UL) + 0x8000UL);
734 + err = get_user(r27, (unsigned long *)addr);
735 + if (err)
736 + break;
737 +
738 + regs->r27 = r27;
739 + regs->pc = r27;
740 + return 2;
741 + }
742 + } while (0);
743 +
744 + do { /* PaX: patched PLT emulation #2 */
745 + unsigned int ldah, lda, br;
746 +
747 + err = get_user(ldah, (unsigned int *)regs->pc);
748 + err |= get_user(lda, (unsigned int *)(regs->pc+4));
749 + err |= get_user(br, (unsigned int *)(regs->pc+8));
750 +
751 + if (err)
752 + break;
753 +
754 + if ((ldah & 0xFFFF0000U) == 0x277B0000U &&
755 + (lda & 0xFFFF0000U) == 0xA77B0000U &&
756 + (br & 0xFFE00000U) == 0xC3E00000U)
757 + {
758 + unsigned long addr = br | 0xFFFFFFFFFFE00000UL;
759 + unsigned long addrh = (ldah | 0xFFFFFFFFFFFF0000UL) << 16;
760 + unsigned long addrl = lda | 0xFFFFFFFFFFFF0000UL;
761 +
762 + regs->r27 += ((addrh ^ 0x80000000UL) + 0x80000000UL) + ((addrl ^ 0x8000UL) + 0x8000UL);
763 + regs->pc += 12 + (((addr ^ 0x00100000UL) + 0x00100000UL) << 2);
764 + return 2;
765 + }
766 + } while (0);
767 +
768 + do { /* PaX: unpatched PLT emulation */
769 + unsigned int br;
770 +
771 + err = get_user(br, (unsigned int *)regs->pc);
772 +
773 + if (!err && (br & 0xFFE00000U) == 0xC3800000U) {
774 + unsigned int br2, ldq, nop, jmp;
775 + unsigned long addr = br | 0xFFFFFFFFFFE00000UL, resolver;
776 +
777 + addr = regs->pc + 4 + (((addr ^ 0x00100000UL) + 0x00100000UL) << 2);
778 + err = get_user(br2, (unsigned int *)addr);
779 + err |= get_user(ldq, (unsigned int *)(addr+4));
780 + err |= get_user(nop, (unsigned int *)(addr+8));
781 + err |= get_user(jmp, (unsigned int *)(addr+12));
782 + err |= get_user(resolver, (unsigned long *)(addr+16));
783 +
784 + if (err)
785 + break;
786 +
787 + if (br2 == 0xC3600000U &&
788 + ldq == 0xA77B000CU &&
789 + nop == 0x47FF041FU &&
790 + jmp == 0x6B7B0000U)
791 + {
792 + regs->r28 = regs->pc+4;
793 + regs->r27 = addr+16;
794 + regs->pc = resolver;
795 + return 3;
796 + }
797 + }
798 + } while (0);
799 +#endif
800 +
801 + return 1;
802 +}
803 +
804 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
805 +{
806 + unsigned long i;
807 +
808 + printk(KERN_ERR "PAX: bytes at PC: ");
809 + for (i = 0; i < 5; i++) {
810 + unsigned int c;
811 + if (get_user(c, (unsigned int *)pc+i))
812 + printk(KERN_CONT "???????? ");
813 + else
814 + printk(KERN_CONT "%08x ", c);
815 + }
816 + printk("\n");
817 +}
818 +#endif
819
820 /*
821 * This routine handles page faults. It determines the address,
822 @@ -133,8 +251,29 @@ retry:
823 good_area:
824 si_code = SEGV_ACCERR;
825 if (cause < 0) {
826 - if (!(vma->vm_flags & VM_EXEC))
827 + if (!(vma->vm_flags & VM_EXEC)) {
828 +
829 +#ifdef CONFIG_PAX_PAGEEXEC
830 + if (!(mm->pax_flags & MF_PAX_PAGEEXEC) || address != regs->pc)
831 + goto bad_area;
832 +
833 + up_read(&mm->mmap_sem);
834 + switch (pax_handle_fetch_fault(regs)) {
835 +
836 +#ifdef CONFIG_PAX_EMUPLT
837 + case 2:
838 + case 3:
839 + return;
840 +#endif
841 +
842 + }
843 + pax_report_fault(regs, (void *)regs->pc, (void *)rdusp());
844 + do_group_exit(SIGKILL);
845 +#else
846 goto bad_area;
847 +#endif
848 +
849 + }
850 } else if (!cause) {
851 /* Allow reads even for write-only mappings */
852 if (!(vma->vm_flags & (VM_READ | VM_WRITE)))
853 diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
854 index db3c541..a1acc89 100644
855 --- a/arch/arm/Kconfig
856 +++ b/arch/arm/Kconfig
857 @@ -1877,7 +1877,7 @@ config ALIGNMENT_TRAP
858
859 config UACCESS_WITH_MEMCPY
860 bool "Use kernel mem{cpy,set}() for {copy_to,clear}_user()"
861 - depends on MMU
862 + depends on MMU && !PAX_MEMORY_UDEREF
863 default y if CPU_FEROCEON
864 help
865 Implement faster copy_to_user and clear_user methods for CPU
866 @@ -2141,6 +2141,7 @@ config XIP_PHYS_ADDR
867 config KEXEC
868 bool "Kexec system call (EXPERIMENTAL)"
869 depends on (!SMP || PM_SLEEP_SMP)
870 + depends on !GRKERNSEC_KMEM
871 help
872 kexec is a system call that implements the ability to shutdown your
873 current kernel, and to start another kernel. It is like a reboot
874 diff --git a/arch/arm/include/asm/atomic.h b/arch/arm/include/asm/atomic.h
875 index 9a92fd7..3502a80 100644
876 --- a/arch/arm/include/asm/atomic.h
877 +++ b/arch/arm/include/asm/atomic.h
878 @@ -18,17 +18,35 @@
879 #include <asm/barrier.h>
880 #include <asm/cmpxchg.h>
881
882 +#ifdef CONFIG_GENERIC_ATOMIC64
883 +#include <asm-generic/atomic64.h>
884 +#endif
885 +
886 #define ATOMIC_INIT(i) { (i) }
887
888 #ifdef __KERNEL__
889
890 +#define _ASM_EXTABLE(from, to) \
891 +" .pushsection __ex_table,\"a\"\n"\
892 +" .align 3\n" \
893 +" .long " #from ", " #to"\n" \
894 +" .popsection"
895 +
896 /*
897 * On ARM, ordinary assignment (str instruction) doesn't clear the local
898 * strex/ldrex monitor on some implementations. The reason we can use it for
899 * atomic_set() is the clrex or dummy strex done on every exception return.
900 */
901 #define atomic_read(v) (*(volatile int *)&(v)->counter)
902 +static inline int atomic_read_unchecked(const atomic_unchecked_t *v)
903 +{
904 + return v->counter;
905 +}
906 #define atomic_set(v,i) (((v)->counter) = (i))
907 +static inline void atomic_set_unchecked(atomic_unchecked_t *v, int i)
908 +{
909 + v->counter = i;
910 +}
911
912 #if __LINUX_ARM_ARCH__ >= 6
913
914 @@ -44,6 +62,36 @@ static inline void atomic_add(int i, atomic_t *v)
915
916 prefetchw(&v->counter);
917 __asm__ __volatile__("@ atomic_add\n"
918 +"1: ldrex %1, [%3]\n"
919 +" adds %0, %1, %4\n"
920 +
921 +#ifdef CONFIG_PAX_REFCOUNT
922 +" bvc 3f\n"
923 +"2: bkpt 0xf103\n"
924 +"3:\n"
925 +#endif
926 +
927 +" strex %1, %0, [%3]\n"
928 +" teq %1, #0\n"
929 +" bne 1b"
930 +
931 +#ifdef CONFIG_PAX_REFCOUNT
932 +"\n4:\n"
933 + _ASM_EXTABLE(2b, 4b)
934 +#endif
935 +
936 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
937 + : "r" (&v->counter), "Ir" (i)
938 + : "cc");
939 +}
940 +
941 +static inline void atomic_add_unchecked(int i, atomic_unchecked_t *v)
942 +{
943 + unsigned long tmp;
944 + int result;
945 +
946 + prefetchw(&v->counter);
947 + __asm__ __volatile__("@ atomic_add_unchecked\n"
948 "1: ldrex %0, [%3]\n"
949 " add %0, %0, %4\n"
950 " strex %1, %0, [%3]\n"
951 @@ -63,6 +111,43 @@ static inline int atomic_add_return(int i, atomic_t *v)
952 prefetchw(&v->counter);
953
954 __asm__ __volatile__("@ atomic_add_return\n"
955 +"1: ldrex %1, [%3]\n"
956 +" adds %0, %1, %4\n"
957 +
958 +#ifdef CONFIG_PAX_REFCOUNT
959 +" bvc 3f\n"
960 +" mov %0, %1\n"
961 +"2: bkpt 0xf103\n"
962 +"3:\n"
963 +#endif
964 +
965 +" strex %1, %0, [%3]\n"
966 +" teq %1, #0\n"
967 +" bne 1b"
968 +
969 +#ifdef CONFIG_PAX_REFCOUNT
970 +"\n4:\n"
971 + _ASM_EXTABLE(2b, 4b)
972 +#endif
973 +
974 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
975 + : "r" (&v->counter), "Ir" (i)
976 + : "cc");
977 +
978 + smp_mb();
979 +
980 + return result;
981 +}
982 +
983 +static inline int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
984 +{
985 + unsigned long tmp;
986 + int result;
987 +
988 + smp_mb();
989 + prefetchw(&v->counter);
990 +
991 + __asm__ __volatile__("@ atomic_add_return_unchecked\n"
992 "1: ldrex %0, [%3]\n"
993 " add %0, %0, %4\n"
994 " strex %1, %0, [%3]\n"
995 @@ -84,6 +169,36 @@ static inline void atomic_sub(int i, atomic_t *v)
996
997 prefetchw(&v->counter);
998 __asm__ __volatile__("@ atomic_sub\n"
999 +"1: ldrex %1, [%3]\n"
1000 +" subs %0, %1, %4\n"
1001 +
1002 +#ifdef CONFIG_PAX_REFCOUNT
1003 +" bvc 3f\n"
1004 +"2: bkpt 0xf103\n"
1005 +"3:\n"
1006 +#endif
1007 +
1008 +" strex %1, %0, [%3]\n"
1009 +" teq %1, #0\n"
1010 +" bne 1b"
1011 +
1012 +#ifdef CONFIG_PAX_REFCOUNT
1013 +"\n4:\n"
1014 + _ASM_EXTABLE(2b, 4b)
1015 +#endif
1016 +
1017 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1018 + : "r" (&v->counter), "Ir" (i)
1019 + : "cc");
1020 +}
1021 +
1022 +static inline void atomic_sub_unchecked(int i, atomic_unchecked_t *v)
1023 +{
1024 + unsigned long tmp;
1025 + int result;
1026 +
1027 + prefetchw(&v->counter);
1028 + __asm__ __volatile__("@ atomic_sub_unchecked\n"
1029 "1: ldrex %0, [%3]\n"
1030 " sub %0, %0, %4\n"
1031 " strex %1, %0, [%3]\n"
1032 @@ -103,11 +218,25 @@ static inline int atomic_sub_return(int i, atomic_t *v)
1033 prefetchw(&v->counter);
1034
1035 __asm__ __volatile__("@ atomic_sub_return\n"
1036 -"1: ldrex %0, [%3]\n"
1037 -" sub %0, %0, %4\n"
1038 +"1: ldrex %1, [%3]\n"
1039 +" subs %0, %1, %4\n"
1040 +
1041 +#ifdef CONFIG_PAX_REFCOUNT
1042 +" bvc 3f\n"
1043 +" mov %0, %1\n"
1044 +"2: bkpt 0xf103\n"
1045 +"3:\n"
1046 +#endif
1047 +
1048 " strex %1, %0, [%3]\n"
1049 " teq %1, #0\n"
1050 " bne 1b"
1051 +
1052 +#ifdef CONFIG_PAX_REFCOUNT
1053 +"\n4:\n"
1054 + _ASM_EXTABLE(2b, 4b)
1055 +#endif
1056 +
1057 : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1058 : "r" (&v->counter), "Ir" (i)
1059 : "cc");
1060 @@ -152,12 +281,24 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
1061 __asm__ __volatile__ ("@ atomic_add_unless\n"
1062 "1: ldrex %0, [%4]\n"
1063 " teq %0, %5\n"
1064 -" beq 2f\n"
1065 -" add %1, %0, %6\n"
1066 +" beq 4f\n"
1067 +" adds %1, %0, %6\n"
1068 +
1069 +#ifdef CONFIG_PAX_REFCOUNT
1070 +" bvc 3f\n"
1071 +"2: bkpt 0xf103\n"
1072 +"3:\n"
1073 +#endif
1074 +
1075 " strex %2, %1, [%4]\n"
1076 " teq %2, #0\n"
1077 " bne 1b\n"
1078 -"2:"
1079 +"4:"
1080 +
1081 +#ifdef CONFIG_PAX_REFCOUNT
1082 + _ASM_EXTABLE(2b, 4b)
1083 +#endif
1084 +
1085 : "=&r" (oldval), "=&r" (newval), "=&r" (tmp), "+Qo" (v->counter)
1086 : "r" (&v->counter), "r" (u), "r" (a)
1087 : "cc");
1088 @@ -168,6 +309,28 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
1089 return oldval;
1090 }
1091
1092 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *ptr, int old, int new)
1093 +{
1094 + unsigned long oldval, res;
1095 +
1096 + smp_mb();
1097 +
1098 + do {
1099 + __asm__ __volatile__("@ atomic_cmpxchg_unchecked\n"
1100 + "ldrex %1, [%3]\n"
1101 + "mov %0, #0\n"
1102 + "teq %1, %4\n"
1103 + "strexeq %0, %5, [%3]\n"
1104 + : "=&r" (res), "=&r" (oldval), "+Qo" (ptr->counter)
1105 + : "r" (&ptr->counter), "Ir" (old), "r" (new)
1106 + : "cc");
1107 + } while (res);
1108 +
1109 + smp_mb();
1110 +
1111 + return oldval;
1112 +}
1113 +
1114 #else /* ARM_ARCH_6 */
1115
1116 #ifdef CONFIG_SMP
1117 @@ -186,7 +349,17 @@ static inline int atomic_add_return(int i, atomic_t *v)
1118
1119 return val;
1120 }
1121 +
1122 +static inline int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
1123 +{
1124 + return atomic_add_return(i, v);
1125 +}
1126 +
1127 #define atomic_add(i, v) (void) atomic_add_return(i, v)
1128 +static inline void atomic_add_unchecked(int i, atomic_unchecked_t *v)
1129 +{
1130 + (void) atomic_add_return(i, v);
1131 +}
1132
1133 static inline int atomic_sub_return(int i, atomic_t *v)
1134 {
1135 @@ -201,6 +374,10 @@ static inline int atomic_sub_return(int i, atomic_t *v)
1136 return val;
1137 }
1138 #define atomic_sub(i, v) (void) atomic_sub_return(i, v)
1139 +static inline void atomic_sub_unchecked(int i, atomic_unchecked_t *v)
1140 +{
1141 + (void) atomic_sub_return(i, v);
1142 +}
1143
1144 static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
1145 {
1146 @@ -216,6 +393,11 @@ static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
1147 return ret;
1148 }
1149
1150 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *v, int old, int new)
1151 +{
1152 + return atomic_cmpxchg(v, old, new);
1153 +}
1154 +
1155 static inline int __atomic_add_unless(atomic_t *v, int a, int u)
1156 {
1157 int c, old;
1158 @@ -229,13 +411,33 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
1159 #endif /* __LINUX_ARM_ARCH__ */
1160
1161 #define atomic_xchg(v, new) (xchg(&((v)->counter), new))
1162 +static inline int atomic_xchg_unchecked(atomic_unchecked_t *v, int new)
1163 +{
1164 + return xchg(&v->counter, new);
1165 +}
1166
1167 #define atomic_inc(v) atomic_add(1, v)
1168 +static inline void atomic_inc_unchecked(atomic_unchecked_t *v)
1169 +{
1170 + atomic_add_unchecked(1, v);
1171 +}
1172 #define atomic_dec(v) atomic_sub(1, v)
1173 +static inline void atomic_dec_unchecked(atomic_unchecked_t *v)
1174 +{
1175 + atomic_sub_unchecked(1, v);
1176 +}
1177
1178 #define atomic_inc_and_test(v) (atomic_add_return(1, v) == 0)
1179 +static inline int atomic_inc_and_test_unchecked(atomic_unchecked_t *v)
1180 +{
1181 + return atomic_add_return_unchecked(1, v) == 0;
1182 +}
1183 #define atomic_dec_and_test(v) (atomic_sub_return(1, v) == 0)
1184 #define atomic_inc_return(v) (atomic_add_return(1, v))
1185 +static inline int atomic_inc_return_unchecked(atomic_unchecked_t *v)
1186 +{
1187 + return atomic_add_return_unchecked(1, v);
1188 +}
1189 #define atomic_dec_return(v) (atomic_sub_return(1, v))
1190 #define atomic_sub_and_test(i, v) (atomic_sub_return(i, v) == 0)
1191
1192 @@ -251,6 +453,14 @@ typedef struct {
1193 long long counter;
1194 } atomic64_t;
1195
1196 +#ifdef CONFIG_PAX_REFCOUNT
1197 +typedef struct {
1198 + long long counter;
1199 +} atomic64_unchecked_t;
1200 +#else
1201 +typedef atomic64_t atomic64_unchecked_t;
1202 +#endif
1203 +
1204 #define ATOMIC64_INIT(i) { (i) }
1205
1206 #ifdef CONFIG_ARM_LPAE
1207 @@ -267,6 +477,19 @@ static inline long long atomic64_read(const atomic64_t *v)
1208 return result;
1209 }
1210
1211 +static inline long long atomic64_read_unchecked(const atomic64_unchecked_t *v)
1212 +{
1213 + long long result;
1214 +
1215 + __asm__ __volatile__("@ atomic64_read_unchecked\n"
1216 +" ldrd %0, %H0, [%1]"
1217 + : "=&r" (result)
1218 + : "r" (&v->counter), "Qo" (v->counter)
1219 + );
1220 +
1221 + return result;
1222 +}
1223 +
1224 static inline void atomic64_set(atomic64_t *v, long long i)
1225 {
1226 __asm__ __volatile__("@ atomic64_set\n"
1227 @@ -275,6 +498,15 @@ static inline void atomic64_set(atomic64_t *v, long long i)
1228 : "r" (&v->counter), "r" (i)
1229 );
1230 }
1231 +
1232 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long long i)
1233 +{
1234 + __asm__ __volatile__("@ atomic64_set_unchecked\n"
1235 +" strd %2, %H2, [%1]"
1236 + : "=Qo" (v->counter)
1237 + : "r" (&v->counter), "r" (i)
1238 + );
1239 +}
1240 #else
1241 static inline long long atomic64_read(const atomic64_t *v)
1242 {
1243 @@ -289,6 +521,19 @@ static inline long long atomic64_read(const atomic64_t *v)
1244 return result;
1245 }
1246
1247 +static inline long long atomic64_read_unchecked(const atomic64_unchecked_t *v)
1248 +{
1249 + long long result;
1250 +
1251 + __asm__ __volatile__("@ atomic64_read_unchecked\n"
1252 +" ldrexd %0, %H0, [%1]"
1253 + : "=&r" (result)
1254 + : "r" (&v->counter), "Qo" (v->counter)
1255 + );
1256 +
1257 + return result;
1258 +}
1259 +
1260 static inline void atomic64_set(atomic64_t *v, long long i)
1261 {
1262 long long tmp;
1263 @@ -303,6 +548,21 @@ static inline void atomic64_set(atomic64_t *v, long long i)
1264 : "r" (&v->counter), "r" (i)
1265 : "cc");
1266 }
1267 +
1268 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long long i)
1269 +{
1270 + long long tmp;
1271 +
1272 + prefetchw(&v->counter);
1273 + __asm__ __volatile__("@ atomic64_set_unchecked\n"
1274 +"1: ldrexd %0, %H0, [%2]\n"
1275 +" strexd %0, %3, %H3, [%2]\n"
1276 +" teq %0, #0\n"
1277 +" bne 1b"
1278 + : "=&r" (tmp), "=Qo" (v->counter)
1279 + : "r" (&v->counter), "r" (i)
1280 + : "cc");
1281 +}
1282 #endif
1283
1284 static inline void atomic64_add(long long i, atomic64_t *v)
1285 @@ -314,6 +574,37 @@ static inline void atomic64_add(long long i, atomic64_t *v)
1286 __asm__ __volatile__("@ atomic64_add\n"
1287 "1: ldrexd %0, %H0, [%3]\n"
1288 " adds %Q0, %Q0, %Q4\n"
1289 +" adcs %R0, %R0, %R4\n"
1290 +
1291 +#ifdef CONFIG_PAX_REFCOUNT
1292 +" bvc 3f\n"
1293 +"2: bkpt 0xf103\n"
1294 +"3:\n"
1295 +#endif
1296 +
1297 +" strexd %1, %0, %H0, [%3]\n"
1298 +" teq %1, #0\n"
1299 +" bne 1b"
1300 +
1301 +#ifdef CONFIG_PAX_REFCOUNT
1302 +"\n4:\n"
1303 + _ASM_EXTABLE(2b, 4b)
1304 +#endif
1305 +
1306 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1307 + : "r" (&v->counter), "r" (i)
1308 + : "cc");
1309 +}
1310 +
1311 +static inline void atomic64_add_unchecked(long long i, atomic64_unchecked_t *v)
1312 +{
1313 + long long result;
1314 + unsigned long tmp;
1315 +
1316 + prefetchw(&v->counter);
1317 + __asm__ __volatile__("@ atomic64_add_unchecked\n"
1318 +"1: ldrexd %0, %H0, [%3]\n"
1319 +" adds %Q0, %Q0, %Q4\n"
1320 " adc %R0, %R0, %R4\n"
1321 " strexd %1, %0, %H0, [%3]\n"
1322 " teq %1, #0\n"
1323 @@ -334,6 +625,44 @@ static inline long long atomic64_add_return(long long i, atomic64_t *v)
1324 __asm__ __volatile__("@ atomic64_add_return\n"
1325 "1: ldrexd %0, %H0, [%3]\n"
1326 " adds %Q0, %Q0, %Q4\n"
1327 +" adcs %R0, %R0, %R4\n"
1328 +
1329 +#ifdef CONFIG_PAX_REFCOUNT
1330 +" bvc 3f\n"
1331 +" mov %0, %1\n"
1332 +" mov %H0, %H1\n"
1333 +"2: bkpt 0xf103\n"
1334 +"3:\n"
1335 +#endif
1336 +
1337 +" strexd %1, %0, %H0, [%3]\n"
1338 +" teq %1, #0\n"
1339 +" bne 1b"
1340 +
1341 +#ifdef CONFIG_PAX_REFCOUNT
1342 +"\n4:\n"
1343 + _ASM_EXTABLE(2b, 4b)
1344 +#endif
1345 +
1346 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1347 + : "r" (&v->counter), "r" (i)
1348 + : "cc");
1349 +
1350 + smp_mb();
1351 +
1352 + return result;
1353 +}
1354 +
1355 +static inline long long atomic64_add_return_unchecked(long long i, atomic64_unchecked_t *v)
1356 +{
1357 + long long result;
1358 + unsigned long tmp;
1359 +
1360 + smp_mb();
1361 +
1362 + __asm__ __volatile__("@ atomic64_add_return_unchecked\n"
1363 +"1: ldrexd %0, %H0, [%3]\n"
1364 +" adds %Q0, %Q0, %Q4\n"
1365 " adc %R0, %R0, %R4\n"
1366 " strexd %1, %0, %H0, [%3]\n"
1367 " teq %1, #0\n"
1368 @@ -356,6 +685,37 @@ static inline void atomic64_sub(long long i, atomic64_t *v)
1369 __asm__ __volatile__("@ atomic64_sub\n"
1370 "1: ldrexd %0, %H0, [%3]\n"
1371 " subs %Q0, %Q0, %Q4\n"
1372 +" sbcs %R0, %R0, %R4\n"
1373 +
1374 +#ifdef CONFIG_PAX_REFCOUNT
1375 +" bvc 3f\n"
1376 +"2: bkpt 0xf103\n"
1377 +"3:\n"
1378 +#endif
1379 +
1380 +" strexd %1, %0, %H0, [%3]\n"
1381 +" teq %1, #0\n"
1382 +" bne 1b"
1383 +
1384 +#ifdef CONFIG_PAX_REFCOUNT
1385 +"\n4:\n"
1386 + _ASM_EXTABLE(2b, 4b)
1387 +#endif
1388 +
1389 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1390 + : "r" (&v->counter), "r" (i)
1391 + : "cc");
1392 +}
1393 +
1394 +static inline void atomic64_sub_unchecked(long long i, atomic64_unchecked_t *v)
1395 +{
1396 + long long result;
1397 + unsigned long tmp;
1398 +
1399 + prefetchw(&v->counter);
1400 + __asm__ __volatile__("@ atomic64_sub_unchecked\n"
1401 +"1: ldrexd %0, %H0, [%3]\n"
1402 +" subs %Q0, %Q0, %Q4\n"
1403 " sbc %R0, %R0, %R4\n"
1404 " strexd %1, %0, %H0, [%3]\n"
1405 " teq %1, #0\n"
1406 @@ -376,16 +736,29 @@ static inline long long atomic64_sub_return(long long i, atomic64_t *v)
1407 __asm__ __volatile__("@ atomic64_sub_return\n"
1408 "1: ldrexd %0, %H0, [%3]\n"
1409 " subs %Q0, %Q0, %Q4\n"
1410 -" sbc %R0, %R0, %R4\n"
1411 +" sbcs %R0, %R0, %R4\n"
1412 +
1413 +#ifdef CONFIG_PAX_REFCOUNT
1414 +" bvc 3f\n"
1415 +" mov %0, %1\n"
1416 +" mov %H0, %H1\n"
1417 +"2: bkpt 0xf103\n"
1418 +"3:\n"
1419 +#endif
1420 +
1421 " strexd %1, %0, %H0, [%3]\n"
1422 " teq %1, #0\n"
1423 " bne 1b"
1424 +
1425 +#ifdef CONFIG_PAX_REFCOUNT
1426 +"\n4:\n"
1427 + _ASM_EXTABLE(2b, 4b)
1428 +#endif
1429 +
1430 : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1431 : "r" (&v->counter), "r" (i)
1432 : "cc");
1433
1434 - smp_mb();
1435 -
1436 return result;
1437 }
1438
1439 @@ -415,6 +788,31 @@ static inline long long atomic64_cmpxchg(atomic64_t *ptr, long long old,
1440 return oldval;
1441 }
1442
1443 +static inline long long atomic64_cmpxchg_unchecked(atomic64_unchecked_t *ptr, long long old,
1444 + long long new)
1445 +{
1446 + long long oldval;
1447 + unsigned long res;
1448 +
1449 + smp_mb();
1450 +
1451 + do {
1452 + __asm__ __volatile__("@ atomic64_cmpxchg_unchecked\n"
1453 + "ldrexd %1, %H1, [%3]\n"
1454 + "mov %0, #0\n"
1455 + "teq %1, %4\n"
1456 + "teqeq %H1, %H4\n"
1457 + "strexdeq %0, %5, %H5, [%3]"
1458 + : "=&r" (res), "=&r" (oldval), "+Qo" (ptr->counter)
1459 + : "r" (&ptr->counter), "r" (old), "r" (new)
1460 + : "cc");
1461 + } while (res);
1462 +
1463 + smp_mb();
1464 +
1465 + return oldval;
1466 +}
1467 +
1468 static inline long long atomic64_xchg(atomic64_t *ptr, long long new)
1469 {
1470 long long result;
1471 @@ -440,21 +838,35 @@ static inline long long atomic64_xchg(atomic64_t *ptr, long long new)
1472 static inline long long atomic64_dec_if_positive(atomic64_t *v)
1473 {
1474 long long result;
1475 - unsigned long tmp;
1476 + u64 tmp;
1477
1478 smp_mb();
1479 prefetchw(&v->counter);
1480
1481 __asm__ __volatile__("@ atomic64_dec_if_positive\n"
1482 -"1: ldrexd %0, %H0, [%3]\n"
1483 -" subs %Q0, %Q0, #1\n"
1484 -" sbc %R0, %R0, #0\n"
1485 +"1: ldrexd %1, %H1, [%3]\n"
1486 +" subs %Q0, %Q1, #1\n"
1487 +" sbcs %R0, %R1, #0\n"
1488 +
1489 +#ifdef CONFIG_PAX_REFCOUNT
1490 +" bvc 3f\n"
1491 +" mov %Q0, %Q1\n"
1492 +" mov %R0, %R1\n"
1493 +"2: bkpt 0xf103\n"
1494 +"3:\n"
1495 +#endif
1496 +
1497 " teq %R0, #0\n"
1498 -" bmi 2f\n"
1499 +" bmi 4f\n"
1500 " strexd %1, %0, %H0, [%3]\n"
1501 " teq %1, #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" (result), "=&r" (tmp), "+Qo" (v->counter)
1511 : "r" (&v->counter)
1512 : "cc");
1513 @@ -478,13 +890,25 @@ static inline int atomic64_add_unless(atomic64_t *v, long long a, long long u)
1514 " teq %0, %5\n"
1515 " teqeq %H0, %H5\n"
1516 " moveq %1, #0\n"
1517 -" beq 2f\n"
1518 +" beq 4f\n"
1519 " adds %Q0, %Q0, %Q6\n"
1520 -" adc %R0, %R0, %R6\n"
1521 +" adcs %R0, %R0, %R6\n"
1522 +
1523 +#ifdef CONFIG_PAX_REFCOUNT
1524 +" bvc 3f\n"
1525 +"2: bkpt 0xf103\n"
1526 +"3:\n"
1527 +#endif
1528 +
1529 " strexd %2, %0, %H0, [%4]\n"
1530 " teq %2, #0\n"
1531 " bne 1b\n"
1532 -"2:"
1533 +"4:\n"
1534 +
1535 +#ifdef CONFIG_PAX_REFCOUNT
1536 + _ASM_EXTABLE(2b, 4b)
1537 +#endif
1538 +
1539 : "=&r" (val), "+r" (ret), "=&r" (tmp), "+Qo" (v->counter)
1540 : "r" (&v->counter), "r" (u), "r" (a)
1541 : "cc");
1542 @@ -497,10 +921,13 @@ static inline int atomic64_add_unless(atomic64_t *v, long long a, long long u)
1543
1544 #define atomic64_add_negative(a, v) (atomic64_add_return((a), (v)) < 0)
1545 #define atomic64_inc(v) atomic64_add(1LL, (v))
1546 +#define atomic64_inc_unchecked(v) atomic64_add_unchecked(1LL, (v))
1547 #define atomic64_inc_return(v) atomic64_add_return(1LL, (v))
1548 +#define atomic64_inc_return_unchecked(v) atomic64_add_return_unchecked(1LL, (v))
1549 #define atomic64_inc_and_test(v) (atomic64_inc_return(v) == 0)
1550 #define atomic64_sub_and_test(a, v) (atomic64_sub_return((a), (v)) == 0)
1551 #define atomic64_dec(v) atomic64_sub(1LL, (v))
1552 +#define atomic64_dec_unchecked(v) atomic64_sub_unchecked(1LL, (v))
1553 #define atomic64_dec_return(v) atomic64_sub_return(1LL, (v))
1554 #define atomic64_dec_and_test(v) (atomic64_dec_return((v)) == 0)
1555 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1LL, 0LL)
1556 diff --git a/arch/arm/include/asm/barrier.h b/arch/arm/include/asm/barrier.h
1557 index 2f59f74..1594659 100644
1558 --- a/arch/arm/include/asm/barrier.h
1559 +++ b/arch/arm/include/asm/barrier.h
1560 @@ -63,7 +63,7 @@
1561 do { \
1562 compiletime_assert_atomic_type(*p); \
1563 smp_mb(); \
1564 - ACCESS_ONCE(*p) = (v); \
1565 + ACCESS_ONCE_RW(*p) = (v); \
1566 } while (0)
1567
1568 #define smp_load_acquire(p) \
1569 diff --git a/arch/arm/include/asm/cache.h b/arch/arm/include/asm/cache.h
1570 index 75fe66b..ba3dee4 100644
1571 --- a/arch/arm/include/asm/cache.h
1572 +++ b/arch/arm/include/asm/cache.h
1573 @@ -4,8 +4,10 @@
1574 #ifndef __ASMARM_CACHE_H
1575 #define __ASMARM_CACHE_H
1576
1577 +#include <linux/const.h>
1578 +
1579 #define L1_CACHE_SHIFT CONFIG_ARM_L1_CACHE_SHIFT
1580 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
1581 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
1582
1583 /*
1584 * Memory returned by kmalloc() may be used for DMA, so we must make
1585 @@ -24,5 +26,6 @@
1586 #endif
1587
1588 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
1589 +#define __read_only __attribute__ ((__section__(".data..read_only")))
1590
1591 #endif
1592 diff --git a/arch/arm/include/asm/cacheflush.h b/arch/arm/include/asm/cacheflush.h
1593 index 8b8b616..d973d24 100644
1594 --- a/arch/arm/include/asm/cacheflush.h
1595 +++ b/arch/arm/include/asm/cacheflush.h
1596 @@ -116,7 +116,7 @@ struct cpu_cache_fns {
1597 void (*dma_unmap_area)(const void *, size_t, int);
1598
1599 void (*dma_flush_range)(const void *, const void *);
1600 -};
1601 +} __no_const;
1602
1603 /*
1604 * Select the calling method
1605 diff --git a/arch/arm/include/asm/checksum.h b/arch/arm/include/asm/checksum.h
1606 index 5233151..87a71fa 100644
1607 --- a/arch/arm/include/asm/checksum.h
1608 +++ b/arch/arm/include/asm/checksum.h
1609 @@ -37,7 +37,19 @@ __wsum
1610 csum_partial_copy_nocheck(const void *src, void *dst, int len, __wsum sum);
1611
1612 __wsum
1613 -csum_partial_copy_from_user(const void __user *src, void *dst, int len, __wsum sum, int *err_ptr);
1614 +__csum_partial_copy_from_user(const void __user *src, void *dst, int len, __wsum sum, int *err_ptr);
1615 +
1616 +static inline __wsum
1617 +csum_partial_copy_from_user(const void __user *src, void *dst, int len, __wsum sum, int *err_ptr)
1618 +{
1619 + __wsum ret;
1620 + pax_open_userland();
1621 + ret = __csum_partial_copy_from_user(src, dst, len, sum, err_ptr);
1622 + pax_close_userland();
1623 + return ret;
1624 +}
1625 +
1626 +
1627
1628 /*
1629 * Fold a partial checksum without adding pseudo headers
1630 diff --git a/arch/arm/include/asm/cmpxchg.h b/arch/arm/include/asm/cmpxchg.h
1631 index abb2c37..96db950 100644
1632 --- a/arch/arm/include/asm/cmpxchg.h
1633 +++ b/arch/arm/include/asm/cmpxchg.h
1634 @@ -104,6 +104,8 @@ static inline unsigned long __xchg(unsigned long x, volatile void *ptr, int size
1635
1636 #define xchg(ptr,x) \
1637 ((__typeof__(*(ptr)))__xchg((unsigned long)(x),(ptr),sizeof(*(ptr))))
1638 +#define xchg_unchecked(ptr,x) \
1639 + ((__typeof__(*(ptr)))__xchg((unsigned long)(x),(ptr),sizeof(*(ptr))))
1640
1641 #include <asm-generic/cmpxchg-local.h>
1642
1643 diff --git a/arch/arm/include/asm/domain.h b/arch/arm/include/asm/domain.h
1644 index 6ddbe44..b5e38b1 100644
1645 --- a/arch/arm/include/asm/domain.h
1646 +++ b/arch/arm/include/asm/domain.h
1647 @@ -48,18 +48,37 @@
1648 * Domain types
1649 */
1650 #define DOMAIN_NOACCESS 0
1651 -#define DOMAIN_CLIENT 1
1652 #ifdef CONFIG_CPU_USE_DOMAINS
1653 +#define DOMAIN_USERCLIENT 1
1654 +#define DOMAIN_KERNELCLIENT 1
1655 #define DOMAIN_MANAGER 3
1656 +#define DOMAIN_VECTORS DOMAIN_USER
1657 #else
1658 +
1659 +#ifdef CONFIG_PAX_KERNEXEC
1660 #define DOMAIN_MANAGER 1
1661 +#define DOMAIN_KERNEXEC 3
1662 +#else
1663 +#define DOMAIN_MANAGER 1
1664 +#endif
1665 +
1666 +#ifdef CONFIG_PAX_MEMORY_UDEREF
1667 +#define DOMAIN_USERCLIENT 0
1668 +#define DOMAIN_UDEREF 1
1669 +#define DOMAIN_VECTORS DOMAIN_KERNEL
1670 +#else
1671 +#define DOMAIN_USERCLIENT 1
1672 +#define DOMAIN_VECTORS DOMAIN_USER
1673 +#endif
1674 +#define DOMAIN_KERNELCLIENT 1
1675 +
1676 #endif
1677
1678 #define domain_val(dom,type) ((type) << (2*(dom)))
1679
1680 #ifndef __ASSEMBLY__
1681
1682 -#ifdef CONFIG_CPU_USE_DOMAINS
1683 +#if defined(CONFIG_CPU_USE_DOMAINS) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
1684 static inline void set_domain(unsigned val)
1685 {
1686 asm volatile(
1687 @@ -68,15 +87,7 @@ static inline void set_domain(unsigned val)
1688 isb();
1689 }
1690
1691 -#define modify_domain(dom,type) \
1692 - do { \
1693 - struct thread_info *thread = current_thread_info(); \
1694 - unsigned int domain = thread->cpu_domain; \
1695 - domain &= ~domain_val(dom, DOMAIN_MANAGER); \
1696 - thread->cpu_domain = domain | domain_val(dom, type); \
1697 - set_domain(thread->cpu_domain); \
1698 - } while (0)
1699 -
1700 +extern void modify_domain(unsigned int dom, unsigned int type);
1701 #else
1702 static inline void set_domain(unsigned val) { }
1703 static inline void modify_domain(unsigned dom, unsigned type) { }
1704 diff --git a/arch/arm/include/asm/elf.h b/arch/arm/include/asm/elf.h
1705 index f4b46d3..abc9b2b 100644
1706 --- a/arch/arm/include/asm/elf.h
1707 +++ b/arch/arm/include/asm/elf.h
1708 @@ -114,7 +114,14 @@ int dump_task_regs(struct task_struct *t, elf_gregset_t *elfregs);
1709 the loader. We need to make sure that it is out of the way of the program
1710 that it will "exec", and that there is sufficient room for the brk. */
1711
1712 -#define ELF_ET_DYN_BASE (2 * TASK_SIZE / 3)
1713 +#define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
1714 +
1715 +#ifdef CONFIG_PAX_ASLR
1716 +#define PAX_ELF_ET_DYN_BASE 0x00008000UL
1717 +
1718 +#define PAX_DELTA_MMAP_LEN ((current->personality == PER_LINUX_32BIT) ? 16 : 10)
1719 +#define PAX_DELTA_STACK_LEN ((current->personality == PER_LINUX_32BIT) ? 16 : 10)
1720 +#endif
1721
1722 /* When the program starts, a1 contains a pointer to a function to be
1723 registered with atexit, as per the SVR4 ABI. A value of 0 means we
1724 @@ -124,10 +131,6 @@ int dump_task_regs(struct task_struct *t, elf_gregset_t *elfregs);
1725 extern void elf_set_personality(const struct elf32_hdr *);
1726 #define SET_PERSONALITY(ex) elf_set_personality(&(ex))
1727
1728 -struct mm_struct;
1729 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
1730 -#define arch_randomize_brk arch_randomize_brk
1731 -
1732 #ifdef CONFIG_MMU
1733 #define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1
1734 struct linux_binprm;
1735 diff --git a/arch/arm/include/asm/fncpy.h b/arch/arm/include/asm/fncpy.h
1736 index de53547..52b9a28 100644
1737 --- a/arch/arm/include/asm/fncpy.h
1738 +++ b/arch/arm/include/asm/fncpy.h
1739 @@ -81,7 +81,9 @@
1740 BUG_ON((uintptr_t)(dest_buf) & (FNCPY_ALIGN - 1) || \
1741 (__funcp_address & ~(uintptr_t)1 & (FNCPY_ALIGN - 1))); \
1742 \
1743 + pax_open_kernel(); \
1744 memcpy(dest_buf, (void const *)(__funcp_address & ~1), size); \
1745 + pax_close_kernel(); \
1746 flush_icache_range((unsigned long)(dest_buf), \
1747 (unsigned long)(dest_buf) + (size)); \
1748 \
1749 diff --git a/arch/arm/include/asm/futex.h b/arch/arm/include/asm/futex.h
1750 index 53e69da..3fdc896 100644
1751 --- a/arch/arm/include/asm/futex.h
1752 +++ b/arch/arm/include/asm/futex.h
1753 @@ -46,6 +46,8 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
1754 if (!access_ok(VERIFY_WRITE, uaddr, sizeof(u32)))
1755 return -EFAULT;
1756
1757 + pax_open_userland();
1758 +
1759 smp_mb();
1760 /* Prefetching cannot fault */
1761 prefetchw(uaddr);
1762 @@ -63,6 +65,8 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
1763 : "cc", "memory");
1764 smp_mb();
1765
1766 + pax_close_userland();
1767 +
1768 *uval = val;
1769 return ret;
1770 }
1771 @@ -93,6 +97,8 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
1772 if (!access_ok(VERIFY_WRITE, uaddr, sizeof(u32)))
1773 return -EFAULT;
1774
1775 + pax_open_userland();
1776 +
1777 __asm__ __volatile__("@futex_atomic_cmpxchg_inatomic\n"
1778 "1: " TUSER(ldr) " %1, [%4]\n"
1779 " teq %1, %2\n"
1780 @@ -103,6 +109,8 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
1781 : "r" (oldval), "r" (newval), "r" (uaddr), "Ir" (-EFAULT)
1782 : "cc", "memory");
1783
1784 + pax_close_userland();
1785 +
1786 *uval = val;
1787 return ret;
1788 }
1789 @@ -125,6 +133,7 @@ futex_atomic_op_inuser (int encoded_op, u32 __user *uaddr)
1790 return -EFAULT;
1791
1792 pagefault_disable(); /* implies preempt_disable() */
1793 + pax_open_userland();
1794
1795 switch (op) {
1796 case FUTEX_OP_SET:
1797 @@ -146,6 +155,7 @@ futex_atomic_op_inuser (int encoded_op, u32 __user *uaddr)
1798 ret = -ENOSYS;
1799 }
1800
1801 + pax_close_userland();
1802 pagefault_enable(); /* subsumes preempt_enable() */
1803
1804 if (!ret) {
1805 diff --git a/arch/arm/include/asm/kmap_types.h b/arch/arm/include/asm/kmap_types.h
1806 index 83eb2f7..ed77159 100644
1807 --- a/arch/arm/include/asm/kmap_types.h
1808 +++ b/arch/arm/include/asm/kmap_types.h
1809 @@ -4,6 +4,6 @@
1810 /*
1811 * This is the "bare minimum". AIO seems to require this.
1812 */
1813 -#define KM_TYPE_NR 16
1814 +#define KM_TYPE_NR 17
1815
1816 #endif
1817 diff --git a/arch/arm/include/asm/mach/dma.h b/arch/arm/include/asm/mach/dma.h
1818 index 9e614a1..3302cca 100644
1819 --- a/arch/arm/include/asm/mach/dma.h
1820 +++ b/arch/arm/include/asm/mach/dma.h
1821 @@ -22,7 +22,7 @@ struct dma_ops {
1822 int (*residue)(unsigned int, dma_t *); /* optional */
1823 int (*setspeed)(unsigned int, dma_t *, int); /* optional */
1824 const char *type;
1825 -};
1826 +} __do_const;
1827
1828 struct dma_struct {
1829 void *addr; /* single DMA address */
1830 diff --git a/arch/arm/include/asm/mach/map.h b/arch/arm/include/asm/mach/map.h
1831 index f98c7f3..e5c626d 100644
1832 --- a/arch/arm/include/asm/mach/map.h
1833 +++ b/arch/arm/include/asm/mach/map.h
1834 @@ -23,17 +23,19 @@ struct map_desc {
1835
1836 /* types 0-3 are defined in asm/io.h */
1837 enum {
1838 - MT_UNCACHED = 4,
1839 - MT_CACHECLEAN,
1840 - MT_MINICLEAN,
1841 + MT_UNCACHED_RW = 4,
1842 + MT_CACHECLEAN_RO,
1843 + MT_MINICLEAN_RO,
1844 MT_LOW_VECTORS,
1845 MT_HIGH_VECTORS,
1846 - MT_MEMORY_RWX,
1847 + __MT_MEMORY_RWX,
1848 MT_MEMORY_RW,
1849 - MT_ROM,
1850 - MT_MEMORY_RWX_NONCACHED,
1851 + MT_MEMORY_RX,
1852 + MT_ROM_RX,
1853 + MT_MEMORY_RW_NONCACHED,
1854 + MT_MEMORY_RX_NONCACHED,
1855 MT_MEMORY_RW_DTCM,
1856 - MT_MEMORY_RWX_ITCM,
1857 + MT_MEMORY_RX_ITCM,
1858 MT_MEMORY_RW_SO,
1859 MT_MEMORY_DMA_READY,
1860 };
1861 diff --git a/arch/arm/include/asm/outercache.h b/arch/arm/include/asm/outercache.h
1862 index f94784f..9a09a4a 100644
1863 --- a/arch/arm/include/asm/outercache.h
1864 +++ b/arch/arm/include/asm/outercache.h
1865 @@ -35,7 +35,7 @@ struct outer_cache_fns {
1866 #endif
1867 void (*set_debug)(unsigned long);
1868 void (*resume)(void);
1869 -};
1870 +} __no_const;
1871
1872 extern struct outer_cache_fns outer_cache;
1873
1874 diff --git a/arch/arm/include/asm/page.h b/arch/arm/include/asm/page.h
1875 index 4355f0e..cd9168e 100644
1876 --- a/arch/arm/include/asm/page.h
1877 +++ b/arch/arm/include/asm/page.h
1878 @@ -23,6 +23,7 @@
1879
1880 #else
1881
1882 +#include <linux/compiler.h>
1883 #include <asm/glue.h>
1884
1885 /*
1886 @@ -114,7 +115,7 @@ struct cpu_user_fns {
1887 void (*cpu_clear_user_highpage)(struct page *page, unsigned long vaddr);
1888 void (*cpu_copy_user_highpage)(struct page *to, struct page *from,
1889 unsigned long vaddr, struct vm_area_struct *vma);
1890 -};
1891 +} __no_const;
1892
1893 #ifdef MULTI_USER
1894 extern struct cpu_user_fns cpu_user;
1895 diff --git a/arch/arm/include/asm/pgalloc.h b/arch/arm/include/asm/pgalloc.h
1896 index 78a7793..e3dc06c 100644
1897 --- a/arch/arm/include/asm/pgalloc.h
1898 +++ b/arch/arm/include/asm/pgalloc.h
1899 @@ -17,6 +17,7 @@
1900 #include <asm/processor.h>
1901 #include <asm/cacheflush.h>
1902 #include <asm/tlbflush.h>
1903 +#include <asm/system_info.h>
1904
1905 #define check_pgt_cache() do { } while (0)
1906
1907 @@ -43,6 +44,11 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
1908 set_pud(pud, __pud(__pa(pmd) | PMD_TYPE_TABLE));
1909 }
1910
1911 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
1912 +{
1913 + pud_populate(mm, pud, pmd);
1914 +}
1915 +
1916 #else /* !CONFIG_ARM_LPAE */
1917
1918 /*
1919 @@ -51,6 +57,7 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
1920 #define pmd_alloc_one(mm,addr) ({ BUG(); ((pmd_t *)2); })
1921 #define pmd_free(mm, pmd) do { } while (0)
1922 #define pud_populate(mm,pmd,pte) BUG()
1923 +#define pud_populate_kernel(mm,pmd,pte) BUG()
1924
1925 #endif /* CONFIG_ARM_LPAE */
1926
1927 @@ -128,6 +135,19 @@ static inline void pte_free(struct mm_struct *mm, pgtable_t pte)
1928 __free_page(pte);
1929 }
1930
1931 +static inline void __section_update(pmd_t *pmdp, unsigned long addr, pmdval_t prot)
1932 +{
1933 +#ifdef CONFIG_ARM_LPAE
1934 + pmdp[0] = __pmd(pmd_val(pmdp[0]) | prot);
1935 +#else
1936 + if (addr & SECTION_SIZE)
1937 + pmdp[1] = __pmd(pmd_val(pmdp[1]) | prot);
1938 + else
1939 + pmdp[0] = __pmd(pmd_val(pmdp[0]) | prot);
1940 +#endif
1941 + flush_pmd_entry(pmdp);
1942 +}
1943 +
1944 static inline void __pmd_populate(pmd_t *pmdp, phys_addr_t pte,
1945 pmdval_t prot)
1946 {
1947 @@ -157,7 +177,7 @@ pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmdp, pte_t *ptep)
1948 static inline void
1949 pmd_populate(struct mm_struct *mm, pmd_t *pmdp, pgtable_t ptep)
1950 {
1951 - __pmd_populate(pmdp, page_to_phys(ptep), _PAGE_USER_TABLE);
1952 + __pmd_populate(pmdp, page_to_phys(ptep), _PAGE_USER_TABLE | __supported_pmd_mask);
1953 }
1954 #define pmd_pgtable(pmd) pmd_page(pmd)
1955
1956 diff --git a/arch/arm/include/asm/pgtable-2level-hwdef.h b/arch/arm/include/asm/pgtable-2level-hwdef.h
1957 index 5cfba15..f415e1a 100644
1958 --- a/arch/arm/include/asm/pgtable-2level-hwdef.h
1959 +++ b/arch/arm/include/asm/pgtable-2level-hwdef.h
1960 @@ -20,12 +20,15 @@
1961 #define PMD_TYPE_FAULT (_AT(pmdval_t, 0) << 0)
1962 #define PMD_TYPE_TABLE (_AT(pmdval_t, 1) << 0)
1963 #define PMD_TYPE_SECT (_AT(pmdval_t, 2) << 0)
1964 +#define PMD_PXNTABLE (_AT(pmdval_t, 1) << 2) /* v7 */
1965 #define PMD_BIT4 (_AT(pmdval_t, 1) << 4)
1966 #define PMD_DOMAIN(x) (_AT(pmdval_t, (x)) << 5)
1967 #define PMD_PROTECTION (_AT(pmdval_t, 1) << 9) /* v5 */
1968 +
1969 /*
1970 * - section
1971 */
1972 +#define PMD_SECT_PXN (_AT(pmdval_t, 1) << 0) /* v7 */
1973 #define PMD_SECT_BUFFERABLE (_AT(pmdval_t, 1) << 2)
1974 #define PMD_SECT_CACHEABLE (_AT(pmdval_t, 1) << 3)
1975 #define PMD_SECT_XN (_AT(pmdval_t, 1) << 4) /* v6 */
1976 @@ -37,6 +40,7 @@
1977 #define PMD_SECT_nG (_AT(pmdval_t, 1) << 17) /* v6 */
1978 #define PMD_SECT_SUPER (_AT(pmdval_t, 1) << 18) /* v6 */
1979 #define PMD_SECT_AF (_AT(pmdval_t, 0))
1980 +#define PMD_SECT_RDONLY (_AT(pmdval_t, 0))
1981
1982 #define PMD_SECT_UNCACHED (_AT(pmdval_t, 0))
1983 #define PMD_SECT_BUFFERED (PMD_SECT_BUFFERABLE)
1984 @@ -66,6 +70,7 @@
1985 * - extended small page/tiny page
1986 */
1987 #define PTE_EXT_XN (_AT(pteval_t, 1) << 0) /* v6 */
1988 +#define PTE_EXT_PXN (_AT(pteval_t, 1) << 2) /* v7 */
1989 #define PTE_EXT_AP_MASK (_AT(pteval_t, 3) << 4)
1990 #define PTE_EXT_AP0 (_AT(pteval_t, 1) << 4)
1991 #define PTE_EXT_AP1 (_AT(pteval_t, 2) << 4)
1992 diff --git a/arch/arm/include/asm/pgtable-2level.h b/arch/arm/include/asm/pgtable-2level.h
1993 index 219ac88..73ec32a 100644
1994 --- a/arch/arm/include/asm/pgtable-2level.h
1995 +++ b/arch/arm/include/asm/pgtable-2level.h
1996 @@ -126,6 +126,9 @@
1997 #define L_PTE_SHARED (_AT(pteval_t, 1) << 10) /* shared(v6), coherent(xsc3) */
1998 #define L_PTE_NONE (_AT(pteval_t, 1) << 11)
1999
2000 +/* Two-level page tables only have PXN in the PGD, not in the PTE. */
2001 +#define L_PTE_PXN (_AT(pteval_t, 0))
2002 +
2003 /*
2004 * These are the memory types, defined to be compatible with
2005 * pre-ARMv6 CPUs cacheable and bufferable bits: XXCB
2006 diff --git a/arch/arm/include/asm/pgtable-3level-hwdef.h b/arch/arm/include/asm/pgtable-3level-hwdef.h
2007 index 626989f..9d67a33 100644
2008 --- a/arch/arm/include/asm/pgtable-3level-hwdef.h
2009 +++ b/arch/arm/include/asm/pgtable-3level-hwdef.h
2010 @@ -75,6 +75,7 @@
2011 #define PTE_EXT_SHARED (_AT(pteval_t, 3) << 8) /* SH[1:0], inner shareable */
2012 #define PTE_EXT_AF (_AT(pteval_t, 1) << 10) /* Access Flag */
2013 #define PTE_EXT_NG (_AT(pteval_t, 1) << 11) /* nG */
2014 +#define PTE_EXT_PXN (_AT(pteval_t, 1) << 53) /* PXN */
2015 #define PTE_EXT_XN (_AT(pteval_t, 1) << 54) /* XN */
2016
2017 /*
2018 diff --git a/arch/arm/include/asm/pgtable-3level.h b/arch/arm/include/asm/pgtable-3level.h
2019 index 85c60ad..b0bbd7e 100644
2020 --- a/arch/arm/include/asm/pgtable-3level.h
2021 +++ b/arch/arm/include/asm/pgtable-3level.h
2022 @@ -82,6 +82,7 @@
2023 #define L_PTE_RDONLY (_AT(pteval_t, 1) << 7) /* AP[2] */
2024 #define L_PTE_SHARED (_AT(pteval_t, 3) << 8) /* SH[1:0], inner shareable */
2025 #define L_PTE_YOUNG (_AT(pteval_t, 1) << 10) /* AF */
2026 +#define L_PTE_PXN (_AT(pteval_t, 1) << 53) /* PXN */
2027 #define L_PTE_XN (_AT(pteval_t, 1) << 54) /* XN */
2028 #define L_PTE_DIRTY (_AT(pteval_t, 1) << 55) /* unused */
2029 #define L_PTE_SPECIAL (_AT(pteval_t, 1) << 56) /* unused */
2030 @@ -95,6 +96,7 @@
2031 /*
2032 * To be used in assembly code with the upper page attributes.
2033 */
2034 +#define L_PTE_PXN_HIGH (1 << (53 - 32))
2035 #define L_PTE_XN_HIGH (1 << (54 - 32))
2036 #define L_PTE_DIRTY_HIGH (1 << (55 - 32))
2037
2038 diff --git a/arch/arm/include/asm/pgtable.h b/arch/arm/include/asm/pgtable.h
2039 index 5478e5d..f5b5cb3 100644
2040 --- a/arch/arm/include/asm/pgtable.h
2041 +++ b/arch/arm/include/asm/pgtable.h
2042 @@ -33,6 +33,9 @@
2043 #include <asm/pgtable-2level.h>
2044 #endif
2045
2046 +#define ktla_ktva(addr) (addr)
2047 +#define ktva_ktla(addr) (addr)
2048 +
2049 /*
2050 * Just any arbitrary offset to the start of the vmalloc VM area: the
2051 * current 8MB value just means that there will be a 8MB "hole" after the
2052 @@ -48,6 +51,9 @@
2053 #define LIBRARY_TEXT_START 0x0c000000
2054
2055 #ifndef __ASSEMBLY__
2056 +extern pteval_t __supported_pte_mask;
2057 +extern pmdval_t __supported_pmd_mask;
2058 +
2059 extern void __pte_error(const char *file, int line, pte_t);
2060 extern void __pmd_error(const char *file, int line, pmd_t);
2061 extern void __pgd_error(const char *file, int line, pgd_t);
2062 @@ -56,6 +62,48 @@ extern void __pgd_error(const char *file, int line, pgd_t);
2063 #define pmd_ERROR(pmd) __pmd_error(__FILE__, __LINE__, pmd)
2064 #define pgd_ERROR(pgd) __pgd_error(__FILE__, __LINE__, pgd)
2065
2066 +#define __HAVE_ARCH_PAX_OPEN_KERNEL
2067 +#define __HAVE_ARCH_PAX_CLOSE_KERNEL
2068 +
2069 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2070 +#include <asm/domain.h>
2071 +#include <linux/thread_info.h>
2072 +#include <linux/preempt.h>
2073 +
2074 +static inline int test_domain(int domain, int domaintype)
2075 +{
2076 + return ((current_thread_info()->cpu_domain) & domain_val(domain, 3)) == domain_val(domain, domaintype);
2077 +}
2078 +#endif
2079 +
2080 +#ifdef CONFIG_PAX_KERNEXEC
2081 +static inline unsigned long pax_open_kernel(void) {
2082 +#ifdef CONFIG_ARM_LPAE
2083 + /* TODO */
2084 +#else
2085 + preempt_disable();
2086 + BUG_ON(test_domain(DOMAIN_KERNEL, DOMAIN_KERNEXEC));
2087 + modify_domain(DOMAIN_KERNEL, DOMAIN_KERNEXEC);
2088 +#endif
2089 + return 0;
2090 +}
2091 +
2092 +static inline unsigned long pax_close_kernel(void) {
2093 +#ifdef CONFIG_ARM_LPAE
2094 + /* TODO */
2095 +#else
2096 + BUG_ON(test_domain(DOMAIN_KERNEL, DOMAIN_MANAGER));
2097 + /* DOMAIN_MANAGER = "client" under KERNEXEC */
2098 + modify_domain(DOMAIN_KERNEL, DOMAIN_MANAGER);
2099 + preempt_enable_no_resched();
2100 +#endif
2101 + return 0;
2102 +}
2103 +#else
2104 +static inline unsigned long pax_open_kernel(void) { return 0; }
2105 +static inline unsigned long pax_close_kernel(void) { return 0; }
2106 +#endif
2107 +
2108 /*
2109 * This is the lowest virtual address we can permit any user space
2110 * mapping to be mapped at. This is particularly important for
2111 @@ -75,8 +123,8 @@ extern void __pgd_error(const char *file, int line, pgd_t);
2112 /*
2113 * The pgprot_* and protection_map entries will be fixed up in runtime
2114 * to include the cachable and bufferable bits based on memory policy,
2115 - * as well as any architecture dependent bits like global/ASID and SMP
2116 - * shared mapping bits.
2117 + * as well as any architecture dependent bits like global/ASID, PXN,
2118 + * and SMP shared mapping bits.
2119 */
2120 #define _L_PTE_DEFAULT L_PTE_PRESENT | L_PTE_YOUNG
2121
2122 @@ -265,7 +313,7 @@ static inline pte_t pte_mkspecial(pte_t pte) { return pte; }
2123 static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
2124 {
2125 const pteval_t mask = L_PTE_XN | L_PTE_RDONLY | L_PTE_USER |
2126 - L_PTE_NONE | L_PTE_VALID;
2127 + L_PTE_NONE | L_PTE_VALID | __supported_pte_mask;
2128 pte_val(pte) = (pte_val(pte) & ~mask) | (pgprot_val(newprot) & mask);
2129 return pte;
2130 }
2131 diff --git a/arch/arm/include/asm/psci.h b/arch/arm/include/asm/psci.h
2132 index c4ae171..ea0c0c2 100644
2133 --- a/arch/arm/include/asm/psci.h
2134 +++ b/arch/arm/include/asm/psci.h
2135 @@ -29,7 +29,7 @@ struct psci_operations {
2136 int (*cpu_off)(struct psci_power_state state);
2137 int (*cpu_on)(unsigned long cpuid, unsigned long entry_point);
2138 int (*migrate)(unsigned long cpuid);
2139 -};
2140 +} __no_const;
2141
2142 extern struct psci_operations psci_ops;
2143 extern struct smp_operations psci_smp_ops;
2144 diff --git a/arch/arm/include/asm/smp.h b/arch/arm/include/asm/smp.h
2145 index 2ec765c..beb1fe16 100644
2146 --- a/arch/arm/include/asm/smp.h
2147 +++ b/arch/arm/include/asm/smp.h
2148 @@ -113,7 +113,7 @@ struct smp_operations {
2149 int (*cpu_disable)(unsigned int cpu);
2150 #endif
2151 #endif
2152 -};
2153 +} __no_const;
2154
2155 struct of_cpu_method {
2156 const char *method;
2157 diff --git a/arch/arm/include/asm/thread_info.h b/arch/arm/include/asm/thread_info.h
2158 index f989d7c..e8aa7f0 100644
2159 --- a/arch/arm/include/asm/thread_info.h
2160 +++ b/arch/arm/include/asm/thread_info.h
2161 @@ -88,9 +88,9 @@ struct thread_info {
2162 .flags = 0, \
2163 .preempt_count = INIT_PREEMPT_COUNT, \
2164 .addr_limit = KERNEL_DS, \
2165 - .cpu_domain = domain_val(DOMAIN_USER, DOMAIN_MANAGER) | \
2166 - domain_val(DOMAIN_KERNEL, DOMAIN_MANAGER) | \
2167 - domain_val(DOMAIN_IO, DOMAIN_CLIENT), \
2168 + .cpu_domain = domain_val(DOMAIN_USER, DOMAIN_USERCLIENT) | \
2169 + domain_val(DOMAIN_KERNEL, DOMAIN_KERNELCLIENT) | \
2170 + domain_val(DOMAIN_IO, DOMAIN_KERNELCLIENT), \
2171 .restart_block = { \
2172 .fn = do_no_restart_syscall, \
2173 }, \
2174 @@ -158,7 +158,11 @@ extern int vfp_restore_user_hwstate(struct user_vfp __user *,
2175 #define TIF_SYSCALL_AUDIT 9
2176 #define TIF_SYSCALL_TRACEPOINT 10
2177 #define TIF_SECCOMP 11 /* seccomp syscall filtering active */
2178 -#define TIF_NOHZ 12 /* in adaptive nohz mode */
2179 +/* within 8 bits of TIF_SYSCALL_TRACE
2180 + * to meet flexible second operand requirements
2181 + */
2182 +#define TIF_GRSEC_SETXID 12
2183 +#define TIF_NOHZ 13 /* in adaptive nohz mode */
2184 #define TIF_USING_IWMMXT 17
2185 #define TIF_MEMDIE 18 /* is terminating due to OOM killer */
2186 #define TIF_RESTORE_SIGMASK 20
2187 @@ -172,10 +176,11 @@ extern int vfp_restore_user_hwstate(struct user_vfp __user *,
2188 #define _TIF_SYSCALL_TRACEPOINT (1 << TIF_SYSCALL_TRACEPOINT)
2189 #define _TIF_SECCOMP (1 << TIF_SECCOMP)
2190 #define _TIF_USING_IWMMXT (1 << TIF_USING_IWMMXT)
2191 +#define _TIF_GRSEC_SETXID (1 << TIF_GRSEC_SETXID)
2192
2193 /* Checks for any syscall work in entry-common.S */
2194 #define _TIF_SYSCALL_WORK (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | \
2195 - _TIF_SYSCALL_TRACEPOINT | _TIF_SECCOMP)
2196 + _TIF_SYSCALL_TRACEPOINT | _TIF_SECCOMP | _TIF_GRSEC_SETXID)
2197
2198 /*
2199 * Change these and you break ASM code in entry-common.S
2200 diff --git a/arch/arm/include/asm/uaccess.h b/arch/arm/include/asm/uaccess.h
2201 index 75d9579..b5b40e4 100644
2202 --- a/arch/arm/include/asm/uaccess.h
2203 +++ b/arch/arm/include/asm/uaccess.h
2204 @@ -18,6 +18,7 @@
2205 #include <asm/domain.h>
2206 #include <asm/unified.h>
2207 #include <asm/compiler.h>
2208 +#include <asm/pgtable.h>
2209
2210 #ifndef CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS
2211 #include <asm-generic/uaccess-unaligned.h>
2212 @@ -70,11 +71,38 @@ extern int __put_user_bad(void);
2213 static inline void set_fs(mm_segment_t fs)
2214 {
2215 current_thread_info()->addr_limit = fs;
2216 - modify_domain(DOMAIN_KERNEL, fs ? DOMAIN_CLIENT : DOMAIN_MANAGER);
2217 + modify_domain(DOMAIN_KERNEL, fs ? DOMAIN_KERNELCLIENT : DOMAIN_MANAGER);
2218 }
2219
2220 #define segment_eq(a,b) ((a) == (b))
2221
2222 +#define __HAVE_ARCH_PAX_OPEN_USERLAND
2223 +#define __HAVE_ARCH_PAX_CLOSE_USERLAND
2224 +
2225 +static inline void pax_open_userland(void)
2226 +{
2227 +
2228 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2229 + if (segment_eq(get_fs(), USER_DS)) {
2230 + BUG_ON(test_domain(DOMAIN_USER, DOMAIN_UDEREF));
2231 + modify_domain(DOMAIN_USER, DOMAIN_UDEREF);
2232 + }
2233 +#endif
2234 +
2235 +}
2236 +
2237 +static inline void pax_close_userland(void)
2238 +{
2239 +
2240 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2241 + if (segment_eq(get_fs(), USER_DS)) {
2242 + BUG_ON(test_domain(DOMAIN_USER, DOMAIN_NOACCESS));
2243 + modify_domain(DOMAIN_USER, DOMAIN_NOACCESS);
2244 + }
2245 +#endif
2246 +
2247 +}
2248 +
2249 #define __addr_ok(addr) ({ \
2250 unsigned long flag; \
2251 __asm__("cmp %2, %0; movlo %0, #0" \
2252 @@ -150,8 +178,12 @@ extern int __get_user_4(void *);
2253
2254 #define get_user(x,p) \
2255 ({ \
2256 + int __e; \
2257 might_fault(); \
2258 - __get_user_check(x,p); \
2259 + pax_open_userland(); \
2260 + __e = __get_user_check(x,p); \
2261 + pax_close_userland(); \
2262 + __e; \
2263 })
2264
2265 extern int __put_user_1(void *, unsigned int);
2266 @@ -196,8 +228,12 @@ extern int __put_user_8(void *, unsigned long long);
2267
2268 #define put_user(x,p) \
2269 ({ \
2270 + int __e; \
2271 might_fault(); \
2272 - __put_user_check(x,p); \
2273 + pax_open_userland(); \
2274 + __e = __put_user_check(x,p); \
2275 + pax_close_userland(); \
2276 + __e; \
2277 })
2278
2279 #else /* CONFIG_MMU */
2280 @@ -221,6 +257,7 @@ static inline void set_fs(mm_segment_t fs)
2281
2282 #endif /* CONFIG_MMU */
2283
2284 +#define access_ok_noprefault(type,addr,size) access_ok((type),(addr),(size))
2285 #define access_ok(type,addr,size) (__range_ok(addr,size) == 0)
2286
2287 #define user_addr_max() \
2288 @@ -238,13 +275,17 @@ static inline void set_fs(mm_segment_t fs)
2289 #define __get_user(x,ptr) \
2290 ({ \
2291 long __gu_err = 0; \
2292 + pax_open_userland(); \
2293 __get_user_err((x),(ptr),__gu_err); \
2294 + pax_close_userland(); \
2295 __gu_err; \
2296 })
2297
2298 #define __get_user_error(x,ptr,err) \
2299 ({ \
2300 + pax_open_userland(); \
2301 __get_user_err((x),(ptr),err); \
2302 + pax_close_userland(); \
2303 (void) 0; \
2304 })
2305
2306 @@ -320,13 +361,17 @@ do { \
2307 #define __put_user(x,ptr) \
2308 ({ \
2309 long __pu_err = 0; \
2310 + pax_open_userland(); \
2311 __put_user_err((x),(ptr),__pu_err); \
2312 + pax_close_userland(); \
2313 __pu_err; \
2314 })
2315
2316 #define __put_user_error(x,ptr,err) \
2317 ({ \
2318 + pax_open_userland(); \
2319 __put_user_err((x),(ptr),err); \
2320 + pax_close_userland(); \
2321 (void) 0; \
2322 })
2323
2324 @@ -426,11 +471,44 @@ do { \
2325
2326
2327 #ifdef CONFIG_MMU
2328 -extern unsigned long __must_check __copy_from_user(void *to, const void __user *from, unsigned long n);
2329 -extern unsigned long __must_check __copy_to_user(void __user *to, const void *from, unsigned long n);
2330 +extern unsigned long __must_check ___copy_from_user(void *to, const void __user *from, unsigned long n);
2331 +extern unsigned long __must_check ___copy_to_user(void __user *to, const void *from, unsigned long n);
2332 +
2333 +static inline unsigned long __must_check __copy_from_user(void *to, const void __user *from, unsigned long n)
2334 +{
2335 + unsigned long ret;
2336 +
2337 + check_object_size(to, n, false);
2338 + pax_open_userland();
2339 + ret = ___copy_from_user(to, from, n);
2340 + pax_close_userland();
2341 + return ret;
2342 +}
2343 +
2344 +static inline unsigned long __must_check __copy_to_user(void __user *to, const void *from, unsigned long n)
2345 +{
2346 + unsigned long ret;
2347 +
2348 + check_object_size(from, n, true);
2349 + pax_open_userland();
2350 + ret = ___copy_to_user(to, from, n);
2351 + pax_close_userland();
2352 + return ret;
2353 +}
2354 +
2355 extern unsigned long __must_check __copy_to_user_std(void __user *to, const void *from, unsigned long n);
2356 -extern unsigned long __must_check __clear_user(void __user *addr, unsigned long n);
2357 +extern unsigned long __must_check ___clear_user(void __user *addr, unsigned long n);
2358 extern unsigned long __must_check __clear_user_std(void __user *addr, unsigned long n);
2359 +
2360 +static inline unsigned long __must_check __clear_user(void __user *addr, unsigned long n)
2361 +{
2362 + unsigned long ret;
2363 + pax_open_userland();
2364 + ret = ___clear_user(addr, n);
2365 + pax_close_userland();
2366 + return ret;
2367 +}
2368 +
2369 #else
2370 #define __copy_from_user(to,from,n) (memcpy(to, (void __force *)from, n), 0)
2371 #define __copy_to_user(to,from,n) (memcpy((void __force *)to, from, n), 0)
2372 @@ -439,6 +517,9 @@ extern unsigned long __must_check __clear_user_std(void __user *addr, unsigned l
2373
2374 static inline unsigned long __must_check copy_from_user(void *to, const void __user *from, unsigned long n)
2375 {
2376 + if ((long)n < 0)
2377 + return n;
2378 +
2379 if (access_ok(VERIFY_READ, from, n))
2380 n = __copy_from_user(to, from, n);
2381 else /* security hole - plug it */
2382 @@ -448,6 +529,9 @@ static inline unsigned long __must_check copy_from_user(void *to, const void __u
2383
2384 static inline unsigned long __must_check copy_to_user(void __user *to, const void *from, unsigned long n)
2385 {
2386 + if ((long)n < 0)
2387 + return n;
2388 +
2389 if (access_ok(VERIFY_WRITE, to, n))
2390 n = __copy_to_user(to, from, n);
2391 return n;
2392 diff --git a/arch/arm/include/uapi/asm/ptrace.h b/arch/arm/include/uapi/asm/ptrace.h
2393 index 5af0ed1..cea83883 100644
2394 --- a/arch/arm/include/uapi/asm/ptrace.h
2395 +++ b/arch/arm/include/uapi/asm/ptrace.h
2396 @@ -92,7 +92,7 @@
2397 * ARMv7 groups of PSR bits
2398 */
2399 #define APSR_MASK 0xf80f0000 /* N, Z, C, V, Q and GE flags */
2400 -#define PSR_ISET_MASK 0x01000010 /* ISA state (J, T) mask */
2401 +#define PSR_ISET_MASK 0x01000020 /* ISA state (J, T) mask */
2402 #define PSR_IT_MASK 0x0600fc00 /* If-Then execution state mask */
2403 #define PSR_ENDIAN_MASK 0x00000200 /* Endianness state mask */
2404
2405 diff --git a/arch/arm/kernel/armksyms.c b/arch/arm/kernel/armksyms.c
2406 index f7b450f..f5364c5 100644
2407 --- a/arch/arm/kernel/armksyms.c
2408 +++ b/arch/arm/kernel/armksyms.c
2409 @@ -55,7 +55,7 @@ EXPORT_SYMBOL(arm_delay_ops);
2410
2411 /* networking */
2412 EXPORT_SYMBOL(csum_partial);
2413 -EXPORT_SYMBOL(csum_partial_copy_from_user);
2414 +EXPORT_SYMBOL(__csum_partial_copy_from_user);
2415 EXPORT_SYMBOL(csum_partial_copy_nocheck);
2416 EXPORT_SYMBOL(__csum_ipv6_magic);
2417
2418 @@ -91,9 +91,9 @@ EXPORT_SYMBOL(__memzero);
2419 #ifdef CONFIG_MMU
2420 EXPORT_SYMBOL(copy_page);
2421
2422 -EXPORT_SYMBOL(__copy_from_user);
2423 -EXPORT_SYMBOL(__copy_to_user);
2424 -EXPORT_SYMBOL(__clear_user);
2425 +EXPORT_SYMBOL(___copy_from_user);
2426 +EXPORT_SYMBOL(___copy_to_user);
2427 +EXPORT_SYMBOL(___clear_user);
2428
2429 EXPORT_SYMBOL(__get_user_1);
2430 EXPORT_SYMBOL(__get_user_2);
2431 diff --git a/arch/arm/kernel/entry-armv.S b/arch/arm/kernel/entry-armv.S
2432 index 1879e8d..b2207fc 100644
2433 --- a/arch/arm/kernel/entry-armv.S
2434 +++ b/arch/arm/kernel/entry-armv.S
2435 @@ -47,6 +47,87 @@
2436 9997:
2437 .endm
2438
2439 + .macro pax_enter_kernel
2440 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2441 + @ make aligned space for saved DACR
2442 + sub sp, sp, #8
2443 + @ save regs
2444 + stmdb sp!, {r1, r2}
2445 + @ read DACR from cpu_domain into r1
2446 + mov r2, sp
2447 + @ assume 8K pages, since we have to split the immediate in two
2448 + bic r2, r2, #(0x1fc0)
2449 + bic r2, r2, #(0x3f)
2450 + ldr r1, [r2, #TI_CPU_DOMAIN]
2451 + @ store old DACR on stack
2452 + str r1, [sp, #8]
2453 +#ifdef CONFIG_PAX_KERNEXEC
2454 + @ set type of DOMAIN_KERNEL to DOMAIN_KERNELCLIENT
2455 + bic r1, r1, #(domain_val(DOMAIN_KERNEL, 3))
2456 + orr r1, r1, #(domain_val(DOMAIN_KERNEL, DOMAIN_KERNELCLIENT))
2457 +#endif
2458 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2459 + @ set current DOMAIN_USER to DOMAIN_NOACCESS
2460 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2461 +#endif
2462 + @ write r1 to current_thread_info()->cpu_domain
2463 + str r1, [r2, #TI_CPU_DOMAIN]
2464 + @ write r1 to DACR
2465 + mcr p15, 0, r1, c3, c0, 0
2466 + @ instruction sync
2467 + instr_sync
2468 + @ restore regs
2469 + ldmia sp!, {r1, r2}
2470 +#endif
2471 + .endm
2472 +
2473 + .macro pax_open_userland
2474 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2475 + @ save regs
2476 + stmdb sp!, {r0, r1}
2477 + @ read DACR from cpu_domain into r1
2478 + mov r0, sp
2479 + @ assume 8K pages, since we have to split the immediate in two
2480 + bic r0, r0, #(0x1fc0)
2481 + bic r0, r0, #(0x3f)
2482 + ldr r1, [r0, #TI_CPU_DOMAIN]
2483 + @ set current DOMAIN_USER to DOMAIN_CLIENT
2484 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2485 + orr r1, r1, #(domain_val(DOMAIN_USER, DOMAIN_UDEREF))
2486 + @ write r1 to current_thread_info()->cpu_domain
2487 + str r1, [r0, #TI_CPU_DOMAIN]
2488 + @ write r1 to DACR
2489 + mcr p15, 0, r1, c3, c0, 0
2490 + @ instruction sync
2491 + instr_sync
2492 + @ restore regs
2493 + ldmia sp!, {r0, r1}
2494 +#endif
2495 + .endm
2496 +
2497 + .macro pax_close_userland
2498 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2499 + @ save regs
2500 + stmdb sp!, {r0, r1}
2501 + @ read DACR from cpu_domain into r1
2502 + mov r0, sp
2503 + @ assume 8K pages, since we have to split the immediate in two
2504 + bic r0, r0, #(0x1fc0)
2505 + bic r0, r0, #(0x3f)
2506 + ldr r1, [r0, #TI_CPU_DOMAIN]
2507 + @ set current DOMAIN_USER to DOMAIN_NOACCESS
2508 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2509 + @ write r1 to current_thread_info()->cpu_domain
2510 + str r1, [r0, #TI_CPU_DOMAIN]
2511 + @ write r1 to DACR
2512 + mcr p15, 0, r1, c3, c0, 0
2513 + @ instruction sync
2514 + instr_sync
2515 + @ restore regs
2516 + ldmia sp!, {r0, r1}
2517 +#endif
2518 + .endm
2519 +
2520 .macro pabt_helper
2521 @ PABORT handler takes pt_regs in r2, fault address in r4 and psr in r5
2522 #ifdef MULTI_PABORT
2523 @@ -89,11 +170,15 @@
2524 * Invalid mode handlers
2525 */
2526 .macro inv_entry, reason
2527 +
2528 + pax_enter_kernel
2529 +
2530 sub sp, sp, #S_FRAME_SIZE
2531 ARM( stmib sp, {r1 - lr} )
2532 THUMB( stmia sp, {r0 - r12} )
2533 THUMB( str sp, [sp, #S_SP] )
2534 THUMB( str lr, [sp, #S_LR] )
2535 +
2536 mov r1, #\reason
2537 .endm
2538
2539 @@ -149,7 +234,11 @@ ENDPROC(__und_invalid)
2540 .macro svc_entry, stack_hole=0
2541 UNWIND(.fnstart )
2542 UNWIND(.save {r0 - pc} )
2543 +
2544 + pax_enter_kernel
2545 +
2546 sub sp, sp, #(S_FRAME_SIZE + \stack_hole - 4)
2547 +
2548 #ifdef CONFIG_THUMB2_KERNEL
2549 SPFIX( str r0, [sp] ) @ temporarily saved
2550 SPFIX( mov r0, sp )
2551 @@ -164,7 +253,12 @@ ENDPROC(__und_invalid)
2552 ldmia r0, {r3 - r5}
2553 add r7, sp, #S_SP - 4 @ here for interlock avoidance
2554 mov r6, #-1 @ "" "" "" ""
2555 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2556 + @ offset sp by 8 as done in pax_enter_kernel
2557 + add r2, sp, #(S_FRAME_SIZE + \stack_hole + 4)
2558 +#else
2559 add r2, sp, #(S_FRAME_SIZE + \stack_hole - 4)
2560 +#endif
2561 SPFIX( addeq r2, r2, #4 )
2562 str r3, [sp, #-4]! @ save the "real" r0 copied
2563 @ from the exception stack
2564 @@ -317,6 +411,9 @@ ENDPROC(__pabt_svc)
2565 .macro usr_entry
2566 UNWIND(.fnstart )
2567 UNWIND(.cantunwind ) @ don't unwind the user space
2568 +
2569 + pax_enter_kernel_user
2570 +
2571 sub sp, sp, #S_FRAME_SIZE
2572 ARM( stmib sp, {r1 - r12} )
2573 THUMB( stmia sp, {r0 - r12} )
2574 @@ -416,7 +513,9 @@ __und_usr:
2575 tst r3, #PSR_T_BIT @ Thumb mode?
2576 bne __und_usr_thumb
2577 sub r4, r2, #4 @ ARM instr at LR - 4
2578 + pax_open_userland
2579 1: ldrt r0, [r4]
2580 + pax_close_userland
2581 ARM_BE8(rev r0, r0) @ little endian instruction
2582
2583 @ r0 = 32-bit ARM instruction which caused the exception
2584 @@ -450,11 +549,15 @@ __und_usr_thumb:
2585 */
2586 .arch armv6t2
2587 #endif
2588 + pax_open_userland
2589 2: ldrht r5, [r4]
2590 + pax_close_userland
2591 ARM_BE8(rev16 r5, r5) @ little endian instruction
2592 cmp r5, #0xe800 @ 32bit instruction if xx != 0
2593 blo __und_usr_fault_16 @ 16bit undefined instruction
2594 + pax_open_userland
2595 3: ldrht r0, [r2]
2596 + pax_close_userland
2597 ARM_BE8(rev16 r0, r0) @ little endian instruction
2598 add r2, r2, #2 @ r2 is PC + 2, make it PC + 4
2599 str r2, [sp, #S_PC] @ it's a 2x16bit instr, update
2600 @@ -484,7 +587,8 @@ ENDPROC(__und_usr)
2601 */
2602 .pushsection .fixup, "ax"
2603 .align 2
2604 -4: mov pc, r9
2605 +4: pax_close_userland
2606 + mov pc, r9
2607 .popsection
2608 .pushsection __ex_table,"a"
2609 .long 1b, 4b
2610 @@ -694,7 +798,7 @@ ENTRY(__switch_to)
2611 THUMB( str lr, [ip], #4 )
2612 ldr r4, [r2, #TI_TP_VALUE]
2613 ldr r5, [r2, #TI_TP_VALUE + 4]
2614 -#ifdef CONFIG_CPU_USE_DOMAINS
2615 +#if defined(CONFIG_CPU_USE_DOMAINS) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2616 ldr r6, [r2, #TI_CPU_DOMAIN]
2617 #endif
2618 switch_tls r1, r4, r5, r3, r7
2619 @@ -703,7 +807,7 @@ ENTRY(__switch_to)
2620 ldr r8, =__stack_chk_guard
2621 ldr r7, [r7, #TSK_STACK_CANARY]
2622 #endif
2623 -#ifdef CONFIG_CPU_USE_DOMAINS
2624 +#if defined(CONFIG_CPU_USE_DOMAINS) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2625 mcr p15, 0, r6, c3, c0, 0 @ Set domain register
2626 #endif
2627 mov r5, r0
2628 diff --git a/arch/arm/kernel/entry-common.S b/arch/arm/kernel/entry-common.S
2629 index a2dcafd..1048b5a 100644
2630 --- a/arch/arm/kernel/entry-common.S
2631 +++ b/arch/arm/kernel/entry-common.S
2632 @@ -10,18 +10,46 @@
2633
2634 #include <asm/unistd.h>
2635 #include <asm/ftrace.h>
2636 +#include <asm/domain.h>
2637 #include <asm/unwind.h>
2638
2639 +#include "entry-header.S"
2640 +
2641 #ifdef CONFIG_NEED_RET_TO_USER
2642 #include <mach/entry-macro.S>
2643 #else
2644 .macro arch_ret_to_user, tmp1, tmp2
2645 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2646 + @ save regs
2647 + stmdb sp!, {r1, r2}
2648 + @ read DACR from cpu_domain into r1
2649 + mov r2, sp
2650 + @ assume 8K pages, since we have to split the immediate in two
2651 + bic r2, r2, #(0x1fc0)
2652 + bic r2, r2, #(0x3f)
2653 + ldr r1, [r2, #TI_CPU_DOMAIN]
2654 +#ifdef CONFIG_PAX_KERNEXEC
2655 + @ set type of DOMAIN_KERNEL to DOMAIN_KERNELCLIENT
2656 + bic r1, r1, #(domain_val(DOMAIN_KERNEL, 3))
2657 + orr r1, r1, #(domain_val(DOMAIN_KERNEL, DOMAIN_KERNELCLIENT))
2658 +#endif
2659 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2660 + @ set current DOMAIN_USER to DOMAIN_UDEREF
2661 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2662 + orr r1, r1, #(domain_val(DOMAIN_USER, DOMAIN_UDEREF))
2663 +#endif
2664 + @ write r1 to current_thread_info()->cpu_domain
2665 + str r1, [r2, #TI_CPU_DOMAIN]
2666 + @ write r1 to DACR
2667 + mcr p15, 0, r1, c3, c0, 0
2668 + @ instruction sync
2669 + instr_sync
2670 + @ restore regs
2671 + ldmia sp!, {r1, r2}
2672 +#endif
2673 .endm
2674 #endif
2675
2676 -#include "entry-header.S"
2677 -
2678 -
2679 .align 5
2680 /*
2681 * This is the fast syscall return path. We do as little as
2682 @@ -411,6 +439,12 @@ ENTRY(vector_swi)
2683 USER( ldr scno, [lr, #-4] ) @ get SWI instruction
2684 #endif
2685
2686 + /*
2687 + * do this here to avoid a performance hit of wrapping the code above
2688 + * that directly dereferences userland to parse the SWI instruction
2689 + */
2690 + pax_enter_kernel_user
2691 +
2692 adr tbl, sys_call_table @ load syscall table pointer
2693
2694 #if defined(CONFIG_OABI_COMPAT)
2695 diff --git a/arch/arm/kernel/entry-header.S b/arch/arm/kernel/entry-header.S
2696 index efb208d..d34bd02 100644
2697 --- a/arch/arm/kernel/entry-header.S
2698 +++ b/arch/arm/kernel/entry-header.S
2699 @@ -188,6 +188,60 @@
2700 msr cpsr_c, \rtemp @ switch back to the SVC mode
2701 .endm
2702
2703 + .macro pax_enter_kernel_user
2704 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2705 + @ save regs
2706 + stmdb sp!, {r0, r1}
2707 + @ read DACR from cpu_domain into r1
2708 + mov r0, sp
2709 + @ assume 8K pages, since we have to split the immediate in two
2710 + bic r0, r0, #(0x1fc0)
2711 + bic r0, r0, #(0x3f)
2712 + ldr r1, [r0, #TI_CPU_DOMAIN]
2713 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2714 + @ set current DOMAIN_USER to DOMAIN_NOACCESS
2715 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2716 +#endif
2717 +#ifdef CONFIG_PAX_KERNEXEC
2718 + @ set current DOMAIN_KERNEL to DOMAIN_KERNELCLIENT
2719 + bic r1, r1, #(domain_val(DOMAIN_KERNEL, 3))
2720 + orr r1, r1, #(domain_val(DOMAIN_KERNEL, DOMAIN_KERNELCLIENT))
2721 +#endif
2722 + @ write r1 to current_thread_info()->cpu_domain
2723 + str r1, [r0, #TI_CPU_DOMAIN]
2724 + @ write r1 to DACR
2725 + mcr p15, 0, r1, c3, c0, 0
2726 + @ instruction sync
2727 + instr_sync
2728 + @ restore regs
2729 + ldmia sp!, {r0, r1}
2730 +#endif
2731 + .endm
2732 +
2733 + .macro pax_exit_kernel
2734 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2735 + @ save regs
2736 + stmdb sp!, {r0, r1}
2737 + @ read old DACR from stack into r1
2738 + ldr r1, [sp, #(8 + S_SP)]
2739 + sub r1, r1, #8
2740 + ldr r1, [r1]
2741 +
2742 + @ write r1 to current_thread_info()->cpu_domain
2743 + mov r0, sp
2744 + @ assume 8K pages, since we have to split the immediate in two
2745 + bic r0, r0, #(0x1fc0)
2746 + bic r0, r0, #(0x3f)
2747 + str r1, [r0, #TI_CPU_DOMAIN]
2748 + @ write r1 to DACR
2749 + mcr p15, 0, r1, c3, c0, 0
2750 + @ instruction sync
2751 + instr_sync
2752 + @ restore regs
2753 + ldmia sp!, {r0, r1}
2754 +#endif
2755 + .endm
2756 +
2757 #ifndef CONFIG_THUMB2_KERNEL
2758 .macro svc_exit, rpsr, irq = 0
2759 .if \irq != 0
2760 @@ -207,6 +261,9 @@
2761 blne trace_hardirqs_off
2762 #endif
2763 .endif
2764 +
2765 + pax_exit_kernel
2766 +
2767 msr spsr_cxsf, \rpsr
2768 #if defined(CONFIG_CPU_V6)
2769 ldr r0, [sp]
2770 @@ -265,6 +322,9 @@
2771 blne trace_hardirqs_off
2772 #endif
2773 .endif
2774 +
2775 + pax_exit_kernel
2776 +
2777 ldr lr, [sp, #S_SP] @ top of the stack
2778 ldrd r0, r1, [sp, #S_LR] @ calling lr and pc
2779 clrex @ clear the exclusive monitor
2780 diff --git a/arch/arm/kernel/fiq.c b/arch/arm/kernel/fiq.c
2781 index 918875d..cd5fa27 100644
2782 --- a/arch/arm/kernel/fiq.c
2783 +++ b/arch/arm/kernel/fiq.c
2784 @@ -87,7 +87,10 @@ void set_fiq_handler(void *start, unsigned int length)
2785 void *base = vectors_page;
2786 unsigned offset = FIQ_OFFSET;
2787
2788 + pax_open_kernel();
2789 memcpy(base + offset, start, length);
2790 + pax_close_kernel();
2791 +
2792 if (!cache_is_vipt_nonaliasing())
2793 flush_icache_range((unsigned long)base + offset, offset +
2794 length);
2795 diff --git a/arch/arm/kernel/head.S b/arch/arm/kernel/head.S
2796 index 591d6e4..8322a26 100644
2797 --- a/arch/arm/kernel/head.S
2798 +++ b/arch/arm/kernel/head.S
2799 @@ -437,7 +437,7 @@ __enable_mmu:
2800 mov r5, #(domain_val(DOMAIN_USER, DOMAIN_MANAGER) | \
2801 domain_val(DOMAIN_KERNEL, DOMAIN_MANAGER) | \
2802 domain_val(DOMAIN_TABLE, DOMAIN_MANAGER) | \
2803 - domain_val(DOMAIN_IO, DOMAIN_CLIENT))
2804 + domain_val(DOMAIN_IO, DOMAIN_KERNELCLIENT))
2805 mcr p15, 0, r5, c3, c0, 0 @ load domain access register
2806 mcr p15, 0, r4, c2, c0, 0 @ load page table pointer
2807 #endif
2808 diff --git a/arch/arm/kernel/module.c b/arch/arm/kernel/module.c
2809 index 45e4781..8eac93d 100644
2810 --- a/arch/arm/kernel/module.c
2811 +++ b/arch/arm/kernel/module.c
2812 @@ -38,12 +38,39 @@
2813 #endif
2814
2815 #ifdef CONFIG_MMU
2816 -void *module_alloc(unsigned long size)
2817 +static inline void *__module_alloc(unsigned long size, pgprot_t prot)
2818 {
2819 + if (!size || PAGE_ALIGN(size) > MODULES_END - MODULES_VADDR)
2820 + return NULL;
2821 return __vmalloc_node_range(size, 1, MODULES_VADDR, MODULES_END,
2822 - GFP_KERNEL, PAGE_KERNEL_EXEC, NUMA_NO_NODE,
2823 + GFP_KERNEL, prot, NUMA_NO_NODE,
2824 __builtin_return_address(0));
2825 }
2826 +
2827 +void *module_alloc(unsigned long size)
2828 +{
2829 +
2830 +#ifdef CONFIG_PAX_KERNEXEC
2831 + return __module_alloc(size, PAGE_KERNEL);
2832 +#else
2833 + return __module_alloc(size, PAGE_KERNEL_EXEC);
2834 +#endif
2835 +
2836 +}
2837 +
2838 +#ifdef CONFIG_PAX_KERNEXEC
2839 +void module_free_exec(struct module *mod, void *module_region)
2840 +{
2841 + module_free(mod, module_region);
2842 +}
2843 +EXPORT_SYMBOL(module_free_exec);
2844 +
2845 +void *module_alloc_exec(unsigned long size)
2846 +{
2847 + return __module_alloc(size, PAGE_KERNEL_EXEC);
2848 +}
2849 +EXPORT_SYMBOL(module_alloc_exec);
2850 +#endif
2851 #endif
2852
2853 int
2854 diff --git a/arch/arm/kernel/patch.c b/arch/arm/kernel/patch.c
2855 index 07314af..c46655c 100644
2856 --- a/arch/arm/kernel/patch.c
2857 +++ b/arch/arm/kernel/patch.c
2858 @@ -18,6 +18,7 @@ void __kprobes __patch_text(void *addr, unsigned int insn)
2859 bool thumb2 = IS_ENABLED(CONFIG_THUMB2_KERNEL);
2860 int size;
2861
2862 + pax_open_kernel();
2863 if (thumb2 && __opcode_is_thumb16(insn)) {
2864 *(u16 *)addr = __opcode_to_mem_thumb16(insn);
2865 size = sizeof(u16);
2866 @@ -39,6 +40,7 @@ void __kprobes __patch_text(void *addr, unsigned int insn)
2867 *(u32 *)addr = insn;
2868 size = sizeof(u32);
2869 }
2870 + pax_close_kernel();
2871
2872 flush_icache_range((uintptr_t)(addr),
2873 (uintptr_t)(addr) + size);
2874 diff --git a/arch/arm/kernel/process.c b/arch/arm/kernel/process.c
2875 index 81ef686..f4130b8 100644
2876 --- a/arch/arm/kernel/process.c
2877 +++ b/arch/arm/kernel/process.c
2878 @@ -212,6 +212,7 @@ void machine_power_off(void)
2879
2880 if (pm_power_off)
2881 pm_power_off();
2882 + BUG();
2883 }
2884
2885 /*
2886 @@ -225,7 +226,7 @@ void machine_power_off(void)
2887 * executing pre-reset code, and using RAM that the primary CPU's code wishes
2888 * to use. Implementing such co-ordination would be essentially impossible.
2889 */
2890 -void machine_restart(char *cmd)
2891 +__noreturn void machine_restart(char *cmd)
2892 {
2893 local_irq_disable();
2894 smp_send_stop();
2895 @@ -248,8 +249,8 @@ void __show_regs(struct pt_regs *regs)
2896
2897 show_regs_print_info(KERN_DEFAULT);
2898
2899 - print_symbol("PC is at %s\n", instruction_pointer(regs));
2900 - print_symbol("LR is at %s\n", regs->ARM_lr);
2901 + printk("PC is at %pA\n", (void *)instruction_pointer(regs));
2902 + printk("LR is at %pA\n", (void *)regs->ARM_lr);
2903 printk("pc : [<%08lx>] lr : [<%08lx>] psr: %08lx\n"
2904 "sp : %08lx ip : %08lx fp : %08lx\n",
2905 regs->ARM_pc, regs->ARM_lr, regs->ARM_cpsr,
2906 @@ -425,12 +426,6 @@ unsigned long get_wchan(struct task_struct *p)
2907 return 0;
2908 }
2909
2910 -unsigned long arch_randomize_brk(struct mm_struct *mm)
2911 -{
2912 - unsigned long range_end = mm->brk + 0x02000000;
2913 - return randomize_range(mm->brk, range_end, 0) ? : mm->brk;
2914 -}
2915 -
2916 #ifdef CONFIG_MMU
2917 #ifdef CONFIG_KUSER_HELPERS
2918 /*
2919 @@ -446,7 +441,7 @@ static struct vm_area_struct gate_vma = {
2920
2921 static int __init gate_vma_init(void)
2922 {
2923 - gate_vma.vm_page_prot = PAGE_READONLY_EXEC;
2924 + gate_vma.vm_page_prot = vm_get_page_prot(gate_vma.vm_flags);
2925 return 0;
2926 }
2927 arch_initcall(gate_vma_init);
2928 @@ -472,41 +467,16 @@ int in_gate_area_no_mm(unsigned long addr)
2929
2930 const char *arch_vma_name(struct vm_area_struct *vma)
2931 {
2932 - return is_gate_vma(vma) ? "[vectors]" :
2933 - (vma->vm_mm && vma->vm_start == vma->vm_mm->context.sigpage) ?
2934 - "[sigpage]" : NULL;
2935 + return is_gate_vma(vma) ? "[vectors]" : NULL;
2936 }
2937
2938 -static struct page *signal_page;
2939 -extern struct page *get_signal_page(void);
2940 -
2941 int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
2942 {
2943 struct mm_struct *mm = current->mm;
2944 - unsigned long addr;
2945 - int ret;
2946 -
2947 - if (!signal_page)
2948 - signal_page = get_signal_page();
2949 - if (!signal_page)
2950 - return -ENOMEM;
2951
2952 down_write(&mm->mmap_sem);
2953 - addr = get_unmapped_area(NULL, 0, PAGE_SIZE, 0, 0);
2954 - if (IS_ERR_VALUE(addr)) {
2955 - ret = addr;
2956 - goto up_fail;
2957 - }
2958 -
2959 - ret = install_special_mapping(mm, addr, PAGE_SIZE,
2960 - VM_READ | VM_EXEC | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC,
2961 - &signal_page);
2962 -
2963 - if (ret == 0)
2964 - mm->context.sigpage = addr;
2965 -
2966 - up_fail:
2967 + mm->context.sigpage = (PAGE_OFFSET + (get_random_int() % 0x3FFEFFE0)) & 0xFFFFFFFC;
2968 up_write(&mm->mmap_sem);
2969 - return ret;
2970 + return 0;
2971 }
2972 #endif
2973 diff --git a/arch/arm/kernel/psci.c b/arch/arm/kernel/psci.c
2974 index 4693188..4596c5e 100644
2975 --- a/arch/arm/kernel/psci.c
2976 +++ b/arch/arm/kernel/psci.c
2977 @@ -24,7 +24,7 @@
2978 #include <asm/opcodes-virt.h>
2979 #include <asm/psci.h>
2980
2981 -struct psci_operations psci_ops;
2982 +struct psci_operations psci_ops __read_only;
2983
2984 static int (*invoke_psci_fn)(u32, u32, u32, u32);
2985
2986 diff --git a/arch/arm/kernel/ptrace.c b/arch/arm/kernel/ptrace.c
2987 index 0dd3b79..e018f64 100644
2988 --- a/arch/arm/kernel/ptrace.c
2989 +++ b/arch/arm/kernel/ptrace.c
2990 @@ -929,10 +929,19 @@ static int tracehook_report_syscall(struct pt_regs *regs,
2991 return current_thread_info()->syscall;
2992 }
2993
2994 +#ifdef CONFIG_GRKERNSEC_SETXID
2995 +extern void gr_delayed_cred_worker(void);
2996 +#endif
2997 +
2998 asmlinkage int syscall_trace_enter(struct pt_regs *regs, int scno)
2999 {
3000 current_thread_info()->syscall = scno;
3001
3002 +#ifdef CONFIG_GRKERNSEC_SETXID
3003 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
3004 + gr_delayed_cred_worker();
3005 +#endif
3006 +
3007 /* Do the secure computing check first; failures should be fast. */
3008 if (secure_computing(scno) == -1)
3009 return -1;
3010 diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c
3011 index 50e198c..a8b5f49 100644
3012 --- a/arch/arm/kernel/setup.c
3013 +++ b/arch/arm/kernel/setup.c
3014 @@ -103,21 +103,23 @@ EXPORT_SYMBOL(elf_hwcap);
3015 unsigned int elf_hwcap2 __read_mostly;
3016 EXPORT_SYMBOL(elf_hwcap2);
3017
3018 +pteval_t __supported_pte_mask __read_only;
3019 +pmdval_t __supported_pmd_mask __read_only;
3020
3021 #ifdef MULTI_CPU
3022 -struct processor processor __read_mostly;
3023 +struct processor processor __read_only;
3024 #endif
3025 #ifdef MULTI_TLB
3026 -struct cpu_tlb_fns cpu_tlb __read_mostly;
3027 +struct cpu_tlb_fns cpu_tlb __read_only;
3028 #endif
3029 #ifdef MULTI_USER
3030 -struct cpu_user_fns cpu_user __read_mostly;
3031 +struct cpu_user_fns cpu_user __read_only;
3032 #endif
3033 #ifdef MULTI_CACHE
3034 -struct cpu_cache_fns cpu_cache __read_mostly;
3035 +struct cpu_cache_fns cpu_cache __read_only;
3036 #endif
3037 #ifdef CONFIG_OUTER_CACHE
3038 -struct outer_cache_fns outer_cache __read_mostly;
3039 +struct outer_cache_fns outer_cache __read_only;
3040 EXPORT_SYMBOL(outer_cache);
3041 #endif
3042
3043 @@ -250,9 +252,13 @@ static int __get_cpu_architecture(void)
3044 asm("mrc p15, 0, %0, c0, c1, 4"
3045 : "=r" (mmfr0));
3046 if ((mmfr0 & 0x0000000f) >= 0x00000003 ||
3047 - (mmfr0 & 0x000000f0) >= 0x00000030)
3048 + (mmfr0 & 0x000000f0) >= 0x00000030) {
3049 cpu_arch = CPU_ARCH_ARMv7;
3050 - else if ((mmfr0 & 0x0000000f) == 0x00000002 ||
3051 + if ((mmfr0 & 0x0000000f) == 0x00000005 || (mmfr0 & 0x0000000f) == 0x00000004) {
3052 + __supported_pte_mask |= L_PTE_PXN;
3053 + __supported_pmd_mask |= PMD_PXNTABLE;
3054 + }
3055 + } else if ((mmfr0 & 0x0000000f) == 0x00000002 ||
3056 (mmfr0 & 0x000000f0) == 0x00000020)
3057 cpu_arch = CPU_ARCH_ARMv6;
3058 else
3059 diff --git a/arch/arm/kernel/signal.c b/arch/arm/kernel/signal.c
3060 index bd19834..e4d8c66 100644
3061 --- a/arch/arm/kernel/signal.c
3062 +++ b/arch/arm/kernel/signal.c
3063 @@ -24,8 +24,6 @@
3064
3065 extern const unsigned long sigreturn_codes[7];
3066
3067 -static unsigned long signal_return_offset;
3068 -
3069 #ifdef CONFIG_CRUNCH
3070 static int preserve_crunch_context(struct crunch_sigframe __user *frame)
3071 {
3072 @@ -396,8 +394,7 @@ setup_return(struct pt_regs *regs, struct ksignal *ksig,
3073 * except when the MPU has protected the vectors
3074 * page from PL0
3075 */
3076 - retcode = mm->context.sigpage + signal_return_offset +
3077 - (idx << 2) + thumb;
3078 + retcode = mm->context.sigpage + (idx << 2) + thumb;
3079 } else
3080 #endif
3081 {
3082 @@ -604,33 +601,3 @@ do_work_pending(struct pt_regs *regs, unsigned int thread_flags, int syscall)
3083 } while (thread_flags & _TIF_WORK_MASK);
3084 return 0;
3085 }
3086 -
3087 -struct page *get_signal_page(void)
3088 -{
3089 - unsigned long ptr;
3090 - unsigned offset;
3091 - struct page *page;
3092 - void *addr;
3093 -
3094 - page = alloc_pages(GFP_KERNEL, 0);
3095 -
3096 - if (!page)
3097 - return NULL;
3098 -
3099 - addr = page_address(page);
3100 -
3101 - /* Give the signal return code some randomness */
3102 - offset = 0x200 + (get_random_int() & 0x7fc);
3103 - signal_return_offset = offset;
3104 -
3105 - /*
3106 - * Copy signal return handlers into the vector page, and
3107 - * set sigreturn to be a pointer to these.
3108 - */
3109 - memcpy(addr + offset, sigreturn_codes, sizeof(sigreturn_codes));
3110 -
3111 - ptr = (unsigned long)addr + offset;
3112 - flush_icache_range(ptr, ptr + sizeof(sigreturn_codes));
3113 -
3114 - return page;
3115 -}
3116 diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c
3117 index 7c4fada..8581286 100644
3118 --- a/arch/arm/kernel/smp.c
3119 +++ b/arch/arm/kernel/smp.c
3120 @@ -73,7 +73,7 @@ enum ipi_msg_type {
3121
3122 static DECLARE_COMPLETION(cpu_running);
3123
3124 -static struct smp_operations smp_ops;
3125 +static struct smp_operations smp_ops __read_only;
3126
3127 void __init smp_set_ops(struct smp_operations *ops)
3128 {
3129 diff --git a/arch/arm/kernel/tcm.c b/arch/arm/kernel/tcm.c
3130 index 7a3be1d..b00c7de 100644
3131 --- a/arch/arm/kernel/tcm.c
3132 +++ b/arch/arm/kernel/tcm.c
3133 @@ -61,7 +61,7 @@ static struct map_desc itcm_iomap[] __initdata = {
3134 .virtual = ITCM_OFFSET,
3135 .pfn = __phys_to_pfn(ITCM_OFFSET),
3136 .length = 0,
3137 - .type = MT_MEMORY_RWX_ITCM,
3138 + .type = MT_MEMORY_RX_ITCM,
3139 }
3140 };
3141
3142 @@ -267,7 +267,9 @@ no_dtcm:
3143 start = &__sitcm_text;
3144 end = &__eitcm_text;
3145 ram = &__itcm_start;
3146 + pax_open_kernel();
3147 memcpy(start, ram, itcm_code_sz);
3148 + pax_close_kernel();
3149 pr_debug("CPU ITCM: copied code from %p - %p\n",
3150 start, end);
3151 itcm_present = true;
3152 diff --git a/arch/arm/kernel/traps.c b/arch/arm/kernel/traps.c
3153 index abd2fc0..895dbb6 100644
3154 --- a/arch/arm/kernel/traps.c
3155 +++ b/arch/arm/kernel/traps.c
3156 @@ -62,7 +62,7 @@ static void dump_mem(const char *, const char *, unsigned long, unsigned long);
3157 void dump_backtrace_entry(unsigned long where, unsigned long from, unsigned long frame)
3158 {
3159 #ifdef CONFIG_KALLSYMS
3160 - printk("[<%08lx>] (%ps) from [<%08lx>] (%pS)\n", where, (void *)where, from, (void *)from);
3161 + printk("[<%08lx>] (%pA) from [<%08lx>] (%pA)\n", where, (void *)where, from, (void *)from);
3162 #else
3163 printk("Function entered at [<%08lx>] from [<%08lx>]\n", where, from);
3164 #endif
3165 @@ -264,6 +264,8 @@ static arch_spinlock_t die_lock = __ARCH_SPIN_LOCK_UNLOCKED;
3166 static int die_owner = -1;
3167 static unsigned int die_nest_count;
3168
3169 +extern void gr_handle_kernel_exploit(void);
3170 +
3171 static unsigned long oops_begin(void)
3172 {
3173 int cpu;
3174 @@ -306,6 +308,9 @@ static void oops_end(unsigned long flags, struct pt_regs *regs, int signr)
3175 panic("Fatal exception in interrupt");
3176 if (panic_on_oops)
3177 panic("Fatal exception");
3178 +
3179 + gr_handle_kernel_exploit();
3180 +
3181 if (signr)
3182 do_exit(signr);
3183 }
3184 @@ -643,7 +648,9 @@ asmlinkage int arm_syscall(int no, struct pt_regs *regs)
3185 * The user helper at 0xffff0fe0 must be used instead.
3186 * (see entry-armv.S for details)
3187 */
3188 + pax_open_kernel();
3189 *((unsigned int *)0xffff0ff0) = regs->ARM_r0;
3190 + pax_close_kernel();
3191 }
3192 return 0;
3193
3194 @@ -900,7 +907,11 @@ void __init early_trap_init(void *vectors_base)
3195 kuser_init(vectors_base);
3196
3197 flush_icache_range(vectors, vectors + PAGE_SIZE * 2);
3198 - modify_domain(DOMAIN_USER, DOMAIN_CLIENT);
3199 +
3200 +#ifndef CONFIG_PAX_MEMORY_UDEREF
3201 + modify_domain(DOMAIN_USER, DOMAIN_USERCLIENT);
3202 +#endif
3203 +
3204 #else /* ifndef CONFIG_CPU_V7M */
3205 /*
3206 * on V7-M there is no need to copy the vector table to a dedicated
3207 diff --git a/arch/arm/kernel/vmlinux.lds.S b/arch/arm/kernel/vmlinux.lds.S
3208 index 7bcee5c..e2f3249 100644
3209 --- a/arch/arm/kernel/vmlinux.lds.S
3210 +++ b/arch/arm/kernel/vmlinux.lds.S
3211 @@ -8,7 +8,11 @@
3212 #include <asm/thread_info.h>
3213 #include <asm/memory.h>
3214 #include <asm/page.h>
3215 -
3216 +
3217 +#ifdef CONFIG_PAX_KERNEXEC
3218 +#include <asm/pgtable.h>
3219 +#endif
3220 +
3221 #define PROC_INFO \
3222 . = ALIGN(4); \
3223 VMLINUX_SYMBOL(__proc_info_begin) = .; \
3224 @@ -34,7 +38,7 @@
3225 #endif
3226
3227 #if (defined(CONFIG_SMP_ON_UP) && !defined(CONFIG_DEBUG_SPINLOCK)) || \
3228 - defined(CONFIG_GENERIC_BUG)
3229 + defined(CONFIG_GENERIC_BUG) || defined(CONFIG_PAX_REFCOUNT)
3230 #define ARM_EXIT_KEEP(x) x
3231 #define ARM_EXIT_DISCARD(x)
3232 #else
3233 @@ -90,6 +94,11 @@ SECTIONS
3234 _text = .;
3235 HEAD_TEXT
3236 }
3237 +
3238 +#ifdef CONFIG_PAX_KERNEXEC
3239 + . = ALIGN(1<<SECTION_SHIFT);
3240 +#endif
3241 +
3242 .text : { /* Real text segment */
3243 _stext = .; /* Text and read-only data */
3244 __exception_text_start = .;
3245 @@ -112,6 +121,8 @@ SECTIONS
3246 ARM_CPU_KEEP(PROC_INFO)
3247 }
3248
3249 + _etext = .; /* End of text section */
3250 +
3251 RO_DATA(PAGE_SIZE)
3252
3253 . = ALIGN(4);
3254 @@ -142,7 +153,9 @@ SECTIONS
3255
3256 NOTES
3257
3258 - _etext = .; /* End of text and rodata section */
3259 +#ifdef CONFIG_PAX_KERNEXEC
3260 + . = ALIGN(1<<SECTION_SHIFT);
3261 +#endif
3262
3263 #ifndef CONFIG_XIP_KERNEL
3264 . = ALIGN(PAGE_SIZE);
3265 @@ -220,6 +233,11 @@ SECTIONS
3266 . = PAGE_OFFSET + TEXT_OFFSET;
3267 #else
3268 __init_end = .;
3269 +
3270 +#ifdef CONFIG_PAX_KERNEXEC
3271 + . = ALIGN(1<<SECTION_SHIFT);
3272 +#endif
3273 +
3274 . = ALIGN(THREAD_SIZE);
3275 __data_loc = .;
3276 #endif
3277 diff --git a/arch/arm/kvm/arm.c b/arch/arm/kvm/arm.c
3278 index f0e50a0..8d5d36c 100644
3279 --- a/arch/arm/kvm/arm.c
3280 +++ b/arch/arm/kvm/arm.c
3281 @@ -57,7 +57,7 @@ static unsigned long hyp_default_vectors;
3282 static DEFINE_PER_CPU(struct kvm_vcpu *, kvm_arm_running_vcpu);
3283
3284 /* The VMID used in the VTTBR */
3285 -static atomic64_t kvm_vmid_gen = ATOMIC64_INIT(1);
3286 +static atomic64_unchecked_t kvm_vmid_gen = ATOMIC64_INIT(1);
3287 static u8 kvm_next_vmid;
3288 static DEFINE_SPINLOCK(kvm_vmid_lock);
3289
3290 @@ -408,7 +408,7 @@ void force_vm_exit(const cpumask_t *mask)
3291 */
3292 static bool need_new_vmid_gen(struct kvm *kvm)
3293 {
3294 - return unlikely(kvm->arch.vmid_gen != atomic64_read(&kvm_vmid_gen));
3295 + return unlikely(kvm->arch.vmid_gen != atomic64_read_unchecked(&kvm_vmid_gen));
3296 }
3297
3298 /**
3299 @@ -441,7 +441,7 @@ static void update_vttbr(struct kvm *kvm)
3300
3301 /* First user of a new VMID generation? */
3302 if (unlikely(kvm_next_vmid == 0)) {
3303 - atomic64_inc(&kvm_vmid_gen);
3304 + atomic64_inc_unchecked(&kvm_vmid_gen);
3305 kvm_next_vmid = 1;
3306
3307 /*
3308 @@ -458,7 +458,7 @@ static void update_vttbr(struct kvm *kvm)
3309 kvm_call_hyp(__kvm_flush_vm_context);
3310 }
3311
3312 - kvm->arch.vmid_gen = atomic64_read(&kvm_vmid_gen);
3313 + kvm->arch.vmid_gen = atomic64_read_unchecked(&kvm_vmid_gen);
3314 kvm->arch.vmid = kvm_next_vmid;
3315 kvm_next_vmid++;
3316
3317 diff --git a/arch/arm/lib/clear_user.S b/arch/arm/lib/clear_user.S
3318 index 14a0d98..7771a7d 100644
3319 --- a/arch/arm/lib/clear_user.S
3320 +++ b/arch/arm/lib/clear_user.S
3321 @@ -12,14 +12,14 @@
3322
3323 .text
3324
3325 -/* Prototype: int __clear_user(void *addr, size_t sz)
3326 +/* Prototype: int ___clear_user(void *addr, size_t sz)
3327 * Purpose : clear some user memory
3328 * Params : addr - user memory address to clear
3329 * : sz - number of bytes to clear
3330 * Returns : number of bytes NOT cleared
3331 */
3332 ENTRY(__clear_user_std)
3333 -WEAK(__clear_user)
3334 +WEAK(___clear_user)
3335 stmfd sp!, {r1, lr}
3336 mov r2, #0
3337 cmp r1, #4
3338 @@ -44,7 +44,7 @@ WEAK(__clear_user)
3339 USER( strnebt r2, [r0])
3340 mov r0, #0
3341 ldmfd sp!, {r1, pc}
3342 -ENDPROC(__clear_user)
3343 +ENDPROC(___clear_user)
3344 ENDPROC(__clear_user_std)
3345
3346 .pushsection .fixup,"ax"
3347 diff --git a/arch/arm/lib/copy_from_user.S b/arch/arm/lib/copy_from_user.S
3348 index 66a477a..bee61d3 100644
3349 --- a/arch/arm/lib/copy_from_user.S
3350 +++ b/arch/arm/lib/copy_from_user.S
3351 @@ -16,7 +16,7 @@
3352 /*
3353 * Prototype:
3354 *
3355 - * size_t __copy_from_user(void *to, const void *from, size_t n)
3356 + * size_t ___copy_from_user(void *to, const void *from, size_t n)
3357 *
3358 * Purpose:
3359 *
3360 @@ -84,11 +84,11 @@
3361
3362 .text
3363
3364 -ENTRY(__copy_from_user)
3365 +ENTRY(___copy_from_user)
3366
3367 #include "copy_template.S"
3368
3369 -ENDPROC(__copy_from_user)
3370 +ENDPROC(___copy_from_user)
3371
3372 .pushsection .fixup,"ax"
3373 .align 0
3374 diff --git a/arch/arm/lib/copy_page.S b/arch/arm/lib/copy_page.S
3375 index 6ee2f67..d1cce76 100644
3376 --- a/arch/arm/lib/copy_page.S
3377 +++ b/arch/arm/lib/copy_page.S
3378 @@ -10,6 +10,7 @@
3379 * ASM optimised string functions
3380 */
3381 #include <linux/linkage.h>
3382 +#include <linux/const.h>
3383 #include <asm/assembler.h>
3384 #include <asm/asm-offsets.h>
3385 #include <asm/cache.h>
3386 diff --git a/arch/arm/lib/copy_to_user.S b/arch/arm/lib/copy_to_user.S
3387 index d066df6..df28194 100644
3388 --- a/arch/arm/lib/copy_to_user.S
3389 +++ b/arch/arm/lib/copy_to_user.S
3390 @@ -16,7 +16,7 @@
3391 /*
3392 * Prototype:
3393 *
3394 - * size_t __copy_to_user(void *to, const void *from, size_t n)
3395 + * size_t ___copy_to_user(void *to, const void *from, size_t n)
3396 *
3397 * Purpose:
3398 *
3399 @@ -88,11 +88,11 @@
3400 .text
3401
3402 ENTRY(__copy_to_user_std)
3403 -WEAK(__copy_to_user)
3404 +WEAK(___copy_to_user)
3405
3406 #include "copy_template.S"
3407
3408 -ENDPROC(__copy_to_user)
3409 +ENDPROC(___copy_to_user)
3410 ENDPROC(__copy_to_user_std)
3411
3412 .pushsection .fixup,"ax"
3413 diff --git a/arch/arm/lib/csumpartialcopyuser.S b/arch/arm/lib/csumpartialcopyuser.S
3414 index 7d08b43..f7ca7ea 100644
3415 --- a/arch/arm/lib/csumpartialcopyuser.S
3416 +++ b/arch/arm/lib/csumpartialcopyuser.S
3417 @@ -57,8 +57,8 @@
3418 * Returns : r0 = checksum, [[sp, #0], #0] = 0 or -EFAULT
3419 */
3420
3421 -#define FN_ENTRY ENTRY(csum_partial_copy_from_user)
3422 -#define FN_EXIT ENDPROC(csum_partial_copy_from_user)
3423 +#define FN_ENTRY ENTRY(__csum_partial_copy_from_user)
3424 +#define FN_EXIT ENDPROC(__csum_partial_copy_from_user)
3425
3426 #include "csumpartialcopygeneric.S"
3427
3428 diff --git a/arch/arm/lib/delay.c b/arch/arm/lib/delay.c
3429 index 5306de3..aed6d03 100644
3430 --- a/arch/arm/lib/delay.c
3431 +++ b/arch/arm/lib/delay.c
3432 @@ -28,7 +28,7 @@
3433 /*
3434 * Default to the loop-based delay implementation.
3435 */
3436 -struct arm_delay_ops arm_delay_ops = {
3437 +struct arm_delay_ops arm_delay_ops __read_only = {
3438 .delay = __loop_delay,
3439 .const_udelay = __loop_const_udelay,
3440 .udelay = __loop_udelay,
3441 diff --git a/arch/arm/lib/uaccess_with_memcpy.c b/arch/arm/lib/uaccess_with_memcpy.c
3442 index 3e58d71..029817c 100644
3443 --- a/arch/arm/lib/uaccess_with_memcpy.c
3444 +++ b/arch/arm/lib/uaccess_with_memcpy.c
3445 @@ -136,7 +136,7 @@ out:
3446 }
3447
3448 unsigned long
3449 -__copy_to_user(void __user *to, const void *from, unsigned long n)
3450 +___copy_to_user(void __user *to, const void *from, unsigned long n)
3451 {
3452 /*
3453 * This test is stubbed out of the main function above to keep
3454 @@ -190,7 +190,7 @@ out:
3455 return n;
3456 }
3457
3458 -unsigned long __clear_user(void __user *addr, unsigned long n)
3459 +unsigned long ___clear_user(void __user *addr, unsigned long n)
3460 {
3461 /* See rational for this in __copy_to_user() above. */
3462 if (n < 64)
3463 diff --git a/arch/arm/mach-at91/setup.c b/arch/arm/mach-at91/setup.c
3464 index f7a07a5..258e1f7 100644
3465 --- a/arch/arm/mach-at91/setup.c
3466 +++ b/arch/arm/mach-at91/setup.c
3467 @@ -81,7 +81,7 @@ void __init at91_init_sram(int bank, unsigned long base, unsigned int length)
3468
3469 desc->pfn = __phys_to_pfn(base);
3470 desc->length = length;
3471 - desc->type = MT_MEMORY_RWX_NONCACHED;
3472 + desc->type = MT_MEMORY_RW_NONCACHED;
3473
3474 pr_info("AT91: sram at 0x%lx of 0x%x mapped at 0x%lx\n",
3475 base, length, desc->virtual);
3476 diff --git a/arch/arm/mach-kirkwood/common.c b/arch/arm/mach-kirkwood/common.c
3477 index 255f33a..507b157 100644
3478 --- a/arch/arm/mach-kirkwood/common.c
3479 +++ b/arch/arm/mach-kirkwood/common.c
3480 @@ -157,7 +157,16 @@ static void clk_gate_fn_disable(struct clk_hw *hw)
3481 clk_gate_ops.disable(hw);
3482 }
3483
3484 -static struct clk_ops clk_gate_fn_ops;
3485 +static int clk_gate_fn_is_enabled(struct clk_hw *hw)
3486 +{
3487 + return clk_gate_ops.is_enabled(hw);
3488 +}
3489 +
3490 +static struct clk_ops clk_gate_fn_ops = {
3491 + .enable = clk_gate_fn_enable,
3492 + .disable = clk_gate_fn_disable,
3493 + .is_enabled = clk_gate_fn_is_enabled,
3494 +};
3495
3496 static struct clk __init *clk_register_gate_fn(struct device *dev,
3497 const char *name,
3498 @@ -191,14 +200,6 @@ static struct clk __init *clk_register_gate_fn(struct device *dev,
3499 gate_fn->fn_en = fn_en;
3500 gate_fn->fn_dis = fn_dis;
3501
3502 - /* ops is the gate ops, but with our enable/disable functions */
3503 - if (clk_gate_fn_ops.enable != clk_gate_fn_enable ||
3504 - clk_gate_fn_ops.disable != clk_gate_fn_disable) {
3505 - clk_gate_fn_ops = clk_gate_ops;
3506 - clk_gate_fn_ops.enable = clk_gate_fn_enable;
3507 - clk_gate_fn_ops.disable = clk_gate_fn_disable;
3508 - }
3509 -
3510 clk = clk_register(dev, &gate_fn->gate.hw);
3511
3512 if (IS_ERR(clk))
3513 diff --git a/arch/arm/mach-omap2/board-n8x0.c b/arch/arm/mach-omap2/board-n8x0.c
3514 index aead77a..a2253fa 100644
3515 --- a/arch/arm/mach-omap2/board-n8x0.c
3516 +++ b/arch/arm/mach-omap2/board-n8x0.c
3517 @@ -568,7 +568,7 @@ static int n8x0_menelaus_late_init(struct device *dev)
3518 }
3519 #endif
3520
3521 -static struct menelaus_platform_data n8x0_menelaus_platform_data __initdata = {
3522 +static struct menelaus_platform_data n8x0_menelaus_platform_data __initconst = {
3523 .late_init = n8x0_menelaus_late_init,
3524 };
3525
3526 diff --git a/arch/arm/mach-omap2/gpmc.c b/arch/arm/mach-omap2/gpmc.c
3527 index 9fe8c94..c014a4d 100644
3528 --- a/arch/arm/mach-omap2/gpmc.c
3529 +++ b/arch/arm/mach-omap2/gpmc.c
3530 @@ -148,7 +148,6 @@ struct omap3_gpmc_regs {
3531 };
3532
3533 static struct gpmc_client_irq gpmc_client_irq[GPMC_NR_IRQ];
3534 -static struct irq_chip gpmc_irq_chip;
3535 static int gpmc_irq_start;
3536
3537 static struct resource gpmc_mem_root;
3538 @@ -727,6 +726,18 @@ static void gpmc_irq_noop(struct irq_data *data) { }
3539
3540 static unsigned int gpmc_irq_noop_ret(struct irq_data *data) { return 0; }
3541
3542 +static struct irq_chip gpmc_irq_chip = {
3543 + .name = "gpmc",
3544 + .irq_startup = gpmc_irq_noop_ret,
3545 + .irq_enable = gpmc_irq_enable,
3546 + .irq_disable = gpmc_irq_disable,
3547 + .irq_shutdown = gpmc_irq_noop,
3548 + .irq_ack = gpmc_irq_noop,
3549 + .irq_mask = gpmc_irq_noop,
3550 + .irq_unmask = gpmc_irq_noop,
3551 +
3552 +};
3553 +
3554 static int gpmc_setup_irq(void)
3555 {
3556 int i;
3557 @@ -741,15 +752,6 @@ static int gpmc_setup_irq(void)
3558 return gpmc_irq_start;
3559 }
3560
3561 - gpmc_irq_chip.name = "gpmc";
3562 - gpmc_irq_chip.irq_startup = gpmc_irq_noop_ret;
3563 - gpmc_irq_chip.irq_enable = gpmc_irq_enable;
3564 - gpmc_irq_chip.irq_disable = gpmc_irq_disable;
3565 - gpmc_irq_chip.irq_shutdown = gpmc_irq_noop;
3566 - gpmc_irq_chip.irq_ack = gpmc_irq_noop;
3567 - gpmc_irq_chip.irq_mask = gpmc_irq_noop;
3568 - gpmc_irq_chip.irq_unmask = gpmc_irq_noop;
3569 -
3570 gpmc_client_irq[0].bitmask = GPMC_IRQ_FIFOEVENTENABLE;
3571 gpmc_client_irq[1].bitmask = GPMC_IRQ_COUNT_EVENT;
3572
3573 diff --git a/arch/arm/mach-omap2/omap-mpuss-lowpower.c b/arch/arm/mach-omap2/omap-mpuss-lowpower.c
3574 index 667915d..2ee1219 100644
3575 --- a/arch/arm/mach-omap2/omap-mpuss-lowpower.c
3576 +++ b/arch/arm/mach-omap2/omap-mpuss-lowpower.c
3577 @@ -84,7 +84,7 @@ struct cpu_pm_ops {
3578 int (*finish_suspend)(unsigned long cpu_state);
3579 void (*resume)(void);
3580 void (*scu_prepare)(unsigned int cpu_id, unsigned int cpu_state);
3581 -};
3582 +} __no_const;
3583
3584 static DEFINE_PER_CPU(struct omap4_cpu_pm_info, omap4_pm_info);
3585 static struct powerdomain *mpuss_pd;
3586 @@ -102,7 +102,7 @@ static void dummy_cpu_resume(void)
3587 static void dummy_scu_prepare(unsigned int cpu_id, unsigned int cpu_state)
3588 {}
3589
3590 -struct cpu_pm_ops omap_pm_ops = {
3591 +static struct cpu_pm_ops omap_pm_ops __read_only = {
3592 .finish_suspend = default_finish_suspend,
3593 .resume = dummy_cpu_resume,
3594 .scu_prepare = dummy_scu_prepare,
3595 diff --git a/arch/arm/mach-omap2/omap-wakeupgen.c b/arch/arm/mach-omap2/omap-wakeupgen.c
3596 index 693fe48..c15ea73 100644
3597 --- a/arch/arm/mach-omap2/omap-wakeupgen.c
3598 +++ b/arch/arm/mach-omap2/omap-wakeupgen.c
3599 @@ -343,7 +343,7 @@ static int irq_cpu_hotplug_notify(struct notifier_block *self,
3600 return NOTIFY_OK;
3601 }
3602
3603 -static struct notifier_block __refdata irq_hotplug_notifier = {
3604 +static struct notifier_block irq_hotplug_notifier = {
3605 .notifier_call = irq_cpu_hotplug_notify,
3606 };
3607
3608 diff --git a/arch/arm/mach-omap2/omap_device.c b/arch/arm/mach-omap2/omap_device.c
3609 index 01ef59d..32ae28a8 100644
3610 --- a/arch/arm/mach-omap2/omap_device.c
3611 +++ b/arch/arm/mach-omap2/omap_device.c
3612 @@ -510,7 +510,7 @@ void omap_device_delete(struct omap_device *od)
3613 struct platform_device __init *omap_device_build(const char *pdev_name,
3614 int pdev_id,
3615 struct omap_hwmod *oh,
3616 - void *pdata, int pdata_len)
3617 + const void *pdata, int pdata_len)
3618 {
3619 struct omap_hwmod *ohs[] = { oh };
3620
3621 @@ -538,7 +538,7 @@ struct platform_device __init *omap_device_build(const char *pdev_name,
3622 struct platform_device __init *omap_device_build_ss(const char *pdev_name,
3623 int pdev_id,
3624 struct omap_hwmod **ohs,
3625 - int oh_cnt, void *pdata,
3626 + int oh_cnt, const void *pdata,
3627 int pdata_len)
3628 {
3629 int ret = -ENOMEM;
3630 diff --git a/arch/arm/mach-omap2/omap_device.h b/arch/arm/mach-omap2/omap_device.h
3631 index 78c02b3..c94109a 100644
3632 --- a/arch/arm/mach-omap2/omap_device.h
3633 +++ b/arch/arm/mach-omap2/omap_device.h
3634 @@ -72,12 +72,12 @@ int omap_device_idle(struct platform_device *pdev);
3635 /* Core code interface */
3636
3637 struct platform_device *omap_device_build(const char *pdev_name, int pdev_id,
3638 - struct omap_hwmod *oh, void *pdata,
3639 + struct omap_hwmod *oh, const void *pdata,
3640 int pdata_len);
3641
3642 struct platform_device *omap_device_build_ss(const char *pdev_name, int pdev_id,
3643 struct omap_hwmod **oh, int oh_cnt,
3644 - void *pdata, int pdata_len);
3645 + const void *pdata, int pdata_len);
3646
3647 struct omap_device *omap_device_alloc(struct platform_device *pdev,
3648 struct omap_hwmod **ohs, int oh_cnt);
3649 diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
3650 index 66c60fe..c78950d 100644
3651 --- a/arch/arm/mach-omap2/omap_hwmod.c
3652 +++ b/arch/arm/mach-omap2/omap_hwmod.c
3653 @@ -194,10 +194,10 @@ struct omap_hwmod_soc_ops {
3654 int (*init_clkdm)(struct omap_hwmod *oh);
3655 void (*update_context_lost)(struct omap_hwmod *oh);
3656 int (*get_context_lost)(struct omap_hwmod *oh);
3657 -};
3658 +} __no_const;
3659
3660 /* soc_ops: adapts the omap_hwmod code to the currently-booted SoC */
3661 -static struct omap_hwmod_soc_ops soc_ops;
3662 +static struct omap_hwmod_soc_ops soc_ops __read_only;
3663
3664 /* omap_hwmod_list contains all registered struct omap_hwmods */
3665 static LIST_HEAD(omap_hwmod_list);
3666 diff --git a/arch/arm/mach-omap2/powerdomains43xx_data.c b/arch/arm/mach-omap2/powerdomains43xx_data.c
3667 index 95fee54..cfa9cf1 100644
3668 --- a/arch/arm/mach-omap2/powerdomains43xx_data.c
3669 +++ b/arch/arm/mach-omap2/powerdomains43xx_data.c
3670 @@ -10,6 +10,7 @@
3671
3672 #include <linux/kernel.h>
3673 #include <linux/init.h>
3674 +#include <asm/pgtable.h>
3675
3676 #include "powerdomain.h"
3677
3678 @@ -129,7 +130,9 @@ static int am43xx_check_vcvp(void)
3679
3680 void __init am43xx_powerdomains_init(void)
3681 {
3682 - omap4_pwrdm_operations.pwrdm_has_voltdm = am43xx_check_vcvp;
3683 + pax_open_kernel();
3684 + *(void **)&omap4_pwrdm_operations.pwrdm_has_voltdm = am43xx_check_vcvp;
3685 + pax_close_kernel();
3686 pwrdm_register_platform_funcs(&omap4_pwrdm_operations);
3687 pwrdm_register_pwrdms(powerdomains_am43xx);
3688 pwrdm_complete_init();
3689 diff --git a/arch/arm/mach-omap2/wd_timer.c b/arch/arm/mach-omap2/wd_timer.c
3690 index d15c7bb..b2d1f0c 100644
3691 --- a/arch/arm/mach-omap2/wd_timer.c
3692 +++ b/arch/arm/mach-omap2/wd_timer.c
3693 @@ -110,7 +110,9 @@ static int __init omap_init_wdt(void)
3694 struct omap_hwmod *oh;
3695 char *oh_name = "wd_timer2";
3696 char *dev_name = "omap_wdt";
3697 - struct omap_wd_timer_platform_data pdata;
3698 + static struct omap_wd_timer_platform_data pdata = {
3699 + .read_reset_sources = prm_read_reset_sources
3700 + };
3701
3702 if (!cpu_class_is_omap2() || of_have_populated_dt())
3703 return 0;
3704 @@ -121,8 +123,6 @@ static int __init omap_init_wdt(void)
3705 return -EINVAL;
3706 }
3707
3708 - pdata.read_reset_sources = prm_read_reset_sources;
3709 -
3710 pdev = omap_device_build(dev_name, id, oh, &pdata,
3711 sizeof(struct omap_wd_timer_platform_data));
3712 WARN(IS_ERR(pdev), "Can't build omap_device for %s:%s.\n",
3713 diff --git a/arch/arm/mach-tegra/cpuidle-tegra20.c b/arch/arm/mach-tegra/cpuidle-tegra20.c
3714 index b82dcae..44ee5b6 100644
3715 --- a/arch/arm/mach-tegra/cpuidle-tegra20.c
3716 +++ b/arch/arm/mach-tegra/cpuidle-tegra20.c
3717 @@ -180,7 +180,7 @@ static int tegra20_idle_lp2_coupled(struct cpuidle_device *dev,
3718 bool entered_lp2 = false;
3719
3720 if (tegra_pending_sgi())
3721 - ACCESS_ONCE(abort_flag) = true;
3722 + ACCESS_ONCE_RW(abort_flag) = true;
3723
3724 cpuidle_coupled_parallel_barrier(dev, &abort_barrier);
3725
3726 diff --git a/arch/arm/mach-ux500/setup.h b/arch/arm/mach-ux500/setup.h
3727 index 2dea8b5..6499da2 100644
3728 --- a/arch/arm/mach-ux500/setup.h
3729 +++ b/arch/arm/mach-ux500/setup.h
3730 @@ -33,13 +33,6 @@ extern void ux500_timer_init(void);
3731 .type = MT_DEVICE, \
3732 }
3733
3734 -#define __MEM_DEV_DESC(x, sz) { \
3735 - .virtual = IO_ADDRESS(x), \
3736 - .pfn = __phys_to_pfn(x), \
3737 - .length = sz, \
3738 - .type = MT_MEMORY_RWX, \
3739 -}
3740 -
3741 extern struct smp_operations ux500_smp_ops;
3742 extern void ux500_cpu_die(unsigned int cpu);
3743
3744 diff --git a/arch/arm/mm/Kconfig b/arch/arm/mm/Kconfig
3745 index 5bf7c3c..571e67e 100644
3746 --- a/arch/arm/mm/Kconfig
3747 +++ b/arch/arm/mm/Kconfig
3748 @@ -446,6 +446,7 @@ config CPU_32v5
3749
3750 config CPU_32v6
3751 bool
3752 + select CPU_USE_DOMAINS if CPU_V6 && MMU && !PAX_KERNEXEC && !PAX_MEMORY_UDEREF
3753 select TLS_REG_EMUL if !CPU_32v6K && !MMU
3754
3755 config CPU_32v6K
3756 @@ -600,6 +601,7 @@ config CPU_CP15_MPU
3757
3758 config CPU_USE_DOMAINS
3759 bool
3760 + depends on !ARM_LPAE && !PAX_KERNEXEC && !PAX_MEMORY_UDEREF
3761 help
3762 This option enables or disables the use of domain switching
3763 via the set_fs() function.
3764 @@ -799,6 +801,7 @@ config NEED_KUSER_HELPERS
3765 config KUSER_HELPERS
3766 bool "Enable kuser helpers in vector page" if !NEED_KUSER_HELPERS
3767 default y
3768 + depends on !(CPU_V6 || CPU_V6K || CPU_V7) || GRKERNSEC_OLD_ARM_USERLAND
3769 help
3770 Warning: disabling this option may break user programs.
3771
3772 @@ -811,7 +814,7 @@ config KUSER_HELPERS
3773 See Documentation/arm/kernel_user_helpers.txt for details.
3774
3775 However, the fixed address nature of these helpers can be used
3776 - by ROP (return orientated programming) authors when creating
3777 + by ROP (Return Oriented Programming) authors when creating
3778 exploits.
3779
3780 If all of the binaries and libraries which run on your platform
3781 diff --git a/arch/arm/mm/alignment.c b/arch/arm/mm/alignment.c
3782 index 9240364..a2b8cf3 100644
3783 --- a/arch/arm/mm/alignment.c
3784 +++ b/arch/arm/mm/alignment.c
3785 @@ -212,10 +212,12 @@ union offset_union {
3786 #define __get16_unaligned_check(ins,val,addr) \
3787 do { \
3788 unsigned int err = 0, v, a = addr; \
3789 + pax_open_userland(); \
3790 __get8_unaligned_check(ins,v,a,err); \
3791 val = v << ((BE) ? 8 : 0); \
3792 __get8_unaligned_check(ins,v,a,err); \
3793 val |= v << ((BE) ? 0 : 8); \
3794 + pax_close_userland(); \
3795 if (err) \
3796 goto fault; \
3797 } while (0)
3798 @@ -229,6 +231,7 @@ union offset_union {
3799 #define __get32_unaligned_check(ins,val,addr) \
3800 do { \
3801 unsigned int err = 0, v, a = addr; \
3802 + pax_open_userland(); \
3803 __get8_unaligned_check(ins,v,a,err); \
3804 val = v << ((BE) ? 24 : 0); \
3805 __get8_unaligned_check(ins,v,a,err); \
3806 @@ -237,6 +240,7 @@ union offset_union {
3807 val |= v << ((BE) ? 8 : 16); \
3808 __get8_unaligned_check(ins,v,a,err); \
3809 val |= v << ((BE) ? 0 : 24); \
3810 + pax_close_userland(); \
3811 if (err) \
3812 goto fault; \
3813 } while (0)
3814 @@ -250,6 +254,7 @@ union offset_union {
3815 #define __put16_unaligned_check(ins,val,addr) \
3816 do { \
3817 unsigned int err = 0, v = val, a = addr; \
3818 + pax_open_userland(); \
3819 __asm__( FIRST_BYTE_16 \
3820 ARM( "1: "ins" %1, [%2], #1\n" ) \
3821 THUMB( "1: "ins" %1, [%2]\n" ) \
3822 @@ -269,6 +274,7 @@ union offset_union {
3823 " .popsection\n" \
3824 : "=r" (err), "=&r" (v), "=&r" (a) \
3825 : "0" (err), "1" (v), "2" (a)); \
3826 + pax_close_userland(); \
3827 if (err) \
3828 goto fault; \
3829 } while (0)
3830 @@ -282,6 +288,7 @@ union offset_union {
3831 #define __put32_unaligned_check(ins,val,addr) \
3832 do { \
3833 unsigned int err = 0, v = val, a = addr; \
3834 + pax_open_userland(); \
3835 __asm__( FIRST_BYTE_32 \
3836 ARM( "1: "ins" %1, [%2], #1\n" ) \
3837 THUMB( "1: "ins" %1, [%2]\n" ) \
3838 @@ -311,6 +318,7 @@ union offset_union {
3839 " .popsection\n" \
3840 : "=r" (err), "=&r" (v), "=&r" (a) \
3841 : "0" (err), "1" (v), "2" (a)); \
3842 + pax_close_userland(); \
3843 if (err) \
3844 goto fault; \
3845 } while (0)
3846 diff --git a/arch/arm/mm/cache-l2x0.c b/arch/arm/mm/cache-l2x0.c
3847 index 7abde2c..9df495f 100644
3848 --- a/arch/arm/mm/cache-l2x0.c
3849 +++ b/arch/arm/mm/cache-l2x0.c
3850 @@ -46,7 +46,7 @@ struct l2x0_of_data {
3851 void (*setup)(const struct device_node *, u32 *, u32 *);
3852 void (*save)(void);
3853 struct outer_cache_fns outer_cache;
3854 -};
3855 +} __do_const;
3856
3857 static bool of_init = false;
3858
3859 diff --git a/arch/arm/mm/context.c b/arch/arm/mm/context.c
3860 index 6eb97b3..ac509f6 100644
3861 --- a/arch/arm/mm/context.c
3862 +++ b/arch/arm/mm/context.c
3863 @@ -43,7 +43,7 @@
3864 #define NUM_USER_ASIDS ASID_FIRST_VERSION
3865
3866 static DEFINE_RAW_SPINLOCK(cpu_asid_lock);
3867 -static atomic64_t asid_generation = ATOMIC64_INIT(ASID_FIRST_VERSION);
3868 +static atomic64_unchecked_t asid_generation = ATOMIC64_INIT(ASID_FIRST_VERSION);
3869 static DECLARE_BITMAP(asid_map, NUM_USER_ASIDS);
3870
3871 static DEFINE_PER_CPU(atomic64_t, active_asids);
3872 @@ -182,7 +182,7 @@ static u64 new_context(struct mm_struct *mm, unsigned int cpu)
3873 {
3874 static u32 cur_idx = 1;
3875 u64 asid = atomic64_read(&mm->context.id);
3876 - u64 generation = atomic64_read(&asid_generation);
3877 + u64 generation = atomic64_read_unchecked(&asid_generation);
3878
3879 if (asid != 0 && is_reserved_asid(asid)) {
3880 /*
3881 @@ -203,7 +203,7 @@ static u64 new_context(struct mm_struct *mm, unsigned int cpu)
3882 */
3883 asid = find_next_zero_bit(asid_map, NUM_USER_ASIDS, cur_idx);
3884 if (asid == NUM_USER_ASIDS) {
3885 - generation = atomic64_add_return(ASID_FIRST_VERSION,
3886 + generation = atomic64_add_return_unchecked(ASID_FIRST_VERSION,
3887 &asid_generation);
3888 flush_context(cpu);
3889 asid = find_next_zero_bit(asid_map, NUM_USER_ASIDS, 1);
3890 @@ -234,14 +234,14 @@ void check_and_switch_context(struct mm_struct *mm, struct task_struct *tsk)
3891 cpu_set_reserved_ttbr0();
3892
3893 asid = atomic64_read(&mm->context.id);
3894 - if (!((asid ^ atomic64_read(&asid_generation)) >> ASID_BITS)
3895 + if (!((asid ^ atomic64_read_unchecked(&asid_generation)) >> ASID_BITS)
3896 && atomic64_xchg(&per_cpu(active_asids, cpu), asid))
3897 goto switch_mm_fastpath;
3898
3899 raw_spin_lock_irqsave(&cpu_asid_lock, flags);
3900 /* Check that our ASID belongs to the current generation. */
3901 asid = atomic64_read(&mm->context.id);
3902 - if ((asid ^ atomic64_read(&asid_generation)) >> ASID_BITS) {
3903 + if ((asid ^ atomic64_read_unchecked(&asid_generation)) >> ASID_BITS) {
3904 asid = new_context(mm, cpu);
3905 atomic64_set(&mm->context.id, asid);
3906 }
3907 diff --git a/arch/arm/mm/fault.c b/arch/arm/mm/fault.c
3908 index eb8830a..5360ce7 100644
3909 --- a/arch/arm/mm/fault.c
3910 +++ b/arch/arm/mm/fault.c
3911 @@ -25,6 +25,7 @@
3912 #include <asm/system_misc.h>
3913 #include <asm/system_info.h>
3914 #include <asm/tlbflush.h>
3915 +#include <asm/sections.h>
3916
3917 #include "fault.h"
3918
3919 @@ -138,6 +139,31 @@ __do_kernel_fault(struct mm_struct *mm, unsigned long addr, unsigned int fsr,
3920 if (fixup_exception(regs))
3921 return;
3922
3923 +#ifdef CONFIG_PAX_MEMORY_UDEREF
3924 + if (addr < TASK_SIZE) {
3925 + if (current->signal->curr_ip)
3926 + 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),
3927 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()), addr);
3928 + else
3929 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to access userland memory at %08lx\n", current->comm, task_pid_nr(current),
3930 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()), addr);
3931 + }
3932 +#endif
3933 +
3934 +#ifdef CONFIG_PAX_KERNEXEC
3935 + if ((fsr & FSR_WRITE) &&
3936 + (((unsigned long)_stext <= addr && addr < init_mm.end_code) ||
3937 + (MODULES_VADDR <= addr && addr < MODULES_END)))
3938 + {
3939 + if (current->signal->curr_ip)
3940 + 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),
3941 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
3942 + else
3943 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to modify kernel code\n", current->comm, task_pid_nr(current),
3944 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
3945 + }
3946 +#endif
3947 +
3948 /*
3949 * No handler, we'll have to terminate things with extreme prejudice.
3950 */
3951 @@ -174,6 +200,13 @@ __do_user_fault(struct task_struct *tsk, unsigned long addr,
3952 }
3953 #endif
3954
3955 +#ifdef CONFIG_PAX_PAGEEXEC
3956 + if (fsr & FSR_LNX_PF) {
3957 + pax_report_fault(regs, (void *)regs->ARM_pc, (void *)regs->ARM_sp);
3958 + do_group_exit(SIGKILL);
3959 + }
3960 +#endif
3961 +
3962 tsk->thread.address = addr;
3963 tsk->thread.error_code = fsr;
3964 tsk->thread.trap_no = 14;
3965 @@ -401,6 +434,33 @@ do_page_fault(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
3966 }
3967 #endif /* CONFIG_MMU */
3968
3969 +#ifdef CONFIG_PAX_PAGEEXEC
3970 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
3971 +{
3972 + long i;
3973 +
3974 + printk(KERN_ERR "PAX: bytes at PC: ");
3975 + for (i = 0; i < 20; i++) {
3976 + unsigned char c;
3977 + if (get_user(c, (__force unsigned char __user *)pc+i))
3978 + printk(KERN_CONT "?? ");
3979 + else
3980 + printk(KERN_CONT "%02x ", c);
3981 + }
3982 + printk("\n");
3983 +
3984 + printk(KERN_ERR "PAX: bytes at SP-4: ");
3985 + for (i = -1; i < 20; i++) {
3986 + unsigned long c;
3987 + if (get_user(c, (__force unsigned long __user *)sp+i))
3988 + printk(KERN_CONT "???????? ");
3989 + else
3990 + printk(KERN_CONT "%08lx ", c);
3991 + }
3992 + printk("\n");
3993 +}
3994 +#endif
3995 +
3996 /*
3997 * First Level Translation Fault Handler
3998 *
3999 @@ -548,9 +608,22 @@ do_DataAbort(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
4000 const struct fsr_info *inf = fsr_info + fsr_fs(fsr);
4001 struct siginfo info;
4002
4003 +#ifdef CONFIG_PAX_MEMORY_UDEREF
4004 + if (addr < TASK_SIZE && is_domain_fault(fsr)) {
4005 + if (current->signal->curr_ip)
4006 + 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),
4007 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()), addr);
4008 + else
4009 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to access userland memory at %08lx\n", current->comm, task_pid_nr(current),
4010 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()), addr);
4011 + goto die;
4012 + }
4013 +#endif
4014 +
4015 if (!inf->fn(addr, fsr & ~FSR_LNX_PF, regs))
4016 return;
4017
4018 +die:
4019 printk(KERN_ALERT "Unhandled fault: %s (0x%03x) at 0x%08lx\n",
4020 inf->name, fsr, addr);
4021
4022 @@ -574,15 +647,98 @@ hook_ifault_code(int nr, int (*fn)(unsigned long, unsigned int, struct pt_regs *
4023 ifsr_info[nr].name = name;
4024 }
4025
4026 +asmlinkage int sys_sigreturn(struct pt_regs *regs);
4027 +asmlinkage int sys_rt_sigreturn(struct pt_regs *regs);
4028 +
4029 asmlinkage void __exception
4030 do_PrefetchAbort(unsigned long addr, unsigned int ifsr, struct pt_regs *regs)
4031 {
4032 const struct fsr_info *inf = ifsr_info + fsr_fs(ifsr);
4033 struct siginfo info;
4034 + unsigned long pc = instruction_pointer(regs);
4035 +
4036 + if (user_mode(regs)) {
4037 + unsigned long sigpage = current->mm->context.sigpage;
4038 +
4039 + if (sigpage <= pc && pc < sigpage + 7*4) {
4040 + if (pc < sigpage + 3*4)
4041 + sys_sigreturn(regs);
4042 + else
4043 + sys_rt_sigreturn(regs);
4044 + return;
4045 + }
4046 + if (pc == 0xffff0f60UL) {
4047 + /*
4048 + * PaX: __kuser_cmpxchg64 emulation
4049 + */
4050 + // TODO
4051 + //regs->ARM_pc = regs->ARM_lr;
4052 + //return;
4053 + }
4054 + if (pc == 0xffff0fa0UL) {
4055 + /*
4056 + * PaX: __kuser_memory_barrier emulation
4057 + */
4058 + // dmb(); implied by the exception
4059 + regs->ARM_pc = regs->ARM_lr;
4060 + return;
4061 + }
4062 + if (pc == 0xffff0fc0UL) {
4063 + /*
4064 + * PaX: __kuser_cmpxchg emulation
4065 + */
4066 + // TODO
4067 + //long new;
4068 + //int op;
4069 +
4070 + //op = FUTEX_OP_SET << 28;
4071 + //new = futex_atomic_op_inuser(op, regs->ARM_r2);
4072 + //regs->ARM_r0 = old != new;
4073 + //regs->ARM_pc = regs->ARM_lr;
4074 + //return;
4075 + }
4076 + if (pc == 0xffff0fe0UL) {
4077 + /*
4078 + * PaX: __kuser_get_tls emulation
4079 + */
4080 + regs->ARM_r0 = current_thread_info()->tp_value[0];
4081 + regs->ARM_pc = regs->ARM_lr;
4082 + return;
4083 + }
4084 + }
4085 +
4086 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
4087 + else if (is_domain_fault(ifsr) || is_xn_fault(ifsr)) {
4088 + if (current->signal->curr_ip)
4089 + 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),
4090 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()),
4091 + pc >= TASK_SIZE ? "non-executable kernel" : "userland", pc);
4092 + else
4093 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to execute %s memory at %08lx\n", current->comm, task_pid_nr(current),
4094 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()),
4095 + pc >= TASK_SIZE ? "non-executable kernel" : "userland", pc);
4096 + goto die;
4097 + }
4098 +#endif
4099 +
4100 +#ifdef CONFIG_PAX_REFCOUNT
4101 + if (fsr_fs(ifsr) == FAULT_CODE_DEBUG) {
4102 + unsigned int bkpt;
4103 +
4104 + if (!probe_kernel_address(pc, bkpt) && cpu_to_le32(bkpt) == 0xe12f1073) {
4105 + current->thread.error_code = ifsr;
4106 + current->thread.trap_no = 0;
4107 + pax_report_refcount_overflow(regs);
4108 + fixup_exception(regs);
4109 + return;
4110 + }
4111 + }
4112 +#endif
4113
4114 if (!inf->fn(addr, ifsr | FSR_LNX_PF, regs))
4115 return;
4116
4117 +die:
4118 printk(KERN_ALERT "Unhandled prefetch abort: %s (0x%03x) at 0x%08lx\n",
4119 inf->name, ifsr, addr);
4120
4121 diff --git a/arch/arm/mm/fault.h b/arch/arm/mm/fault.h
4122 index cf08bdf..772656c 100644
4123 --- a/arch/arm/mm/fault.h
4124 +++ b/arch/arm/mm/fault.h
4125 @@ -3,6 +3,7 @@
4126
4127 /*
4128 * Fault status register encodings. We steal bit 31 for our own purposes.
4129 + * Set when the FSR value is from an instruction fault.
4130 */
4131 #define FSR_LNX_PF (1 << 31)
4132 #define FSR_WRITE (1 << 11)
4133 @@ -22,6 +23,17 @@ static inline int fsr_fs(unsigned int fsr)
4134 }
4135 #endif
4136
4137 +/* valid for LPAE and !LPAE */
4138 +static inline int is_xn_fault(unsigned int fsr)
4139 +{
4140 + return ((fsr_fs(fsr) & 0x3c) == 0xc);
4141 +}
4142 +
4143 +static inline int is_domain_fault(unsigned int fsr)
4144 +{
4145 + return ((fsr_fs(fsr) & 0xD) == 0x9);
4146 +}
4147 +
4148 void do_bad_area(unsigned long addr, unsigned int fsr, struct pt_regs *regs);
4149 unsigned long search_exception_table(unsigned long addr);
4150
4151 diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c
4152 index 2a77ba8..68e6a7a 100644
4153 --- a/arch/arm/mm/init.c
4154 +++ b/arch/arm/mm/init.c
4155 @@ -30,6 +30,8 @@
4156 #include <asm/setup.h>
4157 #include <asm/tlb.h>
4158 #include <asm/fixmap.h>
4159 +#include <asm/system_info.h>
4160 +#include <asm/cp15.h>
4161
4162 #include <asm/mach/arch.h>
4163 #include <asm/mach/map.h>
4164 @@ -627,7 +629,46 @@ void free_initmem(void)
4165 {
4166 #ifdef CONFIG_HAVE_TCM
4167 extern char __tcm_start, __tcm_end;
4168 +#endif
4169
4170 +#ifdef CONFIG_PAX_KERNEXEC
4171 + unsigned long addr;
4172 + pgd_t *pgd;
4173 + pud_t *pud;
4174 + pmd_t *pmd;
4175 + int cpu_arch = cpu_architecture();
4176 + unsigned int cr = get_cr();
4177 +
4178 + if (cpu_arch >= CPU_ARCH_ARMv6 && (cr & CR_XP)) {
4179 + /* make pages tables, etc before .text NX */
4180 + for (addr = PAGE_OFFSET; addr < (unsigned long)_stext; addr += SECTION_SIZE) {
4181 + pgd = pgd_offset_k(addr);
4182 + pud = pud_offset(pgd, addr);
4183 + pmd = pmd_offset(pud, addr);
4184 + __section_update(pmd, addr, PMD_SECT_XN);
4185 + }
4186 + /* make init NX */
4187 + for (addr = (unsigned long)__init_begin; addr < (unsigned long)_sdata; addr += SECTION_SIZE) {
4188 + pgd = pgd_offset_k(addr);
4189 + pud = pud_offset(pgd, addr);
4190 + pmd = pmd_offset(pud, addr);
4191 + __section_update(pmd, addr, PMD_SECT_XN);
4192 + }
4193 + /* make kernel code/rodata RX */
4194 + for (addr = (unsigned long)_stext; addr < (unsigned long)__init_begin; addr += SECTION_SIZE) {
4195 + pgd = pgd_offset_k(addr);
4196 + pud = pud_offset(pgd, addr);
4197 + pmd = pmd_offset(pud, addr);
4198 +#ifdef CONFIG_ARM_LPAE
4199 + __section_update(pmd, addr, PMD_SECT_RDONLY);
4200 +#else
4201 + __section_update(pmd, addr, PMD_SECT_APX|PMD_SECT_AP_WRITE);
4202 +#endif
4203 + }
4204 + }
4205 +#endif
4206 +
4207 +#ifdef CONFIG_HAVE_TCM
4208 poison_init_mem(&__tcm_start, &__tcm_end - &__tcm_start);
4209 free_reserved_area(&__tcm_start, &__tcm_end, -1, "TCM link");
4210 #endif
4211 diff --git a/arch/arm/mm/ioremap.c b/arch/arm/mm/ioremap.c
4212 index f9c32ba..8540068 100644
4213 --- a/arch/arm/mm/ioremap.c
4214 +++ b/arch/arm/mm/ioremap.c
4215 @@ -392,9 +392,9 @@ __arm_ioremap_exec(phys_addr_t phys_addr, size_t size, bool cached)
4216 unsigned int mtype;
4217
4218 if (cached)
4219 - mtype = MT_MEMORY_RWX;
4220 + mtype = MT_MEMORY_RX;
4221 else
4222 - mtype = MT_MEMORY_RWX_NONCACHED;
4223 + mtype = MT_MEMORY_RX_NONCACHED;
4224
4225 return __arm_ioremap_caller(phys_addr, size, mtype,
4226 __builtin_return_address(0));
4227 diff --git a/arch/arm/mm/mmap.c b/arch/arm/mm/mmap.c
4228 index 5e85ed3..b10a7ed 100644
4229 --- a/arch/arm/mm/mmap.c
4230 +++ b/arch/arm/mm/mmap.c
4231 @@ -59,6 +59,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
4232 struct vm_area_struct *vma;
4233 int do_align = 0;
4234 int aliasing = cache_is_vipt_aliasing();
4235 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
4236 struct vm_unmapped_area_info info;
4237
4238 /*
4239 @@ -81,6 +82,10 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
4240 if (len > TASK_SIZE)
4241 return -ENOMEM;
4242
4243 +#ifdef CONFIG_PAX_RANDMMAP
4244 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
4245 +#endif
4246 +
4247 if (addr) {
4248 if (do_align)
4249 addr = COLOUR_ALIGN(addr, pgoff);
4250 @@ -88,8 +93,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
4251 addr = PAGE_ALIGN(addr);
4252
4253 vma = find_vma(mm, addr);
4254 - if (TASK_SIZE - len >= addr &&
4255 - (!vma || addr + len <= vma->vm_start))
4256 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
4257 return addr;
4258 }
4259
4260 @@ -99,6 +103,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
4261 info.high_limit = TASK_SIZE;
4262 info.align_mask = do_align ? (PAGE_MASK & (SHMLBA - 1)) : 0;
4263 info.align_offset = pgoff << PAGE_SHIFT;
4264 + info.threadstack_offset = offset;
4265 return vm_unmapped_area(&info);
4266 }
4267
4268 @@ -112,6 +117,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
4269 unsigned long addr = addr0;
4270 int do_align = 0;
4271 int aliasing = cache_is_vipt_aliasing();
4272 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
4273 struct vm_unmapped_area_info info;
4274
4275 /*
4276 @@ -132,6 +138,10 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
4277 return addr;
4278 }
4279
4280 +#ifdef CONFIG_PAX_RANDMMAP
4281 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
4282 +#endif
4283 +
4284 /* requesting a specific address */
4285 if (addr) {
4286 if (do_align)
4287 @@ -139,8 +149,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
4288 else
4289 addr = PAGE_ALIGN(addr);
4290 vma = find_vma(mm, addr);
4291 - if (TASK_SIZE - len >= addr &&
4292 - (!vma || addr + len <= vma->vm_start))
4293 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
4294 return addr;
4295 }
4296
4297 @@ -150,6 +159,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
4298 info.high_limit = mm->mmap_base;
4299 info.align_mask = do_align ? (PAGE_MASK & (SHMLBA - 1)) : 0;
4300 info.align_offset = pgoff << PAGE_SHIFT;
4301 + info.threadstack_offset = offset;
4302 addr = vm_unmapped_area(&info);
4303
4304 /*
4305 @@ -173,6 +183,10 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
4306 {
4307 unsigned long random_factor = 0UL;
4308
4309 +#ifdef CONFIG_PAX_RANDMMAP
4310 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
4311 +#endif
4312 +
4313 /* 8 bits of randomness in 20 address space bits */
4314 if ((current->flags & PF_RANDOMIZE) &&
4315 !(current->personality & ADDR_NO_RANDOMIZE))
4316 @@ -180,9 +194,21 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
4317
4318 if (mmap_is_legacy()) {
4319 mm->mmap_base = TASK_UNMAPPED_BASE + random_factor;
4320 +
4321 +#ifdef CONFIG_PAX_RANDMMAP
4322 + if (mm->pax_flags & MF_PAX_RANDMMAP)
4323 + mm->mmap_base += mm->delta_mmap;
4324 +#endif
4325 +
4326 mm->get_unmapped_area = arch_get_unmapped_area;
4327 } else {
4328 mm->mmap_base = mmap_base(random_factor);
4329 +
4330 +#ifdef CONFIG_PAX_RANDMMAP
4331 + if (mm->pax_flags & MF_PAX_RANDMMAP)
4332 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
4333 +#endif
4334 +
4335 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
4336 }
4337 }
4338 diff --git a/arch/arm/mm/mmu.c b/arch/arm/mm/mmu.c
4339 index b68c6b2..f66c492 100644
4340 --- a/arch/arm/mm/mmu.c
4341 +++ b/arch/arm/mm/mmu.c
4342 @@ -39,6 +39,22 @@
4343 #include "mm.h"
4344 #include "tcm.h"
4345
4346 +#if defined(CONFIG_CPU_USE_DOMAINS) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
4347 +void modify_domain(unsigned int dom, unsigned int type)
4348 +{
4349 + struct thread_info *thread = current_thread_info();
4350 + unsigned int domain = thread->cpu_domain;
4351 + /*
4352 + * DOMAIN_MANAGER might be defined to some other value,
4353 + * use the arch-defined constant
4354 + */
4355 + domain &= ~domain_val(dom, 3);
4356 + thread->cpu_domain = domain | domain_val(dom, type);
4357 + set_domain(thread->cpu_domain);
4358 +}
4359 +EXPORT_SYMBOL(modify_domain);
4360 +#endif
4361 +
4362 /*
4363 * empty_zero_page is a special page that is used for
4364 * zero-initialized data and COW.
4365 @@ -235,7 +251,15 @@ __setup("noalign", noalign_setup);
4366 #define PROT_PTE_S2_DEVICE PROT_PTE_DEVICE
4367 #define PROT_SECT_DEVICE PMD_TYPE_SECT|PMD_SECT_AP_WRITE
4368
4369 -static struct mem_type mem_types[] = {
4370 +#ifdef CONFIG_PAX_KERNEXEC
4371 +#define L_PTE_KERNEXEC L_PTE_RDONLY
4372 +#define PMD_SECT_KERNEXEC PMD_SECT_RDONLY
4373 +#else
4374 +#define L_PTE_KERNEXEC L_PTE_DIRTY
4375 +#define PMD_SECT_KERNEXEC PMD_SECT_AP_WRITE
4376 +#endif
4377 +
4378 +static struct mem_type mem_types[] __read_only = {
4379 [MT_DEVICE] = { /* Strongly ordered / ARMv6 shared device */
4380 .prot_pte = PROT_PTE_DEVICE | L_PTE_MT_DEV_SHARED |
4381 L_PTE_SHARED,
4382 @@ -264,19 +288,19 @@ static struct mem_type mem_types[] = {
4383 .prot_sect = PROT_SECT_DEVICE,
4384 .domain = DOMAIN_IO,
4385 },
4386 - [MT_UNCACHED] = {
4387 + [MT_UNCACHED_RW] = {
4388 .prot_pte = PROT_PTE_DEVICE,
4389 .prot_l1 = PMD_TYPE_TABLE,
4390 .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN,
4391 .domain = DOMAIN_IO,
4392 },
4393 - [MT_CACHECLEAN] = {
4394 - .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN,
4395 + [MT_CACHECLEAN_RO] = {
4396 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN | PMD_SECT_RDONLY,
4397 .domain = DOMAIN_KERNEL,
4398 },
4399 #ifndef CONFIG_ARM_LPAE
4400 - [MT_MINICLEAN] = {
4401 - .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN | PMD_SECT_MINICACHE,
4402 + [MT_MINICLEAN_RO] = {
4403 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_MINICACHE | PMD_SECT_XN | PMD_SECT_RDONLY,
4404 .domain = DOMAIN_KERNEL,
4405 },
4406 #endif
4407 @@ -284,15 +308,15 @@ static struct mem_type mem_types[] = {
4408 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4409 L_PTE_RDONLY,
4410 .prot_l1 = PMD_TYPE_TABLE,
4411 - .domain = DOMAIN_USER,
4412 + .domain = DOMAIN_VECTORS,
4413 },
4414 [MT_HIGH_VECTORS] = {
4415 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4416 L_PTE_USER | L_PTE_RDONLY,
4417 .prot_l1 = PMD_TYPE_TABLE,
4418 - .domain = DOMAIN_USER,
4419 + .domain = DOMAIN_VECTORS,
4420 },
4421 - [MT_MEMORY_RWX] = {
4422 + [__MT_MEMORY_RWX] = {
4423 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY,
4424 .prot_l1 = PMD_TYPE_TABLE,
4425 .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE,
4426 @@ -305,17 +329,30 @@ static struct mem_type mem_types[] = {
4427 .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE,
4428 .domain = DOMAIN_KERNEL,
4429 },
4430 - [MT_ROM] = {
4431 - .prot_sect = PMD_TYPE_SECT,
4432 + [MT_MEMORY_RX] = {
4433 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_KERNEXEC,
4434 + .prot_l1 = PMD_TYPE_TABLE,
4435 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_KERNEXEC,
4436 + .domain = DOMAIN_KERNEL,
4437 + },
4438 + [MT_ROM_RX] = {
4439 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_RDONLY,
4440 .domain = DOMAIN_KERNEL,
4441 },
4442 - [MT_MEMORY_RWX_NONCACHED] = {
4443 + [MT_MEMORY_RW_NONCACHED] = {
4444 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4445 L_PTE_MT_BUFFERABLE,
4446 .prot_l1 = PMD_TYPE_TABLE,
4447 .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE,
4448 .domain = DOMAIN_KERNEL,
4449 },
4450 + [MT_MEMORY_RX_NONCACHED] = {
4451 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_KERNEXEC |
4452 + L_PTE_MT_BUFFERABLE,
4453 + .prot_l1 = PMD_TYPE_TABLE,
4454 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_KERNEXEC,
4455 + .domain = DOMAIN_KERNEL,
4456 + },
4457 [MT_MEMORY_RW_DTCM] = {
4458 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4459 L_PTE_XN,
4460 @@ -323,9 +360,10 @@ static struct mem_type mem_types[] = {
4461 .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN,
4462 .domain = DOMAIN_KERNEL,
4463 },
4464 - [MT_MEMORY_RWX_ITCM] = {
4465 - .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY,
4466 + [MT_MEMORY_RX_ITCM] = {
4467 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_KERNEXEC,
4468 .prot_l1 = PMD_TYPE_TABLE,
4469 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_KERNEXEC,
4470 .domain = DOMAIN_KERNEL,
4471 },
4472 [MT_MEMORY_RW_SO] = {
4473 @@ -534,9 +572,14 @@ static void __init build_mem_type_table(void)
4474 * Mark cache clean areas and XIP ROM read only
4475 * from SVC mode and no access from userspace.
4476 */
4477 - mem_types[MT_ROM].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4478 - mem_types[MT_MINICLEAN].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4479 - mem_types[MT_CACHECLEAN].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4480 + mem_types[MT_ROM_RX].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4481 +#ifdef CONFIG_PAX_KERNEXEC
4482 + mem_types[MT_MEMORY_RX].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4483 + mem_types[MT_MEMORY_RX_NONCACHED].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4484 + mem_types[MT_MEMORY_RX_ITCM].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4485 +#endif
4486 + mem_types[MT_MINICLEAN_RO].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4487 + mem_types[MT_CACHECLEAN_RO].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4488 #endif
4489
4490 if (is_smp()) {
4491 @@ -552,13 +595,17 @@ static void __init build_mem_type_table(void)
4492 mem_types[MT_DEVICE_WC].prot_pte |= L_PTE_SHARED;
4493 mem_types[MT_DEVICE_CACHED].prot_sect |= PMD_SECT_S;
4494 mem_types[MT_DEVICE_CACHED].prot_pte |= L_PTE_SHARED;
4495 - mem_types[MT_MEMORY_RWX].prot_sect |= PMD_SECT_S;
4496 - mem_types[MT_MEMORY_RWX].prot_pte |= L_PTE_SHARED;
4497 + mem_types[__MT_MEMORY_RWX].prot_sect |= PMD_SECT_S;
4498 + mem_types[__MT_MEMORY_RWX].prot_pte |= L_PTE_SHARED;
4499 mem_types[MT_MEMORY_RW].prot_sect |= PMD_SECT_S;
4500 mem_types[MT_MEMORY_RW].prot_pte |= L_PTE_SHARED;
4501 + mem_types[MT_MEMORY_RX].prot_sect |= PMD_SECT_S;
4502 + mem_types[MT_MEMORY_RX].prot_pte |= L_PTE_SHARED;
4503 mem_types[MT_MEMORY_DMA_READY].prot_pte |= L_PTE_SHARED;
4504 - mem_types[MT_MEMORY_RWX_NONCACHED].prot_sect |= PMD_SECT_S;
4505 - mem_types[MT_MEMORY_RWX_NONCACHED].prot_pte |= L_PTE_SHARED;
4506 + mem_types[MT_MEMORY_RW_NONCACHED].prot_sect |= PMD_SECT_S;
4507 + mem_types[MT_MEMORY_RW_NONCACHED].prot_pte |= L_PTE_SHARED;
4508 + mem_types[MT_MEMORY_RX_NONCACHED].prot_sect |= PMD_SECT_S;
4509 + mem_types[MT_MEMORY_RX_NONCACHED].prot_pte |= L_PTE_SHARED;
4510 }
4511 }
4512
4513 @@ -569,15 +616,20 @@ static void __init build_mem_type_table(void)
4514 if (cpu_arch >= CPU_ARCH_ARMv6) {
4515 if (cpu_arch >= CPU_ARCH_ARMv7 && (cr & CR_TRE)) {
4516 /* Non-cacheable Normal is XCB = 001 */
4517 - mem_types[MT_MEMORY_RWX_NONCACHED].prot_sect |=
4518 + mem_types[MT_MEMORY_RW_NONCACHED].prot_sect |=
4519 + PMD_SECT_BUFFERED;
4520 + mem_types[MT_MEMORY_RX_NONCACHED].prot_sect |=
4521 PMD_SECT_BUFFERED;
4522 } else {
4523 /* For both ARMv6 and non-TEX-remapping ARMv7 */
4524 - mem_types[MT_MEMORY_RWX_NONCACHED].prot_sect |=
4525 + mem_types[MT_MEMORY_RW_NONCACHED].prot_sect |=
4526 + PMD_SECT_TEX(1);
4527 + mem_types[MT_MEMORY_RX_NONCACHED].prot_sect |=
4528 PMD_SECT_TEX(1);
4529 }
4530 } else {
4531 - mem_types[MT_MEMORY_RWX_NONCACHED].prot_sect |= PMD_SECT_BUFFERABLE;
4532 + mem_types[MT_MEMORY_RW_NONCACHED].prot_sect |= PMD_SECT_BUFFERABLE;
4533 + mem_types[MT_MEMORY_RX_NONCACHED].prot_sect |= PMD_SECT_BUFFERABLE;
4534 }
4535
4536 #ifdef CONFIG_ARM_LPAE
4537 @@ -593,6 +645,8 @@ static void __init build_mem_type_table(void)
4538 vecs_pgprot |= PTE_EXT_AF;
4539 #endif
4540
4541 + user_pgprot |= __supported_pte_mask;
4542 +
4543 for (i = 0; i < 16; i++) {
4544 pteval_t v = pgprot_val(protection_map[i]);
4545 protection_map[i] = __pgprot(v | user_pgprot);
4546 @@ -610,21 +664,24 @@ static void __init build_mem_type_table(void)
4547
4548 mem_types[MT_LOW_VECTORS].prot_l1 |= ecc_mask;
4549 mem_types[MT_HIGH_VECTORS].prot_l1 |= ecc_mask;
4550 - mem_types[MT_MEMORY_RWX].prot_sect |= ecc_mask | cp->pmd;
4551 - mem_types[MT_MEMORY_RWX].prot_pte |= kern_pgprot;
4552 + mem_types[__MT_MEMORY_RWX].prot_sect |= ecc_mask | cp->pmd;
4553 + mem_types[__MT_MEMORY_RWX].prot_pte |= kern_pgprot;
4554 mem_types[MT_MEMORY_RW].prot_sect |= ecc_mask | cp->pmd;
4555 mem_types[MT_MEMORY_RW].prot_pte |= kern_pgprot;
4556 + mem_types[MT_MEMORY_RX].prot_sect |= ecc_mask | cp->pmd;
4557 + mem_types[MT_MEMORY_RX].prot_pte |= kern_pgprot;
4558 mem_types[MT_MEMORY_DMA_READY].prot_pte |= kern_pgprot;
4559 - mem_types[MT_MEMORY_RWX_NONCACHED].prot_sect |= ecc_mask;
4560 - mem_types[MT_ROM].prot_sect |= cp->pmd;
4561 + mem_types[MT_MEMORY_RW_NONCACHED].prot_sect |= ecc_mask;
4562 + mem_types[MT_MEMORY_RX_NONCACHED].prot_sect |= ecc_mask;
4563 + mem_types[MT_ROM_RX].prot_sect |= cp->pmd;
4564
4565 switch (cp->pmd) {
4566 case PMD_SECT_WT:
4567 - mem_types[MT_CACHECLEAN].prot_sect |= PMD_SECT_WT;
4568 + mem_types[MT_CACHECLEAN_RO].prot_sect |= PMD_SECT_WT;
4569 break;
4570 case PMD_SECT_WB:
4571 case PMD_SECT_WBWA:
4572 - mem_types[MT_CACHECLEAN].prot_sect |= PMD_SECT_WB;
4573 + mem_types[MT_CACHECLEAN_RO].prot_sect |= PMD_SECT_WB;
4574 break;
4575 }
4576 pr_info("Memory policy: %sData cache %s\n",
4577 @@ -842,7 +899,7 @@ static void __init create_mapping(struct map_desc *md)
4578 return;
4579 }
4580
4581 - if ((md->type == MT_DEVICE || md->type == MT_ROM) &&
4582 + if ((md->type == MT_DEVICE || md->type == MT_ROM_RX) &&
4583 md->virtual >= PAGE_OFFSET &&
4584 (md->virtual < VMALLOC_START || md->virtual >= VMALLOC_END)) {
4585 printk(KERN_WARNING "BUG: mapping for 0x%08llx"
4586 @@ -1257,18 +1314,15 @@ void __init arm_mm_memblock_reserve(void)
4587 * called function. This means you can't use any function or debugging
4588 * method which may touch any device, otherwise the kernel _will_ crash.
4589 */
4590 +
4591 +static char vectors[PAGE_SIZE * 2] __read_only __aligned(PAGE_SIZE);
4592 +
4593 static void __init devicemaps_init(const struct machine_desc *mdesc)
4594 {
4595 struct map_desc map;
4596 unsigned long addr;
4597 - void *vectors;
4598
4599 - /*
4600 - * Allocate the vector page early.
4601 - */
4602 - vectors = early_alloc(PAGE_SIZE * 2);
4603 -
4604 - early_trap_init(vectors);
4605 + early_trap_init(&vectors);
4606
4607 for (addr = VMALLOC_START; addr; addr += PMD_SIZE)
4608 pmd_clear(pmd_off_k(addr));
4609 @@ -1281,7 +1335,7 @@ static void __init devicemaps_init(const struct machine_desc *mdesc)
4610 map.pfn = __phys_to_pfn(CONFIG_XIP_PHYS_ADDR & SECTION_MASK);
4611 map.virtual = MODULES_VADDR;
4612 map.length = ((unsigned long)_etext - map.virtual + ~SECTION_MASK) & SECTION_MASK;
4613 - map.type = MT_ROM;
4614 + map.type = MT_ROM_RX;
4615 create_mapping(&map);
4616 #endif
4617
4618 @@ -1292,14 +1346,14 @@ static void __init devicemaps_init(const struct machine_desc *mdesc)
4619 map.pfn = __phys_to_pfn(FLUSH_BASE_PHYS);
4620 map.virtual = FLUSH_BASE;
4621 map.length = SZ_1M;
4622 - map.type = MT_CACHECLEAN;
4623 + map.type = MT_CACHECLEAN_RO;
4624 create_mapping(&map);
4625 #endif
4626 #ifdef FLUSH_BASE_MINICACHE
4627 map.pfn = __phys_to_pfn(FLUSH_BASE_PHYS + SZ_1M);
4628 map.virtual = FLUSH_BASE_MINICACHE;
4629 map.length = SZ_1M;
4630 - map.type = MT_MINICLEAN;
4631 + map.type = MT_MINICLEAN_RO;
4632 create_mapping(&map);
4633 #endif
4634
4635 @@ -1308,7 +1362,7 @@ static void __init devicemaps_init(const struct machine_desc *mdesc)
4636 * location (0xffff0000). If we aren't using high-vectors, also
4637 * create a mapping at the low-vectors virtual address.
4638 */
4639 - map.pfn = __phys_to_pfn(virt_to_phys(vectors));
4640 + map.pfn = __phys_to_pfn(virt_to_phys(&vectors));
4641 map.virtual = 0xffff0000;
4642 map.length = PAGE_SIZE;
4643 #ifdef CONFIG_KUSER_HELPERS
4644 @@ -1365,8 +1419,10 @@ static void __init kmap_init(void)
4645 static void __init map_lowmem(void)
4646 {
4647 struct memblock_region *reg;
4648 +#ifndef CONFIG_PAX_KERNEXEC
4649 unsigned long kernel_x_start = round_down(__pa(_stext), SECTION_SIZE);
4650 unsigned long kernel_x_end = round_up(__pa(__init_end), SECTION_SIZE);
4651 +#endif
4652
4653 /* Map all the lowmem memory banks. */
4654 for_each_memblock(memory, reg) {
4655 @@ -1379,11 +1435,48 @@ static void __init map_lowmem(void)
4656 if (start >= end)
4657 break;
4658
4659 +#ifdef CONFIG_PAX_KERNEXEC
4660 + map.pfn = __phys_to_pfn(start);
4661 + map.virtual = __phys_to_virt(start);
4662 + map.length = end - start;
4663 +
4664 + if (map.virtual <= (unsigned long)_stext && ((unsigned long)_end < (map.virtual + map.length))) {
4665 + struct map_desc kernel;
4666 + struct map_desc initmap;
4667 +
4668 + /* when freeing initmem we will make this RW */
4669 + initmap.pfn = __phys_to_pfn(__pa(__init_begin));
4670 + initmap.virtual = (unsigned long)__init_begin;
4671 + initmap.length = _sdata - __init_begin;
4672 + initmap.type = __MT_MEMORY_RWX;
4673 + create_mapping(&initmap);
4674 +
4675 + /* when freeing initmem we will make this RX */
4676 + kernel.pfn = __phys_to_pfn(__pa(_stext));
4677 + kernel.virtual = (unsigned long)_stext;
4678 + kernel.length = __init_begin - _stext;
4679 + kernel.type = __MT_MEMORY_RWX;
4680 + create_mapping(&kernel);
4681 +
4682 + if (map.virtual < (unsigned long)_stext) {
4683 + map.length = (unsigned long)_stext - map.virtual;
4684 + map.type = __MT_MEMORY_RWX;
4685 + create_mapping(&map);
4686 + }
4687 +
4688 + map.pfn = __phys_to_pfn(__pa(_sdata));
4689 + map.virtual = (unsigned long)_sdata;
4690 + map.length = end - __pa(_sdata);
4691 + }
4692 +
4693 + map.type = MT_MEMORY_RW;
4694 + create_mapping(&map);
4695 +#else
4696 if (end < kernel_x_start || start >= kernel_x_end) {
4697 map.pfn = __phys_to_pfn(start);
4698 map.virtual = __phys_to_virt(start);
4699 map.length = end - start;
4700 - map.type = MT_MEMORY_RWX;
4701 + map.type = __MT_MEMORY_RWX;
4702
4703 create_mapping(&map);
4704 } else {
4705 @@ -1400,7 +1493,7 @@ static void __init map_lowmem(void)
4706 map.pfn = __phys_to_pfn(kernel_x_start);
4707 map.virtual = __phys_to_virt(kernel_x_start);
4708 map.length = kernel_x_end - kernel_x_start;
4709 - map.type = MT_MEMORY_RWX;
4710 + map.type = __MT_MEMORY_RWX;
4711
4712 create_mapping(&map);
4713
4714 @@ -1413,6 +1506,7 @@ static void __init map_lowmem(void)
4715 create_mapping(&map);
4716 }
4717 }
4718 +#endif
4719 }
4720 }
4721
4722 diff --git a/arch/arm/plat-iop/setup.c b/arch/arm/plat-iop/setup.c
4723 index 5b217f4..c23f40e 100644
4724 --- a/arch/arm/plat-iop/setup.c
4725 +++ b/arch/arm/plat-iop/setup.c
4726 @@ -24,7 +24,7 @@ static struct map_desc iop3xx_std_desc[] __initdata = {
4727 .virtual = IOP3XX_PERIPHERAL_VIRT_BASE,
4728 .pfn = __phys_to_pfn(IOP3XX_PERIPHERAL_PHYS_BASE),
4729 .length = IOP3XX_PERIPHERAL_SIZE,
4730 - .type = MT_UNCACHED,
4731 + .type = MT_UNCACHED_RW,
4732 },
4733 };
4734
4735 diff --git a/arch/arm/plat-omap/sram.c b/arch/arm/plat-omap/sram.c
4736 index a5bc92d..0bb4730 100644
4737 --- a/arch/arm/plat-omap/sram.c
4738 +++ b/arch/arm/plat-omap/sram.c
4739 @@ -93,6 +93,8 @@ void __init omap_map_sram(unsigned long start, unsigned long size,
4740 * Looks like we need to preserve some bootloader code at the
4741 * beginning of SRAM for jumping to flash for reboot to work...
4742 */
4743 + pax_open_kernel();
4744 memset_io(omap_sram_base + omap_sram_skip, 0,
4745 omap_sram_size - omap_sram_skip);
4746 + pax_close_kernel();
4747 }
4748 diff --git a/arch/arm/plat-samsung/include/plat/dma-ops.h b/arch/arm/plat-samsung/include/plat/dma-ops.h
4749 index ce6d763..cfea917 100644
4750 --- a/arch/arm/plat-samsung/include/plat/dma-ops.h
4751 +++ b/arch/arm/plat-samsung/include/plat/dma-ops.h
4752 @@ -47,7 +47,7 @@ struct samsung_dma_ops {
4753 int (*started)(unsigned ch);
4754 int (*flush)(unsigned ch);
4755 int (*stop)(unsigned ch);
4756 -};
4757 +} __no_const;
4758
4759 extern void *samsung_dmadev_get_ops(void);
4760 extern void *s3c_dma_get_ops(void);
4761 diff --git a/arch/arm64/include/asm/barrier.h b/arch/arm64/include/asm/barrier.h
4762 index 66eb764..b529b84 100644
4763 --- a/arch/arm64/include/asm/barrier.h
4764 +++ b/arch/arm64/include/asm/barrier.h
4765 @@ -41,7 +41,7 @@
4766 do { \
4767 compiletime_assert_atomic_type(*p); \
4768 smp_mb(); \
4769 - ACCESS_ONCE(*p) = (v); \
4770 + ACCESS_ONCE_RW(*p) = (v); \
4771 } while (0)
4772
4773 #define smp_load_acquire(p) \
4774 diff --git a/arch/arm64/include/asm/uaccess.h b/arch/arm64/include/asm/uaccess.h
4775 index 3bf8f4e..5dd5491 100644
4776 --- a/arch/arm64/include/asm/uaccess.h
4777 +++ b/arch/arm64/include/asm/uaccess.h
4778 @@ -99,6 +99,7 @@ static inline void set_fs(mm_segment_t fs)
4779 flag; \
4780 })
4781
4782 +#define access_ok_noprefault(type, addr, size) access_ok((type), (addr), (size))
4783 #define access_ok(type, addr, size) __range_ok(addr, size)
4784 #define user_addr_max get_fs
4785
4786 diff --git a/arch/avr32/include/asm/cache.h b/arch/avr32/include/asm/cache.h
4787 index c3a58a1..78fbf54 100644
4788 --- a/arch/avr32/include/asm/cache.h
4789 +++ b/arch/avr32/include/asm/cache.h
4790 @@ -1,8 +1,10 @@
4791 #ifndef __ASM_AVR32_CACHE_H
4792 #define __ASM_AVR32_CACHE_H
4793
4794 +#include <linux/const.h>
4795 +
4796 #define L1_CACHE_SHIFT 5
4797 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4798 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4799
4800 /*
4801 * Memory returned by kmalloc() may be used for DMA, so we must make
4802 diff --git a/arch/avr32/include/asm/elf.h b/arch/avr32/include/asm/elf.h
4803 index d232888..87c8df1 100644
4804 --- a/arch/avr32/include/asm/elf.h
4805 +++ b/arch/avr32/include/asm/elf.h
4806 @@ -84,8 +84,14 @@ typedef struct user_fpu_struct elf_fpregset_t;
4807 the loader. We need to make sure that it is out of the way of the program
4808 that it will "exec", and that there is sufficient room for the brk. */
4809
4810 -#define ELF_ET_DYN_BASE (2 * TASK_SIZE / 3)
4811 +#define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
4812
4813 +#ifdef CONFIG_PAX_ASLR
4814 +#define PAX_ELF_ET_DYN_BASE 0x00001000UL
4815 +
4816 +#define PAX_DELTA_MMAP_LEN 15
4817 +#define PAX_DELTA_STACK_LEN 15
4818 +#endif
4819
4820 /* This yields a mask that user programs can use to figure out what
4821 instruction set this CPU supports. This could be done in user space,
4822 diff --git a/arch/avr32/include/asm/kmap_types.h b/arch/avr32/include/asm/kmap_types.h
4823 index 479330b..53717a8 100644
4824 --- a/arch/avr32/include/asm/kmap_types.h
4825 +++ b/arch/avr32/include/asm/kmap_types.h
4826 @@ -2,9 +2,9 @@
4827 #define __ASM_AVR32_KMAP_TYPES_H
4828
4829 #ifdef CONFIG_DEBUG_HIGHMEM
4830 -# define KM_TYPE_NR 29
4831 +# define KM_TYPE_NR 30
4832 #else
4833 -# define KM_TYPE_NR 14
4834 +# define KM_TYPE_NR 15
4835 #endif
4836
4837 #endif /* __ASM_AVR32_KMAP_TYPES_H */
4838 diff --git a/arch/avr32/mm/fault.c b/arch/avr32/mm/fault.c
4839 index 0eca933..eb78c7b 100644
4840 --- a/arch/avr32/mm/fault.c
4841 +++ b/arch/avr32/mm/fault.c
4842 @@ -41,6 +41,23 @@ static inline int notify_page_fault(struct pt_regs *regs, int trap)
4843
4844 int exception_trace = 1;
4845
4846 +#ifdef CONFIG_PAX_PAGEEXEC
4847 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
4848 +{
4849 + unsigned long i;
4850 +
4851 + printk(KERN_ERR "PAX: bytes at PC: ");
4852 + for (i = 0; i < 20; i++) {
4853 + unsigned char c;
4854 + if (get_user(c, (unsigned char *)pc+i))
4855 + printk(KERN_CONT "???????? ");
4856 + else
4857 + printk(KERN_CONT "%02x ", c);
4858 + }
4859 + printk("\n");
4860 +}
4861 +#endif
4862 +
4863 /*
4864 * This routine handles page faults. It determines the address and the
4865 * problem, and then passes it off to one of the appropriate routines.
4866 @@ -176,6 +193,16 @@ bad_area:
4867 up_read(&mm->mmap_sem);
4868
4869 if (user_mode(regs)) {
4870 +
4871 +#ifdef CONFIG_PAX_PAGEEXEC
4872 + if (mm->pax_flags & MF_PAX_PAGEEXEC) {
4873 + if (ecr == ECR_PROTECTION_X || ecr == ECR_TLB_MISS_X) {
4874 + pax_report_fault(regs, (void *)regs->pc, (void *)regs->sp);
4875 + do_group_exit(SIGKILL);
4876 + }
4877 + }
4878 +#endif
4879 +
4880 if (exception_trace && printk_ratelimit())
4881 printk("%s%s[%d]: segfault at %08lx pc %08lx "
4882 "sp %08lx ecr %lu\n",
4883 diff --git a/arch/blackfin/include/asm/cache.h b/arch/blackfin/include/asm/cache.h
4884 index 568885a..f8008df 100644
4885 --- a/arch/blackfin/include/asm/cache.h
4886 +++ b/arch/blackfin/include/asm/cache.h
4887 @@ -7,6 +7,7 @@
4888 #ifndef __ARCH_BLACKFIN_CACHE_H
4889 #define __ARCH_BLACKFIN_CACHE_H
4890
4891 +#include <linux/const.h>
4892 #include <linux/linkage.h> /* for asmlinkage */
4893
4894 /*
4895 @@ -14,7 +15,7 @@
4896 * Blackfin loads 32 bytes for cache
4897 */
4898 #define L1_CACHE_SHIFT 5
4899 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4900 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4901 #define SMP_CACHE_BYTES L1_CACHE_BYTES
4902
4903 #define ARCH_DMA_MINALIGN L1_CACHE_BYTES
4904 diff --git a/arch/cris/include/arch-v10/arch/cache.h b/arch/cris/include/arch-v10/arch/cache.h
4905 index aea2718..3639a60 100644
4906 --- a/arch/cris/include/arch-v10/arch/cache.h
4907 +++ b/arch/cris/include/arch-v10/arch/cache.h
4908 @@ -1,8 +1,9 @@
4909 #ifndef _ASM_ARCH_CACHE_H
4910 #define _ASM_ARCH_CACHE_H
4911
4912 +#include <linux/const.h>
4913 /* Etrax 100LX have 32-byte cache-lines. */
4914 -#define L1_CACHE_BYTES 32
4915 #define L1_CACHE_SHIFT 5
4916 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4917
4918 #endif /* _ASM_ARCH_CACHE_H */
4919 diff --git a/arch/cris/include/arch-v32/arch/cache.h b/arch/cris/include/arch-v32/arch/cache.h
4920 index 7caf25d..ee65ac5 100644
4921 --- a/arch/cris/include/arch-v32/arch/cache.h
4922 +++ b/arch/cris/include/arch-v32/arch/cache.h
4923 @@ -1,11 +1,12 @@
4924 #ifndef _ASM_CRIS_ARCH_CACHE_H
4925 #define _ASM_CRIS_ARCH_CACHE_H
4926
4927 +#include <linux/const.h>
4928 #include <arch/hwregs/dma.h>
4929
4930 /* A cache-line is 32 bytes. */
4931 -#define L1_CACHE_BYTES 32
4932 #define L1_CACHE_SHIFT 5
4933 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4934
4935 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
4936
4937 diff --git a/arch/frv/include/asm/atomic.h b/arch/frv/include/asm/atomic.h
4938 index b86329d..6709906 100644
4939 --- a/arch/frv/include/asm/atomic.h
4940 +++ b/arch/frv/include/asm/atomic.h
4941 @@ -186,6 +186,16 @@ static inline void atomic64_dec(atomic64_t *v)
4942 #define atomic64_cmpxchg(v, old, new) (__cmpxchg_64(old, new, &(v)->counter))
4943 #define atomic64_xchg(v, new) (__xchg_64(new, &(v)->counter))
4944
4945 +#define atomic64_read_unchecked(v) atomic64_read(v)
4946 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
4947 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
4948 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
4949 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
4950 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
4951 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
4952 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
4953 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
4954 +
4955 static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
4956 {
4957 int c, old;
4958 diff --git a/arch/frv/include/asm/cache.h b/arch/frv/include/asm/cache.h
4959 index 2797163..c2a401d 100644
4960 --- a/arch/frv/include/asm/cache.h
4961 +++ b/arch/frv/include/asm/cache.h
4962 @@ -12,10 +12,11 @@
4963 #ifndef __ASM_CACHE_H
4964 #define __ASM_CACHE_H
4965
4966 +#include <linux/const.h>
4967
4968 /* bytes per L1 cache line */
4969 #define L1_CACHE_SHIFT (CONFIG_FRV_L1_CACHE_SHIFT)
4970 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4971 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4972
4973 #define __cacheline_aligned __attribute__((aligned(L1_CACHE_BYTES)))
4974 #define ____cacheline_aligned __attribute__((aligned(L1_CACHE_BYTES)))
4975 diff --git a/arch/frv/include/asm/kmap_types.h b/arch/frv/include/asm/kmap_types.h
4976 index 43901f2..0d8b865 100644
4977 --- a/arch/frv/include/asm/kmap_types.h
4978 +++ b/arch/frv/include/asm/kmap_types.h
4979 @@ -2,6 +2,6 @@
4980 #ifndef _ASM_KMAP_TYPES_H
4981 #define _ASM_KMAP_TYPES_H
4982
4983 -#define KM_TYPE_NR 17
4984 +#define KM_TYPE_NR 18
4985
4986 #endif
4987 diff --git a/arch/frv/mm/elf-fdpic.c b/arch/frv/mm/elf-fdpic.c
4988 index 836f147..4cf23f5 100644
4989 --- a/arch/frv/mm/elf-fdpic.c
4990 +++ b/arch/frv/mm/elf-fdpic.c
4991 @@ -61,6 +61,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
4992 {
4993 struct vm_area_struct *vma;
4994 struct vm_unmapped_area_info info;
4995 + unsigned long offset = gr_rand_threadstack_offset(current->mm, filp, flags);
4996
4997 if (len > TASK_SIZE)
4998 return -ENOMEM;
4999 @@ -73,8 +74,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
5000 if (addr) {
5001 addr = PAGE_ALIGN(addr);
5002 vma = find_vma(current->mm, addr);
5003 - if (TASK_SIZE - len >= addr &&
5004 - (!vma || addr + len <= vma->vm_start))
5005 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
5006 goto success;
5007 }
5008
5009 @@ -85,6 +85,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
5010 info.high_limit = (current->mm->start_stack - 0x00200000);
5011 info.align_mask = 0;
5012 info.align_offset = 0;
5013 + info.threadstack_offset = offset;
5014 addr = vm_unmapped_area(&info);
5015 if (!(addr & ~PAGE_MASK))
5016 goto success;
5017 diff --git a/arch/hexagon/include/asm/cache.h b/arch/hexagon/include/asm/cache.h
5018 index f4ca594..adc72fd6 100644
5019 --- a/arch/hexagon/include/asm/cache.h
5020 +++ b/arch/hexagon/include/asm/cache.h
5021 @@ -21,9 +21,11 @@
5022 #ifndef __ASM_CACHE_H
5023 #define __ASM_CACHE_H
5024
5025 +#include <linux/const.h>
5026 +
5027 /* Bytes per L1 cache line */
5028 -#define L1_CACHE_SHIFT (5)
5029 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
5030 +#define L1_CACHE_SHIFT 5
5031 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5032
5033 #define __cacheline_aligned __aligned(L1_CACHE_BYTES)
5034 #define ____cacheline_aligned __aligned(L1_CACHE_BYTES)
5035 diff --git a/arch/ia64/Kconfig b/arch/ia64/Kconfig
5036 index 12c3afe..b1abab2 100644
5037 --- a/arch/ia64/Kconfig
5038 +++ b/arch/ia64/Kconfig
5039 @@ -546,6 +546,7 @@ source "drivers/sn/Kconfig"
5040 config KEXEC
5041 bool "kexec system call"
5042 depends on !IA64_HP_SIM && (!SMP || HOTPLUG_CPU)
5043 + depends on !GRKERNSEC_KMEM
5044 help
5045 kexec is a system call that implements the ability to shutdown your
5046 current kernel, and to start another kernel. It is like a reboot
5047 diff --git a/arch/ia64/include/asm/atomic.h b/arch/ia64/include/asm/atomic.h
5048 index 6e6fe18..a6ae668 100644
5049 --- a/arch/ia64/include/asm/atomic.h
5050 +++ b/arch/ia64/include/asm/atomic.h
5051 @@ -208,6 +208,16 @@ atomic64_add_negative (__s64 i, atomic64_t *v)
5052 #define atomic64_inc(v) atomic64_add(1, (v))
5053 #define atomic64_dec(v) atomic64_sub(1, (v))
5054
5055 +#define atomic64_read_unchecked(v) atomic64_read(v)
5056 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
5057 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
5058 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
5059 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
5060 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
5061 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
5062 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
5063 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
5064 +
5065 /* Atomic operations are already serializing */
5066 #define smp_mb__before_atomic_dec() barrier()
5067 #define smp_mb__after_atomic_dec() barrier()
5068 diff --git a/arch/ia64/include/asm/barrier.h b/arch/ia64/include/asm/barrier.h
5069 index d0a69aa..142f878 100644
5070 --- a/arch/ia64/include/asm/barrier.h
5071 +++ b/arch/ia64/include/asm/barrier.h
5072 @@ -64,7 +64,7 @@
5073 do { \
5074 compiletime_assert_atomic_type(*p); \
5075 barrier(); \
5076 - ACCESS_ONCE(*p) = (v); \
5077 + ACCESS_ONCE_RW(*p) = (v); \
5078 } while (0)
5079
5080 #define smp_load_acquire(p) \
5081 diff --git a/arch/ia64/include/asm/cache.h b/arch/ia64/include/asm/cache.h
5082 index 988254a..e1ee885 100644
5083 --- a/arch/ia64/include/asm/cache.h
5084 +++ b/arch/ia64/include/asm/cache.h
5085 @@ -1,6 +1,7 @@
5086 #ifndef _ASM_IA64_CACHE_H
5087 #define _ASM_IA64_CACHE_H
5088
5089 +#include <linux/const.h>
5090
5091 /*
5092 * Copyright (C) 1998-2000 Hewlett-Packard Co
5093 @@ -9,7 +10,7 @@
5094
5095 /* Bytes per L1 (data) cache line. */
5096 #define L1_CACHE_SHIFT CONFIG_IA64_L1_CACHE_SHIFT
5097 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
5098 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5099
5100 #ifdef CONFIG_SMP
5101 # define SMP_CACHE_SHIFT L1_CACHE_SHIFT
5102 diff --git a/arch/ia64/include/asm/elf.h b/arch/ia64/include/asm/elf.h
5103 index 5a83c5c..4d7f553 100644
5104 --- a/arch/ia64/include/asm/elf.h
5105 +++ b/arch/ia64/include/asm/elf.h
5106 @@ -42,6 +42,13 @@
5107 */
5108 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE + 0x800000000UL)
5109
5110 +#ifdef CONFIG_PAX_ASLR
5111 +#define PAX_ELF_ET_DYN_BASE (current->personality == PER_LINUX32 ? 0x08048000UL : 0x4000000000000000UL)
5112 +
5113 +#define PAX_DELTA_MMAP_LEN (current->personality == PER_LINUX32 ? 16 : 3*PAGE_SHIFT - 13)
5114 +#define PAX_DELTA_STACK_LEN (current->personality == PER_LINUX32 ? 16 : 3*PAGE_SHIFT - 13)
5115 +#endif
5116 +
5117 #define PT_IA_64_UNWIND 0x70000001
5118
5119 /* IA-64 relocations: */
5120 diff --git a/arch/ia64/include/asm/pgalloc.h b/arch/ia64/include/asm/pgalloc.h
5121 index 5767cdf..7462574 100644
5122 --- a/arch/ia64/include/asm/pgalloc.h
5123 +++ b/arch/ia64/include/asm/pgalloc.h
5124 @@ -39,6 +39,12 @@ pgd_populate(struct mm_struct *mm, pgd_t * pgd_entry, pud_t * pud)
5125 pgd_val(*pgd_entry) = __pa(pud);
5126 }
5127
5128 +static inline void
5129 +pgd_populate_kernel(struct mm_struct *mm, pgd_t * pgd_entry, pud_t * pud)
5130 +{
5131 + pgd_populate(mm, pgd_entry, pud);
5132 +}
5133 +
5134 static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
5135 {
5136 return quicklist_alloc(0, GFP_KERNEL, NULL);
5137 @@ -57,6 +63,12 @@ pud_populate(struct mm_struct *mm, pud_t * pud_entry, pmd_t * pmd)
5138 pud_val(*pud_entry) = __pa(pmd);
5139 }
5140
5141 +static inline void
5142 +pud_populate_kernel(struct mm_struct *mm, pud_t * pud_entry, pmd_t * pmd)
5143 +{
5144 + pud_populate(mm, pud_entry, pmd);
5145 +}
5146 +
5147 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long addr)
5148 {
5149 return quicklist_alloc(0, GFP_KERNEL, NULL);
5150 diff --git a/arch/ia64/include/asm/pgtable.h b/arch/ia64/include/asm/pgtable.h
5151 index 7935115..c0eca6a 100644
5152 --- a/arch/ia64/include/asm/pgtable.h
5153 +++ b/arch/ia64/include/asm/pgtable.h
5154 @@ -12,7 +12,7 @@
5155 * David Mosberger-Tang <davidm@hpl.hp.com>
5156 */
5157
5158 -
5159 +#include <linux/const.h>
5160 #include <asm/mman.h>
5161 #include <asm/page.h>
5162 #include <asm/processor.h>
5163 @@ -142,6 +142,17 @@
5164 #define PAGE_READONLY __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
5165 #define PAGE_COPY __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
5166 #define PAGE_COPY_EXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_RX)
5167 +
5168 +#ifdef CONFIG_PAX_PAGEEXEC
5169 +# define PAGE_SHARED_NOEXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_RW)
5170 +# define PAGE_READONLY_NOEXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
5171 +# define PAGE_COPY_NOEXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
5172 +#else
5173 +# define PAGE_SHARED_NOEXEC PAGE_SHARED
5174 +# define PAGE_READONLY_NOEXEC PAGE_READONLY
5175 +# define PAGE_COPY_NOEXEC PAGE_COPY
5176 +#endif
5177 +
5178 #define PAGE_GATE __pgprot(__ACCESS_BITS | _PAGE_PL_0 | _PAGE_AR_X_RX)
5179 #define PAGE_KERNEL __pgprot(__DIRTY_BITS | _PAGE_PL_0 | _PAGE_AR_RWX)
5180 #define PAGE_KERNELRX __pgprot(__ACCESS_BITS | _PAGE_PL_0 | _PAGE_AR_RX)
5181 diff --git a/arch/ia64/include/asm/spinlock.h b/arch/ia64/include/asm/spinlock.h
5182 index 45698cd..e8e2dbc 100644
5183 --- a/arch/ia64/include/asm/spinlock.h
5184 +++ b/arch/ia64/include/asm/spinlock.h
5185 @@ -71,7 +71,7 @@ static __always_inline void __ticket_spin_unlock(arch_spinlock_t *lock)
5186 unsigned short *p = (unsigned short *)&lock->lock + 1, tmp;
5187
5188 asm volatile ("ld2.bias %0=[%1]" : "=r"(tmp) : "r"(p));
5189 - ACCESS_ONCE(*p) = (tmp + 2) & ~1;
5190 + ACCESS_ONCE_RW(*p) = (tmp + 2) & ~1;
5191 }
5192
5193 static __always_inline void __ticket_spin_unlock_wait(arch_spinlock_t *lock)
5194 diff --git a/arch/ia64/include/asm/uaccess.h b/arch/ia64/include/asm/uaccess.h
5195 index 449c8c0..3d4b1e9 100644
5196 --- a/arch/ia64/include/asm/uaccess.h
5197 +++ b/arch/ia64/include/asm/uaccess.h
5198 @@ -70,6 +70,7 @@
5199 && ((segment).seg == KERNEL_DS.seg \
5200 || likely(REGION_OFFSET((unsigned long) (addr)) < RGN_MAP_LIMIT))); \
5201 })
5202 +#define access_ok_noprefault(type, addr, size) access_ok((type), (addr), (size))
5203 #define access_ok(type, addr, size) __access_ok((addr), (size), get_fs())
5204
5205 /*
5206 @@ -240,12 +241,24 @@ extern unsigned long __must_check __copy_user (void __user *to, const void __use
5207 static inline unsigned long
5208 __copy_to_user (void __user *to, const void *from, unsigned long count)
5209 {
5210 + if (count > INT_MAX)
5211 + return count;
5212 +
5213 + if (!__builtin_constant_p(count))
5214 + check_object_size(from, count, true);
5215 +
5216 return __copy_user(to, (__force void __user *) from, count);
5217 }
5218
5219 static inline unsigned long
5220 __copy_from_user (void *to, const void __user *from, unsigned long count)
5221 {
5222 + if (count > INT_MAX)
5223 + return count;
5224 +
5225 + if (!__builtin_constant_p(count))
5226 + check_object_size(to, count, false);
5227 +
5228 return __copy_user((__force void __user *) to, from, count);
5229 }
5230
5231 @@ -255,10 +268,13 @@ __copy_from_user (void *to, const void __user *from, unsigned long count)
5232 ({ \
5233 void __user *__cu_to = (to); \
5234 const void *__cu_from = (from); \
5235 - long __cu_len = (n); \
5236 + unsigned long __cu_len = (n); \
5237 \
5238 - if (__access_ok(__cu_to, __cu_len, get_fs())) \
5239 + if (__cu_len <= INT_MAX && __access_ok(__cu_to, __cu_len, get_fs())) { \
5240 + if (!__builtin_constant_p(n)) \
5241 + check_object_size(__cu_from, __cu_len, true); \
5242 __cu_len = __copy_user(__cu_to, (__force void __user *) __cu_from, __cu_len); \
5243 + } \
5244 __cu_len; \
5245 })
5246
5247 @@ -266,11 +282,14 @@ __copy_from_user (void *to, const void __user *from, unsigned long count)
5248 ({ \
5249 void *__cu_to = (to); \
5250 const void __user *__cu_from = (from); \
5251 - long __cu_len = (n); \
5252 + unsigned long __cu_len = (n); \
5253 \
5254 __chk_user_ptr(__cu_from); \
5255 - if (__access_ok(__cu_from, __cu_len, get_fs())) \
5256 + if (__cu_len <= INT_MAX && __access_ok(__cu_from, __cu_len, get_fs())) { \
5257 + if (!__builtin_constant_p(n)) \
5258 + check_object_size(__cu_to, __cu_len, false); \
5259 __cu_len = __copy_user((__force void __user *) __cu_to, __cu_from, __cu_len); \
5260 + } \
5261 __cu_len; \
5262 })
5263
5264 diff --git a/arch/ia64/kernel/module.c b/arch/ia64/kernel/module.c
5265 index 24603be..948052d 100644
5266 --- a/arch/ia64/kernel/module.c
5267 +++ b/arch/ia64/kernel/module.c
5268 @@ -307,8 +307,7 @@ plt_target (struct plt_entry *plt)
5269 void
5270 module_free (struct module *mod, void *module_region)
5271 {
5272 - if (mod && mod->arch.init_unw_table &&
5273 - module_region == mod->module_init) {
5274 + if (mod && mod->arch.init_unw_table && module_region == mod->module_init_rx) {
5275 unw_remove_unwind_table(mod->arch.init_unw_table);
5276 mod->arch.init_unw_table = NULL;
5277 }
5278 @@ -494,15 +493,39 @@ module_frob_arch_sections (Elf_Ehdr *ehdr, Elf_Shdr *sechdrs, char *secstrings,
5279 }
5280
5281 static inline int
5282 +in_init_rx (const struct module *mod, uint64_t addr)
5283 +{
5284 + return addr - (uint64_t) mod->module_init_rx < mod->init_size_rx;
5285 +}
5286 +
5287 +static inline int
5288 +in_init_rw (const struct module *mod, uint64_t addr)
5289 +{
5290 + return addr - (uint64_t) mod->module_init_rw < mod->init_size_rw;
5291 +}
5292 +
5293 +static inline int
5294 in_init (const struct module *mod, uint64_t addr)
5295 {
5296 - return addr - (uint64_t) mod->module_init < mod->init_size;
5297 + return in_init_rx(mod, addr) || in_init_rw(mod, addr);
5298 +}
5299 +
5300 +static inline int
5301 +in_core_rx (const struct module *mod, uint64_t addr)
5302 +{
5303 + return addr - (uint64_t) mod->module_core_rx < mod->core_size_rx;
5304 +}
5305 +
5306 +static inline int
5307 +in_core_rw (const struct module *mod, uint64_t addr)
5308 +{
5309 + return addr - (uint64_t) mod->module_core_rw < mod->core_size_rw;
5310 }
5311
5312 static inline int
5313 in_core (const struct module *mod, uint64_t addr)
5314 {
5315 - return addr - (uint64_t) mod->module_core < mod->core_size;
5316 + return in_core_rx(mod, addr) || in_core_rw(mod, addr);
5317 }
5318
5319 static inline int
5320 @@ -685,7 +708,14 @@ do_reloc (struct module *mod, uint8_t r_type, Elf64_Sym *sym, uint64_t addend,
5321 break;
5322
5323 case RV_BDREL:
5324 - val -= (uint64_t) (in_init(mod, val) ? mod->module_init : mod->module_core);
5325 + if (in_init_rx(mod, val))
5326 + val -= (uint64_t) mod->module_init_rx;
5327 + else if (in_init_rw(mod, val))
5328 + val -= (uint64_t) mod->module_init_rw;
5329 + else if (in_core_rx(mod, val))
5330 + val -= (uint64_t) mod->module_core_rx;
5331 + else if (in_core_rw(mod, val))
5332 + val -= (uint64_t) mod->module_core_rw;
5333 break;
5334
5335 case RV_LTV:
5336 @@ -820,15 +850,15 @@ apply_relocate_add (Elf64_Shdr *sechdrs, const char *strtab, unsigned int symind
5337 * addresses have been selected...
5338 */
5339 uint64_t gp;
5340 - if (mod->core_size > MAX_LTOFF)
5341 + if (mod->core_size_rx + mod->core_size_rw > MAX_LTOFF)
5342 /*
5343 * This takes advantage of fact that SHF_ARCH_SMALL gets allocated
5344 * at the end of the module.
5345 */
5346 - gp = mod->core_size - MAX_LTOFF / 2;
5347 + gp = mod->core_size_rx + mod->core_size_rw - MAX_LTOFF / 2;
5348 else
5349 - gp = mod->core_size / 2;
5350 - gp = (uint64_t) mod->module_core + ((gp + 7) & -8);
5351 + gp = (mod->core_size_rx + mod->core_size_rw) / 2;
5352 + gp = (uint64_t) mod->module_core_rx + ((gp + 7) & -8);
5353 mod->arch.gp = gp;
5354 DEBUGP("%s: placing gp at 0x%lx\n", __func__, gp);
5355 }
5356 diff --git a/arch/ia64/kernel/palinfo.c b/arch/ia64/kernel/palinfo.c
5357 index c39c3cd..3c77738 100644
5358 --- a/arch/ia64/kernel/palinfo.c
5359 +++ b/arch/ia64/kernel/palinfo.c
5360 @@ -980,7 +980,7 @@ static int palinfo_cpu_callback(struct notifier_block *nfb,
5361 return NOTIFY_OK;
5362 }
5363
5364 -static struct notifier_block __refdata palinfo_cpu_notifier =
5365 +static struct notifier_block palinfo_cpu_notifier =
5366 {
5367 .notifier_call = palinfo_cpu_callback,
5368 .priority = 0,
5369 diff --git a/arch/ia64/kernel/sys_ia64.c b/arch/ia64/kernel/sys_ia64.c
5370 index 41e33f8..65180b2a 100644
5371 --- a/arch/ia64/kernel/sys_ia64.c
5372 +++ b/arch/ia64/kernel/sys_ia64.c
5373 @@ -28,6 +28,7 @@ arch_get_unmapped_area (struct file *filp, unsigned long addr, unsigned long len
5374 unsigned long align_mask = 0;
5375 struct mm_struct *mm = current->mm;
5376 struct vm_unmapped_area_info info;
5377 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
5378
5379 if (len > RGN_MAP_LIMIT)
5380 return -ENOMEM;
5381 @@ -43,6 +44,13 @@ arch_get_unmapped_area (struct file *filp, unsigned long addr, unsigned long len
5382 if (REGION_NUMBER(addr) == RGN_HPAGE)
5383 addr = 0;
5384 #endif
5385 +
5386 +#ifdef CONFIG_PAX_RANDMMAP
5387 + if (mm->pax_flags & MF_PAX_RANDMMAP)
5388 + addr = mm->free_area_cache;
5389 + else
5390 +#endif
5391 +
5392 if (!addr)
5393 addr = TASK_UNMAPPED_BASE;
5394
5395 @@ -61,6 +69,7 @@ arch_get_unmapped_area (struct file *filp, unsigned long addr, unsigned long len
5396 info.high_limit = TASK_SIZE;
5397 info.align_mask = align_mask;
5398 info.align_offset = 0;
5399 + info.threadstack_offset = offset;
5400 return vm_unmapped_area(&info);
5401 }
5402
5403 diff --git a/arch/ia64/kernel/vmlinux.lds.S b/arch/ia64/kernel/vmlinux.lds.S
5404 index 84f8a52..7c76178 100644
5405 --- a/arch/ia64/kernel/vmlinux.lds.S
5406 +++ b/arch/ia64/kernel/vmlinux.lds.S
5407 @@ -192,7 +192,7 @@ SECTIONS {
5408 /* Per-cpu data: */
5409 . = ALIGN(PERCPU_PAGE_SIZE);
5410 PERCPU_VADDR(SMP_CACHE_BYTES, PERCPU_ADDR, :percpu)
5411 - __phys_per_cpu_start = __per_cpu_load;
5412 + __phys_per_cpu_start = per_cpu_load;
5413 /*
5414 * ensure percpu data fits
5415 * into percpu page size
5416 diff --git a/arch/ia64/mm/fault.c b/arch/ia64/mm/fault.c
5417 index 7225dad..2a7c8256 100644
5418 --- a/arch/ia64/mm/fault.c
5419 +++ b/arch/ia64/mm/fault.c
5420 @@ -72,6 +72,23 @@ mapped_kernel_page_is_present (unsigned long address)
5421 return pte_present(pte);
5422 }
5423
5424 +#ifdef CONFIG_PAX_PAGEEXEC
5425 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
5426 +{
5427 + unsigned long i;
5428 +
5429 + printk(KERN_ERR "PAX: bytes at PC: ");
5430 + for (i = 0; i < 8; i++) {
5431 + unsigned int c;
5432 + if (get_user(c, (unsigned int *)pc+i))
5433 + printk(KERN_CONT "???????? ");
5434 + else
5435 + printk(KERN_CONT "%08x ", c);
5436 + }
5437 + printk("\n");
5438 +}
5439 +#endif
5440 +
5441 # define VM_READ_BIT 0
5442 # define VM_WRITE_BIT 1
5443 # define VM_EXEC_BIT 2
5444 @@ -151,8 +168,21 @@ retry:
5445 if (((isr >> IA64_ISR_R_BIT) & 1UL) && (!(vma->vm_flags & (VM_READ | VM_WRITE))))
5446 goto bad_area;
5447
5448 - if ((vma->vm_flags & mask) != mask)
5449 + if ((vma->vm_flags & mask) != mask) {
5450 +
5451 +#ifdef CONFIG_PAX_PAGEEXEC
5452 + if (!(vma->vm_flags & VM_EXEC) && (mask & VM_EXEC)) {
5453 + if (!(mm->pax_flags & MF_PAX_PAGEEXEC) || address != regs->cr_iip)
5454 + goto bad_area;
5455 +
5456 + up_read(&mm->mmap_sem);
5457 + pax_report_fault(regs, (void *)regs->cr_iip, (void *)regs->r12);
5458 + do_group_exit(SIGKILL);
5459 + }
5460 +#endif
5461 +
5462 goto bad_area;
5463 + }
5464
5465 /*
5466 * If for any reason at all we couldn't handle the fault, make
5467 diff --git a/arch/ia64/mm/hugetlbpage.c b/arch/ia64/mm/hugetlbpage.c
5468 index 68232db..6ca80af 100644
5469 --- a/arch/ia64/mm/hugetlbpage.c
5470 +++ b/arch/ia64/mm/hugetlbpage.c
5471 @@ -154,6 +154,7 @@ unsigned long hugetlb_get_unmapped_area(struct file *file, unsigned long addr, u
5472 unsigned long pgoff, unsigned long flags)
5473 {
5474 struct vm_unmapped_area_info info;
5475 + unsigned long offset = gr_rand_threadstack_offset(current->mm, file, flags);
5476
5477 if (len > RGN_MAP_LIMIT)
5478 return -ENOMEM;
5479 @@ -177,6 +178,7 @@ unsigned long hugetlb_get_unmapped_area(struct file *file, unsigned long addr, u
5480 info.high_limit = HPAGE_REGION_BASE + RGN_MAP_LIMIT;
5481 info.align_mask = PAGE_MASK & (HPAGE_SIZE - 1);
5482 info.align_offset = 0;
5483 + info.threadstack_offset = offset;
5484 return vm_unmapped_area(&info);
5485 }
5486
5487 diff --git a/arch/ia64/mm/init.c b/arch/ia64/mm/init.c
5488 index 25c3502..560dae7 100644
5489 --- a/arch/ia64/mm/init.c
5490 +++ b/arch/ia64/mm/init.c
5491 @@ -120,6 +120,19 @@ ia64_init_addr_space (void)
5492 vma->vm_start = current->thread.rbs_bot & PAGE_MASK;
5493 vma->vm_end = vma->vm_start + PAGE_SIZE;
5494 vma->vm_flags = VM_DATA_DEFAULT_FLAGS|VM_GROWSUP|VM_ACCOUNT;
5495 +
5496 +#ifdef CONFIG_PAX_PAGEEXEC
5497 + if (current->mm->pax_flags & MF_PAX_PAGEEXEC) {
5498 + vma->vm_flags &= ~VM_EXEC;
5499 +
5500 +#ifdef CONFIG_PAX_MPROTECT
5501 + if (current->mm->pax_flags & MF_PAX_MPROTECT)
5502 + vma->vm_flags &= ~VM_MAYEXEC;
5503 +#endif
5504 +
5505 + }
5506 +#endif
5507 +
5508 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
5509 down_write(&current->mm->mmap_sem);
5510 if (insert_vm_struct(current->mm, vma)) {
5511 diff --git a/arch/m32r/include/asm/cache.h b/arch/m32r/include/asm/cache.h
5512 index 40b3ee9..8c2c112 100644
5513 --- a/arch/m32r/include/asm/cache.h
5514 +++ b/arch/m32r/include/asm/cache.h
5515 @@ -1,8 +1,10 @@
5516 #ifndef _ASM_M32R_CACHE_H
5517 #define _ASM_M32R_CACHE_H
5518
5519 +#include <linux/const.h>
5520 +
5521 /* L1 cache line size */
5522 #define L1_CACHE_SHIFT 4
5523 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
5524 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5525
5526 #endif /* _ASM_M32R_CACHE_H */
5527 diff --git a/arch/m32r/lib/usercopy.c b/arch/m32r/lib/usercopy.c
5528 index 82abd15..d95ae5d 100644
5529 --- a/arch/m32r/lib/usercopy.c
5530 +++ b/arch/m32r/lib/usercopy.c
5531 @@ -14,6 +14,9 @@
5532 unsigned long
5533 __generic_copy_to_user(void __user *to, const void *from, unsigned long n)
5534 {
5535 + if ((long)n < 0)
5536 + return n;
5537 +
5538 prefetch(from);
5539 if (access_ok(VERIFY_WRITE, to, n))
5540 __copy_user(to,from,n);
5541 @@ -23,6 +26,9 @@ __generic_copy_to_user(void __user *to, const void *from, unsigned long n)
5542 unsigned long
5543 __generic_copy_from_user(void *to, const void __user *from, unsigned long n)
5544 {
5545 + if ((long)n < 0)
5546 + return n;
5547 +
5548 prefetchw(to);
5549 if (access_ok(VERIFY_READ, from, n))
5550 __copy_user_zeroing(to,from,n);
5551 diff --git a/arch/m68k/include/asm/cache.h b/arch/m68k/include/asm/cache.h
5552 index 0395c51..5f26031 100644
5553 --- a/arch/m68k/include/asm/cache.h
5554 +++ b/arch/m68k/include/asm/cache.h
5555 @@ -4,9 +4,11 @@
5556 #ifndef __ARCH_M68K_CACHE_H
5557 #define __ARCH_M68K_CACHE_H
5558
5559 +#include <linux/const.h>
5560 +
5561 /* bytes per L1 cache line */
5562 #define L1_CACHE_SHIFT 4
5563 -#define L1_CACHE_BYTES (1<< L1_CACHE_SHIFT)
5564 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5565
5566 #define ARCH_DMA_MINALIGN L1_CACHE_BYTES
5567
5568 diff --git a/arch/metag/include/asm/barrier.h b/arch/metag/include/asm/barrier.h
5569 index 2d6f0de..de5f5ac 100644
5570 --- a/arch/metag/include/asm/barrier.h
5571 +++ b/arch/metag/include/asm/barrier.h
5572 @@ -89,7 +89,7 @@ static inline void fence(void)
5573 do { \
5574 compiletime_assert_atomic_type(*p); \
5575 smp_mb(); \
5576 - ACCESS_ONCE(*p) = (v); \
5577 + ACCESS_ONCE_RW(*p) = (v); \
5578 } while (0)
5579
5580 #define smp_load_acquire(p) \
5581 diff --git a/arch/metag/mm/hugetlbpage.c b/arch/metag/mm/hugetlbpage.c
5582 index 0424315..defcca9 100644
5583 --- a/arch/metag/mm/hugetlbpage.c
5584 +++ b/arch/metag/mm/hugetlbpage.c
5585 @@ -205,6 +205,7 @@ hugetlb_get_unmapped_area_new_pmd(unsigned long len)
5586 info.high_limit = TASK_SIZE;
5587 info.align_mask = PAGE_MASK & HUGEPT_MASK;
5588 info.align_offset = 0;
5589 + info.threadstack_offset = 0;
5590 return vm_unmapped_area(&info);
5591 }
5592
5593 diff --git a/arch/microblaze/include/asm/cache.h b/arch/microblaze/include/asm/cache.h
5594 index 4efe96a..60e8699 100644
5595 --- a/arch/microblaze/include/asm/cache.h
5596 +++ b/arch/microblaze/include/asm/cache.h
5597 @@ -13,11 +13,12 @@
5598 #ifndef _ASM_MICROBLAZE_CACHE_H
5599 #define _ASM_MICROBLAZE_CACHE_H
5600
5601 +#include <linux/const.h>
5602 #include <asm/registers.h>
5603
5604 #define L1_CACHE_SHIFT 5
5605 /* word-granular cache in microblaze */
5606 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
5607 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5608
5609 #define SMP_CACHE_BYTES L1_CACHE_BYTES
5610
5611 diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
5612 index 5cd695f..9a24ad0 100644
5613 --- a/arch/mips/Kconfig
5614 +++ b/arch/mips/Kconfig
5615 @@ -2395,6 +2395,7 @@ source "kernel/Kconfig.preempt"
5616
5617 config KEXEC
5618 bool "Kexec system call"
5619 + depends on !GRKERNSEC_KMEM
5620 help
5621 kexec is a system call that implements the ability to shutdown your
5622 current kernel, and to start another kernel. It is like a reboot
5623 diff --git a/arch/mips/cavium-octeon/dma-octeon.c b/arch/mips/cavium-octeon/dma-octeon.c
5624 index 02f2444..506969c 100644
5625 --- a/arch/mips/cavium-octeon/dma-octeon.c
5626 +++ b/arch/mips/cavium-octeon/dma-octeon.c
5627 @@ -199,7 +199,7 @@ static void octeon_dma_free_coherent(struct device *dev, size_t size,
5628 if (dma_release_from_coherent(dev, order, vaddr))
5629 return;
5630
5631 - swiotlb_free_coherent(dev, size, vaddr, dma_handle);
5632 + swiotlb_free_coherent(dev, size, vaddr, dma_handle, attrs);
5633 }
5634
5635 static dma_addr_t octeon_unity_phys_to_dma(struct device *dev, phys_addr_t paddr)
5636 diff --git a/arch/mips/include/asm/atomic.h b/arch/mips/include/asm/atomic.h
5637 index e8eb3d5..2e665d1 100644
5638 --- a/arch/mips/include/asm/atomic.h
5639 +++ b/arch/mips/include/asm/atomic.h
5640 @@ -21,15 +21,39 @@
5641 #include <asm/cmpxchg.h>
5642 #include <asm/war.h>
5643
5644 +#ifdef CONFIG_GENERIC_ATOMIC64
5645 +#include <asm-generic/atomic64.h>
5646 +#endif
5647 +
5648 #define ATOMIC_INIT(i) { (i) }
5649
5650 +#ifdef CONFIG_64BIT
5651 +#define _ASM_EXTABLE(from, to) \
5652 +" .section __ex_table,\"a\"\n" \
5653 +" .dword " #from ", " #to"\n" \
5654 +" .previous\n"
5655 +#else
5656 +#define _ASM_EXTABLE(from, to) \
5657 +" .section __ex_table,\"a\"\n" \
5658 +" .word " #from ", " #to"\n" \
5659 +" .previous\n"
5660 +#endif
5661 +
5662 /*
5663 * atomic_read - read atomic variable
5664 * @v: pointer of type atomic_t
5665 *
5666 * Atomically reads the value of @v.
5667 */
5668 -#define atomic_read(v) (*(volatile int *)&(v)->counter)
5669 +static inline int atomic_read(const atomic_t *v)
5670 +{
5671 + return (*(volatile const int *) &v->counter);
5672 +}
5673 +
5674 +static inline int atomic_read_unchecked(const atomic_unchecked_t *v)
5675 +{
5676 + return (*(volatile const int *) &v->counter);
5677 +}
5678
5679 /*
5680 * atomic_set - set atomic variable
5681 @@ -38,7 +62,15 @@
5682 *
5683 * Atomically sets the value of @v to @i.
5684 */
5685 -#define atomic_set(v, i) ((v)->counter = (i))
5686 +static inline void atomic_set(atomic_t *v, int i)
5687 +{
5688 + v->counter = i;
5689 +}
5690 +
5691 +static inline void atomic_set_unchecked(atomic_unchecked_t *v, int i)
5692 +{
5693 + v->counter = i;
5694 +}
5695
5696 /*
5697 * atomic_add - add integer to atomic variable
5698 @@ -47,7 +79,67 @@
5699 *
5700 * Atomically adds @i to @v.
5701 */
5702 -static __inline__ void atomic_add(int i, atomic_t * v)
5703 +static __inline__ void atomic_add(int i, atomic_t *v)
5704 +{
5705 + int temp;
5706 +
5707 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
5708 + __asm__ __volatile__(
5709 + " .set mips3 \n"
5710 + "1: ll %0, %1 # atomic_add \n"
5711 +#ifdef CONFIG_PAX_REFCOUNT
5712 + /* Exception on overflow. */
5713 + "2: add %0, %2 \n"
5714 +#else
5715 + " addu %0, %2 \n"
5716 +#endif
5717 + " sc %0, %1 \n"
5718 + " beqzl %0, 1b \n"
5719 +#ifdef CONFIG_PAX_REFCOUNT
5720 + "3: \n"
5721 + _ASM_EXTABLE(2b, 3b)
5722 +#endif
5723 + " .set mips0 \n"
5724 + : "=&r" (temp), "+m" (v->counter)
5725 + : "Ir" (i));
5726 + } else if (kernel_uses_llsc) {
5727 + __asm__ __volatile__(
5728 + " .set mips3 \n"
5729 + "1: ll %0, %1 # atomic_add \n"
5730 +#ifdef CONFIG_PAX_REFCOUNT
5731 + /* Exception on overflow. */
5732 + "2: add %0, %2 \n"
5733 +#else
5734 + " addu %0, %2 \n"
5735 +#endif
5736 + " sc %0, %1 \n"
5737 + " beqz %0, 1b \n"
5738 +#ifdef CONFIG_PAX_REFCOUNT
5739 + "3: \n"
5740 + _ASM_EXTABLE(2b, 3b)
5741 +#endif
5742 + " .set mips0 \n"
5743 + : "=&r" (temp), "+m" (v->counter)
5744 + : "Ir" (i));
5745 + } else {
5746 + unsigned long flags;
5747 +
5748 + raw_local_irq_save(flags);
5749 + __asm__ __volatile__(
5750 +#ifdef CONFIG_PAX_REFCOUNT
5751 + /* Exception on overflow. */
5752 + "1: add %0, %1 \n"
5753 + "2: \n"
5754 + _ASM_EXTABLE(1b, 2b)
5755 +#else
5756 + " addu %0, %1 \n"
5757 +#endif
5758 + : "+r" (v->counter) : "Ir" (i));
5759 + raw_local_irq_restore(flags);
5760 + }
5761 +}
5762 +
5763 +static __inline__ void atomic_add_unchecked(int i, atomic_unchecked_t *v)
5764 {
5765 if (kernel_uses_llsc && R10000_LLSC_WAR) {
5766 int temp;
5767 @@ -90,7 +182,67 @@ static __inline__ void atomic_add(int i, atomic_t * v)
5768 *
5769 * Atomically subtracts @i from @v.
5770 */
5771 -static __inline__ void atomic_sub(int i, atomic_t * v)
5772 +static __inline__ void atomic_sub(int i, atomic_t *v)
5773 +{
5774 + int temp;
5775 +
5776 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
5777 + __asm__ __volatile__(
5778 + " .set mips3 \n"
5779 + "1: ll %0, %1 # atomic64_sub \n"
5780 +#ifdef CONFIG_PAX_REFCOUNT
5781 + /* Exception on overflow. */
5782 + "2: sub %0, %2 \n"
5783 +#else
5784 + " subu %0, %2 \n"
5785 +#endif
5786 + " sc %0, %1 \n"
5787 + " beqzl %0, 1b \n"
5788 +#ifdef CONFIG_PAX_REFCOUNT
5789 + "3: \n"
5790 + _ASM_EXTABLE(2b, 3b)
5791 +#endif
5792 + " .set mips0 \n"
5793 + : "=&r" (temp), "+m" (v->counter)
5794 + : "Ir" (i));
5795 + } else if (kernel_uses_llsc) {
5796 + __asm__ __volatile__(
5797 + " .set mips3 \n"
5798 + "1: ll %0, %1 # atomic64_sub \n"
5799 +#ifdef CONFIG_PAX_REFCOUNT
5800 + /* Exception on overflow. */
5801 + "2: sub %0, %2 \n"
5802 +#else
5803 + " subu %0, %2 \n"
5804 +#endif
5805 + " sc %0, %1 \n"
5806 + " beqz %0, 1b \n"
5807 +#ifdef CONFIG_PAX_REFCOUNT
5808 + "3: \n"
5809 + _ASM_EXTABLE(2b, 3b)
5810 +#endif
5811 + " .set mips0 \n"
5812 + : "=&r" (temp), "+m" (v->counter)
5813 + : "Ir" (i));
5814 + } else {
5815 + unsigned long flags;
5816 +
5817 + raw_local_irq_save(flags);
5818 + __asm__ __volatile__(
5819 +#ifdef CONFIG_PAX_REFCOUNT
5820 + /* Exception on overflow. */
5821 + "1: sub %0, %1 \n"
5822 + "2: \n"
5823 + _ASM_EXTABLE(1b, 2b)
5824 +#else
5825 + " subu %0, %1 \n"
5826 +#endif
5827 + : "+r" (v->counter) : "Ir" (i));
5828 + raw_local_irq_restore(flags);
5829 + }
5830 +}
5831 +
5832 +static __inline__ void atomic_sub_unchecked(long i, atomic_unchecked_t *v)
5833 {
5834 if (kernel_uses_llsc && R10000_LLSC_WAR) {
5835 int temp;
5836 @@ -129,7 +281,93 @@ static __inline__ void atomic_sub(int i, atomic_t * v)
5837 /*
5838 * Same as above, but return the result value
5839 */
5840 -static __inline__ int atomic_add_return(int i, atomic_t * v)
5841 +static __inline__ int atomic_add_return(int i, atomic_t *v)
5842 +{
5843 + int result;
5844 + int temp;
5845 +
5846 + smp_mb__before_llsc();
5847 +
5848 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
5849 + __asm__ __volatile__(
5850 + " .set mips3 \n"
5851 + "1: ll %1, %2 # atomic_add_return \n"
5852 +#ifdef CONFIG_PAX_REFCOUNT
5853 + "2: add %0, %1, %3 \n"
5854 +#else
5855 + " addu %0, %1, %3 \n"
5856 +#endif
5857 + " sc %0, %2 \n"
5858 + " beqzl %0, 1b \n"
5859 +#ifdef CONFIG_PAX_REFCOUNT
5860 + " b 4f \n"
5861 + " .set noreorder \n"
5862 + "3: b 5f \n"
5863 + " move %0, %1 \n"
5864 + " .set reorder \n"
5865 + _ASM_EXTABLE(2b, 3b)
5866 +#endif
5867 + "4: addu %0, %1, %3 \n"
5868 +#ifdef CONFIG_PAX_REFCOUNT
5869 + "5: \n"
5870 +#endif
5871 + " .set mips0 \n"
5872 + : "=&r" (result), "=&r" (temp), "+m" (v->counter)
5873 + : "Ir" (i));
5874 + } else if (kernel_uses_llsc) {
5875 + __asm__ __volatile__(
5876 + " .set mips3 \n"
5877 + "1: ll %1, %2 # atomic_add_return \n"
5878 +#ifdef CONFIG_PAX_REFCOUNT
5879 + "2: add %0, %1, %3 \n"
5880 +#else
5881 + " addu %0, %1, %3 \n"
5882 +#endif
5883 + " sc %0, %2 \n"
5884 + " bnez %0, 4f \n"
5885 + " b 1b \n"
5886 +#ifdef CONFIG_PAX_REFCOUNT
5887 + " .set noreorder \n"
5888 + "3: b 5f \n"
5889 + " move %0, %1 \n"
5890 + " .set reorder \n"
5891 + _ASM_EXTABLE(2b, 3b)
5892 +#endif
5893 + "4: addu %0, %1, %3 \n"
5894 +#ifdef CONFIG_PAX_REFCOUNT
5895 + "5: \n"
5896 +#endif
5897 + " .set mips0 \n"
5898 + : "=&r" (result), "=&r" (temp), "+m" (v->counter)
5899 + : "Ir" (i));
5900 + } else {
5901 + unsigned long flags;
5902 +
5903 + raw_local_irq_save(flags);
5904 + __asm__ __volatile__(
5905 + " lw %0, %1 \n"
5906 +#ifdef CONFIG_PAX_REFCOUNT
5907 + /* Exception on overflow. */
5908 + "1: add %0, %2 \n"
5909 +#else
5910 + " addu %0, %2 \n"
5911 +#endif
5912 + " sw %0, %1 \n"
5913 +#ifdef CONFIG_PAX_REFCOUNT
5914 + /* Note: Dest reg is not modified on overflow */
5915 + "2: \n"
5916 + _ASM_EXTABLE(1b, 2b)
5917 +#endif
5918 + : "=&r" (result), "+m" (v->counter) : "Ir" (i));
5919 + raw_local_irq_restore(flags);
5920 + }
5921 +
5922 + smp_llsc_mb();
5923 +
5924 + return result;
5925 +}
5926 +
5927 +static __inline__ int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
5928 {
5929 int result;
5930
5931 @@ -178,7 +416,93 @@ static __inline__ int atomic_add_return(int i, atomic_t * v)
5932 return result;
5933 }
5934
5935 -static __inline__ int atomic_sub_return(int i, atomic_t * v)
5936 +static __inline__ int atomic_sub_return(int i, atomic_t *v)
5937 +{
5938 + int result;
5939 + int temp;
5940 +
5941 + smp_mb__before_llsc();
5942 +
5943 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
5944 + __asm__ __volatile__(
5945 + " .set mips3 \n"
5946 + "1: ll %1, %2 # atomic_sub_return \n"
5947 +#ifdef CONFIG_PAX_REFCOUNT
5948 + "2: sub %0, %1, %3 \n"
5949 +#else
5950 + " subu %0, %1, %3 \n"
5951 +#endif
5952 + " sc %0, %2 \n"
5953 + " beqzl %0, 1b \n"
5954 +#ifdef CONFIG_PAX_REFCOUNT
5955 + " b 4f \n"
5956 + " .set noreorder \n"
5957 + "3: b 5f \n"
5958 + " move %0, %1 \n"
5959 + " .set reorder \n"
5960 + _ASM_EXTABLE(2b, 3b)
5961 +#endif
5962 + "4: subu %0, %1, %3 \n"
5963 +#ifdef CONFIG_PAX_REFCOUNT
5964 + "5: \n"
5965 +#endif
5966 + " .set mips0 \n"
5967 + : "=&r" (result), "=&r" (temp), "=m" (v->counter)
5968 + : "Ir" (i), "m" (v->counter)
5969 + : "memory");
5970 + } else if (kernel_uses_llsc) {
5971 + __asm__ __volatile__(
5972 + " .set mips3 \n"
5973 + "1: ll %1, %2 # atomic_sub_return \n"
5974 +#ifdef CONFIG_PAX_REFCOUNT
5975 + "2: sub %0, %1, %3 \n"
5976 +#else
5977 + " subu %0, %1, %3 \n"
5978 +#endif
5979 + " sc %0, %2 \n"
5980 + " bnez %0, 4f \n"
5981 + " b 1b \n"
5982 +#ifdef CONFIG_PAX_REFCOUNT
5983 + " .set noreorder \n"
5984 + "3: b 5f \n"
5985 + " move %0, %1 \n"
5986 + " .set reorder \n"
5987 + _ASM_EXTABLE(2b, 3b)
5988 +#endif
5989 + "4: subu %0, %1, %3 \n"
5990 +#ifdef CONFIG_PAX_REFCOUNT
5991 + "5: \n"
5992 +#endif
5993 + " .set mips0 \n"
5994 + : "=&r" (result), "=&r" (temp), "+m" (v->counter)
5995 + : "Ir" (i));
5996 + } else {
5997 + unsigned long flags;
5998 +
5999 + raw_local_irq_save(flags);
6000 + __asm__ __volatile__(
6001 + " lw %0, %1 \n"
6002 +#ifdef CONFIG_PAX_REFCOUNT
6003 + /* Exception on overflow. */
6004 + "1: sub %0, %2 \n"
6005 +#else
6006 + " subu %0, %2 \n"
6007 +#endif
6008 + " sw %0, %1 \n"
6009 +#ifdef CONFIG_PAX_REFCOUNT
6010 + /* Note: Dest reg is not modified on overflow */
6011 + "2: \n"
6012 + _ASM_EXTABLE(1b, 2b)
6013 +#endif
6014 + : "=&r" (result), "+m" (v->counter) : "Ir" (i));
6015 + raw_local_irq_restore(flags);
6016 + }
6017 +
6018 + smp_llsc_mb();
6019 +
6020 + return result;
6021 +}
6022 +static __inline__ int atomic_sub_return_unchecked(int i, atomic_unchecked_t *v)
6023 {
6024 int result;
6025
6026 @@ -238,7 +562,7 @@ static __inline__ int atomic_sub_return(int i, atomic_t * v)
6027 * Atomically test @v and subtract @i if @v is greater or equal than @i.
6028 * The function returns the old value of @v minus @i.
6029 */
6030 -static __inline__ int atomic_sub_if_positive(int i, atomic_t * v)
6031 +static __inline__ int atomic_sub_if_positive(int i, atomic_t *v)
6032 {
6033 int result;
6034
6035 @@ -295,8 +619,26 @@ static __inline__ int atomic_sub_if_positive(int i, atomic_t * v)
6036 return result;
6037 }
6038
6039 -#define atomic_cmpxchg(v, o, n) (cmpxchg(&((v)->counter), (o), (n)))
6040 -#define atomic_xchg(v, new) (xchg(&((v)->counter), (new)))
6041 +static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
6042 +{
6043 + return cmpxchg(&v->counter, old, new);
6044 +}
6045 +
6046 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *v, int old,
6047 + int new)
6048 +{
6049 + return cmpxchg(&(v->counter), old, new);
6050 +}
6051 +
6052 +static inline int atomic_xchg(atomic_t *v, int new)
6053 +{
6054 + return xchg(&v->counter, new);
6055 +}
6056 +
6057 +static inline int atomic_xchg_unchecked(atomic_unchecked_t *v, int new)
6058 +{
6059 + return xchg(&(v->counter), new);
6060 +}
6061
6062 /**
6063 * __atomic_add_unless - add unless the number is a given value
6064 @@ -324,6 +666,10 @@ static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
6065
6066 #define atomic_dec_return(v) atomic_sub_return(1, (v))
6067 #define atomic_inc_return(v) atomic_add_return(1, (v))
6068 +static __inline__ int atomic_inc_return_unchecked(atomic_unchecked_t *v)
6069 +{
6070 + return atomic_add_return_unchecked(1, v);
6071 +}
6072
6073 /*
6074 * atomic_sub_and_test - subtract value from variable and test result
6075 @@ -345,6 +691,10 @@ static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
6076 * other cases.
6077 */
6078 #define atomic_inc_and_test(v) (atomic_inc_return(v) == 0)
6079 +static __inline__ int atomic_inc_and_test_unchecked(atomic_unchecked_t *v)
6080 +{
6081 + return atomic_add_return_unchecked(1, v) == 0;
6082 +}
6083
6084 /*
6085 * atomic_dec_and_test - decrement by 1 and test
6086 @@ -369,6 +719,10 @@ static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
6087 * Atomically increments @v by 1.
6088 */
6089 #define atomic_inc(v) atomic_add(1, (v))
6090 +static __inline__ void atomic_inc_unchecked(atomic_unchecked_t *v)
6091 +{
6092 + atomic_add_unchecked(1, v);
6093 +}
6094
6095 /*
6096 * atomic_dec - decrement and test
6097 @@ -377,6 +731,10 @@ static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
6098 * Atomically decrements @v by 1.
6099 */
6100 #define atomic_dec(v) atomic_sub(1, (v))
6101 +static __inline__ void atomic_dec_unchecked(atomic_unchecked_t *v)
6102 +{
6103 + atomic_sub_unchecked(1, v);
6104 +}
6105
6106 /*
6107 * atomic_add_negative - add and test if negative
6108 @@ -398,14 +756,30 @@ static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
6109 * @v: pointer of type atomic64_t
6110 *
6111 */
6112 -#define atomic64_read(v) (*(volatile long *)&(v)->counter)
6113 +static inline long atomic64_read(const atomic64_t *v)
6114 +{
6115 + return (*(volatile const long *) &v->counter);
6116 +}
6117 +
6118 +static inline long atomic64_read_unchecked(const atomic64_unchecked_t *v)
6119 +{
6120 + return (*(volatile const long *) &v->counter);
6121 +}
6122
6123 /*
6124 * atomic64_set - set atomic variable
6125 * @v: pointer of type atomic64_t
6126 * @i: required value
6127 */
6128 -#define atomic64_set(v, i) ((v)->counter = (i))
6129 +static inline void atomic64_set(atomic64_t *v, long i)
6130 +{
6131 + v->counter = i;
6132 +}
6133 +
6134 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long i)
6135 +{
6136 + v->counter = i;
6137 +}
6138
6139 /*
6140 * atomic64_add - add integer to atomic variable
6141 @@ -414,7 +788,66 @@ static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
6142 *
6143 * Atomically adds @i to @v.
6144 */
6145 -static __inline__ void atomic64_add(long i, atomic64_t * v)
6146 +static __inline__ void atomic64_add(long i, atomic64_t *v)
6147 +{
6148 + long temp;
6149 +
6150 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
6151 + __asm__ __volatile__(
6152 + " .set mips3 \n"
6153 + "1: lld %0, %1 # atomic64_add \n"
6154 +#ifdef CONFIG_PAX_REFCOUNT
6155 + /* Exception on overflow. */
6156 + "2: dadd %0, %2 \n"
6157 +#else
6158 + " daddu %0, %2 \n"
6159 +#endif
6160 + " scd %0, %1 \n"
6161 + " beqzl %0, 1b \n"
6162 +#ifdef CONFIG_PAX_REFCOUNT
6163 + "3: \n"
6164 + _ASM_EXTABLE(2b, 3b)
6165 +#endif
6166 + " .set mips0 \n"
6167 + : "=&r" (temp), "+m" (v->counter)
6168 + : "Ir" (i));
6169 + } else if (kernel_uses_llsc) {
6170 + __asm__ __volatile__(
6171 + " .set mips3 \n"
6172 + "1: lld %0, %1 # atomic64_add \n"
6173 +#ifdef CONFIG_PAX_REFCOUNT
6174 + /* Exception on overflow. */
6175 + "2: dadd %0, %2 \n"
6176 +#else
6177 + " daddu %0, %2 \n"
6178 +#endif
6179 + " scd %0, %1 \n"
6180 + " beqz %0, 1b \n"
6181 +#ifdef CONFIG_PAX_REFCOUNT
6182 + "3: \n"
6183 + _ASM_EXTABLE(2b, 3b)
6184 +#endif
6185 + " .set mips0 \n"
6186 + : "=&r" (temp), "+m" (v->counter)
6187 + : "Ir" (i));
6188 + } else {
6189 + unsigned long flags;
6190 +
6191 + raw_local_irq_save(flags);
6192 + __asm__ __volatile__(
6193 +#ifdef CONFIG_PAX_REFCOUNT
6194 + /* Exception on overflow. */
6195 + "1: dadd %0, %1 \n"
6196 + "2: \n"
6197 + _ASM_EXTABLE(1b, 2b)
6198 +#else
6199 + " daddu %0, %1 \n"
6200 +#endif
6201 + : "+r" (v->counter) : "Ir" (i));
6202 + raw_local_irq_restore(flags);
6203 + }
6204 +}
6205 +static __inline__ void atomic64_add_unchecked(long i, atomic64_unchecked_t *v)
6206 {
6207 if (kernel_uses_llsc && R10000_LLSC_WAR) {
6208 long temp;
6209 @@ -457,7 +890,67 @@ static __inline__ void atomic64_add(long i, atomic64_t * v)
6210 *
6211 * Atomically subtracts @i from @v.
6212 */
6213 -static __inline__ void atomic64_sub(long i, atomic64_t * v)
6214 +static __inline__ void atomic64_sub(long i, atomic64_t *v)
6215 +{
6216 + long temp;
6217 +
6218 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
6219 + __asm__ __volatile__(
6220 + " .set mips3 \n"
6221 + "1: lld %0, %1 # atomic64_sub \n"
6222 +#ifdef CONFIG_PAX_REFCOUNT
6223 + /* Exception on overflow. */
6224 + "2: dsub %0, %2 \n"
6225 +#else
6226 + " dsubu %0, %2 \n"
6227 +#endif
6228 + " scd %0, %1 \n"
6229 + " beqzl %0, 1b \n"
6230 +#ifdef CONFIG_PAX_REFCOUNT
6231 + "3: \n"
6232 + _ASM_EXTABLE(2b, 3b)
6233 +#endif
6234 + " .set mips0 \n"
6235 + : "=&r" (temp), "+m" (v->counter)
6236 + : "Ir" (i));
6237 + } else if (kernel_uses_llsc) {
6238 + __asm__ __volatile__(
6239 + " .set mips3 \n"
6240 + "1: lld %0, %1 # atomic64_sub \n"
6241 +#ifdef CONFIG_PAX_REFCOUNT
6242 + /* Exception on overflow. */
6243 + "2: dsub %0, %2 \n"
6244 +#else
6245 + " dsubu %0, %2 \n"
6246 +#endif
6247 + " scd %0, %1 \n"
6248 + " beqz %0, 1b \n"
6249 +#ifdef CONFIG_PAX_REFCOUNT
6250 + "3: \n"
6251 + _ASM_EXTABLE(2b, 3b)
6252 +#endif
6253 + " .set mips0 \n"
6254 + : "=&r" (temp), "+m" (v->counter)
6255 + : "Ir" (i));
6256 + } else {
6257 + unsigned long flags;
6258 +
6259 + raw_local_irq_save(flags);
6260 + __asm__ __volatile__(
6261 +#ifdef CONFIG_PAX_REFCOUNT
6262 + /* Exception on overflow. */
6263 + "1: dsub %0, %1 \n"
6264 + "2: \n"
6265 + _ASM_EXTABLE(1b, 2b)
6266 +#else
6267 + " dsubu %0, %1 \n"
6268 +#endif
6269 + : "+r" (v->counter) : "Ir" (i));
6270 + raw_local_irq_restore(flags);
6271 + }
6272 +}
6273 +
6274 +static __inline__ void atomic64_sub_unchecked(long i, atomic64_unchecked_t *v)
6275 {
6276 if (kernel_uses_llsc && R10000_LLSC_WAR) {
6277 long temp;
6278 @@ -496,7 +989,93 @@ static __inline__ void atomic64_sub(long i, atomic64_t * v)
6279 /*
6280 * Same as above, but return the result value
6281 */
6282 -static __inline__ long atomic64_add_return(long i, atomic64_t * v)
6283 +static __inline__ long atomic64_add_return(long i, atomic64_t *v)
6284 +{
6285 + long result;
6286 + long temp;
6287 +
6288 + smp_mb__before_llsc();
6289 +
6290 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
6291 + __asm__ __volatile__(
6292 + " .set mips3 \n"
6293 + "1: lld %1, %2 # atomic64_add_return \n"
6294 +#ifdef CONFIG_PAX_REFCOUNT
6295 + "2: dadd %0, %1, %3 \n"
6296 +#else
6297 + " daddu %0, %1, %3 \n"
6298 +#endif
6299 + " scd %0, %2 \n"
6300 + " beqzl %0, 1b \n"
6301 +#ifdef CONFIG_PAX_REFCOUNT
6302 + " b 4f \n"
6303 + " .set noreorder \n"
6304 + "3: b 5f \n"
6305 + " move %0, %1 \n"
6306 + " .set reorder \n"
6307 + _ASM_EXTABLE(2b, 3b)
6308 +#endif
6309 + "4: daddu %0, %1, %3 \n"
6310 +#ifdef CONFIG_PAX_REFCOUNT
6311 + "5: \n"
6312 +#endif
6313 + " .set mips0 \n"
6314 + : "=&r" (result), "=&r" (temp), "+m" (v->counter)
6315 + : "Ir" (i));
6316 + } else if (kernel_uses_llsc) {
6317 + __asm__ __volatile__(
6318 + " .set mips3 \n"
6319 + "1: lld %1, %2 # atomic64_add_return \n"
6320 +#ifdef CONFIG_PAX_REFCOUNT
6321 + "2: dadd %0, %1, %3 \n"
6322 +#else
6323 + " daddu %0, %1, %3 \n"
6324 +#endif
6325 + " scd %0, %2 \n"
6326 + " bnez %0, 4f \n"
6327 + " b 1b \n"
6328 +#ifdef CONFIG_PAX_REFCOUNT
6329 + " .set noreorder \n"
6330 + "3: b 5f \n"
6331 + " move %0, %1 \n"
6332 + " .set reorder \n"
6333 + _ASM_EXTABLE(2b, 3b)
6334 +#endif
6335 + "4: daddu %0, %1, %3 \n"
6336 +#ifdef CONFIG_PAX_REFCOUNT
6337 + "5: \n"
6338 +#endif
6339 + " .set mips0 \n"
6340 + : "=&r" (result), "=&r" (temp), "=m" (v->counter)
6341 + : "Ir" (i), "m" (v->counter)
6342 + : "memory");
6343 + } else {
6344 + unsigned long flags;
6345 +
6346 + raw_local_irq_save(flags);
6347 + __asm__ __volatile__(
6348 + " ld %0, %1 \n"
6349 +#ifdef CONFIG_PAX_REFCOUNT
6350 + /* Exception on overflow. */
6351 + "1: dadd %0, %2 \n"
6352 +#else
6353 + " daddu %0, %2 \n"
6354 +#endif
6355 + " sd %0, %1 \n"
6356 +#ifdef CONFIG_PAX_REFCOUNT
6357 + /* Note: Dest reg is not modified on overflow */
6358 + "2: \n"
6359 + _ASM_EXTABLE(1b, 2b)
6360 +#endif
6361 + : "=&r" (result), "+m" (v->counter) : "Ir" (i));
6362 + raw_local_irq_restore(flags);
6363 + }
6364 +
6365 + smp_llsc_mb();
6366 +
6367 + return result;
6368 +}
6369 +static __inline__ long atomic64_add_return_unchecked(long i, atomic64_unchecked_t *v)
6370 {
6371 long result;
6372
6373 @@ -546,7 +1125,97 @@ static __inline__ long atomic64_add_return(long i, atomic64_t * v)
6374 return result;
6375 }
6376
6377 -static __inline__ long atomic64_sub_return(long i, atomic64_t * v)
6378 +static __inline__ long atomic64_sub_return(long i, atomic64_t *v)
6379 +{
6380 + long result;
6381 + long temp;
6382 +
6383 + smp_mb__before_llsc();
6384 +
6385 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
6386 + long temp;
6387 +
6388 + __asm__ __volatile__(
6389 + " .set mips3 \n"
6390 + "1: lld %1, %2 # atomic64_sub_return \n"
6391 +#ifdef CONFIG_PAX_REFCOUNT
6392 + "2: dsub %0, %1, %3 \n"
6393 +#else
6394 + " dsubu %0, %1, %3 \n"
6395 +#endif
6396 + " scd %0, %2 \n"
6397 + " beqzl %0, 1b \n"
6398 +#ifdef CONFIG_PAX_REFCOUNT
6399 + " b 4f \n"
6400 + " .set noreorder \n"
6401 + "3: b 5f \n"
6402 + " move %0, %1 \n"
6403 + " .set reorder \n"
6404 + _ASM_EXTABLE(2b, 3b)
6405 +#endif
6406 + "4: dsubu %0, %1, %3 \n"
6407 +#ifdef CONFIG_PAX_REFCOUNT
6408 + "5: \n"
6409 +#endif
6410 + " .set mips0 \n"
6411 + : "=&r" (result), "=&r" (temp), "=m" (v->counter)
6412 + : "Ir" (i), "m" (v->counter)
6413 + : "memory");
6414 + } else if (kernel_uses_llsc) {
6415 + __asm__ __volatile__(
6416 + " .set mips3 \n"
6417 + "1: lld %1, %2 # atomic64_sub_return \n"
6418 +#ifdef CONFIG_PAX_REFCOUNT
6419 + "2: dsub %0, %1, %3 \n"
6420 +#else
6421 + " dsubu %0, %1, %3 \n"
6422 +#endif
6423 + " scd %0, %2 \n"
6424 + " bnez %0, 4f \n"
6425 + " b 1b \n"
6426 +#ifdef CONFIG_PAX_REFCOUNT
6427 + " .set noreorder \n"
6428 + "3: b 5f \n"
6429 + " move %0, %1 \n"
6430 + " .set reorder \n"
6431 + _ASM_EXTABLE(2b, 3b)
6432 +#endif
6433 + "4: dsubu %0, %1, %3 \n"
6434 +#ifdef CONFIG_PAX_REFCOUNT
6435 + "5: \n"
6436 +#endif
6437 + " .set mips0 \n"
6438 + : "=&r" (result), "=&r" (temp), "=m" (v->counter)
6439 + : "Ir" (i), "m" (v->counter)
6440 + : "memory");
6441 + } else {
6442 + unsigned long flags;
6443 +
6444 + raw_local_irq_save(flags);
6445 + __asm__ __volatile__(
6446 + " ld %0, %1 \n"
6447 +#ifdef CONFIG_PAX_REFCOUNT
6448 + /* Exception on overflow. */
6449 + "1: dsub %0, %2 \n"
6450 +#else
6451 + " dsubu %0, %2 \n"
6452 +#endif
6453 + " sd %0, %1 \n"
6454 +#ifdef CONFIG_PAX_REFCOUNT
6455 + /* Note: Dest reg is not modified on overflow */
6456 + "2: \n"
6457 + _ASM_EXTABLE(1b, 2b)
6458 +#endif
6459 + : "=&r" (result), "+m" (v->counter) : "Ir" (i));
6460 + raw_local_irq_restore(flags);
6461 + }
6462 +
6463 + smp_llsc_mb();
6464 +
6465 + return result;
6466 +}
6467 +
6468 +static __inline__ long atomic64_sub_return_unchecked(long i, atomic64_unchecked_t *v)
6469 {
6470 long result;
6471
6472 @@ -605,7 +1274,7 @@ static __inline__ long atomic64_sub_return(long i, atomic64_t * v)
6473 * Atomically test @v and subtract @i if @v is greater or equal than @i.
6474 * The function returns the old value of @v minus @i.
6475 */
6476 -static __inline__ long atomic64_sub_if_positive(long i, atomic64_t * v)
6477 +static __inline__ long atomic64_sub_if_positive(long i, atomic64_t *v)
6478 {
6479 long result;
6480
6481 @@ -662,9 +1331,26 @@ static __inline__ long atomic64_sub_if_positive(long i, atomic64_t * v)
6482 return result;
6483 }
6484
6485 -#define atomic64_cmpxchg(v, o, n) \
6486 - ((__typeof__((v)->counter))cmpxchg(&((v)->counter), (o), (n)))
6487 -#define atomic64_xchg(v, new) (xchg(&((v)->counter), (new)))
6488 +static inline long atomic64_cmpxchg(atomic64_t *v, long old, long new)
6489 +{
6490 + return cmpxchg(&v->counter, old, new);
6491 +}
6492 +
6493 +static inline long atomic64_cmpxchg_unchecked(atomic64_unchecked_t *v, long old,
6494 + long new)
6495 +{
6496 + return cmpxchg(&(v->counter), old, new);
6497 +}
6498 +
6499 +static inline long atomic64_xchg(atomic64_t *v, long new)
6500 +{
6501 + return xchg(&v->counter, new);
6502 +}
6503 +
6504 +static inline long atomic64_xchg_unchecked(atomic64_unchecked_t *v, long new)
6505 +{
6506 + return xchg(&(v->counter), new);
6507 +}
6508
6509 /**
6510 * atomic64_add_unless - add unless the number is a given value
6511 @@ -694,6 +1380,7 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)
6512
6513 #define atomic64_dec_return(v) atomic64_sub_return(1, (v))
6514 #define atomic64_inc_return(v) atomic64_add_return(1, (v))
6515 +#define atomic64_inc_return_unchecked(v) atomic64_add_return_unchecked(1, (v))
6516
6517 /*
6518 * atomic64_sub_and_test - subtract value from variable and test result
6519 @@ -715,6 +1402,7 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)
6520 * other cases.
6521 */
6522 #define atomic64_inc_and_test(v) (atomic64_inc_return(v) == 0)
6523 +#define atomic64_inc_and_test_unchecked(v) atomic64_add_return_unchecked(1, (v)) == 0)
6524
6525 /*
6526 * atomic64_dec_and_test - decrement by 1 and test
6527 @@ -739,6 +1427,7 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)
6528 * Atomically increments @v by 1.
6529 */
6530 #define atomic64_inc(v) atomic64_add(1, (v))
6531 +#define atomic64_inc_unchecked(v) atomic64_add_unchecked(1, (v))
6532
6533 /*
6534 * atomic64_dec - decrement and test
6535 @@ -747,6 +1436,7 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)
6536 * Atomically decrements @v by 1.
6537 */
6538 #define atomic64_dec(v) atomic64_sub(1, (v))
6539 +#define atomic64_dec_unchecked(v) atomic64_sub_unchecked(1, (v))
6540
6541 /*
6542 * atomic64_add_negative - add and test if negative
6543 diff --git a/arch/mips/include/asm/barrier.h b/arch/mips/include/asm/barrier.h
6544 index e1aa4e4..670b68b 100644
6545 --- a/arch/mips/include/asm/barrier.h
6546 +++ b/arch/mips/include/asm/barrier.h
6547 @@ -184,7 +184,7 @@
6548 do { \
6549 compiletime_assert_atomic_type(*p); \
6550 smp_mb(); \
6551 - ACCESS_ONCE(*p) = (v); \
6552 + ACCESS_ONCE_RW(*p) = (v); \
6553 } while (0)
6554
6555 #define smp_load_acquire(p) \
6556 diff --git a/arch/mips/include/asm/cache.h b/arch/mips/include/asm/cache.h
6557 index b4db69f..8f3b093 100644
6558 --- a/arch/mips/include/asm/cache.h
6559 +++ b/arch/mips/include/asm/cache.h
6560 @@ -9,10 +9,11 @@
6561 #ifndef _ASM_CACHE_H
6562 #define _ASM_CACHE_H
6563
6564 +#include <linux/const.h>
6565 #include <kmalloc.h>
6566
6567 #define L1_CACHE_SHIFT CONFIG_MIPS_L1_CACHE_SHIFT
6568 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
6569 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
6570
6571 #define SMP_CACHE_SHIFT L1_CACHE_SHIFT
6572 #define SMP_CACHE_BYTES L1_CACHE_BYTES
6573 diff --git a/arch/mips/include/asm/elf.h b/arch/mips/include/asm/elf.h
6574 index d414405..6bb4ba2 100644
6575 --- a/arch/mips/include/asm/elf.h
6576 +++ b/arch/mips/include/asm/elf.h
6577 @@ -398,13 +398,16 @@ extern const char *__elf_platform;
6578 #define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
6579 #endif
6580
6581 +#ifdef CONFIG_PAX_ASLR
6582 +#define PAX_ELF_ET_DYN_BASE (TASK_IS_32BIT_ADDR ? 0x00400000UL : 0x00400000UL)
6583 +
6584 +#define PAX_DELTA_MMAP_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
6585 +#define PAX_DELTA_STACK_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
6586 +#endif
6587 +
6588 #define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1
6589 struct linux_binprm;
6590 extern int arch_setup_additional_pages(struct linux_binprm *bprm,
6591 int uses_interp);
6592
6593 -struct mm_struct;
6594 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
6595 -#define arch_randomize_brk arch_randomize_brk
6596 -
6597 #endif /* _ASM_ELF_H */
6598 diff --git a/arch/mips/include/asm/exec.h b/arch/mips/include/asm/exec.h
6599 index c1f6afa..38cc6e9 100644
6600 --- a/arch/mips/include/asm/exec.h
6601 +++ b/arch/mips/include/asm/exec.h
6602 @@ -12,6 +12,6 @@
6603 #ifndef _ASM_EXEC_H
6604 #define _ASM_EXEC_H
6605
6606 -extern unsigned long arch_align_stack(unsigned long sp);
6607 +#define arch_align_stack(x) ((x) & ~0xfUL)
6608
6609 #endif /* _ASM_EXEC_H */
6610 diff --git a/arch/mips/include/asm/hw_irq.h b/arch/mips/include/asm/hw_irq.h
6611 index 9e8ef59..1139d6b 100644
6612 --- a/arch/mips/include/asm/hw_irq.h
6613 +++ b/arch/mips/include/asm/hw_irq.h
6614 @@ -10,7 +10,7 @@
6615
6616 #include <linux/atomic.h>
6617
6618 -extern atomic_t irq_err_count;
6619 +extern atomic_unchecked_t irq_err_count;
6620
6621 /*
6622 * interrupt-retrigger: NOP for now. This may not be appropriate for all
6623 diff --git a/arch/mips/include/asm/local.h b/arch/mips/include/asm/local.h
6624 index 46dfc3c..a16b13a 100644
6625 --- a/arch/mips/include/asm/local.h
6626 +++ b/arch/mips/include/asm/local.h
6627 @@ -12,15 +12,25 @@ typedef struct
6628 atomic_long_t a;
6629 } local_t;
6630
6631 +typedef struct {
6632 + atomic_long_unchecked_t a;
6633 +} local_unchecked_t;
6634 +
6635 #define LOCAL_INIT(i) { ATOMIC_LONG_INIT(i) }
6636
6637 #define local_read(l) atomic_long_read(&(l)->a)
6638 +#define local_read_unchecked(l) atomic_long_read_unchecked(&(l)->a)
6639 #define local_set(l, i) atomic_long_set(&(l)->a, (i))
6640 +#define local_set_unchecked(l, i) atomic_long_set_unchecked(&(l)->a, (i))
6641
6642 #define local_add(i, l) atomic_long_add((i), (&(l)->a))
6643 +#define local_add_unchecked(i, l) atomic_long_add_unchecked((i), (&(l)->a))
6644 #define local_sub(i, l) atomic_long_sub((i), (&(l)->a))
6645 +#define local_sub_unchecked(i, l) atomic_long_sub_unchecked((i), (&(l)->a))
6646 #define local_inc(l) atomic_long_inc(&(l)->a)
6647 +#define local_inc_unchecked(l) atomic_long_inc_unchecked(&(l)->a)
6648 #define local_dec(l) atomic_long_dec(&(l)->a)
6649 +#define local_dec_unchecked(l) atomic_long_dec_unchecked(&(l)->a)
6650
6651 /*
6652 * Same as above, but return the result value
6653 @@ -70,6 +80,51 @@ static __inline__ long local_add_return(long i, local_t * l)
6654 return result;
6655 }
6656
6657 +static __inline__ long local_add_return_unchecked(long i, local_unchecked_t * l)
6658 +{
6659 + unsigned long result;
6660 +
6661 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
6662 + unsigned long temp;
6663 +
6664 + __asm__ __volatile__(
6665 + " .set mips3 \n"
6666 + "1:" __LL "%1, %2 # local_add_return \n"
6667 + " addu %0, %1, %3 \n"
6668 + __SC "%0, %2 \n"
6669 + " beqzl %0, 1b \n"
6670 + " addu %0, %1, %3 \n"
6671 + " .set mips0 \n"
6672 + : "=&r" (result), "=&r" (temp), "=m" (l->a.counter)
6673 + : "Ir" (i), "m" (l->a.counter)
6674 + : "memory");
6675 + } else if (kernel_uses_llsc) {
6676 + unsigned long temp;
6677 +
6678 + __asm__ __volatile__(
6679 + " .set mips3 \n"
6680 + "1:" __LL "%1, %2 # local_add_return \n"
6681 + " addu %0, %1, %3 \n"
6682 + __SC "%0, %2 \n"
6683 + " beqz %0, 1b \n"
6684 + " addu %0, %1, %3 \n"
6685 + " .set mips0 \n"
6686 + : "=&r" (result), "=&r" (temp), "=m" (l->a.counter)
6687 + : "Ir" (i), "m" (l->a.counter)
6688 + : "memory");
6689 + } else {
6690 + unsigned long flags;
6691 +
6692 + local_irq_save(flags);
6693 + result = l->a.counter;
6694 + result += i;
6695 + l->a.counter = result;
6696 + local_irq_restore(flags);
6697 + }
6698 +
6699 + return result;
6700 +}
6701 +
6702 static __inline__ long local_sub_return(long i, local_t * l)
6703 {
6704 unsigned long result;
6705 @@ -117,6 +172,8 @@ static __inline__ long local_sub_return(long i, local_t * l)
6706
6707 #define local_cmpxchg(l, o, n) \
6708 ((long)cmpxchg_local(&((l)->a.counter), (o), (n)))
6709 +#define local_cmpxchg_unchecked(l, o, n) \
6710 + ((long)cmpxchg_local(&((l)->a.counter), (o), (n)))
6711 #define local_xchg(l, n) (atomic_long_xchg((&(l)->a), (n)))
6712
6713 /**
6714 diff --git a/arch/mips/include/asm/page.h b/arch/mips/include/asm/page.h
6715 index 5699ec3..95def83 100644
6716 --- a/arch/mips/include/asm/page.h
6717 +++ b/arch/mips/include/asm/page.h
6718 @@ -120,7 +120,7 @@ extern void copy_user_highpage(struct page *to, struct page *from,
6719 #ifdef CONFIG_CPU_MIPS32
6720 typedef struct { unsigned long pte_low, pte_high; } pte_t;
6721 #define pte_val(x) ((x).pte_low | ((unsigned long long)(x).pte_high << 32))
6722 - #define __pte(x) ({ pte_t __pte = {(x), ((unsigned long long)(x)) >> 32}; __pte; })
6723 + #define __pte(x) ({ pte_t __pte = {(x), (x) >> 32}; __pte; })
6724 #else
6725 typedef struct { unsigned long long pte; } pte_t;
6726 #define pte_val(x) ((x).pte)
6727 diff --git a/arch/mips/include/asm/pgalloc.h b/arch/mips/include/asm/pgalloc.h
6728 index b336037..5b874cc 100644
6729 --- a/arch/mips/include/asm/pgalloc.h
6730 +++ b/arch/mips/include/asm/pgalloc.h
6731 @@ -37,6 +37,11 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
6732 {
6733 set_pud(pud, __pud((unsigned long)pmd));
6734 }
6735 +
6736 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
6737 +{
6738 + pud_populate(mm, pud, pmd);
6739 +}
6740 #endif
6741
6742 /*
6743 diff --git a/arch/mips/include/asm/pgtable.h b/arch/mips/include/asm/pgtable.h
6744 index 008324d..f67c239 100644
6745 --- a/arch/mips/include/asm/pgtable.h
6746 +++ b/arch/mips/include/asm/pgtable.h
6747 @@ -20,6 +20,9 @@
6748 #include <asm/io.h>
6749 #include <asm/pgtable-bits.h>
6750
6751 +#define ktla_ktva(addr) (addr)
6752 +#define ktva_ktla(addr) (addr)
6753 +
6754 struct mm_struct;
6755 struct vm_area_struct;
6756
6757 diff --git a/arch/mips/include/asm/smtc_proc.h b/arch/mips/include/asm/smtc_proc.h
6758 index 25da651..ae2a259 100644
6759 --- a/arch/mips/include/asm/smtc_proc.h
6760 +++ b/arch/mips/include/asm/smtc_proc.h
6761 @@ -18,6 +18,6 @@ extern struct smtc_cpu_proc smtc_cpu_stats[NR_CPUS];
6762
6763 /* Count of number of recoveries of "stolen" FPU access rights on 34K */
6764
6765 -extern atomic_t smtc_fpu_recoveries;
6766 +extern atomic_unchecked_t smtc_fpu_recoveries;
6767
6768 #endif /* __ASM_SMTC_PROC_H */
6769 diff --git a/arch/mips/include/asm/thread_info.h b/arch/mips/include/asm/thread_info.h
6770 index d2d961d..a674df0 100644
6771 --- a/arch/mips/include/asm/thread_info.h
6772 +++ b/arch/mips/include/asm/thread_info.h
6773 @@ -105,6 +105,9 @@ static inline struct thread_info *current_thread_info(void)
6774 #define TIF_SECCOMP 4 /* secure computing */
6775 #define TIF_NOTIFY_RESUME 5 /* callback before returning to user */
6776 #define TIF_RESTORE_SIGMASK 9 /* restore signal mask in do_signal() */
6777 +/* li takes a 32bit immediate */
6778 +#define TIF_GRSEC_SETXID 10 /* update credentials on syscall entry/exit */
6779 +
6780 #define TIF_USEDFPU 16 /* FPU was used by this task this quantum (SMP) */
6781 #define TIF_MEMDIE 18 /* is terminating due to OOM killer */
6782 #define TIF_NOHZ 19 /* in adaptive nohz mode */
6783 @@ -138,14 +141,16 @@ static inline struct thread_info *current_thread_info(void)
6784 #define _TIF_USEDMSA (1<<TIF_USEDMSA)
6785 #define _TIF_MSA_CTX_LIVE (1<<TIF_MSA_CTX_LIVE)
6786 #define _TIF_SYSCALL_TRACEPOINT (1<<TIF_SYSCALL_TRACEPOINT)
6787 +#define _TIF_GRSEC_SETXID (1<<TIF_GRSEC_SETXID)
6788
6789 #define _TIF_WORK_SYSCALL_ENTRY (_TIF_NOHZ | _TIF_SYSCALL_TRACE | \
6790 _TIF_SYSCALL_AUDIT | \
6791 - _TIF_SYSCALL_TRACEPOINT | _TIF_SECCOMP)
6792 + _TIF_SYSCALL_TRACEPOINT | _TIF_SECCOMP | \
6793 + _TIF_GRSEC_SETXID)
6794
6795 /* work to do in syscall_trace_leave() */
6796 #define _TIF_WORK_SYSCALL_EXIT (_TIF_NOHZ | _TIF_SYSCALL_TRACE | \
6797 - _TIF_SYSCALL_AUDIT | _TIF_SYSCALL_TRACEPOINT)
6798 + _TIF_SYSCALL_AUDIT | _TIF_SYSCALL_TRACEPOINT | _TIF_GRSEC_SETXID)
6799
6800 /* work to do on interrupt/exception return */
6801 #define _TIF_WORK_MASK \
6802 @@ -153,7 +158,7 @@ static inline struct thread_info *current_thread_info(void)
6803 /* work to do on any return to u-space */
6804 #define _TIF_ALLWORK_MASK (_TIF_NOHZ | _TIF_WORK_MASK | \
6805 _TIF_WORK_SYSCALL_EXIT | \
6806 - _TIF_SYSCALL_TRACEPOINT)
6807 + _TIF_SYSCALL_TRACEPOINT | _TIF_GRSEC_SETXID)
6808
6809 /*
6810 * We stash processor id into a COP0 register to retrieve it fast
6811 diff --git a/arch/mips/include/asm/uaccess.h b/arch/mips/include/asm/uaccess.h
6812 index a109510..94ee3f6 100644
6813 --- a/arch/mips/include/asm/uaccess.h
6814 +++ b/arch/mips/include/asm/uaccess.h
6815 @@ -130,6 +130,7 @@ extern u64 __ua_limit;
6816 __ok == 0; \
6817 })
6818
6819 +#define access_ok_noprefault(type, addr, size) access_ok((type), (addr), (size))
6820 #define access_ok(type, addr, size) \
6821 likely(__access_ok((addr), (size), __access_mask))
6822
6823 diff --git a/arch/mips/kernel/binfmt_elfn32.c b/arch/mips/kernel/binfmt_elfn32.c
6824 index 1188e00..41cf144 100644
6825 --- a/arch/mips/kernel/binfmt_elfn32.c
6826 +++ b/arch/mips/kernel/binfmt_elfn32.c
6827 @@ -50,6 +50,13 @@ typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
6828 #undef ELF_ET_DYN_BASE
6829 #define ELF_ET_DYN_BASE (TASK32_SIZE / 3 * 2)
6830
6831 +#ifdef CONFIG_PAX_ASLR
6832 +#define PAX_ELF_ET_DYN_BASE (TASK_IS_32BIT_ADDR ? 0x00400000UL : 0x00400000UL)
6833 +
6834 +#define PAX_DELTA_MMAP_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
6835 +#define PAX_DELTA_STACK_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
6836 +#endif
6837 +
6838 #include <asm/processor.h>
6839 #include <linux/module.h>
6840 #include <linux/elfcore.h>
6841 diff --git a/arch/mips/kernel/binfmt_elfo32.c b/arch/mips/kernel/binfmt_elfo32.c
6842 index 7faf5f2..f3d3cf4 100644
6843 --- a/arch/mips/kernel/binfmt_elfo32.c
6844 +++ b/arch/mips/kernel/binfmt_elfo32.c
6845 @@ -70,6 +70,13 @@ typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
6846 #undef ELF_ET_DYN_BASE
6847 #define ELF_ET_DYN_BASE (TASK32_SIZE / 3 * 2)
6848
6849 +#ifdef CONFIG_PAX_ASLR
6850 +#define PAX_ELF_ET_DYN_BASE (TASK_IS_32BIT_ADDR ? 0x00400000UL : 0x00400000UL)
6851 +
6852 +#define PAX_DELTA_MMAP_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
6853 +#define PAX_DELTA_STACK_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
6854 +#endif
6855 +
6856 #include <asm/processor.h>
6857
6858 /*
6859 diff --git a/arch/mips/kernel/i8259.c b/arch/mips/kernel/i8259.c
6860 index 2b91fe8..fe4f6b4 100644
6861 --- a/arch/mips/kernel/i8259.c
6862 +++ b/arch/mips/kernel/i8259.c
6863 @@ -205,7 +205,7 @@ spurious_8259A_irq:
6864 printk(KERN_DEBUG "spurious 8259A interrupt: IRQ%d.\n", irq);
6865 spurious_irq_mask |= irqmask;
6866 }
6867 - atomic_inc(&irq_err_count);
6868 + atomic_inc_unchecked(&irq_err_count);
6869 /*
6870 * Theoretically we do not have to handle this IRQ,
6871 * but in Linux this does not cause problems and is
6872 diff --git a/arch/mips/kernel/irq-gt641xx.c b/arch/mips/kernel/irq-gt641xx.c
6873 index 44a1f79..2bd6aa3 100644
6874 --- a/arch/mips/kernel/irq-gt641xx.c
6875 +++ b/arch/mips/kernel/irq-gt641xx.c
6876 @@ -110,7 +110,7 @@ void gt641xx_irq_dispatch(void)
6877 }
6878 }
6879
6880 - atomic_inc(&irq_err_count);
6881 + atomic_inc_unchecked(&irq_err_count);
6882 }
6883
6884 void __init gt641xx_irq_init(void)
6885 diff --git a/arch/mips/kernel/irq.c b/arch/mips/kernel/irq.c
6886 index d1fea7a..2e591b0 100644
6887 --- a/arch/mips/kernel/irq.c
6888 +++ b/arch/mips/kernel/irq.c
6889 @@ -77,17 +77,17 @@ void ack_bad_irq(unsigned int irq)
6890 printk("unexpected IRQ # %d\n", irq);
6891 }
6892
6893 -atomic_t irq_err_count;
6894 +atomic_unchecked_t irq_err_count;
6895
6896 int arch_show_interrupts(struct seq_file *p, int prec)
6897 {
6898 - seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read(&irq_err_count));
6899 + seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read_unchecked(&irq_err_count));
6900 return 0;
6901 }
6902
6903 asmlinkage void spurious_interrupt(void)
6904 {
6905 - atomic_inc(&irq_err_count);
6906 + atomic_inc_unchecked(&irq_err_count);
6907 }
6908
6909 void __init init_IRQ(void)
6910 @@ -110,7 +110,10 @@ void __init init_IRQ(void)
6911 #endif
6912 }
6913
6914 +
6915 #ifdef DEBUG_STACKOVERFLOW
6916 +extern void gr_handle_kernel_exploit(void);
6917 +
6918 static inline void check_stack_overflow(void)
6919 {
6920 unsigned long sp;
6921 @@ -126,6 +129,7 @@ static inline void check_stack_overflow(void)
6922 printk("do_IRQ: stack overflow: %ld\n",
6923 sp - sizeof(struct thread_info));
6924 dump_stack();
6925 + gr_handle_kernel_exploit();
6926 }
6927 }
6928 #else
6929 diff --git a/arch/mips/kernel/process.c b/arch/mips/kernel/process.c
6930 index 60e39dc..b4829bf 100644
6931 --- a/arch/mips/kernel/process.c
6932 +++ b/arch/mips/kernel/process.c
6933 @@ -579,15 +579,3 @@ unsigned long get_wchan(struct task_struct *task)
6934 out:
6935 return pc;
6936 }
6937 -
6938 -/*
6939 - * Don't forget that the stack pointer must be aligned on a 8 bytes
6940 - * boundary for 32-bits ABI and 16 bytes for 64-bits ABI.
6941 - */
6942 -unsigned long arch_align_stack(unsigned long sp)
6943 -{
6944 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
6945 - sp -= get_random_int() & ~PAGE_MASK;
6946 -
6947 - return sp & ALMASK;
6948 -}
6949 diff --git a/arch/mips/kernel/ptrace.c b/arch/mips/kernel/ptrace.c
6950 index f639ccd..e4b110d 100644
6951 --- a/arch/mips/kernel/ptrace.c
6952 +++ b/arch/mips/kernel/ptrace.c
6953 @@ -630,6 +630,10 @@ long arch_ptrace(struct task_struct *child, long request,
6954 return ret;
6955 }
6956
6957 +#ifdef CONFIG_GRKERNSEC_SETXID
6958 +extern void gr_delayed_cred_worker(void);
6959 +#endif
6960 +
6961 /*
6962 * Notification of system call entry/exit
6963 * - triggered by current->work.syscall_trace
6964 @@ -646,6 +650,11 @@ asmlinkage long syscall_trace_enter(struct pt_regs *regs, long syscall)
6965 tracehook_report_syscall_entry(regs))
6966 ret = -1;
6967
6968 +#ifdef CONFIG_GRKERNSEC_SETXID
6969 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
6970 + gr_delayed_cred_worker();
6971 +#endif
6972 +
6973 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
6974 trace_sys_enter(regs, regs->regs[2]);
6975
6976 diff --git a/arch/mips/kernel/reset.c b/arch/mips/kernel/reset.c
6977 index 07fc524..b9d7f28 100644
6978 --- a/arch/mips/kernel/reset.c
6979 +++ b/arch/mips/kernel/reset.c
6980 @@ -13,6 +13,7 @@
6981 #include <linux/reboot.h>
6982
6983 #include <asm/reboot.h>
6984 +#include <asm/bug.h>
6985
6986 /*
6987 * Urgs ... Too many MIPS machines to handle this in a generic way.
6988 @@ -29,16 +30,19 @@ void machine_restart(char *command)
6989 {
6990 if (_machine_restart)
6991 _machine_restart(command);
6992 + BUG();
6993 }
6994
6995 void machine_halt(void)
6996 {
6997 if (_machine_halt)
6998 _machine_halt();
6999 + BUG();
7000 }
7001
7002 void machine_power_off(void)
7003 {
7004 if (pm_power_off)
7005 pm_power_off();
7006 + BUG();
7007 }
7008 diff --git a/arch/mips/kernel/smtc-proc.c b/arch/mips/kernel/smtc-proc.c
7009 index 38635a9..3fcd5e0 100644
7010 --- a/arch/mips/kernel/smtc-proc.c
7011 +++ b/arch/mips/kernel/smtc-proc.c
7012 @@ -31,7 +31,7 @@ unsigned long selfipis[NR_CPUS];
7013
7014 struct smtc_cpu_proc smtc_cpu_stats[NR_CPUS];
7015
7016 -atomic_t smtc_fpu_recoveries;
7017 +atomic_unchecked_t smtc_fpu_recoveries;
7018
7019 static int smtc_proc_show(struct seq_file *m, void *v)
7020 {
7021 @@ -48,7 +48,7 @@ static int smtc_proc_show(struct seq_file *m, void *v)
7022 for(i = 0; i < NR_CPUS; i++)
7023 seq_printf(m, "%d: %ld\n", i, smtc_cpu_stats[i].selfipis);
7024 seq_printf(m, "%d Recoveries of \"stolen\" FPU\n",
7025 - atomic_read(&smtc_fpu_recoveries));
7026 + atomic_read_unchecked(&smtc_fpu_recoveries));
7027 return 0;
7028 }
7029
7030 @@ -73,7 +73,7 @@ void init_smtc_stats(void)
7031 smtc_cpu_stats[i].selfipis = 0;
7032 }
7033
7034 - atomic_set(&smtc_fpu_recoveries, 0);
7035 + atomic_set_unchecked(&smtc_fpu_recoveries, 0);
7036
7037 proc_create("smtc", 0444, NULL, &smtc_proc_fops);
7038 }
7039 diff --git a/arch/mips/kernel/smtc.c b/arch/mips/kernel/smtc.c
7040 index c1681d6..9f881d1 100644
7041 --- a/arch/mips/kernel/smtc.c
7042 +++ b/arch/mips/kernel/smtc.c
7043 @@ -1359,7 +1359,7 @@ void smtc_soft_dump(void)
7044 }
7045 smtc_ipi_qdump();
7046 printk("%d Recoveries of \"stolen\" FPU\n",
7047 - atomic_read(&smtc_fpu_recoveries));
7048 + atomic_read_unchecked(&smtc_fpu_recoveries));
7049 }
7050
7051
7052 diff --git a/arch/mips/kernel/sync-r4k.c b/arch/mips/kernel/sync-r4k.c
7053 index c24ad5f..9983ab2 100644
7054 --- a/arch/mips/kernel/sync-r4k.c
7055 +++ b/arch/mips/kernel/sync-r4k.c
7056 @@ -20,8 +20,8 @@
7057 #include <asm/mipsregs.h>
7058
7059 static atomic_t count_start_flag = ATOMIC_INIT(0);
7060 -static atomic_t count_count_start = ATOMIC_INIT(0);
7061 -static atomic_t count_count_stop = ATOMIC_INIT(0);
7062 +static atomic_unchecked_t count_count_start = ATOMIC_INIT(0);
7063 +static atomic_unchecked_t count_count_stop = ATOMIC_INIT(0);
7064 static atomic_t count_reference = ATOMIC_INIT(0);
7065
7066 #define COUNTON 100
7067 @@ -68,13 +68,13 @@ void synchronise_count_master(int cpu)
7068
7069 for (i = 0; i < NR_LOOPS; i++) {
7070 /* slaves loop on '!= 2' */
7071 - while (atomic_read(&count_count_start) != 1)
7072 + while (atomic_read_unchecked(&count_count_start) != 1)
7073 mb();
7074 - atomic_set(&count_count_stop, 0);
7075 + atomic_set_unchecked(&count_count_stop, 0);
7076 smp_wmb();
7077
7078 /* this lets the slaves write their count register */
7079 - atomic_inc(&count_count_start);
7080 + atomic_inc_unchecked(&count_count_start);
7081
7082 /*
7083 * Everyone initialises count in the last loop:
7084 @@ -85,11 +85,11 @@ void synchronise_count_master(int cpu)
7085 /*
7086 * Wait for all slaves to leave the synchronization point:
7087 */
7088 - while (atomic_read(&count_count_stop) != 1)
7089 + while (atomic_read_unchecked(&count_count_stop) != 1)
7090 mb();
7091 - atomic_set(&count_count_start, 0);
7092 + atomic_set_unchecked(&count_count_start, 0);
7093 smp_wmb();
7094 - atomic_inc(&count_count_stop);
7095 + atomic_inc_unchecked(&count_count_stop);
7096 }
7097 /* Arrange for an interrupt in a short while */
7098 write_c0_compare(read_c0_count() + COUNTON);
7099 @@ -130,8 +130,8 @@ void synchronise_count_slave(int cpu)
7100 initcount = atomic_read(&count_reference);
7101
7102 for (i = 0; i < NR_LOOPS; i++) {
7103 - atomic_inc(&count_count_start);
7104 - while (atomic_read(&count_count_start) != 2)
7105 + atomic_inc_unchecked(&count_count_start);
7106 + while (atomic_read_unchecked(&count_count_start) != 2)
7107 mb();
7108
7109 /*
7110 @@ -140,8 +140,8 @@ void synchronise_count_slave(int cpu)
7111 if (i == NR_LOOPS-1)
7112 write_c0_count(initcount);
7113
7114 - atomic_inc(&count_count_stop);
7115 - while (atomic_read(&count_count_stop) != 2)
7116 + atomic_inc_unchecked(&count_count_stop);
7117 + while (atomic_read_unchecked(&count_count_stop) != 2)
7118 mb();
7119 }
7120 /* Arrange for an interrupt in a short while */
7121 diff --git a/arch/mips/kernel/traps.c b/arch/mips/kernel/traps.c
7122 index 8119ac2..b229939 100644
7123 --- a/arch/mips/kernel/traps.c
7124 +++ b/arch/mips/kernel/traps.c
7125 @@ -695,7 +695,18 @@ asmlinkage void do_ov(struct pt_regs *regs)
7126 siginfo_t info;
7127
7128 prev_state = exception_enter();
7129 - die_if_kernel("Integer overflow", regs);
7130 + if (unlikely(!user_mode(regs))) {
7131 +
7132 +#ifdef CONFIG_PAX_REFCOUNT
7133 + if (fixup_exception(regs)) {
7134 + pax_report_refcount_overflow(regs);
7135 + exception_exit(prev_state);
7136 + return;
7137 + }
7138 +#endif
7139 +
7140 + die("Integer overflow", regs);
7141 + }
7142
7143 info.si_code = FPE_INTOVF;
7144 info.si_signo = SIGFPE;
7145 diff --git a/arch/mips/mm/fault.c b/arch/mips/mm/fault.c
7146 index becc42b..9e43d4b 100644
7147 --- a/arch/mips/mm/fault.c
7148 +++ b/arch/mips/mm/fault.c
7149 @@ -28,6 +28,23 @@
7150 #include <asm/highmem.h> /* For VMALLOC_END */
7151 #include <linux/kdebug.h>
7152
7153 +#ifdef CONFIG_PAX_PAGEEXEC
7154 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
7155 +{
7156 + unsigned long i;
7157 +
7158 + printk(KERN_ERR "PAX: bytes at PC: ");
7159 + for (i = 0; i < 5; i++) {
7160 + unsigned int c;
7161 + if (get_user(c, (unsigned int *)pc+i))
7162 + printk(KERN_CONT "???????? ");
7163 + else
7164 + printk(KERN_CONT "%08x ", c);
7165 + }
7166 + printk("\n");
7167 +}
7168 +#endif
7169 +
7170 /*
7171 * This routine handles page faults. It determines the address,
7172 * and the problem, and then passes it off to one of the appropriate
7173 @@ -199,6 +216,14 @@ bad_area:
7174 bad_area_nosemaphore:
7175 /* User mode accesses just cause a SIGSEGV */
7176 if (user_mode(regs)) {
7177 +
7178 +#ifdef CONFIG_PAX_PAGEEXEC
7179 + if (cpu_has_rixi && (mm->pax_flags & MF_PAX_PAGEEXEC) && !write && address == instruction_pointer(regs)) {
7180 + pax_report_fault(regs, (void *)address, (void *)user_stack_pointer(regs));
7181 + do_group_exit(SIGKILL);
7182 + }
7183 +#endif
7184 +
7185 tsk->thread.cp0_badvaddr = address;
7186 tsk->thread.error_code = write;
7187 #if 0
7188 diff --git a/arch/mips/mm/mmap.c b/arch/mips/mm/mmap.c
7189 index f1baadd..5472dca 100644
7190 --- a/arch/mips/mm/mmap.c
7191 +++ b/arch/mips/mm/mmap.c
7192 @@ -59,6 +59,7 @@ static unsigned long arch_get_unmapped_area_common(struct file *filp,
7193 struct vm_area_struct *vma;
7194 unsigned long addr = addr0;
7195 int do_color_align;
7196 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
7197 struct vm_unmapped_area_info info;
7198
7199 if (unlikely(len > TASK_SIZE))
7200 @@ -84,6 +85,11 @@ static unsigned long arch_get_unmapped_area_common(struct file *filp,
7201 do_color_align = 1;
7202
7203 /* requesting a specific address */
7204 +
7205 +#ifdef CONFIG_PAX_RANDMMAP
7206 + if (!(current->mm->pax_flags & MF_PAX_RANDMMAP))
7207 +#endif
7208 +
7209 if (addr) {
7210 if (do_color_align)
7211 addr = COLOUR_ALIGN(addr, pgoff);
7212 @@ -91,14 +97,14 @@ static unsigned long arch_get_unmapped_area_common(struct file *filp,
7213 addr = PAGE_ALIGN(addr);
7214
7215 vma = find_vma(mm, addr);
7216 - if (TASK_SIZE - len >= addr &&
7217 - (!vma || addr + len <= vma->vm_start))
7218 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
7219 return addr;
7220 }
7221
7222 info.length = len;
7223 info.align_mask = do_color_align ? (PAGE_MASK & shm_align_mask) : 0;
7224 info.align_offset = pgoff << PAGE_SHIFT;
7225 + info.threadstack_offset = offset;
7226
7227 if (dir == DOWN) {
7228 info.flags = VM_UNMAPPED_AREA_TOPDOWN;
7229 @@ -146,6 +152,10 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
7230 {
7231 unsigned long random_factor = 0UL;
7232
7233 +#ifdef CONFIG_PAX_RANDMMAP
7234 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
7235 +#endif
7236 +
7237 if (current->flags & PF_RANDOMIZE) {
7238 random_factor = get_random_int();
7239 random_factor = random_factor << PAGE_SHIFT;
7240 @@ -157,40 +167,25 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
7241
7242 if (mmap_is_legacy()) {
7243 mm->mmap_base = TASK_UNMAPPED_BASE + random_factor;
7244 +
7245 +#ifdef CONFIG_PAX_RANDMMAP
7246 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7247 + mm->mmap_base += mm->delta_mmap;
7248 +#endif
7249 +
7250 mm->get_unmapped_area = arch_get_unmapped_area;
7251 } else {
7252 mm->mmap_base = mmap_base(random_factor);
7253 +
7254 +#ifdef CONFIG_PAX_RANDMMAP
7255 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7256 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
7257 +#endif
7258 +
7259 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
7260 }
7261 }
7262
7263 -static inline unsigned long brk_rnd(void)
7264 -{
7265 - unsigned long rnd = get_random_int();
7266 -
7267 - rnd = rnd << PAGE_SHIFT;
7268 - /* 8MB for 32bit, 256MB for 64bit */
7269 - if (TASK_IS_32BIT_ADDR)
7270 - rnd = rnd & 0x7ffffful;
7271 - else
7272 - rnd = rnd & 0xffffffful;
7273 -
7274 - return rnd;
7275 -}
7276 -
7277 -unsigned long arch_randomize_brk(struct mm_struct *mm)
7278 -{
7279 - unsigned long base = mm->brk;
7280 - unsigned long ret;
7281 -
7282 - ret = PAGE_ALIGN(base + brk_rnd());
7283 -
7284 - if (ret < mm->brk)
7285 - return mm->brk;
7286 -
7287 - return ret;
7288 -}
7289 -
7290 int __virt_addr_valid(const volatile void *kaddr)
7291 {
7292 return pfn_valid(PFN_DOWN(virt_to_phys(kaddr)));
7293 diff --git a/arch/mips/pci/pci-octeon.c b/arch/mips/pci/pci-octeon.c
7294 index 59cccd9..f39ac2f 100644
7295 --- a/arch/mips/pci/pci-octeon.c
7296 +++ b/arch/mips/pci/pci-octeon.c
7297 @@ -327,8 +327,8 @@ static int octeon_write_config(struct pci_bus *bus, unsigned int devfn,
7298
7299
7300 static struct pci_ops octeon_pci_ops = {
7301 - octeon_read_config,
7302 - octeon_write_config,
7303 + .read = octeon_read_config,
7304 + .write = octeon_write_config,
7305 };
7306
7307 static struct resource octeon_pci_mem_resource = {
7308 diff --git a/arch/mips/pci/pcie-octeon.c b/arch/mips/pci/pcie-octeon.c
7309 index 5e36c33..eb4a17b 100644
7310 --- a/arch/mips/pci/pcie-octeon.c
7311 +++ b/arch/mips/pci/pcie-octeon.c
7312 @@ -1792,8 +1792,8 @@ static int octeon_dummy_write_config(struct pci_bus *bus, unsigned int devfn,
7313 }
7314
7315 static struct pci_ops octeon_pcie0_ops = {
7316 - octeon_pcie0_read_config,
7317 - octeon_pcie0_write_config,
7318 + .read = octeon_pcie0_read_config,
7319 + .write = octeon_pcie0_write_config,
7320 };
7321
7322 static struct resource octeon_pcie0_mem_resource = {
7323 @@ -1813,8 +1813,8 @@ static struct pci_controller octeon_pcie0_controller = {
7324 };
7325
7326 static struct pci_ops octeon_pcie1_ops = {
7327 - octeon_pcie1_read_config,
7328 - octeon_pcie1_write_config,
7329 + .read = octeon_pcie1_read_config,
7330 + .write = octeon_pcie1_write_config,
7331 };
7332
7333 static struct resource octeon_pcie1_mem_resource = {
7334 @@ -1834,8 +1834,8 @@ static struct pci_controller octeon_pcie1_controller = {
7335 };
7336
7337 static struct pci_ops octeon_dummy_ops = {
7338 - octeon_dummy_read_config,
7339 - octeon_dummy_write_config,
7340 + .read = octeon_dummy_read_config,
7341 + .write = octeon_dummy_write_config,
7342 };
7343
7344 static struct resource octeon_dummy_mem_resource = {
7345 diff --git a/arch/mips/sgi-ip27/ip27-nmi.c b/arch/mips/sgi-ip27/ip27-nmi.c
7346 index a2358b4..7cead4f 100644
7347 --- a/arch/mips/sgi-ip27/ip27-nmi.c
7348 +++ b/arch/mips/sgi-ip27/ip27-nmi.c
7349 @@ -187,9 +187,9 @@ void
7350 cont_nmi_dump(void)
7351 {
7352 #ifndef REAL_NMI_SIGNAL
7353 - static atomic_t nmied_cpus = ATOMIC_INIT(0);
7354 + static atomic_unchecked_t nmied_cpus = ATOMIC_INIT(0);
7355
7356 - atomic_inc(&nmied_cpus);
7357 + atomic_inc_unchecked(&nmied_cpus);
7358 #endif
7359 /*
7360 * Only allow 1 cpu to proceed
7361 @@ -233,7 +233,7 @@ cont_nmi_dump(void)
7362 udelay(10000);
7363 }
7364 #else
7365 - while (atomic_read(&nmied_cpus) != num_online_cpus());
7366 + while (atomic_read_unchecked(&nmied_cpus) != num_online_cpus());
7367 #endif
7368
7369 /*
7370 diff --git a/arch/mips/sni/rm200.c b/arch/mips/sni/rm200.c
7371 index a046b30..6799527 100644
7372 --- a/arch/mips/sni/rm200.c
7373 +++ b/arch/mips/sni/rm200.c
7374 @@ -270,7 +270,7 @@ spurious_8259A_irq:
7375 "spurious RM200 8259A interrupt: IRQ%d.\n", irq);
7376 spurious_irq_mask |= irqmask;
7377 }
7378 - atomic_inc(&irq_err_count);
7379 + atomic_inc_unchecked(&irq_err_count);
7380 /*
7381 * Theoretically we do not have to handle this IRQ,
7382 * but in Linux this does not cause problems and is
7383 diff --git a/arch/mips/vr41xx/common/icu.c b/arch/mips/vr41xx/common/icu.c
7384 index 41e873b..34d33a7 100644
7385 --- a/arch/mips/vr41xx/common/icu.c
7386 +++ b/arch/mips/vr41xx/common/icu.c
7387 @@ -653,7 +653,7 @@ static int icu_get_irq(unsigned int irq)
7388
7389 printk(KERN_ERR "spurious ICU interrupt: %04x,%04x\n", pend1, pend2);
7390
7391 - atomic_inc(&irq_err_count);
7392 + atomic_inc_unchecked(&irq_err_count);
7393
7394 return -1;
7395 }
7396 diff --git a/arch/mips/vr41xx/common/irq.c b/arch/mips/vr41xx/common/irq.c
7397 index ae0e4ee..e8f0692 100644
7398 --- a/arch/mips/vr41xx/common/irq.c
7399 +++ b/arch/mips/vr41xx/common/irq.c
7400 @@ -64,7 +64,7 @@ static void irq_dispatch(unsigned int irq)
7401 irq_cascade_t *cascade;
7402
7403 if (irq >= NR_IRQS) {
7404 - atomic_inc(&irq_err_count);
7405 + atomic_inc_unchecked(&irq_err_count);
7406 return;
7407 }
7408
7409 @@ -84,7 +84,7 @@ static void irq_dispatch(unsigned int irq)
7410 ret = cascade->get_irq(irq);
7411 irq = ret;
7412 if (ret < 0)
7413 - atomic_inc(&irq_err_count);
7414 + atomic_inc_unchecked(&irq_err_count);
7415 else
7416 irq_dispatch(irq);
7417 if (!irqd_irq_disabled(idata) && chip->irq_unmask)
7418 diff --git a/arch/mn10300/proc-mn103e010/include/proc/cache.h b/arch/mn10300/proc-mn103e010/include/proc/cache.h
7419 index 967d144..db12197 100644
7420 --- a/arch/mn10300/proc-mn103e010/include/proc/cache.h
7421 +++ b/arch/mn10300/proc-mn103e010/include/proc/cache.h
7422 @@ -11,12 +11,14 @@
7423 #ifndef _ASM_PROC_CACHE_H
7424 #define _ASM_PROC_CACHE_H
7425
7426 +#include <linux/const.h>
7427 +
7428 /* L1 cache */
7429
7430 #define L1_CACHE_NWAYS 4 /* number of ways in caches */
7431 #define L1_CACHE_NENTRIES 256 /* number of entries in each way */
7432 -#define L1_CACHE_BYTES 16 /* bytes per entry */
7433 #define L1_CACHE_SHIFT 4 /* shift for bytes per entry */
7434 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT) /* bytes per entry */
7435 #define L1_CACHE_WAYDISP 0x1000 /* displacement of one way from the next */
7436
7437 #define L1_CACHE_TAG_VALID 0x00000001 /* cache tag valid bit */
7438 diff --git a/arch/mn10300/proc-mn2ws0050/include/proc/cache.h b/arch/mn10300/proc-mn2ws0050/include/proc/cache.h
7439 index bcb5df2..84fabd2 100644
7440 --- a/arch/mn10300/proc-mn2ws0050/include/proc/cache.h
7441 +++ b/arch/mn10300/proc-mn2ws0050/include/proc/cache.h
7442 @@ -16,13 +16,15 @@
7443 #ifndef _ASM_PROC_CACHE_H
7444 #define _ASM_PROC_CACHE_H
7445
7446 +#include <linux/const.h>
7447 +
7448 /*
7449 * L1 cache
7450 */
7451 #define L1_CACHE_NWAYS 4 /* number of ways in caches */
7452 #define L1_CACHE_NENTRIES 128 /* number of entries in each way */
7453 -#define L1_CACHE_BYTES 32 /* bytes per entry */
7454 #define L1_CACHE_SHIFT 5 /* shift for bytes per entry */
7455 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT) /* bytes per entry */
7456 #define L1_CACHE_WAYDISP 0x1000 /* distance from one way to the next */
7457
7458 #define L1_CACHE_TAG_VALID 0x00000001 /* cache tag valid bit */
7459 diff --git a/arch/openrisc/include/asm/cache.h b/arch/openrisc/include/asm/cache.h
7460 index 4ce7a01..449202a 100644
7461 --- a/arch/openrisc/include/asm/cache.h
7462 +++ b/arch/openrisc/include/asm/cache.h
7463 @@ -19,11 +19,13 @@
7464 #ifndef __ASM_OPENRISC_CACHE_H
7465 #define __ASM_OPENRISC_CACHE_H
7466
7467 +#include <linux/const.h>
7468 +
7469 /* FIXME: How can we replace these with values from the CPU...
7470 * they shouldn't be hard-coded!
7471 */
7472
7473 -#define L1_CACHE_BYTES 16
7474 #define L1_CACHE_SHIFT 4
7475 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
7476
7477 #endif /* __ASM_OPENRISC_CACHE_H */
7478 diff --git a/arch/parisc/include/asm/atomic.h b/arch/parisc/include/asm/atomic.h
7479 index 472886c..00e7df9 100644
7480 --- a/arch/parisc/include/asm/atomic.h
7481 +++ b/arch/parisc/include/asm/atomic.h
7482 @@ -252,6 +252,16 @@ static inline long atomic64_dec_if_positive(atomic64_t *v)
7483 return dec;
7484 }
7485
7486 +#define atomic64_read_unchecked(v) atomic64_read(v)
7487 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
7488 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
7489 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
7490 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
7491 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
7492 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
7493 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
7494 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
7495 +
7496 #endif /* !CONFIG_64BIT */
7497
7498
7499 diff --git a/arch/parisc/include/asm/cache.h b/arch/parisc/include/asm/cache.h
7500 index 47f11c7..3420df2 100644
7501 --- a/arch/parisc/include/asm/cache.h
7502 +++ b/arch/parisc/include/asm/cache.h
7503 @@ -5,6 +5,7 @@
7504 #ifndef __ARCH_PARISC_CACHE_H
7505 #define __ARCH_PARISC_CACHE_H
7506
7507 +#include <linux/const.h>
7508
7509 /*
7510 * PA 2.0 processors have 64-byte cachelines; PA 1.1 processors have
7511 @@ -15,13 +16,13 @@
7512 * just ruin performance.
7513 */
7514 #ifdef CONFIG_PA20
7515 -#define L1_CACHE_BYTES 64
7516 #define L1_CACHE_SHIFT 6
7517 #else
7518 -#define L1_CACHE_BYTES 32
7519 #define L1_CACHE_SHIFT 5
7520 #endif
7521
7522 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
7523 +
7524 #ifndef __ASSEMBLY__
7525
7526 #define SMP_CACHE_BYTES L1_CACHE_BYTES
7527 diff --git a/arch/parisc/include/asm/elf.h b/arch/parisc/include/asm/elf.h
7528 index 3391d06..c23a2cc 100644
7529 --- a/arch/parisc/include/asm/elf.h
7530 +++ b/arch/parisc/include/asm/elf.h
7531 @@ -342,6 +342,13 @@ struct pt_regs; /* forward declaration... */
7532
7533 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE + 0x01000000)
7534
7535 +#ifdef CONFIG_PAX_ASLR
7536 +#define PAX_ELF_ET_DYN_BASE 0x10000UL
7537 +
7538 +#define PAX_DELTA_MMAP_LEN 16
7539 +#define PAX_DELTA_STACK_LEN 16
7540 +#endif
7541 +
7542 /* This yields a mask that user programs can use to figure out what
7543 instruction set this CPU supports. This could be done in user space,
7544 but it's not easy, and we've already done it here. */
7545 diff --git a/arch/parisc/include/asm/pgalloc.h b/arch/parisc/include/asm/pgalloc.h
7546 index f213f5b..0af3e8e 100644
7547 --- a/arch/parisc/include/asm/pgalloc.h
7548 +++ b/arch/parisc/include/asm/pgalloc.h
7549 @@ -61,6 +61,11 @@ static inline void pgd_populate(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
7550 (__u32)(__pa((unsigned long)pmd) >> PxD_VALUE_SHIFT));
7551 }
7552
7553 +static inline void pgd_populate_kernel(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
7554 +{
7555 + pgd_populate(mm, pgd, pmd);
7556 +}
7557 +
7558 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long address)
7559 {
7560 pmd_t *pmd = (pmd_t *)__get_free_pages(GFP_KERNEL|__GFP_REPEAT,
7561 @@ -93,6 +98,7 @@ static inline void pmd_free(struct mm_struct *mm, pmd_t *pmd)
7562 #define pmd_alloc_one(mm, addr) ({ BUG(); ((pmd_t *)2); })
7563 #define pmd_free(mm, x) do { } while (0)
7564 #define pgd_populate(mm, pmd, pte) BUG()
7565 +#define pgd_populate_kernel(mm, pmd, pte) BUG()
7566
7567 #endif
7568
7569 diff --git a/arch/parisc/include/asm/pgtable.h b/arch/parisc/include/asm/pgtable.h
7570 index 22b89d1..ce34230 100644
7571 --- a/arch/parisc/include/asm/pgtable.h
7572 +++ b/arch/parisc/include/asm/pgtable.h
7573 @@ -223,6 +223,17 @@ extern void purge_tlb_entries(struct mm_struct *, unsigned long);
7574 #define PAGE_EXECREAD __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_EXEC |_PAGE_ACCESSED)
7575 #define PAGE_COPY PAGE_EXECREAD
7576 #define PAGE_RWX __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_WRITE | _PAGE_EXEC |_PAGE_ACCESSED)
7577 +
7578 +#ifdef CONFIG_PAX_PAGEEXEC
7579 +# define PAGE_SHARED_NOEXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_WRITE | _PAGE_ACCESSED)
7580 +# define PAGE_COPY_NOEXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_ACCESSED)
7581 +# define PAGE_READONLY_NOEXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_ACCESSED)
7582 +#else
7583 +# define PAGE_SHARED_NOEXEC PAGE_SHARED
7584 +# define PAGE_COPY_NOEXEC PAGE_COPY
7585 +# define PAGE_READONLY_NOEXEC PAGE_READONLY
7586 +#endif
7587 +
7588 #define PAGE_KERNEL __pgprot(_PAGE_KERNEL)
7589 #define PAGE_KERNEL_EXEC __pgprot(_PAGE_KERNEL_EXEC)
7590 #define PAGE_KERNEL_RWX __pgprot(_PAGE_KERNEL_RWX)
7591 diff --git a/arch/parisc/include/asm/uaccess.h b/arch/parisc/include/asm/uaccess.h
7592 index 4006964..fcb3cc2 100644
7593 --- a/arch/parisc/include/asm/uaccess.h
7594 +++ b/arch/parisc/include/asm/uaccess.h
7595 @@ -246,10 +246,10 @@ static inline unsigned long __must_check copy_from_user(void *to,
7596 const void __user *from,
7597 unsigned long n)
7598 {
7599 - int sz = __compiletime_object_size(to);
7600 + size_t sz = __compiletime_object_size(to);
7601 int ret = -EFAULT;
7602
7603 - if (likely(sz == -1 || !__builtin_constant_p(n) || sz >= n))
7604 + if (likely(sz == (size_t)-1 || !__builtin_constant_p(n) || sz >= n))
7605 ret = __copy_from_user(to, from, n);
7606 else
7607 copy_from_user_overflow();
7608 diff --git a/arch/parisc/kernel/module.c b/arch/parisc/kernel/module.c
7609 index 50dfafc..b9fc230 100644
7610 --- a/arch/parisc/kernel/module.c
7611 +++ b/arch/parisc/kernel/module.c
7612 @@ -98,16 +98,38 @@
7613
7614 /* three functions to determine where in the module core
7615 * or init pieces the location is */
7616 +static inline int in_init_rx(struct module *me, void *loc)
7617 +{
7618 + return (loc >= me->module_init_rx &&
7619 + loc < (me->module_init_rx + me->init_size_rx));
7620 +}
7621 +
7622 +static inline int in_init_rw(struct module *me, void *loc)
7623 +{
7624 + return (loc >= me->module_init_rw &&
7625 + loc < (me->module_init_rw + me->init_size_rw));
7626 +}
7627 +
7628 static inline int in_init(struct module *me, void *loc)
7629 {
7630 - return (loc >= me->module_init &&
7631 - loc <= (me->module_init + me->init_size));
7632 + return in_init_rx(me, loc) || in_init_rw(me, loc);
7633 +}
7634 +
7635 +static inline int in_core_rx(struct module *me, void *loc)
7636 +{
7637 + return (loc >= me->module_core_rx &&
7638 + loc < (me->module_core_rx + me->core_size_rx));
7639 +}
7640 +
7641 +static inline int in_core_rw(struct module *me, void *loc)
7642 +{
7643 + return (loc >= me->module_core_rw &&
7644 + loc < (me->module_core_rw + me->core_size_rw));
7645 }
7646
7647 static inline int in_core(struct module *me, void *loc)
7648 {
7649 - return (loc >= me->module_core &&
7650 - loc <= (me->module_core + me->core_size));
7651 + return in_core_rx(me, loc) || in_core_rw(me, loc);
7652 }
7653
7654 static inline int in_local(struct module *me, void *loc)
7655 @@ -371,13 +393,13 @@ int module_frob_arch_sections(CONST Elf_Ehdr *hdr,
7656 }
7657
7658 /* align things a bit */
7659 - me->core_size = ALIGN(me->core_size, 16);
7660 - me->arch.got_offset = me->core_size;
7661 - me->core_size += gots * sizeof(struct got_entry);
7662 + me->core_size_rw = ALIGN(me->core_size_rw, 16);
7663 + me->arch.got_offset = me->core_size_rw;
7664 + me->core_size_rw += gots * sizeof(struct got_entry);
7665
7666 - me->core_size = ALIGN(me->core_size, 16);
7667 - me->arch.fdesc_offset = me->core_size;
7668 - me->core_size += fdescs * sizeof(Elf_Fdesc);
7669 + me->core_size_rw = ALIGN(me->core_size_rw, 16);
7670 + me->arch.fdesc_offset = me->core_size_rw;
7671 + me->core_size_rw += fdescs * sizeof(Elf_Fdesc);
7672
7673 me->arch.got_max = gots;
7674 me->arch.fdesc_max = fdescs;
7675 @@ -395,7 +417,7 @@ static Elf64_Word get_got(struct module *me, unsigned long value, long addend)
7676
7677 BUG_ON(value == 0);
7678
7679 - got = me->module_core + me->arch.got_offset;
7680 + got = me->module_core_rw + me->arch.got_offset;
7681 for (i = 0; got[i].addr; i++)
7682 if (got[i].addr == value)
7683 goto out;
7684 @@ -413,7 +435,7 @@ static Elf64_Word get_got(struct module *me, unsigned long value, long addend)
7685 #ifdef CONFIG_64BIT
7686 static Elf_Addr get_fdesc(struct module *me, unsigned long value)
7687 {
7688 - Elf_Fdesc *fdesc = me->module_core + me->arch.fdesc_offset;
7689 + Elf_Fdesc *fdesc = me->module_core_rw + me->arch.fdesc_offset;
7690
7691 if (!value) {
7692 printk(KERN_ERR "%s: zero OPD requested!\n", me->name);
7693 @@ -431,7 +453,7 @@ static Elf_Addr get_fdesc(struct module *me, unsigned long value)
7694
7695 /* Create new one */
7696 fdesc->addr = value;
7697 - fdesc->gp = (Elf_Addr)me->module_core + me->arch.got_offset;
7698 + fdesc->gp = (Elf_Addr)me->module_core_rw + me->arch.got_offset;
7699 return (Elf_Addr)fdesc;
7700 }
7701 #endif /* CONFIG_64BIT */
7702 @@ -843,7 +865,7 @@ register_unwind_table(struct module *me,
7703
7704 table = (unsigned char *)sechdrs[me->arch.unwind_section].sh_addr;
7705 end = table + sechdrs[me->arch.unwind_section].sh_size;
7706 - gp = (Elf_Addr)me->module_core + me->arch.got_offset;
7707 + gp = (Elf_Addr)me->module_core_rw + me->arch.got_offset;
7708
7709 DEBUGP("register_unwind_table(), sect = %d at 0x%p - 0x%p (gp=0x%lx)\n",
7710 me->arch.unwind_section, table, end, gp);
7711 diff --git a/arch/parisc/kernel/sys_parisc.c b/arch/parisc/kernel/sys_parisc.c
7712 index e1ffea2..46ed66e 100644
7713 --- a/arch/parisc/kernel/sys_parisc.c
7714 +++ b/arch/parisc/kernel/sys_parisc.c
7715 @@ -89,6 +89,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
7716 unsigned long task_size = TASK_SIZE;
7717 int do_color_align, last_mmap;
7718 struct vm_unmapped_area_info info;
7719 + unsigned long offset = gr_rand_threadstack_offset(current->mm, filp, flags);
7720
7721 if (len > task_size)
7722 return -ENOMEM;
7723 @@ -106,6 +107,10 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
7724 goto found_addr;
7725 }
7726
7727 +#ifdef CONFIG_PAX_RANDMMAP
7728 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
7729 +#endif
7730 +
7731 if (addr) {
7732 if (do_color_align && last_mmap)
7733 addr = COLOR_ALIGN(addr, last_mmap, pgoff);
7734 @@ -124,6 +129,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
7735 info.high_limit = mmap_upper_limit();
7736 info.align_mask = last_mmap ? (PAGE_MASK & (SHM_COLOUR - 1)) : 0;
7737 info.align_offset = shared_align_offset(last_mmap, pgoff);
7738 + info.threadstack_offset = offset;
7739 addr = vm_unmapped_area(&info);
7740
7741 found_addr:
7742 @@ -143,6 +149,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
7743 unsigned long addr = addr0;
7744 int do_color_align, last_mmap;
7745 struct vm_unmapped_area_info info;
7746 + unsigned long offset = gr_rand_threadstack_offset(current->mm, filp, flags);
7747
7748 #ifdef CONFIG_64BIT
7749 /* This should only ever run for 32-bit processes. */
7750 @@ -167,6 +174,10 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
7751 }
7752
7753 /* requesting a specific address */
7754 +#ifdef CONFIG_PAX_RANDMMAP
7755 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
7756 +#endif
7757 +
7758 if (addr) {
7759 if (do_color_align && last_mmap)
7760 addr = COLOR_ALIGN(addr, last_mmap, pgoff);
7761 @@ -184,6 +195,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
7762 info.high_limit = mm->mmap_base;
7763 info.align_mask = last_mmap ? (PAGE_MASK & (SHM_COLOUR - 1)) : 0;
7764 info.align_offset = shared_align_offset(last_mmap, pgoff);
7765 + info.threadstack_offset = offset;
7766 addr = vm_unmapped_area(&info);
7767 if (!(addr & ~PAGE_MASK))
7768 goto found_addr;
7769 @@ -249,6 +261,13 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
7770 mm->mmap_legacy_base = mmap_legacy_base();
7771 mm->mmap_base = mmap_upper_limit();
7772
7773 +#ifdef CONFIG_PAX_RANDMMAP
7774 + if (mm->pax_flags & MF_PAX_RANDMMAP) {
7775 + mm->mmap_legacy_base += mm->delta_mmap;
7776 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
7777 + }
7778 +#endif
7779 +
7780 if (mmap_is_legacy()) {
7781 mm->mmap_base = mm->mmap_legacy_base;
7782 mm->get_unmapped_area = arch_get_unmapped_area;
7783 diff --git a/arch/parisc/kernel/traps.c b/arch/parisc/kernel/traps.c
7784 index 47ee620..1107387 100644
7785 --- a/arch/parisc/kernel/traps.c
7786 +++ b/arch/parisc/kernel/traps.c
7787 @@ -726,9 +726,7 @@ void notrace handle_interruption(int code, struct pt_regs *regs)
7788
7789 down_read(&current->mm->mmap_sem);
7790 vma = find_vma(current->mm,regs->iaoq[0]);
7791 - if (vma && (regs->iaoq[0] >= vma->vm_start)
7792 - && (vma->vm_flags & VM_EXEC)) {
7793 -
7794 + if (vma && (regs->iaoq[0] >= vma->vm_start)) {
7795 fault_address = regs->iaoq[0];
7796 fault_space = regs->iasq[0];
7797
7798 diff --git a/arch/parisc/mm/fault.c b/arch/parisc/mm/fault.c
7799 index 3ca9c11..d163ef7 100644
7800 --- a/arch/parisc/mm/fault.c
7801 +++ b/arch/parisc/mm/fault.c
7802 @@ -15,6 +15,7 @@
7803 #include <linux/sched.h>
7804 #include <linux/interrupt.h>
7805 #include <linux/module.h>
7806 +#include <linux/unistd.h>
7807
7808 #include <asm/uaccess.h>
7809 #include <asm/traps.h>
7810 @@ -50,7 +51,7 @@ int show_unhandled_signals = 1;
7811 static unsigned long
7812 parisc_acctyp(unsigned long code, unsigned int inst)
7813 {
7814 - if (code == 6 || code == 16)
7815 + if (code == 6 || code == 7 || code == 16)
7816 return VM_EXEC;
7817
7818 switch (inst & 0xf0000000) {
7819 @@ -136,6 +137,116 @@ parisc_acctyp(unsigned long code, unsigned int inst)
7820 }
7821 #endif
7822
7823 +#ifdef CONFIG_PAX_PAGEEXEC
7824 +/*
7825 + * PaX: decide what to do with offenders (instruction_pointer(regs) = fault address)
7826 + *
7827 + * returns 1 when task should be killed
7828 + * 2 when rt_sigreturn trampoline was detected
7829 + * 3 when unpatched PLT trampoline was detected
7830 + */
7831 +static int pax_handle_fetch_fault(struct pt_regs *regs)
7832 +{
7833 +
7834 +#ifdef CONFIG_PAX_EMUPLT
7835 + int err;
7836 +
7837 + do { /* PaX: unpatched PLT emulation */
7838 + unsigned int bl, depwi;
7839 +
7840 + err = get_user(bl, (unsigned int *)instruction_pointer(regs));
7841 + err |= get_user(depwi, (unsigned int *)(instruction_pointer(regs)+4));
7842 +
7843 + if (err)
7844 + break;
7845 +
7846 + if (bl == 0xEA9F1FDDU && depwi == 0xD6801C1EU) {
7847 + unsigned int ldw, bv, ldw2, addr = instruction_pointer(regs)-12;
7848 +
7849 + err = get_user(ldw, (unsigned int *)addr);
7850 + err |= get_user(bv, (unsigned int *)(addr+4));
7851 + err |= get_user(ldw2, (unsigned int *)(addr+8));
7852 +
7853 + if (err)
7854 + break;
7855 +
7856 + if (ldw == 0x0E801096U &&
7857 + bv == 0xEAC0C000U &&
7858 + ldw2 == 0x0E881095U)
7859 + {
7860 + unsigned int resolver, map;
7861 +
7862 + err = get_user(resolver, (unsigned int *)(instruction_pointer(regs)+8));
7863 + err |= get_user(map, (unsigned int *)(instruction_pointer(regs)+12));
7864 + if (err)
7865 + break;
7866 +
7867 + regs->gr[20] = instruction_pointer(regs)+8;
7868 + regs->gr[21] = map;
7869 + regs->gr[22] = resolver;
7870 + regs->iaoq[0] = resolver | 3UL;
7871 + regs->iaoq[1] = regs->iaoq[0] + 4;
7872 + return 3;
7873 + }
7874 + }
7875 + } while (0);
7876 +#endif
7877 +
7878 +#ifdef CONFIG_PAX_EMUTRAMP
7879 +
7880 +#ifndef CONFIG_PAX_EMUSIGRT
7881 + if (!(current->mm->pax_flags & MF_PAX_EMUTRAMP))
7882 + return 1;
7883 +#endif
7884 +
7885 + do { /* PaX: rt_sigreturn emulation */
7886 + unsigned int ldi1, ldi2, bel, nop;
7887 +
7888 + err = get_user(ldi1, (unsigned int *)instruction_pointer(regs));
7889 + err |= get_user(ldi2, (unsigned int *)(instruction_pointer(regs)+4));
7890 + err |= get_user(bel, (unsigned int *)(instruction_pointer(regs)+8));
7891 + err |= get_user(nop, (unsigned int *)(instruction_pointer(regs)+12));
7892 +
7893 + if (err)
7894 + break;
7895 +
7896 + if ((ldi1 == 0x34190000U || ldi1 == 0x34190002U) &&
7897 + ldi2 == 0x3414015AU &&
7898 + bel == 0xE4008200U &&
7899 + nop == 0x08000240U)
7900 + {
7901 + regs->gr[25] = (ldi1 & 2) >> 1;
7902 + regs->gr[20] = __NR_rt_sigreturn;
7903 + regs->gr[31] = regs->iaoq[1] + 16;
7904 + regs->sr[0] = regs->iasq[1];
7905 + regs->iaoq[0] = 0x100UL;
7906 + regs->iaoq[1] = regs->iaoq[0] + 4;
7907 + regs->iasq[0] = regs->sr[2];
7908 + regs->iasq[1] = regs->sr[2];
7909 + return 2;
7910 + }
7911 + } while (0);
7912 +#endif
7913 +
7914 + return 1;
7915 +}
7916 +
7917 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
7918 +{
7919 + unsigned long i;
7920 +
7921 + printk(KERN_ERR "PAX: bytes at PC: ");
7922 + for (i = 0; i < 5; i++) {
7923 + unsigned int c;
7924 + if (get_user(c, (unsigned int *)pc+i))
7925 + printk(KERN_CONT "???????? ");
7926 + else
7927 + printk(KERN_CONT "%08x ", c);
7928 + }
7929 + printk("\n");
7930 +}
7931 +#endif
7932 +
7933 int fixup_exception(struct pt_regs *regs)
7934 {
7935 const struct exception_table_entry *fix;
7936 @@ -234,8 +345,33 @@ retry:
7937
7938 good_area:
7939
7940 - if ((vma->vm_flags & acc_type) != acc_type)
7941 + if ((vma->vm_flags & acc_type) != acc_type) {
7942 +
7943 +#ifdef CONFIG_PAX_PAGEEXEC
7944 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && (acc_type & VM_EXEC) &&
7945 + (address & ~3UL) == instruction_pointer(regs))
7946 + {
7947 + up_read(&mm->mmap_sem);
7948 + switch (pax_handle_fetch_fault(regs)) {
7949 +
7950 +#ifdef CONFIG_PAX_EMUPLT
7951 + case 3:
7952 + return;
7953 +#endif
7954 +
7955 +#ifdef CONFIG_PAX_EMUTRAMP
7956 + case 2:
7957 + return;
7958 +#endif
7959 +
7960 + }
7961 + pax_report_fault(regs, (void *)instruction_pointer(regs), (void *)regs->gr[30]);
7962 + do_group_exit(SIGKILL);
7963 + }
7964 +#endif
7965 +
7966 goto bad_area;
7967 + }
7968
7969 /*
7970 * If for any reason at all we couldn't handle the fault, make
7971 diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
7972 index e099899..457d6a8 100644
7973 --- a/arch/powerpc/Kconfig
7974 +++ b/arch/powerpc/Kconfig
7975 @@ -397,6 +397,7 @@ config PPC64_SUPPORTS_MEMORY_FAILURE
7976 config KEXEC
7977 bool "kexec system call"
7978 depends on (PPC_BOOK3S || FSL_BOOKE || (44x && !SMP))
7979 + depends on !GRKERNSEC_KMEM
7980 help
7981 kexec is a system call that implements the ability to shutdown your
7982 current kernel, and to start another kernel. It is like a reboot
7983 diff --git a/arch/powerpc/include/asm/atomic.h b/arch/powerpc/include/asm/atomic.h
7984 index e3b1d41..8e81edf 100644
7985 --- a/arch/powerpc/include/asm/atomic.h
7986 +++ b/arch/powerpc/include/asm/atomic.h
7987 @@ -523,6 +523,16 @@ static __inline__ long atomic64_inc_not_zero(atomic64_t *v)
7988 return t1;
7989 }
7990
7991 +#define atomic64_read_unchecked(v) atomic64_read(v)
7992 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
7993 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
7994 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
7995 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
7996 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
7997 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
7998 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
7999 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
8000 +
8001 #endif /* __powerpc64__ */
8002
8003 #endif /* __KERNEL__ */
8004 diff --git a/arch/powerpc/include/asm/barrier.h b/arch/powerpc/include/asm/barrier.h
8005 index f89da80..7f5b05a 100644
8006 --- a/arch/powerpc/include/asm/barrier.h
8007 +++ b/arch/powerpc/include/asm/barrier.h
8008 @@ -73,7 +73,7 @@
8009 do { \
8010 compiletime_assert_atomic_type(*p); \
8011 __lwsync(); \
8012 - ACCESS_ONCE(*p) = (v); \
8013 + ACCESS_ONCE_RW(*p) = (v); \
8014 } while (0)
8015
8016 #define smp_load_acquire(p) \
8017 diff --git a/arch/powerpc/include/asm/cache.h b/arch/powerpc/include/asm/cache.h
8018 index ed0afc1..0332825 100644
8019 --- a/arch/powerpc/include/asm/cache.h
8020 +++ b/arch/powerpc/include/asm/cache.h
8021 @@ -3,6 +3,7 @@
8022
8023 #ifdef __KERNEL__
8024
8025 +#include <linux/const.h>
8026
8027 /* bytes per L1 cache line */
8028 #if defined(CONFIG_8xx) || defined(CONFIG_403GCX)
8029 @@ -22,7 +23,7 @@
8030 #define L1_CACHE_SHIFT 7
8031 #endif
8032
8033 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
8034 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
8035
8036 #define SMP_CACHE_BYTES L1_CACHE_BYTES
8037
8038 diff --git a/arch/powerpc/include/asm/elf.h b/arch/powerpc/include/asm/elf.h
8039 index 935b5e7..7001d2d 100644
8040 --- a/arch/powerpc/include/asm/elf.h
8041 +++ b/arch/powerpc/include/asm/elf.h
8042 @@ -28,8 +28,19 @@
8043 the loader. We need to make sure that it is out of the way of the program
8044 that it will "exec", and that there is sufficient room for the brk. */
8045
8046 -extern unsigned long randomize_et_dyn(unsigned long base);
8047 -#define ELF_ET_DYN_BASE (randomize_et_dyn(0x20000000))
8048 +#define ELF_ET_DYN_BASE (0x20000000)
8049 +
8050 +#ifdef CONFIG_PAX_ASLR
8051 +#define PAX_ELF_ET_DYN_BASE (0x10000000UL)
8052 +
8053 +#ifdef __powerpc64__
8054 +#define PAX_DELTA_MMAP_LEN (is_32bit_task() ? 16 : 28)
8055 +#define PAX_DELTA_STACK_LEN (is_32bit_task() ? 16 : 28)
8056 +#else
8057 +#define PAX_DELTA_MMAP_LEN 15
8058 +#define PAX_DELTA_STACK_LEN 15
8059 +#endif
8060 +#endif
8061
8062 #define ELF_CORE_EFLAGS (is_elf2_task() ? 2 : 0)
8063
8064 @@ -127,10 +138,6 @@ extern int arch_setup_additional_pages(struct linux_binprm *bprm,
8065 (0x7ff >> (PAGE_SHIFT - 12)) : \
8066 (0x3ffff >> (PAGE_SHIFT - 12)))
8067
8068 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
8069 -#define arch_randomize_brk arch_randomize_brk
8070 -
8071 -
8072 #ifdef CONFIG_SPU_BASE
8073 /* Notes used in ET_CORE. Note name is "SPU/<fd>/<filename>". */
8074 #define NT_SPU 1
8075 diff --git a/arch/powerpc/include/asm/exec.h b/arch/powerpc/include/asm/exec.h
8076 index 8196e9c..d83a9f3 100644
8077 --- a/arch/powerpc/include/asm/exec.h
8078 +++ b/arch/powerpc/include/asm/exec.h
8079 @@ -4,6 +4,6 @@
8080 #ifndef _ASM_POWERPC_EXEC_H
8081 #define _ASM_POWERPC_EXEC_H
8082
8083 -extern unsigned long arch_align_stack(unsigned long sp);
8084 +#define arch_align_stack(x) ((x) & ~0xfUL)
8085
8086 #endif /* _ASM_POWERPC_EXEC_H */
8087 diff --git a/arch/powerpc/include/asm/kmap_types.h b/arch/powerpc/include/asm/kmap_types.h
8088 index 5acabbd..7ea14fa 100644
8089 --- a/arch/powerpc/include/asm/kmap_types.h
8090 +++ b/arch/powerpc/include/asm/kmap_types.h
8091 @@ -10,7 +10,7 @@
8092 * 2 of the License, or (at your option) any later version.
8093 */
8094
8095 -#define KM_TYPE_NR 16
8096 +#define KM_TYPE_NR 17
8097
8098 #endif /* __KERNEL__ */
8099 #endif /* _ASM_POWERPC_KMAP_TYPES_H */
8100 diff --git a/arch/powerpc/include/asm/local.h b/arch/powerpc/include/asm/local.h
8101 index b8da913..60b608a 100644
8102 --- a/arch/powerpc/include/asm/local.h
8103 +++ b/arch/powerpc/include/asm/local.h
8104 @@ -9,15 +9,26 @@ typedef struct
8105 atomic_long_t a;
8106 } local_t;
8107
8108 +typedef struct
8109 +{
8110 + atomic_long_unchecked_t a;
8111 +} local_unchecked_t;
8112 +
8113 #define LOCAL_INIT(i) { ATOMIC_LONG_INIT(i) }
8114
8115 #define local_read(l) atomic_long_read(&(l)->a)
8116 +#define local_read_unchecked(l) atomic_long_read_unchecked(&(l)->a)
8117 #define local_set(l,i) atomic_long_set(&(l)->a, (i))
8118 +#define local_set_unchecked(l,i) atomic_long_set_unchecked(&(l)->a, (i))
8119
8120 #define local_add(i,l) atomic_long_add((i),(&(l)->a))
8121 +#define local_add_unchecked(i,l) atomic_long_add_unchecked((i),(&(l)->a))
8122 #define local_sub(i,l) atomic_long_sub((i),(&(l)->a))
8123 +#define local_sub_unchecked(i,l) atomic_long_sub_unchecked((i),(&(l)->a))
8124 #define local_inc(l) atomic_long_inc(&(l)->a)
8125 +#define local_inc_unchecked(l) atomic_long_inc_unchecked(&(l)->a)
8126 #define local_dec(l) atomic_long_dec(&(l)->a)
8127 +#define local_dec_unchecked(l) atomic_long_dec_unchecked(&(l)->a)
8128
8129 static __inline__ long local_add_return(long a, local_t *l)
8130 {
8131 @@ -35,6 +46,7 @@ static __inline__ long local_add_return(long a, local_t *l)
8132
8133 return t;
8134 }
8135 +#define local_add_return_unchecked(i, l) atomic_long_add_return_unchecked((i), (&(l)->a))
8136
8137 #define local_add_negative(a, l) (local_add_return((a), (l)) < 0)
8138
8139 @@ -54,6 +66,7 @@ static __inline__ long local_sub_return(long a, local_t *l)
8140
8141 return t;
8142 }
8143 +#define local_sub_return_unchecked(i, l) atomic_long_sub_return_unchecked((i), (&(l)->a))
8144
8145 static __inline__ long local_inc_return(local_t *l)
8146 {
8147 @@ -101,6 +114,8 @@ static __inline__ long local_dec_return(local_t *l)
8148
8149 #define local_cmpxchg(l, o, n) \
8150 (cmpxchg_local(&((l)->a.counter), (o), (n)))
8151 +#define local_cmpxchg_unchecked(l, o, n) \
8152 + (cmpxchg_local(&((l)->a.counter), (o), (n)))
8153 #define local_xchg(l, n) (xchg_local(&((l)->a.counter), (n)))
8154
8155 /**
8156 diff --git a/arch/powerpc/include/asm/mman.h b/arch/powerpc/include/asm/mman.h
8157 index 8565c25..2865190 100644
8158 --- a/arch/powerpc/include/asm/mman.h
8159 +++ b/arch/powerpc/include/asm/mman.h
8160 @@ -24,7 +24,7 @@ static inline unsigned long arch_calc_vm_prot_bits(unsigned long prot)
8161 }
8162 #define arch_calc_vm_prot_bits(prot) arch_calc_vm_prot_bits(prot)
8163
8164 -static inline pgprot_t arch_vm_get_page_prot(unsigned long vm_flags)
8165 +static inline pgprot_t arch_vm_get_page_prot(vm_flags_t vm_flags)
8166 {
8167 return (vm_flags & VM_SAO) ? __pgprot(_PAGE_SAO) : __pgprot(0);
8168 }
8169 diff --git a/arch/powerpc/include/asm/page.h b/arch/powerpc/include/asm/page.h
8170 index 32e4e21..62afb12 100644
8171 --- a/arch/powerpc/include/asm/page.h
8172 +++ b/arch/powerpc/include/asm/page.h
8173 @@ -230,8 +230,9 @@ extern long long virt_phys_offset;
8174 * and needs to be executable. This means the whole heap ends
8175 * up being executable.
8176 */
8177 -#define VM_DATA_DEFAULT_FLAGS32 (VM_READ | VM_WRITE | VM_EXEC | \
8178 - VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
8179 +#define VM_DATA_DEFAULT_FLAGS32 \
8180 + (((current->personality & READ_IMPLIES_EXEC) ? VM_EXEC : 0) | \
8181 + VM_READ | VM_WRITE | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
8182
8183 #define VM_DATA_DEFAULT_FLAGS64 (VM_READ | VM_WRITE | \
8184 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
8185 @@ -259,6 +260,9 @@ extern long long virt_phys_offset;
8186 #define is_kernel_addr(x) ((x) >= PAGE_OFFSET)
8187 #endif
8188
8189 +#define ktla_ktva(addr) (addr)
8190 +#define ktva_ktla(addr) (addr)
8191 +
8192 #ifndef CONFIG_PPC_BOOK3S_64
8193 /*
8194 * Use the top bit of the higher-level page table entries to indicate whether
8195 diff --git a/arch/powerpc/include/asm/page_64.h b/arch/powerpc/include/asm/page_64.h
8196 index 88693ce..ac6f9ab 100644
8197 --- a/arch/powerpc/include/asm/page_64.h
8198 +++ b/arch/powerpc/include/asm/page_64.h
8199 @@ -153,15 +153,18 @@ do { \
8200 * stack by default, so in the absence of a PT_GNU_STACK program header
8201 * we turn execute permission off.
8202 */
8203 -#define VM_STACK_DEFAULT_FLAGS32 (VM_READ | VM_WRITE | VM_EXEC | \
8204 - VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
8205 +#define VM_STACK_DEFAULT_FLAGS32 \
8206 + (((current->personality & READ_IMPLIES_EXEC) ? VM_EXEC : 0) | \
8207 + VM_READ | VM_WRITE | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
8208
8209 #define VM_STACK_DEFAULT_FLAGS64 (VM_READ | VM_WRITE | \
8210 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
8211
8212 +#ifndef CONFIG_PAX_PAGEEXEC
8213 #define VM_STACK_DEFAULT_FLAGS \
8214 (is_32bit_task() ? \
8215 VM_STACK_DEFAULT_FLAGS32 : VM_STACK_DEFAULT_FLAGS64)
8216 +#endif
8217
8218 #include <asm-generic/getorder.h>
8219
8220 diff --git a/arch/powerpc/include/asm/pgalloc-64.h b/arch/powerpc/include/asm/pgalloc-64.h
8221 index 4b0be20..c15a27d 100644
8222 --- a/arch/powerpc/include/asm/pgalloc-64.h
8223 +++ b/arch/powerpc/include/asm/pgalloc-64.h
8224 @@ -54,6 +54,7 @@ static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
8225 #ifndef CONFIG_PPC_64K_PAGES
8226
8227 #define pgd_populate(MM, PGD, PUD) pgd_set(PGD, PUD)
8228 +#define pgd_populate_kernel(MM, PGD, PUD) pgd_populate((MM), (PGD), (PUD))
8229
8230 static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
8231 {
8232 @@ -71,6 +72,11 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
8233 pud_set(pud, (unsigned long)pmd);
8234 }
8235
8236 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
8237 +{
8238 + pud_populate(mm, pud, pmd);
8239 +}
8240 +
8241 #define pmd_populate(mm, pmd, pte_page) \
8242 pmd_populate_kernel(mm, pmd, page_address(pte_page))
8243 #define pmd_populate_kernel(mm, pmd, pte) pmd_set(pmd, (unsigned long)(pte))
8244 @@ -173,6 +179,7 @@ extern void __tlb_remove_table(void *_table);
8245 #endif
8246
8247 #define pud_populate(mm, pud, pmd) pud_set(pud, (unsigned long)pmd)
8248 +#define pud_populate_kernel(mm, pud, pmd) pud_populate((mm), (pud), (pmd))
8249
8250 static inline void pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmd,
8251 pte_t *pte)
8252 diff --git a/arch/powerpc/include/asm/pgtable.h b/arch/powerpc/include/asm/pgtable.h
8253 index 3ebb188..e17dddf 100644
8254 --- a/arch/powerpc/include/asm/pgtable.h
8255 +++ b/arch/powerpc/include/asm/pgtable.h
8256 @@ -2,6 +2,7 @@
8257 #define _ASM_POWERPC_PGTABLE_H
8258 #ifdef __KERNEL__
8259
8260 +#include <linux/const.h>
8261 #ifndef __ASSEMBLY__
8262 #include <linux/mmdebug.h>
8263 #include <asm/processor.h> /* For TASK_SIZE */
8264 diff --git a/arch/powerpc/include/asm/pte-hash32.h b/arch/powerpc/include/asm/pte-hash32.h
8265 index 4aad413..85d86bf 100644
8266 --- a/arch/powerpc/include/asm/pte-hash32.h
8267 +++ b/arch/powerpc/include/asm/pte-hash32.h
8268 @@ -21,6 +21,7 @@
8269 #define _PAGE_FILE 0x004 /* when !present: nonlinear file mapping */
8270 #define _PAGE_USER 0x004 /* usermode access allowed */
8271 #define _PAGE_GUARDED 0x008 /* G: prohibit speculative access */
8272 +#define _PAGE_EXEC _PAGE_GUARDED
8273 #define _PAGE_COHERENT 0x010 /* M: enforce memory coherence (SMP systems) */
8274 #define _PAGE_NO_CACHE 0x020 /* I: cache inhibit */
8275 #define _PAGE_WRITETHRU 0x040 /* W: cache write-through */
8276 diff --git a/arch/powerpc/include/asm/reg.h b/arch/powerpc/include/asm/reg.h
8277 index e5d2e0b..9ac74b1 100644
8278 --- a/arch/powerpc/include/asm/reg.h
8279 +++ b/arch/powerpc/include/asm/reg.h
8280 @@ -249,6 +249,7 @@
8281 #define SPRN_DBCR 0x136 /* e300 Data Breakpoint Control Reg */
8282 #define SPRN_DSISR 0x012 /* Data Storage Interrupt Status Register */
8283 #define DSISR_NOHPTE 0x40000000 /* no translation found */
8284 +#define DSISR_GUARDED 0x10000000 /* fetch from guarded storage */
8285 #define DSISR_PROTFAULT 0x08000000 /* protection fault */
8286 #define DSISR_ISSTORE 0x02000000 /* access was a store */
8287 #define DSISR_DABRMATCH 0x00400000 /* hit data breakpoint */
8288 diff --git a/arch/powerpc/include/asm/smp.h b/arch/powerpc/include/asm/smp.h
8289 index ff51046..b982dd4 100644
8290 --- a/arch/powerpc/include/asm/smp.h
8291 +++ b/arch/powerpc/include/asm/smp.h
8292 @@ -51,7 +51,7 @@ struct smp_ops_t {
8293 int (*cpu_disable)(void);
8294 void (*cpu_die)(unsigned int nr);
8295 int (*cpu_bootable)(unsigned int nr);
8296 -};
8297 +} __no_const;
8298
8299 extern void smp_send_debugger_break(void);
8300 extern void start_secondary_resume(void);
8301 diff --git a/arch/powerpc/include/asm/thread_info.h b/arch/powerpc/include/asm/thread_info.h
8302 index b034ecd..af7e31f 100644
8303 --- a/arch/powerpc/include/asm/thread_info.h
8304 +++ b/arch/powerpc/include/asm/thread_info.h
8305 @@ -107,6 +107,8 @@ static inline struct thread_info *current_thread_info(void)
8306 #if defined(CONFIG_PPC64)
8307 #define TIF_ELF2ABI 18 /* function descriptors must die! */
8308 #endif
8309 +/* mask must be expressable within 16 bits to satisfy 'andi' instruction reqs */
8310 +#define TIF_GRSEC_SETXID 6 /* update credentials on syscall entry/exit */
8311
8312 /* as above, but as bit values */
8313 #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
8314 @@ -125,9 +127,10 @@ static inline struct thread_info *current_thread_info(void)
8315 #define _TIF_SYSCALL_TRACEPOINT (1<<TIF_SYSCALL_TRACEPOINT)
8316 #define _TIF_EMULATE_STACK_STORE (1<<TIF_EMULATE_STACK_STORE)
8317 #define _TIF_NOHZ (1<<TIF_NOHZ)
8318 +#define _TIF_GRSEC_SETXID (1<<TIF_GRSEC_SETXID)
8319 #define _TIF_SYSCALL_T_OR_A (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | \
8320 _TIF_SECCOMP | _TIF_SYSCALL_TRACEPOINT | \
8321 - _TIF_NOHZ)
8322 + _TIF_NOHZ | _TIF_GRSEC_SETXID)
8323
8324 #define _TIF_USER_WORK_MASK (_TIF_SIGPENDING | _TIF_NEED_RESCHED | \
8325 _TIF_NOTIFY_RESUME | _TIF_UPROBE | \
8326 diff --git a/arch/powerpc/include/asm/uaccess.h b/arch/powerpc/include/asm/uaccess.h
8327 index 9485b43..3bd3c16 100644
8328 --- a/arch/powerpc/include/asm/uaccess.h
8329 +++ b/arch/powerpc/include/asm/uaccess.h
8330 @@ -58,6 +58,7 @@
8331
8332 #endif
8333
8334 +#define access_ok_noprefault(type, addr, size) access_ok((type), (addr), (size))
8335 #define access_ok(type, addr, size) \
8336 (__chk_user_ptr(addr), \
8337 __access_ok((__force unsigned long)(addr), (size), get_fs()))
8338 @@ -318,52 +319,6 @@ do { \
8339 extern unsigned long __copy_tofrom_user(void __user *to,
8340 const void __user *from, unsigned long size);
8341
8342 -#ifndef __powerpc64__
8343 -
8344 -static inline unsigned long copy_from_user(void *to,
8345 - const void __user *from, unsigned long n)
8346 -{
8347 - unsigned long over;
8348 -
8349 - if (access_ok(VERIFY_READ, from, n))
8350 - return __copy_tofrom_user((__force void __user *)to, from, n);
8351 - if ((unsigned long)from < TASK_SIZE) {
8352 - over = (unsigned long)from + n - TASK_SIZE;
8353 - return __copy_tofrom_user((__force void __user *)to, from,
8354 - n - over) + over;
8355 - }
8356 - return n;
8357 -}
8358 -
8359 -static inline unsigned long copy_to_user(void __user *to,
8360 - const void *from, unsigned long n)
8361 -{
8362 - unsigned long over;
8363 -
8364 - if (access_ok(VERIFY_WRITE, to, n))
8365 - return __copy_tofrom_user(to, (__force void __user *)from, n);
8366 - if ((unsigned long)to < TASK_SIZE) {
8367 - over = (unsigned long)to + n - TASK_SIZE;
8368 - return __copy_tofrom_user(to, (__force void __user *)from,
8369 - n - over) + over;
8370 - }
8371 - return n;
8372 -}
8373 -
8374 -#else /* __powerpc64__ */
8375 -
8376 -#define __copy_in_user(to, from, size) \
8377 - __copy_tofrom_user((to), (from), (size))
8378 -
8379 -extern unsigned long copy_from_user(void *to, const void __user *from,
8380 - unsigned long n);
8381 -extern unsigned long copy_to_user(void __user *to, const void *from,
8382 - unsigned long n);
8383 -extern unsigned long copy_in_user(void __user *to, const void __user *from,
8384 - unsigned long n);
8385 -
8386 -#endif /* __powerpc64__ */
8387 -
8388 static inline unsigned long __copy_from_user_inatomic(void *to,
8389 const void __user *from, unsigned long n)
8390 {
8391 @@ -387,6 +342,10 @@ static inline unsigned long __copy_from_user_inatomic(void *to,
8392 if (ret == 0)
8393 return 0;
8394 }
8395 +
8396 + if (!__builtin_constant_p(n))
8397 + check_object_size(to, n, false);
8398 +
8399 return __copy_tofrom_user((__force void __user *)to, from, n);
8400 }
8401
8402 @@ -413,6 +372,10 @@ static inline unsigned long __copy_to_user_inatomic(void __user *to,
8403 if (ret == 0)
8404 return 0;
8405 }
8406 +
8407 + if (!__builtin_constant_p(n))
8408 + check_object_size(from, n, true);
8409 +
8410 return __copy_tofrom_user(to, (__force const void __user *)from, n);
8411 }
8412
8413 @@ -430,6 +393,92 @@ static inline unsigned long __copy_to_user(void __user *to,
8414 return __copy_to_user_inatomic(to, from, size);
8415 }
8416
8417 +#ifndef __powerpc64__
8418 +
8419 +static inline unsigned long __must_check copy_from_user(void *to,
8420 + const void __user *from, unsigned long n)
8421 +{
8422 + unsigned long over;
8423 +
8424 + if ((long)n < 0)
8425 + return n;
8426 +
8427 + if (access_ok(VERIFY_READ, from, n)) {
8428 + if (!__builtin_constant_p(n))
8429 + check_object_size(to, n, false);
8430 + return __copy_tofrom_user((__force void __user *)to, from, n);
8431 + }
8432 + if ((unsigned long)from < TASK_SIZE) {
8433 + over = (unsigned long)from + n - TASK_SIZE;
8434 + if (!__builtin_constant_p(n - over))
8435 + check_object_size(to, n - over, false);
8436 + return __copy_tofrom_user((__force void __user *)to, from,
8437 + n - over) + over;
8438 + }
8439 + return n;
8440 +}
8441 +
8442 +static inline unsigned long __must_check copy_to_user(void __user *to,
8443 + const void *from, unsigned long n)
8444 +{
8445 + unsigned long over;
8446 +
8447 + if ((long)n < 0)
8448 + return n;
8449 +
8450 + if (access_ok(VERIFY_WRITE, to, n)) {
8451 + if (!__builtin_constant_p(n))
8452 + check_object_size(from, n, true);
8453 + return __copy_tofrom_user(to, (__force void __user *)from, n);
8454 + }
8455 + if ((unsigned long)to < TASK_SIZE) {
8456 + over = (unsigned long)to + n - TASK_SIZE;
8457 + if (!__builtin_constant_p(n))
8458 + check_object_size(from, n - over, true);
8459 + return __copy_tofrom_user(to, (__force void __user *)from,
8460 + n - over) + over;
8461 + }
8462 + return n;
8463 +}
8464 +
8465 +#else /* __powerpc64__ */
8466 +
8467 +#define __copy_in_user(to, from, size) \
8468 + __copy_tofrom_user((to), (from), (size))
8469 +
8470 +static inline unsigned long __must_check copy_from_user(void *to, const void __user *from, unsigned long n)
8471 +{
8472 + if ((long)n < 0 || n > INT_MAX)
8473 + return n;
8474 +
8475 + if (!__builtin_constant_p(n))
8476 + check_object_size(to, n, false);
8477 +
8478 + if (likely(access_ok(VERIFY_READ, from, n)))
8479 + n = __copy_from_user(to, from, n);
8480 + else
8481 + memset(to, 0, n);
8482 + return n;
8483 +}
8484 +
8485 +static inline unsigned long __must_check copy_to_user(void __user *to, const void *from, unsigned long n)
8486 +{
8487 + if ((long)n < 0 || n > INT_MAX)
8488 + return n;
8489 +
8490 + if (likely(access_ok(VERIFY_WRITE, to, n))) {
8491 + if (!__builtin_constant_p(n))
8492 + check_object_size(from, n, true);
8493 + n = __copy_to_user(to, from, n);
8494 + }
8495 + return n;
8496 +}
8497 +
8498 +extern unsigned long copy_in_user(void __user *to, const void __user *from,
8499 + unsigned long n);
8500 +
8501 +#endif /* __powerpc64__ */
8502 +
8503 extern unsigned long __clear_user(void __user *addr, unsigned long size);
8504
8505 static inline unsigned long clear_user(void __user *addr, unsigned long size)
8506 diff --git a/arch/powerpc/kernel/Makefile b/arch/powerpc/kernel/Makefile
8507 index fcc9a89..07be2bb 100644
8508 --- a/arch/powerpc/kernel/Makefile
8509 +++ b/arch/powerpc/kernel/Makefile
8510 @@ -26,6 +26,8 @@ CFLAGS_REMOVE_ftrace.o = -pg -mno-sched-epilog
8511 CFLAGS_REMOVE_time.o = -pg -mno-sched-epilog
8512 endif
8513
8514 +CFLAGS_REMOVE_prom_init.o += $(LATENT_ENTROPY_PLUGIN_CFLAGS)
8515 +
8516 obj-y := cputable.o ptrace.o syscalls.o \
8517 irq.o align.o signal_32.o pmc.o vdso.o \
8518 process.o systbl.o idle.o \
8519 diff --git a/arch/powerpc/kernel/exceptions-64e.S b/arch/powerpc/kernel/exceptions-64e.S
8520 index c1bee3c..5b42583 100644
8521 --- a/arch/powerpc/kernel/exceptions-64e.S
8522 +++ b/arch/powerpc/kernel/exceptions-64e.S
8523 @@ -1010,6 +1010,7 @@ storage_fault_common:
8524 std r14,_DAR(r1)
8525 std r15,_DSISR(r1)
8526 addi r3,r1,STACK_FRAME_OVERHEAD
8527 + bl .save_nvgprs
8528 mr r4,r14
8529 mr r5,r15
8530 ld r14,PACA_EXGEN+EX_R14(r13)
8531 @@ -1018,8 +1019,7 @@ storage_fault_common:
8532 cmpdi r3,0
8533 bne- 1f
8534 b .ret_from_except_lite
8535 -1: bl .save_nvgprs
8536 - mr r5,r3
8537 +1: mr r5,r3
8538 addi r3,r1,STACK_FRAME_OVERHEAD
8539 ld r4,_DAR(r1)
8540 bl .bad_page_fault
8541 diff --git a/arch/powerpc/kernel/exceptions-64s.S b/arch/powerpc/kernel/exceptions-64s.S
8542 index 3afd391..18f9e36 100644
8543 --- a/arch/powerpc/kernel/exceptions-64s.S
8544 +++ b/arch/powerpc/kernel/exceptions-64s.S
8545 @@ -1587,10 +1587,10 @@ handle_page_fault:
8546 11: ld r4,_DAR(r1)
8547 ld r5,_DSISR(r1)
8548 addi r3,r1,STACK_FRAME_OVERHEAD
8549 + bl .save_nvgprs
8550 bl .do_page_fault
8551 cmpdi r3,0
8552 beq+ 12f
8553 - bl .save_nvgprs
8554 mr r5,r3
8555 addi r3,r1,STACK_FRAME_OVERHEAD
8556 lwz r4,_DAR(r1)
8557 diff --git a/arch/powerpc/kernel/irq.c b/arch/powerpc/kernel/irq.c
8558 index ca1cd74..6f0241a 100644
8559 --- a/arch/powerpc/kernel/irq.c
8560 +++ b/arch/powerpc/kernel/irq.c
8561 @@ -447,6 +447,8 @@ void migrate_irqs(void)
8562 }
8563 #endif
8564
8565 +extern void gr_handle_kernel_exploit(void);
8566 +
8567 static inline void check_stack_overflow(void)
8568 {
8569 #ifdef CONFIG_DEBUG_STACKOVERFLOW
8570 @@ -459,6 +461,7 @@ static inline void check_stack_overflow(void)
8571 printk("do_IRQ: stack overflow: %ld\n",
8572 sp - sizeof(struct thread_info));
8573 dump_stack();
8574 + gr_handle_kernel_exploit();
8575 }
8576 #endif
8577 }
8578 diff --git a/arch/powerpc/kernel/module_32.c b/arch/powerpc/kernel/module_32.c
8579 index 6cff040..74ac5d1 100644
8580 --- a/arch/powerpc/kernel/module_32.c
8581 +++ b/arch/powerpc/kernel/module_32.c
8582 @@ -161,7 +161,7 @@ int module_frob_arch_sections(Elf32_Ehdr *hdr,
8583 me->arch.core_plt_section = i;
8584 }
8585 if (!me->arch.core_plt_section || !me->arch.init_plt_section) {
8586 - printk("Module doesn't contain .plt or .init.plt sections.\n");
8587 + printk("Module %s doesn't contain .plt or .init.plt sections.\n", me->name);
8588 return -ENOEXEC;
8589 }
8590
8591 @@ -191,11 +191,16 @@ static uint32_t do_plt_call(void *location,
8592
8593 DEBUGP("Doing plt for call to 0x%x at 0x%x\n", val, (unsigned int)location);
8594 /* Init, or core PLT? */
8595 - if (location >= mod->module_core
8596 - && location < mod->module_core + mod->core_size)
8597 + if ((location >= mod->module_core_rx && location < mod->module_core_rx + mod->core_size_rx) ||
8598 + (location >= mod->module_core_rw && location < mod->module_core_rw + mod->core_size_rw))
8599 entry = (void *)sechdrs[mod->arch.core_plt_section].sh_addr;
8600 - else
8601 + else if ((location >= mod->module_init_rx && location < mod->module_init_rx + mod->init_size_rx) ||
8602 + (location >= mod->module_init_rw && location < mod->module_init_rw + mod->init_size_rw))
8603 entry = (void *)sechdrs[mod->arch.init_plt_section].sh_addr;
8604 + else {
8605 + printk(KERN_ERR "%s: invalid R_PPC_REL24 entry found\n", mod->name);
8606 + return ~0UL;
8607 + }
8608
8609 /* Find this entry, or if that fails, the next avail. entry */
8610 while (entry->jump[0]) {
8611 @@ -299,7 +304,7 @@ int apply_relocate_add(Elf32_Shdr *sechdrs,
8612 }
8613 #ifdef CONFIG_DYNAMIC_FTRACE
8614 module->arch.tramp =
8615 - do_plt_call(module->module_core,
8616 + do_plt_call(module->module_core_rx,
8617 (unsigned long)ftrace_caller,
8618 sechdrs, module);
8619 #endif
8620 diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
8621 index 31d0215..206af70 100644
8622 --- a/arch/powerpc/kernel/process.c
8623 +++ b/arch/powerpc/kernel/process.c
8624 @@ -1031,8 +1031,8 @@ void show_regs(struct pt_regs * regs)
8625 * Lookup NIP late so we have the best change of getting the
8626 * above info out without failing
8627 */
8628 - printk("NIP ["REG"] %pS\n", regs->nip, (void *)regs->nip);
8629 - printk("LR ["REG"] %pS\n", regs->link, (void *)regs->link);
8630 + printk("NIP ["REG"] %pA\n", regs->nip, (void *)regs->nip);
8631 + printk("LR ["REG"] %pA\n", regs->link, (void *)regs->link);
8632 #endif
8633 show_stack(current, (unsigned long *) regs->gpr[1]);
8634 if (!user_mode(regs))
8635 @@ -1554,10 +1554,10 @@ void show_stack(struct task_struct *tsk, unsigned long *stack)
8636 newsp = stack[0];
8637 ip = stack[STACK_FRAME_LR_SAVE];
8638 if (!firstframe || ip != lr) {
8639 - printk("["REG"] ["REG"] %pS", sp, ip, (void *)ip);
8640 + printk("["REG"] ["REG"] %pA", sp, ip, (void *)ip);
8641 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
8642 if ((ip == rth || ip == mrth) && curr_frame >= 0) {
8643 - printk(" (%pS)",
8644 + printk(" (%pA)",
8645 (void *)current->ret_stack[curr_frame].ret);
8646 curr_frame--;
8647 }
8648 @@ -1577,7 +1577,7 @@ void show_stack(struct task_struct *tsk, unsigned long *stack)
8649 struct pt_regs *regs = (struct pt_regs *)
8650 (sp + STACK_FRAME_OVERHEAD);
8651 lr = regs->link;
8652 - printk("--- Exception: %lx at %pS\n LR = %pS\n",
8653 + printk("--- Exception: %lx at %pA\n LR = %pA\n",
8654 regs->trap, (void *)regs->nip, (void *)lr);
8655 firstframe = 1;
8656 }
8657 @@ -1613,58 +1613,3 @@ void notrace __ppc64_runlatch_off(void)
8658 mtspr(SPRN_CTRLT, ctrl);
8659 }
8660 #endif /* CONFIG_PPC64 */
8661 -
8662 -unsigned long arch_align_stack(unsigned long sp)
8663 -{
8664 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
8665 - sp -= get_random_int() & ~PAGE_MASK;
8666 - return sp & ~0xf;
8667 -}
8668 -
8669 -static inline unsigned long brk_rnd(void)
8670 -{
8671 - unsigned long rnd = 0;
8672 -
8673 - /* 8MB for 32bit, 1GB for 64bit */
8674 - if (is_32bit_task())
8675 - rnd = (long)(get_random_int() % (1<<(23-PAGE_SHIFT)));
8676 - else
8677 - rnd = (long)(get_random_int() % (1<<(30-PAGE_SHIFT)));
8678 -
8679 - return rnd << PAGE_SHIFT;
8680 -}
8681 -
8682 -unsigned long arch_randomize_brk(struct mm_struct *mm)
8683 -{
8684 - unsigned long base = mm->brk;
8685 - unsigned long ret;
8686 -
8687 -#ifdef CONFIG_PPC_STD_MMU_64
8688 - /*
8689 - * If we are using 1TB segments and we are allowed to randomise
8690 - * the heap, we can put it above 1TB so it is backed by a 1TB
8691 - * segment. Otherwise the heap will be in the bottom 1TB
8692 - * which always uses 256MB segments and this may result in a
8693 - * performance penalty.
8694 - */
8695 - if (!is_32bit_task() && (mmu_highuser_ssize == MMU_SEGSIZE_1T))
8696 - base = max_t(unsigned long, mm->brk, 1UL << SID_SHIFT_1T);
8697 -#endif
8698 -
8699 - ret = PAGE_ALIGN(base + brk_rnd());
8700 -
8701 - if (ret < mm->brk)
8702 - return mm->brk;
8703 -
8704 - return ret;
8705 -}
8706 -
8707 -unsigned long randomize_et_dyn(unsigned long base)
8708 -{
8709 - unsigned long ret = PAGE_ALIGN(base + brk_rnd());
8710 -
8711 - if (ret < base)
8712 - return base;
8713 -
8714 - return ret;
8715 -}
8716 diff --git a/arch/powerpc/kernel/ptrace.c b/arch/powerpc/kernel/ptrace.c
8717 index 2e3d2bf..35df241 100644
8718 --- a/arch/powerpc/kernel/ptrace.c
8719 +++ b/arch/powerpc/kernel/ptrace.c
8720 @@ -1762,6 +1762,10 @@ long arch_ptrace(struct task_struct *child, long request,
8721 return ret;
8722 }
8723
8724 +#ifdef CONFIG_GRKERNSEC_SETXID
8725 +extern void gr_delayed_cred_worker(void);
8726 +#endif
8727 +
8728 /*
8729 * We must return the syscall number to actually look up in the table.
8730 * This can be -1L to skip running any syscall at all.
8731 @@ -1774,6 +1778,11 @@ long do_syscall_trace_enter(struct pt_regs *regs)
8732
8733 secure_computing_strict(regs->gpr[0]);
8734
8735 +#ifdef CONFIG_GRKERNSEC_SETXID
8736 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
8737 + gr_delayed_cred_worker();
8738 +#endif
8739 +
8740 if (test_thread_flag(TIF_SYSCALL_TRACE) &&
8741 tracehook_report_syscall_entry(regs))
8742 /*
8743 @@ -1808,6 +1817,11 @@ void do_syscall_trace_leave(struct pt_regs *regs)
8744 {
8745 int step;
8746
8747 +#ifdef CONFIG_GRKERNSEC_SETXID
8748 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
8749 + gr_delayed_cred_worker();
8750 +#endif
8751 +
8752 audit_syscall_exit(regs);
8753
8754 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
8755 diff --git a/arch/powerpc/kernel/signal_32.c b/arch/powerpc/kernel/signal_32.c
8756 index 4e47db6..6dcc96e 100644
8757 --- a/arch/powerpc/kernel/signal_32.c
8758 +++ b/arch/powerpc/kernel/signal_32.c
8759 @@ -1013,7 +1013,7 @@ int handle_rt_signal32(unsigned long sig, struct k_sigaction *ka,
8760 /* Save user registers on the stack */
8761 frame = &rt_sf->uc.uc_mcontext;
8762 addr = frame;
8763 - if (vdso32_rt_sigtramp && current->mm->context.vdso_base) {
8764 + if (vdso32_rt_sigtramp && current->mm->context.vdso_base != ~0UL) {
8765 sigret = 0;
8766 tramp = current->mm->context.vdso_base + vdso32_rt_sigtramp;
8767 } else {
8768 diff --git a/arch/powerpc/kernel/signal_64.c b/arch/powerpc/kernel/signal_64.c
8769 index d501dc4..e5a0de0 100644
8770 --- a/arch/powerpc/kernel/signal_64.c
8771 +++ b/arch/powerpc/kernel/signal_64.c
8772 @@ -760,7 +760,7 @@ int handle_rt_signal64(int signr, struct k_sigaction *ka, siginfo_t *info,
8773 current->thread.fp_state.fpscr = 0;
8774
8775 /* Set up to return from userspace. */
8776 - if (vdso64_rt_sigtramp && current->mm->context.vdso_base) {
8777 + if (vdso64_rt_sigtramp && current->mm->context.vdso_base != ~0UL) {
8778 regs->link = current->mm->context.vdso_base + vdso64_rt_sigtramp;
8779 } else {
8780 err |= setup_trampoline(__NR_rt_sigreturn, &frame->tramp[0]);
8781 diff --git a/arch/powerpc/kernel/traps.c b/arch/powerpc/kernel/traps.c
8782 index 1bd7ca2..9b78c2f 100644
8783 --- a/arch/powerpc/kernel/traps.c
8784 +++ b/arch/powerpc/kernel/traps.c
8785 @@ -142,6 +142,8 @@ static unsigned __kprobes long oops_begin(struct pt_regs *regs)
8786 return flags;
8787 }
8788
8789 +extern void gr_handle_kernel_exploit(void);
8790 +
8791 static void __kprobes oops_end(unsigned long flags, struct pt_regs *regs,
8792 int signr)
8793 {
8794 @@ -191,6 +193,9 @@ static void __kprobes oops_end(unsigned long flags, struct pt_regs *regs,
8795 panic("Fatal exception in interrupt");
8796 if (panic_on_oops)
8797 panic("Fatal exception");
8798 +
8799 + gr_handle_kernel_exploit();
8800 +
8801 do_exit(signr);
8802 }
8803
8804 diff --git a/arch/powerpc/kernel/vdso.c b/arch/powerpc/kernel/vdso.c
8805 index ce74c33..0803371 100644
8806 --- a/arch/powerpc/kernel/vdso.c
8807 +++ b/arch/powerpc/kernel/vdso.c
8808 @@ -35,6 +35,7 @@
8809 #include <asm/vdso.h>
8810 #include <asm/vdso_datapage.h>
8811 #include <asm/setup.h>
8812 +#include <asm/mman.h>
8813
8814 #undef DEBUG
8815
8816 @@ -221,7 +222,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
8817 vdso_base = VDSO32_MBASE;
8818 #endif
8819
8820 - current->mm->context.vdso_base = 0;
8821 + current->mm->context.vdso_base = ~0UL;
8822
8823 /* vDSO has a problem and was disabled, just don't "enable" it for the
8824 * process
8825 @@ -241,7 +242,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
8826 vdso_base = get_unmapped_area(NULL, vdso_base,
8827 (vdso_pages << PAGE_SHIFT) +
8828 ((VDSO_ALIGNMENT - 1) & PAGE_MASK),
8829 - 0, 0);
8830 + 0, MAP_PRIVATE | MAP_EXECUTABLE);
8831 if (IS_ERR_VALUE(vdso_base)) {
8832 rc = vdso_base;
8833 goto fail_mmapsem;
8834 diff --git a/arch/powerpc/kvm/powerpc.c b/arch/powerpc/kvm/powerpc.c
8835 index 3cf541a..ab2d825 100644
8836 --- a/arch/powerpc/kvm/powerpc.c
8837 +++ b/arch/powerpc/kvm/powerpc.c
8838 @@ -1153,7 +1153,7 @@ void kvmppc_init_lpid(unsigned long nr_lpids_param)
8839 }
8840 EXPORT_SYMBOL_GPL(kvmppc_init_lpid);
8841
8842 -int kvm_arch_init(void *opaque)
8843 +int kvm_arch_init(const void *opaque)
8844 {
8845 return 0;
8846 }
8847 diff --git a/arch/powerpc/lib/usercopy_64.c b/arch/powerpc/lib/usercopy_64.c
8848 index 5eea6f3..5d10396 100644
8849 --- a/arch/powerpc/lib/usercopy_64.c
8850 +++ b/arch/powerpc/lib/usercopy_64.c
8851 @@ -9,22 +9,6 @@
8852 #include <linux/module.h>
8853 #include <asm/uaccess.h>
8854
8855 -unsigned long copy_from_user(void *to, const void __user *from, unsigned long n)
8856 -{
8857 - if (likely(access_ok(VERIFY_READ, from, n)))
8858 - n = __copy_from_user(to, from, n);
8859 - else
8860 - memset(to, 0, n);
8861 - return n;
8862 -}
8863 -
8864 -unsigned long copy_to_user(void __user *to, const void *from, unsigned long n)
8865 -{
8866 - if (likely(access_ok(VERIFY_WRITE, to, n)))
8867 - n = __copy_to_user(to, from, n);
8868 - return n;
8869 -}
8870 -
8871 unsigned long copy_in_user(void __user *to, const void __user *from,
8872 unsigned long n)
8873 {
8874 @@ -35,7 +19,5 @@ unsigned long copy_in_user(void __user *to, const void __user *from,
8875 return n;
8876 }
8877
8878 -EXPORT_SYMBOL(copy_from_user);
8879 -EXPORT_SYMBOL(copy_to_user);
8880 EXPORT_SYMBOL(copy_in_user);
8881
8882 diff --git a/arch/powerpc/mm/fault.c b/arch/powerpc/mm/fault.c
8883 index 51ab9e7..7d3c78b 100644
8884 --- a/arch/powerpc/mm/fault.c
8885 +++ b/arch/powerpc/mm/fault.c
8886 @@ -33,6 +33,10 @@
8887 #include <linux/magic.h>
8888 #include <linux/ratelimit.h>
8889 #include <linux/context_tracking.h>
8890 +#include <linux/slab.h>
8891 +#include <linux/pagemap.h>
8892 +#include <linux/compiler.h>
8893 +#include <linux/unistd.h>
8894
8895 #include <asm/firmware.h>
8896 #include <asm/page.h>
8897 @@ -69,6 +73,33 @@ static inline int notify_page_fault(struct pt_regs *regs)
8898 }
8899 #endif
8900
8901 +#ifdef CONFIG_PAX_PAGEEXEC
8902 +/*
8903 + * PaX: decide what to do with offenders (regs->nip = fault address)
8904 + *
8905 + * returns 1 when task should be killed
8906 + */
8907 +static int pax_handle_fetch_fault(struct pt_regs *regs)
8908 +{
8909 + return 1;
8910 +}
8911 +
8912 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
8913 +{
8914 + unsigned long i;
8915 +
8916 + printk(KERN_ERR "PAX: bytes at PC: ");
8917 + for (i = 0; i < 5; i++) {
8918 + unsigned int c;
8919 + if (get_user(c, (unsigned int __user *)pc+i))
8920 + printk(KERN_CONT "???????? ");
8921 + else
8922 + printk(KERN_CONT "%08x ", c);
8923 + }
8924 + printk("\n");
8925 +}
8926 +#endif
8927 +
8928 /*
8929 * Check whether the instruction at regs->nip is a store using
8930 * an update addressing form which will update r1.
8931 @@ -216,7 +247,7 @@ int __kprobes do_page_fault(struct pt_regs *regs, unsigned long address,
8932 * indicate errors in DSISR but can validly be set in SRR1.
8933 */
8934 if (trap == 0x400)
8935 - error_code &= 0x48200000;
8936 + error_code &= 0x58200000;
8937 else
8938 is_write = error_code & DSISR_ISSTORE;
8939 #else
8940 @@ -378,7 +409,7 @@ good_area:
8941 * "undefined". Of those that can be set, this is the only
8942 * one which seems bad.
8943 */
8944 - if (error_code & 0x10000000)
8945 + if (error_code & DSISR_GUARDED)
8946 /* Guarded storage error. */
8947 goto bad_area;
8948 #endif /* CONFIG_8xx */
8949 @@ -393,7 +424,7 @@ good_area:
8950 * processors use the same I/D cache coherency mechanism
8951 * as embedded.
8952 */
8953 - if (error_code & DSISR_PROTFAULT)
8954 + if (error_code & (DSISR_PROTFAULT | DSISR_GUARDED))
8955 goto bad_area;
8956 #endif /* CONFIG_PPC_STD_MMU */
8957
8958 @@ -483,6 +514,23 @@ bad_area:
8959 bad_area_nosemaphore:
8960 /* User mode accesses cause a SIGSEGV */
8961 if (user_mode(regs)) {
8962 +
8963 +#ifdef CONFIG_PAX_PAGEEXEC
8964 + if (mm->pax_flags & MF_PAX_PAGEEXEC) {
8965 +#ifdef CONFIG_PPC_STD_MMU
8966 + if (is_exec && (error_code & (DSISR_PROTFAULT | DSISR_GUARDED))) {
8967 +#else
8968 + if (is_exec && regs->nip == address) {
8969 +#endif
8970 + switch (pax_handle_fetch_fault(regs)) {
8971 + }
8972 +
8973 + pax_report_fault(regs, (void *)regs->nip, (void *)regs->gpr[PT_R1]);
8974 + do_group_exit(SIGKILL);
8975 + }
8976 + }
8977 +#endif
8978 +
8979 _exception(SIGSEGV, regs, code, address);
8980 goto bail;
8981 }
8982 diff --git a/arch/powerpc/mm/mmap.c b/arch/powerpc/mm/mmap.c
8983 index cb8bdbe..cde4bc7 100644
8984 --- a/arch/powerpc/mm/mmap.c
8985 +++ b/arch/powerpc/mm/mmap.c
8986 @@ -53,10 +53,14 @@ static inline int mmap_is_legacy(void)
8987 return sysctl_legacy_va_layout;
8988 }
8989
8990 -static unsigned long mmap_rnd(void)
8991 +static unsigned long mmap_rnd(struct mm_struct *mm)
8992 {
8993 unsigned long rnd = 0;
8994
8995 +#ifdef CONFIG_PAX_RANDMMAP
8996 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
8997 +#endif
8998 +
8999 if (current->flags & PF_RANDOMIZE) {
9000 /* 8MB for 32bit, 1GB for 64bit */
9001 if (is_32bit_task())
9002 @@ -67,7 +71,7 @@ static unsigned long mmap_rnd(void)
9003 return rnd << PAGE_SHIFT;
9004 }
9005
9006 -static inline unsigned long mmap_base(void)
9007 +static inline unsigned long mmap_base(struct mm_struct *mm)
9008 {
9009 unsigned long gap = rlimit(RLIMIT_STACK);
9010
9011 @@ -76,7 +80,7 @@ static inline unsigned long mmap_base(void)
9012 else if (gap > MAX_GAP)
9013 gap = MAX_GAP;
9014
9015 - return PAGE_ALIGN(TASK_SIZE - gap - mmap_rnd());
9016 + return PAGE_ALIGN(TASK_SIZE - gap - mmap_rnd(mm));
9017 }
9018
9019 /*
9020 @@ -91,9 +95,21 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
9021 */
9022 if (mmap_is_legacy()) {
9023 mm->mmap_base = TASK_UNMAPPED_BASE;
9024 +
9025 +#ifdef CONFIG_PAX_RANDMMAP
9026 + if (mm->pax_flags & MF_PAX_RANDMMAP)
9027 + mm->mmap_base += mm->delta_mmap;
9028 +#endif
9029 +
9030 mm->get_unmapped_area = arch_get_unmapped_area;
9031 } else {
9032 - mm->mmap_base = mmap_base();
9033 + mm->mmap_base = mmap_base(mm);
9034 +
9035 +#ifdef CONFIG_PAX_RANDMMAP
9036 + if (mm->pax_flags & MF_PAX_RANDMMAP)
9037 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
9038 +#endif
9039 +
9040 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
9041 }
9042 }
9043 diff --git a/arch/powerpc/mm/slice.c b/arch/powerpc/mm/slice.c
9044 index b0c75cc..ef7fb93 100644
9045 --- a/arch/powerpc/mm/slice.c
9046 +++ b/arch/powerpc/mm/slice.c
9047 @@ -103,7 +103,7 @@ static int slice_area_is_free(struct mm_struct *mm, unsigned long addr,
9048 if ((mm->task_size - len) < addr)
9049 return 0;
9050 vma = find_vma(mm, addr);
9051 - return (!vma || (addr + len) <= vma->vm_start);
9052 + return check_heap_stack_gap(vma, addr, len, 0);
9053 }
9054
9055 static int slice_low_has_vma(struct mm_struct *mm, unsigned long slice)
9056 @@ -277,6 +277,12 @@ static unsigned long slice_find_area_bottomup(struct mm_struct *mm,
9057 info.align_offset = 0;
9058
9059 addr = TASK_UNMAPPED_BASE;
9060 +
9061 +#ifdef CONFIG_PAX_RANDMMAP
9062 + if (mm->pax_flags & MF_PAX_RANDMMAP)
9063 + addr += mm->delta_mmap;
9064 +#endif
9065 +
9066 while (addr < TASK_SIZE) {
9067 info.low_limit = addr;
9068 if (!slice_scan_available(addr, available, 1, &addr))
9069 @@ -410,6 +416,11 @@ unsigned long slice_get_unmapped_area(unsigned long addr, unsigned long len,
9070 if (fixed && addr > (mm->task_size - len))
9071 return -ENOMEM;
9072
9073 +#ifdef CONFIG_PAX_RANDMMAP
9074 + if (!fixed && (mm->pax_flags & MF_PAX_RANDMMAP))
9075 + addr = 0;
9076 +#endif
9077 +
9078 /* If hint, make sure it matches our alignment restrictions */
9079 if (!fixed && addr) {
9080 addr = _ALIGN_UP(addr, 1ul << pshift);
9081 diff --git a/arch/powerpc/platforms/cell/celleb_scc_pciex.c b/arch/powerpc/platforms/cell/celleb_scc_pciex.c
9082 index 4278acf..67fd0e6 100644
9083 --- a/arch/powerpc/platforms/cell/celleb_scc_pciex.c
9084 +++ b/arch/powerpc/platforms/cell/celleb_scc_pciex.c
9085 @@ -400,8 +400,8 @@ static int scc_pciex_write_config(struct pci_bus *bus, unsigned int devfn,
9086 }
9087
9088 static struct pci_ops scc_pciex_pci_ops = {
9089 - scc_pciex_read_config,
9090 - scc_pciex_write_config,
9091 + .read = scc_pciex_read_config,
9092 + .write = scc_pciex_write_config,
9093 };
9094
9095 static void pciex_clear_intr_all(unsigned int __iomem *base)
9096 diff --git a/arch/powerpc/platforms/cell/spufs/file.c b/arch/powerpc/platforms/cell/spufs/file.c
9097 index 9098692..3d54cd1 100644
9098 --- a/arch/powerpc/platforms/cell/spufs/file.c
9099 +++ b/arch/powerpc/platforms/cell/spufs/file.c
9100 @@ -280,9 +280,9 @@ spufs_mem_mmap_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
9101 return VM_FAULT_NOPAGE;
9102 }
9103
9104 -static int spufs_mem_mmap_access(struct vm_area_struct *vma,
9105 +static ssize_t spufs_mem_mmap_access(struct vm_area_struct *vma,
9106 unsigned long address,
9107 - void *buf, int len, int write)
9108 + void *buf, size_t len, int write)
9109 {
9110 struct spu_context *ctx = vma->vm_file->private_data;
9111 unsigned long offset = address - vma->vm_start;
9112 diff --git a/arch/s390/include/asm/atomic.h b/arch/s390/include/asm/atomic.h
9113 index 1d47061..0714963 100644
9114 --- a/arch/s390/include/asm/atomic.h
9115 +++ b/arch/s390/include/asm/atomic.h
9116 @@ -412,6 +412,16 @@ static inline long long atomic64_dec_if_positive(atomic64_t *v)
9117 #define atomic64_dec_and_test(_v) (atomic64_sub_return(1, _v) == 0)
9118 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
9119
9120 +#define atomic64_read_unchecked(v) atomic64_read(v)
9121 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
9122 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
9123 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
9124 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
9125 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
9126 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
9127 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
9128 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
9129 +
9130 #define smp_mb__before_atomic_dec() smp_mb()
9131 #define smp_mb__after_atomic_dec() smp_mb()
9132 #define smp_mb__before_atomic_inc() smp_mb()
9133 diff --git a/arch/s390/include/asm/barrier.h b/arch/s390/include/asm/barrier.h
9134 index 578680f..0eb3b11 100644
9135 --- a/arch/s390/include/asm/barrier.h
9136 +++ b/arch/s390/include/asm/barrier.h
9137 @@ -36,7 +36,7 @@
9138 do { \
9139 compiletime_assert_atomic_type(*p); \
9140 barrier(); \
9141 - ACCESS_ONCE(*p) = (v); \
9142 + ACCESS_ONCE_RW(*p) = (v); \
9143 } while (0)
9144
9145 #define smp_load_acquire(p) \
9146 diff --git a/arch/s390/include/asm/cache.h b/arch/s390/include/asm/cache.h
9147 index 4d7ccac..d03d0ad 100644
9148 --- a/arch/s390/include/asm/cache.h
9149 +++ b/arch/s390/include/asm/cache.h
9150 @@ -9,8 +9,10 @@
9151 #ifndef __ARCH_S390_CACHE_H
9152 #define __ARCH_S390_CACHE_H
9153
9154 -#define L1_CACHE_BYTES 256
9155 +#include <linux/const.h>
9156 +
9157 #define L1_CACHE_SHIFT 8
9158 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
9159 #define NET_SKB_PAD 32
9160
9161 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
9162 diff --git a/arch/s390/include/asm/elf.h b/arch/s390/include/asm/elf.h
9163 index 78f4f87..598ce39 100644
9164 --- a/arch/s390/include/asm/elf.h
9165 +++ b/arch/s390/include/asm/elf.h
9166 @@ -162,8 +162,14 @@ extern unsigned int vdso_enabled;
9167 the loader. We need to make sure that it is out of the way of the program
9168 that it will "exec", and that there is sufficient room for the brk. */
9169
9170 -extern unsigned long randomize_et_dyn(unsigned long base);
9171 -#define ELF_ET_DYN_BASE (randomize_et_dyn(STACK_TOP / 3 * 2))
9172 +#define ELF_ET_DYN_BASE (STACK_TOP / 3 * 2)
9173 +
9174 +#ifdef CONFIG_PAX_ASLR
9175 +#define PAX_ELF_ET_DYN_BASE (test_thread_flag(TIF_31BIT) ? 0x10000UL : 0x80000000UL)
9176 +
9177 +#define PAX_DELTA_MMAP_LEN (test_thread_flag(TIF_31BIT) ? 15 : 26)
9178 +#define PAX_DELTA_STACK_LEN (test_thread_flag(TIF_31BIT) ? 15 : 26)
9179 +#endif
9180
9181 /* This yields a mask that user programs can use to figure out what
9182 instruction set this CPU supports. */
9183 @@ -222,9 +228,6 @@ struct linux_binprm;
9184 #define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1
9185 int arch_setup_additional_pages(struct linux_binprm *, int);
9186
9187 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
9188 -#define arch_randomize_brk arch_randomize_brk
9189 -
9190 void *fill_cpu_elf_notes(void *ptr, struct save_area *sa);
9191
9192 #endif
9193 diff --git a/arch/s390/include/asm/exec.h b/arch/s390/include/asm/exec.h
9194 index c4a93d6..4d2a9b4 100644
9195 --- a/arch/s390/include/asm/exec.h
9196 +++ b/arch/s390/include/asm/exec.h
9197 @@ -7,6 +7,6 @@
9198 #ifndef __ASM_EXEC_H
9199 #define __ASM_EXEC_H
9200
9201 -extern unsigned long arch_align_stack(unsigned long sp);
9202 +#define arch_align_stack(x) ((x) & ~0xfUL)
9203
9204 #endif /* __ASM_EXEC_H */
9205 diff --git a/arch/s390/include/asm/uaccess.h b/arch/s390/include/asm/uaccess.h
9206 index 1be64a1..086839d1 100644
9207 --- a/arch/s390/include/asm/uaccess.h
9208 +++ b/arch/s390/include/asm/uaccess.h
9209 @@ -59,6 +59,7 @@ static inline int __range_ok(unsigned long addr, unsigned long size)
9210 __range_ok((unsigned long)(addr), (size)); \
9211 })
9212
9213 +#define access_ok_noprefault(type, addr, size) access_ok((type), (addr), (size))
9214 #define access_ok(type, addr, size) __access_ok(addr, size)
9215
9216 /*
9217 @@ -245,6 +246,10 @@ static inline unsigned long __must_check
9218 copy_to_user(void __user *to, const void *from, unsigned long n)
9219 {
9220 might_fault();
9221 +
9222 + if ((long)n < 0)
9223 + return n;
9224 +
9225 return __copy_to_user(to, from, n);
9226 }
9227
9228 @@ -273,10 +278,14 @@ __compiletime_warning("copy_from_user() buffer size is not provably correct")
9229 static inline unsigned long __must_check
9230 copy_from_user(void *to, const void __user *from, unsigned long n)
9231 {
9232 - unsigned int sz = __compiletime_object_size(to);
9233 + size_t sz = __compiletime_object_size(to);
9234
9235 might_fault();
9236 - if (unlikely(sz != -1 && sz < n)) {
9237 +
9238 + if ((long)n < 0)
9239 + return n;
9240 +
9241 + if (unlikely(sz != (size_t)-1 && sz < n)) {
9242 copy_from_user_overflow();
9243 return n;
9244 }
9245 diff --git a/arch/s390/kernel/module.c b/arch/s390/kernel/module.c
9246 index b89b591..fd9609d 100644
9247 --- a/arch/s390/kernel/module.c
9248 +++ b/arch/s390/kernel/module.c
9249 @@ -169,11 +169,11 @@ int module_frob_arch_sections(Elf_Ehdr *hdr, Elf_Shdr *sechdrs,
9250
9251 /* Increase core size by size of got & plt and set start
9252 offsets for got and plt. */
9253 - me->core_size = ALIGN(me->core_size, 4);
9254 - me->arch.got_offset = me->core_size;
9255 - me->core_size += me->arch.got_size;
9256 - me->arch.plt_offset = me->core_size;
9257 - me->core_size += me->arch.plt_size;
9258 + me->core_size_rw = ALIGN(me->core_size_rw, 4);
9259 + me->arch.got_offset = me->core_size_rw;
9260 + me->core_size_rw += me->arch.got_size;
9261 + me->arch.plt_offset = me->core_size_rx;
9262 + me->core_size_rx += me->arch.plt_size;
9263 return 0;
9264 }
9265
9266 @@ -289,7 +289,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
9267 if (info->got_initialized == 0) {
9268 Elf_Addr *gotent;
9269
9270 - gotent = me->module_core + me->arch.got_offset +
9271 + gotent = me->module_core_rw + me->arch.got_offset +
9272 info->got_offset;
9273 *gotent = val;
9274 info->got_initialized = 1;
9275 @@ -312,7 +312,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
9276 rc = apply_rela_bits(loc, val, 0, 64, 0);
9277 else if (r_type == R_390_GOTENT ||
9278 r_type == R_390_GOTPLTENT) {
9279 - val += (Elf_Addr) me->module_core - loc;
9280 + val += (Elf_Addr) me->module_core_rw - loc;
9281 rc = apply_rela_bits(loc, val, 1, 32, 1);
9282 }
9283 break;
9284 @@ -325,7 +325,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
9285 case R_390_PLTOFF64: /* 16 bit offset from GOT to PLT. */
9286 if (info->plt_initialized == 0) {
9287 unsigned int *ip;
9288 - ip = me->module_core + me->arch.plt_offset +
9289 + ip = me->module_core_rx + me->arch.plt_offset +
9290 info->plt_offset;
9291 #ifndef CONFIG_64BIT
9292 ip[0] = 0x0d105810; /* basr 1,0; l 1,6(1); br 1 */
9293 @@ -350,7 +350,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
9294 val - loc + 0xffffUL < 0x1ffffeUL) ||
9295 (r_type == R_390_PLT32DBL &&
9296 val - loc + 0xffffffffULL < 0x1fffffffeULL)))
9297 - val = (Elf_Addr) me->module_core +
9298 + val = (Elf_Addr) me->module_core_rx +
9299 me->arch.plt_offset +
9300 info->plt_offset;
9301 val += rela->r_addend - loc;
9302 @@ -372,7 +372,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
9303 case R_390_GOTOFF32: /* 32 bit offset to GOT. */
9304 case R_390_GOTOFF64: /* 64 bit offset to GOT. */
9305 val = val + rela->r_addend -
9306 - ((Elf_Addr) me->module_core + me->arch.got_offset);
9307 + ((Elf_Addr) me->module_core_rw + me->arch.got_offset);
9308 if (r_type == R_390_GOTOFF16)
9309 rc = apply_rela_bits(loc, val, 0, 16, 0);
9310 else if (r_type == R_390_GOTOFF32)
9311 @@ -382,7 +382,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
9312 break;
9313 case R_390_GOTPC: /* 32 bit PC relative offset to GOT. */
9314 case R_390_GOTPCDBL: /* 32 bit PC rel. off. to GOT shifted by 1. */
9315 - val = (Elf_Addr) me->module_core + me->arch.got_offset +
9316 + val = (Elf_Addr) me->module_core_rw + me->arch.got_offset +
9317 rela->r_addend - loc;
9318 if (r_type == R_390_GOTPC)
9319 rc = apply_rela_bits(loc, val, 1, 32, 0);
9320 diff --git a/arch/s390/kernel/process.c b/arch/s390/kernel/process.c
9321 index dd14532..1dfc145 100644
9322 --- a/arch/s390/kernel/process.c
9323 +++ b/arch/s390/kernel/process.c
9324 @@ -242,37 +242,3 @@ unsigned long get_wchan(struct task_struct *p)
9325 }
9326 return 0;
9327 }
9328 -
9329 -unsigned long arch_align_stack(unsigned long sp)
9330 -{
9331 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
9332 - sp -= get_random_int() & ~PAGE_MASK;
9333 - return sp & ~0xf;
9334 -}
9335 -
9336 -static inline unsigned long brk_rnd(void)
9337 -{
9338 - /* 8MB for 32bit, 1GB for 64bit */
9339 - if (is_32bit_task())
9340 - return (get_random_int() & 0x7ffUL) << PAGE_SHIFT;
9341 - else
9342 - return (get_random_int() & 0x3ffffUL) << PAGE_SHIFT;
9343 -}
9344 -
9345 -unsigned long arch_randomize_brk(struct mm_struct *mm)
9346 -{
9347 - unsigned long ret;
9348 -
9349 - ret = PAGE_ALIGN(mm->brk + brk_rnd());
9350 - return (ret > mm->brk) ? ret : mm->brk;
9351 -}
9352 -
9353 -unsigned long randomize_et_dyn(unsigned long base)
9354 -{
9355 - unsigned long ret;
9356 -
9357 - if (!(current->flags & PF_RANDOMIZE))
9358 - return base;
9359 - ret = PAGE_ALIGN(base + brk_rnd());
9360 - return (ret > base) ? ret : base;
9361 -}
9362 diff --git a/arch/s390/mm/mmap.c b/arch/s390/mm/mmap.c
9363 index 9b436c2..54fbf0a 100644
9364 --- a/arch/s390/mm/mmap.c
9365 +++ b/arch/s390/mm/mmap.c
9366 @@ -95,9 +95,21 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
9367 */
9368 if (mmap_is_legacy()) {
9369 mm->mmap_base = mmap_base_legacy();
9370 +
9371 +#ifdef CONFIG_PAX_RANDMMAP
9372 + if (mm->pax_flags & MF_PAX_RANDMMAP)
9373 + mm->mmap_base += mm->delta_mmap;
9374 +#endif
9375 +
9376 mm->get_unmapped_area = arch_get_unmapped_area;
9377 } else {
9378 mm->mmap_base = mmap_base();
9379 +
9380 +#ifdef CONFIG_PAX_RANDMMAP
9381 + if (mm->pax_flags & MF_PAX_RANDMMAP)
9382 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
9383 +#endif
9384 +
9385 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
9386 }
9387 }
9388 @@ -170,9 +182,21 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
9389 */
9390 if (mmap_is_legacy()) {
9391 mm->mmap_base = mmap_base_legacy();
9392 +
9393 +#ifdef CONFIG_PAX_RANDMMAP
9394 + if (mm->pax_flags & MF_PAX_RANDMMAP)
9395 + mm->mmap_base += mm->delta_mmap;
9396 +#endif
9397 +
9398 mm->get_unmapped_area = s390_get_unmapped_area;
9399 } else {
9400 mm->mmap_base = mmap_base();
9401 +
9402 +#ifdef CONFIG_PAX_RANDMMAP
9403 + if (mm->pax_flags & MF_PAX_RANDMMAP)
9404 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
9405 +#endif
9406 +
9407 mm->get_unmapped_area = s390_get_unmapped_area_topdown;
9408 }
9409 }
9410 diff --git a/arch/score/include/asm/cache.h b/arch/score/include/asm/cache.h
9411 index ae3d59f..f65f075 100644
9412 --- a/arch/score/include/asm/cache.h
9413 +++ b/arch/score/include/asm/cache.h
9414 @@ -1,7 +1,9 @@
9415 #ifndef _ASM_SCORE_CACHE_H
9416 #define _ASM_SCORE_CACHE_H
9417
9418 +#include <linux/const.h>
9419 +
9420 #define L1_CACHE_SHIFT 4
9421 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
9422 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
9423
9424 #endif /* _ASM_SCORE_CACHE_H */
9425 diff --git a/arch/score/include/asm/exec.h b/arch/score/include/asm/exec.h
9426 index f9f3cd5..58ff438 100644
9427 --- a/arch/score/include/asm/exec.h
9428 +++ b/arch/score/include/asm/exec.h
9429 @@ -1,6 +1,6 @@
9430 #ifndef _ASM_SCORE_EXEC_H
9431 #define _ASM_SCORE_EXEC_H
9432
9433 -extern unsigned long arch_align_stack(unsigned long sp);
9434 +#define arch_align_stack(x) (x)
9435
9436 #endif /* _ASM_SCORE_EXEC_H */
9437 diff --git a/arch/score/kernel/process.c b/arch/score/kernel/process.c
9438 index a1519ad3..e8ac1ff 100644
9439 --- a/arch/score/kernel/process.c
9440 +++ b/arch/score/kernel/process.c
9441 @@ -116,8 +116,3 @@ unsigned long get_wchan(struct task_struct *task)
9442
9443 return task_pt_regs(task)->cp0_epc;
9444 }
9445 -
9446 -unsigned long arch_align_stack(unsigned long sp)
9447 -{
9448 - return sp;
9449 -}
9450 diff --git a/arch/sh/include/asm/cache.h b/arch/sh/include/asm/cache.h
9451 index ef9e555..331bd29 100644
9452 --- a/arch/sh/include/asm/cache.h
9453 +++ b/arch/sh/include/asm/cache.h
9454 @@ -9,10 +9,11 @@
9455 #define __ASM_SH_CACHE_H
9456 #ifdef __KERNEL__
9457
9458 +#include <linux/const.h>
9459 #include <linux/init.h>
9460 #include <cpu/cache.h>
9461
9462 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
9463 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
9464
9465 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
9466
9467 diff --git a/arch/sh/mm/mmap.c b/arch/sh/mm/mmap.c
9468 index 6777177..cb5e44f 100644
9469 --- a/arch/sh/mm/mmap.c
9470 +++ b/arch/sh/mm/mmap.c
9471 @@ -36,6 +36,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
9472 struct mm_struct *mm = current->mm;
9473 struct vm_area_struct *vma;
9474 int do_colour_align;
9475 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
9476 struct vm_unmapped_area_info info;
9477
9478 if (flags & MAP_FIXED) {
9479 @@ -55,6 +56,10 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
9480 if (filp || (flags & MAP_SHARED))
9481 do_colour_align = 1;
9482
9483 +#ifdef CONFIG_PAX_RANDMMAP
9484 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
9485 +#endif
9486 +
9487 if (addr) {
9488 if (do_colour_align)
9489 addr = COLOUR_ALIGN(addr, pgoff);
9490 @@ -62,14 +67,13 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
9491 addr = PAGE_ALIGN(addr);
9492
9493 vma = find_vma(mm, addr);
9494 - if (TASK_SIZE - len >= addr &&
9495 - (!vma || addr + len <= vma->vm_start))
9496 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
9497 return addr;
9498 }
9499
9500 info.flags = 0;
9501 info.length = len;
9502 - info.low_limit = TASK_UNMAPPED_BASE;
9503 + info.low_limit = mm->mmap_base;
9504 info.high_limit = TASK_SIZE;
9505 info.align_mask = do_colour_align ? (PAGE_MASK & shm_align_mask) : 0;
9506 info.align_offset = pgoff << PAGE_SHIFT;
9507 @@ -85,6 +89,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
9508 struct mm_struct *mm = current->mm;
9509 unsigned long addr = addr0;
9510 int do_colour_align;
9511 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
9512 struct vm_unmapped_area_info info;
9513
9514 if (flags & MAP_FIXED) {
9515 @@ -104,6 +109,10 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
9516 if (filp || (flags & MAP_SHARED))
9517 do_colour_align = 1;
9518
9519 +#ifdef CONFIG_PAX_RANDMMAP
9520 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
9521 +#endif
9522 +
9523 /* requesting a specific address */
9524 if (addr) {
9525 if (do_colour_align)
9526 @@ -112,8 +121,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
9527 addr = PAGE_ALIGN(addr);
9528
9529 vma = find_vma(mm, addr);
9530 - if (TASK_SIZE - len >= addr &&
9531 - (!vma || addr + len <= vma->vm_start))
9532 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
9533 return addr;
9534 }
9535
9536 @@ -135,6 +143,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
9537 VM_BUG_ON(addr != -ENOMEM);
9538 info.flags = 0;
9539 info.low_limit = TASK_UNMAPPED_BASE;
9540 +
9541 +#ifdef CONFIG_PAX_RANDMMAP
9542 + if (mm->pax_flags & MF_PAX_RANDMMAP)
9543 + info.low_limit += mm->delta_mmap;
9544 +#endif
9545 +
9546 info.high_limit = TASK_SIZE;
9547 addr = vm_unmapped_area(&info);
9548 }
9549 diff --git a/arch/sparc/include/asm/atomic_64.h b/arch/sparc/include/asm/atomic_64.h
9550 index be56a24..443328f 100644
9551 --- a/arch/sparc/include/asm/atomic_64.h
9552 +++ b/arch/sparc/include/asm/atomic_64.h
9553 @@ -14,18 +14,40 @@
9554 #define ATOMIC64_INIT(i) { (i) }
9555
9556 #define atomic_read(v) (*(volatile int *)&(v)->counter)
9557 +static inline int atomic_read_unchecked(const atomic_unchecked_t *v)
9558 +{
9559 + return v->counter;
9560 +}
9561 #define atomic64_read(v) (*(volatile long *)&(v)->counter)
9562 +static inline long atomic64_read_unchecked(const atomic64_unchecked_t *v)
9563 +{
9564 + return v->counter;
9565 +}
9566
9567 #define atomic_set(v, i) (((v)->counter) = i)
9568 +static inline void atomic_set_unchecked(atomic_unchecked_t *v, int i)
9569 +{
9570 + v->counter = i;
9571 +}
9572 #define atomic64_set(v, i) (((v)->counter) = i)
9573 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long i)
9574 +{
9575 + v->counter = i;
9576 +}
9577
9578 extern void atomic_add(int, atomic_t *);
9579 +extern void atomic_add_unchecked(int, atomic_unchecked_t *);
9580 extern void atomic64_add(long, atomic64_t *);
9581 +extern void atomic64_add_unchecked(long, atomic64_unchecked_t *);
9582 extern void atomic_sub(int, atomic_t *);
9583 +extern void atomic_sub_unchecked(int, atomic_unchecked_t *);
9584 extern void atomic64_sub(long, atomic64_t *);
9585 +extern void atomic64_sub_unchecked(long, atomic64_unchecked_t *);
9586
9587 extern int atomic_add_ret(int, atomic_t *);
9588 +extern int atomic_add_ret_unchecked(int, atomic_unchecked_t *);
9589 extern long atomic64_add_ret(long, atomic64_t *);
9590 +extern long atomic64_add_ret_unchecked(long, atomic64_unchecked_t *);
9591 extern int atomic_sub_ret(int, atomic_t *);
9592 extern long atomic64_sub_ret(long, atomic64_t *);
9593
9594 @@ -33,13 +55,29 @@ extern long atomic64_sub_ret(long, atomic64_t *);
9595 #define atomic64_dec_return(v) atomic64_sub_ret(1, v)
9596
9597 #define atomic_inc_return(v) atomic_add_ret(1, v)
9598 +static inline int atomic_inc_return_unchecked(atomic_unchecked_t *v)
9599 +{
9600 + return atomic_add_ret_unchecked(1, v);
9601 +}
9602 #define atomic64_inc_return(v) atomic64_add_ret(1, v)
9603 +static inline long atomic64_inc_return_unchecked(atomic64_unchecked_t *v)
9604 +{
9605 + return atomic64_add_ret_unchecked(1, v);
9606 +}
9607
9608 #define atomic_sub_return(i, v) atomic_sub_ret(i, v)
9609 #define atomic64_sub_return(i, v) atomic64_sub_ret(i, v)
9610
9611 #define atomic_add_return(i, v) atomic_add_ret(i, v)
9612 +static inline int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
9613 +{
9614 + return atomic_add_ret_unchecked(i, v);
9615 +}
9616 #define atomic64_add_return(i, v) atomic64_add_ret(i, v)
9617 +static inline long atomic64_add_return_unchecked(long i, atomic64_unchecked_t *v)
9618 +{
9619 + return atomic64_add_ret_unchecked(i, v);
9620 +}
9621
9622 /*
9623 * atomic_inc_and_test - increment and test
9624 @@ -50,6 +88,10 @@ extern long atomic64_sub_ret(long, atomic64_t *);
9625 * other cases.
9626 */
9627 #define atomic_inc_and_test(v) (atomic_inc_return(v) == 0)
9628 +static inline int atomic_inc_and_test_unchecked(atomic_unchecked_t *v)
9629 +{
9630 + return atomic_inc_return_unchecked(v) == 0;
9631 +}
9632 #define atomic64_inc_and_test(v) (atomic64_inc_return(v) == 0)
9633
9634 #define atomic_sub_and_test(i, v) (atomic_sub_ret(i, v) == 0)
9635 @@ -59,25 +101,60 @@ extern long atomic64_sub_ret(long, atomic64_t *);
9636 #define atomic64_dec_and_test(v) (atomic64_sub_ret(1, v) == 0)
9637
9638 #define atomic_inc(v) atomic_add(1, v)
9639 +static inline void atomic_inc_unchecked(atomic_unchecked_t *v)
9640 +{
9641 + atomic_add_unchecked(1, v);
9642 +}
9643 #define atomic64_inc(v) atomic64_add(1, v)
9644 +static inline void atomic64_inc_unchecked(atomic64_unchecked_t *v)
9645 +{
9646 + atomic64_add_unchecked(1, v);
9647 +}
9648
9649 #define atomic_dec(v) atomic_sub(1, v)
9650 +static inline void atomic_dec_unchecked(atomic_unchecked_t *v)
9651 +{
9652 + atomic_sub_unchecked(1, v);
9653 +}
9654 #define atomic64_dec(v) atomic64_sub(1, v)
9655 +static inline void atomic64_dec_unchecked(atomic64_unchecked_t *v)
9656 +{
9657 + atomic64_sub_unchecked(1, v);
9658 +}
9659
9660 #define atomic_add_negative(i, v) (atomic_add_ret(i, v) < 0)
9661 #define atomic64_add_negative(i, v) (atomic64_add_ret(i, v) < 0)
9662
9663 #define atomic_cmpxchg(v, o, n) (cmpxchg(&((v)->counter), (o), (n)))
9664 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *v, int old, int new)
9665 +{
9666 + return cmpxchg(&v->counter, old, new);
9667 +}
9668 #define atomic_xchg(v, new) (xchg(&((v)->counter), new))
9669 +static inline int atomic_xchg_unchecked(atomic_unchecked_t *v, int new)
9670 +{
9671 + return xchg(&v->counter, new);
9672 +}
9673
9674 static inline int __atomic_add_unless(atomic_t *v, int a, int u)
9675 {
9676 - int c, old;
9677 + int c, old, new;
9678 c = atomic_read(v);
9679 for (;;) {
9680 - if (unlikely(c == (u)))
9681 + if (unlikely(c == u))
9682 break;
9683 - old = atomic_cmpxchg((v), c, c + (a));
9684 +
9685 + asm volatile("addcc %2, %0, %0\n"
9686 +
9687 +#ifdef CONFIG_PAX_REFCOUNT
9688 + "tvs %%icc, 6\n"
9689 +#endif
9690 +
9691 + : "=r" (new)
9692 + : "0" (c), "ir" (a)
9693 + : "cc");
9694 +
9695 + old = atomic_cmpxchg(v, c, new);
9696 if (likely(old == c))
9697 break;
9698 c = old;
9699 @@ -88,20 +165,35 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
9700 #define atomic64_cmpxchg(v, o, n) \
9701 ((__typeof__((v)->counter))cmpxchg(&((v)->counter), (o), (n)))
9702 #define atomic64_xchg(v, new) (xchg(&((v)->counter), new))
9703 +static inline long atomic64_xchg_unchecked(atomic64_unchecked_t *v, long new)
9704 +{
9705 + return xchg(&v->counter, new);
9706 +}
9707
9708 static inline long atomic64_add_unless(atomic64_t *v, long a, long u)
9709 {
9710 - long c, old;
9711 + long c, old, new;
9712 c = atomic64_read(v);
9713 for (;;) {
9714 - if (unlikely(c == (u)))
9715 + if (unlikely(c == u))
9716 break;
9717 - old = atomic64_cmpxchg((v), c, c + (a));
9718 +
9719 + asm volatile("addcc %2, %0, %0\n"
9720 +
9721 +#ifdef CONFIG_PAX_REFCOUNT
9722 + "tvs %%xcc, 6\n"
9723 +#endif
9724 +
9725 + : "=r" (new)
9726 + : "0" (c), "ir" (a)
9727 + : "cc");
9728 +
9729 + old = atomic64_cmpxchg(v, c, new);
9730 if (likely(old == c))
9731 break;
9732 c = old;
9733 }
9734 - return c != (u);
9735 + return c != u;
9736 }
9737
9738 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
9739 diff --git a/arch/sparc/include/asm/barrier_64.h b/arch/sparc/include/asm/barrier_64.h
9740 index b5aad96..99d7465 100644
9741 --- a/arch/sparc/include/asm/barrier_64.h
9742 +++ b/arch/sparc/include/asm/barrier_64.h
9743 @@ -57,7 +57,7 @@ do { __asm__ __volatile__("ba,pt %%xcc, 1f\n\t" \
9744 do { \
9745 compiletime_assert_atomic_type(*p); \
9746 barrier(); \
9747 - ACCESS_ONCE(*p) = (v); \
9748 + ACCESS_ONCE_RW(*p) = (v); \
9749 } while (0)
9750
9751 #define smp_load_acquire(p) \
9752 diff --git a/arch/sparc/include/asm/cache.h b/arch/sparc/include/asm/cache.h
9753 index 5bb6991..5c2132e 100644
9754 --- a/arch/sparc/include/asm/cache.h
9755 +++ b/arch/sparc/include/asm/cache.h
9756 @@ -7,10 +7,12 @@
9757 #ifndef _SPARC_CACHE_H
9758 #define _SPARC_CACHE_H
9759
9760 +#include <linux/const.h>
9761 +
9762 #define ARCH_SLAB_MINALIGN __alignof__(unsigned long long)
9763
9764 #define L1_CACHE_SHIFT 5
9765 -#define L1_CACHE_BYTES 32
9766 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
9767
9768 #ifdef CONFIG_SPARC32
9769 #define SMP_CACHE_BYTES_SHIFT 5
9770 diff --git a/arch/sparc/include/asm/elf_32.h b/arch/sparc/include/asm/elf_32.h
9771 index a24e41f..47677ff 100644
9772 --- a/arch/sparc/include/asm/elf_32.h
9773 +++ b/arch/sparc/include/asm/elf_32.h
9774 @@ -114,6 +114,13 @@ typedef struct {
9775
9776 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE)
9777
9778 +#ifdef CONFIG_PAX_ASLR
9779 +#define PAX_ELF_ET_DYN_BASE 0x10000UL
9780 +
9781 +#define PAX_DELTA_MMAP_LEN 16
9782 +#define PAX_DELTA_STACK_LEN 16
9783 +#endif
9784 +
9785 /* This yields a mask that user programs can use to figure out what
9786 instruction set this cpu supports. This can NOT be done in userspace
9787 on Sparc. */
9788 diff --git a/arch/sparc/include/asm/elf_64.h b/arch/sparc/include/asm/elf_64.h
9789 index 370ca1e..d4f4a98 100644
9790 --- a/arch/sparc/include/asm/elf_64.h
9791 +++ b/arch/sparc/include/asm/elf_64.h
9792 @@ -189,6 +189,13 @@ typedef struct {
9793 #define ELF_ET_DYN_BASE 0x0000010000000000UL
9794 #define COMPAT_ELF_ET_DYN_BASE 0x0000000070000000UL
9795
9796 +#ifdef CONFIG_PAX_ASLR
9797 +#define PAX_ELF_ET_DYN_BASE (test_thread_flag(TIF_32BIT) ? 0x10000UL : 0x100000UL)
9798 +
9799 +#define PAX_DELTA_MMAP_LEN (test_thread_flag(TIF_32BIT) ? 14 : 28)
9800 +#define PAX_DELTA_STACK_LEN (test_thread_flag(TIF_32BIT) ? 15 : 29)
9801 +#endif
9802 +
9803 extern unsigned long sparc64_elf_hwcap;
9804 #define ELF_HWCAP sparc64_elf_hwcap
9805
9806 diff --git a/arch/sparc/include/asm/pgalloc_32.h b/arch/sparc/include/asm/pgalloc_32.h
9807 index 9b1c36d..209298b 100644
9808 --- a/arch/sparc/include/asm/pgalloc_32.h
9809 +++ b/arch/sparc/include/asm/pgalloc_32.h
9810 @@ -33,6 +33,7 @@ static inline void pgd_set(pgd_t * pgdp, pmd_t * pmdp)
9811 }
9812
9813 #define pgd_populate(MM, PGD, PMD) pgd_set(PGD, PMD)
9814 +#define pgd_populate_kernel(MM, PGD, PMD) pgd_populate((MM), (PGD), (PMD))
9815
9816 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm,
9817 unsigned long address)
9818 diff --git a/arch/sparc/include/asm/pgalloc_64.h b/arch/sparc/include/asm/pgalloc_64.h
9819 index bcfe063..b333142 100644
9820 --- a/arch/sparc/include/asm/pgalloc_64.h
9821 +++ b/arch/sparc/include/asm/pgalloc_64.h
9822 @@ -26,6 +26,7 @@ static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
9823 }
9824
9825 #define pud_populate(MM, PUD, PMD) pud_set(PUD, PMD)
9826 +#define pud_populate_kernel(MM, PUD, PMD) pud_populate((MM), (PUD), (PMD))
9827
9828 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long addr)
9829 {
9830 diff --git a/arch/sparc/include/asm/pgtable.h b/arch/sparc/include/asm/pgtable.h
9831 index 59ba6f6..4518128 100644
9832 --- a/arch/sparc/include/asm/pgtable.h
9833 +++ b/arch/sparc/include/asm/pgtable.h
9834 @@ -5,4 +5,8 @@
9835 #else
9836 #include <asm/pgtable_32.h>
9837 #endif
9838 +
9839 +#define ktla_ktva(addr) (addr)
9840 +#define ktva_ktla(addr) (addr)
9841 +
9842 #endif
9843 diff --git a/arch/sparc/include/asm/pgtable_32.h b/arch/sparc/include/asm/pgtable_32.h
9844 index 502f632..da1917f 100644
9845 --- a/arch/sparc/include/asm/pgtable_32.h
9846 +++ b/arch/sparc/include/asm/pgtable_32.h
9847 @@ -50,6 +50,9 @@ extern unsigned long calc_highpages(void);
9848 #define PAGE_SHARED SRMMU_PAGE_SHARED
9849 #define PAGE_COPY SRMMU_PAGE_COPY
9850 #define PAGE_READONLY SRMMU_PAGE_RDONLY
9851 +#define PAGE_SHARED_NOEXEC SRMMU_PAGE_SHARED_NOEXEC
9852 +#define PAGE_COPY_NOEXEC SRMMU_PAGE_COPY_NOEXEC
9853 +#define PAGE_READONLY_NOEXEC SRMMU_PAGE_RDONLY_NOEXEC
9854 #define PAGE_KERNEL SRMMU_PAGE_KERNEL
9855
9856 /* Top-level page directory - dummy used by init-mm.
9857 @@ -62,18 +65,18 @@ extern unsigned long ptr_in_current_pgd;
9858
9859 /* xwr */
9860 #define __P000 PAGE_NONE
9861 -#define __P001 PAGE_READONLY
9862 -#define __P010 PAGE_COPY
9863 -#define __P011 PAGE_COPY
9864 +#define __P001 PAGE_READONLY_NOEXEC
9865 +#define __P010 PAGE_COPY_NOEXEC
9866 +#define __P011 PAGE_COPY_NOEXEC
9867 #define __P100 PAGE_READONLY
9868 #define __P101 PAGE_READONLY
9869 #define __P110 PAGE_COPY
9870 #define __P111 PAGE_COPY
9871
9872 #define __S000 PAGE_NONE
9873 -#define __S001 PAGE_READONLY
9874 -#define __S010 PAGE_SHARED
9875 -#define __S011 PAGE_SHARED
9876 +#define __S001 PAGE_READONLY_NOEXEC
9877 +#define __S010 PAGE_SHARED_NOEXEC
9878 +#define __S011 PAGE_SHARED_NOEXEC
9879 #define __S100 PAGE_READONLY
9880 #define __S101 PAGE_READONLY
9881 #define __S110 PAGE_SHARED
9882 diff --git a/arch/sparc/include/asm/pgtsrmmu.h b/arch/sparc/include/asm/pgtsrmmu.h
9883 index 79da178..c2eede8 100644
9884 --- a/arch/sparc/include/asm/pgtsrmmu.h
9885 +++ b/arch/sparc/include/asm/pgtsrmmu.h
9886 @@ -115,6 +115,11 @@
9887 SRMMU_EXEC | SRMMU_REF)
9888 #define SRMMU_PAGE_RDONLY __pgprot(SRMMU_VALID | SRMMU_CACHE | \
9889 SRMMU_EXEC | SRMMU_REF)
9890 +
9891 +#define SRMMU_PAGE_SHARED_NOEXEC __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_WRITE | SRMMU_REF)
9892 +#define SRMMU_PAGE_COPY_NOEXEC __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_REF)
9893 +#define SRMMU_PAGE_RDONLY_NOEXEC __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_REF)
9894 +
9895 #define SRMMU_PAGE_KERNEL __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_PRIV | \
9896 SRMMU_DIRTY | SRMMU_REF)
9897
9898 diff --git a/arch/sparc/include/asm/spinlock_64.h b/arch/sparc/include/asm/spinlock_64.h
9899 index 9689176..63c18ea 100644
9900 --- a/arch/sparc/include/asm/spinlock_64.h
9901 +++ b/arch/sparc/include/asm/spinlock_64.h
9902 @@ -92,14 +92,19 @@ static inline void arch_spin_lock_flags(arch_spinlock_t *lock, unsigned long fla
9903
9904 /* Multi-reader locks, these are much saner than the 32-bit Sparc ones... */
9905
9906 -static void inline arch_read_lock(arch_rwlock_t *lock)
9907 +static inline void arch_read_lock(arch_rwlock_t *lock)
9908 {
9909 unsigned long tmp1, tmp2;
9910
9911 __asm__ __volatile__ (
9912 "1: ldsw [%2], %0\n"
9913 " brlz,pn %0, 2f\n"
9914 -"4: add %0, 1, %1\n"
9915 +"4: addcc %0, 1, %1\n"
9916 +
9917 +#ifdef CONFIG_PAX_REFCOUNT
9918 +" tvs %%icc, 6\n"
9919 +#endif
9920 +
9921 " cas [%2], %0, %1\n"
9922 " cmp %0, %1\n"
9923 " bne,pn %%icc, 1b\n"
9924 @@ -112,10 +117,10 @@ static void inline arch_read_lock(arch_rwlock_t *lock)
9925 " .previous"
9926 : "=&r" (tmp1), "=&r" (tmp2)
9927 : "r" (lock)
9928 - : "memory");
9929 + : "memory", "cc");
9930 }
9931
9932 -static int inline arch_read_trylock(arch_rwlock_t *lock)
9933 +static inline int arch_read_trylock(arch_rwlock_t *lock)
9934 {
9935 int tmp1, tmp2;
9936
9937 @@ -123,7 +128,12 @@ static int inline arch_read_trylock(arch_rwlock_t *lock)
9938 "1: ldsw [%2], %0\n"
9939 " brlz,a,pn %0, 2f\n"
9940 " mov 0, %0\n"
9941 -" add %0, 1, %1\n"
9942 +" addcc %0, 1, %1\n"
9943 +
9944 +#ifdef CONFIG_PAX_REFCOUNT
9945 +" tvs %%icc, 6\n"
9946 +#endif
9947 +
9948 " cas [%2], %0, %1\n"
9949 " cmp %0, %1\n"
9950 " bne,pn %%icc, 1b\n"
9951 @@ -136,13 +146,18 @@ static int inline arch_read_trylock(arch_rwlock_t *lock)
9952 return tmp1;
9953 }
9954
9955 -static void inline arch_read_unlock(arch_rwlock_t *lock)
9956 +static inline void arch_read_unlock(arch_rwlock_t *lock)
9957 {
9958 unsigned long tmp1, tmp2;
9959
9960 __asm__ __volatile__(
9961 "1: lduw [%2], %0\n"
9962 -" sub %0, 1, %1\n"
9963 +" subcc %0, 1, %1\n"
9964 +
9965 +#ifdef CONFIG_PAX_REFCOUNT
9966 +" tvs %%icc, 6\n"
9967 +#endif
9968 +
9969 " cas [%2], %0, %1\n"
9970 " cmp %0, %1\n"
9971 " bne,pn %%xcc, 1b\n"
9972 @@ -152,7 +167,7 @@ static void inline arch_read_unlock(arch_rwlock_t *lock)
9973 : "memory");
9974 }
9975
9976 -static void inline arch_write_lock(arch_rwlock_t *lock)
9977 +static inline void arch_write_lock(arch_rwlock_t *lock)
9978 {
9979 unsigned long mask, tmp1, tmp2;
9980
9981 @@ -177,7 +192,7 @@ static void inline arch_write_lock(arch_rwlock_t *lock)
9982 : "memory");
9983 }
9984
9985 -static void inline arch_write_unlock(arch_rwlock_t *lock)
9986 +static inline void arch_write_unlock(arch_rwlock_t *lock)
9987 {
9988 __asm__ __volatile__(
9989 " stw %%g0, [%0]"
9990 @@ -186,7 +201,7 @@ static void inline arch_write_unlock(arch_rwlock_t *lock)
9991 : "memory");
9992 }
9993
9994 -static int inline arch_write_trylock(arch_rwlock_t *lock)
9995 +static inline int arch_write_trylock(arch_rwlock_t *lock)
9996 {
9997 unsigned long mask, tmp1, tmp2, result;
9998
9999 diff --git a/arch/sparc/include/asm/thread_info_32.h b/arch/sparc/include/asm/thread_info_32.h
10000 index 96efa7a..16858bf 100644
10001 --- a/arch/sparc/include/asm/thread_info_32.h
10002 +++ b/arch/sparc/include/asm/thread_info_32.h
10003 @@ -49,6 +49,8 @@ struct thread_info {
10004 unsigned long w_saved;
10005
10006 struct restart_block restart_block;
10007 +
10008 + unsigned long lowest_stack;
10009 };
10010
10011 /*
10012 diff --git a/arch/sparc/include/asm/thread_info_64.h b/arch/sparc/include/asm/thread_info_64.h
10013 index a5f01ac..703b554 100644
10014 --- a/arch/sparc/include/asm/thread_info_64.h
10015 +++ b/arch/sparc/include/asm/thread_info_64.h
10016 @@ -63,6 +63,8 @@ struct thread_info {
10017 struct pt_regs *kern_una_regs;
10018 unsigned int kern_una_insn;
10019
10020 + unsigned long lowest_stack;
10021 +
10022 unsigned long fpregs[0] __attribute__ ((aligned(64)));
10023 };
10024
10025 @@ -188,12 +190,13 @@ register struct thread_info *current_thread_info_reg asm("g6");
10026 #define TIF_NEED_RESCHED 3 /* rescheduling necessary */
10027 /* flag bit 4 is available */
10028 #define TIF_UNALIGNED 5 /* allowed to do unaligned accesses */
10029 -/* flag bit 6 is available */
10030 +#define TIF_GRSEC_SETXID 6 /* update credentials on syscall entry/exit */
10031 #define TIF_32BIT 7 /* 32-bit binary */
10032 #define TIF_NOHZ 8 /* in adaptive nohz mode */
10033 #define TIF_SECCOMP 9 /* secure computing */
10034 #define TIF_SYSCALL_AUDIT 10 /* syscall auditing active */
10035 #define TIF_SYSCALL_TRACEPOINT 11 /* syscall tracepoint instrumentation */
10036 +
10037 /* NOTE: Thread flags >= 12 should be ones we have no interest
10038 * in using in assembly, else we can't use the mask as
10039 * an immediate value in instructions such as andcc.
10040 @@ -213,12 +216,18 @@ register struct thread_info *current_thread_info_reg asm("g6");
10041 #define _TIF_SYSCALL_AUDIT (1<<TIF_SYSCALL_AUDIT)
10042 #define _TIF_SYSCALL_TRACEPOINT (1<<TIF_SYSCALL_TRACEPOINT)
10043 #define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG)
10044 +#define _TIF_GRSEC_SETXID (1<<TIF_GRSEC_SETXID)
10045
10046 #define _TIF_USER_WORK_MASK ((0xff << TI_FLAG_WSAVED_SHIFT) | \
10047 _TIF_DO_NOTIFY_RESUME_MASK | \
10048 _TIF_NEED_RESCHED)
10049 #define _TIF_DO_NOTIFY_RESUME_MASK (_TIF_NOTIFY_RESUME | _TIF_SIGPENDING)
10050
10051 +#define _TIF_WORK_SYSCALL \
10052 + (_TIF_SYSCALL_TRACE | _TIF_SECCOMP | _TIF_SYSCALL_AUDIT | \
10053 + _TIF_SYSCALL_TRACEPOINT | _TIF_NOHZ | _TIF_GRSEC_SETXID)
10054 +
10055 +
10056 /*
10057 * Thread-synchronous status.
10058 *
10059 diff --git a/arch/sparc/include/asm/uaccess.h b/arch/sparc/include/asm/uaccess.h
10060 index 0167d26..767bb0c 100644
10061 --- a/arch/sparc/include/asm/uaccess.h
10062 +++ b/arch/sparc/include/asm/uaccess.h
10063 @@ -1,5 +1,6 @@
10064 #ifndef ___ASM_SPARC_UACCESS_H
10065 #define ___ASM_SPARC_UACCESS_H
10066 +
10067 #if defined(__sparc__) && defined(__arch64__)
10068 #include <asm/uaccess_64.h>
10069 #else
10070 diff --git a/arch/sparc/include/asm/uaccess_32.h b/arch/sparc/include/asm/uaccess_32.h
10071 index 53a28dd..50c38c3 100644
10072 --- a/arch/sparc/include/asm/uaccess_32.h
10073 +++ b/arch/sparc/include/asm/uaccess_32.h
10074 @@ -250,27 +250,46 @@ extern unsigned long __copy_user(void __user *to, const void __user *from, unsig
10075
10076 static inline unsigned long copy_to_user(void __user *to, const void *from, unsigned long n)
10077 {
10078 - if (n && __access_ok((unsigned long) to, n))
10079 + if ((long)n < 0)
10080 + return n;
10081 +
10082 + if (n && __access_ok((unsigned long) to, n)) {
10083 + if (!__builtin_constant_p(n))
10084 + check_object_size(from, n, true);
10085 return __copy_user(to, (__force void __user *) from, n);
10086 - else
10087 + } else
10088 return n;
10089 }
10090
10091 static inline unsigned long __copy_to_user(void __user *to, const void *from, unsigned long n)
10092 {
10093 + if ((long)n < 0)
10094 + return n;
10095 +
10096 + if (!__builtin_constant_p(n))
10097 + check_object_size(from, n, true);
10098 +
10099 return __copy_user(to, (__force void __user *) from, n);
10100 }
10101
10102 static inline unsigned long copy_from_user(void *to, const void __user *from, unsigned long n)
10103 {
10104 - if (n && __access_ok((unsigned long) from, n))
10105 + if ((long)n < 0)
10106 + return n;
10107 +
10108 + if (n && __access_ok((unsigned long) from, n)) {
10109 + if (!__builtin_constant_p(n))
10110 + check_object_size(to, n, false);
10111 return __copy_user((__force void __user *) to, from, n);
10112 - else
10113 + } else
10114 return n;
10115 }
10116
10117 static inline unsigned long __copy_from_user(void *to, const void __user *from, unsigned long n)
10118 {
10119 + if ((long)n < 0)
10120 + return n;
10121 +
10122 return __copy_user((__force void __user *) to, from, n);
10123 }
10124
10125 diff --git a/arch/sparc/include/asm/uaccess_64.h b/arch/sparc/include/asm/uaccess_64.h
10126 index ad7e178..c9e7423 100644
10127 --- a/arch/sparc/include/asm/uaccess_64.h
10128 +++ b/arch/sparc/include/asm/uaccess_64.h
10129 @@ -10,6 +10,7 @@
10130 #include <linux/compiler.h>
10131 #include <linux/string.h>
10132 #include <linux/thread_info.h>
10133 +#include <linux/kernel.h>
10134 #include <asm/asi.h>
10135 #include <asm/spitfire.h>
10136 #include <asm-generic/uaccess-unaligned.h>
10137 @@ -214,8 +215,15 @@ extern unsigned long copy_from_user_fixup(void *to, const void __user *from,
10138 static inline unsigned long __must_check
10139 copy_from_user(void *to, const void __user *from, unsigned long size)
10140 {
10141 - unsigned long ret = ___copy_from_user(to, from, size);
10142 + unsigned long ret;
10143
10144 + if ((long)size < 0 || size > INT_MAX)
10145 + return size;
10146 +
10147 + if (!__builtin_constant_p(size))
10148 + check_object_size(to, size, false);
10149 +
10150 + ret = ___copy_from_user(to, from, size);
10151 if (unlikely(ret))
10152 ret = copy_from_user_fixup(to, from, size);
10153
10154 @@ -231,8 +239,15 @@ extern unsigned long copy_to_user_fixup(void __user *to, const void *from,
10155 static inline unsigned long __must_check
10156 copy_to_user(void __user *to, const void *from, unsigned long size)
10157 {
10158 - unsigned long ret = ___copy_to_user(to, from, size);
10159 + unsigned long ret;
10160
10161 + if ((long)size < 0 || size > INT_MAX)
10162 + return size;
10163 +
10164 + if (!__builtin_constant_p(size))
10165 + check_object_size(from, size, true);
10166 +
10167 + ret = ___copy_to_user(to, from, size);
10168 if (unlikely(ret))
10169 ret = copy_to_user_fixup(to, from, size);
10170 return ret;
10171 diff --git a/arch/sparc/kernel/Makefile b/arch/sparc/kernel/Makefile
10172 index d15cc17..d0ae796 100644
10173 --- a/arch/sparc/kernel/Makefile
10174 +++ b/arch/sparc/kernel/Makefile
10175 @@ -4,7 +4,7 @@
10176 #
10177
10178 asflags-y := -ansi
10179 -ccflags-y := -Werror
10180 +#ccflags-y := -Werror
10181
10182 extra-y := head_$(BITS).o
10183
10184 diff --git a/arch/sparc/kernel/process_32.c b/arch/sparc/kernel/process_32.c
10185 index 510baec..9ff2607 100644
10186 --- a/arch/sparc/kernel/process_32.c
10187 +++ b/arch/sparc/kernel/process_32.c
10188 @@ -115,14 +115,14 @@ void show_regs(struct pt_regs *r)
10189
10190 printk("PSR: %08lx PC: %08lx NPC: %08lx Y: %08lx %s\n",
10191 r->psr, r->pc, r->npc, r->y, print_tainted());
10192 - printk("PC: <%pS>\n", (void *) r->pc);
10193 + printk("PC: <%pA>\n", (void *) r->pc);
10194 printk("%%G: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
10195 r->u_regs[0], r->u_regs[1], r->u_regs[2], r->u_regs[3],
10196 r->u_regs[4], r->u_regs[5], r->u_regs[6], r->u_regs[7]);
10197 printk("%%O: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
10198 r->u_regs[8], r->u_regs[9], r->u_regs[10], r->u_regs[11],
10199 r->u_regs[12], r->u_regs[13], r->u_regs[14], r->u_regs[15]);
10200 - printk("RPC: <%pS>\n", (void *) r->u_regs[15]);
10201 + printk("RPC: <%pA>\n", (void *) r->u_regs[15]);
10202
10203 printk("%%L: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
10204 rw->locals[0], rw->locals[1], rw->locals[2], rw->locals[3],
10205 @@ -159,7 +159,7 @@ void show_stack(struct task_struct *tsk, unsigned long *_ksp)
10206 rw = (struct reg_window32 *) fp;
10207 pc = rw->ins[7];
10208 printk("[%08lx : ", pc);
10209 - printk("%pS ] ", (void *) pc);
10210 + printk("%pA ] ", (void *) pc);
10211 fp = rw->ins[6];
10212 } while (++count < 16);
10213 printk("\n");
10214 diff --git a/arch/sparc/kernel/process_64.c b/arch/sparc/kernel/process_64.c
10215 index d7b4967..2edf827 100644
10216 --- a/arch/sparc/kernel/process_64.c
10217 +++ b/arch/sparc/kernel/process_64.c
10218 @@ -161,7 +161,7 @@ static void show_regwindow(struct pt_regs *regs)
10219 printk("i4: %016lx i5: %016lx i6: %016lx i7: %016lx\n",
10220 rwk->ins[4], rwk->ins[5], rwk->ins[6], rwk->ins[7]);
10221 if (regs->tstate & TSTATE_PRIV)
10222 - printk("I7: <%pS>\n", (void *) rwk->ins[7]);
10223 + printk("I7: <%pA>\n", (void *) rwk->ins[7]);
10224 }
10225
10226 void show_regs(struct pt_regs *regs)
10227 @@ -170,7 +170,7 @@ void show_regs(struct pt_regs *regs)
10228
10229 printk("TSTATE: %016lx TPC: %016lx TNPC: %016lx Y: %08x %s\n", regs->tstate,
10230 regs->tpc, regs->tnpc, regs->y, print_tainted());
10231 - printk("TPC: <%pS>\n", (void *) regs->tpc);
10232 + printk("TPC: <%pA>\n", (void *) regs->tpc);
10233 printk("g0: %016lx g1: %016lx g2: %016lx g3: %016lx\n",
10234 regs->u_regs[0], regs->u_regs[1], regs->u_regs[2],
10235 regs->u_regs[3]);
10236 @@ -183,7 +183,7 @@ void show_regs(struct pt_regs *regs)
10237 printk("o4: %016lx o5: %016lx sp: %016lx ret_pc: %016lx\n",
10238 regs->u_regs[12], regs->u_regs[13], regs->u_regs[14],
10239 regs->u_regs[15]);
10240 - printk("RPC: <%pS>\n", (void *) regs->u_regs[15]);
10241 + printk("RPC: <%pA>\n", (void *) regs->u_regs[15]);
10242 show_regwindow(regs);
10243 show_stack(current, (unsigned long *) regs->u_regs[UREG_FP]);
10244 }
10245 @@ -272,7 +272,7 @@ void arch_trigger_all_cpu_backtrace(void)
10246 ((tp && tp->task) ? tp->task->pid : -1));
10247
10248 if (gp->tstate & TSTATE_PRIV) {
10249 - printk(" TPC[%pS] O7[%pS] I7[%pS] RPC[%pS]\n",
10250 + printk(" TPC[%pA] O7[%pA] I7[%pA] RPC[%pA]\n",
10251 (void *) gp->tpc,
10252 (void *) gp->o7,
10253 (void *) gp->i7,
10254 diff --git a/arch/sparc/kernel/prom_common.c b/arch/sparc/kernel/prom_common.c
10255 index 79cc0d1..ec62734 100644
10256 --- a/arch/sparc/kernel/prom_common.c
10257 +++ b/arch/sparc/kernel/prom_common.c
10258 @@ -144,7 +144,7 @@ static int __init prom_common_nextprop(phandle node, char *prev, char *buf)
10259
10260 unsigned int prom_early_allocated __initdata;
10261
10262 -static struct of_pdt_ops prom_sparc_ops __initdata = {
10263 +static struct of_pdt_ops prom_sparc_ops __initconst = {
10264 .nextprop = prom_common_nextprop,
10265 .getproplen = prom_getproplen,
10266 .getproperty = prom_getproperty,
10267 diff --git a/arch/sparc/kernel/ptrace_64.c b/arch/sparc/kernel/ptrace_64.c
10268 index c13c9f2..d572c34 100644
10269 --- a/arch/sparc/kernel/ptrace_64.c
10270 +++ b/arch/sparc/kernel/ptrace_64.c
10271 @@ -1060,6 +1060,10 @@ long arch_ptrace(struct task_struct *child, long request,
10272 return ret;
10273 }
10274
10275 +#ifdef CONFIG_GRKERNSEC_SETXID
10276 +extern void gr_delayed_cred_worker(void);
10277 +#endif
10278 +
10279 asmlinkage int syscall_trace_enter(struct pt_regs *regs)
10280 {
10281 int ret = 0;
10282 @@ -1070,6 +1074,11 @@ asmlinkage int syscall_trace_enter(struct pt_regs *regs)
10283 if (test_thread_flag(TIF_NOHZ))
10284 user_exit();
10285
10286 +#ifdef CONFIG_GRKERNSEC_SETXID
10287 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
10288 + gr_delayed_cred_worker();
10289 +#endif
10290 +
10291 if (test_thread_flag(TIF_SYSCALL_TRACE))
10292 ret = tracehook_report_syscall_entry(regs);
10293
10294 @@ -1093,6 +1102,11 @@ asmlinkage void syscall_trace_leave(struct pt_regs *regs)
10295 if (test_thread_flag(TIF_NOHZ))
10296 user_exit();
10297
10298 +#ifdef CONFIG_GRKERNSEC_SETXID
10299 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
10300 + gr_delayed_cred_worker();
10301 +#endif
10302 +
10303 audit_syscall_exit(regs);
10304
10305 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
10306 diff --git a/arch/sparc/kernel/smp_64.c b/arch/sparc/kernel/smp_64.c
10307 index 745a363..b5566b1 100644
10308 --- a/arch/sparc/kernel/smp_64.c
10309 +++ b/arch/sparc/kernel/smp_64.c
10310 @@ -868,8 +868,8 @@ extern unsigned long xcall_flush_dcache_page_cheetah;
10311 extern unsigned long xcall_flush_dcache_page_spitfire;
10312
10313 #ifdef CONFIG_DEBUG_DCFLUSH
10314 -extern atomic_t dcpage_flushes;
10315 -extern atomic_t dcpage_flushes_xcall;
10316 +extern atomic_unchecked_t dcpage_flushes;
10317 +extern atomic_unchecked_t dcpage_flushes_xcall;
10318 #endif
10319
10320 static inline void __local_flush_dcache_page(struct page *page)
10321 @@ -893,7 +893,7 @@ void smp_flush_dcache_page_impl(struct page *page, int cpu)
10322 return;
10323
10324 #ifdef CONFIG_DEBUG_DCFLUSH
10325 - atomic_inc(&dcpage_flushes);
10326 + atomic_inc_unchecked(&dcpage_flushes);
10327 #endif
10328
10329 this_cpu = get_cpu();
10330 @@ -917,7 +917,7 @@ void smp_flush_dcache_page_impl(struct page *page, int cpu)
10331 xcall_deliver(data0, __pa(pg_addr),
10332 (u64) pg_addr, cpumask_of(cpu));
10333 #ifdef CONFIG_DEBUG_DCFLUSH
10334 - atomic_inc(&dcpage_flushes_xcall);
10335 + atomic_inc_unchecked(&dcpage_flushes_xcall);
10336 #endif
10337 }
10338 }
10339 @@ -936,7 +936,7 @@ void flush_dcache_page_all(struct mm_struct *mm, struct page *page)
10340 preempt_disable();
10341
10342 #ifdef CONFIG_DEBUG_DCFLUSH
10343 - atomic_inc(&dcpage_flushes);
10344 + atomic_inc_unchecked(&dcpage_flushes);
10345 #endif
10346 data0 = 0;
10347 pg_addr = page_address(page);
10348 @@ -953,7 +953,7 @@ void flush_dcache_page_all(struct mm_struct *mm, struct page *page)
10349 xcall_deliver(data0, __pa(pg_addr),
10350 (u64) pg_addr, cpu_online_mask);
10351 #ifdef CONFIG_DEBUG_DCFLUSH
10352 - atomic_inc(&dcpage_flushes_xcall);
10353 + atomic_inc_unchecked(&dcpage_flushes_xcall);
10354 #endif
10355 }
10356 __local_flush_dcache_page(page);
10357 diff --git a/arch/sparc/kernel/sys_sparc_32.c b/arch/sparc/kernel/sys_sparc_32.c
10358 index 3a8d184..49498a8 100644
10359 --- a/arch/sparc/kernel/sys_sparc_32.c
10360 +++ b/arch/sparc/kernel/sys_sparc_32.c
10361 @@ -52,7 +52,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
10362 if (len > TASK_SIZE - PAGE_SIZE)
10363 return -ENOMEM;
10364 if (!addr)
10365 - addr = TASK_UNMAPPED_BASE;
10366 + addr = current->mm->mmap_base;
10367
10368 info.flags = 0;
10369 info.length = len;
10370 diff --git a/arch/sparc/kernel/sys_sparc_64.c b/arch/sparc/kernel/sys_sparc_64.c
10371 index beb0b5a..5a153f7 100644
10372 --- a/arch/sparc/kernel/sys_sparc_64.c
10373 +++ b/arch/sparc/kernel/sys_sparc_64.c
10374 @@ -88,13 +88,14 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
10375 struct vm_area_struct * vma;
10376 unsigned long task_size = TASK_SIZE;
10377 int do_color_align;
10378 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
10379 struct vm_unmapped_area_info info;
10380
10381 if (flags & MAP_FIXED) {
10382 /* We do not accept a shared mapping if it would violate
10383 * cache aliasing constraints.
10384 */
10385 - if ((flags & MAP_SHARED) &&
10386 + if ((filp || (flags & MAP_SHARED)) &&
10387 ((addr - (pgoff << PAGE_SHIFT)) & (SHMLBA - 1)))
10388 return -EINVAL;
10389 return addr;
10390 @@ -109,6 +110,10 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
10391 if (filp || (flags & MAP_SHARED))
10392 do_color_align = 1;
10393
10394 +#ifdef CONFIG_PAX_RANDMMAP
10395 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
10396 +#endif
10397 +
10398 if (addr) {
10399 if (do_color_align)
10400 addr = COLOR_ALIGN(addr, pgoff);
10401 @@ -116,22 +121,28 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
10402 addr = PAGE_ALIGN(addr);
10403
10404 vma = find_vma(mm, addr);
10405 - if (task_size - len >= addr &&
10406 - (!vma || addr + len <= vma->vm_start))
10407 + if (task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
10408 return addr;
10409 }
10410
10411 info.flags = 0;
10412 info.length = len;
10413 - info.low_limit = TASK_UNMAPPED_BASE;
10414 + info.low_limit = mm->mmap_base;
10415 info.high_limit = min(task_size, VA_EXCLUDE_START);
10416 info.align_mask = do_color_align ? (PAGE_MASK & (SHMLBA - 1)) : 0;
10417 info.align_offset = pgoff << PAGE_SHIFT;
10418 + info.threadstack_offset = offset;
10419 addr = vm_unmapped_area(&info);
10420
10421 if ((addr & ~PAGE_MASK) && task_size > VA_EXCLUDE_END) {
10422 VM_BUG_ON(addr != -ENOMEM);
10423 info.low_limit = VA_EXCLUDE_END;
10424 +
10425 +#ifdef CONFIG_PAX_RANDMMAP
10426 + if (mm->pax_flags & MF_PAX_RANDMMAP)
10427 + info.low_limit += mm->delta_mmap;
10428 +#endif
10429 +
10430 info.high_limit = task_size;
10431 addr = vm_unmapped_area(&info);
10432 }
10433 @@ -149,6 +160,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
10434 unsigned long task_size = STACK_TOP32;
10435 unsigned long addr = addr0;
10436 int do_color_align;
10437 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
10438 struct vm_unmapped_area_info info;
10439
10440 /* This should only ever run for 32-bit processes. */
10441 @@ -158,7 +170,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
10442 /* We do not accept a shared mapping if it would violate
10443 * cache aliasing constraints.
10444 */
10445 - if ((flags & MAP_SHARED) &&
10446 + if ((filp || (flags & MAP_SHARED)) &&
10447 ((addr - (pgoff << PAGE_SHIFT)) & (SHMLBA - 1)))
10448 return -EINVAL;
10449 return addr;
10450 @@ -171,6 +183,10 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
10451 if (filp || (flags & MAP_SHARED))
10452 do_color_align = 1;
10453
10454 +#ifdef CONFIG_PAX_RANDMMAP
10455 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
10456 +#endif
10457 +
10458 /* requesting a specific address */
10459 if (addr) {
10460 if (do_color_align)
10461 @@ -179,8 +195,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
10462 addr = PAGE_ALIGN(addr);
10463
10464 vma = find_vma(mm, addr);
10465 - if (task_size - len >= addr &&
10466 - (!vma || addr + len <= vma->vm_start))
10467 + if (task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
10468 return addr;
10469 }
10470
10471 @@ -190,6 +205,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
10472 info.high_limit = mm->mmap_base;
10473 info.align_mask = do_color_align ? (PAGE_MASK & (SHMLBA - 1)) : 0;
10474 info.align_offset = pgoff << PAGE_SHIFT;
10475 + info.threadstack_offset = offset;
10476 addr = vm_unmapped_area(&info);
10477
10478 /*
10479 @@ -202,6 +218,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
10480 VM_BUG_ON(addr != -ENOMEM);
10481 info.flags = 0;
10482 info.low_limit = TASK_UNMAPPED_BASE;
10483 +
10484 +#ifdef CONFIG_PAX_RANDMMAP
10485 + if (mm->pax_flags & MF_PAX_RANDMMAP)
10486 + info.low_limit += mm->delta_mmap;
10487 +#endif
10488 +
10489 info.high_limit = STACK_TOP32;
10490 addr = vm_unmapped_area(&info);
10491 }
10492 @@ -258,10 +280,14 @@ unsigned long get_fb_unmapped_area(struct file *filp, unsigned long orig_addr, u
10493 EXPORT_SYMBOL(get_fb_unmapped_area);
10494
10495 /* Essentially the same as PowerPC. */
10496 -static unsigned long mmap_rnd(void)
10497 +static unsigned long mmap_rnd(struct mm_struct *mm)
10498 {
10499 unsigned long rnd = 0UL;
10500
10501 +#ifdef CONFIG_PAX_RANDMMAP
10502 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
10503 +#endif
10504 +
10505 if (current->flags & PF_RANDOMIZE) {
10506 unsigned long val = get_random_int();
10507 if (test_thread_flag(TIF_32BIT))
10508 @@ -274,7 +300,7 @@ static unsigned long mmap_rnd(void)
10509
10510 void arch_pick_mmap_layout(struct mm_struct *mm)
10511 {
10512 - unsigned long random_factor = mmap_rnd();
10513 + unsigned long random_factor = mmap_rnd(mm);
10514 unsigned long gap;
10515
10516 /*
10517 @@ -287,6 +313,12 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
10518 gap == RLIM_INFINITY ||
10519 sysctl_legacy_va_layout) {
10520 mm->mmap_base = TASK_UNMAPPED_BASE + random_factor;
10521 +
10522 +#ifdef CONFIG_PAX_RANDMMAP
10523 + if (mm->pax_flags & MF_PAX_RANDMMAP)
10524 + mm->mmap_base += mm->delta_mmap;
10525 +#endif
10526 +
10527 mm->get_unmapped_area = arch_get_unmapped_area;
10528 } else {
10529 /* We know it's 32-bit */
10530 @@ -298,6 +330,12 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
10531 gap = (task_size / 6 * 5);
10532
10533 mm->mmap_base = PAGE_ALIGN(task_size - gap - random_factor);
10534 +
10535 +#ifdef CONFIG_PAX_RANDMMAP
10536 + if (mm->pax_flags & MF_PAX_RANDMMAP)
10537 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
10538 +#endif
10539 +
10540 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
10541 }
10542 }
10543 diff --git a/arch/sparc/kernel/syscalls.S b/arch/sparc/kernel/syscalls.S
10544 index 33a17e7..d87fb1f 100644
10545 --- a/arch/sparc/kernel/syscalls.S
10546 +++ b/arch/sparc/kernel/syscalls.S
10547 @@ -52,7 +52,7 @@ sys32_rt_sigreturn:
10548 #endif
10549 .align 32
10550 1: ldx [%g6 + TI_FLAGS], %l5
10551 - andcc %l5, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT|_TIF_NOHZ), %g0
10552 + andcc %l5, _TIF_WORK_SYSCALL, %g0
10553 be,pt %icc, rtrap
10554 nop
10555 call syscall_trace_leave
10556 @@ -184,7 +184,7 @@ linux_sparc_syscall32:
10557
10558 srl %i3, 0, %o3 ! IEU0
10559 srl %i2, 0, %o2 ! IEU0 Group
10560 - andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT|_TIF_NOHZ), %g0
10561 + andcc %l0, _TIF_WORK_SYSCALL, %g0
10562 bne,pn %icc, linux_syscall_trace32 ! CTI
10563 mov %i0, %l5 ! IEU1
10564 5: call %l7 ! CTI Group brk forced
10565 @@ -208,7 +208,7 @@ linux_sparc_syscall:
10566
10567 mov %i3, %o3 ! IEU1
10568 mov %i4, %o4 ! IEU0 Group
10569 - andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT|_TIF_NOHZ), %g0
10570 + andcc %l0, _TIF_WORK_SYSCALL, %g0
10571 bne,pn %icc, linux_syscall_trace ! CTI Group
10572 mov %i0, %l5 ! IEU0
10573 2: call %l7 ! CTI Group brk forced
10574 @@ -223,7 +223,7 @@ ret_sys_call:
10575
10576 cmp %o0, -ERESTART_RESTARTBLOCK
10577 bgeu,pn %xcc, 1f
10578 - andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT|_TIF_NOHZ), %g0
10579 + andcc %l0, _TIF_WORK_SYSCALL, %g0
10580 ldx [%sp + PTREGS_OFF + PT_V9_TNPC], %l1 ! pc = npc
10581
10582 2:
10583 diff --git a/arch/sparc/kernel/traps_32.c b/arch/sparc/kernel/traps_32.c
10584 index 6629829..036032d 100644
10585 --- a/arch/sparc/kernel/traps_32.c
10586 +++ b/arch/sparc/kernel/traps_32.c
10587 @@ -44,6 +44,8 @@ static void instruction_dump(unsigned long *pc)
10588 #define __SAVE __asm__ __volatile__("save %sp, -0x40, %sp\n\t")
10589 #define __RESTORE __asm__ __volatile__("restore %g0, %g0, %g0\n\t")
10590
10591 +extern void gr_handle_kernel_exploit(void);
10592 +
10593 void die_if_kernel(char *str, struct pt_regs *regs)
10594 {
10595 static int die_counter;
10596 @@ -76,15 +78,17 @@ void die_if_kernel(char *str, struct pt_regs *regs)
10597 count++ < 30 &&
10598 (((unsigned long) rw) >= PAGE_OFFSET) &&
10599 !(((unsigned long) rw) & 0x7)) {
10600 - printk("Caller[%08lx]: %pS\n", rw->ins[7],
10601 + printk("Caller[%08lx]: %pA\n", rw->ins[7],
10602 (void *) rw->ins[7]);
10603 rw = (struct reg_window32 *)rw->ins[6];
10604 }
10605 }
10606 printk("Instruction DUMP:");
10607 instruction_dump ((unsigned long *) regs->pc);
10608 - if(regs->psr & PSR_PS)
10609 + if(regs->psr & PSR_PS) {
10610 + gr_handle_kernel_exploit();
10611 do_exit(SIGKILL);
10612 + }
10613 do_exit(SIGSEGV);
10614 }
10615
10616 diff --git a/arch/sparc/kernel/traps_64.c b/arch/sparc/kernel/traps_64.c
10617 index 4ced92f..965eeed 100644
10618 --- a/arch/sparc/kernel/traps_64.c
10619 +++ b/arch/sparc/kernel/traps_64.c
10620 @@ -77,7 +77,7 @@ static void dump_tl1_traplog(struct tl1_traplog *p)
10621 i + 1,
10622 p->trapstack[i].tstate, p->trapstack[i].tpc,
10623 p->trapstack[i].tnpc, p->trapstack[i].tt);
10624 - printk("TRAPLOG: TPC<%pS>\n", (void *) p->trapstack[i].tpc);
10625 + printk("TRAPLOG: TPC<%pA>\n", (void *) p->trapstack[i].tpc);
10626 }
10627 }
10628
10629 @@ -97,6 +97,12 @@ void bad_trap(struct pt_regs *regs, long lvl)
10630
10631 lvl -= 0x100;
10632 if (regs->tstate & TSTATE_PRIV) {
10633 +
10634 +#ifdef CONFIG_PAX_REFCOUNT
10635 + if (lvl == 6)
10636 + pax_report_refcount_overflow(regs);
10637 +#endif
10638 +
10639 sprintf(buffer, "Kernel bad sw trap %lx", lvl);
10640 die_if_kernel(buffer, regs);
10641 }
10642 @@ -115,11 +121,16 @@ void bad_trap(struct pt_regs *regs, long lvl)
10643 void bad_trap_tl1(struct pt_regs *regs, long lvl)
10644 {
10645 char buffer[32];
10646 -
10647 +
10648 if (notify_die(DIE_TRAP_TL1, "bad trap tl1", regs,
10649 0, lvl, SIGTRAP) == NOTIFY_STOP)
10650 return;
10651
10652 +#ifdef CONFIG_PAX_REFCOUNT
10653 + if (lvl == 6)
10654 + pax_report_refcount_overflow(regs);
10655 +#endif
10656 +
10657 dump_tl1_traplog((struct tl1_traplog *)(regs + 1));
10658
10659 sprintf (buffer, "Bad trap %lx at tl>0", lvl);
10660 @@ -1149,7 +1160,7 @@ static void cheetah_log_errors(struct pt_regs *regs, struct cheetah_err_info *in
10661 regs->tpc, regs->tnpc, regs->u_regs[UREG_I7], regs->tstate);
10662 printk("%s" "ERROR(%d): ",
10663 (recoverable ? KERN_WARNING : KERN_CRIT), smp_processor_id());
10664 - printk("TPC<%pS>\n", (void *) regs->tpc);
10665 + printk("TPC<%pA>\n", (void *) regs->tpc);
10666 printk("%s" "ERROR(%d): M_SYND(%lx), E_SYND(%lx)%s%s\n",
10667 (recoverable ? KERN_WARNING : KERN_CRIT), smp_processor_id(),
10668 (afsr & CHAFSR_M_SYNDROME) >> CHAFSR_M_SYNDROME_SHIFT,
10669 @@ -1756,7 +1767,7 @@ void cheetah_plus_parity_error(int type, struct pt_regs *regs)
10670 smp_processor_id(),
10671 (type & 0x1) ? 'I' : 'D',
10672 regs->tpc);
10673 - printk(KERN_EMERG "TPC<%pS>\n", (void *) regs->tpc);
10674 + printk(KERN_EMERG "TPC<%pA>\n", (void *) regs->tpc);
10675 panic("Irrecoverable Cheetah+ parity error.");
10676 }
10677
10678 @@ -1764,7 +1775,7 @@ void cheetah_plus_parity_error(int type, struct pt_regs *regs)
10679 smp_processor_id(),
10680 (type & 0x1) ? 'I' : 'D',
10681 regs->tpc);
10682 - printk(KERN_WARNING "TPC<%pS>\n", (void *) regs->tpc);
10683 + printk(KERN_WARNING "TPC<%pA>\n", (void *) regs->tpc);
10684 }
10685
10686 struct sun4v_error_entry {
10687 @@ -1837,8 +1848,8 @@ struct sun4v_error_entry {
10688 /*0x38*/u64 reserved_5;
10689 };
10690
10691 -static atomic_t sun4v_resum_oflow_cnt = ATOMIC_INIT(0);
10692 -static atomic_t sun4v_nonresum_oflow_cnt = ATOMIC_INIT(0);
10693 +static atomic_unchecked_t sun4v_resum_oflow_cnt = ATOMIC_INIT(0);
10694 +static atomic_unchecked_t sun4v_nonresum_oflow_cnt = ATOMIC_INIT(0);
10695
10696 static const char *sun4v_err_type_to_str(u8 type)
10697 {
10698 @@ -1930,7 +1941,7 @@ static void sun4v_report_real_raddr(const char *pfx, struct pt_regs *regs)
10699 }
10700
10701 static void sun4v_log_error(struct pt_regs *regs, struct sun4v_error_entry *ent,
10702 - int cpu, const char *pfx, atomic_t *ocnt)
10703 + int cpu, const char *pfx, atomic_unchecked_t *ocnt)
10704 {
10705 u64 *raw_ptr = (u64 *) ent;
10706 u32 attrs;
10707 @@ -1988,8 +1999,8 @@ static void sun4v_log_error(struct pt_regs *regs, struct sun4v_error_entry *ent,
10708
10709 show_regs(regs);
10710
10711 - if ((cnt = atomic_read(ocnt)) != 0) {
10712 - atomic_set(ocnt, 0);
10713 + if ((cnt = atomic_read_unchecked(ocnt)) != 0) {
10714 + atomic_set_unchecked(ocnt, 0);
10715 wmb();
10716 printk("%s: Queue overflowed %d times.\n",
10717 pfx, cnt);
10718 @@ -2046,7 +2057,7 @@ out:
10719 */
10720 void sun4v_resum_overflow(struct pt_regs *regs)
10721 {
10722 - atomic_inc(&sun4v_resum_oflow_cnt);
10723 + atomic_inc_unchecked(&sun4v_resum_oflow_cnt);
10724 }
10725
10726 /* We run with %pil set to PIL_NORMAL_MAX and PSTATE_IE enabled in %pstate.
10727 @@ -2099,7 +2110,7 @@ void sun4v_nonresum_overflow(struct pt_regs *regs)
10728 /* XXX Actually even this can make not that much sense. Perhaps
10729 * XXX we should just pull the plug and panic directly from here?
10730 */
10731 - atomic_inc(&sun4v_nonresum_oflow_cnt);
10732 + atomic_inc_unchecked(&sun4v_nonresum_oflow_cnt);
10733 }
10734
10735 unsigned long sun4v_err_itlb_vaddr;
10736 @@ -2114,9 +2125,9 @@ void sun4v_itlb_error_report(struct pt_regs *regs, int tl)
10737
10738 printk(KERN_EMERG "SUN4V-ITLB: Error at TPC[%lx], tl %d\n",
10739 regs->tpc, tl);
10740 - printk(KERN_EMERG "SUN4V-ITLB: TPC<%pS>\n", (void *) regs->tpc);
10741 + printk(KERN_EMERG "SUN4V-ITLB: TPC<%pA>\n", (void *) regs->tpc);
10742 printk(KERN_EMERG "SUN4V-ITLB: O7[%lx]\n", regs->u_regs[UREG_I7]);
10743 - printk(KERN_EMERG "SUN4V-ITLB: O7<%pS>\n",
10744 + printk(KERN_EMERG "SUN4V-ITLB: O7<%pA>\n",
10745 (void *) regs->u_regs[UREG_I7]);
10746 printk(KERN_EMERG "SUN4V-ITLB: vaddr[%lx] ctx[%lx] "
10747 "pte[%lx] error[%lx]\n",
10748 @@ -2138,9 +2149,9 @@ void sun4v_dtlb_error_report(struct pt_regs *regs, int tl)
10749
10750 printk(KERN_EMERG "SUN4V-DTLB: Error at TPC[%lx], tl %d\n",
10751 regs->tpc, tl);
10752 - printk(KERN_EMERG "SUN4V-DTLB: TPC<%pS>\n", (void *) regs->tpc);
10753 + printk(KERN_EMERG "SUN4V-DTLB: TPC<%pA>\n", (void *) regs->tpc);
10754 printk(KERN_EMERG "SUN4V-DTLB: O7[%lx]\n", regs->u_regs[UREG_I7]);
10755 - printk(KERN_EMERG "SUN4V-DTLB: O7<%pS>\n",
10756 + printk(KERN_EMERG "SUN4V-DTLB: O7<%pA>\n",
10757 (void *) regs->u_regs[UREG_I7]);
10758 printk(KERN_EMERG "SUN4V-DTLB: vaddr[%lx] ctx[%lx] "
10759 "pte[%lx] error[%lx]\n",
10760 @@ -2359,13 +2370,13 @@ void show_stack(struct task_struct *tsk, unsigned long *_ksp)
10761 fp = (unsigned long)sf->fp + STACK_BIAS;
10762 }
10763
10764 - printk(" [%016lx] %pS\n", pc, (void *) pc);
10765 + printk(" [%016lx] %pA\n", pc, (void *) pc);
10766 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
10767 if ((pc + 8UL) == (unsigned long) &return_to_handler) {
10768 int index = tsk->curr_ret_stack;
10769 if (tsk->ret_stack && index >= graph) {
10770 pc = tsk->ret_stack[index - graph].ret;
10771 - printk(" [%016lx] %pS\n", pc, (void *) pc);
10772 + printk(" [%016lx] %pA\n", pc, (void *) pc);
10773 graph++;
10774 }
10775 }
10776 @@ -2383,6 +2394,8 @@ static inline struct reg_window *kernel_stack_up(struct reg_window *rw)
10777 return (struct reg_window *) (fp + STACK_BIAS);
10778 }
10779
10780 +extern void gr_handle_kernel_exploit(void);
10781 +
10782 void die_if_kernel(char *str, struct pt_regs *regs)
10783 {
10784 static int die_counter;
10785 @@ -2411,7 +2424,7 @@ void die_if_kernel(char *str, struct pt_regs *regs)
10786 while (rw &&
10787 count++ < 30 &&
10788 kstack_valid(tp, (unsigned long) rw)) {
10789 - printk("Caller[%016lx]: %pS\n", rw->ins[7],
10790 + printk("Caller[%016lx]: %pA\n", rw->ins[7],
10791 (void *) rw->ins[7]);
10792
10793 rw = kernel_stack_up(rw);
10794 @@ -2424,8 +2437,10 @@ void die_if_kernel(char *str, struct pt_regs *regs)
10795 }
10796 user_instruction_dump ((unsigned int __user *) regs->tpc);
10797 }
10798 - if (regs->tstate & TSTATE_PRIV)
10799 + if (regs->tstate & TSTATE_PRIV) {
10800 + gr_handle_kernel_exploit();
10801 do_exit(SIGKILL);
10802 + }
10803 do_exit(SIGSEGV);
10804 }
10805 EXPORT_SYMBOL(die_if_kernel);
10806 diff --git a/arch/sparc/kernel/unaligned_64.c b/arch/sparc/kernel/unaligned_64.c
10807 index 35ab8b6..9046547 100644
10808 --- a/arch/sparc/kernel/unaligned_64.c
10809 +++ b/arch/sparc/kernel/unaligned_64.c
10810 @@ -295,7 +295,7 @@ static void log_unaligned(struct pt_regs *regs)
10811 static DEFINE_RATELIMIT_STATE(ratelimit, 5 * HZ, 5);
10812
10813 if (__ratelimit(&ratelimit)) {
10814 - printk("Kernel unaligned access at TPC[%lx] %pS\n",
10815 + printk("Kernel unaligned access at TPC[%lx] %pA\n",
10816 regs->tpc, (void *) regs->tpc);
10817 }
10818 }
10819 diff --git a/arch/sparc/lib/Makefile b/arch/sparc/lib/Makefile
10820 index dbe119b..089c7c1 100644
10821 --- a/arch/sparc/lib/Makefile
10822 +++ b/arch/sparc/lib/Makefile
10823 @@ -2,7 +2,7 @@
10824 #
10825
10826 asflags-y := -ansi -DST_DIV0=0x02
10827 -ccflags-y := -Werror
10828 +#ccflags-y := -Werror
10829
10830 lib-$(CONFIG_SPARC32) += ashrdi3.o
10831 lib-$(CONFIG_SPARC32) += memcpy.o memset.o
10832 diff --git a/arch/sparc/lib/atomic_64.S b/arch/sparc/lib/atomic_64.S
10833 index 85c233d..68500e0 100644
10834 --- a/arch/sparc/lib/atomic_64.S
10835 +++ b/arch/sparc/lib/atomic_64.S
10836 @@ -17,7 +17,12 @@
10837 ENTRY(atomic_add) /* %o0 = increment, %o1 = atomic_ptr */
10838 BACKOFF_SETUP(%o2)
10839 1: lduw [%o1], %g1
10840 - add %g1, %o0, %g7
10841 + addcc %g1, %o0, %g7
10842 +
10843 +#ifdef CONFIG_PAX_REFCOUNT
10844 + tvs %icc, 6
10845 +#endif
10846 +
10847 cas [%o1], %g1, %g7
10848 cmp %g1, %g7
10849 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
10850 @@ -27,10 +32,28 @@ ENTRY(atomic_add) /* %o0 = increment, %o1 = atomic_ptr */
10851 2: BACKOFF_SPIN(%o2, %o3, 1b)
10852 ENDPROC(atomic_add)
10853
10854 +ENTRY(atomic_add_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
10855 + BACKOFF_SETUP(%o2)
10856 +1: lduw [%o1], %g1
10857 + add %g1, %o0, %g7
10858 + cas [%o1], %g1, %g7
10859 + cmp %g1, %g7
10860 + bne,pn %icc, 2f
10861 + nop
10862 + retl
10863 + nop
10864 +2: BACKOFF_SPIN(%o2, %o3, 1b)
10865 +ENDPROC(atomic_add_unchecked)
10866 +
10867 ENTRY(atomic_sub) /* %o0 = decrement, %o1 = atomic_ptr */
10868 BACKOFF_SETUP(%o2)
10869 1: lduw [%o1], %g1
10870 - sub %g1, %o0, %g7
10871 + subcc %g1, %o0, %g7
10872 +
10873 +#ifdef CONFIG_PAX_REFCOUNT
10874 + tvs %icc, 6
10875 +#endif
10876 +
10877 cas [%o1], %g1, %g7
10878 cmp %g1, %g7
10879 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
10880 @@ -40,10 +63,28 @@ ENTRY(atomic_sub) /* %o0 = decrement, %o1 = atomic_ptr */
10881 2: BACKOFF_SPIN(%o2, %o3, 1b)
10882 ENDPROC(atomic_sub)
10883
10884 +ENTRY(atomic_sub_unchecked) /* %o0 = decrement, %o1 = atomic_ptr */
10885 + BACKOFF_SETUP(%o2)
10886 +1: lduw [%o1], %g1
10887 + sub %g1, %o0, %g7
10888 + cas [%o1], %g1, %g7
10889 + cmp %g1, %g7
10890 + bne,pn %icc, 2f
10891 + nop
10892 + retl
10893 + nop
10894 +2: BACKOFF_SPIN(%o2, %o3, 1b)
10895 +ENDPROC(atomic_sub_unchecked)
10896 +
10897 ENTRY(atomic_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
10898 BACKOFF_SETUP(%o2)
10899 1: lduw [%o1], %g1
10900 - add %g1, %o0, %g7
10901 + addcc %g1, %o0, %g7
10902 +
10903 +#ifdef CONFIG_PAX_REFCOUNT
10904 + tvs %icc, 6
10905 +#endif
10906 +
10907 cas [%o1], %g1, %g7
10908 cmp %g1, %g7
10909 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
10910 @@ -53,10 +94,29 @@ ENTRY(atomic_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
10911 2: BACKOFF_SPIN(%o2, %o3, 1b)
10912 ENDPROC(atomic_add_ret)
10913
10914 +ENTRY(atomic_add_ret_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
10915 + BACKOFF_SETUP(%o2)
10916 +1: lduw [%o1], %g1
10917 + addcc %g1, %o0, %g7
10918 + cas [%o1], %g1, %g7
10919 + cmp %g1, %g7
10920 + bne,pn %icc, 2f
10921 + add %g7, %o0, %g7
10922 + sra %g7, 0, %o0
10923 + retl
10924 + nop
10925 +2: BACKOFF_SPIN(%o2, %o3, 1b)
10926 +ENDPROC(atomic_add_ret_unchecked)
10927 +
10928 ENTRY(atomic_sub_ret) /* %o0 = decrement, %o1 = atomic_ptr */
10929 BACKOFF_SETUP(%o2)
10930 1: lduw [%o1], %g1
10931 - sub %g1, %o0, %g7
10932 + subcc %g1, %o0, %g7
10933 +
10934 +#ifdef CONFIG_PAX_REFCOUNT
10935 + tvs %icc, 6
10936 +#endif
10937 +
10938 cas [%o1], %g1, %g7
10939 cmp %g1, %g7
10940 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
10941 @@ -69,7 +129,12 @@ ENDPROC(atomic_sub_ret)
10942 ENTRY(atomic64_add) /* %o0 = increment, %o1 = atomic_ptr */
10943 BACKOFF_SETUP(%o2)
10944 1: ldx [%o1], %g1
10945 - add %g1, %o0, %g7
10946 + addcc %g1, %o0, %g7
10947 +
10948 +#ifdef CONFIG_PAX_REFCOUNT
10949 + tvs %xcc, 6
10950 +#endif
10951 +
10952 casx [%o1], %g1, %g7
10953 cmp %g1, %g7
10954 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
10955 @@ -79,10 +144,28 @@ ENTRY(atomic64_add) /* %o0 = increment, %o1 = atomic_ptr */
10956 2: BACKOFF_SPIN(%o2, %o3, 1b)
10957 ENDPROC(atomic64_add)
10958
10959 +ENTRY(atomic64_add_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
10960 + BACKOFF_SETUP(%o2)
10961 +1: ldx [%o1], %g1
10962 + addcc %g1, %o0, %g7
10963 + casx [%o1], %g1, %g7
10964 + cmp %g1, %g7
10965 + bne,pn %xcc, 2f
10966 + nop
10967 + retl
10968 + nop
10969 +2: BACKOFF_SPIN(%o2, %o3, 1b)
10970 +ENDPROC(atomic64_add_unchecked)
10971 +
10972 ENTRY(atomic64_sub) /* %o0 = decrement, %o1 = atomic_ptr */
10973 BACKOFF_SETUP(%o2)
10974 1: ldx [%o1], %g1
10975 - sub %g1, %o0, %g7
10976 + subcc %g1, %o0, %g7
10977 +
10978 +#ifdef CONFIG_PAX_REFCOUNT
10979 + tvs %xcc, 6
10980 +#endif
10981 +
10982 casx [%o1], %g1, %g7
10983 cmp %g1, %g7
10984 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
10985 @@ -92,10 +175,28 @@ ENTRY(atomic64_sub) /* %o0 = decrement, %o1 = atomic_ptr */
10986 2: BACKOFF_SPIN(%o2, %o3, 1b)
10987 ENDPROC(atomic64_sub)
10988
10989 +ENTRY(atomic64_sub_unchecked) /* %o0 = decrement, %o1 = atomic_ptr */
10990 + BACKOFF_SETUP(%o2)
10991 +1: ldx [%o1], %g1
10992 + subcc %g1, %o0, %g7
10993 + casx [%o1], %g1, %g7
10994 + cmp %g1, %g7
10995 + bne,pn %xcc, 2f
10996 + nop
10997 + retl
10998 + nop
10999 +2: BACKOFF_SPIN(%o2, %o3, 1b)
11000 +ENDPROC(atomic64_sub_unchecked)
11001 +
11002 ENTRY(atomic64_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
11003 BACKOFF_SETUP(%o2)
11004 1: ldx [%o1], %g1
11005 - add %g1, %o0, %g7
11006 + addcc %g1, %o0, %g7
11007 +
11008 +#ifdef CONFIG_PAX_REFCOUNT
11009 + tvs %xcc, 6
11010 +#endif
11011 +
11012 casx [%o1], %g1, %g7
11013 cmp %g1, %g7
11014 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
11015 @@ -105,10 +206,29 @@ ENTRY(atomic64_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
11016 2: BACKOFF_SPIN(%o2, %o3, 1b)
11017 ENDPROC(atomic64_add_ret)
11018
11019 +ENTRY(atomic64_add_ret_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
11020 + BACKOFF_SETUP(%o2)
11021 +1: ldx [%o1], %g1
11022 + addcc %g1, %o0, %g7
11023 + casx [%o1], %g1, %g7
11024 + cmp %g1, %g7
11025 + bne,pn %xcc, 2f
11026 + add %g7, %o0, %g7
11027 + mov %g7, %o0
11028 + retl
11029 + nop
11030 +2: BACKOFF_SPIN(%o2, %o3, 1b)
11031 +ENDPROC(atomic64_add_ret_unchecked)
11032 +
11033 ENTRY(atomic64_sub_ret) /* %o0 = decrement, %o1 = atomic_ptr */
11034 BACKOFF_SETUP(%o2)
11035 1: ldx [%o1], %g1
11036 - sub %g1, %o0, %g7
11037 + subcc %g1, %o0, %g7
11038 +
11039 +#ifdef CONFIG_PAX_REFCOUNT
11040 + tvs %xcc, 6
11041 +#endif
11042 +
11043 casx [%o1], %g1, %g7
11044 cmp %g1, %g7
11045 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
11046 diff --git a/arch/sparc/lib/ksyms.c b/arch/sparc/lib/ksyms.c
11047 index 323335b..ed85ea2 100644
11048 --- a/arch/sparc/lib/ksyms.c
11049 +++ b/arch/sparc/lib/ksyms.c
11050 @@ -100,12 +100,18 @@ EXPORT_SYMBOL(__clear_user);
11051
11052 /* Atomic counter implementation. */
11053 EXPORT_SYMBOL(atomic_add);
11054 +EXPORT_SYMBOL(atomic_add_unchecked);
11055 EXPORT_SYMBOL(atomic_add_ret);
11056 +EXPORT_SYMBOL(atomic_add_ret_unchecked);
11057 EXPORT_SYMBOL(atomic_sub);
11058 +EXPORT_SYMBOL(atomic_sub_unchecked);
11059 EXPORT_SYMBOL(atomic_sub_ret);
11060 EXPORT_SYMBOL(atomic64_add);
11061 +EXPORT_SYMBOL(atomic64_add_unchecked);
11062 EXPORT_SYMBOL(atomic64_add_ret);
11063 +EXPORT_SYMBOL(atomic64_add_ret_unchecked);
11064 EXPORT_SYMBOL(atomic64_sub);
11065 +EXPORT_SYMBOL(atomic64_sub_unchecked);
11066 EXPORT_SYMBOL(atomic64_sub_ret);
11067 EXPORT_SYMBOL(atomic64_dec_if_positive);
11068
11069 diff --git a/arch/sparc/mm/Makefile b/arch/sparc/mm/Makefile
11070 index 30c3ecc..736f015 100644
11071 --- a/arch/sparc/mm/Makefile
11072 +++ b/arch/sparc/mm/Makefile
11073 @@ -2,7 +2,7 @@
11074 #
11075
11076 asflags-y := -ansi
11077 -ccflags-y := -Werror
11078 +#ccflags-y := -Werror
11079
11080 obj-$(CONFIG_SPARC64) += ultra.o tlb.o tsb.o gup.o
11081 obj-y += fault_$(BITS).o
11082 diff --git a/arch/sparc/mm/fault_32.c b/arch/sparc/mm/fault_32.c
11083 index 59dbd46..1dd7f5e 100644
11084 --- a/arch/sparc/mm/fault_32.c
11085 +++ b/arch/sparc/mm/fault_32.c
11086 @@ -21,6 +21,9 @@
11087 #include <linux/perf_event.h>
11088 #include <linux/interrupt.h>
11089 #include <linux/kdebug.h>
11090 +#include <linux/slab.h>
11091 +#include <linux/pagemap.h>
11092 +#include <linux/compiler.h>
11093
11094 #include <asm/page.h>
11095 #include <asm/pgtable.h>
11096 @@ -159,6 +162,277 @@ static unsigned long compute_si_addr(struct pt_regs *regs, int text_fault)
11097 return safe_compute_effective_address(regs, insn);
11098 }
11099
11100 +#ifdef CONFIG_PAX_PAGEEXEC
11101 +#ifdef CONFIG_PAX_DLRESOLVE
11102 +static void pax_emuplt_close(struct vm_area_struct *vma)
11103 +{
11104 + vma->vm_mm->call_dl_resolve = 0UL;
11105 +}
11106 +
11107 +static int pax_emuplt_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
11108 +{
11109 + unsigned int *kaddr;
11110 +
11111 + vmf->page = alloc_page(GFP_HIGHUSER);
11112 + if (!vmf->page)
11113 + return VM_FAULT_OOM;
11114 +
11115 + kaddr = kmap(vmf->page);
11116 + memset(kaddr, 0, PAGE_SIZE);
11117 + kaddr[0] = 0x9DE3BFA8U; /* save */
11118 + flush_dcache_page(vmf->page);
11119 + kunmap(vmf->page);
11120 + return VM_FAULT_MAJOR;
11121 +}
11122 +
11123 +static const struct vm_operations_struct pax_vm_ops = {
11124 + .close = pax_emuplt_close,
11125 + .fault = pax_emuplt_fault
11126 +};
11127 +
11128 +static int pax_insert_vma(struct vm_area_struct *vma, unsigned long addr)
11129 +{
11130 + int ret;
11131 +
11132 + INIT_LIST_HEAD(&vma->anon_vma_chain);
11133 + vma->vm_mm = current->mm;
11134 + vma->vm_start = addr;
11135 + vma->vm_end = addr + PAGE_SIZE;
11136 + vma->vm_flags = VM_READ | VM_EXEC | VM_MAYREAD | VM_MAYEXEC;
11137 + vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
11138 + vma->vm_ops = &pax_vm_ops;
11139 +
11140 + ret = insert_vm_struct(current->mm, vma);
11141 + if (ret)
11142 + return ret;
11143 +
11144 + ++current->mm->total_vm;
11145 + return 0;
11146 +}
11147 +#endif
11148 +
11149 +/*
11150 + * PaX: decide what to do with offenders (regs->pc = fault address)
11151 + *
11152 + * returns 1 when task should be killed
11153 + * 2 when patched PLT trampoline was detected
11154 + * 3 when unpatched PLT trampoline was detected
11155 + */
11156 +static int pax_handle_fetch_fault(struct pt_regs *regs)
11157 +{
11158 +
11159 +#ifdef CONFIG_PAX_EMUPLT
11160 + int err;
11161 +
11162 + do { /* PaX: patched PLT emulation #1 */
11163 + unsigned int sethi1, sethi2, jmpl;
11164 +
11165 + err = get_user(sethi1, (unsigned int *)regs->pc);
11166 + err |= get_user(sethi2, (unsigned int *)(regs->pc+4));
11167 + err |= get_user(jmpl, (unsigned int *)(regs->pc+8));
11168 +
11169 + if (err)
11170 + break;
11171 +
11172 + if ((sethi1 & 0xFFC00000U) == 0x03000000U &&
11173 + (sethi2 & 0xFFC00000U) == 0x03000000U &&
11174 + (jmpl & 0xFFFFE000U) == 0x81C06000U)
11175 + {
11176 + unsigned int addr;
11177 +
11178 + regs->u_regs[UREG_G1] = (sethi2 & 0x003FFFFFU) << 10;
11179 + addr = regs->u_regs[UREG_G1];
11180 + addr += (((jmpl | 0xFFFFE000U) ^ 0x00001000U) + 0x00001000U);
11181 + regs->pc = addr;
11182 + regs->npc = addr+4;
11183 + return 2;
11184 + }
11185 + } while (0);
11186 +
11187 + do { /* PaX: patched PLT emulation #2 */
11188 + unsigned int ba;
11189 +
11190 + err = get_user(ba, (unsigned int *)regs->pc);
11191 +
11192 + if (err)
11193 + break;
11194 +
11195 + if ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30480000U) {
11196 + unsigned int addr;
11197 +
11198 + if ((ba & 0xFFC00000U) == 0x30800000U)
11199 + addr = regs->pc + ((((ba | 0xFFC00000U) ^ 0x00200000U) + 0x00200000U) << 2);
11200 + else
11201 + addr = regs->pc + ((((ba | 0xFFF80000U) ^ 0x00040000U) + 0x00040000U) << 2);
11202 + regs->pc = addr;
11203 + regs->npc = addr+4;
11204 + return 2;
11205 + }
11206 + } while (0);
11207 +
11208 + do { /* PaX: patched PLT emulation #3 */
11209 + unsigned int sethi, bajmpl, nop;
11210 +
11211 + err = get_user(sethi, (unsigned int *)regs->pc);
11212 + err |= get_user(bajmpl, (unsigned int *)(regs->pc+4));
11213 + err |= get_user(nop, (unsigned int *)(regs->pc+8));
11214 +
11215 + if (err)
11216 + break;
11217 +
11218 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
11219 + ((bajmpl & 0xFFFFE000U) == 0x81C06000U || (bajmpl & 0xFFF80000U) == 0x30480000U) &&
11220 + nop == 0x01000000U)
11221 + {
11222 + unsigned int addr;
11223 +
11224 + addr = (sethi & 0x003FFFFFU) << 10;
11225 + regs->u_regs[UREG_G1] = addr;
11226 + if ((bajmpl & 0xFFFFE000U) == 0x81C06000U)
11227 + addr += (((bajmpl | 0xFFFFE000U) ^ 0x00001000U) + 0x00001000U);
11228 + else
11229 + addr = regs->pc + ((((bajmpl | 0xFFF80000U) ^ 0x00040000U) + 0x00040000U) << 2);
11230 + regs->pc = addr;
11231 + regs->npc = addr+4;
11232 + return 2;
11233 + }
11234 + } while (0);
11235 +
11236 + do { /* PaX: unpatched PLT emulation step 1 */
11237 + unsigned int sethi, ba, nop;
11238 +
11239 + err = get_user(sethi, (unsigned int *)regs->pc);
11240 + err |= get_user(ba, (unsigned int *)(regs->pc+4));
11241 + err |= get_user(nop, (unsigned int *)(regs->pc+8));
11242 +
11243 + if (err)
11244 + break;
11245 +
11246 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
11247 + ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30680000U) &&
11248 + nop == 0x01000000U)
11249 + {
11250 + unsigned int addr, save, call;
11251 +
11252 + if ((ba & 0xFFC00000U) == 0x30800000U)
11253 + addr = regs->pc + 4 + ((((ba | 0xFFC00000U) ^ 0x00200000U) + 0x00200000U) << 2);
11254 + else
11255 + addr = regs->pc + 4 + ((((ba | 0xFFF80000U) ^ 0x00040000U) + 0x00040000U) << 2);
11256 +
11257 + err = get_user(save, (unsigned int *)addr);
11258 + err |= get_user(call, (unsigned int *)(addr+4));
11259 + err |= get_user(nop, (unsigned int *)(addr+8));
11260 + if (err)
11261 + break;
11262 +
11263 +#ifdef CONFIG_PAX_DLRESOLVE
11264 + if (save == 0x9DE3BFA8U &&
11265 + (call & 0xC0000000U) == 0x40000000U &&
11266 + nop == 0x01000000U)
11267 + {
11268 + struct vm_area_struct *vma;
11269 + unsigned long call_dl_resolve;
11270 +
11271 + down_read(&current->mm->mmap_sem);
11272 + call_dl_resolve = current->mm->call_dl_resolve;
11273 + up_read(&current->mm->mmap_sem);
11274 + if (likely(call_dl_resolve))
11275 + goto emulate;
11276 +
11277 + vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
11278 +
11279 + down_write(&current->mm->mmap_sem);
11280 + if (current->mm->call_dl_resolve) {
11281 + call_dl_resolve = current->mm->call_dl_resolve;
11282 + up_write(&current->mm->mmap_sem);
11283 + if (vma)
11284 + kmem_cache_free(vm_area_cachep, vma);
11285 + goto emulate;
11286 + }
11287 +
11288 + call_dl_resolve = get_unmapped_area(NULL, 0UL, PAGE_SIZE, 0UL, MAP_PRIVATE);
11289 + if (!vma || (call_dl_resolve & ~PAGE_MASK)) {
11290 + up_write(&current->mm->mmap_sem);
11291 + if (vma)
11292 + kmem_cache_free(vm_area_cachep, vma);
11293 + return 1;
11294 + }
11295 +
11296 + if (pax_insert_vma(vma, call_dl_resolve)) {
11297 + up_write(&current->mm->mmap_sem);
11298 + kmem_cache_free(vm_area_cachep, vma);
11299 + return 1;
11300 + }
11301 +
11302 + current->mm->call_dl_resolve = call_dl_resolve;
11303 + up_write(&current->mm->mmap_sem);
11304 +
11305 +emulate:
11306 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
11307 + regs->pc = call_dl_resolve;
11308 + regs->npc = addr+4;
11309 + return 3;
11310 + }
11311 +#endif
11312 +
11313 + /* PaX: glibc 2.4+ generates sethi/jmpl instead of save/call */
11314 + if ((save & 0xFFC00000U) == 0x05000000U &&
11315 + (call & 0xFFFFE000U) == 0x85C0A000U &&
11316 + nop == 0x01000000U)
11317 + {
11318 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
11319 + regs->u_regs[UREG_G2] = addr + 4;
11320 + addr = (save & 0x003FFFFFU) << 10;
11321 + addr += (((call | 0xFFFFE000U) ^ 0x00001000U) + 0x00001000U);
11322 + regs->pc = addr;
11323 + regs->npc = addr+4;
11324 + return 3;
11325 + }
11326 + }
11327 + } while (0);
11328 +
11329 + do { /* PaX: unpatched PLT emulation step 2 */
11330 + unsigned int save, call, nop;
11331 +
11332 + err = get_user(save, (unsigned int *)(regs->pc-4));
11333 + err |= get_user(call, (unsigned int *)regs->pc);
11334 + err |= get_user(nop, (unsigned int *)(regs->pc+4));
11335 + if (err)
11336 + break;
11337 +
11338 + if (save == 0x9DE3BFA8U &&
11339 + (call & 0xC0000000U) == 0x40000000U &&
11340 + nop == 0x01000000U)
11341 + {
11342 + unsigned int dl_resolve = regs->pc + ((((call | 0xC0000000U) ^ 0x20000000U) + 0x20000000U) << 2);
11343 +
11344 + regs->u_regs[UREG_RETPC] = regs->pc;
11345 + regs->pc = dl_resolve;
11346 + regs->npc = dl_resolve+4;
11347 + return 3;
11348 + }
11349 + } while (0);
11350 +#endif
11351 +
11352 + return 1;
11353 +}
11354 +
11355 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
11356 +{
11357 + unsigned long i;
11358 +
11359 + printk(KERN_ERR "PAX: bytes at PC: ");
11360 + for (i = 0; i < 8; i++) {
11361 + unsigned int c;
11362 + if (get_user(c, (unsigned int *)pc+i))
11363 + printk(KERN_CONT "???????? ");
11364 + else
11365 + printk(KERN_CONT "%08x ", c);
11366 + }
11367 + printk("\n");
11368 +}
11369 +#endif
11370 +
11371 static noinline void do_fault_siginfo(int code, int sig, struct pt_regs *regs,
11372 int text_fault)
11373 {
11374 @@ -229,6 +503,24 @@ good_area:
11375 if (!(vma->vm_flags & VM_WRITE))
11376 goto bad_area;
11377 } else {
11378 +
11379 +#ifdef CONFIG_PAX_PAGEEXEC
11380 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && text_fault && !(vma->vm_flags & VM_EXEC)) {
11381 + up_read(&mm->mmap_sem);
11382 + switch (pax_handle_fetch_fault(regs)) {
11383 +
11384 +#ifdef CONFIG_PAX_EMUPLT
11385 + case 2:
11386 + case 3:
11387 + return;
11388 +#endif
11389 +
11390 + }
11391 + pax_report_fault(regs, (void *)regs->pc, (void *)regs->u_regs[UREG_FP]);
11392 + do_group_exit(SIGKILL);
11393 + }
11394 +#endif
11395 +
11396 /* Allow reads even for write-only mappings */
11397 if (!(vma->vm_flags & (VM_READ | VM_EXEC)))
11398 goto bad_area;
11399 diff --git a/arch/sparc/mm/fault_64.c b/arch/sparc/mm/fault_64.c
11400 index 4ced3fc..234f1e4 100644
11401 --- a/arch/sparc/mm/fault_64.c
11402 +++ b/arch/sparc/mm/fault_64.c
11403 @@ -22,6 +22,9 @@
11404 #include <linux/kdebug.h>
11405 #include <linux/percpu.h>
11406 #include <linux/context_tracking.h>
11407 +#include <linux/slab.h>
11408 +#include <linux/pagemap.h>
11409 +#include <linux/compiler.h>
11410
11411 #include <asm/page.h>
11412 #include <asm/pgtable.h>
11413 @@ -75,7 +78,7 @@ static void __kprobes bad_kernel_pc(struct pt_regs *regs, unsigned long vaddr)
11414 printk(KERN_CRIT "OOPS: Bogus kernel PC [%016lx] in fault handler\n",
11415 regs->tpc);
11416 printk(KERN_CRIT "OOPS: RPC [%016lx]\n", regs->u_regs[15]);
11417 - printk("OOPS: RPC <%pS>\n", (void *) regs->u_regs[15]);
11418 + printk("OOPS: RPC <%pA>\n", (void *) regs->u_regs[15]);
11419 printk(KERN_CRIT "OOPS: Fault was to vaddr[%lx]\n", vaddr);
11420 dump_stack();
11421 unhandled_fault(regs->tpc, current, regs);
11422 @@ -281,6 +284,466 @@ static void noinline __kprobes bogus_32bit_fault_tpc(struct pt_regs *regs)
11423 show_regs(regs);
11424 }
11425
11426 +#ifdef CONFIG_PAX_PAGEEXEC
11427 +#ifdef CONFIG_PAX_DLRESOLVE
11428 +static void pax_emuplt_close(struct vm_area_struct *vma)
11429 +{
11430 + vma->vm_mm->call_dl_resolve = 0UL;
11431 +}
11432 +
11433 +static int pax_emuplt_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
11434 +{
11435 + unsigned int *kaddr;
11436 +
11437 + vmf->page = alloc_page(GFP_HIGHUSER);
11438 + if (!vmf->page)
11439 + return VM_FAULT_OOM;
11440 +
11441 + kaddr = kmap(vmf->page);
11442 + memset(kaddr, 0, PAGE_SIZE);
11443 + kaddr[0] = 0x9DE3BFA8U; /* save */
11444 + flush_dcache_page(vmf->page);
11445 + kunmap(vmf->page);
11446 + return VM_FAULT_MAJOR;
11447 +}
11448 +
11449 +static const struct vm_operations_struct pax_vm_ops = {
11450 + .close = pax_emuplt_close,
11451 + .fault = pax_emuplt_fault
11452 +};
11453 +
11454 +static int pax_insert_vma(struct vm_area_struct *vma, unsigned long addr)
11455 +{
11456 + int ret;
11457 +
11458 + INIT_LIST_HEAD(&vma->anon_vma_chain);
11459 + vma->vm_mm = current->mm;
11460 + vma->vm_start = addr;
11461 + vma->vm_end = addr + PAGE_SIZE;
11462 + vma->vm_flags = VM_READ | VM_EXEC | VM_MAYREAD | VM_MAYEXEC;
11463 + vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
11464 + vma->vm_ops = &pax_vm_ops;
11465 +
11466 + ret = insert_vm_struct(current->mm, vma);
11467 + if (ret)
11468 + return ret;
11469 +
11470 + ++current->mm->total_vm;
11471 + return 0;
11472 +}
11473 +#endif
11474 +
11475 +/*
11476 + * PaX: decide what to do with offenders (regs->tpc = fault address)
11477 + *
11478 + * returns 1 when task should be killed
11479 + * 2 when patched PLT trampoline was detected
11480 + * 3 when unpatched PLT trampoline was detected
11481 + */
11482 +static int pax_handle_fetch_fault(struct pt_regs *regs)
11483 +{
11484 +
11485 +#ifdef CONFIG_PAX_EMUPLT
11486 + int err;
11487 +
11488 + do { /* PaX: patched PLT emulation #1 */
11489 + unsigned int sethi1, sethi2, jmpl;
11490 +
11491 + err = get_user(sethi1, (unsigned int *)regs->tpc);
11492 + err |= get_user(sethi2, (unsigned int *)(regs->tpc+4));
11493 + err |= get_user(jmpl, (unsigned int *)(regs->tpc+8));
11494 +
11495 + if (err)
11496 + break;
11497 +
11498 + if ((sethi1 & 0xFFC00000U) == 0x03000000U &&
11499 + (sethi2 & 0xFFC00000U) == 0x03000000U &&
11500 + (jmpl & 0xFFFFE000U) == 0x81C06000U)
11501 + {
11502 + unsigned long addr;
11503 +
11504 + regs->u_regs[UREG_G1] = (sethi2 & 0x003FFFFFU) << 10;
11505 + addr = regs->u_regs[UREG_G1];
11506 + addr += (((jmpl | 0xFFFFFFFFFFFFE000UL) ^ 0x00001000UL) + 0x00001000UL);
11507 +
11508 + if (test_thread_flag(TIF_32BIT))
11509 + addr &= 0xFFFFFFFFUL;
11510 +
11511 + regs->tpc = addr;
11512 + regs->tnpc = addr+4;
11513 + return 2;
11514 + }
11515 + } while (0);
11516 +
11517 + do { /* PaX: patched PLT emulation #2 */
11518 + unsigned int ba;
11519 +
11520 + err = get_user(ba, (unsigned int *)regs->tpc);
11521 +
11522 + if (err)
11523 + break;
11524 +
11525 + if ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30480000U) {
11526 + unsigned long addr;
11527 +
11528 + if ((ba & 0xFFC00000U) == 0x30800000U)
11529 + addr = regs->tpc + ((((ba | 0xFFFFFFFFFFC00000UL) ^ 0x00200000UL) + 0x00200000UL) << 2);
11530 + else
11531 + addr = regs->tpc + ((((ba | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
11532 +
11533 + if (test_thread_flag(TIF_32BIT))
11534 + addr &= 0xFFFFFFFFUL;
11535 +
11536 + regs->tpc = addr;
11537 + regs->tnpc = addr+4;
11538 + return 2;
11539 + }
11540 + } while (0);
11541 +
11542 + do { /* PaX: patched PLT emulation #3 */
11543 + unsigned int sethi, bajmpl, nop;
11544 +
11545 + err = get_user(sethi, (unsigned int *)regs->tpc);
11546 + err |= get_user(bajmpl, (unsigned int *)(regs->tpc+4));
11547 + err |= get_user(nop, (unsigned int *)(regs->tpc+8));
11548 +
11549 + if (err)
11550 + break;
11551 +
11552 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
11553 + ((bajmpl & 0xFFFFE000U) == 0x81C06000U || (bajmpl & 0xFFF80000U) == 0x30480000U) &&
11554 + nop == 0x01000000U)
11555 + {
11556 + unsigned long addr;
11557 +
11558 + addr = (sethi & 0x003FFFFFU) << 10;
11559 + regs->u_regs[UREG_G1] = addr;
11560 + if ((bajmpl & 0xFFFFE000U) == 0x81C06000U)
11561 + addr += (((bajmpl | 0xFFFFFFFFFFFFE000UL) ^ 0x00001000UL) + 0x00001000UL);
11562 + else
11563 + addr = regs->tpc + ((((bajmpl | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
11564 +
11565 + if (test_thread_flag(TIF_32BIT))
11566 + addr &= 0xFFFFFFFFUL;
11567 +
11568 + regs->tpc = addr;
11569 + regs->tnpc = addr+4;
11570 + return 2;
11571 + }
11572 + } while (0);
11573 +
11574 + do { /* PaX: patched PLT emulation #4 */
11575 + unsigned int sethi, mov1, call, mov2;
11576 +
11577 + err = get_user(sethi, (unsigned int *)regs->tpc);
11578 + err |= get_user(mov1, (unsigned int *)(regs->tpc+4));
11579 + err |= get_user(call, (unsigned int *)(regs->tpc+8));
11580 + err |= get_user(mov2, (unsigned int *)(regs->tpc+12));
11581 +
11582 + if (err)
11583 + break;
11584 +
11585 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
11586 + mov1 == 0x8210000FU &&
11587 + (call & 0xC0000000U) == 0x40000000U &&
11588 + mov2 == 0x9E100001U)
11589 + {
11590 + unsigned long addr;
11591 +
11592 + regs->u_regs[UREG_G1] = regs->u_regs[UREG_RETPC];
11593 + addr = regs->tpc + 4 + ((((call | 0xFFFFFFFFC0000000UL) ^ 0x20000000UL) + 0x20000000UL) << 2);
11594 +
11595 + if (test_thread_flag(TIF_32BIT))
11596 + addr &= 0xFFFFFFFFUL;
11597 +
11598 + regs->tpc = addr;
11599 + regs->tnpc = addr+4;
11600 + return 2;
11601 + }
11602 + } while (0);
11603 +
11604 + do { /* PaX: patched PLT emulation #5 */
11605 + unsigned int sethi, sethi1, sethi2, or1, or2, sllx, jmpl, nop;
11606 +
11607 + err = get_user(sethi, (unsigned int *)regs->tpc);
11608 + err |= get_user(sethi1, (unsigned int *)(regs->tpc+4));
11609 + err |= get_user(sethi2, (unsigned int *)(regs->tpc+8));
11610 + err |= get_user(or1, (unsigned int *)(regs->tpc+12));
11611 + err |= get_user(or2, (unsigned int *)(regs->tpc+16));
11612 + err |= get_user(sllx, (unsigned int *)(regs->tpc+20));
11613 + err |= get_user(jmpl, (unsigned int *)(regs->tpc+24));
11614 + err |= get_user(nop, (unsigned int *)(regs->tpc+28));
11615 +
11616 + if (err)
11617 + break;
11618 +
11619 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
11620 + (sethi1 & 0xFFC00000U) == 0x03000000U &&
11621 + (sethi2 & 0xFFC00000U) == 0x0B000000U &&
11622 + (or1 & 0xFFFFE000U) == 0x82106000U &&
11623 + (or2 & 0xFFFFE000U) == 0x8A116000U &&
11624 + sllx == 0x83287020U &&
11625 + jmpl == 0x81C04005U &&
11626 + nop == 0x01000000U)
11627 + {
11628 + unsigned long addr;
11629 +
11630 + regs->u_regs[UREG_G1] = ((sethi1 & 0x003FFFFFU) << 10) | (or1 & 0x000003FFU);
11631 + regs->u_regs[UREG_G1] <<= 32;
11632 + regs->u_regs[UREG_G5] = ((sethi2 & 0x003FFFFFU) << 10) | (or2 & 0x000003FFU);
11633 + addr = regs->u_regs[UREG_G1] + regs->u_regs[UREG_G5];
11634 + regs->tpc = addr;
11635 + regs->tnpc = addr+4;
11636 + return 2;
11637 + }
11638 + } while (0);
11639 +
11640 + do { /* PaX: patched PLT emulation #6 */
11641 + unsigned int sethi, sethi1, sethi2, sllx, or, jmpl, nop;
11642 +
11643 + err = get_user(sethi, (unsigned int *)regs->tpc);
11644 + err |= get_user(sethi1, (unsigned int *)(regs->tpc+4));
11645 + err |= get_user(sethi2, (unsigned int *)(regs->tpc+8));
11646 + err |= get_user(sllx, (unsigned int *)(regs->tpc+12));
11647 + err |= get_user(or, (unsigned int *)(regs->tpc+16));
11648 + err |= get_user(jmpl, (unsigned int *)(regs->tpc+20));
11649 + err |= get_user(nop, (unsigned int *)(regs->tpc+24));
11650 +
11651 + if (err)
11652 + break;
11653 +
11654 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
11655 + (sethi1 & 0xFFC00000U) == 0x03000000U &&
11656 + (sethi2 & 0xFFC00000U) == 0x0B000000U &&
11657 + sllx == 0x83287020U &&
11658 + (or & 0xFFFFE000U) == 0x8A116000U &&
11659 + jmpl == 0x81C04005U &&
11660 + nop == 0x01000000U)
11661 + {
11662 + unsigned long addr;
11663 +
11664 + regs->u_regs[UREG_G1] = (sethi1 & 0x003FFFFFU) << 10;
11665 + regs->u_regs[UREG_G1] <<= 32;
11666 + regs->u_regs[UREG_G5] = ((sethi2 & 0x003FFFFFU) << 10) | (or & 0x3FFU);
11667 + addr = regs->u_regs[UREG_G1] + regs->u_regs[UREG_G5];
11668 + regs->tpc = addr;
11669 + regs->tnpc = addr+4;
11670 + return 2;
11671 + }
11672 + } while (0);
11673 +
11674 + do { /* PaX: unpatched PLT emulation step 1 */
11675 + unsigned int sethi, ba, nop;
11676 +
11677 + err = get_user(sethi, (unsigned int *)regs->tpc);
11678 + err |= get_user(ba, (unsigned int *)(regs->tpc+4));
11679 + err |= get_user(nop, (unsigned int *)(regs->tpc+8));
11680 +
11681 + if (err)
11682 + break;
11683 +
11684 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
11685 + ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30680000U) &&
11686 + nop == 0x01000000U)
11687 + {
11688 + unsigned long addr;
11689 + unsigned int save, call;
11690 + unsigned int sethi1, sethi2, or1, or2, sllx, add, jmpl;
11691 +
11692 + if ((ba & 0xFFC00000U) == 0x30800000U)
11693 + addr = regs->tpc + 4 + ((((ba | 0xFFFFFFFFFFC00000UL) ^ 0x00200000UL) + 0x00200000UL) << 2);
11694 + else
11695 + addr = regs->tpc + 4 + ((((ba | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
11696 +
11697 + if (test_thread_flag(TIF_32BIT))
11698 + addr &= 0xFFFFFFFFUL;
11699 +
11700 + err = get_user(save, (unsigned int *)addr);
11701 + err |= get_user(call, (unsigned int *)(addr+4));
11702 + err |= get_user(nop, (unsigned int *)(addr+8));
11703 + if (err)
11704 + break;
11705 +
11706 +#ifdef CONFIG_PAX_DLRESOLVE
11707 + if (save == 0x9DE3BFA8U &&
11708 + (call & 0xC0000000U) == 0x40000000U &&
11709 + nop == 0x01000000U)
11710 + {
11711 + struct vm_area_struct *vma;
11712 + unsigned long call_dl_resolve;
11713 +
11714 + down_read(&current->mm->mmap_sem);
11715 + call_dl_resolve = current->mm->call_dl_resolve;
11716 + up_read(&current->mm->mmap_sem);
11717 + if (likely(call_dl_resolve))
11718 + goto emulate;
11719 +
11720 + vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
11721 +
11722 + down_write(&current->mm->mmap_sem);
11723 + if (current->mm->call_dl_resolve) {
11724 + call_dl_resolve = current->mm->call_dl_resolve;
11725 + up_write(&current->mm->mmap_sem);
11726 + if (vma)
11727 + kmem_cache_free(vm_area_cachep, vma);
11728 + goto emulate;
11729 + }
11730 +
11731 + call_dl_resolve = get_unmapped_area(NULL, 0UL, PAGE_SIZE, 0UL, MAP_PRIVATE);
11732 + if (!vma || (call_dl_resolve & ~PAGE_MASK)) {
11733 + up_write(&current->mm->mmap_sem);
11734 + if (vma)
11735 + kmem_cache_free(vm_area_cachep, vma);
11736 + return 1;
11737 + }
11738 +
11739 + if (pax_insert_vma(vma, call_dl_resolve)) {
11740 + up_write(&current->mm->mmap_sem);
11741 + kmem_cache_free(vm_area_cachep, vma);
11742 + return 1;
11743 + }
11744 +
11745 + current->mm->call_dl_resolve = call_dl_resolve;
11746 + up_write(&current->mm->mmap_sem);
11747 +
11748 +emulate:
11749 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
11750 + regs->tpc = call_dl_resolve;
11751 + regs->tnpc = addr+4;
11752 + return 3;
11753 + }
11754 +#endif
11755 +
11756 + /* PaX: glibc 2.4+ generates sethi/jmpl instead of save/call */
11757 + if ((save & 0xFFC00000U) == 0x05000000U &&
11758 + (call & 0xFFFFE000U) == 0x85C0A000U &&
11759 + nop == 0x01000000U)
11760 + {
11761 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
11762 + regs->u_regs[UREG_G2] = addr + 4;
11763 + addr = (save & 0x003FFFFFU) << 10;
11764 + addr += (((call | 0xFFFFFFFFFFFFE000UL) ^ 0x00001000UL) + 0x00001000UL);
11765 +
11766 + if (test_thread_flag(TIF_32BIT))
11767 + addr &= 0xFFFFFFFFUL;
11768 +
11769 + regs->tpc = addr;
11770 + regs->tnpc = addr+4;
11771 + return 3;
11772 + }
11773 +
11774 + /* PaX: 64-bit PLT stub */
11775 + err = get_user(sethi1, (unsigned int *)addr);
11776 + err |= get_user(sethi2, (unsigned int *)(addr+4));
11777 + err |= get_user(or1, (unsigned int *)(addr+8));
11778 + err |= get_user(or2, (unsigned int *)(addr+12));
11779 + err |= get_user(sllx, (unsigned int *)(addr+16));
11780 + err |= get_user(add, (unsigned int *)(addr+20));
11781 + err |= get_user(jmpl, (unsigned int *)(addr+24));
11782 + err |= get_user(nop, (unsigned int *)(addr+28));
11783 + if (err)
11784 + break;
11785 +
11786 + if ((sethi1 & 0xFFC00000U) == 0x09000000U &&
11787 + (sethi2 & 0xFFC00000U) == 0x0B000000U &&
11788 + (or1 & 0xFFFFE000U) == 0x88112000U &&
11789 + (or2 & 0xFFFFE000U) == 0x8A116000U &&
11790 + sllx == 0x89293020U &&
11791 + add == 0x8A010005U &&
11792 + jmpl == 0x89C14000U &&
11793 + nop == 0x01000000U)
11794 + {
11795 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
11796 + regs->u_regs[UREG_G4] = ((sethi1 & 0x003FFFFFU) << 10) | (or1 & 0x000003FFU);
11797 + regs->u_regs[UREG_G4] <<= 32;
11798 + regs->u_regs[UREG_G5] = ((sethi2 & 0x003FFFFFU) << 10) | (or2 & 0x000003FFU);
11799 + regs->u_regs[UREG_G5] += regs->u_regs[UREG_G4];
11800 + regs->u_regs[UREG_G4] = addr + 24;
11801 + addr = regs->u_regs[UREG_G5];
11802 + regs->tpc = addr;
11803 + regs->tnpc = addr+4;
11804 + return 3;
11805 + }
11806 + }
11807 + } while (0);
11808 +
11809 +#ifdef CONFIG_PAX_DLRESOLVE
11810 + do { /* PaX: unpatched PLT emulation step 2 */
11811 + unsigned int save, call, nop;
11812 +
11813 + err = get_user(save, (unsigned int *)(regs->tpc-4));
11814 + err |= get_user(call, (unsigned int *)regs->tpc);
11815 + err |= get_user(nop, (unsigned int *)(regs->tpc+4));
11816 + if (err)
11817 + break;
11818 +
11819 + if (save == 0x9DE3BFA8U &&
11820 + (call & 0xC0000000U) == 0x40000000U &&
11821 + nop == 0x01000000U)
11822 + {
11823 + unsigned long dl_resolve = regs->tpc + ((((call | 0xFFFFFFFFC0000000UL) ^ 0x20000000UL) + 0x20000000UL) << 2);
11824 +
11825 + if (test_thread_flag(TIF_32BIT))
11826 + dl_resolve &= 0xFFFFFFFFUL;
11827 +
11828 + regs->u_regs[UREG_RETPC] = regs->tpc;
11829 + regs->tpc = dl_resolve;
11830 + regs->tnpc = dl_resolve+4;
11831 + return 3;
11832 + }
11833 + } while (0);
11834 +#endif
11835 +
11836 + do { /* PaX: patched PLT emulation #7, must be AFTER the unpatched PLT emulation */
11837 + unsigned int sethi, ba, nop;
11838 +
11839 + err = get_user(sethi, (unsigned int *)regs->tpc);
11840 + err |= get_user(ba, (unsigned int *)(regs->tpc+4));
11841 + err |= get_user(nop, (unsigned int *)(regs->tpc+8));
11842 +
11843 + if (err)
11844 + break;
11845 +
11846 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
11847 + (ba & 0xFFF00000U) == 0x30600000U &&
11848 + nop == 0x01000000U)
11849 + {
11850 + unsigned long addr;
11851 +
11852 + addr = (sethi & 0x003FFFFFU) << 10;
11853 + regs->u_regs[UREG_G1] = addr;
11854 + addr = regs->tpc + ((((ba | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
11855 +
11856 + if (test_thread_flag(TIF_32BIT))
11857 + addr &= 0xFFFFFFFFUL;
11858 +
11859 + regs->tpc = addr;
11860 + regs->tnpc = addr+4;
11861 + return 2;
11862 + }
11863 + } while (0);
11864 +
11865 +#endif
11866 +
11867 + return 1;
11868 +}
11869 +
11870 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
11871 +{
11872 + unsigned long i;
11873 +
11874 + printk(KERN_ERR "PAX: bytes at PC: ");
11875 + for (i = 0; i < 8; i++) {
11876 + unsigned int c;
11877 + if (get_user(c, (unsigned int *)pc+i))
11878 + printk(KERN_CONT "???????? ");
11879 + else
11880 + printk(KERN_CONT "%08x ", c);
11881 + }
11882 + printk("\n");
11883 +}
11884 +#endif
11885 +
11886 asmlinkage void __kprobes do_sparc64_fault(struct pt_regs *regs)
11887 {
11888 enum ctx_state prev_state = exception_enter();
11889 @@ -352,6 +815,29 @@ retry:
11890 if (!vma)
11891 goto bad_area;
11892
11893 +#ifdef CONFIG_PAX_PAGEEXEC
11894 + /* PaX: detect ITLB misses on non-exec pages */
11895 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && vma->vm_start <= address &&
11896 + !(vma->vm_flags & VM_EXEC) && (fault_code & FAULT_CODE_ITLB))
11897 + {
11898 + if (address != regs->tpc)
11899 + goto good_area;
11900 +
11901 + up_read(&mm->mmap_sem);
11902 + switch (pax_handle_fetch_fault(regs)) {
11903 +
11904 +#ifdef CONFIG_PAX_EMUPLT
11905 + case 2:
11906 + case 3:
11907 + return;
11908 +#endif
11909 +
11910 + }
11911 + pax_report_fault(regs, (void *)regs->tpc, (void *)(regs->u_regs[UREG_FP] + STACK_BIAS));
11912 + do_group_exit(SIGKILL);
11913 + }
11914 +#endif
11915 +
11916 /* Pure DTLB misses do not tell us whether the fault causing
11917 * load/store/atomic was a write or not, it only says that there
11918 * was no match. So in such a case we (carefully) read the
11919 diff --git a/arch/sparc/mm/hugetlbpage.c b/arch/sparc/mm/hugetlbpage.c
11920 index 9bd9ce8..dc84852 100644
11921 --- a/arch/sparc/mm/hugetlbpage.c
11922 +++ b/arch/sparc/mm/hugetlbpage.c
11923 @@ -25,8 +25,10 @@ static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *filp,
11924 unsigned long addr,
11925 unsigned long len,
11926 unsigned long pgoff,
11927 - unsigned long flags)
11928 + unsigned long flags,
11929 + unsigned long offset)
11930 {
11931 + struct mm_struct *mm = current->mm;
11932 unsigned long task_size = TASK_SIZE;
11933 struct vm_unmapped_area_info info;
11934
11935 @@ -35,15 +37,22 @@ static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *filp,
11936
11937 info.flags = 0;
11938 info.length = len;
11939 - info.low_limit = TASK_UNMAPPED_BASE;
11940 + info.low_limit = mm->mmap_base;
11941 info.high_limit = min(task_size, VA_EXCLUDE_START);
11942 info.align_mask = PAGE_MASK & ~HPAGE_MASK;
11943 info.align_offset = 0;
11944 + info.threadstack_offset = offset;
11945 addr = vm_unmapped_area(&info);
11946
11947 if ((addr & ~PAGE_MASK) && task_size > VA_EXCLUDE_END) {
11948 VM_BUG_ON(addr != -ENOMEM);
11949 info.low_limit = VA_EXCLUDE_END;
11950 +
11951 +#ifdef CONFIG_PAX_RANDMMAP
11952 + if (mm->pax_flags & MF_PAX_RANDMMAP)
11953 + info.low_limit += mm->delta_mmap;
11954 +#endif
11955 +
11956 info.high_limit = task_size;
11957 addr = vm_unmapped_area(&info);
11958 }
11959 @@ -55,7 +64,8 @@ static unsigned long
11960 hugetlb_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
11961 const unsigned long len,
11962 const unsigned long pgoff,
11963 - const unsigned long flags)
11964 + const unsigned long flags,
11965 + const unsigned long offset)
11966 {
11967 struct mm_struct *mm = current->mm;
11968 unsigned long addr = addr0;
11969 @@ -70,6 +80,7 @@ hugetlb_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
11970 info.high_limit = mm->mmap_base;
11971 info.align_mask = PAGE_MASK & ~HPAGE_MASK;
11972 info.align_offset = 0;
11973 + info.threadstack_offset = offset;
11974 addr = vm_unmapped_area(&info);
11975
11976 /*
11977 @@ -82,6 +93,12 @@ hugetlb_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
11978 VM_BUG_ON(addr != -ENOMEM);
11979 info.flags = 0;
11980 info.low_limit = TASK_UNMAPPED_BASE;
11981 +
11982 +#ifdef CONFIG_PAX_RANDMMAP
11983 + if (mm->pax_flags & MF_PAX_RANDMMAP)
11984 + info.low_limit += mm->delta_mmap;
11985 +#endif
11986 +
11987 info.high_limit = STACK_TOP32;
11988 addr = vm_unmapped_area(&info);
11989 }
11990 @@ -96,6 +113,7 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
11991 struct mm_struct *mm = current->mm;
11992 struct vm_area_struct *vma;
11993 unsigned long task_size = TASK_SIZE;
11994 + unsigned long offset = gr_rand_threadstack_offset(mm, file, flags);
11995
11996 if (test_thread_flag(TIF_32BIT))
11997 task_size = STACK_TOP32;
11998 @@ -111,19 +129,22 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
11999 return addr;
12000 }
12001
12002 +#ifdef CONFIG_PAX_RANDMMAP
12003 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
12004 +#endif
12005 +
12006 if (addr) {
12007 addr = ALIGN(addr, HPAGE_SIZE);
12008 vma = find_vma(mm, addr);
12009 - if (task_size - len >= addr &&
12010 - (!vma || addr + len <= vma->vm_start))
12011 + if (task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
12012 return addr;
12013 }
12014 if (mm->get_unmapped_area == arch_get_unmapped_area)
12015 return hugetlb_get_unmapped_area_bottomup(file, addr, len,
12016 - pgoff, flags);
12017 + pgoff, flags, offset);
12018 else
12019 return hugetlb_get_unmapped_area_topdown(file, addr, len,
12020 - pgoff, flags);
12021 + pgoff, flags, offset);
12022 }
12023
12024 pte_t *huge_pte_alloc(struct mm_struct *mm,
12025 diff --git a/arch/sparc/mm/init_64.c b/arch/sparc/mm/init_64.c
12026 index ed3c969..42fe48d 100644
12027 --- a/arch/sparc/mm/init_64.c
12028 +++ b/arch/sparc/mm/init_64.c
12029 @@ -188,9 +188,9 @@ unsigned long sparc64_kern_sec_context __read_mostly;
12030 int num_kernel_image_mappings;
12031
12032 #ifdef CONFIG_DEBUG_DCFLUSH
12033 -atomic_t dcpage_flushes = ATOMIC_INIT(0);
12034 +atomic_unchecked_t dcpage_flushes = ATOMIC_INIT(0);
12035 #ifdef CONFIG_SMP
12036 -atomic_t dcpage_flushes_xcall = ATOMIC_INIT(0);
12037 +atomic_unchecked_t dcpage_flushes_xcall = ATOMIC_INIT(0);
12038 #endif
12039 #endif
12040
12041 @@ -198,7 +198,7 @@ inline void flush_dcache_page_impl(struct page *page)
12042 {
12043 BUG_ON(tlb_type == hypervisor);
12044 #ifdef CONFIG_DEBUG_DCFLUSH
12045 - atomic_inc(&dcpage_flushes);
12046 + atomic_inc_unchecked(&dcpage_flushes);
12047 #endif
12048
12049 #ifdef DCACHE_ALIASING_POSSIBLE
12050 @@ -466,10 +466,10 @@ void mmu_info(struct seq_file *m)
12051
12052 #ifdef CONFIG_DEBUG_DCFLUSH
12053 seq_printf(m, "DCPageFlushes\t: %d\n",
12054 - atomic_read(&dcpage_flushes));
12055 + atomic_read_unchecked(&dcpage_flushes));
12056 #ifdef CONFIG_SMP
12057 seq_printf(m, "DCPageFlushesXC\t: %d\n",
12058 - atomic_read(&dcpage_flushes_xcall));
12059 + atomic_read_unchecked(&dcpage_flushes_xcall));
12060 #endif /* CONFIG_SMP */
12061 #endif /* CONFIG_DEBUG_DCFLUSH */
12062 }
12063 diff --git a/arch/tile/Kconfig b/arch/tile/Kconfig
12064 index 85258ca..df97c79 100644
12065 --- a/arch/tile/Kconfig
12066 +++ b/arch/tile/Kconfig
12067 @@ -190,6 +190,7 @@ source "kernel/Kconfig.hz"
12068
12069 config KEXEC
12070 bool "kexec system call"
12071 + depends on !GRKERNSEC_KMEM
12072 ---help---
12073 kexec is a system call that implements the ability to shutdown your
12074 current kernel, and to start another kernel. It is like a reboot
12075 diff --git a/arch/tile/include/asm/atomic_64.h b/arch/tile/include/asm/atomic_64.h
12076 index ad220ee..2f537b3 100644
12077 --- a/arch/tile/include/asm/atomic_64.h
12078 +++ b/arch/tile/include/asm/atomic_64.h
12079 @@ -105,6 +105,16 @@ static inline long atomic64_add_unless(atomic64_t *v, long a, long u)
12080
12081 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
12082
12083 +#define atomic64_read_unchecked(v) atomic64_read(v)
12084 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
12085 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
12086 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
12087 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
12088 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
12089 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
12090 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
12091 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
12092 +
12093 /* Atomic dec and inc don't implement barrier, so provide them if needed. */
12094 #define smp_mb__before_atomic_dec() smp_mb()
12095 #define smp_mb__after_atomic_dec() smp_mb()
12096 diff --git a/arch/tile/include/asm/cache.h b/arch/tile/include/asm/cache.h
12097 index 6160761..00cac88 100644
12098 --- a/arch/tile/include/asm/cache.h
12099 +++ b/arch/tile/include/asm/cache.h
12100 @@ -15,11 +15,12 @@
12101 #ifndef _ASM_TILE_CACHE_H
12102 #define _ASM_TILE_CACHE_H
12103
12104 +#include <linux/const.h>
12105 #include <arch/chip.h>
12106
12107 /* bytes per L1 data cache line */
12108 #define L1_CACHE_SHIFT CHIP_L1D_LOG_LINE_SIZE()
12109 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
12110 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
12111
12112 /* bytes per L2 cache line */
12113 #define L2_CACHE_SHIFT CHIP_L2_LOG_LINE_SIZE()
12114 diff --git a/arch/tile/include/asm/uaccess.h b/arch/tile/include/asm/uaccess.h
12115 index b6cde32..c0cb736 100644
12116 --- a/arch/tile/include/asm/uaccess.h
12117 +++ b/arch/tile/include/asm/uaccess.h
12118 @@ -414,9 +414,9 @@ static inline unsigned long __must_check copy_from_user(void *to,
12119 const void __user *from,
12120 unsigned long n)
12121 {
12122 - int sz = __compiletime_object_size(to);
12123 + size_t sz = __compiletime_object_size(to);
12124
12125 - if (likely(sz == -1 || sz >= n))
12126 + if (likely(sz == (size_t)-1 || sz >= n))
12127 n = _copy_from_user(to, from, n);
12128 else
12129 copy_from_user_overflow();
12130 diff --git a/arch/tile/mm/hugetlbpage.c b/arch/tile/mm/hugetlbpage.c
12131 index 0cb3bba..7338b2d 100644
12132 --- a/arch/tile/mm/hugetlbpage.c
12133 +++ b/arch/tile/mm/hugetlbpage.c
12134 @@ -212,6 +212,7 @@ static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *file,
12135 info.high_limit = TASK_SIZE;
12136 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
12137 info.align_offset = 0;
12138 + info.threadstack_offset = 0;
12139 return vm_unmapped_area(&info);
12140 }
12141
12142 @@ -229,6 +230,7 @@ static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
12143 info.high_limit = current->mm->mmap_base;
12144 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
12145 info.align_offset = 0;
12146 + info.threadstack_offset = 0;
12147 addr = vm_unmapped_area(&info);
12148
12149 /*
12150 diff --git a/arch/um/Makefile b/arch/um/Makefile
12151 index 36e658a..71a5c5a 100644
12152 --- a/arch/um/Makefile
12153 +++ b/arch/um/Makefile
12154 @@ -72,6 +72,10 @@ USER_CFLAGS = $(patsubst $(KERNEL_DEFINES),,$(patsubst -D__KERNEL__,,\
12155 $(patsubst -I%,,$(KBUILD_CFLAGS)))) $(ARCH_INCLUDE) $(MODE_INCLUDE) \
12156 $(filter -I%,$(CFLAGS)) -D_FILE_OFFSET_BITS=64 -idirafter include
12157
12158 +ifdef CONSTIFY_PLUGIN
12159 +USER_CFLAGS += -fplugin-arg-constify_plugin-no-constify
12160 +endif
12161 +
12162 #This will adjust *FLAGS accordingly to the platform.
12163 include $(srctree)/$(ARCH_DIR)/Makefile-os-$(OS)
12164
12165 diff --git a/arch/um/include/asm/cache.h b/arch/um/include/asm/cache.h
12166 index 19e1bdd..3665b77 100644
12167 --- a/arch/um/include/asm/cache.h
12168 +++ b/arch/um/include/asm/cache.h
12169 @@ -1,6 +1,7 @@
12170 #ifndef __UM_CACHE_H
12171 #define __UM_CACHE_H
12172
12173 +#include <linux/const.h>
12174
12175 #if defined(CONFIG_UML_X86) && !defined(CONFIG_64BIT)
12176 # define L1_CACHE_SHIFT (CONFIG_X86_L1_CACHE_SHIFT)
12177 @@ -12,6 +13,6 @@
12178 # define L1_CACHE_SHIFT 5
12179 #endif
12180
12181 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
12182 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
12183
12184 #endif
12185 diff --git a/arch/um/include/asm/kmap_types.h b/arch/um/include/asm/kmap_types.h
12186 index 2e0a6b1..a64d0f5 100644
12187 --- a/arch/um/include/asm/kmap_types.h
12188 +++ b/arch/um/include/asm/kmap_types.h
12189 @@ -8,6 +8,6 @@
12190
12191 /* No more #include "asm/arch/kmap_types.h" ! */
12192
12193 -#define KM_TYPE_NR 14
12194 +#define KM_TYPE_NR 15
12195
12196 #endif
12197 diff --git a/arch/um/include/asm/page.h b/arch/um/include/asm/page.h
12198 index 5ff53d9..5850cdf 100644
12199 --- a/arch/um/include/asm/page.h
12200 +++ b/arch/um/include/asm/page.h
12201 @@ -14,6 +14,9 @@
12202 #define PAGE_SIZE (_AC(1, UL) << PAGE_SHIFT)
12203 #define PAGE_MASK (~(PAGE_SIZE-1))
12204
12205 +#define ktla_ktva(addr) (addr)
12206 +#define ktva_ktla(addr) (addr)
12207 +
12208 #ifndef __ASSEMBLY__
12209
12210 struct page;
12211 diff --git a/arch/um/include/asm/pgtable-3level.h b/arch/um/include/asm/pgtable-3level.h
12212 index 0032f92..cd151e0 100644
12213 --- a/arch/um/include/asm/pgtable-3level.h
12214 +++ b/arch/um/include/asm/pgtable-3level.h
12215 @@ -58,6 +58,7 @@
12216 #define pud_present(x) (pud_val(x) & _PAGE_PRESENT)
12217 #define pud_populate(mm, pud, pmd) \
12218 set_pud(pud, __pud(_PAGE_TABLE + __pa(pmd)))
12219 +#define pud_populate_kernel(mm, pud, pmd) pud_populate((mm), (pud), (pmd))
12220
12221 #ifdef CONFIG_64BIT
12222 #define set_pud(pudptr, pudval) set_64bit((u64 *) (pudptr), pud_val(pudval))
12223 diff --git a/arch/um/kernel/process.c b/arch/um/kernel/process.c
12224 index f17bca8..48adb87 100644
12225 --- a/arch/um/kernel/process.c
12226 +++ b/arch/um/kernel/process.c
12227 @@ -356,22 +356,6 @@ int singlestepping(void * t)
12228 return 2;
12229 }
12230
12231 -/*
12232 - * Only x86 and x86_64 have an arch_align_stack().
12233 - * All other arches have "#define arch_align_stack(x) (x)"
12234 - * in their asm/exec.h
12235 - * As this is included in UML from asm-um/system-generic.h,
12236 - * we can use it to behave as the subarch does.
12237 - */
12238 -#ifndef arch_align_stack
12239 -unsigned long arch_align_stack(unsigned long sp)
12240 -{
12241 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
12242 - sp -= get_random_int() % 8192;
12243 - return sp & ~0xf;
12244 -}
12245 -#endif
12246 -
12247 unsigned long get_wchan(struct task_struct *p)
12248 {
12249 unsigned long stack_page, sp, ip;
12250 diff --git a/arch/unicore32/include/asm/cache.h b/arch/unicore32/include/asm/cache.h
12251 index ad8f795..2c7eec6 100644
12252 --- a/arch/unicore32/include/asm/cache.h
12253 +++ b/arch/unicore32/include/asm/cache.h
12254 @@ -12,8 +12,10 @@
12255 #ifndef __UNICORE_CACHE_H__
12256 #define __UNICORE_CACHE_H__
12257
12258 -#define L1_CACHE_SHIFT (5)
12259 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
12260 +#include <linux/const.h>
12261 +
12262 +#define L1_CACHE_SHIFT 5
12263 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
12264
12265 /*
12266 * Memory returned by kmalloc() may be used for DMA, so we must make
12267 diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
12268 index 25d2c6f..f280b3a 100644
12269 --- a/arch/x86/Kconfig
12270 +++ b/arch/x86/Kconfig
12271 @@ -127,7 +127,7 @@ config X86
12272 select RTC_LIB
12273 select HAVE_DEBUG_STACKOVERFLOW
12274 select HAVE_IRQ_EXIT_ON_IRQ_STACK if X86_64
12275 - select HAVE_CC_STACKPROTECTOR
12276 + select HAVE_CC_STACKPROTECTOR if X86_64 || !PAX_MEMORY_UDEREF
12277 select GENERIC_CPU_AUTOPROBE
12278 select HAVE_ARCH_AUDITSYSCALL
12279
12280 @@ -251,7 +251,7 @@ config X86_HT
12281
12282 config X86_32_LAZY_GS
12283 def_bool y
12284 - depends on X86_32 && !CC_STACKPROTECTOR
12285 + depends on X86_32 && !CC_STACKPROTECTOR && !PAX_MEMORY_UDEREF
12286
12287 config ARCH_HWEIGHT_CFLAGS
12288 string
12289 @@ -545,6 +545,7 @@ config SCHED_OMIT_FRAME_POINTER
12290
12291 menuconfig HYPERVISOR_GUEST
12292 bool "Linux guest support"
12293 + depends on !GRKERNSEC_CONFIG_AUTO || GRKERNSEC_CONFIG_VIRT_GUEST || (GRKERNSEC_CONFIG_VIRT_HOST && GRKERNSEC_CONFIG_VIRT_XEN)
12294 ---help---
12295 Say Y here to enable options for running Linux under various hyper-
12296 visors. This option enables basic hypervisor detection and platform
12297 @@ -1054,6 +1055,7 @@ choice
12298
12299 config NOHIGHMEM
12300 bool "off"
12301 + depends on !(PAX_PAGEEXEC && PAX_ENABLE_PAE)
12302 ---help---
12303 Linux can use up to 64 Gigabytes of physical memory on x86 systems.
12304 However, the address space of 32-bit x86 processors is only 4
12305 @@ -1090,6 +1092,7 @@ config NOHIGHMEM
12306
12307 config HIGHMEM4G
12308 bool "4GB"
12309 + depends on !(PAX_PAGEEXEC && PAX_ENABLE_PAE)
12310 ---help---
12311 Select this if you have a 32-bit processor and between 1 and 4
12312 gigabytes of physical RAM.
12313 @@ -1142,7 +1145,7 @@ config PAGE_OFFSET
12314 hex
12315 default 0xB0000000 if VMSPLIT_3G_OPT
12316 default 0x80000000 if VMSPLIT_2G
12317 - default 0x78000000 if VMSPLIT_2G_OPT
12318 + default 0x70000000 if VMSPLIT_2G_OPT
12319 default 0x40000000 if VMSPLIT_1G
12320 default 0xC0000000
12321 depends on X86_32
12322 @@ -1555,6 +1558,7 @@ source kernel/Kconfig.hz
12323
12324 config KEXEC
12325 bool "kexec system call"
12326 + depends on !GRKERNSEC_KMEM
12327 ---help---
12328 kexec is a system call that implements the ability to shutdown your
12329 current kernel, and to start another kernel. It is like a reboot
12330 @@ -1706,7 +1710,9 @@ config X86_NEED_RELOCS
12331
12332 config PHYSICAL_ALIGN
12333 hex "Alignment value to which kernel should be aligned"
12334 - default "0x200000"
12335 + default "0x1000000"
12336 + range 0x200000 0x1000000 if PAX_KERNEXEC && X86_PAE
12337 + range 0x400000 0x1000000 if PAX_KERNEXEC && !X86_PAE
12338 range 0x2000 0x1000000 if X86_32
12339 range 0x200000 0x1000000 if X86_64
12340 ---help---
12341 @@ -1789,6 +1795,7 @@ config COMPAT_VDSO
12342 def_bool n
12343 prompt "Disable the 32-bit vDSO (needed for glibc 2.3.3)"
12344 depends on X86_32 || IA32_EMULATION
12345 + depends on !PAX_PAGEEXEC && !PAX_SEGMEXEC && !PAX_KERNEXEC && !PAX_MEMORY_UDEREF
12346 ---help---
12347 Certain buggy versions of glibc will crash if they are
12348 presented with a 32-bit vDSO that is not mapped at the address
12349 diff --git a/arch/x86/Kconfig.cpu b/arch/x86/Kconfig.cpu
12350 index 6983314..54ad7e8 100644
12351 --- a/arch/x86/Kconfig.cpu
12352 +++ b/arch/x86/Kconfig.cpu
12353 @@ -319,7 +319,7 @@ config X86_PPRO_FENCE
12354
12355 config X86_F00F_BUG
12356 def_bool y
12357 - depends on M586MMX || M586TSC || M586 || M486
12358 + depends on (M586MMX || M586TSC || M586 || M486) && !PAX_KERNEXEC
12359
12360 config X86_INVD_BUG
12361 def_bool y
12362 @@ -327,7 +327,7 @@ config X86_INVD_BUG
12363
12364 config X86_ALIGNMENT_16
12365 def_bool y
12366 - depends on MWINCHIP3D || MWINCHIPC6 || MCYRIXIII || MELAN || MK6 || M586MMX || M586TSC || M586 || M486 || MVIAC3_2 || MGEODEGX1
12367 + depends on MWINCHIP3D || MWINCHIPC6 || MCYRIXIII || X86_ELAN || MK8 || MK7 || MK6 || MCORE2 || MPENTIUM4 || MPENTIUMIII || MPENTIUMII || M686 || M586MMX || M586TSC || M586 || M486 || MVIAC3_2 || MGEODEGX1
12368
12369 config X86_INTEL_USERCOPY
12370 def_bool y
12371 @@ -369,7 +369,7 @@ config X86_CMPXCHG64
12372 # generates cmov.
12373 config X86_CMOV
12374 def_bool y
12375 - depends on (MK8 || MK7 || MCORE2 || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MVIAC3_2 || MVIAC7 || MCRUSOE || MEFFICEON || X86_64 || MATOM || MGEODE_LX)
12376 + depends on (MK8 || MK7 || MCORE2 || MPSC || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MVIAC3_2 || MVIAC7 || MCRUSOE || MEFFICEON || X86_64 || MATOM || MGEODE_LX)
12377
12378 config X86_MINIMUM_CPU_FAMILY
12379 int
12380 diff --git a/arch/x86/Kconfig.debug b/arch/x86/Kconfig.debug
12381 index 61bd2ad..50b625d 100644
12382 --- a/arch/x86/Kconfig.debug
12383 +++ b/arch/x86/Kconfig.debug
12384 @@ -93,7 +93,7 @@ config EFI_PGT_DUMP
12385 config DEBUG_RODATA
12386 bool "Write protect kernel read-only data structures"
12387 default y
12388 - depends on DEBUG_KERNEL
12389 + depends on DEBUG_KERNEL && BROKEN
12390 ---help---
12391 Mark the kernel read-only data as write-protected in the pagetables,
12392 in order to catch accidental (and incorrect) writes to such const
12393 @@ -111,7 +111,7 @@ config DEBUG_RODATA_TEST
12394
12395 config DEBUG_SET_MODULE_RONX
12396 bool "Set loadable kernel module data as NX and text as RO"
12397 - depends on MODULES
12398 + depends on MODULES && BROKEN
12399 ---help---
12400 This option helps catch unintended modifications to loadable
12401 kernel module's text and read-only data. It also prevents execution
12402 diff --git a/arch/x86/Makefile b/arch/x86/Makefile
12403 index 33f71b0..c2cefa2 100644
12404 --- a/arch/x86/Makefile
12405 +++ b/arch/x86/Makefile
12406 @@ -71,9 +71,6 @@ ifeq ($(CONFIG_X86_32),y)
12407 # CPU-specific tuning. Anything which can be shared with UML should go here.
12408 include $(srctree)/arch/x86/Makefile_32.cpu
12409 KBUILD_CFLAGS += $(cflags-y)
12410 -
12411 - # temporary until string.h is fixed
12412 - KBUILD_CFLAGS += -ffreestanding
12413 else
12414 BITS := 64
12415 UTS_MACHINE := x86_64
12416 @@ -114,6 +111,9 @@ else
12417 KBUILD_CFLAGS += $(call cc-option,-maccumulate-outgoing-args)
12418 endif
12419
12420 +# temporary until string.h is fixed
12421 +KBUILD_CFLAGS += -ffreestanding
12422 +
12423 # Make sure compiler does not have buggy stack-protector support.
12424 ifdef CONFIG_CC_STACKPROTECTOR
12425 cc_has_sp := $(srctree)/scripts/gcc-x86_$(BITS)-has-stack-protector.sh
12426 @@ -271,3 +271,12 @@ define archhelp
12427 echo ' FDINITRD=file initrd for the booted kernel'
12428 echo ' kvmconfig - Enable additional options for guest kernel support'
12429 endef
12430 +
12431 +define OLD_LD
12432 +
12433 +*** ${VERSION}.${PATCHLEVEL} PaX kernels no longer build correctly with old versions of binutils.
12434 +*** Please upgrade your binutils to 2.18 or newer
12435 +endef
12436 +
12437 +archprepare:
12438 + $(if $(LDFLAGS_BUILD_ID),,$(error $(OLD_LD)))
12439 diff --git a/arch/x86/boot/Makefile b/arch/x86/boot/Makefile
12440 index dbe8dd2..2f0a98f 100644
12441 --- a/arch/x86/boot/Makefile
12442 +++ b/arch/x86/boot/Makefile
12443 @@ -52,6 +52,9 @@ $(obj)/cpustr.h: $(obj)/mkcpustr FORCE
12444 # ---------------------------------------------------------------------------
12445
12446 KBUILD_CFLAGS := $(USERINCLUDE) $(REALMODE_CFLAGS) -D_SETUP
12447 +ifdef CONSTIFY_PLUGIN
12448 +KBUILD_CFLAGS += -fplugin-arg-constify_plugin-no-constify
12449 +endif
12450 KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
12451 GCOV_PROFILE := n
12452
12453 diff --git a/arch/x86/boot/bitops.h b/arch/x86/boot/bitops.h
12454 index 878e4b9..20537ab 100644
12455 --- a/arch/x86/boot/bitops.h
12456 +++ b/arch/x86/boot/bitops.h
12457 @@ -26,7 +26,7 @@ static inline int variable_test_bit(int nr, const void *addr)
12458 u8 v;
12459 const u32 *p = (const u32 *)addr;
12460
12461 - asm("btl %2,%1; setc %0" : "=qm" (v) : "m" (*p), "Ir" (nr));
12462 + asm volatile("btl %2,%1; setc %0" : "=qm" (v) : "m" (*p), "Ir" (nr));
12463 return v;
12464 }
12465
12466 @@ -37,7 +37,7 @@ static inline int variable_test_bit(int nr, const void *addr)
12467
12468 static inline void set_bit(int nr, void *addr)
12469 {
12470 - asm("btsl %1,%0" : "+m" (*(u32 *)addr) : "Ir" (nr));
12471 + asm volatile("btsl %1,%0" : "+m" (*(u32 *)addr) : "Ir" (nr));
12472 }
12473
12474 #endif /* BOOT_BITOPS_H */
12475 diff --git a/arch/x86/boot/boot.h b/arch/x86/boot/boot.h
12476 index bd49ec6..94c7f58 100644
12477 --- a/arch/x86/boot/boot.h
12478 +++ b/arch/x86/boot/boot.h
12479 @@ -84,7 +84,7 @@ static inline void io_delay(void)
12480 static inline u16 ds(void)
12481 {
12482 u16 seg;
12483 - asm("movw %%ds,%0" : "=rm" (seg));
12484 + asm volatile("movw %%ds,%0" : "=rm" (seg));
12485 return seg;
12486 }
12487
12488 diff --git a/arch/x86/boot/compressed/Makefile b/arch/x86/boot/compressed/Makefile
12489 index 0fcd913..3bb5c42 100644
12490 --- a/arch/x86/boot/compressed/Makefile
12491 +++ b/arch/x86/boot/compressed/Makefile
12492 @@ -16,6 +16,9 @@ KBUILD_CFLAGS += $(cflags-y)
12493 KBUILD_CFLAGS += -mno-mmx -mno-sse
12494 KBUILD_CFLAGS += $(call cc-option,-ffreestanding)
12495 KBUILD_CFLAGS += $(call cc-option,-fno-stack-protector)
12496 +ifdef CONSTIFY_PLUGIN
12497 +KBUILD_CFLAGS += -fplugin-arg-constify_plugin-no-constify
12498 +endif
12499
12500 KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
12501 GCOV_PROFILE := n
12502 diff --git a/arch/x86/boot/compressed/efi_stub_32.S b/arch/x86/boot/compressed/efi_stub_32.S
12503 index a53440e..c3dbf1e 100644
12504 --- a/arch/x86/boot/compressed/efi_stub_32.S
12505 +++ b/arch/x86/boot/compressed/efi_stub_32.S
12506 @@ -46,16 +46,13 @@ ENTRY(efi_call_phys)
12507 * parameter 2, ..., param n. To make things easy, we save the return
12508 * address of efi_call_phys in a global variable.
12509 */
12510 - popl %ecx
12511 - movl %ecx, saved_return_addr(%edx)
12512 - /* get the function pointer into ECX*/
12513 - popl %ecx
12514 - movl %ecx, efi_rt_function_ptr(%edx)
12515 + popl saved_return_addr(%edx)
12516 + popl efi_rt_function_ptr(%edx)
12517
12518 /*
12519 * 3. Call the physical function.
12520 */
12521 - call *%ecx
12522 + call *efi_rt_function_ptr(%edx)
12523
12524 /*
12525 * 4. Balance the stack. And because EAX contain the return value,
12526 @@ -67,15 +64,12 @@ ENTRY(efi_call_phys)
12527 1: popl %edx
12528 subl $1b, %edx
12529
12530 - movl efi_rt_function_ptr(%edx), %ecx
12531 - pushl %ecx
12532 + pushl efi_rt_function_ptr(%edx)
12533
12534 /*
12535 * 10. Push the saved return address onto the stack and return.
12536 */
12537 - movl saved_return_addr(%edx), %ecx
12538 - pushl %ecx
12539 - ret
12540 + jmpl *saved_return_addr(%edx)
12541 ENDPROC(efi_call_phys)
12542 .previous
12543
12544 diff --git a/arch/x86/boot/compressed/head_32.S b/arch/x86/boot/compressed/head_32.S
12545 index cbed140..5f2ca57 100644
12546 --- a/arch/x86/boot/compressed/head_32.S
12547 +++ b/arch/x86/boot/compressed/head_32.S
12548 @@ -140,10 +140,10 @@ preferred_addr:
12549 addl %eax, %ebx
12550 notl %eax
12551 andl %eax, %ebx
12552 - cmpl $LOAD_PHYSICAL_ADDR, %ebx
12553 + cmpl $____LOAD_PHYSICAL_ADDR, %ebx
12554 jge 1f
12555 #endif
12556 - movl $LOAD_PHYSICAL_ADDR, %ebx
12557 + movl $____LOAD_PHYSICAL_ADDR, %ebx
12558 1:
12559
12560 /* Target address to relocate to for decompression */
12561 diff --git a/arch/x86/boot/compressed/head_64.S b/arch/x86/boot/compressed/head_64.S
12562 index 0d558ee..58f257e 100644
12563 --- a/arch/x86/boot/compressed/head_64.S
12564 +++ b/arch/x86/boot/compressed/head_64.S
12565 @@ -94,10 +94,10 @@ ENTRY(startup_32)
12566 addl %eax, %ebx
12567 notl %eax
12568 andl %eax, %ebx
12569 - cmpl $LOAD_PHYSICAL_ADDR, %ebx
12570 + cmpl $____LOAD_PHYSICAL_ADDR, %ebx
12571 jge 1f
12572 #endif
12573 - movl $LOAD_PHYSICAL_ADDR, %ebx
12574 + movl $____LOAD_PHYSICAL_ADDR, %ebx
12575 1:
12576
12577 /* Target address to relocate to for decompression */
12578 @@ -322,10 +322,10 @@ preferred_addr:
12579 addq %rax, %rbp
12580 notq %rax
12581 andq %rax, %rbp
12582 - cmpq $LOAD_PHYSICAL_ADDR, %rbp
12583 + cmpq $____LOAD_PHYSICAL_ADDR, %rbp
12584 jge 1f
12585 #endif
12586 - movq $LOAD_PHYSICAL_ADDR, %rbp
12587 + movq $____LOAD_PHYSICAL_ADDR, %rbp
12588 1:
12589
12590 /* Target address to relocate to for decompression */
12591 @@ -431,8 +431,8 @@ gdt:
12592 .long gdt
12593 .word 0
12594 .quad 0x0000000000000000 /* NULL descriptor */
12595 - .quad 0x00af9a000000ffff /* __KERNEL_CS */
12596 - .quad 0x00cf92000000ffff /* __KERNEL_DS */
12597 + .quad 0x00af9b000000ffff /* __KERNEL_CS */
12598 + .quad 0x00cf93000000ffff /* __KERNEL_DS */
12599 .quad 0x0080890000000000 /* TS descriptor */
12600 .quad 0x0000000000000000 /* TS continued */
12601 gdt_end:
12602 diff --git a/arch/x86/boot/compressed/misc.c b/arch/x86/boot/compressed/misc.c
12603 index 57ab74d..7c52182 100644
12604 --- a/arch/x86/boot/compressed/misc.c
12605 +++ b/arch/x86/boot/compressed/misc.c
12606 @@ -242,7 +242,7 @@ static void handle_relocations(void *output, unsigned long output_len)
12607 * Calculate the delta between where vmlinux was linked to load
12608 * and where it was actually loaded.
12609 */
12610 - delta = min_addr - LOAD_PHYSICAL_ADDR;
12611 + delta = min_addr - ____LOAD_PHYSICAL_ADDR;
12612 if (!delta) {
12613 debug_putstr("No relocation needed... ");
12614 return;
12615 @@ -312,7 +312,7 @@ static void parse_elf(void *output)
12616 Elf32_Ehdr ehdr;
12617 Elf32_Phdr *phdrs, *phdr;
12618 #endif
12619 - void *dest;
12620 + void *dest, *prev;
12621 int i;
12622
12623 memcpy(&ehdr, output, sizeof(ehdr));
12624 @@ -339,13 +339,16 @@ static void parse_elf(void *output)
12625 case PT_LOAD:
12626 #ifdef CONFIG_RELOCATABLE
12627 dest = output;
12628 - dest += (phdr->p_paddr - LOAD_PHYSICAL_ADDR);
12629 + dest += (phdr->p_paddr - ____LOAD_PHYSICAL_ADDR);
12630 #else
12631 dest = (void *)(phdr->p_paddr);
12632 #endif
12633 memcpy(dest,
12634 output + phdr->p_offset,
12635 phdr->p_filesz);
12636 + if (i)
12637 + memset(prev, 0xff, dest - prev);
12638 + prev = dest + phdr->p_filesz;
12639 break;
12640 default: /* Ignore other PT_* */ break;
12641 }
12642 @@ -395,7 +398,7 @@ asmlinkage __visible void *decompress_kernel(void *rmode, memptr heap,
12643 error("Destination address too large");
12644 #endif
12645 #ifndef CONFIG_RELOCATABLE
12646 - if ((unsigned long)output != LOAD_PHYSICAL_ADDR)
12647 + if ((unsigned long)output != ____LOAD_PHYSICAL_ADDR)
12648 error("Wrong destination address");
12649 #endif
12650
12651 diff --git a/arch/x86/boot/cpucheck.c b/arch/x86/boot/cpucheck.c
12652 index 1fd7d57..0f7d096 100644
12653 --- a/arch/x86/boot/cpucheck.c
12654 +++ b/arch/x86/boot/cpucheck.c
12655 @@ -125,9 +125,9 @@ int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr)
12656 u32 ecx = MSR_K7_HWCR;
12657 u32 eax, edx;
12658
12659 - asm("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
12660 + asm volatile("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
12661 eax &= ~(1 << 15);
12662 - asm("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
12663 + asm volatile("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
12664
12665 get_cpuflags(); /* Make sure it really did something */
12666 err = check_cpuflags();
12667 @@ -140,9 +140,9 @@ int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr)
12668 u32 ecx = MSR_VIA_FCR;
12669 u32 eax, edx;
12670
12671 - asm("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
12672 + asm volatile("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
12673 eax |= (1<<1)|(1<<7);
12674 - asm("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
12675 + asm volatile("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
12676
12677 set_bit(X86_FEATURE_CX8, cpu.flags);
12678 err = check_cpuflags();
12679 @@ -153,12 +153,12 @@ int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr)
12680 u32 eax, edx;
12681 u32 level = 1;
12682
12683 - asm("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
12684 - asm("wrmsr" : : "a" (~0), "d" (edx), "c" (ecx));
12685 - asm("cpuid"
12686 + asm volatile("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
12687 + asm volatile("wrmsr" : : "a" (~0), "d" (edx), "c" (ecx));
12688 + asm volatile("cpuid"
12689 : "+a" (level), "=d" (cpu.flags[0])
12690 : : "ecx", "ebx");
12691 - asm("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
12692 + asm volatile("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
12693
12694 err = check_cpuflags();
12695 } else if (err == 0x01 &&
12696 diff --git a/arch/x86/boot/header.S b/arch/x86/boot/header.S
12697 index 84c2234..3ef6360 100644
12698 --- a/arch/x86/boot/header.S
12699 +++ b/arch/x86/boot/header.S
12700 @@ -420,10 +420,14 @@ setup_data: .quad 0 # 64-bit physical pointer to
12701 # single linked list of
12702 # struct setup_data
12703
12704 -pref_address: .quad LOAD_PHYSICAL_ADDR # preferred load addr
12705 +pref_address: .quad ____LOAD_PHYSICAL_ADDR # preferred load addr
12706
12707 #define ZO_INIT_SIZE (ZO__end - ZO_startup_32 + ZO_z_extract_offset)
12708 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
12709 +#define VO_INIT_SIZE (VO__end - VO__text - __PAGE_OFFSET - ____LOAD_PHYSICAL_ADDR)
12710 +#else
12711 #define VO_INIT_SIZE (VO__end - VO__text)
12712 +#endif
12713 #if ZO_INIT_SIZE > VO_INIT_SIZE
12714 #define INIT_SIZE ZO_INIT_SIZE
12715 #else
12716 diff --git a/arch/x86/boot/memory.c b/arch/x86/boot/memory.c
12717 index db75d07..8e6d0af 100644
12718 --- a/arch/x86/boot/memory.c
12719 +++ b/arch/x86/boot/memory.c
12720 @@ -19,7 +19,7 @@
12721
12722 static int detect_memory_e820(void)
12723 {
12724 - int count = 0;
12725 + unsigned int count = 0;
12726 struct biosregs ireg, oreg;
12727 struct e820entry *desc = boot_params.e820_map;
12728 static struct e820entry buf; /* static so it is zeroed */
12729 diff --git a/arch/x86/boot/video-vesa.c b/arch/x86/boot/video-vesa.c
12730 index ba3e100..6501b8f 100644
12731 --- a/arch/x86/boot/video-vesa.c
12732 +++ b/arch/x86/boot/video-vesa.c
12733 @@ -201,6 +201,7 @@ static void vesa_store_pm_info(void)
12734
12735 boot_params.screen_info.vesapm_seg = oreg.es;
12736 boot_params.screen_info.vesapm_off = oreg.di;
12737 + boot_params.screen_info.vesapm_size = oreg.cx;
12738 }
12739
12740 /*
12741 diff --git a/arch/x86/boot/video.c b/arch/x86/boot/video.c
12742 index 43eda28..5ab5fdb 100644
12743 --- a/arch/x86/boot/video.c
12744 +++ b/arch/x86/boot/video.c
12745 @@ -96,7 +96,7 @@ static void store_mode_params(void)
12746 static unsigned int get_entry(void)
12747 {
12748 char entry_buf[4];
12749 - int i, len = 0;
12750 + unsigned int i, len = 0;
12751 int key;
12752 unsigned int v;
12753
12754 diff --git a/arch/x86/crypto/aes-x86_64-asm_64.S b/arch/x86/crypto/aes-x86_64-asm_64.S
12755 index 9105655..41779c1 100644
12756 --- a/arch/x86/crypto/aes-x86_64-asm_64.S
12757 +++ b/arch/x86/crypto/aes-x86_64-asm_64.S
12758 @@ -8,6 +8,8 @@
12759 * including this sentence is retained in full.
12760 */
12761
12762 +#include <asm/alternative-asm.h>
12763 +
12764 .extern crypto_ft_tab
12765 .extern crypto_it_tab
12766 .extern crypto_fl_tab
12767 @@ -70,6 +72,8 @@
12768 je B192; \
12769 leaq 32(r9),r9;
12770
12771 +#define ret pax_force_retaddr; ret
12772 +
12773 #define epilogue(FUNC,r1,r2,r3,r4,r5,r6,r7,r8,r9) \
12774 movq r1,r2; \
12775 movq r3,r4; \
12776 diff --git a/arch/x86/crypto/aesni-intel_asm.S b/arch/x86/crypto/aesni-intel_asm.S
12777 index 477e9d7..c92c7d8 100644
12778 --- a/arch/x86/crypto/aesni-intel_asm.S
12779 +++ b/arch/x86/crypto/aesni-intel_asm.S
12780 @@ -31,6 +31,7 @@
12781
12782 #include <linux/linkage.h>
12783 #include <asm/inst.h>
12784 +#include <asm/alternative-asm.h>
12785
12786 #ifdef __x86_64__
12787 .data
12788 @@ -205,7 +206,7 @@ enc: .octa 0x2
12789 * num_initial_blocks = b mod 4
12790 * encrypt the initial num_initial_blocks blocks and apply ghash on
12791 * the ciphertext
12792 -* %r10, %r11, %r12, %rax, %xmm5, %xmm6, %xmm7, %xmm8, %xmm9 registers
12793 +* %r10, %r11, %r15, %rax, %xmm5, %xmm6, %xmm7, %xmm8, %xmm9 registers
12794 * are clobbered
12795 * arg1, %arg2, %arg3, %r14 are used as a pointer only, not modified
12796 */
12797 @@ -214,8 +215,8 @@ enc: .octa 0x2
12798 .macro INITIAL_BLOCKS_DEC num_initial_blocks TMP1 TMP2 TMP3 TMP4 TMP5 XMM0 XMM1 \
12799 XMM2 XMM3 XMM4 XMMDst TMP6 TMP7 i i_seq operation
12800 mov arg7, %r10 # %r10 = AAD
12801 - mov arg8, %r12 # %r12 = aadLen
12802 - mov %r12, %r11
12803 + mov arg8, %r15 # %r15 = aadLen
12804 + mov %r15, %r11
12805 pxor %xmm\i, %xmm\i
12806 _get_AAD_loop\num_initial_blocks\operation:
12807 movd (%r10), \TMP1
12808 @@ -223,15 +224,15 @@ _get_AAD_loop\num_initial_blocks\operation:
12809 psrldq $4, %xmm\i
12810 pxor \TMP1, %xmm\i
12811 add $4, %r10
12812 - sub $4, %r12
12813 + sub $4, %r15
12814 jne _get_AAD_loop\num_initial_blocks\operation
12815 cmp $16, %r11
12816 je _get_AAD_loop2_done\num_initial_blocks\operation
12817 - mov $16, %r12
12818 + mov $16, %r15
12819 _get_AAD_loop2\num_initial_blocks\operation:
12820 psrldq $4, %xmm\i
12821 - sub $4, %r12
12822 - cmp %r11, %r12
12823 + sub $4, %r15
12824 + cmp %r11, %r15
12825 jne _get_AAD_loop2\num_initial_blocks\operation
12826 _get_AAD_loop2_done\num_initial_blocks\operation:
12827 movdqa SHUF_MASK(%rip), %xmm14
12828 @@ -443,7 +444,7 @@ _initial_blocks_done\num_initial_blocks\operation:
12829 * num_initial_blocks = b mod 4
12830 * encrypt the initial num_initial_blocks blocks and apply ghash on
12831 * the ciphertext
12832 -* %r10, %r11, %r12, %rax, %xmm5, %xmm6, %xmm7, %xmm8, %xmm9 registers
12833 +* %r10, %r11, %r15, %rax, %xmm5, %xmm6, %xmm7, %xmm8, %xmm9 registers
12834 * are clobbered
12835 * arg1, %arg2, %arg3, %r14 are used as a pointer only, not modified
12836 */
12837 @@ -452,8 +453,8 @@ _initial_blocks_done\num_initial_blocks\operation:
12838 .macro INITIAL_BLOCKS_ENC num_initial_blocks TMP1 TMP2 TMP3 TMP4 TMP5 XMM0 XMM1 \
12839 XMM2 XMM3 XMM4 XMMDst TMP6 TMP7 i i_seq operation
12840 mov arg7, %r10 # %r10 = AAD
12841 - mov arg8, %r12 # %r12 = aadLen
12842 - mov %r12, %r11
12843 + mov arg8, %r15 # %r15 = aadLen
12844 + mov %r15, %r11
12845 pxor %xmm\i, %xmm\i
12846 _get_AAD_loop\num_initial_blocks\operation:
12847 movd (%r10), \TMP1
12848 @@ -461,15 +462,15 @@ _get_AAD_loop\num_initial_blocks\operation:
12849 psrldq $4, %xmm\i
12850 pxor \TMP1, %xmm\i
12851 add $4, %r10
12852 - sub $4, %r12
12853 + sub $4, %r15
12854 jne _get_AAD_loop\num_initial_blocks\operation
12855 cmp $16, %r11
12856 je _get_AAD_loop2_done\num_initial_blocks\operation
12857 - mov $16, %r12
12858 + mov $16, %r15
12859 _get_AAD_loop2\num_initial_blocks\operation:
12860 psrldq $4, %xmm\i
12861 - sub $4, %r12
12862 - cmp %r11, %r12
12863 + sub $4, %r15
12864 + cmp %r11, %r15
12865 jne _get_AAD_loop2\num_initial_blocks\operation
12866 _get_AAD_loop2_done\num_initial_blocks\operation:
12867 movdqa SHUF_MASK(%rip), %xmm14
12868 @@ -1269,7 +1270,7 @@ TMP7 XMM1 XMM2 XMM3 XMM4 XMMDst
12869 *
12870 *****************************************************************************/
12871 ENTRY(aesni_gcm_dec)
12872 - push %r12
12873 + push %r15
12874 push %r13
12875 push %r14
12876 mov %rsp, %r14
12877 @@ -1279,8 +1280,8 @@ ENTRY(aesni_gcm_dec)
12878 */
12879 sub $VARIABLE_OFFSET, %rsp
12880 and $~63, %rsp # align rsp to 64 bytes
12881 - mov %arg6, %r12
12882 - movdqu (%r12), %xmm13 # %xmm13 = HashKey
12883 + mov %arg6, %r15
12884 + movdqu (%r15), %xmm13 # %xmm13 = HashKey
12885 movdqa SHUF_MASK(%rip), %xmm2
12886 PSHUFB_XMM %xmm2, %xmm13
12887
12888 @@ -1308,10 +1309,10 @@ ENTRY(aesni_gcm_dec)
12889 movdqa %xmm13, HashKey(%rsp) # store HashKey<<1 (mod poly)
12890 mov %arg4, %r13 # save the number of bytes of plaintext/ciphertext
12891 and $-16, %r13 # %r13 = %r13 - (%r13 mod 16)
12892 - mov %r13, %r12
12893 - and $(3<<4), %r12
12894 + mov %r13, %r15
12895 + and $(3<<4), %r15
12896 jz _initial_num_blocks_is_0_decrypt
12897 - cmp $(2<<4), %r12
12898 + cmp $(2<<4), %r15
12899 jb _initial_num_blocks_is_1_decrypt
12900 je _initial_num_blocks_is_2_decrypt
12901 _initial_num_blocks_is_3_decrypt:
12902 @@ -1361,16 +1362,16 @@ _zero_cipher_left_decrypt:
12903 sub $16, %r11
12904 add %r13, %r11
12905 movdqu (%arg3,%r11,1), %xmm1 # receive the last <16 byte block
12906 - lea SHIFT_MASK+16(%rip), %r12
12907 - sub %r13, %r12
12908 + lea SHIFT_MASK+16(%rip), %r15
12909 + sub %r13, %r15
12910 # adjust the shuffle mask pointer to be able to shift 16-%r13 bytes
12911 # (%r13 is the number of bytes in plaintext mod 16)
12912 - movdqu (%r12), %xmm2 # get the appropriate shuffle mask
12913 + movdqu (%r15), %xmm2 # get the appropriate shuffle mask
12914 PSHUFB_XMM %xmm2, %xmm1 # right shift 16-%r13 butes
12915
12916 movdqa %xmm1, %xmm2
12917 pxor %xmm1, %xmm0 # Ciphertext XOR E(K, Yn)
12918 - movdqu ALL_F-SHIFT_MASK(%r12), %xmm1
12919 + movdqu ALL_F-SHIFT_MASK(%r15), %xmm1
12920 # get the appropriate mask to mask out top 16-%r13 bytes of %xmm0
12921 pand %xmm1, %xmm0 # mask out top 16-%r13 bytes of %xmm0
12922 pand %xmm1, %xmm2
12923 @@ -1399,9 +1400,9 @@ _less_than_8_bytes_left_decrypt:
12924 sub $1, %r13
12925 jne _less_than_8_bytes_left_decrypt
12926 _multiple_of_16_bytes_decrypt:
12927 - mov arg8, %r12 # %r13 = aadLen (number of bytes)
12928 - shl $3, %r12 # convert into number of bits
12929 - movd %r12d, %xmm15 # len(A) in %xmm15
12930 + mov arg8, %r15 # %r13 = aadLen (number of bytes)
12931 + shl $3, %r15 # convert into number of bits
12932 + movd %r15d, %xmm15 # len(A) in %xmm15
12933 shl $3, %arg4 # len(C) in bits (*128)
12934 MOVQ_R64_XMM %arg4, %xmm1
12935 pslldq $8, %xmm15 # %xmm15 = len(A)||0x0000000000000000
12936 @@ -1440,7 +1441,8 @@ _return_T_done_decrypt:
12937 mov %r14, %rsp
12938 pop %r14
12939 pop %r13
12940 - pop %r12
12941 + pop %r15
12942 + pax_force_retaddr
12943 ret
12944 ENDPROC(aesni_gcm_dec)
12945
12946 @@ -1529,7 +1531,7 @@ ENDPROC(aesni_gcm_dec)
12947 * poly = x^128 + x^127 + x^126 + x^121 + 1
12948 ***************************************************************************/
12949 ENTRY(aesni_gcm_enc)
12950 - push %r12
12951 + push %r15
12952 push %r13
12953 push %r14
12954 mov %rsp, %r14
12955 @@ -1539,8 +1541,8 @@ ENTRY(aesni_gcm_enc)
12956 #
12957 sub $VARIABLE_OFFSET, %rsp
12958 and $~63, %rsp
12959 - mov %arg6, %r12
12960 - movdqu (%r12), %xmm13
12961 + mov %arg6, %r15
12962 + movdqu (%r15), %xmm13
12963 movdqa SHUF_MASK(%rip), %xmm2
12964 PSHUFB_XMM %xmm2, %xmm13
12965
12966 @@ -1564,13 +1566,13 @@ ENTRY(aesni_gcm_enc)
12967 movdqa %xmm13, HashKey(%rsp)
12968 mov %arg4, %r13 # %xmm13 holds HashKey<<1 (mod poly)
12969 and $-16, %r13
12970 - mov %r13, %r12
12971 + mov %r13, %r15
12972
12973 # Encrypt first few blocks
12974
12975 - and $(3<<4), %r12
12976 + and $(3<<4), %r15
12977 jz _initial_num_blocks_is_0_encrypt
12978 - cmp $(2<<4), %r12
12979 + cmp $(2<<4), %r15
12980 jb _initial_num_blocks_is_1_encrypt
12981 je _initial_num_blocks_is_2_encrypt
12982 _initial_num_blocks_is_3_encrypt:
12983 @@ -1623,14 +1625,14 @@ _zero_cipher_left_encrypt:
12984 sub $16, %r11
12985 add %r13, %r11
12986 movdqu (%arg3,%r11,1), %xmm1 # receive the last <16 byte blocks
12987 - lea SHIFT_MASK+16(%rip), %r12
12988 - sub %r13, %r12
12989 + lea SHIFT_MASK+16(%rip), %r15
12990 + sub %r13, %r15
12991 # adjust the shuffle mask pointer to be able to shift 16-r13 bytes
12992 # (%r13 is the number of bytes in plaintext mod 16)
12993 - movdqu (%r12), %xmm2 # get the appropriate shuffle mask
12994 + movdqu (%r15), %xmm2 # get the appropriate shuffle mask
12995 PSHUFB_XMM %xmm2, %xmm1 # shift right 16-r13 byte
12996 pxor %xmm1, %xmm0 # Plaintext XOR Encrypt(K, Yn)
12997 - movdqu ALL_F-SHIFT_MASK(%r12), %xmm1
12998 + movdqu ALL_F-SHIFT_MASK(%r15), %xmm1
12999 # get the appropriate mask to mask out top 16-r13 bytes of xmm0
13000 pand %xmm1, %xmm0 # mask out top 16-r13 bytes of xmm0
13001 movdqa SHUF_MASK(%rip), %xmm10
13002 @@ -1663,9 +1665,9 @@ _less_than_8_bytes_left_encrypt:
13003 sub $1, %r13
13004 jne _less_than_8_bytes_left_encrypt
13005 _multiple_of_16_bytes_encrypt:
13006 - mov arg8, %r12 # %r12 = addLen (number of bytes)
13007 - shl $3, %r12
13008 - movd %r12d, %xmm15 # len(A) in %xmm15
13009 + mov arg8, %r15 # %r15 = addLen (number of bytes)
13010 + shl $3, %r15
13011 + movd %r15d, %xmm15 # len(A) in %xmm15
13012 shl $3, %arg4 # len(C) in bits (*128)
13013 MOVQ_R64_XMM %arg4, %xmm1
13014 pslldq $8, %xmm15 # %xmm15 = len(A)||0x0000000000000000
13015 @@ -1704,7 +1706,8 @@ _return_T_done_encrypt:
13016 mov %r14, %rsp
13017 pop %r14
13018 pop %r13
13019 - pop %r12
13020 + pop %r15
13021 + pax_force_retaddr
13022 ret
13023 ENDPROC(aesni_gcm_enc)
13024
13025 @@ -1722,6 +1725,7 @@ _key_expansion_256a:
13026 pxor %xmm1, %xmm0
13027 movaps %xmm0, (TKEYP)
13028 add $0x10, TKEYP
13029 + pax_force_retaddr
13030 ret
13031 ENDPROC(_key_expansion_128)
13032 ENDPROC(_key_expansion_256a)
13033 @@ -1748,6 +1752,7 @@ _key_expansion_192a:
13034 shufps $0b01001110, %xmm2, %xmm1
13035 movaps %xmm1, 0x10(TKEYP)
13036 add $0x20, TKEYP
13037 + pax_force_retaddr
13038 ret
13039 ENDPROC(_key_expansion_192a)
13040
13041 @@ -1768,6 +1773,7 @@ _key_expansion_192b:
13042
13043 movaps %xmm0, (TKEYP)
13044 add $0x10, TKEYP
13045 + pax_force_retaddr
13046 ret
13047 ENDPROC(_key_expansion_192b)
13048
13049 @@ -1781,6 +1787,7 @@ _key_expansion_256b:
13050 pxor %xmm1, %xmm2
13051 movaps %xmm2, (TKEYP)
13052 add $0x10, TKEYP
13053 + pax_force_retaddr
13054 ret
13055 ENDPROC(_key_expansion_256b)
13056
13057 @@ -1894,6 +1901,7 @@ ENTRY(aesni_set_key)
13058 #ifndef __x86_64__
13059 popl KEYP
13060 #endif
13061 + pax_force_retaddr
13062 ret
13063 ENDPROC(aesni_set_key)
13064
13065 @@ -1916,6 +1924,7 @@ ENTRY(aesni_enc)
13066 popl KLEN
13067 popl KEYP
13068 #endif
13069 + pax_force_retaddr
13070 ret
13071 ENDPROC(aesni_enc)
13072
13073 @@ -1974,6 +1983,7 @@ _aesni_enc1:
13074 AESENC KEY STATE
13075 movaps 0x70(TKEYP), KEY
13076 AESENCLAST KEY STATE
13077 + pax_force_retaddr
13078 ret
13079 ENDPROC(_aesni_enc1)
13080
13081 @@ -2083,6 +2093,7 @@ _aesni_enc4:
13082 AESENCLAST KEY STATE2
13083 AESENCLAST KEY STATE3
13084 AESENCLAST KEY STATE4
13085 + pax_force_retaddr
13086 ret
13087 ENDPROC(_aesni_enc4)
13088
13089 @@ -2106,6 +2117,7 @@ ENTRY(aesni_dec)
13090 popl KLEN
13091 popl KEYP
13092 #endif
13093 + pax_force_retaddr
13094 ret
13095 ENDPROC(aesni_dec)
13096
13097 @@ -2164,6 +2176,7 @@ _aesni_dec1:
13098 AESDEC KEY STATE
13099 movaps 0x70(TKEYP), KEY
13100 AESDECLAST KEY STATE
13101 + pax_force_retaddr
13102 ret
13103 ENDPROC(_aesni_dec1)
13104
13105 @@ -2273,6 +2286,7 @@ _aesni_dec4:
13106 AESDECLAST KEY STATE2
13107 AESDECLAST KEY STATE3
13108 AESDECLAST KEY STATE4
13109 + pax_force_retaddr
13110 ret
13111 ENDPROC(_aesni_dec4)
13112
13113 @@ -2331,6 +2345,7 @@ ENTRY(aesni_ecb_enc)
13114 popl KEYP
13115 popl LEN
13116 #endif
13117 + pax_force_retaddr
13118 ret
13119 ENDPROC(aesni_ecb_enc)
13120
13121 @@ -2390,6 +2405,7 @@ ENTRY(aesni_ecb_dec)
13122 popl KEYP
13123 popl LEN
13124 #endif
13125 + pax_force_retaddr
13126 ret
13127 ENDPROC(aesni_ecb_dec)
13128
13129 @@ -2432,6 +2448,7 @@ ENTRY(aesni_cbc_enc)
13130 popl LEN
13131 popl IVP
13132 #endif
13133 + pax_force_retaddr
13134 ret
13135 ENDPROC(aesni_cbc_enc)
13136
13137 @@ -2523,6 +2540,7 @@ ENTRY(aesni_cbc_dec)
13138 popl LEN
13139 popl IVP
13140 #endif
13141 + pax_force_retaddr
13142 ret
13143 ENDPROC(aesni_cbc_dec)
13144
13145 @@ -2550,6 +2568,7 @@ _aesni_inc_init:
13146 mov $1, TCTR_LOW
13147 MOVQ_R64_XMM TCTR_LOW INC
13148 MOVQ_R64_XMM CTR TCTR_LOW
13149 + pax_force_retaddr
13150 ret
13151 ENDPROC(_aesni_inc_init)
13152
13153 @@ -2579,6 +2598,7 @@ _aesni_inc:
13154 .Linc_low:
13155 movaps CTR, IV
13156 PSHUFB_XMM BSWAP_MASK IV
13157 + pax_force_retaddr
13158 ret
13159 ENDPROC(_aesni_inc)
13160
13161 @@ -2640,6 +2660,7 @@ ENTRY(aesni_ctr_enc)
13162 .Lctr_enc_ret:
13163 movups IV, (IVP)
13164 .Lctr_enc_just_ret:
13165 + pax_force_retaddr
13166 ret
13167 ENDPROC(aesni_ctr_enc)
13168
13169 @@ -2766,6 +2787,7 @@ ENTRY(aesni_xts_crypt8)
13170 pxor INC, STATE4
13171 movdqu STATE4, 0x70(OUTP)
13172
13173 + pax_force_retaddr
13174 ret
13175 ENDPROC(aesni_xts_crypt8)
13176
13177 diff --git a/arch/x86/crypto/blowfish-x86_64-asm_64.S b/arch/x86/crypto/blowfish-x86_64-asm_64.S
13178 index 246c670..466e2d6 100644
13179 --- a/arch/x86/crypto/blowfish-x86_64-asm_64.S
13180 +++ b/arch/x86/crypto/blowfish-x86_64-asm_64.S
13181 @@ -21,6 +21,7 @@
13182 */
13183
13184 #include <linux/linkage.h>
13185 +#include <asm/alternative-asm.h>
13186
13187 .file "blowfish-x86_64-asm.S"
13188 .text
13189 @@ -149,9 +150,11 @@ ENTRY(__blowfish_enc_blk)
13190 jnz .L__enc_xor;
13191
13192 write_block();
13193 + pax_force_retaddr
13194 ret;
13195 .L__enc_xor:
13196 xor_block();
13197 + pax_force_retaddr
13198 ret;
13199 ENDPROC(__blowfish_enc_blk)
13200
13201 @@ -183,6 +186,7 @@ ENTRY(blowfish_dec_blk)
13202
13203 movq %r11, %rbp;
13204
13205 + pax_force_retaddr
13206 ret;
13207 ENDPROC(blowfish_dec_blk)
13208
13209 @@ -334,6 +338,7 @@ ENTRY(__blowfish_enc_blk_4way)
13210
13211 popq %rbx;
13212 popq %rbp;
13213 + pax_force_retaddr
13214 ret;
13215
13216 .L__enc_xor4:
13217 @@ -341,6 +346,7 @@ ENTRY(__blowfish_enc_blk_4way)
13218
13219 popq %rbx;
13220 popq %rbp;
13221 + pax_force_retaddr
13222 ret;
13223 ENDPROC(__blowfish_enc_blk_4way)
13224
13225 @@ -375,5 +381,6 @@ ENTRY(blowfish_dec_blk_4way)
13226 popq %rbx;
13227 popq %rbp;
13228
13229 + pax_force_retaddr
13230 ret;
13231 ENDPROC(blowfish_dec_blk_4way)
13232 diff --git a/arch/x86/crypto/camellia-aesni-avx-asm_64.S b/arch/x86/crypto/camellia-aesni-avx-asm_64.S
13233 index ce71f92..1dce7ec 100644
13234 --- a/arch/x86/crypto/camellia-aesni-avx-asm_64.S
13235 +++ b/arch/x86/crypto/camellia-aesni-avx-asm_64.S
13236 @@ -16,6 +16,7 @@
13237 */
13238
13239 #include <linux/linkage.h>
13240 +#include <asm/alternative-asm.h>
13241
13242 #define CAMELLIA_TABLE_BYTE_LEN 272
13243
13244 @@ -191,6 +192,7 @@ roundsm16_x0_x1_x2_x3_x4_x5_x6_x7_y0_y1_y2_y3_y4_y5_y6_y7_cd:
13245 roundsm16(%xmm0, %xmm1, %xmm2, %xmm3, %xmm4, %xmm5, %xmm6, %xmm7,
13246 %xmm8, %xmm9, %xmm10, %xmm11, %xmm12, %xmm13, %xmm14, %xmm15,
13247 %rcx, (%r9));
13248 + pax_force_retaddr
13249 ret;
13250 ENDPROC(roundsm16_x0_x1_x2_x3_x4_x5_x6_x7_y0_y1_y2_y3_y4_y5_y6_y7_cd)
13251
13252 @@ -199,6 +201,7 @@ roundsm16_x4_x5_x6_x7_x0_x1_x2_x3_y4_y5_y6_y7_y0_y1_y2_y3_ab:
13253 roundsm16(%xmm4, %xmm5, %xmm6, %xmm7, %xmm0, %xmm1, %xmm2, %xmm3,
13254 %xmm12, %xmm13, %xmm14, %xmm15, %xmm8, %xmm9, %xmm10, %xmm11,
13255 %rax, (%r9));
13256 + pax_force_retaddr
13257 ret;
13258 ENDPROC(roundsm16_x4_x5_x6_x7_x0_x1_x2_x3_y4_y5_y6_y7_y0_y1_y2_y3_ab)
13259
13260 @@ -780,6 +783,7 @@ __camellia_enc_blk16:
13261 %xmm8, %xmm9, %xmm10, %xmm11, %xmm12, %xmm13, %xmm14,
13262 %xmm15, (key_table)(CTX, %r8, 8), (%rax), 1 * 16(%rax));
13263
13264 + pax_force_retaddr
13265 ret;
13266
13267 .align 8
13268 @@ -865,6 +869,7 @@ __camellia_dec_blk16:
13269 %xmm8, %xmm9, %xmm10, %xmm11, %xmm12, %xmm13, %xmm14,
13270 %xmm15, (key_table)(CTX), (%rax), 1 * 16(%rax));
13271
13272 + pax_force_retaddr
13273 ret;
13274
13275 .align 8
13276 @@ -904,6 +909,7 @@ ENTRY(camellia_ecb_enc_16way)
13277 %xmm15, %xmm14, %xmm13, %xmm12, %xmm11, %xmm10, %xmm9,
13278 %xmm8, %rsi);
13279
13280 + pax_force_retaddr
13281 ret;
13282 ENDPROC(camellia_ecb_enc_16way)
13283
13284 @@ -932,6 +938,7 @@ ENTRY(camellia_ecb_dec_16way)
13285 %xmm15, %xmm14, %xmm13, %xmm12, %xmm11, %xmm10, %xmm9,
13286 %xmm8, %rsi);
13287
13288 + pax_force_retaddr
13289 ret;
13290 ENDPROC(camellia_ecb_dec_16way)
13291
13292 @@ -981,6 +988,7 @@ ENTRY(camellia_cbc_dec_16way)
13293 %xmm15, %xmm14, %xmm13, %xmm12, %xmm11, %xmm10, %xmm9,
13294 %xmm8, %rsi);
13295
13296 + pax_force_retaddr
13297 ret;
13298 ENDPROC(camellia_cbc_dec_16way)
13299
13300 @@ -1092,6 +1100,7 @@ ENTRY(camellia_ctr_16way)
13301 %xmm15, %xmm14, %xmm13, %xmm12, %xmm11, %xmm10, %xmm9,
13302 %xmm8, %rsi);
13303
13304 + pax_force_retaddr
13305 ret;
13306 ENDPROC(camellia_ctr_16way)
13307
13308 @@ -1234,6 +1243,7 @@ camellia_xts_crypt_16way:
13309 %xmm15, %xmm14, %xmm13, %xmm12, %xmm11, %xmm10, %xmm9,
13310 %xmm8, %rsi);
13311
13312 + pax_force_retaddr
13313 ret;
13314 ENDPROC(camellia_xts_crypt_16way)
13315
13316 diff --git a/arch/x86/crypto/camellia-aesni-avx2-asm_64.S b/arch/x86/crypto/camellia-aesni-avx2-asm_64.S
13317 index 0e0b886..5a3123c 100644
13318 --- a/arch/x86/crypto/camellia-aesni-avx2-asm_64.S
13319 +++ b/arch/x86/crypto/camellia-aesni-avx2-asm_64.S
13320 @@ -11,6 +11,7 @@
13321 */
13322
13323 #include <linux/linkage.h>
13324 +#include <asm/alternative-asm.h>
13325
13326 #define CAMELLIA_TABLE_BYTE_LEN 272
13327
13328 @@ -230,6 +231,7 @@ roundsm32_x0_x1_x2_x3_x4_x5_x6_x7_y0_y1_y2_y3_y4_y5_y6_y7_cd:
13329 roundsm32(%ymm0, %ymm1, %ymm2, %ymm3, %ymm4, %ymm5, %ymm6, %ymm7,
13330 %ymm8, %ymm9, %ymm10, %ymm11, %ymm12, %ymm13, %ymm14, %ymm15,
13331 %rcx, (%r9));
13332 + pax_force_retaddr
13333 ret;
13334 ENDPROC(roundsm32_x0_x1_x2_x3_x4_x5_x6_x7_y0_y1_y2_y3_y4_y5_y6_y7_cd)
13335
13336 @@ -238,6 +240,7 @@ roundsm32_x4_x5_x6_x7_x0_x1_x2_x3_y4_y5_y6_y7_y0_y1_y2_y3_ab:
13337 roundsm32(%ymm4, %ymm5, %ymm6, %ymm7, %ymm0, %ymm1, %ymm2, %ymm3,
13338 %ymm12, %ymm13, %ymm14, %ymm15, %ymm8, %ymm9, %ymm10, %ymm11,
13339 %rax, (%r9));
13340 + pax_force_retaddr
13341 ret;
13342 ENDPROC(roundsm32_x4_x5_x6_x7_x0_x1_x2_x3_y4_y5_y6_y7_y0_y1_y2_y3_ab)
13343
13344 @@ -820,6 +823,7 @@ __camellia_enc_blk32:
13345 %ymm8, %ymm9, %ymm10, %ymm11, %ymm12, %ymm13, %ymm14,
13346 %ymm15, (key_table)(CTX, %r8, 8), (%rax), 1 * 32(%rax));
13347
13348 + pax_force_retaddr
13349 ret;
13350
13351 .align 8
13352 @@ -905,6 +909,7 @@ __camellia_dec_blk32:
13353 %ymm8, %ymm9, %ymm10, %ymm11, %ymm12, %ymm13, %ymm14,
13354 %ymm15, (key_table)(CTX), (%rax), 1 * 32(%rax));
13355
13356 + pax_force_retaddr
13357 ret;
13358
13359 .align 8
13360 @@ -948,6 +953,7 @@ ENTRY(camellia_ecb_enc_32way)
13361
13362 vzeroupper;
13363
13364 + pax_force_retaddr
13365 ret;
13366 ENDPROC(camellia_ecb_enc_32way)
13367
13368 @@ -980,6 +986,7 @@ ENTRY(camellia_ecb_dec_32way)
13369
13370 vzeroupper;
13371
13372 + pax_force_retaddr
13373 ret;
13374 ENDPROC(camellia_ecb_dec_32way)
13375
13376 @@ -1046,6 +1053,7 @@ ENTRY(camellia_cbc_dec_32way)
13377
13378 vzeroupper;
13379
13380 + pax_force_retaddr
13381 ret;
13382 ENDPROC(camellia_cbc_dec_32way)
13383
13384 @@ -1184,6 +1192,7 @@ ENTRY(camellia_ctr_32way)
13385
13386 vzeroupper;
13387
13388 + pax_force_retaddr
13389 ret;
13390 ENDPROC(camellia_ctr_32way)
13391
13392 @@ -1349,6 +1358,7 @@ camellia_xts_crypt_32way:
13393
13394 vzeroupper;
13395
13396 + pax_force_retaddr
13397 ret;
13398 ENDPROC(camellia_xts_crypt_32way)
13399
13400 diff --git a/arch/x86/crypto/camellia-x86_64-asm_64.S b/arch/x86/crypto/camellia-x86_64-asm_64.S
13401 index 310319c..db3d7b5 100644
13402 --- a/arch/x86/crypto/camellia-x86_64-asm_64.S
13403 +++ b/arch/x86/crypto/camellia-x86_64-asm_64.S
13404 @@ -21,6 +21,7 @@
13405 */
13406
13407 #include <linux/linkage.h>
13408 +#include <asm/alternative-asm.h>
13409
13410 .file "camellia-x86_64-asm_64.S"
13411 .text
13412 @@ -228,12 +229,14 @@ ENTRY(__camellia_enc_blk)
13413 enc_outunpack(mov, RT1);
13414
13415 movq RRBP, %rbp;
13416 + pax_force_retaddr
13417 ret;
13418
13419 .L__enc_xor:
13420 enc_outunpack(xor, RT1);
13421
13422 movq RRBP, %rbp;
13423 + pax_force_retaddr
13424 ret;
13425 ENDPROC(__camellia_enc_blk)
13426
13427 @@ -272,6 +275,7 @@ ENTRY(camellia_dec_blk)
13428 dec_outunpack();
13429
13430 movq RRBP, %rbp;
13431 + pax_force_retaddr
13432 ret;
13433 ENDPROC(camellia_dec_blk)
13434
13435 @@ -463,6 +467,7 @@ ENTRY(__camellia_enc_blk_2way)
13436
13437 movq RRBP, %rbp;
13438 popq %rbx;
13439 + pax_force_retaddr
13440 ret;
13441
13442 .L__enc2_xor:
13443 @@ -470,6 +475,7 @@ ENTRY(__camellia_enc_blk_2way)
13444
13445 movq RRBP, %rbp;
13446 popq %rbx;
13447 + pax_force_retaddr
13448 ret;
13449 ENDPROC(__camellia_enc_blk_2way)
13450
13451 @@ -510,5 +516,6 @@ ENTRY(camellia_dec_blk_2way)
13452
13453 movq RRBP, %rbp;
13454 movq RXOR, %rbx;
13455 + pax_force_retaddr
13456 ret;
13457 ENDPROC(camellia_dec_blk_2way)
13458 diff --git a/arch/x86/crypto/cast5-avx-x86_64-asm_64.S b/arch/x86/crypto/cast5-avx-x86_64-asm_64.S
13459 index c35fd5d..2d8c7db 100644
13460 --- a/arch/x86/crypto/cast5-avx-x86_64-asm_64.S
13461 +++ b/arch/x86/crypto/cast5-avx-x86_64-asm_64.S
13462 @@ -24,6 +24,7 @@
13463 */
13464
13465 #include <linux/linkage.h>
13466 +#include <asm/alternative-asm.h>
13467
13468 .file "cast5-avx-x86_64-asm_64.S"
13469
13470 @@ -281,6 +282,7 @@ __cast5_enc_blk16:
13471 outunpack_blocks(RR3, RL3, RTMP, RX, RKM);
13472 outunpack_blocks(RR4, RL4, RTMP, RX, RKM);
13473
13474 + pax_force_retaddr
13475 ret;
13476 ENDPROC(__cast5_enc_blk16)
13477
13478 @@ -352,6 +354,7 @@ __cast5_dec_blk16:
13479 outunpack_blocks(RR3, RL3, RTMP, RX, RKM);
13480 outunpack_blocks(RR4, RL4, RTMP, RX, RKM);
13481
13482 + pax_force_retaddr
13483 ret;
13484
13485 .L__skip_dec:
13486 @@ -388,6 +391,7 @@ ENTRY(cast5_ecb_enc_16way)
13487 vmovdqu RR4, (6*4*4)(%r11);
13488 vmovdqu RL4, (7*4*4)(%r11);
13489
13490 + pax_force_retaddr
13491 ret;
13492 ENDPROC(cast5_ecb_enc_16way)
13493
13494 @@ -420,6 +424,7 @@ ENTRY(cast5_ecb_dec_16way)
13495 vmovdqu RR4, (6*4*4)(%r11);
13496 vmovdqu RL4, (7*4*4)(%r11);
13497
13498 + pax_force_retaddr
13499 ret;
13500 ENDPROC(cast5_ecb_dec_16way)
13501
13502 @@ -430,10 +435,10 @@ ENTRY(cast5_cbc_dec_16way)
13503 * %rdx: src
13504 */
13505
13506 - pushq %r12;
13507 + pushq %r14;
13508
13509 movq %rsi, %r11;
13510 - movq %rdx, %r12;
13511 + movq %rdx, %r14;
13512
13513 vmovdqu (0*16)(%rdx), RL1;
13514 vmovdqu (1*16)(%rdx), RR1;
13515 @@ -447,16 +452,16 @@ ENTRY(cast5_cbc_dec_16way)
13516 call __cast5_dec_blk16;
13517
13518 /* xor with src */
13519 - vmovq (%r12), RX;
13520 + vmovq (%r14), RX;
13521 vpshufd $0x4f, RX, RX;
13522 vpxor RX, RR1, RR1;
13523 - vpxor 0*16+8(%r12), RL1, RL1;
13524 - vpxor 1*16+8(%r12), RR2, RR2;
13525 - vpxor 2*16+8(%r12), RL2, RL2;
13526 - vpxor 3*16+8(%r12), RR3, RR3;
13527 - vpxor 4*16+8(%r12), RL3, RL3;
13528 - vpxor 5*16+8(%r12), RR4, RR4;
13529 - vpxor 6*16+8(%r12), RL4, RL4;
13530 + vpxor 0*16+8(%r14), RL1, RL1;
13531 + vpxor 1*16+8(%r14), RR2, RR2;
13532 + vpxor 2*16+8(%r14), RL2, RL2;
13533 + vpxor 3*16+8(%r14), RR3, RR3;
13534 + vpxor 4*16+8(%r14), RL3, RL3;
13535 + vpxor 5*16+8(%r14), RR4, RR4;
13536 + vpxor 6*16+8(%r14), RL4, RL4;
13537
13538 vmovdqu RR1, (0*16)(%r11);
13539 vmovdqu RL1, (1*16)(%r11);
13540 @@ -467,8 +472,9 @@ ENTRY(cast5_cbc_dec_16way)
13541 vmovdqu RR4, (6*16)(%r11);
13542 vmovdqu RL4, (7*16)(%r11);
13543
13544 - popq %r12;
13545 + popq %r14;
13546
13547 + pax_force_retaddr
13548 ret;
13549 ENDPROC(cast5_cbc_dec_16way)
13550
13551 @@ -480,10 +486,10 @@ ENTRY(cast5_ctr_16way)
13552 * %rcx: iv (big endian, 64bit)
13553 */
13554
13555 - pushq %r12;
13556 + pushq %r14;
13557
13558 movq %rsi, %r11;
13559 - movq %rdx, %r12;
13560 + movq %rdx, %r14;
13561
13562 vpcmpeqd RTMP, RTMP, RTMP;
13563 vpsrldq $8, RTMP, RTMP; /* low: -1, high: 0 */
13564 @@ -523,14 +529,14 @@ ENTRY(cast5_ctr_16way)
13565 call __cast5_enc_blk16;
13566
13567 /* dst = src ^ iv */
13568 - vpxor (0*16)(%r12), RR1, RR1;
13569 - vpxor (1*16)(%r12), RL1, RL1;
13570 - vpxor (2*16)(%r12), RR2, RR2;
13571 - vpxor (3*16)(%r12), RL2, RL2;
13572 - vpxor (4*16)(%r12), RR3, RR3;
13573 - vpxor (5*16)(%r12), RL3, RL3;
13574 - vpxor (6*16)(%r12), RR4, RR4;
13575 - vpxor (7*16)(%r12), RL4, RL4;
13576 + vpxor (0*16)(%r14), RR1, RR1;
13577 + vpxor (1*16)(%r14), RL1, RL1;
13578 + vpxor (2*16)(%r14), RR2, RR2;
13579 + vpxor (3*16)(%r14), RL2, RL2;
13580 + vpxor (4*16)(%r14), RR3, RR3;
13581 + vpxor (5*16)(%r14), RL3, RL3;
13582 + vpxor (6*16)(%r14), RR4, RR4;
13583 + vpxor (7*16)(%r14), RL4, RL4;
13584 vmovdqu RR1, (0*16)(%r11);
13585 vmovdqu RL1, (1*16)(%r11);
13586 vmovdqu RR2, (2*16)(%r11);
13587 @@ -540,7 +546,8 @@ ENTRY(cast5_ctr_16way)
13588 vmovdqu RR4, (6*16)(%r11);
13589 vmovdqu RL4, (7*16)(%r11);
13590
13591 - popq %r12;
13592 + popq %r14;
13593
13594 + pax_force_retaddr
13595 ret;
13596 ENDPROC(cast5_ctr_16way)
13597 diff --git a/arch/x86/crypto/cast6-avx-x86_64-asm_64.S b/arch/x86/crypto/cast6-avx-x86_64-asm_64.S
13598 index e3531f8..e123f35 100644
13599 --- a/arch/x86/crypto/cast6-avx-x86_64-asm_64.S
13600 +++ b/arch/x86/crypto/cast6-avx-x86_64-asm_64.S
13601 @@ -24,6 +24,7 @@
13602 */
13603
13604 #include <linux/linkage.h>
13605 +#include <asm/alternative-asm.h>
13606 #include "glue_helper-asm-avx.S"
13607
13608 .file "cast6-avx-x86_64-asm_64.S"
13609 @@ -295,6 +296,7 @@ __cast6_enc_blk8:
13610 outunpack_blocks(RA1, RB1, RC1, RD1, RTMP, RX, RKRF, RKM);
13611 outunpack_blocks(RA2, RB2, RC2, RD2, RTMP, RX, RKRF, RKM);
13612
13613 + pax_force_retaddr
13614 ret;
13615 ENDPROC(__cast6_enc_blk8)
13616
13617 @@ -340,6 +342,7 @@ __cast6_dec_blk8:
13618 outunpack_blocks(RA1, RB1, RC1, RD1, RTMP, RX, RKRF, RKM);
13619 outunpack_blocks(RA2, RB2, RC2, RD2, RTMP, RX, RKRF, RKM);
13620
13621 + pax_force_retaddr
13622 ret;
13623 ENDPROC(__cast6_dec_blk8)
13624
13625 @@ -358,6 +361,7 @@ ENTRY(cast6_ecb_enc_8way)
13626
13627 store_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
13628
13629 + pax_force_retaddr
13630 ret;
13631 ENDPROC(cast6_ecb_enc_8way)
13632
13633 @@ -376,6 +380,7 @@ ENTRY(cast6_ecb_dec_8way)
13634
13635 store_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
13636
13637 + pax_force_retaddr
13638 ret;
13639 ENDPROC(cast6_ecb_dec_8way)
13640
13641 @@ -386,19 +391,20 @@ ENTRY(cast6_cbc_dec_8way)
13642 * %rdx: src
13643 */
13644
13645 - pushq %r12;
13646 + pushq %r14;
13647
13648 movq %rsi, %r11;
13649 - movq %rdx, %r12;
13650 + movq %rdx, %r14;
13651
13652 load_8way(%rdx, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
13653
13654 call __cast6_dec_blk8;
13655
13656 - store_cbc_8way(%r12, %r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
13657 + store_cbc_8way(%r14, %r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
13658
13659 - popq %r12;
13660 + popq %r14;
13661
13662 + pax_force_retaddr
13663 ret;
13664 ENDPROC(cast6_cbc_dec_8way)
13665
13666 @@ -410,20 +416,21 @@ ENTRY(cast6_ctr_8way)
13667 * %rcx: iv (little endian, 128bit)
13668 */
13669
13670 - pushq %r12;
13671 + pushq %r14;
13672
13673 movq %rsi, %r11;
13674 - movq %rdx, %r12;
13675 + movq %rdx, %r14;
13676
13677 load_ctr_8way(%rcx, .Lbswap128_mask, RA1, RB1, RC1, RD1, RA2, RB2, RC2,
13678 RD2, RX, RKR, RKM);
13679
13680 call __cast6_enc_blk8;
13681
13682 - store_ctr_8way(%r12, %r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
13683 + store_ctr_8way(%r14, %r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
13684
13685 - popq %r12;
13686 + popq %r14;
13687
13688 + pax_force_retaddr
13689 ret;
13690 ENDPROC(cast6_ctr_8way)
13691
13692 @@ -446,6 +453,7 @@ ENTRY(cast6_xts_enc_8way)
13693 /* dst <= regs xor IVs(in dst) */
13694 store_xts_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
13695
13696 + pax_force_retaddr
13697 ret;
13698 ENDPROC(cast6_xts_enc_8way)
13699
13700 @@ -468,5 +476,6 @@ ENTRY(cast6_xts_dec_8way)
13701 /* dst <= regs xor IVs(in dst) */
13702 store_xts_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
13703
13704 + pax_force_retaddr
13705 ret;
13706 ENDPROC(cast6_xts_dec_8way)
13707 diff --git a/arch/x86/crypto/crc32c-pcl-intel-asm_64.S b/arch/x86/crypto/crc32c-pcl-intel-asm_64.S
13708 index dbc4339..de6e120 100644
13709 --- a/arch/x86/crypto/crc32c-pcl-intel-asm_64.S
13710 +++ b/arch/x86/crypto/crc32c-pcl-intel-asm_64.S
13711 @@ -45,6 +45,7 @@
13712
13713 #include <asm/inst.h>
13714 #include <linux/linkage.h>
13715 +#include <asm/alternative-asm.h>
13716
13717 ## ISCSI CRC 32 Implementation with crc32 and pclmulqdq Instruction
13718
13719 @@ -312,6 +313,7 @@ do_return:
13720 popq %rsi
13721 popq %rdi
13722 popq %rbx
13723 + pax_force_retaddr
13724 ret
13725
13726 ################################################################
13727 diff --git a/arch/x86/crypto/ghash-clmulni-intel_asm.S b/arch/x86/crypto/ghash-clmulni-intel_asm.S
13728 index 185fad4..ff4cd36 100644
13729 --- a/arch/x86/crypto/ghash-clmulni-intel_asm.S
13730 +++ b/arch/x86/crypto/ghash-clmulni-intel_asm.S
13731 @@ -18,6 +18,7 @@
13732
13733 #include <linux/linkage.h>
13734 #include <asm/inst.h>
13735 +#include <asm/alternative-asm.h>
13736
13737 .data
13738
13739 @@ -89,6 +90,7 @@ __clmul_gf128mul_ble:
13740 psrlq $1, T2
13741 pxor T2, T1
13742 pxor T1, DATA
13743 + pax_force_retaddr
13744 ret
13745 ENDPROC(__clmul_gf128mul_ble)
13746
13747 @@ -101,6 +103,7 @@ ENTRY(clmul_ghash_mul)
13748 call __clmul_gf128mul_ble
13749 PSHUFB_XMM BSWAP DATA
13750 movups DATA, (%rdi)
13751 + pax_force_retaddr
13752 ret
13753 ENDPROC(clmul_ghash_mul)
13754
13755 @@ -128,5 +131,6 @@ ENTRY(clmul_ghash_update)
13756 PSHUFB_XMM BSWAP DATA
13757 movups DATA, (%rdi)
13758 .Lupdate_just_ret:
13759 + pax_force_retaddr
13760 ret
13761 ENDPROC(clmul_ghash_update)
13762 diff --git a/arch/x86/crypto/salsa20-x86_64-asm_64.S b/arch/x86/crypto/salsa20-x86_64-asm_64.S
13763 index 9279e0b..c4b3d2c 100644
13764 --- a/arch/x86/crypto/salsa20-x86_64-asm_64.S
13765 +++ b/arch/x86/crypto/salsa20-x86_64-asm_64.S
13766 @@ -1,4 +1,5 @@
13767 #include <linux/linkage.h>
13768 +#include <asm/alternative-asm.h>
13769
13770 # enter salsa20_encrypt_bytes
13771 ENTRY(salsa20_encrypt_bytes)
13772 @@ -789,6 +790,7 @@ ENTRY(salsa20_encrypt_bytes)
13773 add %r11,%rsp
13774 mov %rdi,%rax
13775 mov %rsi,%rdx
13776 + pax_force_retaddr
13777 ret
13778 # bytesatleast65:
13779 ._bytesatleast65:
13780 @@ -889,6 +891,7 @@ ENTRY(salsa20_keysetup)
13781 add %r11,%rsp
13782 mov %rdi,%rax
13783 mov %rsi,%rdx
13784 + pax_force_retaddr
13785 ret
13786 ENDPROC(salsa20_keysetup)
13787
13788 @@ -914,5 +917,6 @@ ENTRY(salsa20_ivsetup)
13789 add %r11,%rsp
13790 mov %rdi,%rax
13791 mov %rsi,%rdx
13792 + pax_force_retaddr
13793 ret
13794 ENDPROC(salsa20_ivsetup)
13795 diff --git a/arch/x86/crypto/serpent-avx-x86_64-asm_64.S b/arch/x86/crypto/serpent-avx-x86_64-asm_64.S
13796 index 2f202f4..d9164d6 100644
13797 --- a/arch/x86/crypto/serpent-avx-x86_64-asm_64.S
13798 +++ b/arch/x86/crypto/serpent-avx-x86_64-asm_64.S
13799 @@ -24,6 +24,7 @@
13800 */
13801
13802 #include <linux/linkage.h>
13803 +#include <asm/alternative-asm.h>
13804 #include "glue_helper-asm-avx.S"
13805
13806 .file "serpent-avx-x86_64-asm_64.S"
13807 @@ -618,6 +619,7 @@ __serpent_enc_blk8_avx:
13808 write_blocks(RA1, RB1, RC1, RD1, RK0, RK1, RK2);
13809 write_blocks(RA2, RB2, RC2, RD2, RK0, RK1, RK2);
13810
13811 + pax_force_retaddr
13812 ret;
13813 ENDPROC(__serpent_enc_blk8_avx)
13814
13815 @@ -672,6 +674,7 @@ __serpent_dec_blk8_avx:
13816 write_blocks(RC1, RD1, RB1, RE1, RK0, RK1, RK2);
13817 write_blocks(RC2, RD2, RB2, RE2, RK0, RK1, RK2);
13818
13819 + pax_force_retaddr
13820 ret;
13821 ENDPROC(__serpent_dec_blk8_avx)
13822
13823 @@ -688,6 +691,7 @@ ENTRY(serpent_ecb_enc_8way_avx)
13824
13825 store_8way(%rsi, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
13826
13827 + pax_force_retaddr
13828 ret;
13829 ENDPROC(serpent_ecb_enc_8way_avx)
13830
13831 @@ -704,6 +708,7 @@ ENTRY(serpent_ecb_dec_8way_avx)
13832
13833 store_8way(%rsi, RC1, RD1, RB1, RE1, RC2, RD2, RB2, RE2);
13834
13835 + pax_force_retaddr
13836 ret;
13837 ENDPROC(serpent_ecb_dec_8way_avx)
13838
13839 @@ -720,6 +725,7 @@ ENTRY(serpent_cbc_dec_8way_avx)
13840
13841 store_cbc_8way(%rdx, %rsi, RC1, RD1, RB1, RE1, RC2, RD2, RB2, RE2);
13842
13843 + pax_force_retaddr
13844 ret;
13845 ENDPROC(serpent_cbc_dec_8way_avx)
13846
13847 @@ -738,6 +744,7 @@ ENTRY(serpent_ctr_8way_avx)
13848
13849 store_ctr_8way(%rdx, %rsi, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
13850
13851 + pax_force_retaddr
13852 ret;
13853 ENDPROC(serpent_ctr_8way_avx)
13854
13855 @@ -758,6 +765,7 @@ ENTRY(serpent_xts_enc_8way_avx)
13856 /* dst <= regs xor IVs(in dst) */
13857 store_xts_8way(%rsi, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
13858
13859 + pax_force_retaddr
13860 ret;
13861 ENDPROC(serpent_xts_enc_8way_avx)
13862
13863 @@ -778,5 +786,6 @@ ENTRY(serpent_xts_dec_8way_avx)
13864 /* dst <= regs xor IVs(in dst) */
13865 store_xts_8way(%rsi, RC1, RD1, RB1, RE1, RC2, RD2, RB2, RE2);
13866
13867 + pax_force_retaddr
13868 ret;
13869 ENDPROC(serpent_xts_dec_8way_avx)
13870 diff --git a/arch/x86/crypto/serpent-avx2-asm_64.S b/arch/x86/crypto/serpent-avx2-asm_64.S
13871 index b222085..abd483c 100644
13872 --- a/arch/x86/crypto/serpent-avx2-asm_64.S
13873 +++ b/arch/x86/crypto/serpent-avx2-asm_64.S
13874 @@ -15,6 +15,7 @@
13875 */
13876
13877 #include <linux/linkage.h>
13878 +#include <asm/alternative-asm.h>
13879 #include "glue_helper-asm-avx2.S"
13880
13881 .file "serpent-avx2-asm_64.S"
13882 @@ -610,6 +611,7 @@ __serpent_enc_blk16:
13883 write_blocks(RA1, RB1, RC1, RD1, RK0, RK1, RK2);
13884 write_blocks(RA2, RB2, RC2, RD2, RK0, RK1, RK2);
13885
13886 + pax_force_retaddr
13887 ret;
13888 ENDPROC(__serpent_enc_blk16)
13889
13890 @@ -664,6 +666,7 @@ __serpent_dec_blk16:
13891 write_blocks(RC1, RD1, RB1, RE1, RK0, RK1, RK2);
13892 write_blocks(RC2, RD2, RB2, RE2, RK0, RK1, RK2);
13893
13894 + pax_force_retaddr
13895 ret;
13896 ENDPROC(__serpent_dec_blk16)
13897
13898 @@ -684,6 +687,7 @@ ENTRY(serpent_ecb_enc_16way)
13899
13900 vzeroupper;
13901
13902 + pax_force_retaddr
13903 ret;
13904 ENDPROC(serpent_ecb_enc_16way)
13905
13906 @@ -704,6 +708,7 @@ ENTRY(serpent_ecb_dec_16way)
13907
13908 vzeroupper;
13909
13910 + pax_force_retaddr
13911 ret;
13912 ENDPROC(serpent_ecb_dec_16way)
13913
13914 @@ -725,6 +730,7 @@ ENTRY(serpent_cbc_dec_16way)
13915
13916 vzeroupper;
13917
13918 + pax_force_retaddr
13919 ret;
13920 ENDPROC(serpent_cbc_dec_16way)
13921
13922 @@ -748,6 +754,7 @@ ENTRY(serpent_ctr_16way)
13923
13924 vzeroupper;
13925
13926 + pax_force_retaddr
13927 ret;
13928 ENDPROC(serpent_ctr_16way)
13929
13930 @@ -772,6 +779,7 @@ ENTRY(serpent_xts_enc_16way)
13931
13932 vzeroupper;
13933
13934 + pax_force_retaddr
13935 ret;
13936 ENDPROC(serpent_xts_enc_16way)
13937
13938 @@ -796,5 +804,6 @@ ENTRY(serpent_xts_dec_16way)
13939
13940 vzeroupper;
13941
13942 + pax_force_retaddr
13943 ret;
13944 ENDPROC(serpent_xts_dec_16way)
13945 diff --git a/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S b/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S
13946 index acc066c..1559cc4 100644
13947 --- a/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S
13948 +++ b/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S
13949 @@ -25,6 +25,7 @@
13950 */
13951
13952 #include <linux/linkage.h>
13953 +#include <asm/alternative-asm.h>
13954
13955 .file "serpent-sse2-x86_64-asm_64.S"
13956 .text
13957 @@ -690,12 +691,14 @@ ENTRY(__serpent_enc_blk_8way)
13958 write_blocks(%rsi, RA1, RB1, RC1, RD1, RK0, RK1, RK2);
13959 write_blocks(%rax, RA2, RB2, RC2, RD2, RK0, RK1, RK2);
13960
13961 + pax_force_retaddr
13962 ret;
13963
13964 .L__enc_xor8:
13965 xor_blocks(%rsi, RA1, RB1, RC1, RD1, RK0, RK1, RK2);
13966 xor_blocks(%rax, RA2, RB2, RC2, RD2, RK0, RK1, RK2);
13967
13968 + pax_force_retaddr
13969 ret;
13970 ENDPROC(__serpent_enc_blk_8way)
13971
13972 @@ -750,5 +753,6 @@ ENTRY(serpent_dec_blk_8way)
13973 write_blocks(%rsi, RC1, RD1, RB1, RE1, RK0, RK1, RK2);
13974 write_blocks(%rax, RC2, RD2, RB2, RE2, RK0, RK1, RK2);
13975
13976 + pax_force_retaddr
13977 ret;
13978 ENDPROC(serpent_dec_blk_8way)
13979 diff --git a/arch/x86/crypto/sha1_ssse3_asm.S b/arch/x86/crypto/sha1_ssse3_asm.S
13980 index a410950..9dfe7ad 100644
13981 --- a/arch/x86/crypto/sha1_ssse3_asm.S
13982 +++ b/arch/x86/crypto/sha1_ssse3_asm.S
13983 @@ -29,6 +29,7 @@
13984 */
13985
13986 #include <linux/linkage.h>
13987 +#include <asm/alternative-asm.h>
13988
13989 #define CTX %rdi // arg1
13990 #define BUF %rsi // arg2
13991 @@ -75,9 +76,9 @@
13992
13993 push %rbx
13994 push %rbp
13995 - push %r12
13996 + push %r14
13997
13998 - mov %rsp, %r12
13999 + mov %rsp, %r14
14000 sub $64, %rsp # allocate workspace
14001 and $~15, %rsp # align stack
14002
14003 @@ -99,11 +100,12 @@
14004 xor %rax, %rax
14005 rep stosq
14006
14007 - mov %r12, %rsp # deallocate workspace
14008 + mov %r14, %rsp # deallocate workspace
14009
14010 - pop %r12
14011 + pop %r14
14012 pop %rbp
14013 pop %rbx
14014 + pax_force_retaddr
14015 ret
14016
14017 ENDPROC(\name)
14018 diff --git a/arch/x86/crypto/sha256-avx-asm.S b/arch/x86/crypto/sha256-avx-asm.S
14019 index 642f156..51a513c 100644
14020 --- a/arch/x86/crypto/sha256-avx-asm.S
14021 +++ b/arch/x86/crypto/sha256-avx-asm.S
14022 @@ -49,6 +49,7 @@
14023
14024 #ifdef CONFIG_AS_AVX
14025 #include <linux/linkage.h>
14026 +#include <asm/alternative-asm.h>
14027
14028 ## assume buffers not aligned
14029 #define VMOVDQ vmovdqu
14030 @@ -460,6 +461,7 @@ done_hash:
14031 popq %r13
14032 popq %rbp
14033 popq %rbx
14034 + pax_force_retaddr
14035 ret
14036 ENDPROC(sha256_transform_avx)
14037
14038 diff --git a/arch/x86/crypto/sha256-avx2-asm.S b/arch/x86/crypto/sha256-avx2-asm.S
14039 index 9e86944..3795e6a 100644
14040 --- a/arch/x86/crypto/sha256-avx2-asm.S
14041 +++ b/arch/x86/crypto/sha256-avx2-asm.S
14042 @@ -50,6 +50,7 @@
14043
14044 #ifdef CONFIG_AS_AVX2
14045 #include <linux/linkage.h>
14046 +#include <asm/alternative-asm.h>
14047
14048 ## assume buffers not aligned
14049 #define VMOVDQ vmovdqu
14050 @@ -720,6 +721,7 @@ done_hash:
14051 popq %r12
14052 popq %rbp
14053 popq %rbx
14054 + pax_force_retaddr
14055 ret
14056 ENDPROC(sha256_transform_rorx)
14057
14058 diff --git a/arch/x86/crypto/sha256-ssse3-asm.S b/arch/x86/crypto/sha256-ssse3-asm.S
14059 index f833b74..8c62a9e 100644
14060 --- a/arch/x86/crypto/sha256-ssse3-asm.S
14061 +++ b/arch/x86/crypto/sha256-ssse3-asm.S
14062 @@ -47,6 +47,7 @@
14063 ########################################################################
14064
14065 #include <linux/linkage.h>
14066 +#include <asm/alternative-asm.h>
14067
14068 ## assume buffers not aligned
14069 #define MOVDQ movdqu
14070 @@ -471,6 +472,7 @@ done_hash:
14071 popq %rbp
14072 popq %rbx
14073
14074 + pax_force_retaddr
14075 ret
14076 ENDPROC(sha256_transform_ssse3)
14077
14078 diff --git a/arch/x86/crypto/sha512-avx-asm.S b/arch/x86/crypto/sha512-avx-asm.S
14079 index 974dde9..a823ff9 100644
14080 --- a/arch/x86/crypto/sha512-avx-asm.S
14081 +++ b/arch/x86/crypto/sha512-avx-asm.S
14082 @@ -49,6 +49,7 @@
14083
14084 #ifdef CONFIG_AS_AVX
14085 #include <linux/linkage.h>
14086 +#include <asm/alternative-asm.h>
14087
14088 .text
14089
14090 @@ -364,6 +365,7 @@ updateblock:
14091 mov frame_RSPSAVE(%rsp), %rsp
14092
14093 nowork:
14094 + pax_force_retaddr
14095 ret
14096 ENDPROC(sha512_transform_avx)
14097
14098 diff --git a/arch/x86/crypto/sha512-avx2-asm.S b/arch/x86/crypto/sha512-avx2-asm.S
14099 index 568b961..ed20c37 100644
14100 --- a/arch/x86/crypto/sha512-avx2-asm.S
14101 +++ b/arch/x86/crypto/sha512-avx2-asm.S
14102 @@ -51,6 +51,7 @@
14103
14104 #ifdef CONFIG_AS_AVX2
14105 #include <linux/linkage.h>
14106 +#include <asm/alternative-asm.h>
14107
14108 .text
14109
14110 @@ -678,6 +679,7 @@ done_hash:
14111
14112 # Restore Stack Pointer
14113 mov frame_RSPSAVE(%rsp), %rsp
14114 + pax_force_retaddr
14115 ret
14116 ENDPROC(sha512_transform_rorx)
14117
14118 diff --git a/arch/x86/crypto/sha512-ssse3-asm.S b/arch/x86/crypto/sha512-ssse3-asm.S
14119 index fb56855..6edd768 100644
14120 --- a/arch/x86/crypto/sha512-ssse3-asm.S
14121 +++ b/arch/x86/crypto/sha512-ssse3-asm.S
14122 @@ -48,6 +48,7 @@
14123 ########################################################################
14124
14125 #include <linux/linkage.h>
14126 +#include <asm/alternative-asm.h>
14127
14128 .text
14129
14130 @@ -363,6 +364,7 @@ updateblock:
14131 mov frame_RSPSAVE(%rsp), %rsp
14132
14133 nowork:
14134 + pax_force_retaddr
14135 ret
14136 ENDPROC(sha512_transform_ssse3)
14137
14138 diff --git a/arch/x86/crypto/twofish-avx-x86_64-asm_64.S b/arch/x86/crypto/twofish-avx-x86_64-asm_64.S
14139 index 0505813..b067311 100644
14140 --- a/arch/x86/crypto/twofish-avx-x86_64-asm_64.S
14141 +++ b/arch/x86/crypto/twofish-avx-x86_64-asm_64.S
14142 @@ -24,6 +24,7 @@
14143 */
14144
14145 #include <linux/linkage.h>
14146 +#include <asm/alternative-asm.h>
14147 #include "glue_helper-asm-avx.S"
14148
14149 .file "twofish-avx-x86_64-asm_64.S"
14150 @@ -284,6 +285,7 @@ __twofish_enc_blk8:
14151 outunpack_blocks(RC1, RD1, RA1, RB1, RK1, RX0, RY0, RK2);
14152 outunpack_blocks(RC2, RD2, RA2, RB2, RK1, RX0, RY0, RK2);
14153
14154 + pax_force_retaddr
14155 ret;
14156 ENDPROC(__twofish_enc_blk8)
14157
14158 @@ -324,6 +326,7 @@ __twofish_dec_blk8:
14159 outunpack_blocks(RA1, RB1, RC1, RD1, RK1, RX0, RY0, RK2);
14160 outunpack_blocks(RA2, RB2, RC2, RD2, RK1, RX0, RY0, RK2);
14161
14162 + pax_force_retaddr
14163 ret;
14164 ENDPROC(__twofish_dec_blk8)
14165
14166 @@ -342,6 +345,7 @@ ENTRY(twofish_ecb_enc_8way)
14167
14168 store_8way(%r11, RC1, RD1, RA1, RB1, RC2, RD2, RA2, RB2);
14169
14170 + pax_force_retaddr
14171 ret;
14172 ENDPROC(twofish_ecb_enc_8way)
14173
14174 @@ -360,6 +364,7 @@ ENTRY(twofish_ecb_dec_8way)
14175
14176 store_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
14177
14178 + pax_force_retaddr
14179 ret;
14180 ENDPROC(twofish_ecb_dec_8way)
14181
14182 @@ -370,19 +375,20 @@ ENTRY(twofish_cbc_dec_8way)
14183 * %rdx: src
14184 */
14185
14186 - pushq %r12;
14187 + pushq %r14;
14188
14189 movq %rsi, %r11;
14190 - movq %rdx, %r12;
14191 + movq %rdx, %r14;
14192
14193 load_8way(%rdx, RC1, RD1, RA1, RB1, RC2, RD2, RA2, RB2);
14194
14195 call __twofish_dec_blk8;
14196
14197 - store_cbc_8way(%r12, %r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
14198 + store_cbc_8way(%r14, %r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
14199
14200 - popq %r12;
14201 + popq %r14;
14202
14203 + pax_force_retaddr
14204 ret;
14205 ENDPROC(twofish_cbc_dec_8way)
14206
14207 @@ -394,20 +400,21 @@ ENTRY(twofish_ctr_8way)
14208 * %rcx: iv (little endian, 128bit)
14209 */
14210
14211 - pushq %r12;
14212 + pushq %r14;
14213
14214 movq %rsi, %r11;
14215 - movq %rdx, %r12;
14216 + movq %rdx, %r14;
14217
14218 load_ctr_8way(%rcx, .Lbswap128_mask, RA1, RB1, RC1, RD1, RA2, RB2, RC2,
14219 RD2, RX0, RX1, RY0);
14220
14221 call __twofish_enc_blk8;
14222
14223 - store_ctr_8way(%r12, %r11, RC1, RD1, RA1, RB1, RC2, RD2, RA2, RB2);
14224 + store_ctr_8way(%r14, %r11, RC1, RD1, RA1, RB1, RC2, RD2, RA2, RB2);
14225
14226 - popq %r12;
14227 + popq %r14;
14228
14229 + pax_force_retaddr
14230 ret;
14231 ENDPROC(twofish_ctr_8way)
14232
14233 @@ -430,6 +437,7 @@ ENTRY(twofish_xts_enc_8way)
14234 /* dst <= regs xor IVs(in dst) */
14235 store_xts_8way(%r11, RC1, RD1, RA1, RB1, RC2, RD2, RA2, RB2);
14236
14237 + pax_force_retaddr
14238 ret;
14239 ENDPROC(twofish_xts_enc_8way)
14240
14241 @@ -452,5 +460,6 @@ ENTRY(twofish_xts_dec_8way)
14242 /* dst <= regs xor IVs(in dst) */
14243 store_xts_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
14244
14245 + pax_force_retaddr
14246 ret;
14247 ENDPROC(twofish_xts_dec_8way)
14248 diff --git a/arch/x86/crypto/twofish-x86_64-asm_64-3way.S b/arch/x86/crypto/twofish-x86_64-asm_64-3way.S
14249 index 1c3b7ce..02f578d 100644
14250 --- a/arch/x86/crypto/twofish-x86_64-asm_64-3way.S
14251 +++ b/arch/x86/crypto/twofish-x86_64-asm_64-3way.S
14252 @@ -21,6 +21,7 @@
14253 */
14254
14255 #include <linux/linkage.h>
14256 +#include <asm/alternative-asm.h>
14257
14258 .file "twofish-x86_64-asm-3way.S"
14259 .text
14260 @@ -258,6 +259,7 @@ ENTRY(__twofish_enc_blk_3way)
14261 popq %r13;
14262 popq %r14;
14263 popq %r15;
14264 + pax_force_retaddr
14265 ret;
14266
14267 .L__enc_xor3:
14268 @@ -269,6 +271,7 @@ ENTRY(__twofish_enc_blk_3way)
14269 popq %r13;
14270 popq %r14;
14271 popq %r15;
14272 + pax_force_retaddr
14273 ret;
14274 ENDPROC(__twofish_enc_blk_3way)
14275
14276 @@ -308,5 +311,6 @@ ENTRY(twofish_dec_blk_3way)
14277 popq %r13;
14278 popq %r14;
14279 popq %r15;
14280 + pax_force_retaddr
14281 ret;
14282 ENDPROC(twofish_dec_blk_3way)
14283 diff --git a/arch/x86/crypto/twofish-x86_64-asm_64.S b/arch/x86/crypto/twofish-x86_64-asm_64.S
14284 index a039d21..524b8b2 100644
14285 --- a/arch/x86/crypto/twofish-x86_64-asm_64.S
14286 +++ b/arch/x86/crypto/twofish-x86_64-asm_64.S
14287 @@ -22,6 +22,7 @@
14288
14289 #include <linux/linkage.h>
14290 #include <asm/asm-offsets.h>
14291 +#include <asm/alternative-asm.h>
14292
14293 #define a_offset 0
14294 #define b_offset 4
14295 @@ -265,6 +266,7 @@ ENTRY(twofish_enc_blk)
14296
14297 popq R1
14298 movq $1,%rax
14299 + pax_force_retaddr
14300 ret
14301 ENDPROC(twofish_enc_blk)
14302
14303 @@ -317,5 +319,6 @@ ENTRY(twofish_dec_blk)
14304
14305 popq R1
14306 movq $1,%rax
14307 + pax_force_retaddr
14308 ret
14309 ENDPROC(twofish_dec_blk)
14310 diff --git a/arch/x86/ia32/ia32_aout.c b/arch/x86/ia32/ia32_aout.c
14311 index d21ff89..6da8e6e 100644
14312 --- a/arch/x86/ia32/ia32_aout.c
14313 +++ b/arch/x86/ia32/ia32_aout.c
14314 @@ -153,6 +153,8 @@ static int aout_core_dump(struct coredump_params *cprm)
14315 unsigned long dump_start, dump_size;
14316 struct user32 dump;
14317
14318 + memset(&dump, 0, sizeof(dump));
14319 +
14320 fs = get_fs();
14321 set_fs(KERNEL_DS);
14322 has_dumped = 1;
14323 diff --git a/arch/x86/ia32/ia32_signal.c b/arch/x86/ia32/ia32_signal.c
14324 index 2206757..85cbcfa 100644
14325 --- a/arch/x86/ia32/ia32_signal.c
14326 +++ b/arch/x86/ia32/ia32_signal.c
14327 @@ -218,7 +218,7 @@ asmlinkage long sys32_sigreturn(void)
14328 if (__get_user(set.sig[0], &frame->sc.oldmask)
14329 || (_COMPAT_NSIG_WORDS > 1
14330 && __copy_from_user((((char *) &set.sig) + 4),
14331 - &frame->extramask,
14332 + frame->extramask,
14333 sizeof(frame->extramask))))
14334 goto badframe;
14335
14336 @@ -338,7 +338,7 @@ static void __user *get_sigframe(struct ksignal *ksig, struct pt_regs *regs,
14337 sp -= frame_size;
14338 /* Align the stack pointer according to the i386 ABI,
14339 * i.e. so that on function entry ((sp + 4) & 15) == 0. */
14340 - sp = ((sp + 4) & -16ul) - 4;
14341 + sp = ((sp - 12) & -16ul) - 4;
14342 return (void __user *) sp;
14343 }
14344
14345 @@ -386,7 +386,7 @@ int ia32_setup_frame(int sig, struct ksignal *ksig,
14346 restorer = VDSO32_SYMBOL(current->mm->context.vdso,
14347 sigreturn);
14348 else
14349 - restorer = &frame->retcode;
14350 + restorer = frame->retcode;
14351 }
14352
14353 put_user_try {
14354 @@ -396,7 +396,7 @@ int ia32_setup_frame(int sig, struct ksignal *ksig,
14355 * These are actually not used anymore, but left because some
14356 * gdb versions depend on them as a marker.
14357 */
14358 - put_user_ex(*((u64 *)&code), (u64 __user *)frame->retcode);
14359 + put_user_ex(*((const u64 *)&code), (u64 __user *)frame->retcode);
14360 } put_user_catch(err);
14361
14362 if (err)
14363 @@ -438,7 +438,7 @@ int ia32_setup_rt_frame(int sig, struct ksignal *ksig,
14364 0xb8,
14365 __NR_ia32_rt_sigreturn,
14366 0x80cd,
14367 - 0,
14368 + 0
14369 };
14370
14371 frame = get_sigframe(ksig, regs, sizeof(*frame), &fpstate);
14372 @@ -461,16 +461,18 @@ int ia32_setup_rt_frame(int sig, struct ksignal *ksig,
14373
14374 if (ksig->ka.sa.sa_flags & SA_RESTORER)
14375 restorer = ksig->ka.sa.sa_restorer;
14376 + else if (current->mm->context.vdso)
14377 + /* Return stub is in 32bit vsyscall page */
14378 + restorer = VDSO32_SYMBOL(current->mm->context.vdso, rt_sigreturn);
14379 else
14380 - restorer = VDSO32_SYMBOL(current->mm->context.vdso,
14381 - rt_sigreturn);
14382 + restorer = frame->retcode;
14383 put_user_ex(ptr_to_compat(restorer), &frame->pretcode);
14384
14385 /*
14386 * Not actually used anymore, but left because some gdb
14387 * versions need it.
14388 */
14389 - put_user_ex(*((u64 *)&code), (u64 __user *)frame->retcode);
14390 + put_user_ex(*((const u64 *)&code), (u64 __user *)frame->retcode);
14391 } put_user_catch(err);
14392
14393 err |= copy_siginfo_to_user32(&frame->info, &ksig->info);
14394 diff --git a/arch/x86/ia32/ia32entry.S b/arch/x86/ia32/ia32entry.S
14395 index 4299eb0..c0687a7 100644
14396 --- a/arch/x86/ia32/ia32entry.S
14397 +++ b/arch/x86/ia32/ia32entry.S
14398 @@ -15,8 +15,10 @@
14399 #include <asm/irqflags.h>
14400 #include <asm/asm.h>
14401 #include <asm/smap.h>
14402 +#include <asm/pgtable.h>
14403 #include <linux/linkage.h>
14404 #include <linux/err.h>
14405 +#include <asm/alternative-asm.h>
14406
14407 /* Avoid __ASSEMBLER__'ifying <linux/audit.h> just for this. */
14408 #include <linux/elf-em.h>
14409 @@ -62,12 +64,12 @@
14410 */
14411 .macro LOAD_ARGS32 offset, _r9=0
14412 .if \_r9
14413 - movl \offset+16(%rsp),%r9d
14414 + movl \offset+R9(%rsp),%r9d
14415 .endif
14416 - movl \offset+40(%rsp),%ecx
14417 - movl \offset+48(%rsp),%edx
14418 - movl \offset+56(%rsp),%esi
14419 - movl \offset+64(%rsp),%edi
14420 + movl \offset+RCX(%rsp),%ecx
14421 + movl \offset+RDX(%rsp),%edx
14422 + movl \offset+RSI(%rsp),%esi
14423 + movl \offset+RDI(%rsp),%edi
14424 movl %eax,%eax /* zero extension */
14425 .endm
14426
14427 @@ -96,6 +98,32 @@ ENTRY(native_irq_enable_sysexit)
14428 ENDPROC(native_irq_enable_sysexit)
14429 #endif
14430
14431 + .macro pax_enter_kernel_user
14432 + pax_set_fptr_mask
14433 +#ifdef CONFIG_PAX_MEMORY_UDEREF
14434 + call pax_enter_kernel_user
14435 +#endif
14436 + .endm
14437 +
14438 + .macro pax_exit_kernel_user
14439 +#ifdef CONFIG_PAX_MEMORY_UDEREF
14440 + call pax_exit_kernel_user
14441 +#endif
14442 +#ifdef CONFIG_PAX_RANDKSTACK
14443 + pushq %rax
14444 + pushq %r11
14445 + call pax_randomize_kstack
14446 + popq %r11
14447 + popq %rax
14448 +#endif
14449 + .endm
14450 +
14451 + .macro pax_erase_kstack
14452 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
14453 + call pax_erase_kstack
14454 +#endif
14455 + .endm
14456 +
14457 /*
14458 * 32bit SYSENTER instruction entry.
14459 *
14460 @@ -122,12 +150,6 @@ ENTRY(ia32_sysenter_target)
14461 CFI_REGISTER rsp,rbp
14462 SWAPGS_UNSAFE_STACK
14463 movq PER_CPU_VAR(kernel_stack), %rsp
14464 - addq $(KERNEL_STACK_OFFSET),%rsp
14465 - /*
14466 - * No need to follow this irqs on/off section: the syscall
14467 - * disabled irqs, here we enable it straight after entry:
14468 - */
14469 - ENABLE_INTERRUPTS(CLBR_NONE)
14470 movl %ebp,%ebp /* zero extension */
14471 pushq_cfi $__USER32_DS
14472 /*CFI_REL_OFFSET ss,0*/
14473 @@ -135,24 +157,49 @@ ENTRY(ia32_sysenter_target)
14474 CFI_REL_OFFSET rsp,0
14475 pushfq_cfi
14476 /*CFI_REL_OFFSET rflags,0*/
14477 - movl TI_sysenter_return+THREAD_INFO(%rsp,3*8-KERNEL_STACK_OFFSET),%r10d
14478 - CFI_REGISTER rip,r10
14479 + orl $X86_EFLAGS_IF,(%rsp)
14480 + GET_THREAD_INFO(%r11)
14481 + movl TI_sysenter_return(%r11), %r11d
14482 + CFI_REGISTER rip,r11
14483 pushq_cfi $__USER32_CS
14484 /*CFI_REL_OFFSET cs,0*/
14485 movl %eax, %eax
14486 - pushq_cfi %r10
14487 + pushq_cfi %r11
14488 CFI_REL_OFFSET rip,0
14489 pushq_cfi %rax
14490 cld
14491 SAVE_ARGS 0,1,0
14492 + pax_enter_kernel_user
14493 +
14494 +#ifdef CONFIG_PAX_RANDKSTACK
14495 + pax_erase_kstack
14496 +#endif
14497 +
14498 + /*
14499 + * No need to follow this irqs on/off section: the syscall
14500 + * disabled irqs, here we enable it straight after entry:
14501 + */
14502 + ENABLE_INTERRUPTS(CLBR_NONE)
14503 /* no need to do an access_ok check here because rbp has been
14504 32bit zero extended */
14505 +
14506 +#ifdef CONFIG_PAX_MEMORY_UDEREF
14507 + addq pax_user_shadow_base,%rbp
14508 + ASM_PAX_OPEN_USERLAND
14509 +#endif
14510 +
14511 ASM_STAC
14512 1: movl (%rbp),%ebp
14513 _ASM_EXTABLE(1b,ia32_badarg)
14514 ASM_CLAC
14515 - orl $TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
14516 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
14517 +
14518 +#ifdef CONFIG_PAX_MEMORY_UDEREF
14519 + ASM_PAX_CLOSE_USERLAND
14520 +#endif
14521 +
14522 + GET_THREAD_INFO(%r11)
14523 + orl $TS_COMPAT,TI_status(%r11)
14524 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r11)
14525 CFI_REMEMBER_STATE
14526 jnz sysenter_tracesys
14527 cmpq $(IA32_NR_syscalls-1),%rax
14528 @@ -162,15 +209,18 @@ sysenter_do_call:
14529 sysenter_dispatch:
14530 call *ia32_sys_call_table(,%rax,8)
14531 movq %rax,RAX-ARGOFFSET(%rsp)
14532 + GET_THREAD_INFO(%r11)
14533 DISABLE_INTERRUPTS(CLBR_NONE)
14534 TRACE_IRQS_OFF
14535 - testl $_TIF_ALLWORK_MASK,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
14536 + testl $_TIF_ALLWORK_MASK,TI_flags(%r11)
14537 jnz sysexit_audit
14538 sysexit_from_sys_call:
14539 - andl $~TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
14540 + pax_exit_kernel_user
14541 + pax_erase_kstack
14542 + andl $~TS_COMPAT,TI_status(%r11)
14543 /* clear IF, that popfq doesn't enable interrupts early */
14544 - andl $~0x200,EFLAGS-R11(%rsp)
14545 - movl RIP-R11(%rsp),%edx /* User %eip */
14546 + andl $~X86_EFLAGS_IF,EFLAGS(%rsp)
14547 + movl RIP(%rsp),%edx /* User %eip */
14548 CFI_REGISTER rip,rdx
14549 RESTORE_ARGS 0,24,0,0,0,0
14550 xorq %r8,%r8
14551 @@ -193,6 +243,9 @@ sysexit_from_sys_call:
14552 movl %eax,%esi /* 2nd arg: syscall number */
14553 movl $AUDIT_ARCH_I386,%edi /* 1st arg: audit arch */
14554 call __audit_syscall_entry
14555 +
14556 + pax_erase_kstack
14557 +
14558 movl RAX-ARGOFFSET(%rsp),%eax /* reload syscall number */
14559 cmpq $(IA32_NR_syscalls-1),%rax
14560 ja ia32_badsys
14561 @@ -204,7 +257,7 @@ sysexit_from_sys_call:
14562 .endm
14563
14564 .macro auditsys_exit exit
14565 - testl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
14566 + testl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT),TI_flags(%r11)
14567 jnz ia32_ret_from_sys_call
14568 TRACE_IRQS_ON
14569 ENABLE_INTERRUPTS(CLBR_NONE)
14570 @@ -215,11 +268,12 @@ sysexit_from_sys_call:
14571 1: setbe %al /* 1 if error, 0 if not */
14572 movzbl %al,%edi /* zero-extend that into %edi */
14573 call __audit_syscall_exit
14574 + GET_THREAD_INFO(%r11)
14575 movq RAX-ARGOFFSET(%rsp),%rax /* reload syscall return value */
14576 movl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT),%edi
14577 DISABLE_INTERRUPTS(CLBR_NONE)
14578 TRACE_IRQS_OFF
14579 - testl %edi,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
14580 + testl %edi,TI_flags(%r11)
14581 jz \exit
14582 CLEAR_RREGS -ARGOFFSET
14583 jmp int_with_check
14584 @@ -237,7 +291,7 @@ sysexit_audit:
14585
14586 sysenter_tracesys:
14587 #ifdef CONFIG_AUDITSYSCALL
14588 - testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
14589 + testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags(%r11)
14590 jz sysenter_auditsys
14591 #endif
14592 SAVE_REST
14593 @@ -249,6 +303,9 @@ sysenter_tracesys:
14594 RESTORE_REST
14595 cmpq $(IA32_NR_syscalls-1),%rax
14596 ja int_ret_from_sys_call /* sysenter_tracesys has set RAX(%rsp) */
14597 +
14598 + pax_erase_kstack
14599 +
14600 jmp sysenter_do_call
14601 CFI_ENDPROC
14602 ENDPROC(ia32_sysenter_target)
14603 @@ -276,19 +333,25 @@ ENDPROC(ia32_sysenter_target)
14604 ENTRY(ia32_cstar_target)
14605 CFI_STARTPROC32 simple
14606 CFI_SIGNAL_FRAME
14607 - CFI_DEF_CFA rsp,KERNEL_STACK_OFFSET
14608 + CFI_DEF_CFA rsp,0
14609 CFI_REGISTER rip,rcx
14610 /*CFI_REGISTER rflags,r11*/
14611 SWAPGS_UNSAFE_STACK
14612 movl %esp,%r8d
14613 CFI_REGISTER rsp,r8
14614 movq PER_CPU_VAR(kernel_stack),%rsp
14615 + SAVE_ARGS 8*6,0,0
14616 + pax_enter_kernel_user
14617 +
14618 +#ifdef CONFIG_PAX_RANDKSTACK
14619 + pax_erase_kstack
14620 +#endif
14621 +
14622 /*
14623 * No need to follow this irqs on/off section: the syscall
14624 * disabled irqs and here we enable it straight after entry:
14625 */
14626 ENABLE_INTERRUPTS(CLBR_NONE)
14627 - SAVE_ARGS 8,0,0
14628 movl %eax,%eax /* zero extension */
14629 movq %rax,ORIG_RAX-ARGOFFSET(%rsp)
14630 movq %rcx,RIP-ARGOFFSET(%rsp)
14631 @@ -304,12 +367,25 @@ ENTRY(ia32_cstar_target)
14632 /* no need to do an access_ok check here because r8 has been
14633 32bit zero extended */
14634 /* hardware stack frame is complete now */
14635 +
14636 +#ifdef CONFIG_PAX_MEMORY_UDEREF
14637 + ASM_PAX_OPEN_USERLAND
14638 + movq pax_user_shadow_base,%r8
14639 + addq RSP-ARGOFFSET(%rsp),%r8
14640 +#endif
14641 +
14642 ASM_STAC
14643 1: movl (%r8),%r9d
14644 _ASM_EXTABLE(1b,ia32_badarg)
14645 ASM_CLAC
14646 - orl $TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
14647 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
14648 +
14649 +#ifdef CONFIG_PAX_MEMORY_UDEREF
14650 + ASM_PAX_CLOSE_USERLAND
14651 +#endif
14652 +
14653 + GET_THREAD_INFO(%r11)
14654 + orl $TS_COMPAT,TI_status(%r11)
14655 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r11)
14656 CFI_REMEMBER_STATE
14657 jnz cstar_tracesys
14658 cmpq $IA32_NR_syscalls-1,%rax
14659 @@ -319,13 +395,16 @@ cstar_do_call:
14660 cstar_dispatch:
14661 call *ia32_sys_call_table(,%rax,8)
14662 movq %rax,RAX-ARGOFFSET(%rsp)
14663 + GET_THREAD_INFO(%r11)
14664 DISABLE_INTERRUPTS(CLBR_NONE)
14665 TRACE_IRQS_OFF
14666 - testl $_TIF_ALLWORK_MASK,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
14667 + testl $_TIF_ALLWORK_MASK,TI_flags(%r11)
14668 jnz sysretl_audit
14669 sysretl_from_sys_call:
14670 - andl $~TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
14671 - RESTORE_ARGS 0,-ARG_SKIP,0,0,0
14672 + pax_exit_kernel_user
14673 + pax_erase_kstack
14674 + andl $~TS_COMPAT,TI_status(%r11)
14675 + RESTORE_ARGS 0,-ORIG_RAX,0,0,0
14676 movl RIP-ARGOFFSET(%rsp),%ecx
14677 CFI_REGISTER rip,rcx
14678 movl EFLAGS-ARGOFFSET(%rsp),%r11d
14679 @@ -352,7 +431,7 @@ sysretl_audit:
14680
14681 cstar_tracesys:
14682 #ifdef CONFIG_AUDITSYSCALL
14683 - testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
14684 + testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags(%r11)
14685 jz cstar_auditsys
14686 #endif
14687 xchgl %r9d,%ebp
14688 @@ -366,11 +445,19 @@ cstar_tracesys:
14689 xchgl %ebp,%r9d
14690 cmpq $(IA32_NR_syscalls-1),%rax
14691 ja int_ret_from_sys_call /* cstar_tracesys has set RAX(%rsp) */
14692 +
14693 + pax_erase_kstack
14694 +
14695 jmp cstar_do_call
14696 END(ia32_cstar_target)
14697
14698 ia32_badarg:
14699 ASM_CLAC
14700 +
14701 +#ifdef CONFIG_PAX_MEMORY_UDEREF
14702 + ASM_PAX_CLOSE_USERLAND
14703 +#endif
14704 +
14705 movq $-EFAULT,%rax
14706 jmp ia32_sysret
14707 CFI_ENDPROC
14708 @@ -407,19 +494,26 @@ ENTRY(ia32_syscall)
14709 CFI_REL_OFFSET rip,RIP-RIP
14710 PARAVIRT_ADJUST_EXCEPTION_FRAME
14711 SWAPGS
14712 - /*
14713 - * No need to follow this irqs on/off section: the syscall
14714 - * disabled irqs and here we enable it straight after entry:
14715 - */
14716 - ENABLE_INTERRUPTS(CLBR_NONE)
14717 movl %eax,%eax
14718 pushq_cfi %rax
14719 cld
14720 /* note the registers are not zero extended to the sf.
14721 this could be a problem. */
14722 SAVE_ARGS 0,1,0
14723 - orl $TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
14724 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
14725 + pax_enter_kernel_user
14726 +
14727 +#ifdef CONFIG_PAX_RANDKSTACK
14728 + pax_erase_kstack
14729 +#endif
14730 +
14731 + /*
14732 + * No need to follow this irqs on/off section: the syscall
14733 + * disabled irqs and here we enable it straight after entry:
14734 + */
14735 + ENABLE_INTERRUPTS(CLBR_NONE)
14736 + GET_THREAD_INFO(%r11)
14737 + orl $TS_COMPAT,TI_status(%r11)
14738 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r11)
14739 jnz ia32_tracesys
14740 cmpq $(IA32_NR_syscalls-1),%rax
14741 ja ia32_badsys
14742 @@ -442,6 +536,9 @@ ia32_tracesys:
14743 RESTORE_REST
14744 cmpq $(IA32_NR_syscalls-1),%rax
14745 ja int_ret_from_sys_call /* ia32_tracesys has set RAX(%rsp) */
14746 +
14747 + pax_erase_kstack
14748 +
14749 jmp ia32_do_call
14750 END(ia32_syscall)
14751
14752 diff --git a/arch/x86/ia32/sys_ia32.c b/arch/x86/ia32/sys_ia32.c
14753 index 8e0ceec..af13504 100644
14754 --- a/arch/x86/ia32/sys_ia32.c
14755 +++ b/arch/x86/ia32/sys_ia32.c
14756 @@ -69,8 +69,8 @@ asmlinkage long sys32_ftruncate64(unsigned int fd, unsigned long offset_low,
14757 */
14758 static int cp_stat64(struct stat64 __user *ubuf, struct kstat *stat)
14759 {
14760 - typeof(ubuf->st_uid) uid = 0;
14761 - typeof(ubuf->st_gid) gid = 0;
14762 + typeof(((struct stat64 *)0)->st_uid) uid = 0;
14763 + typeof(((struct stat64 *)0)->st_gid) gid = 0;
14764 SET_UID(uid, from_kuid_munged(current_user_ns(), stat->uid));
14765 SET_GID(gid, from_kgid_munged(current_user_ns(), stat->gid));
14766 if (!access_ok(VERIFY_WRITE, ubuf, sizeof(struct stat64)) ||
14767 diff --git a/arch/x86/include/asm/alternative-asm.h b/arch/x86/include/asm/alternative-asm.h
14768 index 372231c..51b537d 100644
14769 --- a/arch/x86/include/asm/alternative-asm.h
14770 +++ b/arch/x86/include/asm/alternative-asm.h
14771 @@ -18,6 +18,45 @@
14772 .endm
14773 #endif
14774
14775 +#ifdef KERNEXEC_PLUGIN
14776 + .macro pax_force_retaddr_bts rip=0
14777 + btsq $63,\rip(%rsp)
14778 + .endm
14779 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_BTS
14780 + .macro pax_force_retaddr rip=0, reload=0
14781 + btsq $63,\rip(%rsp)
14782 + .endm
14783 + .macro pax_force_fptr ptr
14784 + btsq $63,\ptr
14785 + .endm
14786 + .macro pax_set_fptr_mask
14787 + .endm
14788 +#endif
14789 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR
14790 + .macro pax_force_retaddr rip=0, reload=0
14791 + .if \reload
14792 + pax_set_fptr_mask
14793 + .endif
14794 + orq %r12,\rip(%rsp)
14795 + .endm
14796 + .macro pax_force_fptr ptr
14797 + orq %r12,\ptr
14798 + .endm
14799 + .macro pax_set_fptr_mask
14800 + movabs $0x8000000000000000,%r12
14801 + .endm
14802 +#endif
14803 +#else
14804 + .macro pax_force_retaddr rip=0, reload=0
14805 + .endm
14806 + .macro pax_force_fptr ptr
14807 + .endm
14808 + .macro pax_force_retaddr_bts rip=0
14809 + .endm
14810 + .macro pax_set_fptr_mask
14811 + .endm
14812 +#endif
14813 +
14814 .macro altinstruction_entry orig alt feature orig_len alt_len
14815 .long \orig - .
14816 .long \alt - .
14817 diff --git a/arch/x86/include/asm/alternative.h b/arch/x86/include/asm/alternative.h
14818 index 0a3f9c9..c9d081d 100644
14819 --- a/arch/x86/include/asm/alternative.h
14820 +++ b/arch/x86/include/asm/alternative.h
14821 @@ -106,7 +106,7 @@ static inline int alternatives_text_reserved(void *start, void *end)
14822 ".pushsection .discard,\"aw\",@progbits\n" \
14823 DISCARD_ENTRY(1) \
14824 ".popsection\n" \
14825 - ".pushsection .altinstr_replacement, \"ax\"\n" \
14826 + ".pushsection .altinstr_replacement, \"a\"\n" \
14827 ALTINSTR_REPLACEMENT(newinstr, feature, 1) \
14828 ".popsection"
14829
14830 @@ -120,7 +120,7 @@ static inline int alternatives_text_reserved(void *start, void *end)
14831 DISCARD_ENTRY(1) \
14832 DISCARD_ENTRY(2) \
14833 ".popsection\n" \
14834 - ".pushsection .altinstr_replacement, \"ax\"\n" \
14835 + ".pushsection .altinstr_replacement, \"a\"\n" \
14836 ALTINSTR_REPLACEMENT(newinstr1, feature1, 1) \
14837 ALTINSTR_REPLACEMENT(newinstr2, feature2, 2) \
14838 ".popsection"
14839 diff --git a/arch/x86/include/asm/apic.h b/arch/x86/include/asm/apic.h
14840 index 19b0eba..12254cd 100644
14841 --- a/arch/x86/include/asm/apic.h
14842 +++ b/arch/x86/include/asm/apic.h
14843 @@ -45,7 +45,7 @@ static inline void generic_apic_probe(void)
14844
14845 #ifdef CONFIG_X86_LOCAL_APIC
14846
14847 -extern unsigned int apic_verbosity;
14848 +extern int apic_verbosity;
14849 extern int local_apic_timer_c2_ok;
14850
14851 extern int disable_apic;
14852 diff --git a/arch/x86/include/asm/apm.h b/arch/x86/include/asm/apm.h
14853 index 20370c6..a2eb9b0 100644
14854 --- a/arch/x86/include/asm/apm.h
14855 +++ b/arch/x86/include/asm/apm.h
14856 @@ -34,7 +34,7 @@ static inline void apm_bios_call_asm(u32 func, u32 ebx_in, u32 ecx_in,
14857 __asm__ __volatile__(APM_DO_ZERO_SEGS
14858 "pushl %%edi\n\t"
14859 "pushl %%ebp\n\t"
14860 - "lcall *%%cs:apm_bios_entry\n\t"
14861 + "lcall *%%ss:apm_bios_entry\n\t"
14862 "setc %%al\n\t"
14863 "popl %%ebp\n\t"
14864 "popl %%edi\n\t"
14865 @@ -58,7 +58,7 @@ static inline u8 apm_bios_call_simple_asm(u32 func, u32 ebx_in,
14866 __asm__ __volatile__(APM_DO_ZERO_SEGS
14867 "pushl %%edi\n\t"
14868 "pushl %%ebp\n\t"
14869 - "lcall *%%cs:apm_bios_entry\n\t"
14870 + "lcall *%%ss:apm_bios_entry\n\t"
14871 "setc %%bl\n\t"
14872 "popl %%ebp\n\t"
14873 "popl %%edi\n\t"
14874 diff --git a/arch/x86/include/asm/atomic.h b/arch/x86/include/asm/atomic.h
14875 index b17f4f4..9620151 100644
14876 --- a/arch/x86/include/asm/atomic.h
14877 +++ b/arch/x86/include/asm/atomic.h
14878 @@ -23,7 +23,18 @@
14879 */
14880 static inline int atomic_read(const atomic_t *v)
14881 {
14882 - return (*(volatile int *)&(v)->counter);
14883 + return (*(volatile const int *)&(v)->counter);
14884 +}
14885 +
14886 +/**
14887 + * atomic_read_unchecked - read atomic variable
14888 + * @v: pointer of type atomic_unchecked_t
14889 + *
14890 + * Atomically reads the value of @v.
14891 + */
14892 +static inline int __intentional_overflow(-1) atomic_read_unchecked(const atomic_unchecked_t *v)
14893 +{
14894 + return (*(volatile const int *)&(v)->counter);
14895 }
14896
14897 /**
14898 @@ -39,6 +50,18 @@ static inline void atomic_set(atomic_t *v, int i)
14899 }
14900
14901 /**
14902 + * atomic_set_unchecked - set atomic variable
14903 + * @v: pointer of type atomic_unchecked_t
14904 + * @i: required value
14905 + *
14906 + * Atomically sets the value of @v to @i.
14907 + */
14908 +static inline void atomic_set_unchecked(atomic_unchecked_t *v, int i)
14909 +{
14910 + v->counter = i;
14911 +}
14912 +
14913 +/**
14914 * atomic_add - add integer to atomic variable
14915 * @i: integer value to add
14916 * @v: pointer of type atomic_t
14917 @@ -47,7 +70,29 @@ static inline void atomic_set(atomic_t *v, int i)
14918 */
14919 static inline void atomic_add(int i, atomic_t *v)
14920 {
14921 - asm volatile(LOCK_PREFIX "addl %1,%0"
14922 + asm volatile(LOCK_PREFIX "addl %1,%0\n"
14923 +
14924 +#ifdef CONFIG_PAX_REFCOUNT
14925 + "jno 0f\n"
14926 + LOCK_PREFIX "subl %1,%0\n"
14927 + "int $4\n0:\n"
14928 + _ASM_EXTABLE(0b, 0b)
14929 +#endif
14930 +
14931 + : "+m" (v->counter)
14932 + : "ir" (i));
14933 +}
14934 +
14935 +/**
14936 + * atomic_add_unchecked - add integer to atomic variable
14937 + * @i: integer value to add
14938 + * @v: pointer of type atomic_unchecked_t
14939 + *
14940 + * Atomically adds @i to @v.
14941 + */
14942 +static inline void atomic_add_unchecked(int i, atomic_unchecked_t *v)
14943 +{
14944 + asm volatile(LOCK_PREFIX "addl %1,%0\n"
14945 : "+m" (v->counter)
14946 : "ir" (i));
14947 }
14948 @@ -61,7 +106,29 @@ static inline void atomic_add(int i, atomic_t *v)
14949 */
14950 static inline void atomic_sub(int i, atomic_t *v)
14951 {
14952 - asm volatile(LOCK_PREFIX "subl %1,%0"
14953 + asm volatile(LOCK_PREFIX "subl %1,%0\n"
14954 +
14955 +#ifdef CONFIG_PAX_REFCOUNT
14956 + "jno 0f\n"
14957 + LOCK_PREFIX "addl %1,%0\n"
14958 + "int $4\n0:\n"
14959 + _ASM_EXTABLE(0b, 0b)
14960 +#endif
14961 +
14962 + : "+m" (v->counter)
14963 + : "ir" (i));
14964 +}
14965 +
14966 +/**
14967 + * atomic_sub_unchecked - subtract integer from atomic variable
14968 + * @i: integer value to subtract
14969 + * @v: pointer of type atomic_unchecked_t
14970 + *
14971 + * Atomically subtracts @i from @v.
14972 + */
14973 +static inline void atomic_sub_unchecked(int i, atomic_unchecked_t *v)
14974 +{
14975 + asm volatile(LOCK_PREFIX "subl %1,%0\n"
14976 : "+m" (v->counter)
14977 : "ir" (i));
14978 }
14979 @@ -77,7 +144,7 @@ static inline void atomic_sub(int i, atomic_t *v)
14980 */
14981 static inline int atomic_sub_and_test(int i, atomic_t *v)
14982 {
14983 - GEN_BINARY_RMWcc(LOCK_PREFIX "subl", v->counter, "er", i, "%0", "e");
14984 + GEN_BINARY_RMWcc(LOCK_PREFIX "subl", LOCK_PREFIX "addl", v->counter, "er", i, "%0", "e");
14985 }
14986
14987 /**
14988 @@ -88,7 +155,27 @@ static inline int atomic_sub_and_test(int i, atomic_t *v)
14989 */
14990 static inline void atomic_inc(atomic_t *v)
14991 {
14992 - asm volatile(LOCK_PREFIX "incl %0"
14993 + asm volatile(LOCK_PREFIX "incl %0\n"
14994 +
14995 +#ifdef CONFIG_PAX_REFCOUNT
14996 + "jno 0f\n"
14997 + LOCK_PREFIX "decl %0\n"
14998 + "int $4\n0:\n"
14999 + _ASM_EXTABLE(0b, 0b)
15000 +#endif
15001 +
15002 + : "+m" (v->counter));
15003 +}
15004 +
15005 +/**
15006 + * atomic_inc_unchecked - increment atomic variable
15007 + * @v: pointer of type atomic_unchecked_t
15008 + *
15009 + * Atomically increments @v by 1.
15010 + */
15011 +static inline void atomic_inc_unchecked(atomic_unchecked_t *v)
15012 +{
15013 + asm volatile(LOCK_PREFIX "incl %0\n"
15014 : "+m" (v->counter));
15015 }
15016
15017 @@ -100,7 +187,27 @@ static inline void atomic_inc(atomic_t *v)
15018 */
15019 static inline void atomic_dec(atomic_t *v)
15020 {
15021 - asm volatile(LOCK_PREFIX "decl %0"
15022 + asm volatile(LOCK_PREFIX "decl %0\n"
15023 +
15024 +#ifdef CONFIG_PAX_REFCOUNT
15025 + "jno 0f\n"
15026 + LOCK_PREFIX "incl %0\n"
15027 + "int $4\n0:\n"
15028 + _ASM_EXTABLE(0b, 0b)
15029 +#endif
15030 +
15031 + : "+m" (v->counter));
15032 +}
15033 +
15034 +/**
15035 + * atomic_dec_unchecked - decrement atomic variable
15036 + * @v: pointer of type atomic_unchecked_t
15037 + *
15038 + * Atomically decrements @v by 1.
15039 + */
15040 +static inline void atomic_dec_unchecked(atomic_unchecked_t *v)
15041 +{
15042 + asm volatile(LOCK_PREFIX "decl %0\n"
15043 : "+m" (v->counter));
15044 }
15045
15046 @@ -114,7 +221,7 @@ static inline void atomic_dec(atomic_t *v)
15047 */
15048 static inline int atomic_dec_and_test(atomic_t *v)
15049 {
15050 - GEN_UNARY_RMWcc(LOCK_PREFIX "decl", v->counter, "%0", "e");
15051 + GEN_UNARY_RMWcc(LOCK_PREFIX "decl", LOCK_PREFIX "incl", v->counter, "%0", "e");
15052 }
15053
15054 /**
15055 @@ -127,7 +234,20 @@ static inline int atomic_dec_and_test(atomic_t *v)
15056 */
15057 static inline int atomic_inc_and_test(atomic_t *v)
15058 {
15059 - GEN_UNARY_RMWcc(LOCK_PREFIX "incl", v->counter, "%0", "e");
15060 + GEN_UNARY_RMWcc(LOCK_PREFIX "incl", LOCK_PREFIX "decl", v->counter, "%0", "e");
15061 +}
15062 +
15063 +/**
15064 + * atomic_inc_and_test_unchecked - increment and test
15065 + * @v: pointer of type atomic_unchecked_t
15066 + *
15067 + * Atomically increments @v by 1
15068 + * and returns true if the result is zero, or false for all
15069 + * other cases.
15070 + */
15071 +static inline int atomic_inc_and_test_unchecked(atomic_unchecked_t *v)
15072 +{
15073 + GEN_UNARY_RMWcc_unchecked(LOCK_PREFIX "incl", v->counter, "%0", "e");
15074 }
15075
15076 /**
15077 @@ -141,7 +261,7 @@ static inline int atomic_inc_and_test(atomic_t *v)
15078 */
15079 static inline int atomic_add_negative(int i, atomic_t *v)
15080 {
15081 - GEN_BINARY_RMWcc(LOCK_PREFIX "addl", v->counter, "er", i, "%0", "s");
15082 + GEN_BINARY_RMWcc(LOCK_PREFIX "addl", LOCK_PREFIX "subl", v->counter, "er", i, "%0", "s");
15083 }
15084
15085 /**
15086 @@ -153,6 +273,18 @@ static inline int atomic_add_negative(int i, atomic_t *v)
15087 */
15088 static inline int atomic_add_return(int i, atomic_t *v)
15089 {
15090 + return i + xadd_check_overflow(&v->counter, i);
15091 +}
15092 +
15093 +/**
15094 + * atomic_add_return_unchecked - add integer and return
15095 + * @i: integer value to add
15096 + * @v: pointer of type atomic_unchecked_t
15097 + *
15098 + * Atomically adds @i to @v and returns @i + @v
15099 + */
15100 +static inline int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
15101 +{
15102 return i + xadd(&v->counter, i);
15103 }
15104
15105 @@ -169,9 +301,18 @@ static inline int atomic_sub_return(int i, atomic_t *v)
15106 }
15107
15108 #define atomic_inc_return(v) (atomic_add_return(1, v))
15109 +static inline int atomic_inc_return_unchecked(atomic_unchecked_t *v)
15110 +{
15111 + return atomic_add_return_unchecked(1, v);
15112 +}
15113 #define atomic_dec_return(v) (atomic_sub_return(1, v))
15114
15115 -static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
15116 +static inline int __intentional_overflow(-1) atomic_cmpxchg(atomic_t *v, int old, int new)
15117 +{
15118 + return cmpxchg(&v->counter, old, new);
15119 +}
15120 +
15121 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *v, int old, int new)
15122 {
15123 return cmpxchg(&v->counter, old, new);
15124 }
15125 @@ -181,6 +322,11 @@ static inline int atomic_xchg(atomic_t *v, int new)
15126 return xchg(&v->counter, new);
15127 }
15128
15129 +static inline int atomic_xchg_unchecked(atomic_unchecked_t *v, int new)
15130 +{
15131 + return xchg(&v->counter, new);
15132 +}
15133 +
15134 /**
15135 * __atomic_add_unless - add unless the number is already a given value
15136 * @v: pointer of type atomic_t
15137 @@ -190,14 +336,27 @@ static inline int atomic_xchg(atomic_t *v, int new)
15138 * Atomically adds @a to @v, so long as @v was not already @u.
15139 * Returns the old value of @v.
15140 */
15141 -static inline int __atomic_add_unless(atomic_t *v, int a, int u)
15142 +static inline int __intentional_overflow(-1) __atomic_add_unless(atomic_t *v, int a, int u)
15143 {
15144 - int c, old;
15145 + int c, old, new;
15146 c = atomic_read(v);
15147 for (;;) {
15148 - if (unlikely(c == (u)))
15149 + if (unlikely(c == u))
15150 break;
15151 - old = atomic_cmpxchg((v), c, c + (a));
15152 +
15153 + asm volatile("addl %2,%0\n"
15154 +
15155 +#ifdef CONFIG_PAX_REFCOUNT
15156 + "jno 0f\n"
15157 + "subl %2,%0\n"
15158 + "int $4\n0:\n"
15159 + _ASM_EXTABLE(0b, 0b)
15160 +#endif
15161 +
15162 + : "=r" (new)
15163 + : "0" (c), "ir" (a));
15164 +
15165 + old = atomic_cmpxchg(v, c, new);
15166 if (likely(old == c))
15167 break;
15168 c = old;
15169 @@ -206,6 +365,49 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
15170 }
15171
15172 /**
15173 + * atomic_inc_not_zero_hint - increment if not null
15174 + * @v: pointer of type atomic_t
15175 + * @hint: probable value of the atomic before the increment
15176 + *
15177 + * This version of atomic_inc_not_zero() gives a hint of probable
15178 + * value of the atomic. This helps processor to not read the memory
15179 + * before doing the atomic read/modify/write cycle, lowering
15180 + * number of bus transactions on some arches.
15181 + *
15182 + * Returns: 0 if increment was not done, 1 otherwise.
15183 + */
15184 +#define atomic_inc_not_zero_hint atomic_inc_not_zero_hint
15185 +static inline int atomic_inc_not_zero_hint(atomic_t *v, int hint)
15186 +{
15187 + int val, c = hint, new;
15188 +
15189 + /* sanity test, should be removed by compiler if hint is a constant */
15190 + if (!hint)
15191 + return __atomic_add_unless(v, 1, 0);
15192 +
15193 + do {
15194 + asm volatile("incl %0\n"
15195 +
15196 +#ifdef CONFIG_PAX_REFCOUNT
15197 + "jno 0f\n"
15198 + "decl %0\n"
15199 + "int $4\n0:\n"
15200 + _ASM_EXTABLE(0b, 0b)
15201 +#endif
15202 +
15203 + : "=r" (new)
15204 + : "0" (c));
15205 +
15206 + val = atomic_cmpxchg(v, c, new);
15207 + if (val == c)
15208 + return 1;
15209 + c = val;
15210 + } while (c);
15211 +
15212 + return 0;
15213 +}
15214 +
15215 +/**
15216 * atomic_inc_short - increment of a short integer
15217 * @v: pointer to type int
15218 *
15219 @@ -234,14 +436,37 @@ static inline void atomic_or_long(unsigned long *v1, unsigned long v2)
15220 #endif
15221
15222 /* These are x86-specific, used by some header files */
15223 -#define atomic_clear_mask(mask, addr) \
15224 - asm volatile(LOCK_PREFIX "andl %0,%1" \
15225 - : : "r" (~(mask)), "m" (*(addr)) : "memory")
15226 +static inline void atomic_clear_mask(unsigned int mask, atomic_t *v)
15227 +{
15228 + asm volatile(LOCK_PREFIX "andl %1,%0"
15229 + : "+m" (v->counter)
15230 + : "r" (~(mask))
15231 + : "memory");
15232 +}
15233
15234 -#define atomic_set_mask(mask, addr) \
15235 - asm volatile(LOCK_PREFIX "orl %0,%1" \
15236 - : : "r" ((unsigned)(mask)), "m" (*(addr)) \
15237 - : "memory")
15238 +static inline void atomic_clear_mask_unchecked(unsigned int mask, atomic_unchecked_t *v)
15239 +{
15240 + asm volatile(LOCK_PREFIX "andl %1,%0"
15241 + : "+m" (v->counter)
15242 + : "r" (~(mask))
15243 + : "memory");
15244 +}
15245 +
15246 +static inline void atomic_set_mask(unsigned int mask, atomic_t *v)
15247 +{
15248 + asm volatile(LOCK_PREFIX "orl %1,%0"
15249 + : "+m" (v->counter)
15250 + : "r" (mask)
15251 + : "memory");
15252 +}
15253 +
15254 +static inline void atomic_set_mask_unchecked(unsigned int mask, atomic_unchecked_t *v)
15255 +{
15256 + asm volatile(LOCK_PREFIX "orl %1,%0"
15257 + : "+m" (v->counter)
15258 + : "r" (mask)
15259 + : "memory");
15260 +}
15261
15262 /* Atomic operations are already serializing on x86 */
15263 #define smp_mb__before_atomic_dec() barrier()
15264 diff --git a/arch/x86/include/asm/atomic64_32.h b/arch/x86/include/asm/atomic64_32.h
15265 index b154de7..bf18a5a 100644
15266 --- a/arch/x86/include/asm/atomic64_32.h
15267 +++ b/arch/x86/include/asm/atomic64_32.h
15268 @@ -12,6 +12,14 @@ typedef struct {
15269 u64 __aligned(8) counter;
15270 } atomic64_t;
15271
15272 +#ifdef CONFIG_PAX_REFCOUNT
15273 +typedef struct {
15274 + u64 __aligned(8) counter;
15275 +} atomic64_unchecked_t;
15276 +#else
15277 +typedef atomic64_t atomic64_unchecked_t;
15278 +#endif
15279 +
15280 #define ATOMIC64_INIT(val) { (val) }
15281
15282 #define __ATOMIC64_DECL(sym) void atomic64_##sym(atomic64_t *, ...)
15283 @@ -37,21 +45,31 @@ typedef struct {
15284 ATOMIC64_DECL_ONE(sym##_386)
15285
15286 ATOMIC64_DECL_ONE(add_386);
15287 +ATOMIC64_DECL_ONE(add_unchecked_386);
15288 ATOMIC64_DECL_ONE(sub_386);
15289 +ATOMIC64_DECL_ONE(sub_unchecked_386);
15290 ATOMIC64_DECL_ONE(inc_386);
15291 +ATOMIC64_DECL_ONE(inc_unchecked_386);
15292 ATOMIC64_DECL_ONE(dec_386);
15293 +ATOMIC64_DECL_ONE(dec_unchecked_386);
15294 #endif
15295
15296 #define alternative_atomic64(f, out, in...) \
15297 __alternative_atomic64(f, f, ASM_OUTPUT2(out), ## in)
15298
15299 ATOMIC64_DECL(read);
15300 +ATOMIC64_DECL(read_unchecked);
15301 ATOMIC64_DECL(set);
15302 +ATOMIC64_DECL(set_unchecked);
15303 ATOMIC64_DECL(xchg);
15304 ATOMIC64_DECL(add_return);
15305 +ATOMIC64_DECL(add_return_unchecked);
15306 ATOMIC64_DECL(sub_return);
15307 +ATOMIC64_DECL(sub_return_unchecked);
15308 ATOMIC64_DECL(inc_return);
15309 +ATOMIC64_DECL(inc_return_unchecked);
15310 ATOMIC64_DECL(dec_return);
15311 +ATOMIC64_DECL(dec_return_unchecked);
15312 ATOMIC64_DECL(dec_if_positive);
15313 ATOMIC64_DECL(inc_not_zero);
15314 ATOMIC64_DECL(add_unless);
15315 @@ -77,6 +95,21 @@ static inline long long atomic64_cmpxchg(atomic64_t *v, long long o, long long n
15316 }
15317
15318 /**
15319 + * atomic64_cmpxchg_unchecked - cmpxchg atomic64 variable
15320 + * @p: pointer to type atomic64_unchecked_t
15321 + * @o: expected value
15322 + * @n: new value
15323 + *
15324 + * Atomically sets @v to @n if it was equal to @o and returns
15325 + * the old value.
15326 + */
15327 +
15328 +static inline long long atomic64_cmpxchg_unchecked(atomic64_unchecked_t *v, long long o, long long n)
15329 +{
15330 + return cmpxchg64(&v->counter, o, n);
15331 +}
15332 +
15333 +/**
15334 * atomic64_xchg - xchg atomic64 variable
15335 * @v: pointer to type atomic64_t
15336 * @n: value to assign
15337 @@ -112,6 +145,22 @@ static inline void atomic64_set(atomic64_t *v, long long i)
15338 }
15339
15340 /**
15341 + * atomic64_set_unchecked - set atomic64 variable
15342 + * @v: pointer to type atomic64_unchecked_t
15343 + * @n: value to assign
15344 + *
15345 + * Atomically sets the value of @v to @n.
15346 + */
15347 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long long i)
15348 +{
15349 + unsigned high = (unsigned)(i >> 32);
15350 + unsigned low = (unsigned)i;
15351 + alternative_atomic64(set, /* no output */,
15352 + "S" (v), "b" (low), "c" (high)
15353 + : "eax", "edx", "memory");
15354 +}
15355 +
15356 +/**
15357 * atomic64_read - read atomic64 variable
15358 * @v: pointer to type atomic64_t
15359 *
15360 @@ -125,6 +174,19 @@ static inline long long atomic64_read(const atomic64_t *v)
15361 }
15362
15363 /**
15364 + * atomic64_read_unchecked - read atomic64 variable
15365 + * @v: pointer to type atomic64_unchecked_t
15366 + *
15367 + * Atomically reads the value of @v and returns it.
15368 + */
15369 +static inline long long __intentional_overflow(-1) atomic64_read_unchecked(atomic64_unchecked_t *v)
15370 +{
15371 + long long r;
15372 + alternative_atomic64(read, "=&A" (r), "c" (v) : "memory");
15373 + return r;
15374 + }
15375 +
15376 +/**
15377 * atomic64_add_return - add and return
15378 * @i: integer value to add
15379 * @v: pointer to type atomic64_t
15380 @@ -139,6 +201,21 @@ static inline long long atomic64_add_return(long long i, atomic64_t *v)
15381 return i;
15382 }
15383
15384 +/**
15385 + * atomic64_add_return_unchecked - add and return
15386 + * @i: integer value to add
15387 + * @v: pointer to type atomic64_unchecked_t
15388 + *
15389 + * Atomically adds @i to @v and returns @i + *@v
15390 + */
15391 +static inline long long atomic64_add_return_unchecked(long long i, atomic64_unchecked_t *v)
15392 +{
15393 + alternative_atomic64(add_return_unchecked,
15394 + ASM_OUTPUT2("+A" (i), "+c" (v)),
15395 + ASM_NO_INPUT_CLOBBER("memory"));
15396 + return i;
15397 +}
15398 +
15399 /*
15400 * Other variants with different arithmetic operators:
15401 */
15402 @@ -158,6 +235,14 @@ static inline long long atomic64_inc_return(atomic64_t *v)
15403 return a;
15404 }
15405
15406 +static inline long long atomic64_inc_return_unchecked(atomic64_unchecked_t *v)
15407 +{
15408 + long long a;
15409 + alternative_atomic64(inc_return_unchecked, "=&A" (a),
15410 + "S" (v) : "memory", "ecx");
15411 + return a;
15412 +}
15413 +
15414 static inline long long atomic64_dec_return(atomic64_t *v)
15415 {
15416 long long a;
15417 @@ -182,6 +267,21 @@ static inline long long atomic64_add(long long i, atomic64_t *v)
15418 }
15419
15420 /**
15421 + * atomic64_add_unchecked - add integer to atomic64 variable
15422 + * @i: integer value to add
15423 + * @v: pointer to type atomic64_unchecked_t
15424 + *
15425 + * Atomically adds @i to @v.
15426 + */
15427 +static inline long long atomic64_add_unchecked(long long i, atomic64_unchecked_t *v)
15428 +{
15429 + __alternative_atomic64(add_unchecked, add_return_unchecked,
15430 + ASM_OUTPUT2("+A" (i), "+c" (v)),
15431 + ASM_NO_INPUT_CLOBBER("memory"));
15432 + return i;
15433 +}
15434 +
15435 +/**
15436 * atomic64_sub - subtract the atomic64 variable
15437 * @i: integer value to subtract
15438 * @v: pointer to type atomic64_t
15439 diff --git a/arch/x86/include/asm/atomic64_64.h b/arch/x86/include/asm/atomic64_64.h
15440 index 46e9052..ae45136 100644
15441 --- a/arch/x86/include/asm/atomic64_64.h
15442 +++ b/arch/x86/include/asm/atomic64_64.h
15443 @@ -18,7 +18,19 @@
15444 */
15445 static inline long atomic64_read(const atomic64_t *v)
15446 {
15447 - return (*(volatile long *)&(v)->counter);
15448 + return (*(volatile const long *)&(v)->counter);
15449 +}
15450 +
15451 +/**
15452 + * atomic64_read_unchecked - read atomic64 variable
15453 + * @v: pointer of type atomic64_unchecked_t
15454 + *
15455 + * Atomically reads the value of @v.
15456 + * Doesn't imply a read memory barrier.
15457 + */
15458 +static inline long __intentional_overflow(-1) atomic64_read_unchecked(const atomic64_unchecked_t *v)
15459 +{
15460 + return (*(volatile const long *)&(v)->counter);
15461 }
15462
15463 /**
15464 @@ -34,6 +46,18 @@ static inline void atomic64_set(atomic64_t *v, long i)
15465 }
15466
15467 /**
15468 + * atomic64_set_unchecked - set atomic64 variable
15469 + * @v: pointer to type atomic64_unchecked_t
15470 + * @i: required value
15471 + *
15472 + * Atomically sets the value of @v to @i.
15473 + */
15474 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long i)
15475 +{
15476 + v->counter = i;
15477 +}
15478 +
15479 +/**
15480 * atomic64_add - add integer to atomic64 variable
15481 * @i: integer value to add
15482 * @v: pointer to type atomic64_t
15483 @@ -42,6 +66,28 @@ static inline void atomic64_set(atomic64_t *v, long i)
15484 */
15485 static inline void atomic64_add(long i, atomic64_t *v)
15486 {
15487 + asm volatile(LOCK_PREFIX "addq %1,%0\n"
15488 +
15489 +#ifdef CONFIG_PAX_REFCOUNT
15490 + "jno 0f\n"
15491 + LOCK_PREFIX "subq %1,%0\n"
15492 + "int $4\n0:\n"
15493 + _ASM_EXTABLE(0b, 0b)
15494 +#endif
15495 +
15496 + : "=m" (v->counter)
15497 + : "er" (i), "m" (v->counter));
15498 +}
15499 +
15500 +/**
15501 + * atomic64_add_unchecked - add integer to atomic64 variable
15502 + * @i: integer value to add
15503 + * @v: pointer to type atomic64_unchecked_t
15504 + *
15505 + * Atomically adds @i to @v.
15506 + */
15507 +static inline void atomic64_add_unchecked(long i, atomic64_unchecked_t *v)
15508 +{
15509 asm volatile(LOCK_PREFIX "addq %1,%0"
15510 : "=m" (v->counter)
15511 : "er" (i), "m" (v->counter));
15512 @@ -56,7 +102,29 @@ static inline void atomic64_add(long i, atomic64_t *v)
15513 */
15514 static inline void atomic64_sub(long i, atomic64_t *v)
15515 {
15516 - asm volatile(LOCK_PREFIX "subq %1,%0"
15517 + asm volatile(LOCK_PREFIX "subq %1,%0\n"
15518 +
15519 +#ifdef CONFIG_PAX_REFCOUNT
15520 + "jno 0f\n"
15521 + LOCK_PREFIX "addq %1,%0\n"
15522 + "int $4\n0:\n"
15523 + _ASM_EXTABLE(0b, 0b)
15524 +#endif
15525 +
15526 + : "=m" (v->counter)
15527 + : "er" (i), "m" (v->counter));
15528 +}
15529 +
15530 +/**
15531 + * atomic64_sub_unchecked - subtract the atomic64 variable
15532 + * @i: integer value to subtract
15533 + * @v: pointer to type atomic64_unchecked_t
15534 + *
15535 + * Atomically subtracts @i from @v.
15536 + */
15537 +static inline void atomic64_sub_unchecked(long i, atomic64_unchecked_t *v)
15538 +{
15539 + asm volatile(LOCK_PREFIX "subq %1,%0\n"
15540 : "=m" (v->counter)
15541 : "er" (i), "m" (v->counter));
15542 }
15543 @@ -72,7 +140,7 @@ static inline void atomic64_sub(long i, atomic64_t *v)
15544 */
15545 static inline int atomic64_sub_and_test(long i, atomic64_t *v)
15546 {
15547 - GEN_BINARY_RMWcc(LOCK_PREFIX "subq", v->counter, "er", i, "%0", "e");
15548 + GEN_BINARY_RMWcc(LOCK_PREFIX "subq", LOCK_PREFIX "addq", v->counter, "er", i, "%0", "e");
15549 }
15550
15551 /**
15552 @@ -83,6 +151,27 @@ static inline int atomic64_sub_and_test(long i, atomic64_t *v)
15553 */
15554 static inline void atomic64_inc(atomic64_t *v)
15555 {
15556 + asm volatile(LOCK_PREFIX "incq %0\n"
15557 +
15558 +#ifdef CONFIG_PAX_REFCOUNT
15559 + "jno 0f\n"
15560 + LOCK_PREFIX "decq %0\n"
15561 + "int $4\n0:\n"
15562 + _ASM_EXTABLE(0b, 0b)
15563 +#endif
15564 +
15565 + : "=m" (v->counter)
15566 + : "m" (v->counter));
15567 +}
15568 +
15569 +/**
15570 + * atomic64_inc_unchecked - increment atomic64 variable
15571 + * @v: pointer to type atomic64_unchecked_t
15572 + *
15573 + * Atomically increments @v by 1.
15574 + */
15575 +static inline void atomic64_inc_unchecked(atomic64_unchecked_t *v)
15576 +{
15577 asm volatile(LOCK_PREFIX "incq %0"
15578 : "=m" (v->counter)
15579 : "m" (v->counter));
15580 @@ -96,7 +185,28 @@ static inline void atomic64_inc(atomic64_t *v)
15581 */
15582 static inline void atomic64_dec(atomic64_t *v)
15583 {
15584 - asm volatile(LOCK_PREFIX "decq %0"
15585 + asm volatile(LOCK_PREFIX "decq %0\n"
15586 +
15587 +#ifdef CONFIG_PAX_REFCOUNT
15588 + "jno 0f\n"
15589 + LOCK_PREFIX "incq %0\n"
15590 + "int $4\n0:\n"
15591 + _ASM_EXTABLE(0b, 0b)
15592 +#endif
15593 +
15594 + : "=m" (v->counter)
15595 + : "m" (v->counter));
15596 +}
15597 +
15598 +/**
15599 + * atomic64_dec_unchecked - decrement atomic64 variable
15600 + * @v: pointer to type atomic64_t
15601 + *
15602 + * Atomically decrements @v by 1.
15603 + */
15604 +static inline void atomic64_dec_unchecked(atomic64_unchecked_t *v)
15605 +{
15606 + asm volatile(LOCK_PREFIX "decq %0\n"
15607 : "=m" (v->counter)
15608 : "m" (v->counter));
15609 }
15610 @@ -111,7 +221,7 @@ static inline void atomic64_dec(atomic64_t *v)
15611 */
15612 static inline int atomic64_dec_and_test(atomic64_t *v)
15613 {
15614 - GEN_UNARY_RMWcc(LOCK_PREFIX "decq", v->counter, "%0", "e");
15615 + GEN_UNARY_RMWcc(LOCK_PREFIX "decq", LOCK_PREFIX "incq", v->counter, "%0", "e");
15616 }
15617
15618 /**
15619 @@ -124,7 +234,7 @@ static inline int atomic64_dec_and_test(atomic64_t *v)
15620 */
15621 static inline int atomic64_inc_and_test(atomic64_t *v)
15622 {
15623 - GEN_UNARY_RMWcc(LOCK_PREFIX "incq", v->counter, "%0", "e");
15624 + GEN_UNARY_RMWcc(LOCK_PREFIX "incq", LOCK_PREFIX "decq", v->counter, "%0", "e");
15625 }
15626
15627 /**
15628 @@ -138,7 +248,7 @@ static inline int atomic64_inc_and_test(atomic64_t *v)
15629 */
15630 static inline int atomic64_add_negative(long i, atomic64_t *v)
15631 {
15632 - GEN_BINARY_RMWcc(LOCK_PREFIX "addq", v->counter, "er", i, "%0", "s");
15633 + GEN_BINARY_RMWcc(LOCK_PREFIX "addq", LOCK_PREFIX "subq", v->counter, "er", i, "%0", "s");
15634 }
15635
15636 /**
15637 @@ -150,6 +260,18 @@ static inline int atomic64_add_negative(long i, atomic64_t *v)
15638 */
15639 static inline long atomic64_add_return(long i, atomic64_t *v)
15640 {
15641 + return i + xadd_check_overflow(&v->counter, i);
15642 +}
15643 +
15644 +/**
15645 + * atomic64_add_return_unchecked - add and return
15646 + * @i: integer value to add
15647 + * @v: pointer to type atomic64_unchecked_t
15648 + *
15649 + * Atomically adds @i to @v and returns @i + @v
15650 + */
15651 +static inline long atomic64_add_return_unchecked(long i, atomic64_unchecked_t *v)
15652 +{
15653 return i + xadd(&v->counter, i);
15654 }
15655
15656 @@ -159,6 +281,10 @@ static inline long atomic64_sub_return(long i, atomic64_t *v)
15657 }
15658
15659 #define atomic64_inc_return(v) (atomic64_add_return(1, (v)))
15660 +static inline long atomic64_inc_return_unchecked(atomic64_unchecked_t *v)
15661 +{
15662 + return atomic64_add_return_unchecked(1, v);
15663 +}
15664 #define atomic64_dec_return(v) (atomic64_sub_return(1, (v)))
15665
15666 static inline long atomic64_cmpxchg(atomic64_t *v, long old, long new)
15667 @@ -166,6 +292,11 @@ static inline long atomic64_cmpxchg(atomic64_t *v, long old, long new)
15668 return cmpxchg(&v->counter, old, new);
15669 }
15670
15671 +static inline long atomic64_cmpxchg_unchecked(atomic64_unchecked_t *v, long old, long new)
15672 +{
15673 + return cmpxchg(&v->counter, old, new);
15674 +}
15675 +
15676 static inline long atomic64_xchg(atomic64_t *v, long new)
15677 {
15678 return xchg(&v->counter, new);
15679 @@ -182,17 +313,30 @@ static inline long atomic64_xchg(atomic64_t *v, long new)
15680 */
15681 static inline int atomic64_add_unless(atomic64_t *v, long a, long u)
15682 {
15683 - long c, old;
15684 + long c, old, new;
15685 c = atomic64_read(v);
15686 for (;;) {
15687 - if (unlikely(c == (u)))
15688 + if (unlikely(c == u))
15689 break;
15690 - old = atomic64_cmpxchg((v), c, c + (a));
15691 +
15692 + asm volatile("add %2,%0\n"
15693 +
15694 +#ifdef CONFIG_PAX_REFCOUNT
15695 + "jno 0f\n"
15696 + "sub %2,%0\n"
15697 + "int $4\n0:\n"
15698 + _ASM_EXTABLE(0b, 0b)
15699 +#endif
15700 +
15701 + : "=r" (new)
15702 + : "0" (c), "ir" (a));
15703 +
15704 + old = atomic64_cmpxchg(v, c, new);
15705 if (likely(old == c))
15706 break;
15707 c = old;
15708 }
15709 - return c != (u);
15710 + return c != u;
15711 }
15712
15713 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
15714 diff --git a/arch/x86/include/asm/barrier.h b/arch/x86/include/asm/barrier.h
15715 index 69bbb48..32517fe 100644
15716 --- a/arch/x86/include/asm/barrier.h
15717 +++ b/arch/x86/include/asm/barrier.h
15718 @@ -107,7 +107,7 @@
15719 do { \
15720 compiletime_assert_atomic_type(*p); \
15721 smp_mb(); \
15722 - ACCESS_ONCE(*p) = (v); \
15723 + ACCESS_ONCE_RW(*p) = (v); \
15724 } while (0)
15725
15726 #define smp_load_acquire(p) \
15727 @@ -124,7 +124,7 @@ do { \
15728 do { \
15729 compiletime_assert_atomic_type(*p); \
15730 barrier(); \
15731 - ACCESS_ONCE(*p) = (v); \
15732 + ACCESS_ONCE_RW(*p) = (v); \
15733 } while (0)
15734
15735 #define smp_load_acquire(p) \
15736 diff --git a/arch/x86/include/asm/bitops.h b/arch/x86/include/asm/bitops.h
15737 index 9fc1af7..fc71228 100644
15738 --- a/arch/x86/include/asm/bitops.h
15739 +++ b/arch/x86/include/asm/bitops.h
15740 @@ -49,7 +49,7 @@
15741 * a mask operation on a byte.
15742 */
15743 #define IS_IMMEDIATE(nr) (__builtin_constant_p(nr))
15744 -#define CONST_MASK_ADDR(nr, addr) BITOP_ADDR((void *)(addr) + ((nr)>>3))
15745 +#define CONST_MASK_ADDR(nr, addr) BITOP_ADDR((volatile void *)(addr) + ((nr)>>3))
15746 #define CONST_MASK(nr) (1 << ((nr) & 7))
15747
15748 /**
15749 @@ -205,7 +205,7 @@ static inline void change_bit(long nr, volatile unsigned long *addr)
15750 */
15751 static inline int test_and_set_bit(long nr, volatile unsigned long *addr)
15752 {
15753 - GEN_BINARY_RMWcc(LOCK_PREFIX "bts", *addr, "Ir", nr, "%0", "c");
15754 + GEN_BINARY_RMWcc_unchecked(LOCK_PREFIX "bts", *addr, "Ir", nr, "%0", "c");
15755 }
15756
15757 /**
15758 @@ -251,7 +251,7 @@ static inline int __test_and_set_bit(long nr, volatile unsigned long *addr)
15759 */
15760 static inline int test_and_clear_bit(long nr, volatile unsigned long *addr)
15761 {
15762 - GEN_BINARY_RMWcc(LOCK_PREFIX "btr", *addr, "Ir", nr, "%0", "c");
15763 + GEN_BINARY_RMWcc_unchecked(LOCK_PREFIX "btr", *addr, "Ir", nr, "%0", "c");
15764 }
15765
15766 /**
15767 @@ -304,7 +304,7 @@ static inline int __test_and_change_bit(long nr, volatile unsigned long *addr)
15768 */
15769 static inline int test_and_change_bit(long nr, volatile unsigned long *addr)
15770 {
15771 - GEN_BINARY_RMWcc(LOCK_PREFIX "btc", *addr, "Ir", nr, "%0", "c");
15772 + GEN_BINARY_RMWcc_unchecked(LOCK_PREFIX "btc", *addr, "Ir", nr, "%0", "c");
15773 }
15774
15775 static __always_inline int constant_test_bit(long nr, const volatile unsigned long *addr)
15776 @@ -345,7 +345,7 @@ static int test_bit(int nr, const volatile unsigned long *addr);
15777 *
15778 * Undefined if no bit exists, so code should check against 0 first.
15779 */
15780 -static inline unsigned long __ffs(unsigned long word)
15781 +static inline unsigned long __intentional_overflow(-1) __ffs(unsigned long word)
15782 {
15783 asm("rep; bsf %1,%0"
15784 : "=r" (word)
15785 @@ -359,7 +359,7 @@ static inline unsigned long __ffs(unsigned long word)
15786 *
15787 * Undefined if no zero exists, so code should check against ~0UL first.
15788 */
15789 -static inline unsigned long ffz(unsigned long word)
15790 +static inline unsigned long __intentional_overflow(-1) ffz(unsigned long word)
15791 {
15792 asm("rep; bsf %1,%0"
15793 : "=r" (word)
15794 @@ -373,7 +373,7 @@ static inline unsigned long ffz(unsigned long word)
15795 *
15796 * Undefined if no set bit exists, so code should check against 0 first.
15797 */
15798 -static inline unsigned long __fls(unsigned long word)
15799 +static inline unsigned long __intentional_overflow(-1) __fls(unsigned long word)
15800 {
15801 asm("bsr %1,%0"
15802 : "=r" (word)
15803 @@ -436,7 +436,7 @@ static inline int ffs(int x)
15804 * set bit if value is nonzero. The last (most significant) bit is
15805 * at position 32.
15806 */
15807 -static inline int fls(int x)
15808 +static inline int __intentional_overflow(-1) fls(int x)
15809 {
15810 int r;
15811
15812 @@ -478,7 +478,7 @@ static inline int fls(int x)
15813 * at position 64.
15814 */
15815 #ifdef CONFIG_X86_64
15816 -static __always_inline int fls64(__u64 x)
15817 +static __always_inline long fls64(__u64 x)
15818 {
15819 int bitpos = -1;
15820 /*
15821 diff --git a/arch/x86/include/asm/boot.h b/arch/x86/include/asm/boot.h
15822 index 4fa687a..60f2d39 100644
15823 --- a/arch/x86/include/asm/boot.h
15824 +++ b/arch/x86/include/asm/boot.h
15825 @@ -6,10 +6,15 @@
15826 #include <uapi/asm/boot.h>
15827
15828 /* Physical address where kernel should be loaded. */
15829 -#define LOAD_PHYSICAL_ADDR ((CONFIG_PHYSICAL_START \
15830 +#define ____LOAD_PHYSICAL_ADDR ((CONFIG_PHYSICAL_START \
15831 + (CONFIG_PHYSICAL_ALIGN - 1)) \
15832 & ~(CONFIG_PHYSICAL_ALIGN - 1))
15833
15834 +#ifndef __ASSEMBLY__
15835 +extern unsigned char __LOAD_PHYSICAL_ADDR[];
15836 +#define LOAD_PHYSICAL_ADDR ((unsigned long)__LOAD_PHYSICAL_ADDR)
15837 +#endif
15838 +
15839 /* Minimum kernel alignment, as a power of two */
15840 #ifdef CONFIG_X86_64
15841 #define MIN_KERNEL_ALIGN_LG2 PMD_SHIFT
15842 diff --git a/arch/x86/include/asm/cache.h b/arch/x86/include/asm/cache.h
15843 index 48f99f1..d78ebf9 100644
15844 --- a/arch/x86/include/asm/cache.h
15845 +++ b/arch/x86/include/asm/cache.h
15846 @@ -5,12 +5,13 @@
15847
15848 /* L1 cache line size */
15849 #define L1_CACHE_SHIFT (CONFIG_X86_L1_CACHE_SHIFT)
15850 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
15851 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
15852
15853 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
15854 +#define __read_only __attribute__((__section__(".data..read_only")))
15855
15856 #define INTERNODE_CACHE_SHIFT CONFIG_X86_INTERNODE_CACHE_SHIFT
15857 -#define INTERNODE_CACHE_BYTES (1 << INTERNODE_CACHE_SHIFT)
15858 +#define INTERNODE_CACHE_BYTES (_AC(1,UL) << INTERNODE_CACHE_SHIFT)
15859
15860 #ifdef CONFIG_X86_VSMP
15861 #ifdef CONFIG_SMP
15862 diff --git a/arch/x86/include/asm/cacheflush.h b/arch/x86/include/asm/cacheflush.h
15863 index 9863ee3..4a1f8e1 100644
15864 --- a/arch/x86/include/asm/cacheflush.h
15865 +++ b/arch/x86/include/asm/cacheflush.h
15866 @@ -27,7 +27,7 @@ static inline unsigned long get_page_memtype(struct page *pg)
15867 unsigned long pg_flags = pg->flags & _PGMT_MASK;
15868
15869 if (pg_flags == _PGMT_DEFAULT)
15870 - return -1;
15871 + return ~0UL;
15872 else if (pg_flags == _PGMT_WC)
15873 return _PAGE_CACHE_WC;
15874 else if (pg_flags == _PGMT_UC_MINUS)
15875 diff --git a/arch/x86/include/asm/calling.h b/arch/x86/include/asm/calling.h
15876 index cb4c73b..c473c29 100644
15877 --- a/arch/x86/include/asm/calling.h
15878 +++ b/arch/x86/include/asm/calling.h
15879 @@ -82,103 +82,113 @@ For 32-bit we have the following conventions - kernel is built with
15880 #define RSP 152
15881 #define SS 160
15882
15883 -#define ARGOFFSET R11
15884 -#define SWFRAME ORIG_RAX
15885 +#define ARGOFFSET R15
15886
15887 .macro SAVE_ARGS addskip=0, save_rcx=1, save_r891011=1
15888 - subq $9*8+\addskip, %rsp
15889 - CFI_ADJUST_CFA_OFFSET 9*8+\addskip
15890 - movq_cfi rdi, 8*8
15891 - movq_cfi rsi, 7*8
15892 - movq_cfi rdx, 6*8
15893 + subq $ORIG_RAX-ARGOFFSET+\addskip, %rsp
15894 + CFI_ADJUST_CFA_OFFSET ORIG_RAX-ARGOFFSET+\addskip
15895 + movq_cfi rdi, RDI
15896 + movq_cfi rsi, RSI
15897 + movq_cfi rdx, RDX
15898
15899 .if \save_rcx
15900 - movq_cfi rcx, 5*8
15901 + movq_cfi rcx, RCX
15902 .endif
15903
15904 - movq_cfi rax, 4*8
15905 + movq_cfi rax, RAX
15906
15907 .if \save_r891011
15908 - movq_cfi r8, 3*8
15909 - movq_cfi r9, 2*8
15910 - movq_cfi r10, 1*8
15911 - movq_cfi r11, 0*8
15912 + movq_cfi r8, R8
15913 + movq_cfi r9, R9
15914 + movq_cfi r10, R10
15915 + movq_cfi r11, R11
15916 .endif
15917
15918 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR
15919 + movq_cfi r12, R12
15920 +#endif
15921 +
15922 .endm
15923
15924 -#define ARG_SKIP (9*8)
15925 +#define ARG_SKIP ORIG_RAX
15926
15927 .macro RESTORE_ARGS rstor_rax=1, addskip=0, rstor_rcx=1, rstor_r11=1, \
15928 rstor_r8910=1, rstor_rdx=1
15929 +
15930 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR
15931 + movq_cfi_restore R12, r12
15932 +#endif
15933 +
15934 .if \rstor_r11
15935 - movq_cfi_restore 0*8, r11
15936 + movq_cfi_restore R11, r11
15937 .endif
15938
15939 .if \rstor_r8910
15940 - movq_cfi_restore 1*8, r10
15941 - movq_cfi_restore 2*8, r9
15942 - movq_cfi_restore 3*8, r8
15943 + movq_cfi_restore R10, r10
15944 + movq_cfi_restore R9, r9
15945 + movq_cfi_restore R8, r8
15946 .endif
15947
15948 .if \rstor_rax
15949 - movq_cfi_restore 4*8, rax
15950 + movq_cfi_restore RAX, rax
15951 .endif
15952
15953 .if \rstor_rcx
15954 - movq_cfi_restore 5*8, rcx
15955 + movq_cfi_restore RCX, rcx
15956 .endif
15957
15958 .if \rstor_rdx
15959 - movq_cfi_restore 6*8, rdx
15960 + movq_cfi_restore RDX, rdx
15961 .endif
15962
15963 - movq_cfi_restore 7*8, rsi
15964 - movq_cfi_restore 8*8, rdi
15965 + movq_cfi_restore RSI, rsi
15966 + movq_cfi_restore RDI, rdi
15967
15968 - .if ARG_SKIP+\addskip > 0
15969 - addq $ARG_SKIP+\addskip, %rsp
15970 - CFI_ADJUST_CFA_OFFSET -(ARG_SKIP+\addskip)
15971 + .if ORIG_RAX+\addskip > 0
15972 + addq $ORIG_RAX+\addskip, %rsp
15973 + CFI_ADJUST_CFA_OFFSET -(ORIG_RAX+\addskip)
15974 .endif
15975 .endm
15976
15977 - .macro LOAD_ARGS offset, skiprax=0
15978 - movq \offset(%rsp), %r11
15979 - movq \offset+8(%rsp), %r10
15980 - movq \offset+16(%rsp), %r9
15981 - movq \offset+24(%rsp), %r8
15982 - movq \offset+40(%rsp), %rcx
15983 - movq \offset+48(%rsp), %rdx
15984 - movq \offset+56(%rsp), %rsi
15985 - movq \offset+64(%rsp), %rdi
15986 + .macro LOAD_ARGS skiprax=0
15987 + movq R11(%rsp), %r11
15988 + movq R10(%rsp), %r10
15989 + movq R9(%rsp), %r9
15990 + movq R8(%rsp), %r8
15991 + movq RCX(%rsp), %rcx
15992 + movq RDX(%rsp), %rdx
15993 + movq RSI(%rsp), %rsi
15994 + movq RDI(%rsp), %rdi
15995 .if \skiprax
15996 .else
15997 - movq \offset+72(%rsp), %rax
15998 + movq RAX(%rsp), %rax
15999 .endif
16000 .endm
16001
16002 -#define REST_SKIP (6*8)
16003 -
16004 .macro SAVE_REST
16005 - subq $REST_SKIP, %rsp
16006 - CFI_ADJUST_CFA_OFFSET REST_SKIP
16007 - movq_cfi rbx, 5*8
16008 - movq_cfi rbp, 4*8
16009 - movq_cfi r12, 3*8
16010 - movq_cfi r13, 2*8
16011 - movq_cfi r14, 1*8
16012 - movq_cfi r15, 0*8
16013 + movq_cfi rbx, RBX
16014 + movq_cfi rbp, RBP
16015 +
16016 +#ifndef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR
16017 + movq_cfi r12, R12
16018 +#endif
16019 +
16020 + movq_cfi r13, R13
16021 + movq_cfi r14, R14
16022 + movq_cfi r15, R15
16023 .endm
16024
16025 .macro RESTORE_REST
16026 - movq_cfi_restore 0*8, r15
16027 - movq_cfi_restore 1*8, r14
16028 - movq_cfi_restore 2*8, r13
16029 - movq_cfi_restore 3*8, r12
16030 - movq_cfi_restore 4*8, rbp
16031 - movq_cfi_restore 5*8, rbx
16032 - addq $REST_SKIP, %rsp
16033 - CFI_ADJUST_CFA_OFFSET -(REST_SKIP)
16034 + movq_cfi_restore R15, r15
16035 + movq_cfi_restore R14, r14
16036 + movq_cfi_restore R13, r13
16037 +
16038 +#ifndef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR
16039 + movq_cfi_restore R12, r12
16040 +#endif
16041 +
16042 + movq_cfi_restore RBP, rbp
16043 + movq_cfi_restore RBX, rbx
16044 .endm
16045
16046 .macro SAVE_ALL
16047 diff --git a/arch/x86/include/asm/checksum_32.h b/arch/x86/include/asm/checksum_32.h
16048 index f50de69..2b0a458 100644
16049 --- a/arch/x86/include/asm/checksum_32.h
16050 +++ b/arch/x86/include/asm/checksum_32.h
16051 @@ -31,6 +31,14 @@ asmlinkage __wsum csum_partial_copy_generic(const void *src, void *dst,
16052 int len, __wsum sum,
16053 int *src_err_ptr, int *dst_err_ptr);
16054
16055 +asmlinkage __wsum csum_partial_copy_generic_to_user(const void *src, void *dst,
16056 + int len, __wsum sum,
16057 + int *src_err_ptr, int *dst_err_ptr);
16058 +
16059 +asmlinkage __wsum csum_partial_copy_generic_from_user(const void *src, void *dst,
16060 + int len, __wsum sum,
16061 + int *src_err_ptr, int *dst_err_ptr);
16062 +
16063 /*
16064 * Note: when you get a NULL pointer exception here this means someone
16065 * passed in an incorrect kernel address to one of these functions.
16066 @@ -53,7 +61,7 @@ static inline __wsum csum_partial_copy_from_user(const void __user *src,
16067
16068 might_sleep();
16069 stac();
16070 - ret = csum_partial_copy_generic((__force void *)src, dst,
16071 + ret = csum_partial_copy_generic_from_user((__force void *)src, dst,
16072 len, sum, err_ptr, NULL);
16073 clac();
16074
16075 @@ -187,7 +195,7 @@ static inline __wsum csum_and_copy_to_user(const void *src,
16076 might_sleep();
16077 if (access_ok(VERIFY_WRITE, dst, len)) {
16078 stac();
16079 - ret = csum_partial_copy_generic(src, (__force void *)dst,
16080 + ret = csum_partial_copy_generic_to_user(src, (__force void *)dst,
16081 len, sum, NULL, err_ptr);
16082 clac();
16083 return ret;
16084 diff --git a/arch/x86/include/asm/cmpxchg.h b/arch/x86/include/asm/cmpxchg.h
16085 index d47786a..2d8883e 100644
16086 --- a/arch/x86/include/asm/cmpxchg.h
16087 +++ b/arch/x86/include/asm/cmpxchg.h
16088 @@ -14,8 +14,12 @@ extern void __cmpxchg_wrong_size(void)
16089 __compiletime_error("Bad argument size for cmpxchg");
16090 extern void __xadd_wrong_size(void)
16091 __compiletime_error("Bad argument size for xadd");
16092 +extern void __xadd_check_overflow_wrong_size(void)
16093 + __compiletime_error("Bad argument size for xadd_check_overflow");
16094 extern void __add_wrong_size(void)
16095 __compiletime_error("Bad argument size for add");
16096 +extern void __add_check_overflow_wrong_size(void)
16097 + __compiletime_error("Bad argument size for add_check_overflow");
16098
16099 /*
16100 * Constants for operation sizes. On 32-bit, the 64-bit size it set to
16101 @@ -67,6 +71,38 @@ extern void __add_wrong_size(void)
16102 __ret; \
16103 })
16104
16105 +#ifdef CONFIG_PAX_REFCOUNT
16106 +#define __xchg_op_check_overflow(ptr, arg, op, lock) \
16107 + ({ \
16108 + __typeof__ (*(ptr)) __ret = (arg); \
16109 + switch (sizeof(*(ptr))) { \
16110 + case __X86_CASE_L: \
16111 + asm volatile (lock #op "l %0, %1\n" \
16112 + "jno 0f\n" \
16113 + "mov %0,%1\n" \
16114 + "int $4\n0:\n" \
16115 + _ASM_EXTABLE(0b, 0b) \
16116 + : "+r" (__ret), "+m" (*(ptr)) \
16117 + : : "memory", "cc"); \
16118 + break; \
16119 + case __X86_CASE_Q: \
16120 + asm volatile (lock #op "q %q0, %1\n" \
16121 + "jno 0f\n" \
16122 + "mov %0,%1\n" \
16123 + "int $4\n0:\n" \
16124 + _ASM_EXTABLE(0b, 0b) \
16125 + : "+r" (__ret), "+m" (*(ptr)) \
16126 + : : "memory", "cc"); \
16127 + break; \
16128 + default: \
16129 + __ ## op ## _check_overflow_wrong_size(); \
16130 + } \
16131 + __ret; \
16132 + })
16133 +#else
16134 +#define __xchg_op_check_overflow(ptr, arg, op, lock) __xchg_op(ptr, arg, op, lock)
16135 +#endif
16136 +
16137 /*
16138 * Note: no "lock" prefix even on SMP: xchg always implies lock anyway.
16139 * Since this is generally used to protect other memory information, we
16140 @@ -167,6 +203,9 @@ extern void __add_wrong_size(void)
16141 #define xadd_sync(ptr, inc) __xadd((ptr), (inc), "lock; ")
16142 #define xadd_local(ptr, inc) __xadd((ptr), (inc), "")
16143
16144 +#define __xadd_check_overflow(ptr, inc, lock) __xchg_op_check_overflow((ptr), (inc), xadd, lock)
16145 +#define xadd_check_overflow(ptr, inc) __xadd_check_overflow((ptr), (inc), LOCK_PREFIX)
16146 +
16147 #define __add(ptr, inc, lock) \
16148 ({ \
16149 __typeof__ (*(ptr)) __ret = (inc); \
16150 diff --git a/arch/x86/include/asm/compat.h b/arch/x86/include/asm/compat.h
16151 index 59c6c40..5e0b22c 100644
16152 --- a/arch/x86/include/asm/compat.h
16153 +++ b/arch/x86/include/asm/compat.h
16154 @@ -41,7 +41,7 @@ typedef s64 __attribute__((aligned(4))) compat_s64;
16155 typedef u32 compat_uint_t;
16156 typedef u32 compat_ulong_t;
16157 typedef u64 __attribute__((aligned(4))) compat_u64;
16158 -typedef u32 compat_uptr_t;
16159 +typedef u32 __user compat_uptr_t;
16160
16161 struct compat_timespec {
16162 compat_time_t tv_sec;
16163 diff --git a/arch/x86/include/asm/cpufeature.h b/arch/x86/include/asm/cpufeature.h
16164 index e265ff9..72c253b 100644
16165 --- a/arch/x86/include/asm/cpufeature.h
16166 +++ b/arch/x86/include/asm/cpufeature.h
16167 @@ -203,7 +203,7 @@
16168 #define X86_FEATURE_DECODEASSISTS (8*32+12) /* AMD Decode Assists support */
16169 #define X86_FEATURE_PAUSEFILTER (8*32+13) /* AMD filtered pause intercept */
16170 #define X86_FEATURE_PFTHRESHOLD (8*32+14) /* AMD pause filter threshold */
16171 -
16172 +#define X86_FEATURE_STRONGUDEREF (8*32+31) /* PaX PCID based strong UDEREF */
16173
16174 /* Intel-defined CPU features, CPUID level 0x00000007:0 (ebx), word 9 */
16175 #define X86_FEATURE_FSGSBASE (9*32+ 0) /* {RD/WR}{FS/GS}BASE instructions*/
16176 @@ -211,7 +211,7 @@
16177 #define X86_FEATURE_BMI1 (9*32+ 3) /* 1st group bit manipulation extensions */
16178 #define X86_FEATURE_HLE (9*32+ 4) /* Hardware Lock Elision */
16179 #define X86_FEATURE_AVX2 (9*32+ 5) /* AVX2 instructions */
16180 -#define X86_FEATURE_SMEP (9*32+ 7) /* Supervisor Mode Execution Protection */
16181 +#define X86_FEATURE_SMEP (9*32+ 7) /* Supervisor Mode Execution Prevention */
16182 #define X86_FEATURE_BMI2 (9*32+ 8) /* 2nd group bit manipulation extensions */
16183 #define X86_FEATURE_ERMS (9*32+ 9) /* Enhanced REP MOVSB/STOSB */
16184 #define X86_FEATURE_INVPCID (9*32+10) /* Invalidate Processor Context ID */
16185 @@ -359,6 +359,7 @@ extern const char * const x86_power_flags[32];
16186 #undef cpu_has_centaur_mcr
16187 #define cpu_has_centaur_mcr 0
16188
16189 +#define cpu_has_pcid boot_cpu_has(X86_FEATURE_PCID)
16190 #endif /* CONFIG_X86_64 */
16191
16192 #if __GNUC__ >= 4
16193 @@ -411,7 +412,8 @@ static __always_inline __pure bool __static_cpu_has(u16 bit)
16194
16195 #ifdef CONFIG_X86_DEBUG_STATIC_CPU_HAS
16196 t_warn:
16197 - warn_pre_alternatives();
16198 + if (bit != X86_FEATURE_PCID && bit != X86_FEATURE_INVPCID)
16199 + warn_pre_alternatives();
16200 return false;
16201 #endif
16202
16203 @@ -431,7 +433,7 @@ static __always_inline __pure bool __static_cpu_has(u16 bit)
16204 ".section .discard,\"aw\",@progbits\n"
16205 " .byte 0xff + (4f-3f) - (2b-1b)\n" /* size check */
16206 ".previous\n"
16207 - ".section .altinstr_replacement,\"ax\"\n"
16208 + ".section .altinstr_replacement,\"a\"\n"
16209 "3: movb $1,%0\n"
16210 "4:\n"
16211 ".previous\n"
16212 @@ -468,7 +470,7 @@ static __always_inline __pure bool _static_cpu_has_safe(u16 bit)
16213 " .byte 2b - 1b\n" /* src len */
16214 " .byte 4f - 3f\n" /* repl len */
16215 ".previous\n"
16216 - ".section .altinstr_replacement,\"ax\"\n"
16217 + ".section .altinstr_replacement,\"a\"\n"
16218 "3: .byte 0xe9\n .long %l[t_no] - 2b\n"
16219 "4:\n"
16220 ".previous\n"
16221 @@ -501,7 +503,7 @@ static __always_inline __pure bool _static_cpu_has_safe(u16 bit)
16222 ".section .discard,\"aw\",@progbits\n"
16223 " .byte 0xff + (4f-3f) - (2b-1b)\n" /* size check */
16224 ".previous\n"
16225 - ".section .altinstr_replacement,\"ax\"\n"
16226 + ".section .altinstr_replacement,\"a\"\n"
16227 "3: movb $0,%0\n"
16228 "4:\n"
16229 ".previous\n"
16230 @@ -515,7 +517,7 @@ static __always_inline __pure bool _static_cpu_has_safe(u16 bit)
16231 ".section .discard,\"aw\",@progbits\n"
16232 " .byte 0xff + (6f-5f) - (4b-3b)\n" /* size check */
16233 ".previous\n"
16234 - ".section .altinstr_replacement,\"ax\"\n"
16235 + ".section .altinstr_replacement,\"a\"\n"
16236 "5: movb $1,%0\n"
16237 "6:\n"
16238 ".previous\n"
16239 diff --git a/arch/x86/include/asm/desc.h b/arch/x86/include/asm/desc.h
16240 index 50d033a..37deb26 100644
16241 --- a/arch/x86/include/asm/desc.h
16242 +++ b/arch/x86/include/asm/desc.h
16243 @@ -4,6 +4,7 @@
16244 #include <asm/desc_defs.h>
16245 #include <asm/ldt.h>
16246 #include <asm/mmu.h>
16247 +#include <asm/pgtable.h>
16248
16249 #include <linux/smp.h>
16250 #include <linux/percpu.h>
16251 @@ -17,6 +18,7 @@ static inline void fill_ldt(struct desc_struct *desc, const struct user_desc *in
16252
16253 desc->type = (info->read_exec_only ^ 1) << 1;
16254 desc->type |= info->contents << 2;
16255 + desc->type |= info->seg_not_present ^ 1;
16256
16257 desc->s = 1;
16258 desc->dpl = 0x3;
16259 @@ -35,19 +37,14 @@ static inline void fill_ldt(struct desc_struct *desc, const struct user_desc *in
16260 }
16261
16262 extern struct desc_ptr idt_descr;
16263 -extern gate_desc idt_table[];
16264 -extern struct desc_ptr debug_idt_descr;
16265 -extern gate_desc debug_idt_table[];
16266 -
16267 -struct gdt_page {
16268 - struct desc_struct gdt[GDT_ENTRIES];
16269 -} __attribute__((aligned(PAGE_SIZE)));
16270 -
16271 -DECLARE_PER_CPU_PAGE_ALIGNED(struct gdt_page, gdt_page);
16272 +extern gate_desc idt_table[IDT_ENTRIES];
16273 +extern const struct desc_ptr debug_idt_descr;
16274 +extern gate_desc debug_idt_table[IDT_ENTRIES];
16275
16276 +extern struct desc_struct cpu_gdt_table[NR_CPUS][PAGE_SIZE / sizeof(struct desc_struct)];
16277 static inline struct desc_struct *get_cpu_gdt_table(unsigned int cpu)
16278 {
16279 - return per_cpu(gdt_page, cpu).gdt;
16280 + return cpu_gdt_table[cpu];
16281 }
16282
16283 #ifdef CONFIG_X86_64
16284 @@ -72,8 +69,14 @@ static inline void pack_gate(gate_desc *gate, unsigned char type,
16285 unsigned long base, unsigned dpl, unsigned flags,
16286 unsigned short seg)
16287 {
16288 - gate->a = (seg << 16) | (base & 0xffff);
16289 - gate->b = (base & 0xffff0000) | (((0x80 | type | (dpl << 5)) & 0xff) << 8);
16290 + gate->gate.offset_low = base;
16291 + gate->gate.seg = seg;
16292 + gate->gate.reserved = 0;
16293 + gate->gate.type = type;
16294 + gate->gate.s = 0;
16295 + gate->gate.dpl = dpl;
16296 + gate->gate.p = 1;
16297 + gate->gate.offset_high = base >> 16;
16298 }
16299
16300 #endif
16301 @@ -118,12 +121,16 @@ static inline void paravirt_free_ldt(struct desc_struct *ldt, unsigned entries)
16302
16303 static inline void native_write_idt_entry(gate_desc *idt, int entry, const gate_desc *gate)
16304 {
16305 + pax_open_kernel();
16306 memcpy(&idt[entry], gate, sizeof(*gate));
16307 + pax_close_kernel();
16308 }
16309
16310 static inline void native_write_ldt_entry(struct desc_struct *ldt, int entry, const void *desc)
16311 {
16312 + pax_open_kernel();
16313 memcpy(&ldt[entry], desc, 8);
16314 + pax_close_kernel();
16315 }
16316
16317 static inline void
16318 @@ -137,7 +144,9 @@ native_write_gdt_entry(struct desc_struct *gdt, int entry, const void *desc, int
16319 default: size = sizeof(*gdt); break;
16320 }
16321
16322 + pax_open_kernel();
16323 memcpy(&gdt[entry], desc, size);
16324 + pax_close_kernel();
16325 }
16326
16327 static inline void pack_descriptor(struct desc_struct *desc, unsigned long base,
16328 @@ -210,7 +219,9 @@ static inline void native_set_ldt(const void *addr, unsigned int entries)
16329
16330 static inline void native_load_tr_desc(void)
16331 {
16332 + pax_open_kernel();
16333 asm volatile("ltr %w0"::"q" (GDT_ENTRY_TSS*8));
16334 + pax_close_kernel();
16335 }
16336
16337 static inline void native_load_gdt(const struct desc_ptr *dtr)
16338 @@ -247,8 +258,10 @@ static inline void native_load_tls(struct thread_struct *t, unsigned int cpu)
16339 struct desc_struct *gdt = get_cpu_gdt_table(cpu);
16340 unsigned int i;
16341
16342 + pax_open_kernel();
16343 for (i = 0; i < GDT_ENTRY_TLS_ENTRIES; i++)
16344 gdt[GDT_ENTRY_TLS_MIN + i] = t->tls_array[i];
16345 + pax_close_kernel();
16346 }
16347
16348 #define _LDT_empty(info) \
16349 @@ -287,7 +300,7 @@ static inline void load_LDT(mm_context_t *pc)
16350 preempt_enable();
16351 }
16352
16353 -static inline unsigned long get_desc_base(const struct desc_struct *desc)
16354 +static inline unsigned long __intentional_overflow(-1) get_desc_base(const struct desc_struct *desc)
16355 {
16356 return (unsigned)(desc->base0 | ((desc->base1) << 16) | ((desc->base2) << 24));
16357 }
16358 @@ -311,7 +324,7 @@ static inline void set_desc_limit(struct desc_struct *desc, unsigned long limit)
16359 }
16360
16361 #ifdef CONFIG_X86_64
16362 -static inline void set_nmi_gate(int gate, void *addr)
16363 +static inline void set_nmi_gate(int gate, const void *addr)
16364 {
16365 gate_desc s;
16366
16367 @@ -321,14 +334,14 @@ static inline void set_nmi_gate(int gate, void *addr)
16368 #endif
16369
16370 #ifdef CONFIG_TRACING
16371 -extern struct desc_ptr trace_idt_descr;
16372 -extern gate_desc trace_idt_table[];
16373 +extern const struct desc_ptr trace_idt_descr;
16374 +extern gate_desc trace_idt_table[IDT_ENTRIES];
16375 static inline void write_trace_idt_entry(int entry, const gate_desc *gate)
16376 {
16377 write_idt_entry(trace_idt_table, entry, gate);
16378 }
16379
16380 -static inline void _trace_set_gate(int gate, unsigned type, void *addr,
16381 +static inline void _trace_set_gate(int gate, unsigned type, const void *addr,
16382 unsigned dpl, unsigned ist, unsigned seg)
16383 {
16384 gate_desc s;
16385 @@ -348,7 +361,7 @@ static inline void write_trace_idt_entry(int entry, const gate_desc *gate)
16386 #define _trace_set_gate(gate, type, addr, dpl, ist, seg)
16387 #endif
16388
16389 -static inline void _set_gate(int gate, unsigned type, void *addr,
16390 +static inline void _set_gate(int gate, unsigned type, const void *addr,
16391 unsigned dpl, unsigned ist, unsigned seg)
16392 {
16393 gate_desc s;
16394 @@ -371,9 +384,9 @@ static inline void _set_gate(int gate, unsigned type, void *addr,
16395 #define set_intr_gate(n, addr) \
16396 do { \
16397 BUG_ON((unsigned)n > 0xFF); \
16398 - _set_gate(n, GATE_INTERRUPT, (void *)addr, 0, 0, \
16399 + _set_gate(n, GATE_INTERRUPT, (const void *)addr, 0, 0, \
16400 __KERNEL_CS); \
16401 - _trace_set_gate(n, GATE_INTERRUPT, (void *)trace_##addr,\
16402 + _trace_set_gate(n, GATE_INTERRUPT, (const void *)trace_##addr,\
16403 0, 0, __KERNEL_CS); \
16404 } while (0)
16405
16406 @@ -401,19 +414,19 @@ static inline void alloc_system_vector(int vector)
16407 /*
16408 * This routine sets up an interrupt gate at directory privilege level 3.
16409 */
16410 -static inline void set_system_intr_gate(unsigned int n, void *addr)
16411 +static inline void set_system_intr_gate(unsigned int n, const void *addr)
16412 {
16413 BUG_ON((unsigned)n > 0xFF);
16414 _set_gate(n, GATE_INTERRUPT, addr, 0x3, 0, __KERNEL_CS);
16415 }
16416
16417 -static inline void set_system_trap_gate(unsigned int n, void *addr)
16418 +static inline void set_system_trap_gate(unsigned int n, const void *addr)
16419 {
16420 BUG_ON((unsigned)n > 0xFF);
16421 _set_gate(n, GATE_TRAP, addr, 0x3, 0, __KERNEL_CS);
16422 }
16423
16424 -static inline void set_trap_gate(unsigned int n, void *addr)
16425 +static inline void set_trap_gate(unsigned int n, const void *addr)
16426 {
16427 BUG_ON((unsigned)n > 0xFF);
16428 _set_gate(n, GATE_TRAP, addr, 0, 0, __KERNEL_CS);
16429 @@ -422,16 +435,16 @@ static inline void set_trap_gate(unsigned int n, void *addr)
16430 static inline void set_task_gate(unsigned int n, unsigned int gdt_entry)
16431 {
16432 BUG_ON((unsigned)n > 0xFF);
16433 - _set_gate(n, GATE_TASK, (void *)0, 0, 0, (gdt_entry<<3));
16434 + _set_gate(n, GATE_TASK, (const void *)0, 0, 0, (gdt_entry<<3));
16435 }
16436
16437 -static inline void set_intr_gate_ist(int n, void *addr, unsigned ist)
16438 +static inline void set_intr_gate_ist(int n, const void *addr, unsigned ist)
16439 {
16440 BUG_ON((unsigned)n > 0xFF);
16441 _set_gate(n, GATE_INTERRUPT, addr, 0, ist, __KERNEL_CS);
16442 }
16443
16444 -static inline void set_system_intr_gate_ist(int n, void *addr, unsigned ist)
16445 +static inline void set_system_intr_gate_ist(int n, const void *addr, unsigned ist)
16446 {
16447 BUG_ON((unsigned)n > 0xFF);
16448 _set_gate(n, GATE_INTERRUPT, addr, 0x3, ist, __KERNEL_CS);
16449 @@ -503,4 +516,17 @@ static inline void load_current_idt(void)
16450 else
16451 load_idt((const struct desc_ptr *)&idt_descr);
16452 }
16453 +
16454 +#ifdef CONFIG_X86_32
16455 +static inline void set_user_cs(unsigned long base, unsigned long limit, int cpu)
16456 +{
16457 + struct desc_struct d;
16458 +
16459 + if (likely(limit))
16460 + limit = (limit - 1UL) >> PAGE_SHIFT;
16461 + pack_descriptor(&d, base, limit, 0xFB, 0xC);
16462 + write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_DEFAULT_USER_CS, &d, DESCTYPE_S);
16463 +}
16464 +#endif
16465 +
16466 #endif /* _ASM_X86_DESC_H */
16467 diff --git a/arch/x86/include/asm/desc_defs.h b/arch/x86/include/asm/desc_defs.h
16468 index 278441f..b95a174 100644
16469 --- a/arch/x86/include/asm/desc_defs.h
16470 +++ b/arch/x86/include/asm/desc_defs.h
16471 @@ -31,6 +31,12 @@ struct desc_struct {
16472 unsigned base1: 8, type: 4, s: 1, dpl: 2, p: 1;
16473 unsigned limit: 4, avl: 1, l: 1, d: 1, g: 1, base2: 8;
16474 };
16475 + struct {
16476 + u16 offset_low;
16477 + u16 seg;
16478 + unsigned reserved: 8, type: 4, s: 1, dpl: 2, p: 1;
16479 + unsigned offset_high: 16;
16480 + } gate;
16481 };
16482 } __attribute__((packed));
16483
16484 diff --git a/arch/x86/include/asm/div64.h b/arch/x86/include/asm/div64.h
16485 index ced283a..ffe04cc 100644
16486 --- a/arch/x86/include/asm/div64.h
16487 +++ b/arch/x86/include/asm/div64.h
16488 @@ -39,7 +39,7 @@
16489 __mod; \
16490 })
16491
16492 -static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
16493 +static inline u64 __intentional_overflow(-1) div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
16494 {
16495 union {
16496 u64 v64;
16497 diff --git a/arch/x86/include/asm/elf.h b/arch/x86/include/asm/elf.h
16498 index 2c71182..731124d 100644
16499 --- a/arch/x86/include/asm/elf.h
16500 +++ b/arch/x86/include/asm/elf.h
16501 @@ -243,7 +243,25 @@ extern int force_personality32;
16502 the loader. We need to make sure that it is out of the way of the program
16503 that it will "exec", and that there is sufficient room for the brk. */
16504
16505 +#ifdef CONFIG_PAX_SEGMEXEC
16506 +#define ELF_ET_DYN_BASE ((current->mm->pax_flags & MF_PAX_SEGMEXEC) ? SEGMEXEC_TASK_SIZE/3*2 : TASK_SIZE/3*2)
16507 +#else
16508 #define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
16509 +#endif
16510 +
16511 +#ifdef CONFIG_PAX_ASLR
16512 +#ifdef CONFIG_X86_32
16513 +#define PAX_ELF_ET_DYN_BASE 0x10000000UL
16514 +
16515 +#define PAX_DELTA_MMAP_LEN (current->mm->pax_flags & MF_PAX_SEGMEXEC ? 15 : 16)
16516 +#define PAX_DELTA_STACK_LEN (current->mm->pax_flags & MF_PAX_SEGMEXEC ? 15 : 16)
16517 +#else
16518 +#define PAX_ELF_ET_DYN_BASE 0x400000UL
16519 +
16520 +#define PAX_DELTA_MMAP_LEN ((test_thread_flag(TIF_ADDR32)) ? 16 : TASK_SIZE_MAX_SHIFT - PAGE_SHIFT - 3)
16521 +#define PAX_DELTA_STACK_LEN ((test_thread_flag(TIF_ADDR32)) ? 16 : TASK_SIZE_MAX_SHIFT - PAGE_SHIFT - 3)
16522 +#endif
16523 +#endif
16524
16525 /* This yields a mask that user programs can use to figure out what
16526 instruction set this CPU supports. This could be done in user space,
16527 @@ -292,16 +310,12 @@ do { \
16528
16529 #define ARCH_DLINFO \
16530 do { \
16531 - if (vdso_enabled) \
16532 - NEW_AUX_ENT(AT_SYSINFO_EHDR, \
16533 - (unsigned long)current->mm->context.vdso); \
16534 + NEW_AUX_ENT(AT_SYSINFO_EHDR, current->mm->context.vdso); \
16535 } while (0)
16536
16537 #define ARCH_DLINFO_X32 \
16538 do { \
16539 - if (vdso_enabled) \
16540 - NEW_AUX_ENT(AT_SYSINFO_EHDR, \
16541 - (unsigned long)current->mm->context.vdso); \
16542 + NEW_AUX_ENT(AT_SYSINFO_EHDR, current->mm->context.vdso); \
16543 } while (0)
16544
16545 #define AT_SYSINFO 32
16546 @@ -316,7 +330,7 @@ else \
16547
16548 #endif /* !CONFIG_X86_32 */
16549
16550 -#define VDSO_CURRENT_BASE ((unsigned long)current->mm->context.vdso)
16551 +#define VDSO_CURRENT_BASE (current->mm->context.vdso)
16552
16553 #define VDSO_ENTRY \
16554 ((unsigned long)VDSO32_SYMBOL(VDSO_CURRENT_BASE, vsyscall))
16555 @@ -332,9 +346,6 @@ extern int x32_setup_additional_pages(struct linux_binprm *bprm,
16556 extern int syscall32_setup_pages(struct linux_binprm *, int exstack);
16557 #define compat_arch_setup_additional_pages syscall32_setup_pages
16558
16559 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
16560 -#define arch_randomize_brk arch_randomize_brk
16561 -
16562 /*
16563 * True on X86_32 or when emulating IA32 on X86_64
16564 */
16565 diff --git a/arch/x86/include/asm/emergency-restart.h b/arch/x86/include/asm/emergency-restart.h
16566 index 77a99ac..39ff7f5 100644
16567 --- a/arch/x86/include/asm/emergency-restart.h
16568 +++ b/arch/x86/include/asm/emergency-restart.h
16569 @@ -1,6 +1,6 @@
16570 #ifndef _ASM_X86_EMERGENCY_RESTART_H
16571 #define _ASM_X86_EMERGENCY_RESTART_H
16572
16573 -extern void machine_emergency_restart(void);
16574 +extern void machine_emergency_restart(void) __noreturn;
16575
16576 #endif /* _ASM_X86_EMERGENCY_RESTART_H */
16577 diff --git a/arch/x86/include/asm/floppy.h b/arch/x86/include/asm/floppy.h
16578 index 1c7eefe..d0e4702 100644
16579 --- a/arch/x86/include/asm/floppy.h
16580 +++ b/arch/x86/include/asm/floppy.h
16581 @@ -229,18 +229,18 @@ static struct fd_routine_l {
16582 int (*_dma_setup)(char *addr, unsigned long size, int mode, int io);
16583 } fd_routine[] = {
16584 {
16585 - request_dma,
16586 - free_dma,
16587 - get_dma_residue,
16588 - dma_mem_alloc,
16589 - hard_dma_setup
16590 + ._request_dma = request_dma,
16591 + ._free_dma = free_dma,
16592 + ._get_dma_residue = get_dma_residue,
16593 + ._dma_mem_alloc = dma_mem_alloc,
16594 + ._dma_setup = hard_dma_setup
16595 },
16596 {
16597 - vdma_request_dma,
16598 - vdma_nop,
16599 - vdma_get_dma_residue,
16600 - vdma_mem_alloc,
16601 - vdma_dma_setup
16602 + ._request_dma = vdma_request_dma,
16603 + ._free_dma = vdma_nop,
16604 + ._get_dma_residue = vdma_get_dma_residue,
16605 + ._dma_mem_alloc = vdma_mem_alloc,
16606 + ._dma_setup = vdma_dma_setup
16607 }
16608 };
16609
16610 diff --git a/arch/x86/include/asm/fpu-internal.h b/arch/x86/include/asm/fpu-internal.h
16611 index cea1c76..6c0d79b 100644
16612 --- a/arch/x86/include/asm/fpu-internal.h
16613 +++ b/arch/x86/include/asm/fpu-internal.h
16614 @@ -124,8 +124,11 @@ static inline void sanitize_i387_state(struct task_struct *tsk)
16615 #define user_insn(insn, output, input...) \
16616 ({ \
16617 int err; \
16618 + pax_open_userland(); \
16619 asm volatile(ASM_STAC "\n" \
16620 - "1:" #insn "\n\t" \
16621 + "1:" \
16622 + __copyuser_seg \
16623 + #insn "\n\t" \
16624 "2: " ASM_CLAC "\n" \
16625 ".section .fixup,\"ax\"\n" \
16626 "3: movl $-1,%[err]\n" \
16627 @@ -134,6 +137,7 @@ static inline void sanitize_i387_state(struct task_struct *tsk)
16628 _ASM_EXTABLE(1b, 3b) \
16629 : [err] "=r" (err), output \
16630 : "0"(0), input); \
16631 + pax_close_userland(); \
16632 err; \
16633 })
16634
16635 @@ -298,7 +302,7 @@ static inline int restore_fpu_checking(struct task_struct *tsk)
16636 "fnclex\n\t"
16637 "emms\n\t"
16638 "fildl %P[addr]" /* set F?P to defined value */
16639 - : : [addr] "m" (tsk->thread.fpu.has_fpu));
16640 + : : [addr] "m" (init_tss[raw_smp_processor_id()].x86_tss.sp0));
16641 }
16642
16643 return fpu_restore_checking(&tsk->thread.fpu);
16644 diff --git a/arch/x86/include/asm/futex.h b/arch/x86/include/asm/futex.h
16645 index b4c1f54..e290c08 100644
16646 --- a/arch/x86/include/asm/futex.h
16647 +++ b/arch/x86/include/asm/futex.h
16648 @@ -12,6 +12,7 @@
16649 #include <asm/smap.h>
16650
16651 #define __futex_atomic_op1(insn, ret, oldval, uaddr, oparg) \
16652 + typecheck(u32 __user *, uaddr); \
16653 asm volatile("\t" ASM_STAC "\n" \
16654 "1:\t" insn "\n" \
16655 "2:\t" ASM_CLAC "\n" \
16656 @@ -20,15 +21,16 @@
16657 "\tjmp\t2b\n" \
16658 "\t.previous\n" \
16659 _ASM_EXTABLE(1b, 3b) \
16660 - : "=r" (oldval), "=r" (ret), "+m" (*uaddr) \
16661 + : "=r" (oldval), "=r" (ret), "+m" (*(u32 __user *)____m(uaddr)) \
16662 : "i" (-EFAULT), "0" (oparg), "1" (0))
16663
16664 #define __futex_atomic_op2(insn, ret, oldval, uaddr, oparg) \
16665 + typecheck(u32 __user *, uaddr); \
16666 asm volatile("\t" ASM_STAC "\n" \
16667 "1:\tmovl %2, %0\n" \
16668 "\tmovl\t%0, %3\n" \
16669 "\t" insn "\n" \
16670 - "2:\t" LOCK_PREFIX "cmpxchgl %3, %2\n" \
16671 + "2:\t" LOCK_PREFIX __copyuser_seg"cmpxchgl %3, %2\n" \
16672 "\tjnz\t1b\n" \
16673 "3:\t" ASM_CLAC "\n" \
16674 "\t.section .fixup,\"ax\"\n" \
16675 @@ -38,7 +40,7 @@
16676 _ASM_EXTABLE(1b, 4b) \
16677 _ASM_EXTABLE(2b, 4b) \
16678 : "=&a" (oldval), "=&r" (ret), \
16679 - "+m" (*uaddr), "=&r" (tem) \
16680 + "+m" (*(u32 __user *)____m(uaddr)), "=&r" (tem) \
16681 : "r" (oparg), "i" (-EFAULT), "1" (0))
16682
16683 static inline int futex_atomic_op_inuser(int encoded_op, u32 __user *uaddr)
16684 @@ -57,12 +59,13 @@ static inline int futex_atomic_op_inuser(int encoded_op, u32 __user *uaddr)
16685
16686 pagefault_disable();
16687
16688 + pax_open_userland();
16689 switch (op) {
16690 case FUTEX_OP_SET:
16691 - __futex_atomic_op1("xchgl %0, %2", ret, oldval, uaddr, oparg);
16692 + __futex_atomic_op1(__copyuser_seg"xchgl %0, %2", ret, oldval, uaddr, oparg);
16693 break;
16694 case FUTEX_OP_ADD:
16695 - __futex_atomic_op1(LOCK_PREFIX "xaddl %0, %2", ret, oldval,
16696 + __futex_atomic_op1(LOCK_PREFIX __copyuser_seg"xaddl %0, %2", ret, oldval,
16697 uaddr, oparg);
16698 break;
16699 case FUTEX_OP_OR:
16700 @@ -77,6 +80,7 @@ static inline int futex_atomic_op_inuser(int encoded_op, u32 __user *uaddr)
16701 default:
16702 ret = -ENOSYS;
16703 }
16704 + pax_close_userland();
16705
16706 pagefault_enable();
16707
16708 diff --git a/arch/x86/include/asm/hw_irq.h b/arch/x86/include/asm/hw_irq.h
16709 index a307b75..ec74ca2 100644
16710 --- a/arch/x86/include/asm/hw_irq.h
16711 +++ b/arch/x86/include/asm/hw_irq.h
16712 @@ -164,8 +164,8 @@ extern void setup_ioapic_dest(void);
16713 extern void enable_IO_APIC(void);
16714
16715 /* Statistics */
16716 -extern atomic_t irq_err_count;
16717 -extern atomic_t irq_mis_count;
16718 +extern atomic_unchecked_t irq_err_count;
16719 +extern atomic_unchecked_t irq_mis_count;
16720
16721 /* EISA */
16722 extern void eisa_set_level_irq(unsigned int irq);
16723 diff --git a/arch/x86/include/asm/i8259.h b/arch/x86/include/asm/i8259.h
16724 index a203659..9889f1c 100644
16725 --- a/arch/x86/include/asm/i8259.h
16726 +++ b/arch/x86/include/asm/i8259.h
16727 @@ -62,7 +62,7 @@ struct legacy_pic {
16728 void (*init)(int auto_eoi);
16729 int (*irq_pending)(unsigned int irq);
16730 void (*make_irq)(unsigned int irq);
16731 -};
16732 +} __do_const;
16733
16734 extern struct legacy_pic *legacy_pic;
16735 extern struct legacy_pic null_legacy_pic;
16736 diff --git a/arch/x86/include/asm/io.h b/arch/x86/include/asm/io.h
16737 index b8237d8..3e8864e 100644
16738 --- a/arch/x86/include/asm/io.h
16739 +++ b/arch/x86/include/asm/io.h
16740 @@ -52,12 +52,12 @@ static inline void name(type val, volatile void __iomem *addr) \
16741 "m" (*(volatile type __force *)addr) barrier); }
16742
16743 build_mmio_read(readb, "b", unsigned char, "=q", :"memory")
16744 -build_mmio_read(readw, "w", unsigned short, "=r", :"memory")
16745 -build_mmio_read(readl, "l", unsigned int, "=r", :"memory")
16746 +build_mmio_read(__intentional_overflow(-1) readw, "w", unsigned short, "=r", :"memory")
16747 +build_mmio_read(__intentional_overflow(-1) readl, "l", unsigned int, "=r", :"memory")
16748
16749 build_mmio_read(__readb, "b", unsigned char, "=q", )
16750 -build_mmio_read(__readw, "w", unsigned short, "=r", )
16751 -build_mmio_read(__readl, "l", unsigned int, "=r", )
16752 +build_mmio_read(__intentional_overflow(-1) __readw, "w", unsigned short, "=r", )
16753 +build_mmio_read(__intentional_overflow(-1) __readl, "l", unsigned int, "=r", )
16754
16755 build_mmio_write(writeb, "b", unsigned char, "q", :"memory")
16756 build_mmio_write(writew, "w", unsigned short, "r", :"memory")
16757 @@ -109,7 +109,7 @@ build_mmio_write(writeq, "q", unsigned long, "r", :"memory")
16758 * this function
16759 */
16760
16761 -static inline phys_addr_t virt_to_phys(volatile void *address)
16762 +static inline phys_addr_t __intentional_overflow(-1) virt_to_phys(volatile void *address)
16763 {
16764 return __pa(address);
16765 }
16766 @@ -185,7 +185,7 @@ static inline void __iomem *ioremap(resource_size_t offset, unsigned long size)
16767 return ioremap_nocache(offset, size);
16768 }
16769
16770 -extern void iounmap(volatile void __iomem *addr);
16771 +extern void iounmap(const volatile void __iomem *addr);
16772
16773 extern void set_iounmap_nonlazy(void);
16774
16775 @@ -195,6 +195,17 @@ extern void set_iounmap_nonlazy(void);
16776
16777 #include <linux/vmalloc.h>
16778
16779 +#define ARCH_HAS_VALID_PHYS_ADDR_RANGE
16780 +static inline int valid_phys_addr_range(unsigned long addr, size_t count)
16781 +{
16782 + return ((addr + count + PAGE_SIZE - 1) >> PAGE_SHIFT) < (1ULL << (boot_cpu_data.x86_phys_bits - PAGE_SHIFT)) ? 1 : 0;
16783 +}
16784 +
16785 +static inline int valid_mmap_phys_addr_range(unsigned long pfn, size_t count)
16786 +{
16787 + return (pfn + (count >> PAGE_SHIFT)) < (1ULL << (boot_cpu_data.x86_phys_bits - PAGE_SHIFT)) ? 1 : 0;
16788 +}
16789 +
16790 /*
16791 * Convert a virtual cached pointer to an uncached pointer
16792 */
16793 diff --git a/arch/x86/include/asm/irqflags.h b/arch/x86/include/asm/irqflags.h
16794 index bba3cf8..06bc8da 100644
16795 --- a/arch/x86/include/asm/irqflags.h
16796 +++ b/arch/x86/include/asm/irqflags.h
16797 @@ -141,6 +141,11 @@ static inline notrace unsigned long arch_local_irq_save(void)
16798 sti; \
16799 sysexit
16800
16801 +#define GET_CR0_INTO_RDI mov %cr0, %rdi
16802 +#define SET_RDI_INTO_CR0 mov %rdi, %cr0
16803 +#define GET_CR3_INTO_RDI mov %cr3, %rdi
16804 +#define SET_RDI_INTO_CR3 mov %rdi, %cr3
16805 +
16806 #else
16807 #define INTERRUPT_RETURN iret
16808 #define ENABLE_INTERRUPTS_SYSEXIT sti; sysexit
16809 diff --git a/arch/x86/include/asm/kprobes.h b/arch/x86/include/asm/kprobes.h
16810 index 9454c16..e4100e3 100644
16811 --- a/arch/x86/include/asm/kprobes.h
16812 +++ b/arch/x86/include/asm/kprobes.h
16813 @@ -38,13 +38,8 @@ typedef u8 kprobe_opcode_t;
16814 #define RELATIVEJUMP_SIZE 5
16815 #define RELATIVECALL_OPCODE 0xe8
16816 #define RELATIVE_ADDR_SIZE 4
16817 -#define MAX_STACK_SIZE 64
16818 -#define MIN_STACK_SIZE(ADDR) \
16819 - (((MAX_STACK_SIZE) < (((unsigned long)current_thread_info()) + \
16820 - THREAD_SIZE - (unsigned long)(ADDR))) \
16821 - ? (MAX_STACK_SIZE) \
16822 - : (((unsigned long)current_thread_info()) + \
16823 - THREAD_SIZE - (unsigned long)(ADDR)))
16824 +#define MAX_STACK_SIZE 64UL
16825 +#define MIN_STACK_SIZE(ADDR) min(MAX_STACK_SIZE, current->thread.sp0 - (unsigned long)(ADDR))
16826
16827 #define flush_insn_slot(p) do { } while (0)
16828
16829 diff --git a/arch/x86/include/asm/local.h b/arch/x86/include/asm/local.h
16830 index 4ad6560..75c7bdd 100644
16831 --- a/arch/x86/include/asm/local.h
16832 +++ b/arch/x86/include/asm/local.h
16833 @@ -10,33 +10,97 @@ typedef struct {
16834 atomic_long_t a;
16835 } local_t;
16836
16837 +typedef struct {
16838 + atomic_long_unchecked_t a;
16839 +} local_unchecked_t;
16840 +
16841 #define LOCAL_INIT(i) { ATOMIC_LONG_INIT(i) }
16842
16843 #define local_read(l) atomic_long_read(&(l)->a)
16844 +#define local_read_unchecked(l) atomic_long_read_unchecked(&(l)->a)
16845 #define local_set(l, i) atomic_long_set(&(l)->a, (i))
16846 +#define local_set_unchecked(l, i) atomic_long_set_unchecked(&(l)->a, (i))
16847
16848 static inline void local_inc(local_t *l)
16849 {
16850 - asm volatile(_ASM_INC "%0"
16851 + asm volatile(_ASM_INC "%0\n"
16852 +
16853 +#ifdef CONFIG_PAX_REFCOUNT
16854 + "jno 0f\n"
16855 + _ASM_DEC "%0\n"
16856 + "int $4\n0:\n"
16857 + _ASM_EXTABLE(0b, 0b)
16858 +#endif
16859 +
16860 + : "+m" (l->a.counter));
16861 +}
16862 +
16863 +static inline void local_inc_unchecked(local_unchecked_t *l)
16864 +{
16865 + asm volatile(_ASM_INC "%0\n"
16866 : "+m" (l->a.counter));
16867 }
16868
16869 static inline void local_dec(local_t *l)
16870 {
16871 - asm volatile(_ASM_DEC "%0"
16872 + asm volatile(_ASM_DEC "%0\n"
16873 +
16874 +#ifdef CONFIG_PAX_REFCOUNT
16875 + "jno 0f\n"
16876 + _ASM_INC "%0\n"
16877 + "int $4\n0:\n"
16878 + _ASM_EXTABLE(0b, 0b)
16879 +#endif
16880 +
16881 + : "+m" (l->a.counter));
16882 +}
16883 +
16884 +static inline void local_dec_unchecked(local_unchecked_t *l)
16885 +{
16886 + asm volatile(_ASM_DEC "%0\n"
16887 : "+m" (l->a.counter));
16888 }
16889
16890 static inline void local_add(long i, local_t *l)
16891 {
16892 - asm volatile(_ASM_ADD "%1,%0"
16893 + asm volatile(_ASM_ADD "%1,%0\n"
16894 +
16895 +#ifdef CONFIG_PAX_REFCOUNT
16896 + "jno 0f\n"
16897 + _ASM_SUB "%1,%0\n"
16898 + "int $4\n0:\n"
16899 + _ASM_EXTABLE(0b, 0b)
16900 +#endif
16901 +
16902 + : "+m" (l->a.counter)
16903 + : "ir" (i));
16904 +}
16905 +
16906 +static inline void local_add_unchecked(long i, local_unchecked_t *l)
16907 +{
16908 + asm volatile(_ASM_ADD "%1,%0\n"
16909 : "+m" (l->a.counter)
16910 : "ir" (i));
16911 }
16912
16913 static inline void local_sub(long i, local_t *l)
16914 {
16915 - asm volatile(_ASM_SUB "%1,%0"
16916 + asm volatile(_ASM_SUB "%1,%0\n"
16917 +
16918 +#ifdef CONFIG_PAX_REFCOUNT
16919 + "jno 0f\n"
16920 + _ASM_ADD "%1,%0\n"
16921 + "int $4\n0:\n"
16922 + _ASM_EXTABLE(0b, 0b)
16923 +#endif
16924 +
16925 + : "+m" (l->a.counter)
16926 + : "ir" (i));
16927 +}
16928 +
16929 +static inline void local_sub_unchecked(long i, local_unchecked_t *l)
16930 +{
16931 + asm volatile(_ASM_SUB "%1,%0\n"
16932 : "+m" (l->a.counter)
16933 : "ir" (i));
16934 }
16935 @@ -52,7 +116,7 @@ static inline void local_sub(long i, local_t *l)
16936 */
16937 static inline int local_sub_and_test(long i, local_t *l)
16938 {
16939 - GEN_BINARY_RMWcc(_ASM_SUB, l->a.counter, "er", i, "%0", "e");
16940 + GEN_BINARY_RMWcc(_ASM_SUB, _ASM_ADD, l->a.counter, "er", i, "%0", "e");
16941 }
16942
16943 /**
16944 @@ -65,7 +129,7 @@ static inline int local_sub_and_test(long i, local_t *l)
16945 */
16946 static inline int local_dec_and_test(local_t *l)
16947 {
16948 - GEN_UNARY_RMWcc(_ASM_DEC, l->a.counter, "%0", "e");
16949 + GEN_UNARY_RMWcc(_ASM_DEC, _ASM_INC, l->a.counter, "%0", "e");
16950 }
16951
16952 /**
16953 @@ -78,7 +142,7 @@ static inline int local_dec_and_test(local_t *l)
16954 */
16955 static inline int local_inc_and_test(local_t *l)
16956 {
16957 - GEN_UNARY_RMWcc(_ASM_INC, l->a.counter, "%0", "e");
16958 + GEN_UNARY_RMWcc(_ASM_INC, _ASM_DEC, l->a.counter, "%0", "e");
16959 }
16960
16961 /**
16962 @@ -92,7 +156,7 @@ static inline int local_inc_and_test(local_t *l)
16963 */
16964 static inline int local_add_negative(long i, local_t *l)
16965 {
16966 - GEN_BINARY_RMWcc(_ASM_ADD, l->a.counter, "er", i, "%0", "s");
16967 + GEN_BINARY_RMWcc(_ASM_ADD, _ASM_SUB, l->a.counter, "er", i, "%0", "s");
16968 }
16969
16970 /**
16971 @@ -105,6 +169,30 @@ static inline int local_add_negative(long i, local_t *l)
16972 static inline long local_add_return(long i, local_t *l)
16973 {
16974 long __i = i;
16975 + asm volatile(_ASM_XADD "%0, %1\n"
16976 +
16977 +#ifdef CONFIG_PAX_REFCOUNT
16978 + "jno 0f\n"
16979 + _ASM_MOV "%0,%1\n"
16980 + "int $4\n0:\n"
16981 + _ASM_EXTABLE(0b, 0b)
16982 +#endif
16983 +
16984 + : "+r" (i), "+m" (l->a.counter)
16985 + : : "memory");
16986 + return i + __i;
16987 +}
16988 +
16989 +/**
16990 + * local_add_return_unchecked - add and return
16991 + * @i: integer value to add
16992 + * @l: pointer to type local_unchecked_t
16993 + *
16994 + * Atomically adds @i to @l and returns @i + @l
16995 + */
16996 +static inline long local_add_return_unchecked(long i, local_unchecked_t *l)
16997 +{
16998 + long __i = i;
16999 asm volatile(_ASM_XADD "%0, %1;"
17000 : "+r" (i), "+m" (l->a.counter)
17001 : : "memory");
17002 @@ -121,6 +209,8 @@ static inline long local_sub_return(long i, local_t *l)
17003
17004 #define local_cmpxchg(l, o, n) \
17005 (cmpxchg_local(&((l)->a.counter), (o), (n)))
17006 +#define local_cmpxchg_unchecked(l, o, n) \
17007 + (cmpxchg_local(&((l)->a.counter), (o), (n)))
17008 /* Always has a lock prefix */
17009 #define local_xchg(l, n) (xchg(&((l)->a.counter), (n)))
17010
17011 diff --git a/arch/x86/include/asm/mman.h b/arch/x86/include/asm/mman.h
17012 new file mode 100644
17013 index 0000000..2bfd3ba
17014 --- /dev/null
17015 +++ b/arch/x86/include/asm/mman.h
17016 @@ -0,0 +1,15 @@
17017 +#ifndef _X86_MMAN_H
17018 +#define _X86_MMAN_H
17019 +
17020 +#include <uapi/asm/mman.h>
17021 +
17022 +#ifdef __KERNEL__
17023 +#ifndef __ASSEMBLY__
17024 +#ifdef CONFIG_X86_32
17025 +#define arch_mmap_check i386_mmap_check
17026 +int i386_mmap_check(unsigned long addr, unsigned long len, unsigned long flags);
17027 +#endif
17028 +#endif
17029 +#endif
17030 +
17031 +#endif /* X86_MMAN_H */
17032 diff --git a/arch/x86/include/asm/mmu.h b/arch/x86/include/asm/mmu.h
17033 index 5f55e69..e20bfb1 100644
17034 --- a/arch/x86/include/asm/mmu.h
17035 +++ b/arch/x86/include/asm/mmu.h
17036 @@ -9,7 +9,7 @@
17037 * we put the segment information here.
17038 */
17039 typedef struct {
17040 - void *ldt;
17041 + struct desc_struct *ldt;
17042 int size;
17043
17044 #ifdef CONFIG_X86_64
17045 @@ -18,7 +18,19 @@ typedef struct {
17046 #endif
17047
17048 struct mutex lock;
17049 - void *vdso;
17050 + unsigned long vdso;
17051 +
17052 +#ifdef CONFIG_X86_32
17053 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
17054 + unsigned long user_cs_base;
17055 + unsigned long user_cs_limit;
17056 +
17057 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_SMP)
17058 + cpumask_t cpu_user_cs_mask;
17059 +#endif
17060 +
17061 +#endif
17062 +#endif
17063 } mm_context_t;
17064
17065 #ifdef CONFIG_SMP
17066 diff --git a/arch/x86/include/asm/mmu_context.h b/arch/x86/include/asm/mmu_context.h
17067 index be12c53..4d24039 100644
17068 --- a/arch/x86/include/asm/mmu_context.h
17069 +++ b/arch/x86/include/asm/mmu_context.h
17070 @@ -24,6 +24,20 @@ void destroy_context(struct mm_struct *mm);
17071
17072 static inline void enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk)
17073 {
17074 +
17075 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
17076 + if (!(static_cpu_has(X86_FEATURE_PCID))) {
17077 + unsigned int i;
17078 + pgd_t *pgd;
17079 +
17080 + pax_open_kernel();
17081 + pgd = get_cpu_pgd(smp_processor_id(), kernel);
17082 + for (i = USER_PGD_PTRS; i < 2 * USER_PGD_PTRS; ++i)
17083 + set_pgd_batched(pgd+i, native_make_pgd(0));
17084 + pax_close_kernel();
17085 + }
17086 +#endif
17087 +
17088 #ifdef CONFIG_SMP
17089 if (this_cpu_read(cpu_tlbstate.state) == TLBSTATE_OK)
17090 this_cpu_write(cpu_tlbstate.state, TLBSTATE_LAZY);
17091 @@ -34,16 +48,59 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
17092 struct task_struct *tsk)
17093 {
17094 unsigned cpu = smp_processor_id();
17095 +#if defined(CONFIG_X86_32) && defined(CONFIG_SMP) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
17096 + int tlbstate = TLBSTATE_OK;
17097 +#endif
17098
17099 if (likely(prev != next)) {
17100 #ifdef CONFIG_SMP
17101 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
17102 + tlbstate = this_cpu_read(cpu_tlbstate.state);
17103 +#endif
17104 this_cpu_write(cpu_tlbstate.state, TLBSTATE_OK);
17105 this_cpu_write(cpu_tlbstate.active_mm, next);
17106 #endif
17107 cpumask_set_cpu(cpu, mm_cpumask(next));
17108
17109 /* Re-load page tables */
17110 +#ifdef CONFIG_PAX_PER_CPU_PGD
17111 + pax_open_kernel();
17112 +
17113 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
17114 + if (static_cpu_has(X86_FEATURE_PCID))
17115 + __clone_user_pgds(get_cpu_pgd(cpu, user), next->pgd);
17116 + else
17117 +#endif
17118 +
17119 + __clone_user_pgds(get_cpu_pgd(cpu, kernel), next->pgd);
17120 + __shadow_user_pgds(get_cpu_pgd(cpu, kernel) + USER_PGD_PTRS, next->pgd);
17121 + pax_close_kernel();
17122 + 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));
17123 +
17124 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
17125 + if (static_cpu_has(X86_FEATURE_PCID)) {
17126 + if (static_cpu_has(X86_FEATURE_INVPCID)) {
17127 + u64 descriptor[2];
17128 + descriptor[0] = PCID_USER;
17129 + asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_SINGLE_CONTEXT) : "memory");
17130 + if (!static_cpu_has(X86_FEATURE_STRONGUDEREF)) {
17131 + descriptor[0] = PCID_KERNEL;
17132 + asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_SINGLE_CONTEXT) : "memory");
17133 + }
17134 + } else {
17135 + write_cr3(__pa(get_cpu_pgd(cpu, user)) | PCID_USER);
17136 + if (static_cpu_has(X86_FEATURE_STRONGUDEREF))
17137 + write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL | PCID_NOFLUSH);
17138 + else
17139 + write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL);
17140 + }
17141 + } else
17142 +#endif
17143 +
17144 + load_cr3(get_cpu_pgd(cpu, kernel));
17145 +#else
17146 load_cr3(next->pgd);
17147 +#endif
17148
17149 /* Stop flush ipis for the previous mm */
17150 cpumask_clear_cpu(cpu, mm_cpumask(prev));
17151 @@ -51,9 +108,67 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
17152 /* Load the LDT, if the LDT is different: */
17153 if (unlikely(prev->context.ldt != next->context.ldt))
17154 load_LDT_nolock(&next->context);
17155 +
17156 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_SMP)
17157 + if (!(__supported_pte_mask & _PAGE_NX)) {
17158 + smp_mb__before_clear_bit();
17159 + cpu_clear(cpu, prev->context.cpu_user_cs_mask);
17160 + smp_mb__after_clear_bit();
17161 + cpu_set(cpu, next->context.cpu_user_cs_mask);
17162 + }
17163 +#endif
17164 +
17165 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
17166 + if (unlikely(prev->context.user_cs_base != next->context.user_cs_base ||
17167 + prev->context.user_cs_limit != next->context.user_cs_limit))
17168 + set_user_cs(next->context.user_cs_base, next->context.user_cs_limit, cpu);
17169 +#ifdef CONFIG_SMP
17170 + else if (unlikely(tlbstate != TLBSTATE_OK))
17171 + set_user_cs(next->context.user_cs_base, next->context.user_cs_limit, cpu);
17172 +#endif
17173 +#endif
17174 +
17175 }
17176 + else {
17177 +
17178 +#ifdef CONFIG_PAX_PER_CPU_PGD
17179 + pax_open_kernel();
17180 +
17181 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
17182 + if (static_cpu_has(X86_FEATURE_PCID))
17183 + __clone_user_pgds(get_cpu_pgd(cpu, user), next->pgd);
17184 + else
17185 +#endif
17186 +
17187 + __clone_user_pgds(get_cpu_pgd(cpu, kernel), next->pgd);
17188 + __shadow_user_pgds(get_cpu_pgd(cpu, kernel) + USER_PGD_PTRS, next->pgd);
17189 + pax_close_kernel();
17190 + 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));
17191 +
17192 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
17193 + if (static_cpu_has(X86_FEATURE_PCID)) {
17194 + if (static_cpu_has(X86_FEATURE_INVPCID)) {
17195 + u64 descriptor[2];
17196 + descriptor[0] = PCID_USER;
17197 + asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_SINGLE_CONTEXT) : "memory");
17198 + if (!static_cpu_has(X86_FEATURE_STRONGUDEREF)) {
17199 + descriptor[0] = PCID_KERNEL;
17200 + asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_SINGLE_CONTEXT) : "memory");
17201 + }
17202 + } else {
17203 + write_cr3(__pa(get_cpu_pgd(cpu, user)) | PCID_USER);
17204 + if (static_cpu_has(X86_FEATURE_STRONGUDEREF))
17205 + write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL | PCID_NOFLUSH);
17206 + else
17207 + write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL);
17208 + }
17209 + } else
17210 +#endif
17211 +
17212 + load_cr3(get_cpu_pgd(cpu, kernel));
17213 +#endif
17214 +
17215 #ifdef CONFIG_SMP
17216 - else {
17217 this_cpu_write(cpu_tlbstate.state, TLBSTATE_OK);
17218 BUG_ON(this_cpu_read(cpu_tlbstate.active_mm) != next);
17219
17220 @@ -70,11 +185,28 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
17221 * tlb flush IPI delivery. We must reload CR3
17222 * to make sure to use no freed page tables.
17223 */
17224 +
17225 +#ifndef CONFIG_PAX_PER_CPU_PGD
17226 load_cr3(next->pgd);
17227 +#endif
17228 +
17229 load_LDT_nolock(&next->context);
17230 +
17231 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
17232 + if (!(__supported_pte_mask & _PAGE_NX))
17233 + cpu_set(cpu, next->context.cpu_user_cs_mask);
17234 +#endif
17235 +
17236 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
17237 +#ifdef CONFIG_PAX_PAGEEXEC
17238 + if (!((next->pax_flags & MF_PAX_PAGEEXEC) && (__supported_pte_mask & _PAGE_NX)))
17239 +#endif
17240 + set_user_cs(next->context.user_cs_base, next->context.user_cs_limit, cpu);
17241 +#endif
17242 +
17243 }
17244 +#endif
17245 }
17246 -#endif
17247 }
17248
17249 #define activate_mm(prev, next) \
17250 diff --git a/arch/x86/include/asm/module.h b/arch/x86/include/asm/module.h
17251 index e3b7819..b257c64 100644
17252 --- a/arch/x86/include/asm/module.h
17253 +++ b/arch/x86/include/asm/module.h
17254 @@ -5,6 +5,7 @@
17255
17256 #ifdef CONFIG_X86_64
17257 /* X86_64 does not define MODULE_PROC_FAMILY */
17258 +#define MODULE_PROC_FAMILY ""
17259 #elif defined CONFIG_M486
17260 #define MODULE_PROC_FAMILY "486 "
17261 #elif defined CONFIG_M586
17262 @@ -57,8 +58,20 @@
17263 #error unknown processor family
17264 #endif
17265
17266 -#ifdef CONFIG_X86_32
17267 -# define MODULE_ARCH_VERMAGIC MODULE_PROC_FAMILY
17268 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_BTS
17269 +#define MODULE_PAX_KERNEXEC "KERNEXEC_BTS "
17270 +#elif defined(CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR)
17271 +#define MODULE_PAX_KERNEXEC "KERNEXEC_OR "
17272 +#else
17273 +#define MODULE_PAX_KERNEXEC ""
17274 #endif
17275
17276 +#ifdef CONFIG_PAX_MEMORY_UDEREF
17277 +#define MODULE_PAX_UDEREF "UDEREF "
17278 +#else
17279 +#define MODULE_PAX_UDEREF ""
17280 +#endif
17281 +
17282 +#define MODULE_ARCH_VERMAGIC MODULE_PROC_FAMILY MODULE_PAX_KERNEXEC MODULE_PAX_UDEREF
17283 +
17284 #endif /* _ASM_X86_MODULE_H */
17285 diff --git a/arch/x86/include/asm/nmi.h b/arch/x86/include/asm/nmi.h
17286 index 5f2fc44..106caa6 100644
17287 --- a/arch/x86/include/asm/nmi.h
17288 +++ b/arch/x86/include/asm/nmi.h
17289 @@ -36,26 +36,35 @@ enum {
17290
17291 typedef int (*nmi_handler_t)(unsigned int, struct pt_regs *);
17292
17293 +struct nmiaction;
17294 +
17295 +struct nmiwork {
17296 + const struct nmiaction *action;
17297 + u64 max_duration;
17298 + struct irq_work irq_work;
17299 +};
17300 +
17301 struct nmiaction {
17302 struct list_head list;
17303 nmi_handler_t handler;
17304 - u64 max_duration;
17305 - struct irq_work irq_work;
17306 unsigned long flags;
17307 const char *name;
17308 -};
17309 + struct nmiwork *work;
17310 +} __do_const;
17311
17312 #define register_nmi_handler(t, fn, fg, n, init...) \
17313 ({ \
17314 - static struct nmiaction init fn##_na = { \
17315 + static struct nmiwork fn##_nw; \
17316 + static const struct nmiaction init fn##_na = { \
17317 .handler = (fn), \
17318 .name = (n), \
17319 .flags = (fg), \
17320 + .work = &fn##_nw, \
17321 }; \
17322 __register_nmi_handler((t), &fn##_na); \
17323 })
17324
17325 -int __register_nmi_handler(unsigned int, struct nmiaction *);
17326 +int __register_nmi_handler(unsigned int, const struct nmiaction *);
17327
17328 void unregister_nmi_handler(unsigned int, const char *);
17329
17330 diff --git a/arch/x86/include/asm/page.h b/arch/x86/include/asm/page.h
17331 index 775873d..04cd306 100644
17332 --- a/arch/x86/include/asm/page.h
17333 +++ b/arch/x86/include/asm/page.h
17334 @@ -52,6 +52,7 @@ static inline void copy_user_page(void *to, void *from, unsigned long vaddr,
17335 __phys_addr_symbol(__phys_reloc_hide((unsigned long)(x)))
17336
17337 #define __va(x) ((void *)((unsigned long)(x)+PAGE_OFFSET))
17338 +#define __early_va(x) ((void *)((unsigned long)(x)+__START_KERNEL_map - phys_base))
17339
17340 #define __boot_va(x) __va(x)
17341 #define __boot_pa(x) __pa(x)
17342 @@ -60,11 +61,21 @@ static inline void copy_user_page(void *to, void *from, unsigned long vaddr,
17343 * virt_to_page(kaddr) returns a valid pointer if and only if
17344 * virt_addr_valid(kaddr) returns true.
17345 */
17346 -#define virt_to_page(kaddr) pfn_to_page(__pa(kaddr) >> PAGE_SHIFT)
17347 #define pfn_to_kaddr(pfn) __va((pfn) << PAGE_SHIFT)
17348 extern bool __virt_addr_valid(unsigned long kaddr);
17349 #define virt_addr_valid(kaddr) __virt_addr_valid((unsigned long) (kaddr))
17350
17351 +#ifdef CONFIG_GRKERNSEC_KSTACKOVERFLOW
17352 +#define virt_to_page(kaddr) \
17353 + ({ \
17354 + const void *__kaddr = (const void *)(kaddr); \
17355 + BUG_ON(!virt_addr_valid(__kaddr)); \
17356 + pfn_to_page(__pa(__kaddr) >> PAGE_SHIFT); \
17357 + })
17358 +#else
17359 +#define virt_to_page(kaddr) pfn_to_page(__pa(kaddr) >> PAGE_SHIFT)
17360 +#endif
17361 +
17362 #endif /* __ASSEMBLY__ */
17363
17364 #include <asm-generic/memory_model.h>
17365 diff --git a/arch/x86/include/asm/page_64.h b/arch/x86/include/asm/page_64.h
17366 index 0f1ddee..e2fc3d1 100644
17367 --- a/arch/x86/include/asm/page_64.h
17368 +++ b/arch/x86/include/asm/page_64.h
17369 @@ -7,9 +7,9 @@
17370
17371 /* duplicated to the one in bootmem.h */
17372 extern unsigned long max_pfn;
17373 -extern unsigned long phys_base;
17374 +extern const unsigned long phys_base;
17375
17376 -static inline unsigned long __phys_addr_nodebug(unsigned long x)
17377 +static inline unsigned long __intentional_overflow(-1) __phys_addr_nodebug(unsigned long x)
17378 {
17379 unsigned long y = x - __START_KERNEL_map;
17380
17381 diff --git a/arch/x86/include/asm/paravirt.h b/arch/x86/include/asm/paravirt.h
17382 index cd6e1610..70f4418 100644
17383 --- a/arch/x86/include/asm/paravirt.h
17384 +++ b/arch/x86/include/asm/paravirt.h
17385 @@ -560,7 +560,7 @@ static inline pmd_t __pmd(pmdval_t val)
17386 return (pmd_t) { ret };
17387 }
17388
17389 -static inline pmdval_t pmd_val(pmd_t pmd)
17390 +static inline __intentional_overflow(-1) pmdval_t pmd_val(pmd_t pmd)
17391 {
17392 pmdval_t ret;
17393
17394 @@ -626,6 +626,18 @@ static inline void set_pgd(pgd_t *pgdp, pgd_t pgd)
17395 val);
17396 }
17397
17398 +static inline void set_pgd_batched(pgd_t *pgdp, pgd_t pgd)
17399 +{
17400 + pgdval_t val = native_pgd_val(pgd);
17401 +
17402 + if (sizeof(pgdval_t) > sizeof(long))
17403 + PVOP_VCALL3(pv_mmu_ops.set_pgd_batched, pgdp,
17404 + val, (u64)val >> 32);
17405 + else
17406 + PVOP_VCALL2(pv_mmu_ops.set_pgd_batched, pgdp,
17407 + val);
17408 +}
17409 +
17410 static inline void pgd_clear(pgd_t *pgdp)
17411 {
17412 set_pgd(pgdp, __pgd(0));
17413 @@ -710,6 +722,21 @@ static inline void __set_fixmap(unsigned /* enum fixed_addresses */ idx,
17414 pv_mmu_ops.set_fixmap(idx, phys, flags);
17415 }
17416
17417 +#ifdef CONFIG_PAX_KERNEXEC
17418 +static inline unsigned long pax_open_kernel(void)
17419 +{
17420 + return PVOP_CALL0(unsigned long, pv_mmu_ops.pax_open_kernel);
17421 +}
17422 +
17423 +static inline unsigned long pax_close_kernel(void)
17424 +{
17425 + return PVOP_CALL0(unsigned long, pv_mmu_ops.pax_close_kernel);
17426 +}
17427 +#else
17428 +static inline unsigned long pax_open_kernel(void) { return 0; }
17429 +static inline unsigned long pax_close_kernel(void) { return 0; }
17430 +#endif
17431 +
17432 #if defined(CONFIG_SMP) && defined(CONFIG_PARAVIRT_SPINLOCKS)
17433
17434 static __always_inline void __ticket_lock_spinning(struct arch_spinlock *lock,
17435 @@ -906,7 +933,7 @@ extern void default_banner(void);
17436
17437 #define PARA_PATCH(struct, off) ((PARAVIRT_PATCH_##struct + (off)) / 4)
17438 #define PARA_SITE(ptype, clobbers, ops) _PVSITE(ptype, clobbers, ops, .long, 4)
17439 -#define PARA_INDIRECT(addr) *%cs:addr
17440 +#define PARA_INDIRECT(addr) *%ss:addr
17441 #endif
17442
17443 #define INTERRUPT_RETURN \
17444 @@ -981,6 +1008,21 @@ extern void default_banner(void);
17445 PARA_SITE(PARA_PATCH(pv_cpu_ops, PV_CPU_irq_enable_sysexit), \
17446 CLBR_NONE, \
17447 jmp PARA_INDIRECT(pv_cpu_ops+PV_CPU_irq_enable_sysexit))
17448 +
17449 +#define GET_CR0_INTO_RDI \
17450 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_read_cr0); \
17451 + mov %rax,%rdi
17452 +
17453 +#define SET_RDI_INTO_CR0 \
17454 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_write_cr0)
17455 +
17456 +#define GET_CR3_INTO_RDI \
17457 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_read_cr3); \
17458 + mov %rax,%rdi
17459 +
17460 +#define SET_RDI_INTO_CR3 \
17461 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_write_cr3)
17462 +
17463 #endif /* CONFIG_X86_32 */
17464
17465 #endif /* __ASSEMBLY__ */
17466 diff --git a/arch/x86/include/asm/paravirt_types.h b/arch/x86/include/asm/paravirt_types.h
17467 index 7549b8b..f0edfda 100644
17468 --- a/arch/x86/include/asm/paravirt_types.h
17469 +++ b/arch/x86/include/asm/paravirt_types.h
17470 @@ -84,7 +84,7 @@ struct pv_init_ops {
17471 */
17472 unsigned (*patch)(u8 type, u16 clobber, void *insnbuf,
17473 unsigned long addr, unsigned len);
17474 -};
17475 +} __no_const __no_randomize_layout;
17476
17477
17478 struct pv_lazy_ops {
17479 @@ -92,13 +92,13 @@ struct pv_lazy_ops {
17480 void (*enter)(void);
17481 void (*leave)(void);
17482 void (*flush)(void);
17483 -};
17484 +} __no_randomize_layout;
17485
17486 struct pv_time_ops {
17487 unsigned long long (*sched_clock)(void);
17488 unsigned long long (*steal_clock)(int cpu);
17489 unsigned long (*get_tsc_khz)(void);
17490 -};
17491 +} __no_const __no_randomize_layout;
17492
17493 struct pv_cpu_ops {
17494 /* hooks for various privileged instructions */
17495 @@ -192,7 +192,7 @@ struct pv_cpu_ops {
17496
17497 void (*start_context_switch)(struct task_struct *prev);
17498 void (*end_context_switch)(struct task_struct *next);
17499 -};
17500 +} __no_const __no_randomize_layout;
17501
17502 struct pv_irq_ops {
17503 /*
17504 @@ -215,7 +215,7 @@ struct pv_irq_ops {
17505 #ifdef CONFIG_X86_64
17506 void (*adjust_exception_frame)(void);
17507 #endif
17508 -};
17509 +} __no_randomize_layout;
17510
17511 struct pv_apic_ops {
17512 #ifdef CONFIG_X86_LOCAL_APIC
17513 @@ -223,7 +223,7 @@ struct pv_apic_ops {
17514 unsigned long start_eip,
17515 unsigned long start_esp);
17516 #endif
17517 -};
17518 +} __no_const __no_randomize_layout;
17519
17520 struct pv_mmu_ops {
17521 unsigned long (*read_cr2)(void);
17522 @@ -313,6 +313,7 @@ struct pv_mmu_ops {
17523 struct paravirt_callee_save make_pud;
17524
17525 void (*set_pgd)(pgd_t *pudp, pgd_t pgdval);
17526 + void (*set_pgd_batched)(pgd_t *pudp, pgd_t pgdval);
17527 #endif /* PAGETABLE_LEVELS == 4 */
17528 #endif /* PAGETABLE_LEVELS >= 3 */
17529
17530 @@ -324,7 +325,13 @@ struct pv_mmu_ops {
17531 an mfn. We can tell which is which from the index. */
17532 void (*set_fixmap)(unsigned /* enum fixed_addresses */ idx,
17533 phys_addr_t phys, pgprot_t flags);
17534 -};
17535 +
17536 +#ifdef CONFIG_PAX_KERNEXEC
17537 + unsigned long (*pax_open_kernel)(void);
17538 + unsigned long (*pax_close_kernel)(void);
17539 +#endif
17540 +
17541 +} __no_randomize_layout;
17542
17543 struct arch_spinlock;
17544 #ifdef CONFIG_SMP
17545 @@ -336,11 +343,14 @@ typedef u16 __ticket_t;
17546 struct pv_lock_ops {
17547 struct paravirt_callee_save lock_spinning;
17548 void (*unlock_kick)(struct arch_spinlock *lock, __ticket_t ticket);
17549 -};
17550 +} __no_randomize_layout;
17551
17552 /* This contains all the paravirt structures: we get a convenient
17553 * number for each function using the offset which we use to indicate
17554 - * what to patch. */
17555 + * what to patch.
17556 + * shouldn't be randomized due to the "NEAT TRICK" in paravirt.c
17557 + */
17558 +
17559 struct paravirt_patch_template {
17560 struct pv_init_ops pv_init_ops;
17561 struct pv_time_ops pv_time_ops;
17562 @@ -349,7 +359,7 @@ struct paravirt_patch_template {
17563 struct pv_apic_ops pv_apic_ops;
17564 struct pv_mmu_ops pv_mmu_ops;
17565 struct pv_lock_ops pv_lock_ops;
17566 -};
17567 +} __no_randomize_layout;
17568
17569 extern struct pv_info pv_info;
17570 extern struct pv_init_ops pv_init_ops;
17571 diff --git a/arch/x86/include/asm/pgalloc.h b/arch/x86/include/asm/pgalloc.h
17572 index c4412e9..90e88c5 100644
17573 --- a/arch/x86/include/asm/pgalloc.h
17574 +++ b/arch/x86/include/asm/pgalloc.h
17575 @@ -63,6 +63,13 @@ static inline void pmd_populate_kernel(struct mm_struct *mm,
17576 pmd_t *pmd, pte_t *pte)
17577 {
17578 paravirt_alloc_pte(mm, __pa(pte) >> PAGE_SHIFT);
17579 + set_pmd(pmd, __pmd(__pa(pte) | _KERNPG_TABLE));
17580 +}
17581 +
17582 +static inline void pmd_populate_user(struct mm_struct *mm,
17583 + pmd_t *pmd, pte_t *pte)
17584 +{
17585 + paravirt_alloc_pte(mm, __pa(pte) >> PAGE_SHIFT);
17586 set_pmd(pmd, __pmd(__pa(pte) | _PAGE_TABLE));
17587 }
17588
17589 @@ -108,12 +115,22 @@ static inline void __pmd_free_tlb(struct mmu_gather *tlb, pmd_t *pmd,
17590
17591 #ifdef CONFIG_X86_PAE
17592 extern void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd);
17593 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd)
17594 +{
17595 + pud_populate(mm, pudp, pmd);
17596 +}
17597 #else /* !CONFIG_X86_PAE */
17598 static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
17599 {
17600 paravirt_alloc_pmd(mm, __pa(pmd) >> PAGE_SHIFT);
17601 set_pud(pud, __pud(_PAGE_TABLE | __pa(pmd)));
17602 }
17603 +
17604 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
17605 +{
17606 + paravirt_alloc_pmd(mm, __pa(pmd) >> PAGE_SHIFT);
17607 + set_pud(pud, __pud(_KERNPG_TABLE | __pa(pmd)));
17608 +}
17609 #endif /* CONFIG_X86_PAE */
17610
17611 #if PAGETABLE_LEVELS > 3
17612 @@ -123,6 +140,12 @@ static inline void pgd_populate(struct mm_struct *mm, pgd_t *pgd, pud_t *pud)
17613 set_pgd(pgd, __pgd(_PAGE_TABLE | __pa(pud)));
17614 }
17615
17616 +static inline void pgd_populate_kernel(struct mm_struct *mm, pgd_t *pgd, pud_t *pud)
17617 +{
17618 + paravirt_alloc_pud(mm, __pa(pud) >> PAGE_SHIFT);
17619 + set_pgd(pgd, __pgd(_KERNPG_TABLE | __pa(pud)));
17620 +}
17621 +
17622 static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
17623 {
17624 return (pud_t *)get_zeroed_page(GFP_KERNEL|__GFP_REPEAT);
17625 diff --git a/arch/x86/include/asm/pgtable-2level.h b/arch/x86/include/asm/pgtable-2level.h
17626 index 0d193e2..bf59aeb 100644
17627 --- a/arch/x86/include/asm/pgtable-2level.h
17628 +++ b/arch/x86/include/asm/pgtable-2level.h
17629 @@ -18,7 +18,9 @@ static inline void native_set_pte(pte_t *ptep , pte_t pte)
17630
17631 static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
17632 {
17633 + pax_open_kernel();
17634 *pmdp = pmd;
17635 + pax_close_kernel();
17636 }
17637
17638 static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte)
17639 diff --git a/arch/x86/include/asm/pgtable-3level.h b/arch/x86/include/asm/pgtable-3level.h
17640 index 81bb91b..9392125 100644
17641 --- a/arch/x86/include/asm/pgtable-3level.h
17642 +++ b/arch/x86/include/asm/pgtable-3level.h
17643 @@ -92,12 +92,16 @@ static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte)
17644
17645 static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
17646 {
17647 + pax_open_kernel();
17648 set_64bit((unsigned long long *)(pmdp), native_pmd_val(pmd));
17649 + pax_close_kernel();
17650 }
17651
17652 static inline void native_set_pud(pud_t *pudp, pud_t pud)
17653 {
17654 + pax_open_kernel();
17655 set_64bit((unsigned long long *)(pudp), native_pud_val(pud));
17656 + pax_close_kernel();
17657 }
17658
17659 /*
17660 diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h
17661 index b459ddf..b44081b 100644
17662 --- a/arch/x86/include/asm/pgtable.h
17663 +++ b/arch/x86/include/asm/pgtable.h
17664 @@ -46,6 +46,7 @@ extern struct mm_struct *pgd_page_get_mm(struct page *page);
17665
17666 #ifndef __PAGETABLE_PUD_FOLDED
17667 #define set_pgd(pgdp, pgd) native_set_pgd(pgdp, pgd)
17668 +#define set_pgd_batched(pgdp, pgd) native_set_pgd_batched(pgdp, pgd)
17669 #define pgd_clear(pgd) native_pgd_clear(pgd)
17670 #endif
17671
17672 @@ -83,12 +84,51 @@ extern struct mm_struct *pgd_page_get_mm(struct page *page);
17673
17674 #define arch_end_context_switch(prev) do {} while(0)
17675
17676 +#define pax_open_kernel() native_pax_open_kernel()
17677 +#define pax_close_kernel() native_pax_close_kernel()
17678 #endif /* CONFIG_PARAVIRT */
17679
17680 +#define __HAVE_ARCH_PAX_OPEN_KERNEL
17681 +#define __HAVE_ARCH_PAX_CLOSE_KERNEL
17682 +
17683 +#ifdef CONFIG_PAX_KERNEXEC
17684 +static inline unsigned long native_pax_open_kernel(void)
17685 +{
17686 + unsigned long cr0;
17687 +
17688 + preempt_disable();
17689 + barrier();
17690 + cr0 = read_cr0() ^ X86_CR0_WP;
17691 + BUG_ON(cr0 & X86_CR0_WP);
17692 + write_cr0(cr0);
17693 + return cr0 ^ X86_CR0_WP;
17694 +}
17695 +
17696 +static inline unsigned long native_pax_close_kernel(void)
17697 +{
17698 + unsigned long cr0;
17699 +
17700 + cr0 = read_cr0() ^ X86_CR0_WP;
17701 + BUG_ON(!(cr0 & X86_CR0_WP));
17702 + write_cr0(cr0);
17703 + barrier();
17704 + preempt_enable_no_resched();
17705 + return cr0 ^ X86_CR0_WP;
17706 +}
17707 +#else
17708 +static inline unsigned long native_pax_open_kernel(void) { return 0; }
17709 +static inline unsigned long native_pax_close_kernel(void) { return 0; }
17710 +#endif
17711 +
17712 /*
17713 * The following only work if pte_present() is true.
17714 * Undefined behaviour if not..
17715 */
17716 +static inline int pte_user(pte_t pte)
17717 +{
17718 + return pte_val(pte) & _PAGE_USER;
17719 +}
17720 +
17721 static inline int pte_dirty(pte_t pte)
17722 {
17723 return pte_flags(pte) & _PAGE_DIRTY;
17724 @@ -149,6 +189,11 @@ static inline unsigned long pud_pfn(pud_t pud)
17725 return (pud_val(pud) & PTE_PFN_MASK) >> PAGE_SHIFT;
17726 }
17727
17728 +static inline unsigned long pgd_pfn(pgd_t pgd)
17729 +{
17730 + return (pgd_val(pgd) & PTE_PFN_MASK) >> PAGE_SHIFT;
17731 +}
17732 +
17733 #define pte_page(pte) pfn_to_page(pte_pfn(pte))
17734
17735 static inline int pmd_large(pmd_t pte)
17736 @@ -202,9 +247,29 @@ static inline pte_t pte_wrprotect(pte_t pte)
17737 return pte_clear_flags(pte, _PAGE_RW);
17738 }
17739
17740 +static inline pte_t pte_mkread(pte_t pte)
17741 +{
17742 + return __pte(pte_val(pte) | _PAGE_USER);
17743 +}
17744 +
17745 static inline pte_t pte_mkexec(pte_t pte)
17746 {
17747 - return pte_clear_flags(pte, _PAGE_NX);
17748 +#ifdef CONFIG_X86_PAE
17749 + if (__supported_pte_mask & _PAGE_NX)
17750 + return pte_clear_flags(pte, _PAGE_NX);
17751 + else
17752 +#endif
17753 + return pte_set_flags(pte, _PAGE_USER);
17754 +}
17755 +
17756 +static inline pte_t pte_exprotect(pte_t pte)
17757 +{
17758 +#ifdef CONFIG_X86_PAE
17759 + if (__supported_pte_mask & _PAGE_NX)
17760 + return pte_set_flags(pte, _PAGE_NX);
17761 + else
17762 +#endif
17763 + return pte_clear_flags(pte, _PAGE_USER);
17764 }
17765
17766 static inline pte_t pte_mkdirty(pte_t pte)
17767 @@ -431,6 +496,16 @@ pte_t *populate_extra_pte(unsigned long vaddr);
17768 #endif
17769
17770 #ifndef __ASSEMBLY__
17771 +
17772 +#ifdef CONFIG_PAX_PER_CPU_PGD
17773 +extern pgd_t cpu_pgd[NR_CPUS][2][PTRS_PER_PGD];
17774 +enum cpu_pgd_type {kernel = 0, user = 1};
17775 +static inline pgd_t *get_cpu_pgd(unsigned int cpu, enum cpu_pgd_type type)
17776 +{
17777 + return cpu_pgd[cpu][type];
17778 +}
17779 +#endif
17780 +
17781 #include <linux/mm_types.h>
17782 #include <linux/mmdebug.h>
17783 #include <linux/log2.h>
17784 @@ -571,7 +646,7 @@ static inline unsigned long pud_page_vaddr(pud_t pud)
17785 * Currently stuck as a macro due to indirect forward reference to
17786 * linux/mmzone.h's __section_mem_map_addr() definition:
17787 */
17788 -#define pud_page(pud) pfn_to_page(pud_val(pud) >> PAGE_SHIFT)
17789 +#define pud_page(pud) pfn_to_page((pud_val(pud) & PTE_PFN_MASK) >> PAGE_SHIFT)
17790
17791 /* Find an entry in the second-level page table.. */
17792 static inline pmd_t *pmd_offset(pud_t *pud, unsigned long address)
17793 @@ -611,7 +686,7 @@ static inline unsigned long pgd_page_vaddr(pgd_t pgd)
17794 * Currently stuck as a macro due to indirect forward reference to
17795 * linux/mmzone.h's __section_mem_map_addr() definition:
17796 */
17797 -#define pgd_page(pgd) pfn_to_page(pgd_val(pgd) >> PAGE_SHIFT)
17798 +#define pgd_page(pgd) pfn_to_page((pgd_val(pgd) & PTE_PFN_MASK) >> PAGE_SHIFT)
17799
17800 /* to find an entry in a page-table-directory. */
17801 static inline unsigned long pud_index(unsigned long address)
17802 @@ -626,7 +701,7 @@ static inline pud_t *pud_offset(pgd_t *pgd, unsigned long address)
17803
17804 static inline int pgd_bad(pgd_t pgd)
17805 {
17806 - return (pgd_flags(pgd) & ~_PAGE_USER) != _KERNPG_TABLE;
17807 + return (pgd_flags(pgd) & ~(_PAGE_USER | _PAGE_NX)) != _KERNPG_TABLE;
17808 }
17809
17810 static inline int pgd_none(pgd_t pgd)
17811 @@ -649,7 +724,12 @@ static inline int pgd_none(pgd_t pgd)
17812 * pgd_offset() returns a (pgd_t *)
17813 * pgd_index() is used get the offset into the pgd page's array of pgd_t's;
17814 */
17815 -#define pgd_offset(mm, address) ((mm)->pgd + pgd_index((address)))
17816 +#define pgd_offset(mm, address) ((mm)->pgd + pgd_index(address))
17817 +
17818 +#ifdef CONFIG_PAX_PER_CPU_PGD
17819 +#define pgd_offset_cpu(cpu, type, address) (get_cpu_pgd(cpu, type) + pgd_index(address))
17820 +#endif
17821 +
17822 /*
17823 * a shortcut which implies the use of the kernel's pgd, instead
17824 * of a process's
17825 @@ -660,6 +740,23 @@ static inline int pgd_none(pgd_t pgd)
17826 #define KERNEL_PGD_BOUNDARY pgd_index(PAGE_OFFSET)
17827 #define KERNEL_PGD_PTRS (PTRS_PER_PGD - KERNEL_PGD_BOUNDARY)
17828
17829 +#ifdef CONFIG_X86_32
17830 +#define USER_PGD_PTRS KERNEL_PGD_BOUNDARY
17831 +#else
17832 +#define TASK_SIZE_MAX_SHIFT CONFIG_TASK_SIZE_MAX_SHIFT
17833 +#define USER_PGD_PTRS (_AC(1,UL) << (TASK_SIZE_MAX_SHIFT - PGDIR_SHIFT))
17834 +
17835 +#ifdef CONFIG_PAX_MEMORY_UDEREF
17836 +#ifdef __ASSEMBLY__
17837 +#define pax_user_shadow_base pax_user_shadow_base(%rip)
17838 +#else
17839 +extern unsigned long pax_user_shadow_base;
17840 +extern pgdval_t clone_pgd_mask;
17841 +#endif
17842 +#endif
17843 +
17844 +#endif
17845 +
17846 #ifndef __ASSEMBLY__
17847
17848 extern int direct_gbpages;
17849 @@ -826,11 +923,24 @@ static inline void pmdp_set_wrprotect(struct mm_struct *mm,
17850 * dst and src can be on the same page, but the range must not overlap,
17851 * and must not cross a page boundary.
17852 */
17853 -static inline void clone_pgd_range(pgd_t *dst, pgd_t *src, int count)
17854 +static inline void clone_pgd_range(pgd_t *dst, const pgd_t *src, int count)
17855 {
17856 - memcpy(dst, src, count * sizeof(pgd_t));
17857 + pax_open_kernel();
17858 + while (count--)
17859 + *dst++ = *src++;
17860 + pax_close_kernel();
17861 }
17862
17863 +#ifdef CONFIG_PAX_PER_CPU_PGD
17864 +extern void __clone_user_pgds(pgd_t *dst, const pgd_t *src);
17865 +#endif
17866 +
17867 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
17868 +extern void __shadow_user_pgds(pgd_t *dst, const pgd_t *src);
17869 +#else
17870 +static inline void __shadow_user_pgds(pgd_t *dst, const pgd_t *src) {}
17871 +#endif
17872 +
17873 #define PTE_SHIFT ilog2(PTRS_PER_PTE)
17874 static inline int page_level_shift(enum pg_level level)
17875 {
17876 diff --git a/arch/x86/include/asm/pgtable_32.h b/arch/x86/include/asm/pgtable_32.h
17877 index 9ee3221..b979c6b 100644
17878 --- a/arch/x86/include/asm/pgtable_32.h
17879 +++ b/arch/x86/include/asm/pgtable_32.h
17880 @@ -25,9 +25,6 @@
17881 struct mm_struct;
17882 struct vm_area_struct;
17883
17884 -extern pgd_t swapper_pg_dir[1024];
17885 -extern pgd_t initial_page_table[1024];
17886 -
17887 static inline void pgtable_cache_init(void) { }
17888 static inline void check_pgt_cache(void) { }
17889 void paging_init(void);
17890 @@ -48,6 +45,12 @@ extern void set_pmd_pfn(unsigned long, unsigned long, pgprot_t);
17891 # include <asm/pgtable-2level.h>
17892 #endif
17893
17894 +extern pgd_t swapper_pg_dir[PTRS_PER_PGD];
17895 +extern pgd_t initial_page_table[PTRS_PER_PGD];
17896 +#ifdef CONFIG_X86_PAE
17897 +extern pmd_t swapper_pm_dir[PTRS_PER_PGD][PTRS_PER_PMD];
17898 +#endif
17899 +
17900 #if defined(CONFIG_HIGHPTE)
17901 #define pte_offset_map(dir, address) \
17902 ((pte_t *)kmap_atomic(pmd_page(*(dir))) + \
17903 @@ -62,12 +65,17 @@ extern void set_pmd_pfn(unsigned long, unsigned long, pgprot_t);
17904 /* Clear a kernel PTE and flush it from the TLB */
17905 #define kpte_clear_flush(ptep, vaddr) \
17906 do { \
17907 + pax_open_kernel(); \
17908 pte_clear(&init_mm, (vaddr), (ptep)); \
17909 + pax_close_kernel(); \
17910 __flush_tlb_one((vaddr)); \
17911 } while (0)
17912
17913 #endif /* !__ASSEMBLY__ */
17914
17915 +#define HAVE_ARCH_UNMAPPED_AREA
17916 +#define HAVE_ARCH_UNMAPPED_AREA_TOPDOWN
17917 +
17918 /*
17919 * kern_addr_valid() is (1) for FLATMEM and (0) for
17920 * SPARSEMEM and DISCONTIGMEM
17921 diff --git a/arch/x86/include/asm/pgtable_32_types.h b/arch/x86/include/asm/pgtable_32_types.h
17922 index ed5903b..c7fe163 100644
17923 --- a/arch/x86/include/asm/pgtable_32_types.h
17924 +++ b/arch/x86/include/asm/pgtable_32_types.h
17925 @@ -8,7 +8,7 @@
17926 */
17927 #ifdef CONFIG_X86_PAE
17928 # include <asm/pgtable-3level_types.h>
17929 -# define PMD_SIZE (1UL << PMD_SHIFT)
17930 +# define PMD_SIZE (_AC(1, UL) << PMD_SHIFT)
17931 # define PMD_MASK (~(PMD_SIZE - 1))
17932 #else
17933 # include <asm/pgtable-2level_types.h>
17934 @@ -46,6 +46,19 @@ extern bool __vmalloc_start_set; /* set once high_memory is set */
17935 # define VMALLOC_END (FIXADDR_START - 2 * PAGE_SIZE)
17936 #endif
17937
17938 +#ifdef CONFIG_PAX_KERNEXEC
17939 +#ifndef __ASSEMBLY__
17940 +extern unsigned char MODULES_EXEC_VADDR[];
17941 +extern unsigned char MODULES_EXEC_END[];
17942 +#endif
17943 +#include <asm/boot.h>
17944 +#define ktla_ktva(addr) (addr + LOAD_PHYSICAL_ADDR + PAGE_OFFSET)
17945 +#define ktva_ktla(addr) (addr - LOAD_PHYSICAL_ADDR - PAGE_OFFSET)
17946 +#else
17947 +#define ktla_ktva(addr) (addr)
17948 +#define ktva_ktla(addr) (addr)
17949 +#endif
17950 +
17951 #define MODULES_VADDR VMALLOC_START
17952 #define MODULES_END VMALLOC_END
17953 #define MODULES_LEN (MODULES_VADDR - MODULES_END)
17954 diff --git a/arch/x86/include/asm/pgtable_64.h b/arch/x86/include/asm/pgtable_64.h
17955 index e22c1db..23a625a 100644
17956 --- a/arch/x86/include/asm/pgtable_64.h
17957 +++ b/arch/x86/include/asm/pgtable_64.h
17958 @@ -16,10 +16,14 @@
17959
17960 extern pud_t level3_kernel_pgt[512];
17961 extern pud_t level3_ident_pgt[512];
17962 +extern pud_t level3_vmalloc_start_pgt[512];
17963 +extern pud_t level3_vmalloc_end_pgt[512];
17964 +extern pud_t level3_vmemmap_pgt[512];
17965 +extern pud_t level2_vmemmap_pgt[512];
17966 extern pmd_t level2_kernel_pgt[512];
17967 extern pmd_t level2_fixmap_pgt[512];
17968 -extern pmd_t level2_ident_pgt[512];
17969 -extern pgd_t init_level4_pgt[];
17970 +extern pmd_t level2_ident_pgt[512*2];
17971 +extern pgd_t init_level4_pgt[512];
17972
17973 #define swapper_pg_dir init_level4_pgt
17974
17975 @@ -61,7 +65,9 @@ static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte)
17976
17977 static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
17978 {
17979 + pax_open_kernel();
17980 *pmdp = pmd;
17981 + pax_close_kernel();
17982 }
17983
17984 static inline void native_pmd_clear(pmd_t *pmd)
17985 @@ -97,7 +103,9 @@ static inline pmd_t native_pmdp_get_and_clear(pmd_t *xp)
17986
17987 static inline void native_set_pud(pud_t *pudp, pud_t pud)
17988 {
17989 + pax_open_kernel();
17990 *pudp = pud;
17991 + pax_close_kernel();
17992 }
17993
17994 static inline void native_pud_clear(pud_t *pud)
17995 @@ -107,6 +115,13 @@ static inline void native_pud_clear(pud_t *pud)
17996
17997 static inline void native_set_pgd(pgd_t *pgdp, pgd_t pgd)
17998 {
17999 + pax_open_kernel();
18000 + *pgdp = pgd;
18001 + pax_close_kernel();
18002 +}
18003 +
18004 +static inline void native_set_pgd_batched(pgd_t *pgdp, pgd_t pgd)
18005 +{
18006 *pgdp = pgd;
18007 }
18008
18009 diff --git a/arch/x86/include/asm/pgtable_64_types.h b/arch/x86/include/asm/pgtable_64_types.h
18010 index c883bf7..19970b3 100644
18011 --- a/arch/x86/include/asm/pgtable_64_types.h
18012 +++ b/arch/x86/include/asm/pgtable_64_types.h
18013 @@ -61,6 +61,11 @@ typedef struct { pteval_t pte; } pte_t;
18014 #define MODULES_VADDR (__START_KERNEL_map + KERNEL_IMAGE_SIZE)
18015 #define MODULES_END _AC(0xffffffffff000000, UL)
18016 #define MODULES_LEN (MODULES_END - MODULES_VADDR)
18017 +#define MODULES_EXEC_VADDR MODULES_VADDR
18018 +#define MODULES_EXEC_END MODULES_END
18019 +
18020 +#define ktla_ktva(addr) (addr)
18021 +#define ktva_ktla(addr) (addr)
18022
18023 #define EARLY_DYNAMIC_PAGE_TABLES 64
18024
18025 diff --git a/arch/x86/include/asm/pgtable_types.h b/arch/x86/include/asm/pgtable_types.h
18026 index eb3d449..8d95316 100644
18027 --- a/arch/x86/include/asm/pgtable_types.h
18028 +++ b/arch/x86/include/asm/pgtable_types.h
18029 @@ -16,13 +16,12 @@
18030 #define _PAGE_BIT_PSE 7 /* 4 MB (or 2MB) page */
18031 #define _PAGE_BIT_PAT 7 /* on 4KB pages */
18032 #define _PAGE_BIT_GLOBAL 8 /* Global TLB entry PPro+ */
18033 -#define _PAGE_BIT_UNUSED1 9 /* available for programmer */
18034 +#define _PAGE_BIT_SPECIAL 9 /* special mappings, no associated struct page */
18035 #define _PAGE_BIT_IOMAP 10 /* flag used to indicate IO mapping */
18036 #define _PAGE_BIT_HIDDEN 11 /* hidden by kmemcheck */
18037 #define _PAGE_BIT_PAT_LARGE 12 /* On 2MB or 1GB pages */
18038 -#define _PAGE_BIT_SPECIAL _PAGE_BIT_UNUSED1
18039 -#define _PAGE_BIT_CPA_TEST _PAGE_BIT_UNUSED1
18040 -#define _PAGE_BIT_SPLITTING _PAGE_BIT_UNUSED1 /* only valid on a PSE pmd */
18041 +#define _PAGE_BIT_CPA_TEST _PAGE_BIT_SPECIAL
18042 +#define _PAGE_BIT_SPLITTING _PAGE_BIT_SPECIAL /* only valid on a PSE pmd */
18043 #define _PAGE_BIT_NX 63 /* No execute: only valid after cpuid check */
18044
18045 /* If _PAGE_BIT_PRESENT is clear, we use these: */
18046 @@ -40,7 +39,6 @@
18047 #define _PAGE_DIRTY (_AT(pteval_t, 1) << _PAGE_BIT_DIRTY)
18048 #define _PAGE_PSE (_AT(pteval_t, 1) << _PAGE_BIT_PSE)
18049 #define _PAGE_GLOBAL (_AT(pteval_t, 1) << _PAGE_BIT_GLOBAL)
18050 -#define _PAGE_UNUSED1 (_AT(pteval_t, 1) << _PAGE_BIT_UNUSED1)
18051 #define _PAGE_IOMAP (_AT(pteval_t, 1) << _PAGE_BIT_IOMAP)
18052 #define _PAGE_PAT (_AT(pteval_t, 1) << _PAGE_BIT_PAT)
18053 #define _PAGE_PAT_LARGE (_AT(pteval_t, 1) << _PAGE_BIT_PAT_LARGE)
18054 @@ -87,8 +85,10 @@
18055
18056 #if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
18057 #define _PAGE_NX (_AT(pteval_t, 1) << _PAGE_BIT_NX)
18058 -#else
18059 +#elif defined(CONFIG_KMEMCHECK) || defined(CONFIG_MEM_SOFT_DIRTY)
18060 #define _PAGE_NX (_AT(pteval_t, 0))
18061 +#else
18062 +#define _PAGE_NX (_AT(pteval_t, 1) << _PAGE_BIT_HIDDEN)
18063 #endif
18064
18065 #define _PAGE_FILE (_AT(pteval_t, 1) << _PAGE_BIT_FILE)
18066 @@ -147,6 +147,9 @@
18067 #define PAGE_READONLY_EXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | \
18068 _PAGE_ACCESSED)
18069
18070 +#define PAGE_READONLY_NOEXEC PAGE_READONLY
18071 +#define PAGE_SHARED_NOEXEC PAGE_SHARED
18072 +
18073 #define __PAGE_KERNEL_EXEC \
18074 (_PAGE_PRESENT | _PAGE_RW | _PAGE_DIRTY | _PAGE_ACCESSED | _PAGE_GLOBAL)
18075 #define __PAGE_KERNEL (__PAGE_KERNEL_EXEC | _PAGE_NX)
18076 @@ -157,7 +160,7 @@
18077 #define __PAGE_KERNEL_WC (__PAGE_KERNEL | _PAGE_CACHE_WC)
18078 #define __PAGE_KERNEL_NOCACHE (__PAGE_KERNEL | _PAGE_PCD | _PAGE_PWT)
18079 #define __PAGE_KERNEL_UC_MINUS (__PAGE_KERNEL | _PAGE_PCD)
18080 -#define __PAGE_KERNEL_VSYSCALL (__PAGE_KERNEL_RX | _PAGE_USER)
18081 +#define __PAGE_KERNEL_VSYSCALL (__PAGE_KERNEL_RO | _PAGE_USER)
18082 #define __PAGE_KERNEL_VVAR (__PAGE_KERNEL_RO | _PAGE_USER)
18083 #define __PAGE_KERNEL_VVAR_NOCACHE (__PAGE_KERNEL_VVAR | _PAGE_PCD | _PAGE_PWT)
18084 #define __PAGE_KERNEL_LARGE (__PAGE_KERNEL | _PAGE_PSE)
18085 @@ -214,7 +217,7 @@
18086 #ifdef CONFIG_X86_64
18087 #define __PAGE_KERNEL_IDENT_LARGE_EXEC __PAGE_KERNEL_LARGE_EXEC
18088 #else
18089 -#define PTE_IDENT_ATTR 0x003 /* PRESENT+RW */
18090 +#define PTE_IDENT_ATTR 0x063 /* PRESENT+RW+DIRTY+ACCESSED */
18091 #define PDE_IDENT_ATTR 0x063 /* PRESENT+RW+DIRTY+ACCESSED */
18092 #define PGD_IDENT_ATTR 0x001 /* PRESENT (no other attributes) */
18093 #endif
18094 @@ -253,7 +256,17 @@ static inline pgdval_t pgd_flags(pgd_t pgd)
18095 {
18096 return native_pgd_val(pgd) & PTE_FLAGS_MASK;
18097 }
18098 +#endif
18099
18100 +#if PAGETABLE_LEVELS == 3
18101 +#include <asm-generic/pgtable-nopud.h>
18102 +#endif
18103 +
18104 +#if PAGETABLE_LEVELS == 2
18105 +#include <asm-generic/pgtable-nopmd.h>
18106 +#endif
18107 +
18108 +#ifndef __ASSEMBLY__
18109 #if PAGETABLE_LEVELS > 3
18110 typedef struct { pudval_t pud; } pud_t;
18111
18112 @@ -267,8 +280,6 @@ static inline pudval_t native_pud_val(pud_t pud)
18113 return pud.pud;
18114 }
18115 #else
18116 -#include <asm-generic/pgtable-nopud.h>
18117 -
18118 static inline pudval_t native_pud_val(pud_t pud)
18119 {
18120 return native_pgd_val(pud.pgd);
18121 @@ -288,8 +299,6 @@ static inline pmdval_t native_pmd_val(pmd_t pmd)
18122 return pmd.pmd;
18123 }
18124 #else
18125 -#include <asm-generic/pgtable-nopmd.h>
18126 -
18127 static inline pmdval_t native_pmd_val(pmd_t pmd)
18128 {
18129 return native_pgd_val(pmd.pud.pgd);
18130 @@ -329,7 +338,6 @@ typedef struct page *pgtable_t;
18131
18132 extern pteval_t __supported_pte_mask;
18133 extern void set_nx(void);
18134 -extern int nx_enabled;
18135
18136 #define pgprot_writecombine pgprot_writecombine
18137 extern pgprot_t pgprot_writecombine(pgprot_t prot);
18138 diff --git a/arch/x86/include/asm/preempt.h b/arch/x86/include/asm/preempt.h
18139 index 7024c12..71c46b9 100644
18140 --- a/arch/x86/include/asm/preempt.h
18141 +++ b/arch/x86/include/asm/preempt.h
18142 @@ -87,7 +87,7 @@ static __always_inline void __preempt_count_sub(int val)
18143 */
18144 static __always_inline bool __preempt_count_dec_and_test(void)
18145 {
18146 - GEN_UNARY_RMWcc("decl", __preempt_count, __percpu_arg(0), "e");
18147 + GEN_UNARY_RMWcc("decl", "incl", __preempt_count, __percpu_arg(0), "e");
18148 }
18149
18150 /*
18151 diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h
18152 index a4ea023..33aa874 100644
18153 --- a/arch/x86/include/asm/processor.h
18154 +++ b/arch/x86/include/asm/processor.h
18155 @@ -128,7 +128,7 @@ struct cpuinfo_x86 {
18156 /* Index into per_cpu list: */
18157 u16 cpu_index;
18158 u32 microcode;
18159 -} __attribute__((__aligned__(SMP_CACHE_BYTES)));
18160 +} __attribute__((__aligned__(SMP_CACHE_BYTES))) __randomize_layout;
18161
18162 #define X86_VENDOR_INTEL 0
18163 #define X86_VENDOR_CYRIX 1
18164 @@ -199,9 +199,21 @@ static inline void native_cpuid(unsigned int *eax, unsigned int *ebx,
18165 : "memory");
18166 }
18167
18168 +/* invpcid (%rdx),%rax */
18169 +#define __ASM_INVPCID ".byte 0x66,0x0f,0x38,0x82,0x02"
18170 +
18171 +#define INVPCID_SINGLE_ADDRESS 0UL
18172 +#define INVPCID_SINGLE_CONTEXT 1UL
18173 +#define INVPCID_ALL_GLOBAL 2UL
18174 +#define INVPCID_ALL_MONGLOBAL 3UL
18175 +
18176 +#define PCID_KERNEL 0UL
18177 +#define PCID_USER 1UL
18178 +#define PCID_NOFLUSH (1UL << 63)
18179 +
18180 static inline void load_cr3(pgd_t *pgdir)
18181 {
18182 - write_cr3(__pa(pgdir));
18183 + write_cr3(__pa(pgdir) | PCID_KERNEL);
18184 }
18185
18186 #ifdef CONFIG_X86_32
18187 @@ -283,7 +295,7 @@ struct tss_struct {
18188
18189 } ____cacheline_aligned;
18190
18191 -DECLARE_PER_CPU_SHARED_ALIGNED(struct tss_struct, init_tss);
18192 +extern struct tss_struct init_tss[NR_CPUS];
18193
18194 /*
18195 * Save the original ist values for checking stack pointers during debugging
18196 @@ -479,6 +491,7 @@ struct thread_struct {
18197 unsigned short ds;
18198 unsigned short fsindex;
18199 unsigned short gsindex;
18200 + unsigned short ss;
18201 #endif
18202 #ifdef CONFIG_X86_32
18203 unsigned long ip;
18204 @@ -588,29 +601,8 @@ static inline void load_sp0(struct tss_struct *tss,
18205 extern unsigned long mmu_cr4_features;
18206 extern u32 *trampoline_cr4_features;
18207
18208 -static inline void set_in_cr4(unsigned long mask)
18209 -{
18210 - unsigned long cr4;
18211 -
18212 - mmu_cr4_features |= mask;
18213 - if (trampoline_cr4_features)
18214 - *trampoline_cr4_features = mmu_cr4_features;
18215 - cr4 = read_cr4();
18216 - cr4 |= mask;
18217 - write_cr4(cr4);
18218 -}
18219 -
18220 -static inline void clear_in_cr4(unsigned long mask)
18221 -{
18222 - unsigned long cr4;
18223 -
18224 - mmu_cr4_features &= ~mask;
18225 - if (trampoline_cr4_features)
18226 - *trampoline_cr4_features = mmu_cr4_features;
18227 - cr4 = read_cr4();
18228 - cr4 &= ~mask;
18229 - write_cr4(cr4);
18230 -}
18231 +extern void set_in_cr4(unsigned long mask);
18232 +extern void clear_in_cr4(unsigned long mask);
18233
18234 typedef struct {
18235 unsigned long seg;
18236 @@ -836,11 +828,18 @@ static inline void spin_lock_prefetch(const void *x)
18237 */
18238 #define TASK_SIZE PAGE_OFFSET
18239 #define TASK_SIZE_MAX TASK_SIZE
18240 +
18241 +#ifdef CONFIG_PAX_SEGMEXEC
18242 +#define SEGMEXEC_TASK_SIZE (TASK_SIZE / 2)
18243 +#define STACK_TOP ((current->mm->pax_flags & MF_PAX_SEGMEXEC)?SEGMEXEC_TASK_SIZE:TASK_SIZE)
18244 +#else
18245 #define STACK_TOP TASK_SIZE
18246 -#define STACK_TOP_MAX STACK_TOP
18247 +#endif
18248 +
18249 +#define STACK_TOP_MAX TASK_SIZE
18250
18251 #define INIT_THREAD { \
18252 - .sp0 = sizeof(init_stack) + (long)&init_stack, \
18253 + .sp0 = sizeof(init_stack) + (long)&init_stack - 8, \
18254 .vm86_info = NULL, \
18255 .sysenter_cs = __KERNEL_CS, \
18256 .io_bitmap_ptr = NULL, \
18257 @@ -854,7 +853,7 @@ static inline void spin_lock_prefetch(const void *x)
18258 */
18259 #define INIT_TSS { \
18260 .x86_tss = { \
18261 - .sp0 = sizeof(init_stack) + (long)&init_stack, \
18262 + .sp0 = sizeof(init_stack) + (long)&init_stack - 8, \
18263 .ss0 = __KERNEL_DS, \
18264 .ss1 = __KERNEL_CS, \
18265 .io_bitmap_base = INVALID_IO_BITMAP_OFFSET, \
18266 @@ -865,11 +864,7 @@ static inline void spin_lock_prefetch(const void *x)
18267 extern unsigned long thread_saved_pc(struct task_struct *tsk);
18268
18269 #define THREAD_SIZE_LONGS (THREAD_SIZE/sizeof(unsigned long))
18270 -#define KSTK_TOP(info) \
18271 -({ \
18272 - unsigned long *__ptr = (unsigned long *)(info); \
18273 - (unsigned long)(&__ptr[THREAD_SIZE_LONGS]); \
18274 -})
18275 +#define KSTK_TOP(info) ((container_of(info, struct task_struct, tinfo))->thread.sp0)
18276
18277 /*
18278 * The below -8 is to reserve 8 bytes on top of the ring0 stack.
18279 @@ -884,7 +879,7 @@ extern unsigned long thread_saved_pc(struct task_struct *tsk);
18280 #define task_pt_regs(task) \
18281 ({ \
18282 struct pt_regs *__regs__; \
18283 - __regs__ = (struct pt_regs *)(KSTK_TOP(task_stack_page(task))-8); \
18284 + __regs__ = (struct pt_regs *)((task)->thread.sp0); \
18285 __regs__ - 1; \
18286 })
18287
18288 @@ -894,13 +889,13 @@ extern unsigned long thread_saved_pc(struct task_struct *tsk);
18289 /*
18290 * User space process size. 47bits minus one guard page.
18291 */
18292 -#define TASK_SIZE_MAX ((1UL << 47) - PAGE_SIZE)
18293 +#define TASK_SIZE_MAX ((1UL << TASK_SIZE_MAX_SHIFT) - PAGE_SIZE)
18294
18295 /* This decides where the kernel will search for a free chunk of vm
18296 * space during mmap's.
18297 */
18298 #define IA32_PAGE_OFFSET ((current->personality & ADDR_LIMIT_3GB) ? \
18299 - 0xc0000000 : 0xFFFFe000)
18300 + 0xc0000000 : 0xFFFFf000)
18301
18302 #define TASK_SIZE (test_thread_flag(TIF_ADDR32) ? \
18303 IA32_PAGE_OFFSET : TASK_SIZE_MAX)
18304 @@ -911,11 +906,11 @@ extern unsigned long thread_saved_pc(struct task_struct *tsk);
18305 #define STACK_TOP_MAX TASK_SIZE_MAX
18306
18307 #define INIT_THREAD { \
18308 - .sp0 = (unsigned long)&init_stack + sizeof(init_stack) \
18309 + .sp0 = (unsigned long)&init_stack + sizeof(init_stack) - 16 \
18310 }
18311
18312 #define INIT_TSS { \
18313 - .x86_tss.sp0 = (unsigned long)&init_stack + sizeof(init_stack) \
18314 + .x86_tss.sp0 = (unsigned long)&init_stack + sizeof(init_stack) - 16 \
18315 }
18316
18317 /*
18318 @@ -943,6 +938,10 @@ extern void start_thread(struct pt_regs *regs, unsigned long new_ip,
18319 */
18320 #define TASK_UNMAPPED_BASE (PAGE_ALIGN(TASK_SIZE / 3))
18321
18322 +#ifdef CONFIG_PAX_SEGMEXEC
18323 +#define SEGMEXEC_TASK_UNMAPPED_BASE (PAGE_ALIGN(SEGMEXEC_TASK_SIZE / 3))
18324 +#endif
18325 +
18326 #define KSTK_EIP(task) (task_pt_regs(task)->ip)
18327
18328 /* Get/set a process' ability to use the timestamp counter instruction */
18329 @@ -969,7 +968,7 @@ static inline uint32_t hypervisor_cpuid_base(const char *sig, uint32_t leaves)
18330 return 0;
18331 }
18332
18333 -extern unsigned long arch_align_stack(unsigned long sp);
18334 +#define arch_align_stack(x) ((x) & ~0xfUL)
18335 extern void free_init_pages(char *what, unsigned long begin, unsigned long end);
18336
18337 void default_idle(void);
18338 @@ -979,6 +978,6 @@ bool xen_set_default_idle(void);
18339 #define xen_set_default_idle 0
18340 #endif
18341
18342 -void stop_this_cpu(void *dummy);
18343 +void stop_this_cpu(void *dummy) __noreturn;
18344 void df_debug(struct pt_regs *regs, long error_code);
18345 #endif /* _ASM_X86_PROCESSOR_H */
18346 diff --git a/arch/x86/include/asm/ptrace.h b/arch/x86/include/asm/ptrace.h
18347 index 14fd6fd..6740420 100644
18348 --- a/arch/x86/include/asm/ptrace.h
18349 +++ b/arch/x86/include/asm/ptrace.h
18350 @@ -84,28 +84,29 @@ static inline unsigned long regs_return_value(struct pt_regs *regs)
18351 }
18352
18353 /*
18354 - * user_mode_vm(regs) determines whether a register set came from user mode.
18355 + * user_mode(regs) determines whether a register set came from user mode.
18356 * This is true if V8086 mode was enabled OR if the register set was from
18357 * protected mode with RPL-3 CS value. This tricky test checks that with
18358 * one comparison. Many places in the kernel can bypass this full check
18359 - * if they have already ruled out V8086 mode, so user_mode(regs) can be used.
18360 + * if they have already ruled out V8086 mode, so user_mode_novm(regs) can
18361 + * be used.
18362 */
18363 -static inline int user_mode(struct pt_regs *regs)
18364 +static inline int user_mode_novm(struct pt_regs *regs)
18365 {
18366 #ifdef CONFIG_X86_32
18367 return (regs->cs & SEGMENT_RPL_MASK) == USER_RPL;
18368 #else
18369 - return !!(regs->cs & 3);
18370 + return !!(regs->cs & SEGMENT_RPL_MASK);
18371 #endif
18372 }
18373
18374 -static inline int user_mode_vm(struct pt_regs *regs)
18375 +static inline int user_mode(struct pt_regs *regs)
18376 {
18377 #ifdef CONFIG_X86_32
18378 return ((regs->cs & SEGMENT_RPL_MASK) | (regs->flags & X86_VM_MASK)) >=
18379 USER_RPL;
18380 #else
18381 - return user_mode(regs);
18382 + return user_mode_novm(regs);
18383 #endif
18384 }
18385
18386 @@ -121,15 +122,16 @@ static inline int v8086_mode(struct pt_regs *regs)
18387 #ifdef CONFIG_X86_64
18388 static inline bool user_64bit_mode(struct pt_regs *regs)
18389 {
18390 + unsigned long cs = regs->cs & 0xffff;
18391 #ifndef CONFIG_PARAVIRT
18392 /*
18393 * On non-paravirt systems, this is the only long mode CPL 3
18394 * selector. We do not allow long mode selectors in the LDT.
18395 */
18396 - return regs->cs == __USER_CS;
18397 + return cs == __USER_CS;
18398 #else
18399 /* Headers are too twisted for this to go in paravirt.h. */
18400 - return regs->cs == __USER_CS || regs->cs == pv_info.extra_user_64bit_cs;
18401 + return cs == __USER_CS || cs == pv_info.extra_user_64bit_cs;
18402 #endif
18403 }
18404
18405 @@ -180,9 +182,11 @@ static inline unsigned long regs_get_register(struct pt_regs *regs,
18406 * Traps from the kernel do not save sp and ss.
18407 * Use the helper function to retrieve sp.
18408 */
18409 - if (offset == offsetof(struct pt_regs, sp) &&
18410 - regs->cs == __KERNEL_CS)
18411 - return kernel_stack_pointer(regs);
18412 + if (offset == offsetof(struct pt_regs, sp)) {
18413 + unsigned long cs = regs->cs & 0xffff;
18414 + if (cs == __KERNEL_CS || cs == __KERNEXEC_KERNEL_CS)
18415 + return kernel_stack_pointer(regs);
18416 + }
18417 #endif
18418 return *(unsigned long *)((unsigned long)regs + offset);
18419 }
18420 diff --git a/arch/x86/include/asm/realmode.h b/arch/x86/include/asm/realmode.h
18421 index 9c6b890..5305f53 100644
18422 --- a/arch/x86/include/asm/realmode.h
18423 +++ b/arch/x86/include/asm/realmode.h
18424 @@ -22,16 +22,14 @@ struct real_mode_header {
18425 #endif
18426 /* APM/BIOS reboot */
18427 u32 machine_real_restart_asm;
18428 -#ifdef CONFIG_X86_64
18429 u32 machine_real_restart_seg;
18430 -#endif
18431 };
18432
18433 /* This must match data at trampoline_32/64.S */
18434 struct trampoline_header {
18435 #ifdef CONFIG_X86_32
18436 u32 start;
18437 - u16 gdt_pad;
18438 + u16 boot_cs;
18439 u16 gdt_limit;
18440 u32 gdt_base;
18441 #else
18442 diff --git a/arch/x86/include/asm/reboot.h b/arch/x86/include/asm/reboot.h
18443 index a82c4f1..ac45053 100644
18444 --- a/arch/x86/include/asm/reboot.h
18445 +++ b/arch/x86/include/asm/reboot.h
18446 @@ -6,13 +6,13 @@
18447 struct pt_regs;
18448
18449 struct machine_ops {
18450 - void (*restart)(char *cmd);
18451 - void (*halt)(void);
18452 - void (*power_off)(void);
18453 + void (* __noreturn restart)(char *cmd);
18454 + void (* __noreturn halt)(void);
18455 + void (* __noreturn power_off)(void);
18456 void (*shutdown)(void);
18457 void (*crash_shutdown)(struct pt_regs *);
18458 - void (*emergency_restart)(void);
18459 -};
18460 + void (* __noreturn emergency_restart)(void);
18461 +} __no_const;
18462
18463 extern struct machine_ops machine_ops;
18464
18465 diff --git a/arch/x86/include/asm/rmwcc.h b/arch/x86/include/asm/rmwcc.h
18466 index 8f7866a..e442f20 100644
18467 --- a/arch/x86/include/asm/rmwcc.h
18468 +++ b/arch/x86/include/asm/rmwcc.h
18469 @@ -3,7 +3,34 @@
18470
18471 #ifdef CC_HAVE_ASM_GOTO
18472
18473 -#define __GEN_RMWcc(fullop, var, cc, ...) \
18474 +#ifdef CONFIG_PAX_REFCOUNT
18475 +#define __GEN_RMWcc(fullop, fullantiop, var, cc, ...) \
18476 +do { \
18477 + asm_volatile_goto (fullop \
18478 + ";jno 0f\n" \
18479 + fullantiop \
18480 + ";int $4\n0:\n" \
18481 + _ASM_EXTABLE(0b, 0b) \
18482 + ";j" cc " %l[cc_label]" \
18483 + : : "m" (var), ## __VA_ARGS__ \
18484 + : "memory" : cc_label); \
18485 + return 0; \
18486 +cc_label: \
18487 + return 1; \
18488 +} while (0)
18489 +#else
18490 +#define __GEN_RMWcc(fullop, fullantiop, var, cc, ...) \
18491 +do { \
18492 + asm_volatile_goto (fullop ";j" cc " %l[cc_label]" \
18493 + : : "m" (var), ## __VA_ARGS__ \
18494 + : "memory" : cc_label); \
18495 + return 0; \
18496 +cc_label: \
18497 + return 1; \
18498 +} while (0)
18499 +#endif
18500 +
18501 +#define __GEN_RMWcc_unchecked(fullop, var, cc, ...) \
18502 do { \
18503 asm_volatile_goto (fullop "; j" cc " %l[cc_label]" \
18504 : : "m" (var), ## __VA_ARGS__ \
18505 @@ -13,15 +40,46 @@ cc_label: \
18506 return 1; \
18507 } while (0)
18508
18509 -#define GEN_UNARY_RMWcc(op, var, arg0, cc) \
18510 - __GEN_RMWcc(op " " arg0, var, cc)
18511 +#define GEN_UNARY_RMWcc(op, antiop, var, arg0, cc) \
18512 + __GEN_RMWcc(op " " arg0, antiop " " arg0, var, cc)
18513
18514 -#define GEN_BINARY_RMWcc(op, var, vcon, val, arg0, cc) \
18515 - __GEN_RMWcc(op " %1, " arg0, var, cc, vcon (val))
18516 +#define GEN_UNARY_RMWcc_unchecked(op, var, arg0, cc) \
18517 + __GEN_RMWcc_unchecked(op " " arg0, var, cc)
18518 +
18519 +#define GEN_BINARY_RMWcc(op, antiop, var, vcon, val, arg0, cc) \
18520 + __GEN_RMWcc(op " %1, " arg0, antiop " %1, " arg0, var, cc, vcon (val))
18521 +
18522 +#define GEN_BINARY_RMWcc_unchecked(op, var, vcon, val, arg0, cc) \
18523 + __GEN_RMWcc_unchecked(op " %1, " arg0, var, cc, vcon (val))
18524
18525 #else /* !CC_HAVE_ASM_GOTO */
18526
18527 -#define __GEN_RMWcc(fullop, var, cc, ...) \
18528 +#ifdef CONFIG_PAX_REFCOUNT
18529 +#define __GEN_RMWcc(fullop, fullantiop, var, cc, ...) \
18530 +do { \
18531 + char c; \
18532 + asm volatile (fullop \
18533 + ";jno 0f\n" \
18534 + fullantiop \
18535 + ";int $4\n0:\n" \
18536 + _ASM_EXTABLE(0b, 0b) \
18537 + "; set" cc " %1" \
18538 + : "+m" (var), "=qm" (c) \
18539 + : __VA_ARGS__ : "memory"); \
18540 + return c != 0; \
18541 +} while (0)
18542 +#else
18543 +#define __GEN_RMWcc(fullop, fullantiop, var, cc, ...) \
18544 +do { \
18545 + char c; \
18546 + asm volatile (fullop "; set" cc " %1" \
18547 + : "+m" (var), "=qm" (c) \
18548 + : __VA_ARGS__ : "memory"); \
18549 + return c != 0; \
18550 +} while (0)
18551 +#endif
18552 +
18553 +#define __GEN_RMWcc_unchecked(fullop, var, cc, ...) \
18554 do { \
18555 char c; \
18556 asm volatile (fullop "; set" cc " %1" \
18557 @@ -30,11 +88,17 @@ do { \
18558 return c != 0; \
18559 } while (0)
18560
18561 -#define GEN_UNARY_RMWcc(op, var, arg0, cc) \
18562 - __GEN_RMWcc(op " " arg0, var, cc)
18563 +#define GEN_UNARY_RMWcc(op, antiop, var, arg0, cc) \
18564 + __GEN_RMWcc(op " " arg0, antiop " " arg0, var, cc)
18565 +
18566 +#define GEN_UNARY_RMWcc_unchecked(op, var, arg0, cc) \
18567 + __GEN_RMWcc_unchecked(op " " arg0, var, cc)
18568 +
18569 +#define GEN_BINARY_RMWcc(op, antiop, var, vcon, val, arg0, cc) \
18570 + __GEN_RMWcc(op " %2, " arg0, antiop " %2, " arg0, var, cc, vcon (val))
18571
18572 -#define GEN_BINARY_RMWcc(op, var, vcon, val, arg0, cc) \
18573 - __GEN_RMWcc(op " %2, " arg0, var, cc, vcon (val))
18574 +#define GEN_BINARY_RMWcc_unchecked(op, var, vcon, val, arg0, cc) \
18575 + __GEN_RMWcc_unchecked(op " %2, " arg0, var, cc, vcon (val))
18576
18577 #endif /* CC_HAVE_ASM_GOTO */
18578
18579 diff --git a/arch/x86/include/asm/rwsem.h b/arch/x86/include/asm/rwsem.h
18580 index cad82c9..2e5c5c1 100644
18581 --- a/arch/x86/include/asm/rwsem.h
18582 +++ b/arch/x86/include/asm/rwsem.h
18583 @@ -64,6 +64,14 @@ static inline void __down_read(struct rw_semaphore *sem)
18584 {
18585 asm volatile("# beginning down_read\n\t"
18586 LOCK_PREFIX _ASM_INC "(%1)\n\t"
18587 +
18588 +#ifdef CONFIG_PAX_REFCOUNT
18589 + "jno 0f\n"
18590 + LOCK_PREFIX _ASM_DEC "(%1)\n"
18591 + "int $4\n0:\n"
18592 + _ASM_EXTABLE(0b, 0b)
18593 +#endif
18594 +
18595 /* adds 0x00000001 */
18596 " jns 1f\n"
18597 " call call_rwsem_down_read_failed\n"
18598 @@ -85,6 +93,14 @@ static inline int __down_read_trylock(struct rw_semaphore *sem)
18599 "1:\n\t"
18600 " mov %1,%2\n\t"
18601 " add %3,%2\n\t"
18602 +
18603 +#ifdef CONFIG_PAX_REFCOUNT
18604 + "jno 0f\n"
18605 + "sub %3,%2\n"
18606 + "int $4\n0:\n"
18607 + _ASM_EXTABLE(0b, 0b)
18608 +#endif
18609 +
18610 " jle 2f\n\t"
18611 LOCK_PREFIX " cmpxchg %2,%0\n\t"
18612 " jnz 1b\n\t"
18613 @@ -104,6 +120,14 @@ static inline void __down_write_nested(struct rw_semaphore *sem, int subclass)
18614 long tmp;
18615 asm volatile("# beginning down_write\n\t"
18616 LOCK_PREFIX " xadd %1,(%2)\n\t"
18617 +
18618 +#ifdef CONFIG_PAX_REFCOUNT
18619 + "jno 0f\n"
18620 + "mov %1,(%2)\n"
18621 + "int $4\n0:\n"
18622 + _ASM_EXTABLE(0b, 0b)
18623 +#endif
18624 +
18625 /* adds 0xffff0001, returns the old value */
18626 " test " __ASM_SEL(%w1,%k1) "," __ASM_SEL(%w1,%k1) "\n\t"
18627 /* was the active mask 0 before? */
18628 @@ -155,6 +179,14 @@ static inline void __up_read(struct rw_semaphore *sem)
18629 long tmp;
18630 asm volatile("# beginning __up_read\n\t"
18631 LOCK_PREFIX " xadd %1,(%2)\n\t"
18632 +
18633 +#ifdef CONFIG_PAX_REFCOUNT
18634 + "jno 0f\n"
18635 + "mov %1,(%2)\n"
18636 + "int $4\n0:\n"
18637 + _ASM_EXTABLE(0b, 0b)
18638 +#endif
18639 +
18640 /* subtracts 1, returns the old value */
18641 " jns 1f\n\t"
18642 " call call_rwsem_wake\n" /* expects old value in %edx */
18643 @@ -173,6 +205,14 @@ static inline void __up_write(struct rw_semaphore *sem)
18644 long tmp;
18645 asm volatile("# beginning __up_write\n\t"
18646 LOCK_PREFIX " xadd %1,(%2)\n\t"
18647 +
18648 +#ifdef CONFIG_PAX_REFCOUNT
18649 + "jno 0f\n"
18650 + "mov %1,(%2)\n"
18651 + "int $4\n0:\n"
18652 + _ASM_EXTABLE(0b, 0b)
18653 +#endif
18654 +
18655 /* subtracts 0xffff0001, returns the old value */
18656 " jns 1f\n\t"
18657 " call call_rwsem_wake\n" /* expects old value in %edx */
18658 @@ -190,6 +230,14 @@ static inline void __downgrade_write(struct rw_semaphore *sem)
18659 {
18660 asm volatile("# beginning __downgrade_write\n\t"
18661 LOCK_PREFIX _ASM_ADD "%2,(%1)\n\t"
18662 +
18663 +#ifdef CONFIG_PAX_REFCOUNT
18664 + "jno 0f\n"
18665 + LOCK_PREFIX _ASM_SUB "%2,(%1)\n"
18666 + "int $4\n0:\n"
18667 + _ASM_EXTABLE(0b, 0b)
18668 +#endif
18669 +
18670 /*
18671 * transitions 0xZZZZ0001 -> 0xYYYY0001 (i386)
18672 * 0xZZZZZZZZ00000001 -> 0xYYYYYYYY00000001 (x86_64)
18673 @@ -208,7 +256,15 @@ static inline void __downgrade_write(struct rw_semaphore *sem)
18674 */
18675 static inline void rwsem_atomic_add(long delta, struct rw_semaphore *sem)
18676 {
18677 - asm volatile(LOCK_PREFIX _ASM_ADD "%1,%0"
18678 + asm volatile(LOCK_PREFIX _ASM_ADD "%1,%0\n"
18679 +
18680 +#ifdef CONFIG_PAX_REFCOUNT
18681 + "jno 0f\n"
18682 + LOCK_PREFIX _ASM_SUB "%1,%0\n"
18683 + "int $4\n0:\n"
18684 + _ASM_EXTABLE(0b, 0b)
18685 +#endif
18686 +
18687 : "+m" (sem->count)
18688 : "er" (delta));
18689 }
18690 @@ -218,7 +274,7 @@ static inline void rwsem_atomic_add(long delta, struct rw_semaphore *sem)
18691 */
18692 static inline long rwsem_atomic_update(long delta, struct rw_semaphore *sem)
18693 {
18694 - return delta + xadd(&sem->count, delta);
18695 + return delta + xadd_check_overflow(&sem->count, delta);
18696 }
18697
18698 #endif /* __KERNEL__ */
18699 diff --git a/arch/x86/include/asm/segment.h b/arch/x86/include/asm/segment.h
18700 index 6f1c3a8..7744f19 100644
18701 --- a/arch/x86/include/asm/segment.h
18702 +++ b/arch/x86/include/asm/segment.h
18703 @@ -64,10 +64,15 @@
18704 * 26 - ESPFIX small SS
18705 * 27 - per-cpu [ offset to per-cpu data area ]
18706 * 28 - stack_canary-20 [ for stack protector ]
18707 - * 29 - unused
18708 - * 30 - unused
18709 + * 29 - PCI BIOS CS
18710 + * 30 - PCI BIOS DS
18711 * 31 - TSS for double fault handler
18712 */
18713 +#define GDT_ENTRY_KERNEXEC_EFI_CS (1)
18714 +#define GDT_ENTRY_KERNEXEC_EFI_DS (2)
18715 +#define __KERNEXEC_EFI_CS (GDT_ENTRY_KERNEXEC_EFI_CS*8)
18716 +#define __KERNEXEC_EFI_DS (GDT_ENTRY_KERNEXEC_EFI_DS*8)
18717 +
18718 #define GDT_ENTRY_TLS_MIN 6
18719 #define GDT_ENTRY_TLS_MAX (GDT_ENTRY_TLS_MIN + GDT_ENTRY_TLS_ENTRIES - 1)
18720
18721 @@ -79,6 +84,8 @@
18722
18723 #define GDT_ENTRY_KERNEL_CS (GDT_ENTRY_KERNEL_BASE+0)
18724
18725 +#define GDT_ENTRY_KERNEXEC_KERNEL_CS (4)
18726 +
18727 #define GDT_ENTRY_KERNEL_DS (GDT_ENTRY_KERNEL_BASE+1)
18728
18729 #define GDT_ENTRY_TSS (GDT_ENTRY_KERNEL_BASE+4)
18730 @@ -104,6 +111,12 @@
18731 #define __KERNEL_STACK_CANARY 0
18732 #endif
18733
18734 +#define GDT_ENTRY_PCIBIOS_CS (GDT_ENTRY_KERNEL_BASE+17)
18735 +#define __PCIBIOS_CS (GDT_ENTRY_PCIBIOS_CS * 8)
18736 +
18737 +#define GDT_ENTRY_PCIBIOS_DS (GDT_ENTRY_KERNEL_BASE+18)
18738 +#define __PCIBIOS_DS (GDT_ENTRY_PCIBIOS_DS * 8)
18739 +
18740 #define GDT_ENTRY_DOUBLEFAULT_TSS 31
18741
18742 /*
18743 @@ -141,7 +154,7 @@
18744 */
18745
18746 /* Matches PNP_CS32 and PNP_CS16 (they must be consecutive) */
18747 -#define SEGMENT_IS_PNP_CODE(x) (((x) & 0xf4) == GDT_ENTRY_PNPBIOS_BASE * 8)
18748 +#define SEGMENT_IS_PNP_CODE(x) (((x) & 0xFFFCU) == PNP_CS32 || ((x) & 0xFFFCU) == PNP_CS16)
18749
18750
18751 #else
18752 @@ -165,6 +178,8 @@
18753 #define __USER32_CS (GDT_ENTRY_DEFAULT_USER32_CS*8+3)
18754 #define __USER32_DS __USER_DS
18755
18756 +#define GDT_ENTRY_KERNEXEC_KERNEL_CS 7
18757 +
18758 #define GDT_ENTRY_TSS 8 /* needs two entries */
18759 #define GDT_ENTRY_LDT 10 /* needs two entries */
18760 #define GDT_ENTRY_TLS_MIN 12
18761 @@ -173,6 +188,8 @@
18762 #define GDT_ENTRY_PER_CPU 15 /* Abused to load per CPU data from limit */
18763 #define __PER_CPU_SEG (GDT_ENTRY_PER_CPU * 8 + 3)
18764
18765 +#define GDT_ENTRY_UDEREF_KERNEL_DS 16
18766 +
18767 /* TLS indexes for 64bit - hardcoded in arch_prctl */
18768 #define FS_TLS 0
18769 #define GS_TLS 1
18770 @@ -180,12 +197,14 @@
18771 #define GS_TLS_SEL ((GDT_ENTRY_TLS_MIN+GS_TLS)*8 + 3)
18772 #define FS_TLS_SEL ((GDT_ENTRY_TLS_MIN+FS_TLS)*8 + 3)
18773
18774 -#define GDT_ENTRIES 16
18775 +#define GDT_ENTRIES 17
18776
18777 #endif
18778
18779 #define __KERNEL_CS (GDT_ENTRY_KERNEL_CS*8)
18780 +#define __KERNEXEC_KERNEL_CS (GDT_ENTRY_KERNEXEC_KERNEL_CS*8)
18781 #define __KERNEL_DS (GDT_ENTRY_KERNEL_DS*8)
18782 +#define __UDEREF_KERNEL_DS (GDT_ENTRY_UDEREF_KERNEL_DS*8)
18783 #define __USER_DS (GDT_ENTRY_DEFAULT_USER_DS*8+3)
18784 #define __USER_CS (GDT_ENTRY_DEFAULT_USER_CS*8+3)
18785 #ifndef CONFIG_PARAVIRT
18786 @@ -268,7 +287,7 @@ static inline unsigned long get_limit(unsigned long segment)
18787 {
18788 unsigned long __limit;
18789 asm("lsll %1,%0" : "=r" (__limit) : "r" (segment));
18790 - return __limit + 1;
18791 + return __limit;
18792 }
18793
18794 #endif /* !__ASSEMBLY__ */
18795 diff --git a/arch/x86/include/asm/smap.h b/arch/x86/include/asm/smap.h
18796 index 8d3120f..352b440 100644
18797 --- a/arch/x86/include/asm/smap.h
18798 +++ b/arch/x86/include/asm/smap.h
18799 @@ -25,11 +25,40 @@
18800
18801 #include <asm/alternative-asm.h>
18802
18803 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
18804 +#define ASM_PAX_OPEN_USERLAND \
18805 + 661: jmp 663f; \
18806 + .pushsection .altinstr_replacement, "a" ; \
18807 + 662: pushq %rax; nop; \
18808 + .popsection ; \
18809 + .pushsection .altinstructions, "a" ; \
18810 + altinstruction_entry 661b, 662b, X86_FEATURE_STRONGUDEREF, 2, 2;\
18811 + .popsection ; \
18812 + call __pax_open_userland; \
18813 + popq %rax; \
18814 + 663:
18815 +
18816 +#define ASM_PAX_CLOSE_USERLAND \
18817 + 661: jmp 663f; \
18818 + .pushsection .altinstr_replacement, "a" ; \
18819 + 662: pushq %rax; nop; \
18820 + .popsection; \
18821 + .pushsection .altinstructions, "a" ; \
18822 + altinstruction_entry 661b, 662b, X86_FEATURE_STRONGUDEREF, 2, 2;\
18823 + .popsection; \
18824 + call __pax_close_userland; \
18825 + popq %rax; \
18826 + 663:
18827 +#else
18828 +#define ASM_PAX_OPEN_USERLAND
18829 +#define ASM_PAX_CLOSE_USERLAND
18830 +#endif
18831 +
18832 #ifdef CONFIG_X86_SMAP
18833
18834 #define ASM_CLAC \
18835 661: ASM_NOP3 ; \
18836 - .pushsection .altinstr_replacement, "ax" ; \
18837 + .pushsection .altinstr_replacement, "a" ; \
18838 662: __ASM_CLAC ; \
18839 .popsection ; \
18840 .pushsection .altinstructions, "a" ; \
18841 @@ -38,7 +67,7 @@
18842
18843 #define ASM_STAC \
18844 661: ASM_NOP3 ; \
18845 - .pushsection .altinstr_replacement, "ax" ; \
18846 + .pushsection .altinstr_replacement, "a" ; \
18847 662: __ASM_STAC ; \
18848 .popsection ; \
18849 .pushsection .altinstructions, "a" ; \
18850 @@ -56,6 +85,37 @@
18851
18852 #include <asm/alternative.h>
18853
18854 +#define __HAVE_ARCH_PAX_OPEN_USERLAND
18855 +#define __HAVE_ARCH_PAX_CLOSE_USERLAND
18856 +
18857 +extern void __pax_open_userland(void);
18858 +static __always_inline unsigned long pax_open_userland(void)
18859 +{
18860 +
18861 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
18862 + asm volatile(ALTERNATIVE(ASM_NOP5, "call %P[open]", X86_FEATURE_STRONGUDEREF)
18863 + :
18864 + : [open] "i" (__pax_open_userland)
18865 + : "memory", "rax");
18866 +#endif
18867 +
18868 + return 0;
18869 +}
18870 +
18871 +extern void __pax_close_userland(void);
18872 +static __always_inline unsigned long pax_close_userland(void)
18873 +{
18874 +
18875 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
18876 + asm volatile(ALTERNATIVE(ASM_NOP5, "call %P[close]", X86_FEATURE_STRONGUDEREF)
18877 + :
18878 + : [close] "i" (__pax_close_userland)
18879 + : "memory", "rax");
18880 +#endif
18881 +
18882 + return 0;
18883 +}
18884 +
18885 #ifdef CONFIG_X86_SMAP
18886
18887 static __always_inline void clac(void)
18888 diff --git a/arch/x86/include/asm/smp.h b/arch/x86/include/asm/smp.h
18889 index 8cd27e0..7f05ec8 100644
18890 --- a/arch/x86/include/asm/smp.h
18891 +++ b/arch/x86/include/asm/smp.h
18892 @@ -35,7 +35,7 @@ DECLARE_PER_CPU_READ_MOSTLY(cpumask_var_t, cpu_core_map);
18893 /* cpus sharing the last level cache: */
18894 DECLARE_PER_CPU_READ_MOSTLY(cpumask_var_t, cpu_llc_shared_map);
18895 DECLARE_PER_CPU_READ_MOSTLY(u16, cpu_llc_id);
18896 -DECLARE_PER_CPU_READ_MOSTLY(int, cpu_number);
18897 +DECLARE_PER_CPU_READ_MOSTLY(unsigned int, cpu_number);
18898
18899 static inline struct cpumask *cpu_sibling_mask(int cpu)
18900 {
18901 @@ -78,7 +78,7 @@ struct smp_ops {
18902
18903 void (*send_call_func_ipi)(const struct cpumask *mask);
18904 void (*send_call_func_single_ipi)(int cpu);
18905 -};
18906 +} __no_const;
18907
18908 /* Globals due to paravirt */
18909 extern void set_cpu_sibling_map(int cpu);
18910 @@ -190,14 +190,8 @@ extern unsigned disabled_cpus;
18911 extern int safe_smp_processor_id(void);
18912
18913 #elif defined(CONFIG_X86_64_SMP)
18914 -#define raw_smp_processor_id() (this_cpu_read(cpu_number))
18915 -
18916 -#define stack_smp_processor_id() \
18917 -({ \
18918 - struct thread_info *ti; \
18919 - __asm__("andq %%rsp,%0; ":"=r" (ti) : "0" (CURRENT_MASK)); \
18920 - ti->cpu; \
18921 -})
18922 +#define raw_smp_processor_id() (this_cpu_read(cpu_number))
18923 +#define stack_smp_processor_id() raw_smp_processor_id()
18924 #define safe_smp_processor_id() smp_processor_id()
18925
18926 #endif
18927 diff --git a/arch/x86/include/asm/spinlock.h b/arch/x86/include/asm/spinlock.h
18928 index 0f62f54..cb5d0dd 100644
18929 --- a/arch/x86/include/asm/spinlock.h
18930 +++ b/arch/x86/include/asm/spinlock.h
18931 @@ -222,6 +222,14 @@ static inline int arch_write_can_lock(arch_rwlock_t *lock)
18932 static inline void arch_read_lock(arch_rwlock_t *rw)
18933 {
18934 asm volatile(LOCK_PREFIX READ_LOCK_SIZE(dec) " (%0)\n\t"
18935 +
18936 +#ifdef CONFIG_PAX_REFCOUNT
18937 + "jno 0f\n"
18938 + LOCK_PREFIX READ_LOCK_SIZE(inc) " (%0)\n"
18939 + "int $4\n0:\n"
18940 + _ASM_EXTABLE(0b, 0b)
18941 +#endif
18942 +
18943 "jns 1f\n"
18944 "call __read_lock_failed\n\t"
18945 "1:\n"
18946 @@ -231,6 +239,14 @@ static inline void arch_read_lock(arch_rwlock_t *rw)
18947 static inline void arch_write_lock(arch_rwlock_t *rw)
18948 {
18949 asm volatile(LOCK_PREFIX WRITE_LOCK_SUB(%1) "(%0)\n\t"
18950 +
18951 +#ifdef CONFIG_PAX_REFCOUNT
18952 + "jno 0f\n"
18953 + LOCK_PREFIX WRITE_LOCK_ADD(%1) "(%0)\n"
18954 + "int $4\n0:\n"
18955 + _ASM_EXTABLE(0b, 0b)
18956 +#endif
18957 +
18958 "jz 1f\n"
18959 "call __write_lock_failed\n\t"
18960 "1:\n"
18961 @@ -260,13 +276,29 @@ static inline int arch_write_trylock(arch_rwlock_t *lock)
18962
18963 static inline void arch_read_unlock(arch_rwlock_t *rw)
18964 {
18965 - asm volatile(LOCK_PREFIX READ_LOCK_SIZE(inc) " %0"
18966 + asm volatile(LOCK_PREFIX READ_LOCK_SIZE(inc) " %0\n"
18967 +
18968 +#ifdef CONFIG_PAX_REFCOUNT
18969 + "jno 0f\n"
18970 + LOCK_PREFIX READ_LOCK_SIZE(dec) " %0\n"
18971 + "int $4\n0:\n"
18972 + _ASM_EXTABLE(0b, 0b)
18973 +#endif
18974 +
18975 :"+m" (rw->lock) : : "memory");
18976 }
18977
18978 static inline void arch_write_unlock(arch_rwlock_t *rw)
18979 {
18980 - asm volatile(LOCK_PREFIX WRITE_LOCK_ADD(%1) "%0"
18981 + asm volatile(LOCK_PREFIX WRITE_LOCK_ADD(%1) "%0\n"
18982 +
18983 +#ifdef CONFIG_PAX_REFCOUNT
18984 + "jno 0f\n"
18985 + LOCK_PREFIX WRITE_LOCK_SUB(%1) "%0\n"
18986 + "int $4\n0:\n"
18987 + _ASM_EXTABLE(0b, 0b)
18988 +#endif
18989 +
18990 : "+m" (rw->write) : "i" (RW_LOCK_BIAS) : "memory");
18991 }
18992
18993 diff --git a/arch/x86/include/asm/stackprotector.h b/arch/x86/include/asm/stackprotector.h
18994 index 6a99859..03cb807 100644
18995 --- a/arch/x86/include/asm/stackprotector.h
18996 +++ b/arch/x86/include/asm/stackprotector.h
18997 @@ -47,7 +47,7 @@
18998 * head_32 for boot CPU and setup_per_cpu_areas() for others.
18999 */
19000 #define GDT_STACK_CANARY_INIT \
19001 - [GDT_ENTRY_STACK_CANARY] = GDT_ENTRY_INIT(0x4090, 0, 0x18),
19002 + [GDT_ENTRY_STACK_CANARY] = GDT_ENTRY_INIT(0x4090, 0, 0x17),
19003
19004 /*
19005 * Initialize the stackprotector canary value.
19006 @@ -112,7 +112,7 @@ static inline void setup_stack_canary_segment(int cpu)
19007
19008 static inline void load_stack_canary_segment(void)
19009 {
19010 -#ifdef CONFIG_X86_32
19011 +#if defined(CONFIG_X86_32) && !defined(CONFIG_PAX_MEMORY_UDEREF)
19012 asm volatile ("mov %0, %%gs" : : "r" (0));
19013 #endif
19014 }
19015 diff --git a/arch/x86/include/asm/stacktrace.h b/arch/x86/include/asm/stacktrace.h
19016 index 70bbe39..4ae2bd4 100644
19017 --- a/arch/x86/include/asm/stacktrace.h
19018 +++ b/arch/x86/include/asm/stacktrace.h
19019 @@ -11,28 +11,20 @@
19020
19021 extern int kstack_depth_to_print;
19022
19023 -struct thread_info;
19024 +struct task_struct;
19025 struct stacktrace_ops;
19026
19027 -typedef unsigned long (*walk_stack_t)(struct thread_info *tinfo,
19028 - unsigned long *stack,
19029 - unsigned long bp,
19030 - const struct stacktrace_ops *ops,
19031 - void *data,
19032 - unsigned long *end,
19033 - int *graph);
19034 +typedef unsigned long walk_stack_t(struct task_struct *task,
19035 + void *stack_start,
19036 + unsigned long *stack,
19037 + unsigned long bp,
19038 + const struct stacktrace_ops *ops,
19039 + void *data,
19040 + unsigned long *end,
19041 + int *graph);
19042
19043 -extern unsigned long
19044 -print_context_stack(struct thread_info *tinfo,
19045 - unsigned long *stack, unsigned long bp,
19046 - const struct stacktrace_ops *ops, void *data,
19047 - unsigned long *end, int *graph);
19048 -
19049 -extern unsigned long
19050 -print_context_stack_bp(struct thread_info *tinfo,
19051 - unsigned long *stack, unsigned long bp,
19052 - const struct stacktrace_ops *ops, void *data,
19053 - unsigned long *end, int *graph);
19054 +extern walk_stack_t print_context_stack;
19055 +extern walk_stack_t print_context_stack_bp;
19056
19057 /* Generic stack tracer with callbacks */
19058
19059 @@ -40,7 +32,7 @@ struct stacktrace_ops {
19060 void (*address)(void *data, unsigned long address, int reliable);
19061 /* On negative return stop dumping */
19062 int (*stack)(void *data, char *name);
19063 - walk_stack_t walk_stack;
19064 + walk_stack_t *walk_stack;
19065 };
19066
19067 void dump_trace(struct task_struct *tsk, struct pt_regs *regs,
19068 diff --git a/arch/x86/include/asm/switch_to.h b/arch/x86/include/asm/switch_to.h
19069 index d7f3b3b..3cc39f1 100644
19070 --- a/arch/x86/include/asm/switch_to.h
19071 +++ b/arch/x86/include/asm/switch_to.h
19072 @@ -108,7 +108,7 @@ do { \
19073 "call __switch_to\n\t" \
19074 "movq "__percpu_arg([current_task])",%%rsi\n\t" \
19075 __switch_canary \
19076 - "movq %P[thread_info](%%rsi),%%r8\n\t" \
19077 + "movq "__percpu_arg([thread_info])",%%r8\n\t" \
19078 "movq %%rax,%%rdi\n\t" \
19079 "testl %[_tif_fork],%P[ti_flags](%%r8)\n\t" \
19080 "jnz ret_from_fork\n\t" \
19081 @@ -119,7 +119,7 @@ do { \
19082 [threadrsp] "i" (offsetof(struct task_struct, thread.sp)), \
19083 [ti_flags] "i" (offsetof(struct thread_info, flags)), \
19084 [_tif_fork] "i" (_TIF_FORK), \
19085 - [thread_info] "i" (offsetof(struct task_struct, stack)), \
19086 + [thread_info] "m" (current_tinfo), \
19087 [current_task] "m" (current_task) \
19088 __switch_canary_iparam \
19089 : "memory", "cc" __EXTRA_CLOBBER)
19090 diff --git a/arch/x86/include/asm/thread_info.h b/arch/x86/include/asm/thread_info.h
19091 index 47e5de2..d3dda54 100644
19092 --- a/arch/x86/include/asm/thread_info.h
19093 +++ b/arch/x86/include/asm/thread_info.h
19094 @@ -24,7 +24,6 @@ struct exec_domain;
19095 #include <linux/atomic.h>
19096
19097 struct thread_info {
19098 - struct task_struct *task; /* main task structure */
19099 struct exec_domain *exec_domain; /* execution domain */
19100 __u32 flags; /* low level flags */
19101 __u32 status; /* thread synchronous flags */
19102 @@ -33,13 +32,13 @@ struct thread_info {
19103 mm_segment_t addr_limit;
19104 struct restart_block restart_block;
19105 void __user *sysenter_return;
19106 + unsigned long lowest_stack;
19107 unsigned int sig_on_uaccess_error:1;
19108 unsigned int uaccess_err:1; /* uaccess failed */
19109 };
19110
19111 -#define INIT_THREAD_INFO(tsk) \
19112 +#define INIT_THREAD_INFO \
19113 { \
19114 - .task = &tsk, \
19115 .exec_domain = &default_exec_domain, \
19116 .flags = 0, \
19117 .cpu = 0, \
19118 @@ -50,7 +49,7 @@ struct thread_info {
19119 }, \
19120 }
19121
19122 -#define init_thread_info (init_thread_union.thread_info)
19123 +#define init_thread_info (init_thread_union.stack)
19124 #define init_stack (init_thread_union.stack)
19125
19126 #else /* !__ASSEMBLY__ */
19127 @@ -90,6 +89,7 @@ struct thread_info {
19128 #define TIF_SYSCALL_TRACEPOINT 28 /* syscall tracepoint instrumentation */
19129 #define TIF_ADDR32 29 /* 32-bit address space on 64 bits */
19130 #define TIF_X32 30 /* 32-bit native x86-64 binary */
19131 +#define TIF_GRSEC_SETXID 31 /* update credentials on syscall entry/exit */
19132
19133 #define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE)
19134 #define _TIF_NOTIFY_RESUME (1 << TIF_NOTIFY_RESUME)
19135 @@ -113,17 +113,18 @@ struct thread_info {
19136 #define _TIF_SYSCALL_TRACEPOINT (1 << TIF_SYSCALL_TRACEPOINT)
19137 #define _TIF_ADDR32 (1 << TIF_ADDR32)
19138 #define _TIF_X32 (1 << TIF_X32)
19139 +#define _TIF_GRSEC_SETXID (1 << TIF_GRSEC_SETXID)
19140
19141 /* work to do in syscall_trace_enter() */
19142 #define _TIF_WORK_SYSCALL_ENTRY \
19143 (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_EMU | _TIF_SYSCALL_AUDIT | \
19144 _TIF_SECCOMP | _TIF_SINGLESTEP | _TIF_SYSCALL_TRACEPOINT | \
19145 - _TIF_NOHZ)
19146 + _TIF_NOHZ | _TIF_GRSEC_SETXID)
19147
19148 /* work to do in syscall_trace_leave() */
19149 #define _TIF_WORK_SYSCALL_EXIT \
19150 (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | _TIF_SINGLESTEP | \
19151 - _TIF_SYSCALL_TRACEPOINT | _TIF_NOHZ)
19152 + _TIF_SYSCALL_TRACEPOINT | _TIF_NOHZ | _TIF_GRSEC_SETXID)
19153
19154 /* work to do on interrupt/exception return */
19155 #define _TIF_WORK_MASK \
19156 @@ -134,7 +135,7 @@ struct thread_info {
19157 /* work to do on any return to user space */
19158 #define _TIF_ALLWORK_MASK \
19159 ((0x0000FFFF & ~_TIF_SECCOMP) | _TIF_SYSCALL_TRACEPOINT | \
19160 - _TIF_NOHZ)
19161 + _TIF_NOHZ | _TIF_GRSEC_SETXID)
19162
19163 /* Only used for 64 bit */
19164 #define _TIF_DO_NOTIFY_MASK \
19165 @@ -149,7 +150,6 @@ struct thread_info {
19166 #define _TIF_WORK_CTXSW_NEXT (_TIF_WORK_CTXSW)
19167
19168 #define STACK_WARN (THREAD_SIZE/8)
19169 -#define KERNEL_STACK_OFFSET (5*(BITS_PER_LONG/8))
19170
19171 /*
19172 * macros/functions for gaining access to the thread information structure
19173 @@ -160,26 +160,18 @@ struct thread_info {
19174
19175 DECLARE_PER_CPU(unsigned long, kernel_stack);
19176
19177 +DECLARE_PER_CPU(struct thread_info *, current_tinfo);
19178 +
19179 static inline struct thread_info *current_thread_info(void)
19180 {
19181 - struct thread_info *ti;
19182 - ti = (void *)(this_cpu_read_stable(kernel_stack) +
19183 - KERNEL_STACK_OFFSET - THREAD_SIZE);
19184 - return ti;
19185 + return this_cpu_read_stable(current_tinfo);
19186 }
19187
19188 #else /* !__ASSEMBLY__ */
19189
19190 /* how to get the thread information struct from ASM */
19191 #define GET_THREAD_INFO(reg) \
19192 - _ASM_MOV PER_CPU_VAR(kernel_stack),reg ; \
19193 - _ASM_SUB $(THREAD_SIZE-KERNEL_STACK_OFFSET),reg ;
19194 -
19195 -/*
19196 - * Same if PER_CPU_VAR(kernel_stack) is, perhaps with some offset, already in
19197 - * a certain register (to be used in assembler memory operands).
19198 - */
19199 -#define THREAD_INFO(reg, off) KERNEL_STACK_OFFSET+(off)-THREAD_SIZE(reg)
19200 + _ASM_MOV PER_CPU_VAR(current_tinfo),reg ;
19201
19202 #endif
19203
19204 @@ -237,5 +229,12 @@ static inline bool is_ia32_task(void)
19205 extern void arch_task_cache_init(void);
19206 extern int arch_dup_task_struct(struct task_struct *dst, struct task_struct *src);
19207 extern void arch_release_task_struct(struct task_struct *tsk);
19208 +
19209 +#define __HAVE_THREAD_FUNCTIONS
19210 +#define task_thread_info(task) (&(task)->tinfo)
19211 +#define task_stack_page(task) ((task)->stack)
19212 +#define setup_thread_stack(p, org) do {} while (0)
19213 +#define end_of_stack(p) ((unsigned long *)task_stack_page(p) + 1)
19214 +
19215 #endif
19216 #endif /* _ASM_X86_THREAD_INFO_H */
19217 diff --git a/arch/x86/include/asm/tlbflush.h b/arch/x86/include/asm/tlbflush.h
19218 index 04905bf..49203ca 100644
19219 --- a/arch/x86/include/asm/tlbflush.h
19220 +++ b/arch/x86/include/asm/tlbflush.h
19221 @@ -17,18 +17,44 @@
19222
19223 static inline void __native_flush_tlb(void)
19224 {
19225 + if (static_cpu_has(X86_FEATURE_INVPCID)) {
19226 + u64 descriptor[2];
19227 +
19228 + descriptor[0] = PCID_KERNEL;
19229 + asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_ALL_MONGLOBAL) : "memory");
19230 + return;
19231 + }
19232 +
19233 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
19234 + if (static_cpu_has(X86_FEATURE_PCID)) {
19235 + unsigned int cpu = raw_get_cpu();
19236 +
19237 + native_write_cr3(__pa(get_cpu_pgd(cpu, user)) | PCID_USER);
19238 + native_write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL);
19239 + raw_put_cpu_no_resched();
19240 + return;
19241 + }
19242 +#endif
19243 +
19244 native_write_cr3(native_read_cr3());
19245 }
19246
19247 static inline void __native_flush_tlb_global_irq_disabled(void)
19248 {
19249 - unsigned long cr4;
19250 + if (static_cpu_has(X86_FEATURE_INVPCID)) {
19251 + u64 descriptor[2];
19252
19253 - cr4 = native_read_cr4();
19254 - /* clear PGE */
19255 - native_write_cr4(cr4 & ~X86_CR4_PGE);
19256 - /* write old PGE again and flush TLBs */
19257 - native_write_cr4(cr4);
19258 + descriptor[0] = PCID_KERNEL;
19259 + asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_ALL_GLOBAL) : "memory");
19260 + } else {
19261 + unsigned long cr4;
19262 +
19263 + cr4 = native_read_cr4();
19264 + /* clear PGE */
19265 + native_write_cr4(cr4 & ~X86_CR4_PGE);
19266 + /* write old PGE again and flush TLBs */
19267 + native_write_cr4(cr4);
19268 + }
19269 }
19270
19271 static inline void __native_flush_tlb_global(void)
19272 @@ -49,6 +75,41 @@ static inline void __native_flush_tlb_global(void)
19273
19274 static inline void __native_flush_tlb_single(unsigned long addr)
19275 {
19276 + if (static_cpu_has(X86_FEATURE_INVPCID)) {
19277 + u64 descriptor[2];
19278 +
19279 + descriptor[0] = PCID_KERNEL;
19280 + descriptor[1] = addr;
19281 +
19282 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
19283 + if (!static_cpu_has(X86_FEATURE_STRONGUDEREF) || addr >= TASK_SIZE_MAX) {
19284 + if (addr < TASK_SIZE_MAX)
19285 + descriptor[1] += pax_user_shadow_base;
19286 + asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_SINGLE_ADDRESS) : "memory");
19287 + }
19288 +
19289 + descriptor[0] = PCID_USER;
19290 + descriptor[1] = addr;
19291 +#endif
19292 +
19293 + asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_SINGLE_ADDRESS) : "memory");
19294 + return;
19295 + }
19296 +
19297 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
19298 + if (static_cpu_has(X86_FEATURE_PCID)) {
19299 + unsigned int cpu = raw_get_cpu();
19300 +
19301 + native_write_cr3(__pa(get_cpu_pgd(cpu, user)) | PCID_USER | PCID_NOFLUSH);
19302 + asm volatile("invlpg (%0)" ::"r" (addr) : "memory");
19303 + native_write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL | PCID_NOFLUSH);
19304 + raw_put_cpu_no_resched();
19305 +
19306 + if (!static_cpu_has(X86_FEATURE_STRONGUDEREF) && addr < TASK_SIZE_MAX)
19307 + addr += pax_user_shadow_base;
19308 + }
19309 +#endif
19310 +
19311 asm volatile("invlpg (%0)" ::"r" (addr) : "memory");
19312 }
19313
19314 diff --git a/arch/x86/include/asm/uaccess.h b/arch/x86/include/asm/uaccess.h
19315 index 0d592e0..7437fcc 100644
19316 --- a/arch/x86/include/asm/uaccess.h
19317 +++ b/arch/x86/include/asm/uaccess.h
19318 @@ -7,6 +7,7 @@
19319 #include <linux/compiler.h>
19320 #include <linux/thread_info.h>
19321 #include <linux/string.h>
19322 +#include <linux/spinlock.h>
19323 #include <asm/asm.h>
19324 #include <asm/page.h>
19325 #include <asm/smap.h>
19326 @@ -29,7 +30,12 @@
19327
19328 #define get_ds() (KERNEL_DS)
19329 #define get_fs() (current_thread_info()->addr_limit)
19330 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
19331 +void __set_fs(mm_segment_t x);
19332 +void set_fs(mm_segment_t x);
19333 +#else
19334 #define set_fs(x) (current_thread_info()->addr_limit = (x))
19335 +#endif
19336
19337 #define segment_eq(a, b) ((a).seg == (b).seg)
19338
19339 @@ -85,8 +91,36 @@ static inline bool __chk_range_not_ok(unsigned long addr, unsigned long size, un
19340 * checks that the pointer is in the user space range - after calling
19341 * this function, memory access functions may still return -EFAULT.
19342 */
19343 -#define access_ok(type, addr, size) \
19344 - likely(!__range_not_ok(addr, size, user_addr_max()))
19345 +extern int _cond_resched(void);
19346 +#define access_ok_noprefault(type, addr, size) (likely(!__range_not_ok(addr, size, user_addr_max())))
19347 +#define access_ok(type, addr, size) \
19348 +({ \
19349 + unsigned long __size = size; \
19350 + unsigned long __addr = (unsigned long)addr; \
19351 + bool __ret_ao = __range_not_ok(__addr, __size, user_addr_max()) == 0;\
19352 + if (__ret_ao && __size) { \
19353 + unsigned long __addr_ao = __addr & PAGE_MASK; \
19354 + unsigned long __end_ao = __addr + __size - 1; \
19355 + if (unlikely((__end_ao ^ __addr_ao) & PAGE_MASK)) { \
19356 + while (__addr_ao <= __end_ao) { \
19357 + char __c_ao; \
19358 + __addr_ao += PAGE_SIZE; \
19359 + if (__size > PAGE_SIZE) \
19360 + _cond_resched(); \
19361 + if (__get_user(__c_ao, (char __user *)__addr)) \
19362 + break; \
19363 + if (type != VERIFY_WRITE) { \
19364 + __addr = __addr_ao; \
19365 + continue; \
19366 + } \
19367 + if (__put_user(__c_ao, (char __user *)__addr)) \
19368 + break; \
19369 + __addr = __addr_ao; \
19370 + } \
19371 + } \
19372 + } \
19373 + __ret_ao; \
19374 +})
19375
19376 /*
19377 * The exception table consists of pairs of addresses relative to the
19378 @@ -176,10 +210,12 @@ __typeof__(__builtin_choose_expr(sizeof(x) > sizeof(0UL), 0ULL, 0UL))
19379 register __inttype(*(ptr)) __val_gu asm("%"_ASM_DX); \
19380 __chk_user_ptr(ptr); \
19381 might_fault(); \
19382 + pax_open_userland(); \
19383 asm volatile("call __get_user_%P3" \
19384 : "=a" (__ret_gu), "=r" (__val_gu) \
19385 : "0" (ptr), "i" (sizeof(*(ptr)))); \
19386 (x) = (__typeof__(*(ptr))) __val_gu; \
19387 + pax_close_userland(); \
19388 __ret_gu; \
19389 })
19390
19391 @@ -187,13 +223,21 @@ __typeof__(__builtin_choose_expr(sizeof(x) > sizeof(0UL), 0ULL, 0UL))
19392 asm volatile("call __put_user_" #size : "=a" (__ret_pu) \
19393 : "0" ((typeof(*(ptr)))(x)), "c" (ptr) : "ebx")
19394
19395 -
19396 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
19397 +#define __copyuser_seg "gs;"
19398 +#define __COPYUSER_SET_ES "pushl %%gs; popl %%es\n"
19399 +#define __COPYUSER_RESTORE_ES "pushl %%ss; popl %%es\n"
19400 +#else
19401 +#define __copyuser_seg
19402 +#define __COPYUSER_SET_ES
19403 +#define __COPYUSER_RESTORE_ES
19404 +#endif
19405
19406 #ifdef CONFIG_X86_32
19407 #define __put_user_asm_u64(x, addr, err, errret) \
19408 asm volatile(ASM_STAC "\n" \
19409 - "1: movl %%eax,0(%2)\n" \
19410 - "2: movl %%edx,4(%2)\n" \
19411 + "1: "__copyuser_seg"movl %%eax,0(%2)\n" \
19412 + "2: "__copyuser_seg"movl %%edx,4(%2)\n" \
19413 "3: " ASM_CLAC "\n" \
19414 ".section .fixup,\"ax\"\n" \
19415 "4: movl %3,%0\n" \
19416 @@ -206,8 +250,8 @@ __typeof__(__builtin_choose_expr(sizeof(x) > sizeof(0UL), 0ULL, 0UL))
19417
19418 #define __put_user_asm_ex_u64(x, addr) \
19419 asm volatile(ASM_STAC "\n" \
19420 - "1: movl %%eax,0(%1)\n" \
19421 - "2: movl %%edx,4(%1)\n" \
19422 + "1: "__copyuser_seg"movl %%eax,0(%1)\n" \
19423 + "2: "__copyuser_seg"movl %%edx,4(%1)\n" \
19424 "3: " ASM_CLAC "\n" \
19425 _ASM_EXTABLE_EX(1b, 2b) \
19426 _ASM_EXTABLE_EX(2b, 3b) \
19427 @@ -257,7 +301,8 @@ extern void __put_user_8(void);
19428 __typeof__(*(ptr)) __pu_val; \
19429 __chk_user_ptr(ptr); \
19430 might_fault(); \
19431 - __pu_val = x; \
19432 + __pu_val = (x); \
19433 + pax_open_userland(); \
19434 switch (sizeof(*(ptr))) { \
19435 case 1: \
19436 __put_user_x(1, __pu_val, ptr, __ret_pu); \
19437 @@ -275,6 +320,7 @@ extern void __put_user_8(void);
19438 __put_user_x(X, __pu_val, ptr, __ret_pu); \
19439 break; \
19440 } \
19441 + pax_close_userland(); \
19442 __ret_pu; \
19443 })
19444
19445 @@ -355,8 +401,10 @@ do { \
19446 } while (0)
19447
19448 #define __get_user_asm(x, addr, err, itype, rtype, ltype, errret) \
19449 +do { \
19450 + pax_open_userland(); \
19451 asm volatile(ASM_STAC "\n" \
19452 - "1: mov"itype" %2,%"rtype"1\n" \
19453 + "1: "__copyuser_seg"mov"itype" %2,%"rtype"1\n"\
19454 "2: " ASM_CLAC "\n" \
19455 ".section .fixup,\"ax\"\n" \
19456 "3: mov %3,%0\n" \
19457 @@ -364,8 +412,10 @@ do { \
19458 " jmp 2b\n" \
19459 ".previous\n" \
19460 _ASM_EXTABLE(1b, 3b) \
19461 - : "=r" (err), ltype(x) \
19462 - : "m" (__m(addr)), "i" (errret), "0" (err))
19463 + : "=r" (err), ltype (x) \
19464 + : "m" (__m(addr)), "i" (errret), "0" (err)); \
19465 + pax_close_userland(); \
19466 +} while (0)
19467
19468 #define __get_user_size_ex(x, ptr, size) \
19469 do { \
19470 @@ -389,7 +439,7 @@ do { \
19471 } while (0)
19472
19473 #define __get_user_asm_ex(x, addr, itype, rtype, ltype) \
19474 - asm volatile("1: mov"itype" %1,%"rtype"0\n" \
19475 + asm volatile("1: "__copyuser_seg"mov"itype" %1,%"rtype"0\n"\
19476 "2:\n" \
19477 _ASM_EXTABLE_EX(1b, 2b) \
19478 : ltype(x) : "m" (__m(addr)))
19479 @@ -406,13 +456,24 @@ do { \
19480 int __gu_err; \
19481 unsigned long __gu_val; \
19482 __get_user_size(__gu_val, (ptr), (size), __gu_err, -EFAULT); \
19483 - (x) = (__force __typeof__(*(ptr)))__gu_val; \
19484 + (x) = (__typeof__(*(ptr)))__gu_val; \
19485 __gu_err; \
19486 })
19487
19488 /* FIXME: this hack is definitely wrong -AK */
19489 struct __large_struct { unsigned long buf[100]; };
19490 -#define __m(x) (*(struct __large_struct __user *)(x))
19491 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
19492 +#define ____m(x) \
19493 +({ \
19494 + unsigned long ____x = (unsigned long)(x); \
19495 + if (____x < pax_user_shadow_base) \
19496 + ____x += pax_user_shadow_base; \
19497 + (typeof(x))____x; \
19498 +})
19499 +#else
19500 +#define ____m(x) (x)
19501 +#endif
19502 +#define __m(x) (*(struct __large_struct __user *)____m(x))
19503
19504 /*
19505 * Tell gcc we read from memory instead of writing: this is because
19506 @@ -420,8 +481,10 @@ struct __large_struct { unsigned long buf[100]; };
19507 * aliasing issues.
19508 */
19509 #define __put_user_asm(x, addr, err, itype, rtype, ltype, errret) \
19510 +do { \
19511 + pax_open_userland(); \
19512 asm volatile(ASM_STAC "\n" \
19513 - "1: mov"itype" %"rtype"1,%2\n" \
19514 + "1: "__copyuser_seg"mov"itype" %"rtype"1,%2\n"\
19515 "2: " ASM_CLAC "\n" \
19516 ".section .fixup,\"ax\"\n" \
19517 "3: mov %3,%0\n" \
19518 @@ -429,10 +492,12 @@ struct __large_struct { unsigned long buf[100]; };
19519 ".previous\n" \
19520 _ASM_EXTABLE(1b, 3b) \
19521 : "=r"(err) \
19522 - : ltype(x), "m" (__m(addr)), "i" (errret), "0" (err))
19523 + : ltype (x), "m" (__m(addr)), "i" (errret), "0" (err));\
19524 + pax_close_userland(); \
19525 +} while (0)
19526
19527 #define __put_user_asm_ex(x, addr, itype, rtype, ltype) \
19528 - asm volatile("1: mov"itype" %"rtype"0,%1\n" \
19529 + asm volatile("1: "__copyuser_seg"mov"itype" %"rtype"0,%1\n"\
19530 "2:\n" \
19531 _ASM_EXTABLE_EX(1b, 2b) \
19532 : : ltype(x), "m" (__m(addr)))
19533 @@ -442,11 +507,13 @@ struct __large_struct { unsigned long buf[100]; };
19534 */
19535 #define uaccess_try do { \
19536 current_thread_info()->uaccess_err = 0; \
19537 + pax_open_userland(); \
19538 stac(); \
19539 barrier();
19540
19541 #define uaccess_catch(err) \
19542 clac(); \
19543 + pax_close_userland(); \
19544 (err) |= (current_thread_info()->uaccess_err ? -EFAULT : 0); \
19545 } while (0)
19546
19547 @@ -471,8 +538,12 @@ struct __large_struct { unsigned long buf[100]; };
19548 * On error, the variable @x is set to zero.
19549 */
19550
19551 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
19552 +#define __get_user(x, ptr) get_user((x), (ptr))
19553 +#else
19554 #define __get_user(x, ptr) \
19555 __get_user_nocheck((x), (ptr), sizeof(*(ptr)))
19556 +#endif
19557
19558 /**
19559 * __put_user: - Write a simple value into user space, with less checking.
19560 @@ -494,8 +565,12 @@ struct __large_struct { unsigned long buf[100]; };
19561 * Returns zero on success, or -EFAULT on error.
19562 */
19563
19564 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
19565 +#define __put_user(x, ptr) put_user((x), (ptr))
19566 +#else
19567 #define __put_user(x, ptr) \
19568 __put_user_nocheck((__typeof__(*(ptr)))(x), (ptr), sizeof(*(ptr)))
19569 +#endif
19570
19571 #define __get_user_unaligned __get_user
19572 #define __put_user_unaligned __put_user
19573 @@ -513,7 +588,7 @@ struct __large_struct { unsigned long buf[100]; };
19574 #define get_user_ex(x, ptr) do { \
19575 unsigned long __gue_val; \
19576 __get_user_size_ex((__gue_val), (ptr), (sizeof(*(ptr)))); \
19577 - (x) = (__force __typeof__(*(ptr)))__gue_val; \
19578 + (x) = (__typeof__(*(ptr)))__gue_val; \
19579 } while (0)
19580
19581 #define put_user_try uaccess_try
19582 @@ -542,18 +617,19 @@ extern void __cmpxchg_wrong_size(void)
19583 __typeof__(ptr) __uval = (uval); \
19584 __typeof__(*(ptr)) __old = (old); \
19585 __typeof__(*(ptr)) __new = (new); \
19586 + pax_open_userland(); \
19587 switch (size) { \
19588 case 1: \
19589 { \
19590 asm volatile("\t" ASM_STAC "\n" \
19591 - "1:\t" LOCK_PREFIX "cmpxchgb %4, %2\n" \
19592 + "1:\t" LOCK_PREFIX __copyuser_seg"cmpxchgb %4, %2\n"\
19593 "2:\t" ASM_CLAC "\n" \
19594 "\t.section .fixup, \"ax\"\n" \
19595 "3:\tmov %3, %0\n" \
19596 "\tjmp 2b\n" \
19597 "\t.previous\n" \
19598 _ASM_EXTABLE(1b, 3b) \
19599 - : "+r" (__ret), "=a" (__old), "+m" (*(ptr)) \
19600 + : "+r" (__ret), "=a" (__old), "+m" (*____m(ptr))\
19601 : "i" (-EFAULT), "q" (__new), "1" (__old) \
19602 : "memory" \
19603 ); \
19604 @@ -562,14 +638,14 @@ extern void __cmpxchg_wrong_size(void)
19605 case 2: \
19606 { \
19607 asm volatile("\t" ASM_STAC "\n" \
19608 - "1:\t" LOCK_PREFIX "cmpxchgw %4, %2\n" \
19609 + "1:\t" LOCK_PREFIX __copyuser_seg"cmpxchgw %4, %2\n"\
19610 "2:\t" ASM_CLAC "\n" \
19611 "\t.section .fixup, \"ax\"\n" \
19612 "3:\tmov %3, %0\n" \
19613 "\tjmp 2b\n" \
19614 "\t.previous\n" \
19615 _ASM_EXTABLE(1b, 3b) \
19616 - : "+r" (__ret), "=a" (__old), "+m" (*(ptr)) \
19617 + : "+r" (__ret), "=a" (__old), "+m" (*____m(ptr))\
19618 : "i" (-EFAULT), "r" (__new), "1" (__old) \
19619 : "memory" \
19620 ); \
19621 @@ -578,14 +654,14 @@ extern void __cmpxchg_wrong_size(void)
19622 case 4: \
19623 { \
19624 asm volatile("\t" ASM_STAC "\n" \
19625 - "1:\t" LOCK_PREFIX "cmpxchgl %4, %2\n" \
19626 + "1:\t" LOCK_PREFIX __copyuser_seg"cmpxchgl %4, %2\n"\
19627 "2:\t" ASM_CLAC "\n" \
19628 "\t.section .fixup, \"ax\"\n" \
19629 "3:\tmov %3, %0\n" \
19630 "\tjmp 2b\n" \
19631 "\t.previous\n" \
19632 _ASM_EXTABLE(1b, 3b) \
19633 - : "+r" (__ret), "=a" (__old), "+m" (*(ptr)) \
19634 + : "+r" (__ret), "=a" (__old), "+m" (*____m(ptr))\
19635 : "i" (-EFAULT), "r" (__new), "1" (__old) \
19636 : "memory" \
19637 ); \
19638 @@ -597,14 +673,14 @@ extern void __cmpxchg_wrong_size(void)
19639 __cmpxchg_wrong_size(); \
19640 \
19641 asm volatile("\t" ASM_STAC "\n" \
19642 - "1:\t" LOCK_PREFIX "cmpxchgq %4, %2\n" \
19643 + "1:\t" LOCK_PREFIX __copyuser_seg"cmpxchgq %4, %2\n"\
19644 "2:\t" ASM_CLAC "\n" \
19645 "\t.section .fixup, \"ax\"\n" \
19646 "3:\tmov %3, %0\n" \
19647 "\tjmp 2b\n" \
19648 "\t.previous\n" \
19649 _ASM_EXTABLE(1b, 3b) \
19650 - : "+r" (__ret), "=a" (__old), "+m" (*(ptr)) \
19651 + : "+r" (__ret), "=a" (__old), "+m" (*____m(ptr))\
19652 : "i" (-EFAULT), "r" (__new), "1" (__old) \
19653 : "memory" \
19654 ); \
19655 @@ -613,6 +689,7 @@ extern void __cmpxchg_wrong_size(void)
19656 default: \
19657 __cmpxchg_wrong_size(); \
19658 } \
19659 + pax_close_userland(); \
19660 *__uval = __old; \
19661 __ret; \
19662 })
19663 @@ -636,17 +713,6 @@ extern struct movsl_mask {
19664
19665 #define ARCH_HAS_NOCACHE_UACCESS 1
19666
19667 -#ifdef CONFIG_X86_32
19668 -# include <asm/uaccess_32.h>
19669 -#else
19670 -# include <asm/uaccess_64.h>
19671 -#endif
19672 -
19673 -unsigned long __must_check _copy_from_user(void *to, const void __user *from,
19674 - unsigned n);
19675 -unsigned long __must_check _copy_to_user(void __user *to, const void *from,
19676 - unsigned n);
19677 -
19678 #ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
19679 # define copy_user_diag __compiletime_error
19680 #else
19681 @@ -656,7 +722,7 @@ unsigned long __must_check _copy_to_user(void __user *to, const void *from,
19682 extern void copy_user_diag("copy_from_user() buffer size is too small")
19683 copy_from_user_overflow(void);
19684 extern void copy_user_diag("copy_to_user() buffer size is too small")
19685 -copy_to_user_overflow(void) __asm__("copy_from_user_overflow");
19686 +copy_to_user_overflow(void);
19687
19688 #undef copy_user_diag
19689
19690 @@ -669,7 +735,7 @@ __copy_from_user_overflow(void) __asm__("copy_from_user_overflow");
19691
19692 extern void
19693 __compiletime_warning("copy_to_user() buffer size is not provably correct")
19694 -__copy_to_user_overflow(void) __asm__("copy_from_user_overflow");
19695 +__copy_to_user_overflow(void) __asm__("copy_to_user_overflow");
19696 #define __copy_to_user_overflow(size, count) __copy_to_user_overflow()
19697
19698 #else
19699 @@ -684,10 +750,16 @@ __copy_from_user_overflow(int size, unsigned long count)
19700
19701 #endif
19702
19703 +#ifdef CONFIG_X86_32
19704 +# include <asm/uaccess_32.h>
19705 +#else
19706 +# include <asm/uaccess_64.h>
19707 +#endif
19708 +
19709 static inline unsigned long __must_check
19710 copy_from_user(void *to, const void __user *from, unsigned long n)
19711 {
19712 - int sz = __compiletime_object_size(to);
19713 + size_t sz = __compiletime_object_size(to);
19714
19715 might_fault();
19716
19717 @@ -709,12 +781,15 @@ copy_from_user(void *to, const void __user *from, unsigned long n)
19718 * case, and do only runtime checking for non-constant sizes.
19719 */
19720
19721 - if (likely(sz < 0 || sz >= n))
19722 - n = _copy_from_user(to, from, n);
19723 - else if(__builtin_constant_p(n))
19724 - copy_from_user_overflow();
19725 - else
19726 - __copy_from_user_overflow(sz, n);
19727 + if (likely(sz != (size_t)-1 && sz < n)) {
19728 + if(__builtin_constant_p(n))
19729 + copy_from_user_overflow();
19730 + else
19731 + __copy_from_user_overflow(sz, n);
19732 + } if (access_ok(VERIFY_READ, from, n))
19733 + n = __copy_from_user(to, from, n);
19734 + else if ((long)n > 0)
19735 + memset(to, 0, n);
19736
19737 return n;
19738 }
19739 @@ -722,17 +797,18 @@ copy_from_user(void *to, const void __user *from, unsigned long n)
19740 static inline unsigned long __must_check
19741 copy_to_user(void __user *to, const void *from, unsigned long n)
19742 {
19743 - int sz = __compiletime_object_size(from);
19744 + size_t sz = __compiletime_object_size(from);
19745
19746 might_fault();
19747
19748 /* See the comment in copy_from_user() above. */
19749 - if (likely(sz < 0 || sz >= n))
19750 - n = _copy_to_user(to, from, n);
19751 - else if(__builtin_constant_p(n))
19752 - copy_to_user_overflow();
19753 - else
19754 - __copy_to_user_overflow(sz, n);
19755 + if (likely(sz != (size_t)-1 && sz < n)) {
19756 + if(__builtin_constant_p(n))
19757 + copy_to_user_overflow();
19758 + else
19759 + __copy_to_user_overflow(sz, n);
19760 + } else if (access_ok(VERIFY_WRITE, to, n))
19761 + n = __copy_to_user(to, from, n);
19762
19763 return n;
19764 }
19765 diff --git a/arch/x86/include/asm/uaccess_32.h b/arch/x86/include/asm/uaccess_32.h
19766 index 3c03a5d..1071638 100644
19767 --- a/arch/x86/include/asm/uaccess_32.h
19768 +++ b/arch/x86/include/asm/uaccess_32.h
19769 @@ -43,6 +43,11 @@ unsigned long __must_check __copy_from_user_ll_nocache_nozero
19770 static __always_inline unsigned long __must_check
19771 __copy_to_user_inatomic(void __user *to, const void *from, unsigned long n)
19772 {
19773 + if ((long)n < 0)
19774 + return n;
19775 +
19776 + check_object_size(from, n, true);
19777 +
19778 if (__builtin_constant_p(n)) {
19779 unsigned long ret;
19780
19781 @@ -82,12 +87,16 @@ static __always_inline unsigned long __must_check
19782 __copy_to_user(void __user *to, const void *from, unsigned long n)
19783 {
19784 might_fault();
19785 +
19786 return __copy_to_user_inatomic(to, from, n);
19787 }
19788
19789 static __always_inline unsigned long
19790 __copy_from_user_inatomic(void *to, const void __user *from, unsigned long n)
19791 {
19792 + if ((long)n < 0)
19793 + return n;
19794 +
19795 /* Avoid zeroing the tail if the copy fails..
19796 * If 'n' is constant and 1, 2, or 4, we do still zero on a failure,
19797 * but as the zeroing behaviour is only significant when n is not
19798 @@ -137,6 +146,12 @@ static __always_inline unsigned long
19799 __copy_from_user(void *to, const void __user *from, unsigned long n)
19800 {
19801 might_fault();
19802 +
19803 + if ((long)n < 0)
19804 + return n;
19805 +
19806 + check_object_size(to, n, false);
19807 +
19808 if (__builtin_constant_p(n)) {
19809 unsigned long ret;
19810
19811 @@ -159,6 +174,10 @@ static __always_inline unsigned long __copy_from_user_nocache(void *to,
19812 const void __user *from, unsigned long n)
19813 {
19814 might_fault();
19815 +
19816 + if ((long)n < 0)
19817 + return n;
19818 +
19819 if (__builtin_constant_p(n)) {
19820 unsigned long ret;
19821
19822 @@ -181,7 +200,10 @@ static __always_inline unsigned long
19823 __copy_from_user_inatomic_nocache(void *to, const void __user *from,
19824 unsigned long n)
19825 {
19826 - return __copy_from_user_ll_nocache_nozero(to, from, n);
19827 + if ((long)n < 0)
19828 + return n;
19829 +
19830 + return __copy_from_user_ll_nocache_nozero(to, from, n);
19831 }
19832
19833 #endif /* _ASM_X86_UACCESS_32_H */
19834 diff --git a/arch/x86/include/asm/uaccess_64.h b/arch/x86/include/asm/uaccess_64.h
19835 index 12a26b9..206c200 100644
19836 --- a/arch/x86/include/asm/uaccess_64.h
19837 +++ b/arch/x86/include/asm/uaccess_64.h
19838 @@ -10,6 +10,9 @@
19839 #include <asm/alternative.h>
19840 #include <asm/cpufeature.h>
19841 #include <asm/page.h>
19842 +#include <asm/pgtable.h>
19843 +
19844 +#define set_fs(x) (current_thread_info()->addr_limit = (x))
19845
19846 /*
19847 * Copy To/From Userspace
19848 @@ -17,14 +20,14 @@
19849
19850 /* Handles exceptions in both to and from, but doesn't do access_ok */
19851 __must_check unsigned long
19852 -copy_user_enhanced_fast_string(void *to, const void *from, unsigned len);
19853 +copy_user_enhanced_fast_string(void *to, const void *from, unsigned len) __size_overflow(3);
19854 __must_check unsigned long
19855 -copy_user_generic_string(void *to, const void *from, unsigned len);
19856 +copy_user_generic_string(void *to, const void *from, unsigned len) __size_overflow(3);
19857 __must_check unsigned long
19858 -copy_user_generic_unrolled(void *to, const void *from, unsigned len);
19859 +copy_user_generic_unrolled(void *to, const void *from, unsigned len) __size_overflow(3);
19860
19861 static __always_inline __must_check unsigned long
19862 -copy_user_generic(void *to, const void *from, unsigned len)
19863 +copy_user_generic(void *to, const void *from, unsigned long len)
19864 {
19865 unsigned ret;
19866
19867 @@ -46,121 +49,170 @@ copy_user_generic(void *to, const void *from, unsigned len)
19868 }
19869
19870 __must_check unsigned long
19871 -copy_in_user(void __user *to, const void __user *from, unsigned len);
19872 +copy_in_user(void __user *to, const void __user *from, unsigned long len);
19873
19874 static __always_inline __must_check
19875 -int __copy_from_user_nocheck(void *dst, const void __user *src, unsigned size)
19876 +unsigned long __copy_from_user_nocheck(void *dst, const void __user *src, unsigned long size)
19877 {
19878 - int ret = 0;
19879 + size_t sz = __compiletime_object_size(dst);
19880 + unsigned ret = 0;
19881 +
19882 + if (size > INT_MAX)
19883 + return size;
19884 +
19885 + check_object_size(dst, size, false);
19886 +
19887 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19888 + if (!access_ok_noprefault(VERIFY_READ, src, size))
19889 + return size;
19890 +#endif
19891 +
19892 + if (unlikely(sz != (size_t)-1 && sz < size)) {
19893 + if(__builtin_constant_p(size))
19894 + copy_from_user_overflow();
19895 + else
19896 + __copy_from_user_overflow(sz, size);
19897 + return size;
19898 + }
19899
19900 if (!__builtin_constant_p(size))
19901 - return copy_user_generic(dst, (__force void *)src, size);
19902 + return copy_user_generic(dst, (__force_kernel const void *)____m(src), size);
19903 switch (size) {
19904 - case 1:__get_user_asm(*(u8 *)dst, (u8 __user *)src,
19905 + case 1:__get_user_asm(*(u8 *)dst, (const u8 __user *)src,
19906 ret, "b", "b", "=q", 1);
19907 return ret;
19908 - case 2:__get_user_asm(*(u16 *)dst, (u16 __user *)src,
19909 + case 2:__get_user_asm(*(u16 *)dst, (const u16 __user *)src,
19910 ret, "w", "w", "=r", 2);
19911 return ret;
19912 - case 4:__get_user_asm(*(u32 *)dst, (u32 __user *)src,
19913 + case 4:__get_user_asm(*(u32 *)dst, (const u32 __user *)src,
19914 ret, "l", "k", "=r", 4);
19915 return ret;
19916 - case 8:__get_user_asm(*(u64 *)dst, (u64 __user *)src,
19917 + case 8:__get_user_asm(*(u64 *)dst, (const u64 __user *)src,
19918 ret, "q", "", "=r", 8);
19919 return ret;
19920 case 10:
19921 - __get_user_asm(*(u64 *)dst, (u64 __user *)src,
19922 + __get_user_asm(*(u64 *)dst, (const u64 __user *)src,
19923 ret, "q", "", "=r", 10);
19924 if (unlikely(ret))
19925 return ret;
19926 __get_user_asm(*(u16 *)(8 + (char *)dst),
19927 - (u16 __user *)(8 + (char __user *)src),
19928 + (const u16 __user *)(8 + (const char __user *)src),
19929 ret, "w", "w", "=r", 2);
19930 return ret;
19931 case 16:
19932 - __get_user_asm(*(u64 *)dst, (u64 __user *)src,
19933 + __get_user_asm(*(u64 *)dst, (const u64 __user *)src,
19934 ret, "q", "", "=r", 16);
19935 if (unlikely(ret))
19936 return ret;
19937 __get_user_asm(*(u64 *)(8 + (char *)dst),
19938 - (u64 __user *)(8 + (char __user *)src),
19939 + (const u64 __user *)(8 + (const char __user *)src),
19940 ret, "q", "", "=r", 8);
19941 return ret;
19942 default:
19943 - return copy_user_generic(dst, (__force void *)src, size);
19944 + return copy_user_generic(dst, (__force_kernel const void *)____m(src), size);
19945 }
19946 }
19947
19948 static __always_inline __must_check
19949 -int __copy_from_user(void *dst, const void __user *src, unsigned size)
19950 +unsigned long __copy_from_user(void *dst, const void __user *src, unsigned long size)
19951 {
19952 might_fault();
19953 return __copy_from_user_nocheck(dst, src, size);
19954 }
19955
19956 static __always_inline __must_check
19957 -int __copy_to_user_nocheck(void __user *dst, const void *src, unsigned size)
19958 +unsigned long __copy_to_user_nocheck(void __user *dst, const void *src, unsigned long size)
19959 {
19960 - int ret = 0;
19961 + size_t sz = __compiletime_object_size(src);
19962 + unsigned ret = 0;
19963 +
19964 + if (size > INT_MAX)
19965 + return size;
19966 +
19967 + check_object_size(src, size, true);
19968 +
19969 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19970 + if (!access_ok_noprefault(VERIFY_WRITE, dst, size))
19971 + return size;
19972 +#endif
19973 +
19974 + if (unlikely(sz != (size_t)-1 && sz < size)) {
19975 + if(__builtin_constant_p(size))
19976 + copy_to_user_overflow();
19977 + else
19978 + __copy_to_user_overflow(sz, size);
19979 + return size;
19980 + }
19981
19982 if (!__builtin_constant_p(size))
19983 - return copy_user_generic((__force void *)dst, src, size);
19984 + return copy_user_generic((__force_kernel void *)____m(dst), src, size);
19985 switch (size) {
19986 - case 1:__put_user_asm(*(u8 *)src, (u8 __user *)dst,
19987 + case 1:__put_user_asm(*(const u8 *)src, (u8 __user *)dst,
19988 ret, "b", "b", "iq", 1);
19989 return ret;
19990 - case 2:__put_user_asm(*(u16 *)src, (u16 __user *)dst,
19991 + case 2:__put_user_asm(*(const u16 *)src, (u16 __user *)dst,
19992 ret, "w", "w", "ir", 2);
19993 return ret;
19994 - case 4:__put_user_asm(*(u32 *)src, (u32 __user *)dst,
19995 + case 4:__put_user_asm(*(const u32 *)src, (u32 __user *)dst,
19996 ret, "l", "k", "ir", 4);
19997 return ret;
19998 - case 8:__put_user_asm(*(u64 *)src, (u64 __user *)dst,
19999 + case 8:__put_user_asm(*(const u64 *)src, (u64 __user *)dst,
20000 ret, "q", "", "er", 8);
20001 return ret;
20002 case 10:
20003 - __put_user_asm(*(u64 *)src, (u64 __user *)dst,
20004 + __put_user_asm(*(const u64 *)src, (u64 __user *)dst,
20005 ret, "q", "", "er", 10);
20006 if (unlikely(ret))
20007 return ret;
20008 asm("":::"memory");
20009 - __put_user_asm(4[(u16 *)src], 4 + (u16 __user *)dst,
20010 + __put_user_asm(4[(const u16 *)src], 4 + (u16 __user *)dst,
20011 ret, "w", "w", "ir", 2);
20012 return ret;
20013 case 16:
20014 - __put_user_asm(*(u64 *)src, (u64 __user *)dst,
20015 + __put_user_asm(*(const u64 *)src, (u64 __user *)dst,
20016 ret, "q", "", "er", 16);
20017 if (unlikely(ret))
20018 return ret;
20019 asm("":::"memory");
20020 - __put_user_asm(1[(u64 *)src], 1 + (u64 __user *)dst,
20021 + __put_user_asm(1[(const u64 *)src], 1 + (u64 __user *)dst,
20022 ret, "q", "", "er", 8);
20023 return ret;
20024 default:
20025 - return copy_user_generic((__force void *)dst, src, size);
20026 + return copy_user_generic((__force_kernel void *)____m(dst), src, size);
20027 }
20028 }
20029
20030 static __always_inline __must_check
20031 -int __copy_to_user(void __user *dst, const void *src, unsigned size)
20032 +unsigned long __copy_to_user(void __user *dst, const void *src, unsigned long size)
20033 {
20034 might_fault();
20035 return __copy_to_user_nocheck(dst, src, size);
20036 }
20037
20038 static __always_inline __must_check
20039 -int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
20040 +unsigned long __copy_in_user(void __user *dst, const void __user *src, unsigned size)
20041 {
20042 - int ret = 0;
20043 + unsigned ret = 0;
20044
20045 might_fault();
20046 +
20047 + if (size > INT_MAX)
20048 + return size;
20049 +
20050 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20051 + if (!access_ok_noprefault(VERIFY_READ, src, size))
20052 + return size;
20053 + if (!access_ok_noprefault(VERIFY_WRITE, dst, size))
20054 + return size;
20055 +#endif
20056 +
20057 if (!__builtin_constant_p(size))
20058 - return copy_user_generic((__force void *)dst,
20059 - (__force void *)src, size);
20060 + return copy_user_generic((__force_kernel void *)____m(dst),
20061 + (__force_kernel const void *)____m(src), size);
20062 switch (size) {
20063 case 1: {
20064 u8 tmp;
20065 - __get_user_asm(tmp, (u8 __user *)src,
20066 + __get_user_asm(tmp, (const u8 __user *)src,
20067 ret, "b", "b", "=q", 1);
20068 if (likely(!ret))
20069 __put_user_asm(tmp, (u8 __user *)dst,
20070 @@ -169,7 +221,7 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
20071 }
20072 case 2: {
20073 u16 tmp;
20074 - __get_user_asm(tmp, (u16 __user *)src,
20075 + __get_user_asm(tmp, (const u16 __user *)src,
20076 ret, "w", "w", "=r", 2);
20077 if (likely(!ret))
20078 __put_user_asm(tmp, (u16 __user *)dst,
20079 @@ -179,7 +231,7 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
20080
20081 case 4: {
20082 u32 tmp;
20083 - __get_user_asm(tmp, (u32 __user *)src,
20084 + __get_user_asm(tmp, (const u32 __user *)src,
20085 ret, "l", "k", "=r", 4);
20086 if (likely(!ret))
20087 __put_user_asm(tmp, (u32 __user *)dst,
20088 @@ -188,7 +240,7 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
20089 }
20090 case 8: {
20091 u64 tmp;
20092 - __get_user_asm(tmp, (u64 __user *)src,
20093 + __get_user_asm(tmp, (const u64 __user *)src,
20094 ret, "q", "", "=r", 8);
20095 if (likely(!ret))
20096 __put_user_asm(tmp, (u64 __user *)dst,
20097 @@ -196,41 +248,58 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
20098 return ret;
20099 }
20100 default:
20101 - return copy_user_generic((__force void *)dst,
20102 - (__force void *)src, size);
20103 + return copy_user_generic((__force_kernel void *)____m(dst),
20104 + (__force_kernel const void *)____m(src), size);
20105 }
20106 }
20107
20108 -static __must_check __always_inline int
20109 -__copy_from_user_inatomic(void *dst, const void __user *src, unsigned size)
20110 +static __must_check __always_inline unsigned long
20111 +__copy_from_user_inatomic(void *dst, const void __user *src, unsigned long size)
20112 {
20113 return __copy_from_user_nocheck(dst, src, size);
20114 }
20115
20116 -static __must_check __always_inline int
20117 -__copy_to_user_inatomic(void __user *dst, const void *src, unsigned size)
20118 +static __must_check __always_inline unsigned long
20119 +__copy_to_user_inatomic(void __user *dst, const void *src, unsigned long size)
20120 {
20121 return __copy_to_user_nocheck(dst, src, size);
20122 }
20123
20124 -extern long __copy_user_nocache(void *dst, const void __user *src,
20125 - unsigned size, int zerorest);
20126 +extern unsigned long __copy_user_nocache(void *dst, const void __user *src,
20127 + unsigned long size, int zerorest);
20128
20129 -static inline int
20130 -__copy_from_user_nocache(void *dst, const void __user *src, unsigned size)
20131 +static inline unsigned long
20132 +__copy_from_user_nocache(void *dst, const void __user *src, unsigned long size)
20133 {
20134 might_fault();
20135 +
20136 + if (size > INT_MAX)
20137 + return size;
20138 +
20139 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20140 + if (!access_ok_noprefault(VERIFY_READ, src, size))
20141 + return size;
20142 +#endif
20143 +
20144 return __copy_user_nocache(dst, src, size, 1);
20145 }
20146
20147 -static inline int
20148 +static inline unsigned long
20149 __copy_from_user_inatomic_nocache(void *dst, const void __user *src,
20150 - unsigned size)
20151 + unsigned long size)
20152 {
20153 + if (size > INT_MAX)
20154 + return size;
20155 +
20156 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20157 + if (!access_ok_noprefault(VERIFY_READ, src, size))
20158 + return size;
20159 +#endif
20160 +
20161 return __copy_user_nocache(dst, src, size, 0);
20162 }
20163
20164 unsigned long
20165 -copy_user_handle_tail(char *to, char *from, unsigned len, unsigned zerorest);
20166 +copy_user_handle_tail(char __user *to, char __user *from, unsigned long len, unsigned zerorest) __size_overflow(3);
20167
20168 #endif /* _ASM_X86_UACCESS_64_H */
20169 diff --git a/arch/x86/include/asm/word-at-a-time.h b/arch/x86/include/asm/word-at-a-time.h
20170 index 5b238981..77fdd78 100644
20171 --- a/arch/x86/include/asm/word-at-a-time.h
20172 +++ b/arch/x86/include/asm/word-at-a-time.h
20173 @@ -11,7 +11,7 @@
20174 * and shift, for example.
20175 */
20176 struct word_at_a_time {
20177 - const unsigned long one_bits, high_bits;
20178 + unsigned long one_bits, high_bits;
20179 };
20180
20181 #define WORD_AT_A_TIME_CONSTANTS { REPEAT_BYTE(0x01), REPEAT_BYTE(0x80) }
20182 diff --git a/arch/x86/include/asm/x86_init.h b/arch/x86/include/asm/x86_init.h
20183 index e45e4da..44e8572 100644
20184 --- a/arch/x86/include/asm/x86_init.h
20185 +++ b/arch/x86/include/asm/x86_init.h
20186 @@ -129,7 +129,7 @@ struct x86_init_ops {
20187 struct x86_init_timers timers;
20188 struct x86_init_iommu iommu;
20189 struct x86_init_pci pci;
20190 -};
20191 +} __no_const;
20192
20193 /**
20194 * struct x86_cpuinit_ops - platform specific cpu hotplug setups
20195 @@ -140,7 +140,7 @@ struct x86_cpuinit_ops {
20196 void (*setup_percpu_clockev)(void);
20197 void (*early_percpu_clock_init)(void);
20198 void (*fixup_cpu_id)(struct cpuinfo_x86 *c, int node);
20199 -};
20200 +} __no_const;
20201
20202 struct timespec;
20203
20204 @@ -168,7 +168,7 @@ struct x86_platform_ops {
20205 void (*save_sched_clock_state)(void);
20206 void (*restore_sched_clock_state)(void);
20207 void (*apic_post_init)(void);
20208 -};
20209 +} __no_const;
20210
20211 struct pci_dev;
20212 struct msi_msg;
20213 @@ -185,7 +185,7 @@ struct x86_msi_ops {
20214 int (*setup_hpet_msi)(unsigned int irq, unsigned int id);
20215 u32 (*msi_mask_irq)(struct msi_desc *desc, u32 mask, u32 flag);
20216 u32 (*msix_mask_irq)(struct msi_desc *desc, u32 flag);
20217 -};
20218 +} __no_const;
20219
20220 struct IO_APIC_route_entry;
20221 struct io_apic_irq_attr;
20222 @@ -206,7 +206,7 @@ struct x86_io_apic_ops {
20223 unsigned int destination, int vector,
20224 struct io_apic_irq_attr *attr);
20225 void (*eoi_ioapic_pin)(int apic, int pin, int vector);
20226 -};
20227 +} __no_const;
20228
20229 extern struct x86_init_ops x86_init;
20230 extern struct x86_cpuinit_ops x86_cpuinit;
20231 diff --git a/arch/x86/include/asm/xen/page.h b/arch/x86/include/asm/xen/page.h
20232 index c949923..c22bfa4 100644
20233 --- a/arch/x86/include/asm/xen/page.h
20234 +++ b/arch/x86/include/asm/xen/page.h
20235 @@ -63,7 +63,7 @@ extern int m2p_remove_override(struct page *page,
20236 extern struct page *m2p_find_override(unsigned long mfn);
20237 extern unsigned long m2p_find_override_pfn(unsigned long mfn, unsigned long pfn);
20238
20239 -static inline unsigned long pfn_to_mfn(unsigned long pfn)
20240 +static inline unsigned long __intentional_overflow(-1) pfn_to_mfn(unsigned long pfn)
20241 {
20242 unsigned long mfn;
20243
20244 diff --git a/arch/x86/include/asm/xsave.h b/arch/x86/include/asm/xsave.h
20245 index d949ef2..479b9d1 100644
20246 --- a/arch/x86/include/asm/xsave.h
20247 +++ b/arch/x86/include/asm/xsave.h
20248 @@ -82,8 +82,11 @@ static inline int xsave_user(struct xsave_struct __user *buf)
20249 if (unlikely(err))
20250 return -EFAULT;
20251
20252 + pax_open_userland();
20253 __asm__ __volatile__(ASM_STAC "\n"
20254 - "1: .byte " REX_PREFIX "0x0f,0xae,0x27\n"
20255 + "1:"
20256 + __copyuser_seg
20257 + ".byte " REX_PREFIX "0x0f,0xae,0x27\n"
20258 "2: " ASM_CLAC "\n"
20259 ".section .fixup,\"ax\"\n"
20260 "3: movl $-1,%[err]\n"
20261 @@ -93,18 +96,22 @@ static inline int xsave_user(struct xsave_struct __user *buf)
20262 : [err] "=r" (err)
20263 : "D" (buf), "a" (-1), "d" (-1), "0" (0)
20264 : "memory");
20265 + pax_close_userland();
20266 return err;
20267 }
20268
20269 static inline int xrestore_user(struct xsave_struct __user *buf, u64 mask)
20270 {
20271 int err;
20272 - struct xsave_struct *xstate = ((__force struct xsave_struct *)buf);
20273 + struct xsave_struct *xstate = ((__force_kernel struct xsave_struct *)buf);
20274 u32 lmask = mask;
20275 u32 hmask = mask >> 32;
20276
20277 + pax_open_userland();
20278 __asm__ __volatile__(ASM_STAC "\n"
20279 - "1: .byte " REX_PREFIX "0x0f,0xae,0x2f\n"
20280 + "1:"
20281 + __copyuser_seg
20282 + ".byte " REX_PREFIX "0x0f,0xae,0x2f\n"
20283 "2: " ASM_CLAC "\n"
20284 ".section .fixup,\"ax\"\n"
20285 "3: movl $-1,%[err]\n"
20286 @@ -114,6 +121,7 @@ static inline int xrestore_user(struct xsave_struct __user *buf, u64 mask)
20287 : [err] "=r" (err)
20288 : "D" (xstate), "a" (lmask), "d" (hmask), "0" (0)
20289 : "memory"); /* memory required? */
20290 + pax_close_userland();
20291 return err;
20292 }
20293
20294 diff --git a/arch/x86/include/uapi/asm/e820.h b/arch/x86/include/uapi/asm/e820.h
20295 index bbae024..e1528f9 100644
20296 --- a/arch/x86/include/uapi/asm/e820.h
20297 +++ b/arch/x86/include/uapi/asm/e820.h
20298 @@ -63,7 +63,7 @@ struct e820map {
20299 #define ISA_START_ADDRESS 0xa0000
20300 #define ISA_END_ADDRESS 0x100000
20301
20302 -#define BIOS_BEGIN 0x000a0000
20303 +#define BIOS_BEGIN 0x000c0000
20304 #define BIOS_END 0x00100000
20305
20306 #define BIOS_ROM_BASE 0xffe00000
20307 diff --git a/arch/x86/include/uapi/asm/ptrace-abi.h b/arch/x86/include/uapi/asm/ptrace-abi.h
20308 index 7b0a55a..ad115bf 100644
20309 --- a/arch/x86/include/uapi/asm/ptrace-abi.h
20310 +++ b/arch/x86/include/uapi/asm/ptrace-abi.h
20311 @@ -49,7 +49,6 @@
20312 #define EFLAGS 144
20313 #define RSP 152
20314 #define SS 160
20315 -#define ARGOFFSET R11
20316 #endif /* __ASSEMBLY__ */
20317
20318 /* top of stack page */
20319 diff --git a/arch/x86/kernel/Makefile b/arch/x86/kernel/Makefile
20320 index f4d9600..b45af01 100644
20321 --- a/arch/x86/kernel/Makefile
20322 +++ b/arch/x86/kernel/Makefile
20323 @@ -24,7 +24,7 @@ obj-y += time.o ioport.o ldt.o dumpstack.o nmi.o
20324 obj-y += setup.o x86_init.o i8259.o irqinit.o jump_label.o
20325 obj-$(CONFIG_IRQ_WORK) += irq_work.o
20326 obj-y += probe_roms.o
20327 -obj-$(CONFIG_X86_32) += i386_ksyms_32.o
20328 +obj-$(CONFIG_X86_32) += sys_i386_32.o i386_ksyms_32.o
20329 obj-$(CONFIG_X86_64) += sys_x86_64.o x8664_ksyms_64.o
20330 obj-y += syscall_$(BITS).o vsyscall_gtod.o
20331 obj-$(CONFIG_X86_64) += vsyscall_64.o
20332 diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c
20333 index 86281ff..e046fc2 100644
20334 --- a/arch/x86/kernel/acpi/boot.c
20335 +++ b/arch/x86/kernel/acpi/boot.c
20336 @@ -1296,7 +1296,7 @@ static int __init dmi_ignore_irq0_timer_override(const struct dmi_system_id *d)
20337 * If your system is blacklisted here, but you find that acpi=force
20338 * works for you, please contact linux-acpi@vger.kernel.org
20339 */
20340 -static struct dmi_system_id __initdata acpi_dmi_table[] = {
20341 +static const struct dmi_system_id __initconst acpi_dmi_table[] = {
20342 /*
20343 * Boxes that need ACPI disabled
20344 */
20345 @@ -1371,7 +1371,7 @@ static struct dmi_system_id __initdata acpi_dmi_table[] = {
20346 };
20347
20348 /* second table for DMI checks that should run after early-quirks */
20349 -static struct dmi_system_id __initdata acpi_dmi_table_late[] = {
20350 +static const struct dmi_system_id __initconst acpi_dmi_table_late[] = {
20351 /*
20352 * HP laptops which use a DSDT reporting as HP/SB400/10000,
20353 * which includes some code which overrides all temperature
20354 diff --git a/arch/x86/kernel/acpi/sleep.c b/arch/x86/kernel/acpi/sleep.c
20355 index 3136820..e2c6577 100644
20356 --- a/arch/x86/kernel/acpi/sleep.c
20357 +++ b/arch/x86/kernel/acpi/sleep.c
20358 @@ -99,8 +99,12 @@ int x86_acpi_suspend_lowlevel(void)
20359 #else /* CONFIG_64BIT */
20360 #ifdef CONFIG_SMP
20361 stack_start = (unsigned long)temp_stack + sizeof(temp_stack);
20362 +
20363 + pax_open_kernel();
20364 early_gdt_descr.address =
20365 (unsigned long)get_cpu_gdt_table(smp_processor_id());
20366 + pax_close_kernel();
20367 +
20368 initial_gs = per_cpu_offset(smp_processor_id());
20369 #endif
20370 initial_code = (unsigned long)wakeup_long64;
20371 diff --git a/arch/x86/kernel/acpi/wakeup_32.S b/arch/x86/kernel/acpi/wakeup_32.S
20372 index 665c6b7..eae4d56 100644
20373 --- a/arch/x86/kernel/acpi/wakeup_32.S
20374 +++ b/arch/x86/kernel/acpi/wakeup_32.S
20375 @@ -29,13 +29,11 @@ wakeup_pmode_return:
20376 # and restore the stack ... but you need gdt for this to work
20377 movl saved_context_esp, %esp
20378
20379 - movl %cs:saved_magic, %eax
20380 - cmpl $0x12345678, %eax
20381 + cmpl $0x12345678, saved_magic
20382 jne bogus_magic
20383
20384 # jump to place where we left off
20385 - movl saved_eip, %eax
20386 - jmp *%eax
20387 + jmp *(saved_eip)
20388
20389 bogus_magic:
20390 jmp bogus_magic
20391 diff --git a/arch/x86/kernel/alternative.c b/arch/x86/kernel/alternative.c
20392 index df94598..b7162f9 100644
20393 --- a/arch/x86/kernel/alternative.c
20394 +++ b/arch/x86/kernel/alternative.c
20395 @@ -269,6 +269,13 @@ void __init_or_module apply_alternatives(struct alt_instr *start,
20396 */
20397 for (a = start; a < end; a++) {
20398 instr = (u8 *)&a->instr_offset + a->instr_offset;
20399 +
20400 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
20401 + instr += ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
20402 + if (instr < (u8 *)_text || (u8 *)_einittext <= instr)
20403 + instr -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
20404 +#endif
20405 +
20406 replacement = (u8 *)&a->repl_offset + a->repl_offset;
20407 BUG_ON(a->replacementlen > a->instrlen);
20408 BUG_ON(a->instrlen > sizeof(insnbuf));
20409 @@ -285,6 +292,11 @@ void __init_or_module apply_alternatives(struct alt_instr *start,
20410 add_nops(insnbuf + a->replacementlen,
20411 a->instrlen - a->replacementlen);
20412
20413 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
20414 + if (instr < (u8 *)_text || (u8 *)_einittext <= instr)
20415 + instr = ktva_ktla(instr);
20416 +#endif
20417 +
20418 text_poke_early(instr, insnbuf, a->instrlen);
20419 }
20420 }
20421 @@ -300,10 +312,16 @@ static void alternatives_smp_lock(const s32 *start, const s32 *end,
20422 for (poff = start; poff < end; poff++) {
20423 u8 *ptr = (u8 *)poff + *poff;
20424
20425 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
20426 + ptr += ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
20427 + if (ptr < (u8 *)_text || (u8 *)_einittext <= ptr)
20428 + ptr -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
20429 +#endif
20430 +
20431 if (!*poff || ptr < text || ptr >= text_end)
20432 continue;
20433 /* turn DS segment override prefix into lock prefix */
20434 - if (*ptr == 0x3e)
20435 + if (*ktla_ktva(ptr) == 0x3e)
20436 text_poke(ptr, ((unsigned char []){0xf0}), 1);
20437 }
20438 mutex_unlock(&text_mutex);
20439 @@ -318,10 +336,16 @@ static void alternatives_smp_unlock(const s32 *start, const s32 *end,
20440 for (poff = start; poff < end; poff++) {
20441 u8 *ptr = (u8 *)poff + *poff;
20442
20443 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
20444 + ptr += ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
20445 + if (ptr < (u8 *)_text || (u8 *)_einittext <= ptr)
20446 + ptr -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
20447 +#endif
20448 +
20449 if (!*poff || ptr < text || ptr >= text_end)
20450 continue;
20451 /* turn lock prefix into DS segment override prefix */
20452 - if (*ptr == 0xf0)
20453 + if (*ktla_ktva(ptr) == 0xf0)
20454 text_poke(ptr, ((unsigned char []){0x3E}), 1);
20455 }
20456 mutex_unlock(&text_mutex);
20457 @@ -458,7 +482,7 @@ void __init_or_module apply_paravirt(struct paravirt_patch_site *start,
20458
20459 BUG_ON(p->len > MAX_PATCH_LEN);
20460 /* prep the buffer with the original instructions */
20461 - memcpy(insnbuf, p->instr, p->len);
20462 + memcpy(insnbuf, ktla_ktva(p->instr), p->len);
20463 used = pv_init_ops.patch(p->instrtype, p->clobbers, insnbuf,
20464 (unsigned long)p->instr, p->len);
20465
20466 @@ -505,7 +529,7 @@ void __init alternative_instructions(void)
20467 if (!uniproc_patched || num_possible_cpus() == 1)
20468 free_init_pages("SMP alternatives",
20469 (unsigned long)__smp_locks,
20470 - (unsigned long)__smp_locks_end);
20471 + PAGE_ALIGN((unsigned long)__smp_locks_end));
20472 #endif
20473
20474 apply_paravirt(__parainstructions, __parainstructions_end);
20475 @@ -525,13 +549,17 @@ void __init alternative_instructions(void)
20476 * instructions. And on the local CPU you need to be protected again NMI or MCE
20477 * handlers seeing an inconsistent instruction while you patch.
20478 */
20479 -void *__init_or_module text_poke_early(void *addr, const void *opcode,
20480 +void *__kprobes text_poke_early(void *addr, const void *opcode,
20481 size_t len)
20482 {
20483 unsigned long flags;
20484 local_irq_save(flags);
20485 - memcpy(addr, opcode, len);
20486 +
20487 + pax_open_kernel();
20488 + memcpy(ktla_ktva(addr), opcode, len);
20489 sync_core();
20490 + pax_close_kernel();
20491 +
20492 local_irq_restore(flags);
20493 /* Could also do a CLFLUSH here to speed up CPU recovery; but
20494 that causes hangs on some VIA CPUs. */
20495 @@ -553,36 +581,22 @@ void *__init_or_module text_poke_early(void *addr, const void *opcode,
20496 */
20497 void *__kprobes text_poke(void *addr, const void *opcode, size_t len)
20498 {
20499 - unsigned long flags;
20500 - char *vaddr;
20501 + unsigned char *vaddr = ktla_ktva(addr);
20502 struct page *pages[2];
20503 - int i;
20504 + size_t i;
20505
20506 if (!core_kernel_text((unsigned long)addr)) {
20507 - pages[0] = vmalloc_to_page(addr);
20508 - pages[1] = vmalloc_to_page(addr + PAGE_SIZE);
20509 + pages[0] = vmalloc_to_page(vaddr);
20510 + pages[1] = vmalloc_to_page(vaddr + PAGE_SIZE);
20511 } else {
20512 - pages[0] = virt_to_page(addr);
20513 + pages[0] = virt_to_page(vaddr);
20514 WARN_ON(!PageReserved(pages[0]));
20515 - pages[1] = virt_to_page(addr + PAGE_SIZE);
20516 + pages[1] = virt_to_page(vaddr + PAGE_SIZE);
20517 }
20518 BUG_ON(!pages[0]);
20519 - local_irq_save(flags);
20520 - set_fixmap(FIX_TEXT_POKE0, page_to_phys(pages[0]));
20521 - if (pages[1])
20522 - set_fixmap(FIX_TEXT_POKE1, page_to_phys(pages[1]));
20523 - vaddr = (char *)fix_to_virt(FIX_TEXT_POKE0);
20524 - memcpy(&vaddr[(unsigned long)addr & ~PAGE_MASK], opcode, len);
20525 - clear_fixmap(FIX_TEXT_POKE0);
20526 - if (pages[1])
20527 - clear_fixmap(FIX_TEXT_POKE1);
20528 - local_flush_tlb();
20529 - sync_core();
20530 - /* Could also do a CLFLUSH here to speed up CPU recovery; but
20531 - that causes hangs on some VIA CPUs. */
20532 + text_poke_early(addr, opcode, len);
20533 for (i = 0; i < len; i++)
20534 - BUG_ON(((char *)addr)[i] != ((char *)opcode)[i]);
20535 - local_irq_restore(flags);
20536 + BUG_ON((vaddr)[i] != ((const unsigned char *)opcode)[i]);
20537 return addr;
20538 }
20539
20540 @@ -602,7 +616,7 @@ int poke_int3_handler(struct pt_regs *regs)
20541 if (likely(!bp_patching_in_progress))
20542 return 0;
20543
20544 - if (user_mode_vm(regs) || regs->ip != (unsigned long)bp_int3_addr)
20545 + if (user_mode(regs) || regs->ip != (unsigned long)bp_int3_addr)
20546 return 0;
20547
20548 /* set up the specified breakpoint handler */
20549 @@ -636,7 +650,7 @@ int poke_int3_handler(struct pt_regs *regs)
20550 */
20551 void *text_poke_bp(void *addr, const void *opcode, size_t len, void *handler)
20552 {
20553 - unsigned char int3 = 0xcc;
20554 + const unsigned char int3 = 0xcc;
20555
20556 bp_int3_handler = handler;
20557 bp_int3_addr = (u8 *)addr + sizeof(int3);
20558 diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c
20559 index ad28db7..c538b2c 100644
20560 --- a/arch/x86/kernel/apic/apic.c
20561 +++ b/arch/x86/kernel/apic/apic.c
20562 @@ -201,7 +201,7 @@ int first_system_vector = 0xfe;
20563 /*
20564 * Debug level, exported for io_apic.c
20565 */
20566 -unsigned int apic_verbosity;
20567 +int apic_verbosity;
20568
20569 int pic_mode;
20570
20571 @@ -2000,7 +2000,7 @@ static inline void __smp_error_interrupt(struct pt_regs *regs)
20572 apic_write(APIC_ESR, 0);
20573 v = apic_read(APIC_ESR);
20574 ack_APIC_irq();
20575 - atomic_inc(&irq_err_count);
20576 + atomic_inc_unchecked(&irq_err_count);
20577
20578 apic_printk(APIC_DEBUG, KERN_DEBUG "APIC error on CPU%d: %02x",
20579 smp_processor_id(), v);
20580 diff --git a/arch/x86/kernel/apic/apic_flat_64.c b/arch/x86/kernel/apic/apic_flat_64.c
20581 index 7c1b294..e71d27f 100644
20582 --- a/arch/x86/kernel/apic/apic_flat_64.c
20583 +++ b/arch/x86/kernel/apic/apic_flat_64.c
20584 @@ -154,7 +154,7 @@ static int flat_probe(void)
20585 return 1;
20586 }
20587
20588 -static struct apic apic_flat = {
20589 +static struct apic apic_flat __read_only = {
20590 .name = "flat",
20591 .probe = flat_probe,
20592 .acpi_madt_oem_check = flat_acpi_madt_oem_check,
20593 @@ -268,7 +268,7 @@ static int physflat_probe(void)
20594 return 0;
20595 }
20596
20597 -static struct apic apic_physflat = {
20598 +static struct apic apic_physflat __read_only = {
20599
20600 .name = "physical flat",
20601 .probe = physflat_probe,
20602 diff --git a/arch/x86/kernel/apic/apic_noop.c b/arch/x86/kernel/apic/apic_noop.c
20603 index 8c7c982..a225910 100644
20604 --- a/arch/x86/kernel/apic/apic_noop.c
20605 +++ b/arch/x86/kernel/apic/apic_noop.c
20606 @@ -118,7 +118,7 @@ static void noop_apic_write(u32 reg, u32 v)
20607 WARN_ON_ONCE(cpu_has_apic && !disable_apic);
20608 }
20609
20610 -struct apic apic_noop = {
20611 +struct apic apic_noop __read_only = {
20612 .name = "noop",
20613 .probe = noop_probe,
20614 .acpi_madt_oem_check = NULL,
20615 diff --git a/arch/x86/kernel/apic/bigsmp_32.c b/arch/x86/kernel/apic/bigsmp_32.c
20616 index e4840aa..e7d9dac 100644
20617 --- a/arch/x86/kernel/apic/bigsmp_32.c
20618 +++ b/arch/x86/kernel/apic/bigsmp_32.c
20619 @@ -152,7 +152,7 @@ static int probe_bigsmp(void)
20620 return dmi_bigsmp;
20621 }
20622
20623 -static struct apic apic_bigsmp = {
20624 +static struct apic apic_bigsmp __read_only = {
20625
20626 .name = "bigsmp",
20627 .probe = probe_bigsmp,
20628 diff --git a/arch/x86/kernel/apic/io_apic.c b/arch/x86/kernel/apic/io_apic.c
20629 index 992060e..ecdc3b3 100644
20630 --- a/arch/x86/kernel/apic/io_apic.c
20631 +++ b/arch/x86/kernel/apic/io_apic.c
20632 @@ -1057,7 +1057,7 @@ int IO_APIC_get_PCI_irq_vector(int bus, int slot, int pin,
20633 }
20634 EXPORT_SYMBOL(IO_APIC_get_PCI_irq_vector);
20635
20636 -void lock_vector_lock(void)
20637 +void lock_vector_lock(void) __acquires(vector_lock)
20638 {
20639 /* Used to the online set of cpus does not change
20640 * during assign_irq_vector.
20641 @@ -1065,7 +1065,7 @@ void lock_vector_lock(void)
20642 raw_spin_lock(&vector_lock);
20643 }
20644
20645 -void unlock_vector_lock(void)
20646 +void unlock_vector_lock(void) __releases(vector_lock)
20647 {
20648 raw_spin_unlock(&vector_lock);
20649 }
20650 @@ -2364,7 +2364,7 @@ static void ack_apic_edge(struct irq_data *data)
20651 ack_APIC_irq();
20652 }
20653
20654 -atomic_t irq_mis_count;
20655 +atomic_unchecked_t irq_mis_count;
20656
20657 #ifdef CONFIG_GENERIC_PENDING_IRQ
20658 static bool io_apic_level_ack_pending(struct irq_cfg *cfg)
20659 @@ -2505,7 +2505,7 @@ static void ack_apic_level(struct irq_data *data)
20660 * at the cpu.
20661 */
20662 if (!(v & (1 << (i & 0x1f)))) {
20663 - atomic_inc(&irq_mis_count);
20664 + atomic_inc_unchecked(&irq_mis_count);
20665
20666 eoi_ioapic_irq(irq, cfg);
20667 }
20668 diff --git a/arch/x86/kernel/apic/probe_32.c b/arch/x86/kernel/apic/probe_32.c
20669 index cceb352..a635fd8 100644
20670 --- a/arch/x86/kernel/apic/probe_32.c
20671 +++ b/arch/x86/kernel/apic/probe_32.c
20672 @@ -72,7 +72,7 @@ static int probe_default(void)
20673 return 1;
20674 }
20675
20676 -static struct apic apic_default = {
20677 +static struct apic apic_default __read_only = {
20678
20679 .name = "default",
20680 .probe = probe_default,
20681 diff --git a/arch/x86/kernel/apic/x2apic_cluster.c b/arch/x86/kernel/apic/x2apic_cluster.c
20682 index e66766b..1c008ba 100644
20683 --- a/arch/x86/kernel/apic/x2apic_cluster.c
20684 +++ b/arch/x86/kernel/apic/x2apic_cluster.c
20685 @@ -182,7 +182,7 @@ update_clusterinfo(struct notifier_block *nfb, unsigned long action, void *hcpu)
20686 return notifier_from_errno(err);
20687 }
20688
20689 -static struct notifier_block __refdata x2apic_cpu_notifier = {
20690 +static struct notifier_block x2apic_cpu_notifier = {
20691 .notifier_call = update_clusterinfo,
20692 };
20693
20694 @@ -234,7 +234,7 @@ static void cluster_vector_allocation_domain(int cpu, struct cpumask *retmask,
20695 cpumask_and(retmask, mask, per_cpu(cpus_in_cluster, cpu));
20696 }
20697
20698 -static struct apic apic_x2apic_cluster = {
20699 +static struct apic apic_x2apic_cluster __read_only = {
20700
20701 .name = "cluster x2apic",
20702 .probe = x2apic_cluster_probe,
20703 diff --git a/arch/x86/kernel/apic/x2apic_phys.c b/arch/x86/kernel/apic/x2apic_phys.c
20704 index 6d600eb..0300c00 100644
20705 --- a/arch/x86/kernel/apic/x2apic_phys.c
20706 +++ b/arch/x86/kernel/apic/x2apic_phys.c
20707 @@ -88,7 +88,7 @@ static int x2apic_phys_probe(void)
20708 return apic == &apic_x2apic_phys;
20709 }
20710
20711 -static struct apic apic_x2apic_phys = {
20712 +static struct apic apic_x2apic_phys __read_only = {
20713
20714 .name = "physical x2apic",
20715 .probe = x2apic_phys_probe,
20716 diff --git a/arch/x86/kernel/apic/x2apic_uv_x.c b/arch/x86/kernel/apic/x2apic_uv_x.c
20717 index 7834389..4ffc9c8 100644
20718 --- a/arch/x86/kernel/apic/x2apic_uv_x.c
20719 +++ b/arch/x86/kernel/apic/x2apic_uv_x.c
20720 @@ -350,7 +350,7 @@ static int uv_probe(void)
20721 return apic == &apic_x2apic_uv_x;
20722 }
20723
20724 -static struct apic __refdata apic_x2apic_uv_x = {
20725 +static struct apic apic_x2apic_uv_x __read_only = {
20726
20727 .name = "UV large system",
20728 .probe = uv_probe,
20729 diff --git a/arch/x86/kernel/apm_32.c b/arch/x86/kernel/apm_32.c
20730 index 3ab0343..814c4787 100644
20731 --- a/arch/x86/kernel/apm_32.c
20732 +++ b/arch/x86/kernel/apm_32.c
20733 @@ -433,7 +433,7 @@ static DEFINE_MUTEX(apm_mutex);
20734 * This is for buggy BIOS's that refer to (real mode) segment 0x40
20735 * even though they are called in protected mode.
20736 */
20737 -static struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4092,
20738 +static const struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4093,
20739 (unsigned long)__va(0x400UL), PAGE_SIZE - 0x400 - 1);
20740
20741 static const char driver_version[] = "1.16ac"; /* no spaces */
20742 @@ -611,7 +611,10 @@ static long __apm_bios_call(void *_call)
20743 BUG_ON(cpu != 0);
20744 gdt = get_cpu_gdt_table(cpu);
20745 save_desc_40 = gdt[0x40 / 8];
20746 +
20747 + pax_open_kernel();
20748 gdt[0x40 / 8] = bad_bios_desc;
20749 + pax_close_kernel();
20750
20751 apm_irq_save(flags);
20752 APM_DO_SAVE_SEGS;
20753 @@ -620,7 +623,11 @@ static long __apm_bios_call(void *_call)
20754 &call->esi);
20755 APM_DO_RESTORE_SEGS;
20756 apm_irq_restore(flags);
20757 +
20758 + pax_open_kernel();
20759 gdt[0x40 / 8] = save_desc_40;
20760 + pax_close_kernel();
20761 +
20762 put_cpu();
20763
20764 return call->eax & 0xff;
20765 @@ -687,7 +694,10 @@ static long __apm_bios_call_simple(void *_call)
20766 BUG_ON(cpu != 0);
20767 gdt = get_cpu_gdt_table(cpu);
20768 save_desc_40 = gdt[0x40 / 8];
20769 +
20770 + pax_open_kernel();
20771 gdt[0x40 / 8] = bad_bios_desc;
20772 + pax_close_kernel();
20773
20774 apm_irq_save(flags);
20775 APM_DO_SAVE_SEGS;
20776 @@ -695,7 +705,11 @@ static long __apm_bios_call_simple(void *_call)
20777 &call->eax);
20778 APM_DO_RESTORE_SEGS;
20779 apm_irq_restore(flags);
20780 +
20781 + pax_open_kernel();
20782 gdt[0x40 / 8] = save_desc_40;
20783 + pax_close_kernel();
20784 +
20785 put_cpu();
20786 return error;
20787 }
20788 @@ -2362,12 +2376,15 @@ static int __init apm_init(void)
20789 * code to that CPU.
20790 */
20791 gdt = get_cpu_gdt_table(0);
20792 +
20793 + pax_open_kernel();
20794 set_desc_base(&gdt[APM_CS >> 3],
20795 (unsigned long)__va((unsigned long)apm_info.bios.cseg << 4));
20796 set_desc_base(&gdt[APM_CS_16 >> 3],
20797 (unsigned long)__va((unsigned long)apm_info.bios.cseg_16 << 4));
20798 set_desc_base(&gdt[APM_DS >> 3],
20799 (unsigned long)__va((unsigned long)apm_info.bios.dseg << 4));
20800 + pax_close_kernel();
20801
20802 proc_create("apm", 0, NULL, &apm_file_ops);
20803
20804 diff --git a/arch/x86/kernel/asm-offsets.c b/arch/x86/kernel/asm-offsets.c
20805 index 9f6b934..cf5ffb3 100644
20806 --- a/arch/x86/kernel/asm-offsets.c
20807 +++ b/arch/x86/kernel/asm-offsets.c
20808 @@ -32,6 +32,8 @@ void common(void) {
20809 OFFSET(TI_flags, thread_info, flags);
20810 OFFSET(TI_status, thread_info, status);
20811 OFFSET(TI_addr_limit, thread_info, addr_limit);
20812 + OFFSET(TI_lowest_stack, thread_info, lowest_stack);
20813 + DEFINE(TI_task_thread_sp0, offsetof(struct task_struct, thread.sp0) - offsetof(struct task_struct, tinfo));
20814
20815 BLANK();
20816 OFFSET(crypto_tfm_ctx_offset, crypto_tfm, __crt_ctx);
20817 @@ -52,8 +54,26 @@ void common(void) {
20818 OFFSET(PV_CPU_irq_enable_sysexit, pv_cpu_ops, irq_enable_sysexit);
20819 OFFSET(PV_CPU_read_cr0, pv_cpu_ops, read_cr0);
20820 OFFSET(PV_MMU_read_cr2, pv_mmu_ops, read_cr2);
20821 +
20822 +#ifdef CONFIG_PAX_KERNEXEC
20823 + OFFSET(PV_CPU_write_cr0, pv_cpu_ops, write_cr0);
20824 #endif
20825
20826 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20827 + OFFSET(PV_MMU_read_cr3, pv_mmu_ops, read_cr3);
20828 + OFFSET(PV_MMU_write_cr3, pv_mmu_ops, write_cr3);
20829 +#ifdef CONFIG_X86_64
20830 + OFFSET(PV_MMU_set_pgd_batched, pv_mmu_ops, set_pgd_batched);
20831 +#endif
20832 +#endif
20833 +
20834 +#endif
20835 +
20836 + BLANK();
20837 + DEFINE(PAGE_SIZE_asm, PAGE_SIZE);
20838 + DEFINE(PAGE_SHIFT_asm, PAGE_SHIFT);
20839 + DEFINE(THREAD_SIZE_asm, THREAD_SIZE);
20840 +
20841 #ifdef CONFIG_XEN
20842 BLANK();
20843 OFFSET(XEN_vcpu_info_mask, vcpu_info, evtchn_upcall_mask);
20844 diff --git a/arch/x86/kernel/asm-offsets_64.c b/arch/x86/kernel/asm-offsets_64.c
20845 index e7c798b..2b2019b 100644
20846 --- a/arch/x86/kernel/asm-offsets_64.c
20847 +++ b/arch/x86/kernel/asm-offsets_64.c
20848 @@ -77,6 +77,7 @@ int main(void)
20849 BLANK();
20850 #undef ENTRY
20851
20852 + DEFINE(TSS_size, sizeof(struct tss_struct));
20853 OFFSET(TSS_ist, tss_struct, x86_tss.ist);
20854 BLANK();
20855
20856 diff --git a/arch/x86/kernel/cpu/Makefile b/arch/x86/kernel/cpu/Makefile
20857 index 7fd54f0..0691410 100644
20858 --- a/arch/x86/kernel/cpu/Makefile
20859 +++ b/arch/x86/kernel/cpu/Makefile
20860 @@ -8,10 +8,6 @@ CFLAGS_REMOVE_common.o = -pg
20861 CFLAGS_REMOVE_perf_event.o = -pg
20862 endif
20863
20864 -# Make sure load_percpu_segment has no stackprotector
20865 -nostackp := $(call cc-option, -fno-stack-protector)
20866 -CFLAGS_common.o := $(nostackp)
20867 -
20868 obj-y := intel_cacheinfo.o scattered.o topology.o
20869 obj-y += proc.o capflags.o powerflags.o common.o
20870 obj-y += rdrand.o
20871 diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c
20872 index ce8b8ff..d7d8851 100644
20873 --- a/arch/x86/kernel/cpu/amd.c
20874 +++ b/arch/x86/kernel/cpu/amd.c
20875 @@ -728,7 +728,7 @@ static void init_amd(struct cpuinfo_x86 *c)
20876 static unsigned int amd_size_cache(struct cpuinfo_x86 *c, unsigned int size)
20877 {
20878 /* AMD errata T13 (order #21922) */
20879 - if ((c->x86 == 6)) {
20880 + if (c->x86 == 6) {
20881 /* Duron Rev A0 */
20882 if (c->x86_model == 3 && c->x86_mask == 0)
20883 size = 64;
20884 diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
20885 index a135239..41fb30a 100644
20886 --- a/arch/x86/kernel/cpu/common.c
20887 +++ b/arch/x86/kernel/cpu/common.c
20888 @@ -88,60 +88,6 @@ static const struct cpu_dev default_cpu = {
20889
20890 static const struct cpu_dev *this_cpu = &default_cpu;
20891
20892 -DEFINE_PER_CPU_PAGE_ALIGNED(struct gdt_page, gdt_page) = { .gdt = {
20893 -#ifdef CONFIG_X86_64
20894 - /*
20895 - * We need valid kernel segments for data and code in long mode too
20896 - * IRET will check the segment types kkeil 2000/10/28
20897 - * Also sysret mandates a special GDT layout
20898 - *
20899 - * TLS descriptors are currently at a different place compared to i386.
20900 - * Hopefully nobody expects them at a fixed place (Wine?)
20901 - */
20902 - [GDT_ENTRY_KERNEL32_CS] = GDT_ENTRY_INIT(0xc09b, 0, 0xfffff),
20903 - [GDT_ENTRY_KERNEL_CS] = GDT_ENTRY_INIT(0xa09b, 0, 0xfffff),
20904 - [GDT_ENTRY_KERNEL_DS] = GDT_ENTRY_INIT(0xc093, 0, 0xfffff),
20905 - [GDT_ENTRY_DEFAULT_USER32_CS] = GDT_ENTRY_INIT(0xc0fb, 0, 0xfffff),
20906 - [GDT_ENTRY_DEFAULT_USER_DS] = GDT_ENTRY_INIT(0xc0f3, 0, 0xfffff),
20907 - [GDT_ENTRY_DEFAULT_USER_CS] = GDT_ENTRY_INIT(0xa0fb, 0, 0xfffff),
20908 -#else
20909 - [GDT_ENTRY_KERNEL_CS] = GDT_ENTRY_INIT(0xc09a, 0, 0xfffff),
20910 - [GDT_ENTRY_KERNEL_DS] = GDT_ENTRY_INIT(0xc092, 0, 0xfffff),
20911 - [GDT_ENTRY_DEFAULT_USER_CS] = GDT_ENTRY_INIT(0xc0fa, 0, 0xfffff),
20912 - [GDT_ENTRY_DEFAULT_USER_DS] = GDT_ENTRY_INIT(0xc0f2, 0, 0xfffff),
20913 - /*
20914 - * Segments used for calling PnP BIOS have byte granularity.
20915 - * They code segments and data segments have fixed 64k limits,
20916 - * the transfer segment sizes are set at run time.
20917 - */
20918 - /* 32-bit code */
20919 - [GDT_ENTRY_PNPBIOS_CS32] = GDT_ENTRY_INIT(0x409a, 0, 0xffff),
20920 - /* 16-bit code */
20921 - [GDT_ENTRY_PNPBIOS_CS16] = GDT_ENTRY_INIT(0x009a, 0, 0xffff),
20922 - /* 16-bit data */
20923 - [GDT_ENTRY_PNPBIOS_DS] = GDT_ENTRY_INIT(0x0092, 0, 0xffff),
20924 - /* 16-bit data */
20925 - [GDT_ENTRY_PNPBIOS_TS1] = GDT_ENTRY_INIT(0x0092, 0, 0),
20926 - /* 16-bit data */
20927 - [GDT_ENTRY_PNPBIOS_TS2] = GDT_ENTRY_INIT(0x0092, 0, 0),
20928 - /*
20929 - * The APM segments have byte granularity and their bases
20930 - * are set at run time. All have 64k limits.
20931 - */
20932 - /* 32-bit code */
20933 - [GDT_ENTRY_APMBIOS_BASE] = GDT_ENTRY_INIT(0x409a, 0, 0xffff),
20934 - /* 16-bit code */
20935 - [GDT_ENTRY_APMBIOS_BASE+1] = GDT_ENTRY_INIT(0x009a, 0, 0xffff),
20936 - /* data */
20937 - [GDT_ENTRY_APMBIOS_BASE+2] = GDT_ENTRY_INIT(0x4092, 0, 0xffff),
20938 -
20939 - [GDT_ENTRY_ESPFIX_SS] = GDT_ENTRY_INIT(0xc092, 0, 0xfffff),
20940 - [GDT_ENTRY_PERCPU] = GDT_ENTRY_INIT(0xc092, 0, 0xfffff),
20941 - GDT_STACK_CANARY_INIT
20942 -#endif
20943 -} };
20944 -EXPORT_PER_CPU_SYMBOL_GPL(gdt_page);
20945 -
20946 static int __init x86_xsave_setup(char *s)
20947 {
20948 setup_clear_cpu_cap(X86_FEATURE_XSAVE);
20949 @@ -293,6 +239,59 @@ static __always_inline void setup_smap(struct cpuinfo_x86 *c)
20950 }
20951 }
20952
20953 +#ifdef CONFIG_X86_64
20954 +static __init int setup_disable_pcid(char *arg)
20955 +{
20956 + setup_clear_cpu_cap(X86_FEATURE_PCID);
20957 + setup_clear_cpu_cap(X86_FEATURE_INVPCID);
20958 +
20959 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20960 + if (clone_pgd_mask != ~(pgdval_t)0UL)
20961 + pax_user_shadow_base = 1UL << TASK_SIZE_MAX_SHIFT;
20962 +#endif
20963 +
20964 + return 1;
20965 +}
20966 +__setup("nopcid", setup_disable_pcid);
20967 +
20968 +static void setup_pcid(struct cpuinfo_x86 *c)
20969 +{
20970 + if (!cpu_has(c, X86_FEATURE_PCID)) {
20971 + clear_cpu_cap(c, X86_FEATURE_INVPCID);
20972 +
20973 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20974 + if (clone_pgd_mask != ~(pgdval_t)0UL) {
20975 + pax_open_kernel();
20976 + pax_user_shadow_base = 1UL << TASK_SIZE_MAX_SHIFT;
20977 + pax_close_kernel();
20978 + printk("PAX: slow and weak UDEREF enabled\n");
20979 + } else
20980 + printk("PAX: UDEREF disabled\n");
20981 +#endif
20982 +
20983 + return;
20984 + }
20985 +
20986 + printk("PAX: PCID detected\n");
20987 + set_in_cr4(X86_CR4_PCIDE);
20988 +
20989 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20990 + pax_open_kernel();
20991 + clone_pgd_mask = ~(pgdval_t)0UL;
20992 + pax_close_kernel();
20993 + if (pax_user_shadow_base)
20994 + printk("PAX: weak UDEREF enabled\n");
20995 + else {
20996 + set_cpu_cap(c, X86_FEATURE_STRONGUDEREF);
20997 + printk("PAX: strong UDEREF enabled\n");
20998 + }
20999 +#endif
21000 +
21001 + if (cpu_has(c, X86_FEATURE_INVPCID))
21002 + printk("PAX: INVPCID detected\n");
21003 +}
21004 +#endif
21005 +
21006 /*
21007 * Some CPU features depend on higher CPUID levels, which may not always
21008 * be available due to CPUID level capping or broken virtualization
21009 @@ -393,7 +392,7 @@ void switch_to_new_gdt(int cpu)
21010 {
21011 struct desc_ptr gdt_descr;
21012
21013 - gdt_descr.address = (long)get_cpu_gdt_table(cpu);
21014 + gdt_descr.address = (unsigned long)get_cpu_gdt_table(cpu);
21015 gdt_descr.size = GDT_SIZE - 1;
21016 load_gdt(&gdt_descr);
21017 /* Reload the per-cpu base */
21018 @@ -883,6 +882,10 @@ static void identify_cpu(struct cpuinfo_x86 *c)
21019 setup_smep(c);
21020 setup_smap(c);
21021
21022 +#ifdef CONFIG_X86_64
21023 + setup_pcid(c);
21024 +#endif
21025 +
21026 /*
21027 * The vendor-specific functions might have changed features.
21028 * Now we do "generic changes."
21029 @@ -891,6 +894,10 @@ static void identify_cpu(struct cpuinfo_x86 *c)
21030 /* Filter out anything that depends on CPUID levels we don't have */
21031 filter_cpuid_features(c, true);
21032
21033 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_SEGMEXEC) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF))
21034 + setup_clear_cpu_cap(X86_FEATURE_SEP);
21035 +#endif
21036 +
21037 /* If the model name is still unset, do table lookup. */
21038 if (!c->x86_model_id[0]) {
21039 const char *p;
21040 @@ -1079,14 +1086,16 @@ static __init int setup_disablecpuid(char *arg)
21041 }
21042 __setup("clearcpuid=", setup_disablecpuid);
21043
21044 +DEFINE_PER_CPU(struct thread_info *, current_tinfo) = &init_task.tinfo;
21045 +EXPORT_PER_CPU_SYMBOL(current_tinfo);
21046 +
21047 DEFINE_PER_CPU(unsigned long, kernel_stack) =
21048 - (unsigned long)&init_thread_union - KERNEL_STACK_OFFSET + THREAD_SIZE;
21049 + (unsigned long)&init_thread_union - 16 + THREAD_SIZE;
21050 EXPORT_PER_CPU_SYMBOL(kernel_stack);
21051
21052 #ifdef CONFIG_X86_64
21053 -struct desc_ptr idt_descr = { NR_VECTORS * 16 - 1, (unsigned long) idt_table };
21054 -struct desc_ptr debug_idt_descr = { NR_VECTORS * 16 - 1,
21055 - (unsigned long) debug_idt_table };
21056 +struct desc_ptr idt_descr __read_only = { NR_VECTORS * 16 - 1, (unsigned long) idt_table };
21057 +const struct desc_ptr debug_idt_descr = { NR_VECTORS * 16 - 1, (unsigned long) debug_idt_table };
21058
21059 DEFINE_PER_CPU_FIRST(union irq_stack_union,
21060 irq_stack_union) __aligned(PAGE_SIZE) __visible;
21061 @@ -1246,7 +1255,7 @@ void cpu_init(void)
21062 load_ucode_ap();
21063
21064 cpu = stack_smp_processor_id();
21065 - t = &per_cpu(init_tss, cpu);
21066 + t = init_tss + cpu;
21067 oist = &per_cpu(orig_ist, cpu);
21068
21069 #ifdef CONFIG_NUMA
21070 @@ -1281,7 +1290,6 @@ void cpu_init(void)
21071 wrmsrl(MSR_KERNEL_GS_BASE, 0);
21072 barrier();
21073
21074 - x86_configure_nx();
21075 enable_x2apic();
21076
21077 /*
21078 @@ -1333,7 +1341,7 @@ void cpu_init(void)
21079 {
21080 int cpu = smp_processor_id();
21081 struct task_struct *curr = current;
21082 - struct tss_struct *t = &per_cpu(init_tss, cpu);
21083 + struct tss_struct *t = init_tss + cpu;
21084 struct thread_struct *thread = &curr->thread;
21085
21086 show_ucode_info_early();
21087 diff --git a/arch/x86/kernel/cpu/intel_cacheinfo.c b/arch/x86/kernel/cpu/intel_cacheinfo.c
21088 index a952e9c..58a4cbb 100644
21089 --- a/arch/x86/kernel/cpu/intel_cacheinfo.c
21090 +++ b/arch/x86/kernel/cpu/intel_cacheinfo.c
21091 @@ -1014,6 +1014,22 @@ static struct attribute *default_attrs[] = {
21092 };
21093
21094 #ifdef CONFIG_AMD_NB
21095 +static struct attribute *default_attrs_amd_nb[] = {
21096 + &type.attr,
21097 + &level.attr,
21098 + &coherency_line_size.attr,
21099 + &physical_line_partition.attr,
21100 + &ways_of_associativity.attr,
21101 + &number_of_sets.attr,
21102 + &size.attr,
21103 + &shared_cpu_map.attr,
21104 + &shared_cpu_list.attr,
21105 + NULL,
21106 + NULL,
21107 + NULL,
21108 + NULL
21109 +};
21110 +
21111 static struct attribute **amd_l3_attrs(void)
21112 {
21113 static struct attribute **attrs;
21114 @@ -1024,18 +1040,7 @@ static struct attribute **amd_l3_attrs(void)
21115
21116 n = ARRAY_SIZE(default_attrs);
21117
21118 - if (amd_nb_has_feature(AMD_NB_L3_INDEX_DISABLE))
21119 - n += 2;
21120 -
21121 - if (amd_nb_has_feature(AMD_NB_L3_PARTITIONING))
21122 - n += 1;
21123 -
21124 - attrs = kzalloc(n * sizeof (struct attribute *), GFP_KERNEL);
21125 - if (attrs == NULL)
21126 - return attrs = default_attrs;
21127 -
21128 - for (n = 0; default_attrs[n]; n++)
21129 - attrs[n] = default_attrs[n];
21130 + attrs = default_attrs_amd_nb;
21131
21132 if (amd_nb_has_feature(AMD_NB_L3_INDEX_DISABLE)) {
21133 attrs[n++] = &cache_disable_0.attr;
21134 @@ -1086,6 +1091,13 @@ static struct kobj_type ktype_cache = {
21135 .default_attrs = default_attrs,
21136 };
21137
21138 +#ifdef CONFIG_AMD_NB
21139 +static struct kobj_type ktype_cache_amd_nb = {
21140 + .sysfs_ops = &sysfs_ops,
21141 + .default_attrs = default_attrs_amd_nb,
21142 +};
21143 +#endif
21144 +
21145 static struct kobj_type ktype_percpu_entry = {
21146 .sysfs_ops = &sysfs_ops,
21147 };
21148 @@ -1151,20 +1163,26 @@ static int cache_add_dev(struct device *dev)
21149 return retval;
21150 }
21151
21152 +#ifdef CONFIG_AMD_NB
21153 + amd_l3_attrs();
21154 +#endif
21155 +
21156 for (i = 0; i < num_cache_leaves; i++) {
21157 + struct kobj_type *ktype;
21158 +
21159 this_object = INDEX_KOBJECT_PTR(cpu, i);
21160 this_object->cpu = cpu;
21161 this_object->index = i;
21162
21163 this_leaf = CPUID4_INFO_IDX(cpu, i);
21164
21165 - ktype_cache.default_attrs = default_attrs;
21166 + ktype = &ktype_cache;
21167 #ifdef CONFIG_AMD_NB
21168 if (this_leaf->base.nb)
21169 - ktype_cache.default_attrs = amd_l3_attrs();
21170 + ktype = &ktype_cache_amd_nb;
21171 #endif
21172 retval = kobject_init_and_add(&(this_object->kobj),
21173 - &ktype_cache,
21174 + ktype,
21175 per_cpu(ici_cache_kobject, cpu),
21176 "index%1lu", i);
21177 if (unlikely(retval)) {
21178 diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c
21179 index 68317c8..c860d41 100644
21180 --- a/arch/x86/kernel/cpu/mcheck/mce.c
21181 +++ b/arch/x86/kernel/cpu/mcheck/mce.c
21182 @@ -45,6 +45,7 @@
21183 #include <asm/processor.h>
21184 #include <asm/mce.h>
21185 #include <asm/msr.h>
21186 +#include <asm/local.h>
21187
21188 #include "mce-internal.h"
21189
21190 @@ -261,7 +262,7 @@ static void print_mce(struct mce *m)
21191 !(m->mcgstatus & MCG_STATUS_EIPV) ? " !INEXACT!" : "",
21192 m->cs, m->ip);
21193
21194 - if (m->cs == __KERNEL_CS)
21195 + if (m->cs == __KERNEL_CS || m->cs == __KERNEXEC_KERNEL_CS)
21196 print_symbol("{%s}", m->ip);
21197 pr_cont("\n");
21198 }
21199 @@ -294,10 +295,10 @@ static void print_mce(struct mce *m)
21200
21201 #define PANIC_TIMEOUT 5 /* 5 seconds */
21202
21203 -static atomic_t mce_paniced;
21204 +static atomic_unchecked_t mce_paniced;
21205
21206 static int fake_panic;
21207 -static atomic_t mce_fake_paniced;
21208 +static atomic_unchecked_t mce_fake_paniced;
21209
21210 /* Panic in progress. Enable interrupts and wait for final IPI */
21211 static void wait_for_panic(void)
21212 @@ -321,7 +322,7 @@ static void mce_panic(char *msg, struct mce *final, char *exp)
21213 /*
21214 * Make sure only one CPU runs in machine check panic
21215 */
21216 - if (atomic_inc_return(&mce_paniced) > 1)
21217 + if (atomic_inc_return_unchecked(&mce_paniced) > 1)
21218 wait_for_panic();
21219 barrier();
21220
21221 @@ -329,7 +330,7 @@ static void mce_panic(char *msg, struct mce *final, char *exp)
21222 console_verbose();
21223 } else {
21224 /* Don't log too much for fake panic */
21225 - if (atomic_inc_return(&mce_fake_paniced) > 1)
21226 + if (atomic_inc_return_unchecked(&mce_fake_paniced) > 1)
21227 return;
21228 }
21229 /* First print corrected ones that are still unlogged */
21230 @@ -368,7 +369,7 @@ static void mce_panic(char *msg, struct mce *final, char *exp)
21231 if (!fake_panic) {
21232 if (panic_timeout == 0)
21233 panic_timeout = mca_cfg.panic_timeout;
21234 - panic(msg);
21235 + panic("%s", msg);
21236 } else
21237 pr_emerg(HW_ERR "Fake kernel panic: %s\n", msg);
21238 }
21239 @@ -699,7 +700,7 @@ static int mce_timed_out(u64 *t)
21240 * might have been modified by someone else.
21241 */
21242 rmb();
21243 - if (atomic_read(&mce_paniced))
21244 + if (atomic_read_unchecked(&mce_paniced))
21245 wait_for_panic();
21246 if (!mca_cfg.monarch_timeout)
21247 goto out;
21248 @@ -1680,7 +1681,7 @@ static void unexpected_machine_check(struct pt_regs *regs, long error_code)
21249 }
21250
21251 /* Call the installed machine check handler for this CPU setup. */
21252 -void (*machine_check_vector)(struct pt_regs *, long error_code) =
21253 +void (*machine_check_vector)(struct pt_regs *, long error_code) __read_only =
21254 unexpected_machine_check;
21255
21256 /*
21257 @@ -1703,7 +1704,9 @@ void mcheck_cpu_init(struct cpuinfo_x86 *c)
21258 return;
21259 }
21260
21261 + pax_open_kernel();
21262 machine_check_vector = do_machine_check;
21263 + pax_close_kernel();
21264
21265 __mcheck_cpu_init_generic();
21266 __mcheck_cpu_init_vendor(c);
21267 @@ -1717,7 +1720,7 @@ void mcheck_cpu_init(struct cpuinfo_x86 *c)
21268 */
21269
21270 static DEFINE_SPINLOCK(mce_chrdev_state_lock);
21271 -static int mce_chrdev_open_count; /* #times opened */
21272 +static local_t mce_chrdev_open_count; /* #times opened */
21273 static int mce_chrdev_open_exclu; /* already open exclusive? */
21274
21275 static int mce_chrdev_open(struct inode *inode, struct file *file)
21276 @@ -1725,7 +1728,7 @@ static int mce_chrdev_open(struct inode *inode, struct file *file)
21277 spin_lock(&mce_chrdev_state_lock);
21278
21279 if (mce_chrdev_open_exclu ||
21280 - (mce_chrdev_open_count && (file->f_flags & O_EXCL))) {
21281 + (local_read(&mce_chrdev_open_count) && (file->f_flags & O_EXCL))) {
21282 spin_unlock(&mce_chrdev_state_lock);
21283
21284 return -EBUSY;
21285 @@ -1733,7 +1736,7 @@ static int mce_chrdev_open(struct inode *inode, struct file *file)
21286
21287 if (file->f_flags & O_EXCL)
21288 mce_chrdev_open_exclu = 1;
21289 - mce_chrdev_open_count++;
21290 + local_inc(&mce_chrdev_open_count);
21291
21292 spin_unlock(&mce_chrdev_state_lock);
21293
21294 @@ -1744,7 +1747,7 @@ static int mce_chrdev_release(struct inode *inode, struct file *file)
21295 {
21296 spin_lock(&mce_chrdev_state_lock);
21297
21298 - mce_chrdev_open_count--;
21299 + local_dec(&mce_chrdev_open_count);
21300 mce_chrdev_open_exclu = 0;
21301
21302 spin_unlock(&mce_chrdev_state_lock);
21303 @@ -2420,7 +2423,7 @@ static __init void mce_init_banks(void)
21304
21305 for (i = 0; i < mca_cfg.banks; i++) {
21306 struct mce_bank *b = &mce_banks[i];
21307 - struct device_attribute *a = &b->attr;
21308 + device_attribute_no_const *a = &b->attr;
21309
21310 sysfs_attr_init(&a->attr);
21311 a->attr.name = b->attrname;
21312 @@ -2492,7 +2495,7 @@ struct dentry *mce_get_debugfs_dir(void)
21313 static void mce_reset(void)
21314 {
21315 cpu_missing = 0;
21316 - atomic_set(&mce_fake_paniced, 0);
21317 + atomic_set_unchecked(&mce_fake_paniced, 0);
21318 atomic_set(&mce_executing, 0);
21319 atomic_set(&mce_callin, 0);
21320 atomic_set(&global_nwo, 0);
21321 diff --git a/arch/x86/kernel/cpu/mcheck/p5.c b/arch/x86/kernel/cpu/mcheck/p5.c
21322 index a304298..49b6d06 100644
21323 --- a/arch/x86/kernel/cpu/mcheck/p5.c
21324 +++ b/arch/x86/kernel/cpu/mcheck/p5.c
21325 @@ -10,6 +10,7 @@
21326 #include <asm/processor.h>
21327 #include <asm/mce.h>
21328 #include <asm/msr.h>
21329 +#include <asm/pgtable.h>
21330
21331 /* By default disabled */
21332 int mce_p5_enabled __read_mostly;
21333 @@ -48,7 +49,9 @@ void intel_p5_mcheck_init(struct cpuinfo_x86 *c)
21334 if (!cpu_has(c, X86_FEATURE_MCE))
21335 return;
21336
21337 + pax_open_kernel();
21338 machine_check_vector = pentium_machine_check;
21339 + pax_close_kernel();
21340 /* Make sure the vector pointer is visible before we enable MCEs: */
21341 wmb();
21342
21343 diff --git a/arch/x86/kernel/cpu/mcheck/winchip.c b/arch/x86/kernel/cpu/mcheck/winchip.c
21344 index 7dc5564..1273569 100644
21345 --- a/arch/x86/kernel/cpu/mcheck/winchip.c
21346 +++ b/arch/x86/kernel/cpu/mcheck/winchip.c
21347 @@ -9,6 +9,7 @@
21348 #include <asm/processor.h>
21349 #include <asm/mce.h>
21350 #include <asm/msr.h>
21351 +#include <asm/pgtable.h>
21352
21353 /* Machine check handler for WinChip C6: */
21354 static void winchip_machine_check(struct pt_regs *regs, long error_code)
21355 @@ -22,7 +23,9 @@ void winchip_mcheck_init(struct cpuinfo_x86 *c)
21356 {
21357 u32 lo, hi;
21358
21359 + pax_open_kernel();
21360 machine_check_vector = winchip_machine_check;
21361 + pax_close_kernel();
21362 /* Make sure the vector pointer is visible before we enable MCEs: */
21363 wmb();
21364
21365 diff --git a/arch/x86/kernel/cpu/microcode/core.c b/arch/x86/kernel/cpu/microcode/core.c
21366 index 15c9876..0a43909 100644
21367 --- a/arch/x86/kernel/cpu/microcode/core.c
21368 +++ b/arch/x86/kernel/cpu/microcode/core.c
21369 @@ -513,7 +513,7 @@ mc_cpu_callback(struct notifier_block *nb, unsigned long action, void *hcpu)
21370 return NOTIFY_OK;
21371 }
21372
21373 -static struct notifier_block __refdata mc_cpu_notifier = {
21374 +static struct notifier_block mc_cpu_notifier = {
21375 .notifier_call = mc_cpu_callback,
21376 };
21377
21378 diff --git a/arch/x86/kernel/cpu/microcode/intel.c b/arch/x86/kernel/cpu/microcode/intel.c
21379 index a276fa7..e66810f 100644
21380 --- a/arch/x86/kernel/cpu/microcode/intel.c
21381 +++ b/arch/x86/kernel/cpu/microcode/intel.c
21382 @@ -293,13 +293,13 @@ static enum ucode_state request_microcode_fw(int cpu, struct device *device,
21383
21384 static int get_ucode_user(void *to, const void *from, size_t n)
21385 {
21386 - return copy_from_user(to, from, n);
21387 + return copy_from_user(to, (const void __force_user *)from, n);
21388 }
21389
21390 static enum ucode_state
21391 request_microcode_user(int cpu, const void __user *buf, size_t size)
21392 {
21393 - return generic_load_microcode(cpu, (void *)buf, size, &get_ucode_user);
21394 + return generic_load_microcode(cpu, (__force_kernel void *)buf, size, &get_ucode_user);
21395 }
21396
21397 static void microcode_fini_cpu(int cpu)
21398 diff --git a/arch/x86/kernel/cpu/mtrr/main.c b/arch/x86/kernel/cpu/mtrr/main.c
21399 index f961de9..8a9d332 100644
21400 --- a/arch/x86/kernel/cpu/mtrr/main.c
21401 +++ b/arch/x86/kernel/cpu/mtrr/main.c
21402 @@ -66,7 +66,7 @@ static DEFINE_MUTEX(mtrr_mutex);
21403 u64 size_or_mask, size_and_mask;
21404 static bool mtrr_aps_delayed_init;
21405
21406 -static const struct mtrr_ops *mtrr_ops[X86_VENDOR_NUM];
21407 +static const struct mtrr_ops *mtrr_ops[X86_VENDOR_NUM] __read_only;
21408
21409 const struct mtrr_ops *mtrr_if;
21410
21411 diff --git a/arch/x86/kernel/cpu/mtrr/mtrr.h b/arch/x86/kernel/cpu/mtrr/mtrr.h
21412 index df5e41f..816c719 100644
21413 --- a/arch/x86/kernel/cpu/mtrr/mtrr.h
21414 +++ b/arch/x86/kernel/cpu/mtrr/mtrr.h
21415 @@ -25,7 +25,7 @@ struct mtrr_ops {
21416 int (*validate_add_page)(unsigned long base, unsigned long size,
21417 unsigned int type);
21418 int (*have_wrcomb)(void);
21419 -};
21420 +} __do_const;
21421
21422 extern int generic_get_free_region(unsigned long base, unsigned long size,
21423 int replace_reg);
21424 diff --git a/arch/x86/kernel/cpu/perf_event.c b/arch/x86/kernel/cpu/perf_event.c
21425 index ae407f7..39c5b00 100644
21426 --- a/arch/x86/kernel/cpu/perf_event.c
21427 +++ b/arch/x86/kernel/cpu/perf_event.c
21428 @@ -1367,7 +1367,7 @@ static void __init pmu_check_apic(void)
21429 pr_info("no hardware sampling interrupt available.\n");
21430 }
21431
21432 -static struct attribute_group x86_pmu_format_group = {
21433 +static attribute_group_no_const x86_pmu_format_group = {
21434 .name = "format",
21435 .attrs = NULL,
21436 };
21437 @@ -1466,7 +1466,7 @@ static struct attribute *events_attr[] = {
21438 NULL,
21439 };
21440
21441 -static struct attribute_group x86_pmu_events_group = {
21442 +static attribute_group_no_const x86_pmu_events_group = {
21443 .name = "events",
21444 .attrs = events_attr,
21445 };
21446 @@ -1990,7 +1990,7 @@ static unsigned long get_segment_base(unsigned int segment)
21447 if (idx > GDT_ENTRIES)
21448 return 0;
21449
21450 - desc = __this_cpu_ptr(&gdt_page.gdt[0]);
21451 + desc = get_cpu_gdt_table(smp_processor_id());
21452 }
21453
21454 return get_desc_base(desc + idx);
21455 @@ -2080,7 +2080,7 @@ perf_callchain_user(struct perf_callchain_entry *entry, struct pt_regs *regs)
21456 break;
21457
21458 perf_callchain_store(entry, frame.return_address);
21459 - fp = frame.next_frame;
21460 + fp = (const void __force_user *)frame.next_frame;
21461 }
21462 }
21463
21464 diff --git a/arch/x86/kernel/cpu/perf_event_amd_iommu.c b/arch/x86/kernel/cpu/perf_event_amd_iommu.c
21465 index 639d128..e92d7e5 100644
21466 --- a/arch/x86/kernel/cpu/perf_event_amd_iommu.c
21467 +++ b/arch/x86/kernel/cpu/perf_event_amd_iommu.c
21468 @@ -405,7 +405,7 @@ static void perf_iommu_del(struct perf_event *event, int flags)
21469 static __init int _init_events_attrs(struct perf_amd_iommu *perf_iommu)
21470 {
21471 struct attribute **attrs;
21472 - struct attribute_group *attr_group;
21473 + attribute_group_no_const *attr_group;
21474 int i = 0, j;
21475
21476 while (amd_iommu_v2_event_descs[i].attr.attr.name)
21477 diff --git a/arch/x86/kernel/cpu/perf_event_intel.c b/arch/x86/kernel/cpu/perf_event_intel.c
21478 index adb02aa..9688c02 100644
21479 --- a/arch/x86/kernel/cpu/perf_event_intel.c
21480 +++ b/arch/x86/kernel/cpu/perf_event_intel.c
21481 @@ -2308,10 +2308,10 @@ __init int intel_pmu_init(void)
21482 x86_pmu.num_counters_fixed = max((int)edx.split.num_counters_fixed, 3);
21483
21484 if (boot_cpu_has(X86_FEATURE_PDCM)) {
21485 - u64 capabilities;
21486 + u64 capabilities = x86_pmu.intel_cap.capabilities;
21487
21488 - rdmsrl(MSR_IA32_PERF_CAPABILITIES, capabilities);
21489 - x86_pmu.intel_cap.capabilities = capabilities;
21490 + if (rdmsrl_safe(MSR_IA32_PERF_CAPABILITIES, &x86_pmu.intel_cap.capabilities))
21491 + x86_pmu.intel_cap.capabilities = capabilities;
21492 }
21493
21494 intel_ds_init();
21495 diff --git a/arch/x86/kernel/cpu/perf_event_intel_rapl.c b/arch/x86/kernel/cpu/perf_event_intel_rapl.c
21496 index 619f769..d510008 100644
21497 --- a/arch/x86/kernel/cpu/perf_event_intel_rapl.c
21498 +++ b/arch/x86/kernel/cpu/perf_event_intel_rapl.c
21499 @@ -449,7 +449,7 @@ static struct attribute *rapl_events_hsw_attr[] = {
21500 NULL,
21501 };
21502
21503 -static struct attribute_group rapl_pmu_events_group = {
21504 +static attribute_group_no_const rapl_pmu_events_group __read_only = {
21505 .name = "events",
21506 .attrs = NULL, /* patched at runtime */
21507 };
21508 diff --git a/arch/x86/kernel/cpu/perf_event_intel_uncore.c b/arch/x86/kernel/cpu/perf_event_intel_uncore.c
21509 index 65bbbea..1438d9e 100644
21510 --- a/arch/x86/kernel/cpu/perf_event_intel_uncore.c
21511 +++ b/arch/x86/kernel/cpu/perf_event_intel_uncore.c
21512 @@ -3693,7 +3693,7 @@ static void __init uncore_types_exit(struct intel_uncore_type **types)
21513 static int __init uncore_type_init(struct intel_uncore_type *type)
21514 {
21515 struct intel_uncore_pmu *pmus;
21516 - struct attribute_group *attr_group;
21517 + attribute_group_no_const *attr_group;
21518 struct attribute **attrs;
21519 int i, j;
21520
21521 diff --git a/arch/x86/kernel/cpu/perf_event_intel_uncore.h b/arch/x86/kernel/cpu/perf_event_intel_uncore.h
21522 index 90236f0..54cb20d 100644
21523 --- a/arch/x86/kernel/cpu/perf_event_intel_uncore.h
21524 +++ b/arch/x86/kernel/cpu/perf_event_intel_uncore.h
21525 @@ -503,7 +503,7 @@ struct intel_uncore_box {
21526 struct uncore_event_desc {
21527 struct kobj_attribute attr;
21528 const char *config;
21529 -};
21530 +} __do_const;
21531
21532 #define INTEL_UNCORE_EVENT_DESC(_name, _config) \
21533 { \
21534 diff --git a/arch/x86/kernel/cpuid.c b/arch/x86/kernel/cpuid.c
21535 index 3225ae6c..ee3c6db 100644
21536 --- a/arch/x86/kernel/cpuid.c
21537 +++ b/arch/x86/kernel/cpuid.c
21538 @@ -170,7 +170,7 @@ static int cpuid_class_cpu_callback(struct notifier_block *nfb,
21539 return notifier_from_errno(err);
21540 }
21541
21542 -static struct notifier_block __refdata cpuid_class_cpu_notifier =
21543 +static struct notifier_block cpuid_class_cpu_notifier =
21544 {
21545 .notifier_call = cpuid_class_cpu_callback,
21546 };
21547 diff --git a/arch/x86/kernel/crash.c b/arch/x86/kernel/crash.c
21548 index 507de80..ebaae2a 100644
21549 --- a/arch/x86/kernel/crash.c
21550 +++ b/arch/x86/kernel/crash.c
21551 @@ -58,7 +58,7 @@ static void kdump_nmi_callback(int cpu, struct pt_regs *regs)
21552 #ifdef CONFIG_X86_32
21553 struct pt_regs fixed_regs;
21554
21555 - if (!user_mode_vm(regs)) {
21556 + if (!user_mode(regs)) {
21557 crash_fixup_ss_esp(&fixed_regs, regs);
21558 regs = &fixed_regs;
21559 }
21560 diff --git a/arch/x86/kernel/crash_dump_64.c b/arch/x86/kernel/crash_dump_64.c
21561 index afa64ad..dce67dd 100644
21562 --- a/arch/x86/kernel/crash_dump_64.c
21563 +++ b/arch/x86/kernel/crash_dump_64.c
21564 @@ -36,7 +36,7 @@ ssize_t copy_oldmem_page(unsigned long pfn, char *buf,
21565 return -ENOMEM;
21566
21567 if (userbuf) {
21568 - if (copy_to_user(buf, vaddr + offset, csize)) {
21569 + if (copy_to_user((char __force_user *)buf, vaddr + offset, csize)) {
21570 iounmap(vaddr);
21571 return -EFAULT;
21572 }
21573 diff --git a/arch/x86/kernel/doublefault.c b/arch/x86/kernel/doublefault.c
21574 index f6dfd93..892ade4 100644
21575 --- a/arch/x86/kernel/doublefault.c
21576 +++ b/arch/x86/kernel/doublefault.c
21577 @@ -12,7 +12,7 @@
21578
21579 #define DOUBLEFAULT_STACKSIZE (1024)
21580 static unsigned long doublefault_stack[DOUBLEFAULT_STACKSIZE];
21581 -#define STACK_START (unsigned long)(doublefault_stack+DOUBLEFAULT_STACKSIZE)
21582 +#define STACK_START (unsigned long)(doublefault_stack+DOUBLEFAULT_STACKSIZE-2)
21583
21584 #define ptr_ok(x) ((x) > PAGE_OFFSET && (x) < PAGE_OFFSET + MAXMEM)
21585
21586 @@ -22,7 +22,7 @@ static void doublefault_fn(void)
21587 unsigned long gdt, tss;
21588
21589 native_store_gdt(&gdt_desc);
21590 - gdt = gdt_desc.address;
21591 + gdt = (unsigned long)gdt_desc.address;
21592
21593 printk(KERN_EMERG "PANIC: double fault, gdt at %08lx [%d bytes]\n", gdt, gdt_desc.size);
21594
21595 @@ -59,10 +59,10 @@ struct tss_struct doublefault_tss __cacheline_aligned = {
21596 /* 0x2 bit is always set */
21597 .flags = X86_EFLAGS_SF | 0x2,
21598 .sp = STACK_START,
21599 - .es = __USER_DS,
21600 + .es = __KERNEL_DS,
21601 .cs = __KERNEL_CS,
21602 .ss = __KERNEL_DS,
21603 - .ds = __USER_DS,
21604 + .ds = __KERNEL_DS,
21605 .fs = __KERNEL_PERCPU,
21606
21607 .__cr3 = __pa_nodebug(swapper_pg_dir),
21608 diff --git a/arch/x86/kernel/dumpstack.c b/arch/x86/kernel/dumpstack.c
21609 index d9c12d3..7858b62 100644
21610 --- a/arch/x86/kernel/dumpstack.c
21611 +++ b/arch/x86/kernel/dumpstack.c
21612 @@ -2,6 +2,9 @@
21613 * Copyright (C) 1991, 1992 Linus Torvalds
21614 * Copyright (C) 2000, 2001, 2002 Andi Kleen, SuSE Labs
21615 */
21616 +#ifdef CONFIG_GRKERNSEC_HIDESYM
21617 +#define __INCLUDED_BY_HIDESYM 1
21618 +#endif
21619 #include <linux/kallsyms.h>
21620 #include <linux/kprobes.h>
21621 #include <linux/uaccess.h>
21622 @@ -40,16 +43,14 @@ void printk_address(unsigned long address)
21623 static void
21624 print_ftrace_graph_addr(unsigned long addr, void *data,
21625 const struct stacktrace_ops *ops,
21626 - struct thread_info *tinfo, int *graph)
21627 + struct task_struct *task, int *graph)
21628 {
21629 - struct task_struct *task;
21630 unsigned long ret_addr;
21631 int index;
21632
21633 if (addr != (unsigned long)return_to_handler)
21634 return;
21635
21636 - task = tinfo->task;
21637 index = task->curr_ret_stack;
21638
21639 if (!task->ret_stack || index < *graph)
21640 @@ -66,7 +67,7 @@ print_ftrace_graph_addr(unsigned long addr, void *data,
21641 static inline void
21642 print_ftrace_graph_addr(unsigned long addr, void *data,
21643 const struct stacktrace_ops *ops,
21644 - struct thread_info *tinfo, int *graph)
21645 + struct task_struct *task, int *graph)
21646 { }
21647 #endif
21648
21649 @@ -77,10 +78,8 @@ print_ftrace_graph_addr(unsigned long addr, void *data,
21650 * severe exception (double fault, nmi, stack fault, debug, mce) hardware stack
21651 */
21652
21653 -static inline int valid_stack_ptr(struct thread_info *tinfo,
21654 - void *p, unsigned int size, void *end)
21655 +static inline int valid_stack_ptr(void *t, void *p, unsigned int size, void *end)
21656 {
21657 - void *t = tinfo;
21658 if (end) {
21659 if (p < end && p >= (end-THREAD_SIZE))
21660 return 1;
21661 @@ -91,14 +90,14 @@ static inline int valid_stack_ptr(struct thread_info *tinfo,
21662 }
21663
21664 unsigned long
21665 -print_context_stack(struct thread_info *tinfo,
21666 +print_context_stack(struct task_struct *task, void *stack_start,
21667 unsigned long *stack, unsigned long bp,
21668 const struct stacktrace_ops *ops, void *data,
21669 unsigned long *end, int *graph)
21670 {
21671 struct stack_frame *frame = (struct stack_frame *)bp;
21672
21673 - while (valid_stack_ptr(tinfo, stack, sizeof(*stack), end)) {
21674 + while (valid_stack_ptr(stack_start, stack, sizeof(*stack), end)) {
21675 unsigned long addr;
21676
21677 addr = *stack;
21678 @@ -110,7 +109,7 @@ print_context_stack(struct thread_info *tinfo,
21679 } else {
21680 ops->address(data, addr, 0);
21681 }
21682 - print_ftrace_graph_addr(addr, data, ops, tinfo, graph);
21683 + print_ftrace_graph_addr(addr, data, ops, task, graph);
21684 }
21685 stack++;
21686 }
21687 @@ -119,7 +118,7 @@ print_context_stack(struct thread_info *tinfo,
21688 EXPORT_SYMBOL_GPL(print_context_stack);
21689
21690 unsigned long
21691 -print_context_stack_bp(struct thread_info *tinfo,
21692 +print_context_stack_bp(struct task_struct *task, void *stack_start,
21693 unsigned long *stack, unsigned long bp,
21694 const struct stacktrace_ops *ops, void *data,
21695 unsigned long *end, int *graph)
21696 @@ -127,7 +126,7 @@ print_context_stack_bp(struct thread_info *tinfo,
21697 struct stack_frame *frame = (struct stack_frame *)bp;
21698 unsigned long *ret_addr = &frame->return_address;
21699
21700 - while (valid_stack_ptr(tinfo, ret_addr, sizeof(*ret_addr), end)) {
21701 + while (valid_stack_ptr(stack_start, ret_addr, sizeof(*ret_addr), end)) {
21702 unsigned long addr = *ret_addr;
21703
21704 if (!__kernel_text_address(addr))
21705 @@ -136,7 +135,7 @@ print_context_stack_bp(struct thread_info *tinfo,
21706 ops->address(data, addr, 1);
21707 frame = frame->next_frame;
21708 ret_addr = &frame->return_address;
21709 - print_ftrace_graph_addr(addr, data, ops, tinfo, graph);
21710 + print_ftrace_graph_addr(addr, data, ops, task, graph);
21711 }
21712
21713 return (unsigned long)frame;
21714 @@ -155,7 +154,7 @@ static int print_trace_stack(void *data, char *name)
21715 static void print_trace_address(void *data, unsigned long addr, int reliable)
21716 {
21717 touch_nmi_watchdog();
21718 - printk(data);
21719 + printk("%s", (char *)data);
21720 printk_stack_address(addr, reliable);
21721 }
21722
21723 @@ -224,6 +223,8 @@ unsigned __kprobes long oops_begin(void)
21724 }
21725 EXPORT_SYMBOL_GPL(oops_begin);
21726
21727 +extern void gr_handle_kernel_exploit(void);
21728 +
21729 void __kprobes oops_end(unsigned long flags, struct pt_regs *regs, int signr)
21730 {
21731 if (regs && kexec_should_crash(current))
21732 @@ -245,7 +246,10 @@ void __kprobes oops_end(unsigned long flags, struct pt_regs *regs, int signr)
21733 panic("Fatal exception in interrupt");
21734 if (panic_on_oops)
21735 panic("Fatal exception");
21736 - do_exit(signr);
21737 +
21738 + gr_handle_kernel_exploit();
21739 +
21740 + do_group_exit(signr);
21741 }
21742
21743 int __kprobes __die(const char *str, struct pt_regs *regs, long err)
21744 @@ -273,7 +277,7 @@ int __kprobes __die(const char *str, struct pt_regs *regs, long err)
21745 print_modules();
21746 show_regs(regs);
21747 #ifdef CONFIG_X86_32
21748 - if (user_mode_vm(regs)) {
21749 + if (user_mode(regs)) {
21750 sp = regs->sp;
21751 ss = regs->ss & 0xffff;
21752 } else {
21753 @@ -301,7 +305,7 @@ void die(const char *str, struct pt_regs *regs, long err)
21754 unsigned long flags = oops_begin();
21755 int sig = SIGSEGV;
21756
21757 - if (!user_mode_vm(regs))
21758 + if (!user_mode(regs))
21759 report_bug(regs->ip, regs);
21760
21761 if (__die(str, regs, err))
21762 diff --git a/arch/x86/kernel/dumpstack_32.c b/arch/x86/kernel/dumpstack_32.c
21763 index 5abd4cd..c65733b 100644
21764 --- a/arch/x86/kernel/dumpstack_32.c
21765 +++ b/arch/x86/kernel/dumpstack_32.c
21766 @@ -61,15 +61,14 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
21767 bp = stack_frame(task, regs);
21768
21769 for (;;) {
21770 - struct thread_info *context;
21771 + void *stack_start = (void *)((unsigned long)stack & ~(THREAD_SIZE-1));
21772 void *end_stack;
21773
21774 end_stack = is_hardirq_stack(stack, cpu);
21775 if (!end_stack)
21776 end_stack = is_softirq_stack(stack, cpu);
21777
21778 - context = task_thread_info(task);
21779 - bp = ops->walk_stack(context, stack, bp, ops, data,
21780 + bp = ops->walk_stack(task, stack_start, stack, bp, ops, data,
21781 end_stack, &graph);
21782
21783 /* Stop if not on irq stack */
21784 @@ -123,27 +122,28 @@ void show_regs(struct pt_regs *regs)
21785 int i;
21786
21787 show_regs_print_info(KERN_EMERG);
21788 - __show_regs(regs, !user_mode_vm(regs));
21789 + __show_regs(regs, !user_mode(regs));
21790
21791 /*
21792 * When in-kernel, we also print out the stack and code at the
21793 * time of the fault..
21794 */
21795 - if (!user_mode_vm(regs)) {
21796 + if (!user_mode(regs)) {
21797 unsigned int code_prologue = code_bytes * 43 / 64;
21798 unsigned int code_len = code_bytes;
21799 unsigned char c;
21800 u8 *ip;
21801 + unsigned long cs_base = get_desc_base(&get_cpu_gdt_table(0)[(0xffff & regs->cs) >> 3]);
21802
21803 pr_emerg("Stack:\n");
21804 show_stack_log_lvl(NULL, regs, &regs->sp, 0, KERN_EMERG);
21805
21806 pr_emerg("Code:");
21807
21808 - ip = (u8 *)regs->ip - code_prologue;
21809 + ip = (u8 *)regs->ip - code_prologue + cs_base;
21810 if (ip < (u8 *)PAGE_OFFSET || probe_kernel_address(ip, c)) {
21811 /* try starting at IP */
21812 - ip = (u8 *)regs->ip;
21813 + ip = (u8 *)regs->ip + cs_base;
21814 code_len = code_len - code_prologue + 1;
21815 }
21816 for (i = 0; i < code_len; i++, ip++) {
21817 @@ -152,7 +152,7 @@ void show_regs(struct pt_regs *regs)
21818 pr_cont(" Bad EIP value.");
21819 break;
21820 }
21821 - if (ip == (u8 *)regs->ip)
21822 + if (ip == (u8 *)regs->ip + cs_base)
21823 pr_cont(" <%02x>", c);
21824 else
21825 pr_cont(" %02x", c);
21826 @@ -165,6 +165,7 @@ int is_valid_bugaddr(unsigned long ip)
21827 {
21828 unsigned short ud2;
21829
21830 + ip = ktla_ktva(ip);
21831 if (ip < PAGE_OFFSET)
21832 return 0;
21833 if (probe_kernel_address((unsigned short *)ip, ud2))
21834 @@ -172,3 +173,15 @@ int is_valid_bugaddr(unsigned long ip)
21835
21836 return ud2 == 0x0b0f;
21837 }
21838 +
21839 +#if defined(CONFIG_PAX_MEMORY_STACKLEAK) || defined(CONFIG_PAX_USERCOPY)
21840 +void pax_check_alloca(unsigned long size)
21841 +{
21842 + unsigned long sp = (unsigned long)&sp, stack_left;
21843 +
21844 + /* all kernel stacks are of the same size */
21845 + stack_left = sp & (THREAD_SIZE - 1);
21846 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
21847 +}
21848 +EXPORT_SYMBOL(pax_check_alloca);
21849 +#endif
21850 diff --git a/arch/x86/kernel/dumpstack_64.c b/arch/x86/kernel/dumpstack_64.c
21851 index 1abcb50..6c8d702 100644
21852 --- a/arch/x86/kernel/dumpstack_64.c
21853 +++ b/arch/x86/kernel/dumpstack_64.c
21854 @@ -154,12 +154,12 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
21855 const struct stacktrace_ops *ops, void *data)
21856 {
21857 const unsigned cpu = get_cpu();
21858 - struct thread_info *tinfo;
21859 unsigned long *irq_stack = (unsigned long *)per_cpu(irq_stack_ptr, cpu);
21860 unsigned long dummy;
21861 unsigned used = 0;
21862 int graph = 0;
21863 int done = 0;
21864 + void *stack_start;
21865
21866 if (!task)
21867 task = current;
21868 @@ -180,7 +180,6 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
21869 * current stack address. If the stacks consist of nested
21870 * exceptions
21871 */
21872 - tinfo = task_thread_info(task);
21873 while (!done) {
21874 unsigned long *stack_end;
21875 enum stack_type stype;
21876 @@ -203,7 +202,7 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
21877 if (ops->stack(data, id) < 0)
21878 break;
21879
21880 - bp = ops->walk_stack(tinfo, stack, bp, ops,
21881 + bp = ops->walk_stack(task, stack_end - EXCEPTION_STKSZ, stack, bp, ops,
21882 data, stack_end, &graph);
21883 ops->stack(data, "<EOE>");
21884 /*
21885 @@ -211,6 +210,8 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
21886 * second-to-last pointer (index -2 to end) in the
21887 * exception stack:
21888 */
21889 + if ((u16)stack_end[-1] != __KERNEL_DS)
21890 + goto out;
21891 stack = (unsigned long *) stack_end[-2];
21892 done = 0;
21893 break;
21894 @@ -219,7 +220,7 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
21895
21896 if (ops->stack(data, "IRQ") < 0)
21897 break;
21898 - bp = ops->walk_stack(tinfo, stack, bp,
21899 + bp = ops->walk_stack(task, irq_stack, stack, bp,
21900 ops, data, stack_end, &graph);
21901 /*
21902 * We link to the next stack (which would be
21903 @@ -241,7 +242,9 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
21904 /*
21905 * This handles the process stack:
21906 */
21907 - bp = ops->walk_stack(tinfo, stack, bp, ops, data, NULL, &graph);
21908 + stack_start = (void *)((unsigned long)stack & ~(THREAD_SIZE-1));
21909 + bp = ops->walk_stack(task, stack_start, stack, bp, ops, data, NULL, &graph);
21910 +out:
21911 put_cpu();
21912 }
21913 EXPORT_SYMBOL(dump_trace);
21914 @@ -350,3 +353,50 @@ int is_valid_bugaddr(unsigned long ip)
21915
21916 return ud2 == 0x0b0f;
21917 }
21918 +
21919 +#if defined(CONFIG_PAX_MEMORY_STACKLEAK) || defined(CONFIG_PAX_USERCOPY)
21920 +void pax_check_alloca(unsigned long size)
21921 +{
21922 + unsigned long sp = (unsigned long)&sp, stack_start, stack_end;
21923 + unsigned cpu, used;
21924 + char *id;
21925 +
21926 + /* check the process stack first */
21927 + stack_start = (unsigned long)task_stack_page(current);
21928 + stack_end = stack_start + THREAD_SIZE;
21929 + if (likely(stack_start <= sp && sp < stack_end)) {
21930 + unsigned long stack_left = sp & (THREAD_SIZE - 1);
21931 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
21932 + return;
21933 + }
21934 +
21935 + cpu = get_cpu();
21936 +
21937 + /* check the irq stacks */
21938 + stack_end = (unsigned long)per_cpu(irq_stack_ptr, cpu);
21939 + stack_start = stack_end - IRQ_STACK_SIZE;
21940 + if (stack_start <= sp && sp < stack_end) {
21941 + unsigned long stack_left = sp & (IRQ_STACK_SIZE - 1);
21942 + put_cpu();
21943 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
21944 + return;
21945 + }
21946 +
21947 + /* check the exception stacks */
21948 + used = 0;
21949 + stack_end = (unsigned long)in_exception_stack(cpu, sp, &used, &id);
21950 + stack_start = stack_end - EXCEPTION_STKSZ;
21951 + if (stack_end && stack_start <= sp && sp < stack_end) {
21952 + unsigned long stack_left = sp & (EXCEPTION_STKSZ - 1);
21953 + put_cpu();
21954 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
21955 + return;
21956 + }
21957 +
21958 + put_cpu();
21959 +
21960 + /* unknown stack */
21961 + BUG();
21962 +}
21963 +EXPORT_SYMBOL(pax_check_alloca);
21964 +#endif
21965 diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c
21966 index 988c00a..4f673b6 100644
21967 --- a/arch/x86/kernel/e820.c
21968 +++ b/arch/x86/kernel/e820.c
21969 @@ -803,8 +803,8 @@ unsigned long __init e820_end_of_low_ram_pfn(void)
21970
21971 static void early_panic(char *msg)
21972 {
21973 - early_printk(msg);
21974 - panic(msg);
21975 + early_printk("%s", msg);
21976 + panic("%s", msg);
21977 }
21978
21979 static int userdef __initdata;
21980 diff --git a/arch/x86/kernel/early_printk.c b/arch/x86/kernel/early_printk.c
21981 index 01d1c18..8073693 100644
21982 --- a/arch/x86/kernel/early_printk.c
21983 +++ b/arch/x86/kernel/early_printk.c
21984 @@ -7,6 +7,7 @@
21985 #include <linux/pci_regs.h>
21986 #include <linux/pci_ids.h>
21987 #include <linux/errno.h>
21988 +#include <linux/sched.h>
21989 #include <asm/io.h>
21990 #include <asm/processor.h>
21991 #include <asm/fcntl.h>
21992 diff --git a/arch/x86/kernel/entry_32.S b/arch/x86/kernel/entry_32.S
21993 index a2a4f46..6cab058 100644
21994 --- a/arch/x86/kernel/entry_32.S
21995 +++ b/arch/x86/kernel/entry_32.S
21996 @@ -177,13 +177,153 @@
21997 /*CFI_REL_OFFSET gs, PT_GS*/
21998 .endm
21999 .macro SET_KERNEL_GS reg
22000 +
22001 +#ifdef CONFIG_CC_STACKPROTECTOR
22002 movl $(__KERNEL_STACK_CANARY), \reg
22003 +#elif defined(CONFIG_PAX_MEMORY_UDEREF)
22004 + movl $(__USER_DS), \reg
22005 +#else
22006 + xorl \reg, \reg
22007 +#endif
22008 +
22009 movl \reg, %gs
22010 .endm
22011
22012 #endif /* CONFIG_X86_32_LAZY_GS */
22013
22014 -.macro SAVE_ALL
22015 +.macro pax_enter_kernel
22016 +#ifdef CONFIG_PAX_KERNEXEC
22017 + call pax_enter_kernel
22018 +#endif
22019 +.endm
22020 +
22021 +.macro pax_exit_kernel
22022 +#ifdef CONFIG_PAX_KERNEXEC
22023 + call pax_exit_kernel
22024 +#endif
22025 +.endm
22026 +
22027 +#ifdef CONFIG_PAX_KERNEXEC
22028 +ENTRY(pax_enter_kernel)
22029 +#ifdef CONFIG_PARAVIRT
22030 + pushl %eax
22031 + pushl %ecx
22032 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_read_cr0)
22033 + mov %eax, %esi
22034 +#else
22035 + mov %cr0, %esi
22036 +#endif
22037 + bts $16, %esi
22038 + jnc 1f
22039 + mov %cs, %esi
22040 + cmp $__KERNEL_CS, %esi
22041 + jz 3f
22042 + ljmp $__KERNEL_CS, $3f
22043 +1: ljmp $__KERNEXEC_KERNEL_CS, $2f
22044 +2:
22045 +#ifdef CONFIG_PARAVIRT
22046 + mov %esi, %eax
22047 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_write_cr0)
22048 +#else
22049 + mov %esi, %cr0
22050 +#endif
22051 +3:
22052 +#ifdef CONFIG_PARAVIRT
22053 + popl %ecx
22054 + popl %eax
22055 +#endif
22056 + ret
22057 +ENDPROC(pax_enter_kernel)
22058 +
22059 +ENTRY(pax_exit_kernel)
22060 +#ifdef CONFIG_PARAVIRT
22061 + pushl %eax
22062 + pushl %ecx
22063 +#endif
22064 + mov %cs, %esi
22065 + cmp $__KERNEXEC_KERNEL_CS, %esi
22066 + jnz 2f
22067 +#ifdef CONFIG_PARAVIRT
22068 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_read_cr0);
22069 + mov %eax, %esi
22070 +#else
22071 + mov %cr0, %esi
22072 +#endif
22073 + btr $16, %esi
22074 + ljmp $__KERNEL_CS, $1f
22075 +1:
22076 +#ifdef CONFIG_PARAVIRT
22077 + mov %esi, %eax
22078 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_write_cr0);
22079 +#else
22080 + mov %esi, %cr0
22081 +#endif
22082 +2:
22083 +#ifdef CONFIG_PARAVIRT
22084 + popl %ecx
22085 + popl %eax
22086 +#endif
22087 + ret
22088 +ENDPROC(pax_exit_kernel)
22089 +#endif
22090 +
22091 + .macro pax_erase_kstack
22092 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
22093 + call pax_erase_kstack
22094 +#endif
22095 + .endm
22096 +
22097 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
22098 +/*
22099 + * ebp: thread_info
22100 + */
22101 +ENTRY(pax_erase_kstack)
22102 + pushl %edi
22103 + pushl %ecx
22104 + pushl %eax
22105 +
22106 + mov TI_lowest_stack(%ebp), %edi
22107 + mov $-0xBEEF, %eax
22108 + std
22109 +
22110 +1: mov %edi, %ecx
22111 + and $THREAD_SIZE_asm - 1, %ecx
22112 + shr $2, %ecx
22113 + repne scasl
22114 + jecxz 2f
22115 +
22116 + cmp $2*16, %ecx
22117 + jc 2f
22118 +
22119 + mov $2*16, %ecx
22120 + repe scasl
22121 + jecxz 2f
22122 + jne 1b
22123 +
22124 +2: cld
22125 + mov %esp, %ecx
22126 + sub %edi, %ecx
22127 +
22128 + cmp $THREAD_SIZE_asm, %ecx
22129 + jb 3f
22130 + ud2
22131 +3:
22132 +
22133 + shr $2, %ecx
22134 + rep stosl
22135 +
22136 + mov TI_task_thread_sp0(%ebp), %edi
22137 + sub $128, %edi
22138 + mov %edi, TI_lowest_stack(%ebp)
22139 +
22140 + popl %eax
22141 + popl %ecx
22142 + popl %edi
22143 + ret
22144 +ENDPROC(pax_erase_kstack)
22145 +#endif
22146 +
22147 +.macro __SAVE_ALL _DS
22148 cld
22149 PUSH_GS
22150 pushl_cfi %fs
22151 @@ -206,7 +346,7 @@
22152 CFI_REL_OFFSET ecx, 0
22153 pushl_cfi %ebx
22154 CFI_REL_OFFSET ebx, 0
22155 - movl $(__USER_DS), %edx
22156 + movl $\_DS, %edx
22157 movl %edx, %ds
22158 movl %edx, %es
22159 movl $(__KERNEL_PERCPU), %edx
22160 @@ -214,6 +354,15 @@
22161 SET_KERNEL_GS %edx
22162 .endm
22163
22164 +.macro SAVE_ALL
22165 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
22166 + __SAVE_ALL __KERNEL_DS
22167 + pax_enter_kernel
22168 +#else
22169 + __SAVE_ALL __USER_DS
22170 +#endif
22171 +.endm
22172 +
22173 .macro RESTORE_INT_REGS
22174 popl_cfi %ebx
22175 CFI_RESTORE ebx
22176 @@ -297,7 +446,7 @@ ENTRY(ret_from_fork)
22177 popfl_cfi
22178 jmp syscall_exit
22179 CFI_ENDPROC
22180 -END(ret_from_fork)
22181 +ENDPROC(ret_from_fork)
22182
22183 ENTRY(ret_from_kernel_thread)
22184 CFI_STARTPROC
22185 @@ -344,7 +493,15 @@ ret_from_intr:
22186 andl $SEGMENT_RPL_MASK, %eax
22187 #endif
22188 cmpl $USER_RPL, %eax
22189 +
22190 +#ifdef CONFIG_PAX_KERNEXEC
22191 + jae resume_userspace
22192 +
22193 + pax_exit_kernel
22194 + jmp resume_kernel
22195 +#else
22196 jb resume_kernel # not returning to v8086 or userspace
22197 +#endif
22198
22199 ENTRY(resume_userspace)
22200 LOCKDEP_SYS_EXIT
22201 @@ -356,8 +513,8 @@ ENTRY(resume_userspace)
22202 andl $_TIF_WORK_MASK, %ecx # is there any work to be done on
22203 # int/exception return?
22204 jne work_pending
22205 - jmp restore_all
22206 -END(ret_from_exception)
22207 + jmp restore_all_pax
22208 +ENDPROC(ret_from_exception)
22209
22210 #ifdef CONFIG_PREEMPT
22211 ENTRY(resume_kernel)
22212 @@ -369,7 +526,7 @@ need_resched:
22213 jz restore_all
22214 call preempt_schedule_irq
22215 jmp need_resched
22216 -END(resume_kernel)
22217 +ENDPROC(resume_kernel)
22218 #endif
22219 CFI_ENDPROC
22220 /*
22221 @@ -403,30 +560,45 @@ sysenter_past_esp:
22222 /*CFI_REL_OFFSET cs, 0*/
22223 /*
22224 * Push current_thread_info()->sysenter_return to the stack.
22225 - * A tiny bit of offset fixup is necessary - 4*4 means the 4 words
22226 - * pushed above; +8 corresponds to copy_thread's esp0 setting.
22227 */
22228 - pushl_cfi ((TI_sysenter_return)-THREAD_SIZE+8+4*4)(%esp)
22229 + pushl_cfi $0
22230 CFI_REL_OFFSET eip, 0
22231
22232 pushl_cfi %eax
22233 SAVE_ALL
22234 + GET_THREAD_INFO(%ebp)
22235 + movl TI_sysenter_return(%ebp),%ebp
22236 + movl %ebp,PT_EIP(%esp)
22237 ENABLE_INTERRUPTS(CLBR_NONE)
22238
22239 /*
22240 * Load the potential sixth argument from user stack.
22241 * Careful about security.
22242 */
22243 + movl PT_OLDESP(%esp),%ebp
22244 +
22245 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22246 + mov PT_OLDSS(%esp),%ds
22247 +1: movl %ds:(%ebp),%ebp
22248 + push %ss
22249 + pop %ds
22250 +#else
22251 cmpl $__PAGE_OFFSET-3,%ebp
22252 jae syscall_fault
22253 ASM_STAC
22254 1: movl (%ebp),%ebp
22255 ASM_CLAC
22256 +#endif
22257 +
22258 movl %ebp,PT_EBP(%esp)
22259 _ASM_EXTABLE(1b,syscall_fault)
22260
22261 GET_THREAD_INFO(%ebp)
22262
22263 +#ifdef CONFIG_PAX_RANDKSTACK
22264 + pax_erase_kstack
22265 +#endif
22266 +
22267 testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%ebp)
22268 jnz sysenter_audit
22269 sysenter_do_call:
22270 @@ -441,12 +613,24 @@ sysenter_do_call:
22271 testl $_TIF_ALLWORK_MASK, %ecx
22272 jne sysexit_audit
22273 sysenter_exit:
22274 +
22275 +#ifdef CONFIG_PAX_RANDKSTACK
22276 + pushl_cfi %eax
22277 + movl %esp, %eax
22278 + call pax_randomize_kstack
22279 + popl_cfi %eax
22280 +#endif
22281 +
22282 + pax_erase_kstack
22283 +
22284 /* if something modifies registers it must also disable sysexit */
22285 movl PT_EIP(%esp), %edx
22286 movl PT_OLDESP(%esp), %ecx
22287 xorl %ebp,%ebp
22288 TRACE_IRQS_ON
22289 1: mov PT_FS(%esp), %fs
22290 +2: mov PT_DS(%esp), %ds
22291 +3: mov PT_ES(%esp), %es
22292 PTGS_TO_GS
22293 ENABLE_INTERRUPTS_SYSEXIT
22294
22295 @@ -463,6 +647,9 @@ sysenter_audit:
22296 movl %eax,%edx /* 2nd arg: syscall number */
22297 movl $AUDIT_ARCH_I386,%eax /* 1st arg: audit arch */
22298 call __audit_syscall_entry
22299 +
22300 + pax_erase_kstack
22301 +
22302 pushl_cfi %ebx
22303 movl PT_EAX(%esp),%eax /* reload syscall number */
22304 jmp sysenter_do_call
22305 @@ -488,10 +675,16 @@ sysexit_audit:
22306
22307 CFI_ENDPROC
22308 .pushsection .fixup,"ax"
22309 -2: movl $0,PT_FS(%esp)
22310 +4: movl $0,PT_FS(%esp)
22311 + jmp 1b
22312 +5: movl $0,PT_DS(%esp)
22313 + jmp 1b
22314 +6: movl $0,PT_ES(%esp)
22315 jmp 1b
22316 .popsection
22317 - _ASM_EXTABLE(1b,2b)
22318 + _ASM_EXTABLE(1b,4b)
22319 + _ASM_EXTABLE(2b,5b)
22320 + _ASM_EXTABLE(3b,6b)
22321 PTGS_TO_GS_EX
22322 ENDPROC(ia32_sysenter_target)
22323
22324 @@ -506,6 +699,11 @@ ENTRY(system_call)
22325 pushl_cfi %eax # save orig_eax
22326 SAVE_ALL
22327 GET_THREAD_INFO(%ebp)
22328 +
22329 +#ifdef CONFIG_PAX_RANDKSTACK
22330 + pax_erase_kstack
22331 +#endif
22332 +
22333 # system call tracing in operation / emulation
22334 testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%ebp)
22335 jnz syscall_trace_entry
22336 @@ -524,6 +722,15 @@ syscall_exit:
22337 testl $_TIF_ALLWORK_MASK, %ecx # current->work
22338 jne syscall_exit_work
22339
22340 +restore_all_pax:
22341 +
22342 +#ifdef CONFIG_PAX_RANDKSTACK
22343 + movl %esp, %eax
22344 + call pax_randomize_kstack
22345 +#endif
22346 +
22347 + pax_erase_kstack
22348 +
22349 restore_all:
22350 TRACE_IRQS_IRET
22351 restore_all_notrace:
22352 @@ -580,14 +787,34 @@ ldt_ss:
22353 * compensating for the offset by changing to the ESPFIX segment with
22354 * a base address that matches for the difference.
22355 */
22356 -#define GDT_ESPFIX_SS PER_CPU_VAR(gdt_page) + (GDT_ENTRY_ESPFIX_SS * 8)
22357 +#define GDT_ESPFIX_SS (GDT_ENTRY_ESPFIX_SS * 8)(%ebx)
22358 mov %esp, %edx /* load kernel esp */
22359 mov PT_OLDESP(%esp), %eax /* load userspace esp */
22360 mov %dx, %ax /* eax: new kernel esp */
22361 sub %eax, %edx /* offset (low word is 0) */
22362 +#ifdef CONFIG_SMP
22363 + movl PER_CPU_VAR(cpu_number), %ebx
22364 + shll $PAGE_SHIFT_asm, %ebx
22365 + addl $cpu_gdt_table, %ebx
22366 +#else
22367 + movl $cpu_gdt_table, %ebx
22368 +#endif
22369 shr $16, %edx
22370 - mov %dl, GDT_ESPFIX_SS + 4 /* bits 16..23 */
22371 - mov %dh, GDT_ESPFIX_SS + 7 /* bits 24..31 */
22372 +
22373 +#ifdef CONFIG_PAX_KERNEXEC
22374 + mov %cr0, %esi
22375 + btr $16, %esi
22376 + mov %esi, %cr0
22377 +#endif
22378 +
22379 + mov %dl, 4 + GDT_ESPFIX_SS /* bits 16..23 */
22380 + mov %dh, 7 + GDT_ESPFIX_SS /* bits 24..31 */
22381 +
22382 +#ifdef CONFIG_PAX_KERNEXEC
22383 + bts $16, %esi
22384 + mov %esi, %cr0
22385 +#endif
22386 +
22387 pushl_cfi $__ESPFIX_SS
22388 pushl_cfi %eax /* new kernel esp */
22389 /* Disable interrupts, but do not irqtrace this section: we
22390 @@ -616,20 +843,18 @@ work_resched:
22391 movl TI_flags(%ebp), %ecx
22392 andl $_TIF_WORK_MASK, %ecx # is there any work to be done other
22393 # than syscall tracing?
22394 - jz restore_all
22395 + jz restore_all_pax
22396 testb $_TIF_NEED_RESCHED, %cl
22397 jnz work_resched
22398
22399 work_notifysig: # deal with pending signals and
22400 # notify-resume requests
22401 + movl %esp, %eax
22402 #ifdef CONFIG_VM86
22403 testl $X86_EFLAGS_VM, PT_EFLAGS(%esp)
22404 - movl %esp, %eax
22405 jne work_notifysig_v86 # returning to kernel-space or
22406 # vm86-space
22407 1:
22408 -#else
22409 - movl %esp, %eax
22410 #endif
22411 TRACE_IRQS_ON
22412 ENABLE_INTERRUPTS(CLBR_NONE)
22413 @@ -650,7 +875,7 @@ work_notifysig_v86:
22414 movl %eax, %esp
22415 jmp 1b
22416 #endif
22417 -END(work_pending)
22418 +ENDPROC(work_pending)
22419
22420 # perform syscall exit tracing
22421 ALIGN
22422 @@ -658,11 +883,14 @@ syscall_trace_entry:
22423 movl $-ENOSYS,PT_EAX(%esp)
22424 movl %esp, %eax
22425 call syscall_trace_enter
22426 +
22427 + pax_erase_kstack
22428 +
22429 /* What it returned is what we'll actually use. */
22430 cmpl $(NR_syscalls), %eax
22431 jnae syscall_call
22432 jmp syscall_exit
22433 -END(syscall_trace_entry)
22434 +ENDPROC(syscall_trace_entry)
22435
22436 # perform syscall exit tracing
22437 ALIGN
22438 @@ -675,21 +903,25 @@ syscall_exit_work:
22439 movl %esp, %eax
22440 call syscall_trace_leave
22441 jmp resume_userspace
22442 -END(syscall_exit_work)
22443 +ENDPROC(syscall_exit_work)
22444 CFI_ENDPROC
22445
22446 RING0_INT_FRAME # can't unwind into user space anyway
22447 syscall_fault:
22448 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22449 + push %ss
22450 + pop %ds
22451 +#endif
22452 ASM_CLAC
22453 GET_THREAD_INFO(%ebp)
22454 movl $-EFAULT,PT_EAX(%esp)
22455 jmp resume_userspace
22456 -END(syscall_fault)
22457 +ENDPROC(syscall_fault)
22458
22459 syscall_badsys:
22460 movl $-ENOSYS,PT_EAX(%esp)
22461 jmp resume_userspace
22462 -END(syscall_badsys)
22463 +ENDPROC(syscall_badsys)
22464 CFI_ENDPROC
22465 /*
22466 * End of kprobes section
22467 @@ -705,8 +937,15 @@ END(syscall_badsys)
22468 * normal stack and adjusts ESP with the matching offset.
22469 */
22470 /* fixup the stack */
22471 - mov GDT_ESPFIX_SS + 4, %al /* bits 16..23 */
22472 - mov GDT_ESPFIX_SS + 7, %ah /* bits 24..31 */
22473 +#ifdef CONFIG_SMP
22474 + movl PER_CPU_VAR(cpu_number), %ebx
22475 + shll $PAGE_SHIFT_asm, %ebx
22476 + addl $cpu_gdt_table, %ebx
22477 +#else
22478 + movl $cpu_gdt_table, %ebx
22479 +#endif
22480 + mov 4 + GDT_ESPFIX_SS, %al /* bits 16..23 */
22481 + mov 7 + GDT_ESPFIX_SS, %ah /* bits 24..31 */
22482 shl $16, %eax
22483 addl %esp, %eax /* the adjusted stack pointer */
22484 pushl_cfi $__KERNEL_DS
22485 @@ -759,7 +998,7 @@ vector=vector+1
22486 .endr
22487 2: jmp common_interrupt
22488 .endr
22489 -END(irq_entries_start)
22490 +ENDPROC(irq_entries_start)
22491
22492 .previous
22493 END(interrupt)
22494 @@ -820,7 +1059,7 @@ ENTRY(coprocessor_error)
22495 pushl_cfi $do_coprocessor_error
22496 jmp error_code
22497 CFI_ENDPROC
22498 -END(coprocessor_error)
22499 +ENDPROC(coprocessor_error)
22500
22501 ENTRY(simd_coprocessor_error)
22502 RING0_INT_FRAME
22503 @@ -833,7 +1072,7 @@ ENTRY(simd_coprocessor_error)
22504 .section .altinstructions,"a"
22505 altinstruction_entry 661b, 663f, X86_FEATURE_XMM, 662b-661b, 664f-663f
22506 .previous
22507 -.section .altinstr_replacement,"ax"
22508 +.section .altinstr_replacement,"a"
22509 663: pushl $do_simd_coprocessor_error
22510 664:
22511 .previous
22512 @@ -842,7 +1081,7 @@ ENTRY(simd_coprocessor_error)
22513 #endif
22514 jmp error_code
22515 CFI_ENDPROC
22516 -END(simd_coprocessor_error)
22517 +ENDPROC(simd_coprocessor_error)
22518
22519 ENTRY(device_not_available)
22520 RING0_INT_FRAME
22521 @@ -851,18 +1090,18 @@ ENTRY(device_not_available)
22522 pushl_cfi $do_device_not_available
22523 jmp error_code
22524 CFI_ENDPROC
22525 -END(device_not_available)
22526 +ENDPROC(device_not_available)
22527
22528 #ifdef CONFIG_PARAVIRT
22529 ENTRY(native_iret)
22530 iret
22531 _ASM_EXTABLE(native_iret, iret_exc)
22532 -END(native_iret)
22533 +ENDPROC(native_iret)
22534
22535 ENTRY(native_irq_enable_sysexit)
22536 sti
22537 sysexit
22538 -END(native_irq_enable_sysexit)
22539 +ENDPROC(native_irq_enable_sysexit)
22540 #endif
22541
22542 ENTRY(overflow)
22543 @@ -872,7 +1111,7 @@ ENTRY(overflow)
22544 pushl_cfi $do_overflow
22545 jmp error_code
22546 CFI_ENDPROC
22547 -END(overflow)
22548 +ENDPROC(overflow)
22549
22550 ENTRY(bounds)
22551 RING0_INT_FRAME
22552 @@ -881,7 +1120,7 @@ ENTRY(bounds)
22553 pushl_cfi $do_bounds
22554 jmp error_code
22555 CFI_ENDPROC
22556 -END(bounds)
22557 +ENDPROC(bounds)
22558
22559 ENTRY(invalid_op)
22560 RING0_INT_FRAME
22561 @@ -890,7 +1129,7 @@ ENTRY(invalid_op)
22562 pushl_cfi $do_invalid_op
22563 jmp error_code
22564 CFI_ENDPROC
22565 -END(invalid_op)
22566 +ENDPROC(invalid_op)
22567
22568 ENTRY(coprocessor_segment_overrun)
22569 RING0_INT_FRAME
22570 @@ -899,7 +1138,7 @@ ENTRY(coprocessor_segment_overrun)
22571 pushl_cfi $do_coprocessor_segment_overrun
22572 jmp error_code
22573 CFI_ENDPROC
22574 -END(coprocessor_segment_overrun)
22575 +ENDPROC(coprocessor_segment_overrun)
22576
22577 ENTRY(invalid_TSS)
22578 RING0_EC_FRAME
22579 @@ -907,7 +1146,7 @@ ENTRY(invalid_TSS)
22580 pushl_cfi $do_invalid_TSS
22581 jmp error_code
22582 CFI_ENDPROC
22583 -END(invalid_TSS)
22584 +ENDPROC(invalid_TSS)
22585
22586 ENTRY(segment_not_present)
22587 RING0_EC_FRAME
22588 @@ -915,7 +1154,7 @@ ENTRY(segment_not_present)
22589 pushl_cfi $do_segment_not_present
22590 jmp error_code
22591 CFI_ENDPROC
22592 -END(segment_not_present)
22593 +ENDPROC(segment_not_present)
22594
22595 ENTRY(stack_segment)
22596 RING0_EC_FRAME
22597 @@ -923,7 +1162,7 @@ ENTRY(stack_segment)
22598 pushl_cfi $do_stack_segment
22599 jmp error_code
22600 CFI_ENDPROC
22601 -END(stack_segment)
22602 +ENDPROC(stack_segment)
22603
22604 ENTRY(alignment_check)
22605 RING0_EC_FRAME
22606 @@ -931,7 +1170,7 @@ ENTRY(alignment_check)
22607 pushl_cfi $do_alignment_check
22608 jmp error_code
22609 CFI_ENDPROC
22610 -END(alignment_check)
22611 +ENDPROC(alignment_check)
22612
22613 ENTRY(divide_error)
22614 RING0_INT_FRAME
22615 @@ -940,7 +1179,7 @@ ENTRY(divide_error)
22616 pushl_cfi $do_divide_error
22617 jmp error_code
22618 CFI_ENDPROC
22619 -END(divide_error)
22620 +ENDPROC(divide_error)
22621
22622 #ifdef CONFIG_X86_MCE
22623 ENTRY(machine_check)
22624 @@ -950,7 +1189,7 @@ ENTRY(machine_check)
22625 pushl_cfi machine_check_vector
22626 jmp error_code
22627 CFI_ENDPROC
22628 -END(machine_check)
22629 +ENDPROC(machine_check)
22630 #endif
22631
22632 ENTRY(spurious_interrupt_bug)
22633 @@ -960,7 +1199,7 @@ ENTRY(spurious_interrupt_bug)
22634 pushl_cfi $do_spurious_interrupt_bug
22635 jmp error_code
22636 CFI_ENDPROC
22637 -END(spurious_interrupt_bug)
22638 +ENDPROC(spurious_interrupt_bug)
22639 /*
22640 * End of kprobes section
22641 */
22642 @@ -1070,7 +1309,7 @@ BUILD_INTERRUPT3(hyperv_callback_vector, HYPERVISOR_CALLBACK_VECTOR,
22643
22644 ENTRY(mcount)
22645 ret
22646 -END(mcount)
22647 +ENDPROC(mcount)
22648
22649 ENTRY(ftrace_caller)
22650 cmpl $0, function_trace_stop
22651 @@ -1103,7 +1342,7 @@ ftrace_graph_call:
22652 .globl ftrace_stub
22653 ftrace_stub:
22654 ret
22655 -END(ftrace_caller)
22656 +ENDPROC(ftrace_caller)
22657
22658 ENTRY(ftrace_regs_caller)
22659 pushf /* push flags before compare (in cs location) */
22660 @@ -1207,7 +1446,7 @@ trace:
22661 popl %ecx
22662 popl %eax
22663 jmp ftrace_stub
22664 -END(mcount)
22665 +ENDPROC(mcount)
22666 #endif /* CONFIG_DYNAMIC_FTRACE */
22667 #endif /* CONFIG_FUNCTION_TRACER */
22668
22669 @@ -1225,7 +1464,7 @@ ENTRY(ftrace_graph_caller)
22670 popl %ecx
22671 popl %eax
22672 ret
22673 -END(ftrace_graph_caller)
22674 +ENDPROC(ftrace_graph_caller)
22675
22676 .globl return_to_handler
22677 return_to_handler:
22678 @@ -1291,15 +1530,18 @@ error_code:
22679 movl $-1, PT_ORIG_EAX(%esp) # no syscall to restart
22680 REG_TO_PTGS %ecx
22681 SET_KERNEL_GS %ecx
22682 - movl $(__USER_DS), %ecx
22683 + movl $(__KERNEL_DS), %ecx
22684 movl %ecx, %ds
22685 movl %ecx, %es
22686 +
22687 + pax_enter_kernel
22688 +
22689 TRACE_IRQS_OFF
22690 movl %esp,%eax # pt_regs pointer
22691 call *%edi
22692 jmp ret_from_exception
22693 CFI_ENDPROC
22694 -END(page_fault)
22695 +ENDPROC(page_fault)
22696
22697 /*
22698 * Debug traps and NMI can happen at the one SYSENTER instruction
22699 @@ -1342,7 +1584,7 @@ debug_stack_correct:
22700 call do_debug
22701 jmp ret_from_exception
22702 CFI_ENDPROC
22703 -END(debug)
22704 +ENDPROC(debug)
22705
22706 /*
22707 * NMI is doubly nasty. It can happen _while_ we're handling
22708 @@ -1380,6 +1622,9 @@ nmi_stack_correct:
22709 xorl %edx,%edx # zero error code
22710 movl %esp,%eax # pt_regs pointer
22711 call do_nmi
22712 +
22713 + pax_exit_kernel
22714 +
22715 jmp restore_all_notrace
22716 CFI_ENDPROC
22717
22718 @@ -1416,12 +1661,15 @@ nmi_espfix_stack:
22719 FIXUP_ESPFIX_STACK # %eax == %esp
22720 xorl %edx,%edx # zero error code
22721 call do_nmi
22722 +
22723 + pax_exit_kernel
22724 +
22725 RESTORE_REGS
22726 lss 12+4(%esp), %esp # back to espfix stack
22727 CFI_ADJUST_CFA_OFFSET -24
22728 jmp irq_return
22729 CFI_ENDPROC
22730 -END(nmi)
22731 +ENDPROC(nmi)
22732
22733 ENTRY(int3)
22734 RING0_INT_FRAME
22735 @@ -1434,14 +1682,14 @@ ENTRY(int3)
22736 call do_int3
22737 jmp ret_from_exception
22738 CFI_ENDPROC
22739 -END(int3)
22740 +ENDPROC(int3)
22741
22742 ENTRY(general_protection)
22743 RING0_EC_FRAME
22744 pushl_cfi $do_general_protection
22745 jmp error_code
22746 CFI_ENDPROC
22747 -END(general_protection)
22748 +ENDPROC(general_protection)
22749
22750 #ifdef CONFIG_KVM_GUEST
22751 ENTRY(async_page_fault)
22752 @@ -1450,7 +1698,7 @@ ENTRY(async_page_fault)
22753 pushl_cfi $do_async_page_fault
22754 jmp error_code
22755 CFI_ENDPROC
22756 -END(async_page_fault)
22757 +ENDPROC(async_page_fault)
22758 #endif
22759
22760 /*
22761 diff --git a/arch/x86/kernel/entry_64.S b/arch/x86/kernel/entry_64.S
22762 index 1e96c36..3ff710a 100644
22763 --- a/arch/x86/kernel/entry_64.S
22764 +++ b/arch/x86/kernel/entry_64.S
22765 @@ -59,6 +59,8 @@
22766 #include <asm/context_tracking.h>
22767 #include <asm/smap.h>
22768 #include <linux/err.h>
22769 +#include <asm/pgtable.h>
22770 +#include <asm/alternative-asm.h>
22771
22772 /* Avoid __ASSEMBLER__'ifying <linux/audit.h> just for this. */
22773 #include <linux/elf-em.h>
22774 @@ -80,8 +82,9 @@
22775 #ifdef CONFIG_DYNAMIC_FTRACE
22776
22777 ENTRY(function_hook)
22778 + pax_force_retaddr
22779 retq
22780 -END(function_hook)
22781 +ENDPROC(function_hook)
22782
22783 /* skip is set if stack has been adjusted */
22784 .macro ftrace_caller_setup skip=0
22785 @@ -122,8 +125,9 @@ GLOBAL(ftrace_graph_call)
22786 #endif
22787
22788 GLOBAL(ftrace_stub)
22789 + pax_force_retaddr
22790 retq
22791 -END(ftrace_caller)
22792 +ENDPROC(ftrace_caller)
22793
22794 ENTRY(ftrace_regs_caller)
22795 /* Save the current flags before compare (in SS location)*/
22796 @@ -191,7 +195,7 @@ ftrace_restore_flags:
22797 popfq
22798 jmp ftrace_stub
22799
22800 -END(ftrace_regs_caller)
22801 +ENDPROC(ftrace_regs_caller)
22802
22803
22804 #else /* ! CONFIG_DYNAMIC_FTRACE */
22805 @@ -212,6 +216,7 @@ ENTRY(function_hook)
22806 #endif
22807
22808 GLOBAL(ftrace_stub)
22809 + pax_force_retaddr
22810 retq
22811
22812 trace:
22813 @@ -225,12 +230,13 @@ trace:
22814 #endif
22815 subq $MCOUNT_INSN_SIZE, %rdi
22816
22817 + pax_force_fptr ftrace_trace_function
22818 call *ftrace_trace_function
22819
22820 MCOUNT_RESTORE_FRAME
22821
22822 jmp ftrace_stub
22823 -END(function_hook)
22824 +ENDPROC(function_hook)
22825 #endif /* CONFIG_DYNAMIC_FTRACE */
22826 #endif /* CONFIG_FUNCTION_TRACER */
22827
22828 @@ -252,8 +258,9 @@ ENTRY(ftrace_graph_caller)
22829
22830 MCOUNT_RESTORE_FRAME
22831
22832 + pax_force_retaddr
22833 retq
22834 -END(ftrace_graph_caller)
22835 +ENDPROC(ftrace_graph_caller)
22836
22837 GLOBAL(return_to_handler)
22838 subq $24, %rsp
22839 @@ -269,7 +276,9 @@ GLOBAL(return_to_handler)
22840 movq 8(%rsp), %rdx
22841 movq (%rsp), %rax
22842 addq $24, %rsp
22843 + pax_force_fptr %rdi
22844 jmp *%rdi
22845 +ENDPROC(return_to_handler)
22846 #endif
22847
22848
22849 @@ -284,6 +293,430 @@ ENTRY(native_usergs_sysret64)
22850 ENDPROC(native_usergs_sysret64)
22851 #endif /* CONFIG_PARAVIRT */
22852
22853 + .macro ljmpq sel, off
22854 +#if defined(CONFIG_MPSC) || defined(CONFIG_MCORE2) || defined (CONFIG_MATOM)
22855 + .byte 0x48; ljmp *1234f(%rip)
22856 + .pushsection .rodata
22857 + .align 16
22858 + 1234: .quad \off; .word \sel
22859 + .popsection
22860 +#else
22861 + pushq $\sel
22862 + pushq $\off
22863 + lretq
22864 +#endif
22865 + .endm
22866 +
22867 + .macro pax_enter_kernel
22868 + pax_set_fptr_mask
22869 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
22870 + call pax_enter_kernel
22871 +#endif
22872 + .endm
22873 +
22874 + .macro pax_exit_kernel
22875 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
22876 + call pax_exit_kernel
22877 +#endif
22878 +
22879 + .endm
22880 +
22881 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
22882 +ENTRY(pax_enter_kernel)
22883 + pushq %rdi
22884 +
22885 +#ifdef CONFIG_PARAVIRT
22886 + PV_SAVE_REGS(CLBR_RDI)
22887 +#endif
22888 +
22889 +#ifdef CONFIG_PAX_KERNEXEC
22890 + GET_CR0_INTO_RDI
22891 + bts $16,%rdi
22892 + jnc 3f
22893 + mov %cs,%edi
22894 + cmp $__KERNEL_CS,%edi
22895 + jnz 2f
22896 +1:
22897 +#endif
22898 +
22899 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22900 + 661: jmp 111f
22901 + .pushsection .altinstr_replacement, "a"
22902 + 662: ASM_NOP2
22903 + .popsection
22904 + .pushsection .altinstructions, "a"
22905 + altinstruction_entry 661b, 662b, X86_FEATURE_PCID, 2, 2
22906 + .popsection
22907 + GET_CR3_INTO_RDI
22908 + cmp $0,%dil
22909 + jnz 112f
22910 + mov $__KERNEL_DS,%edi
22911 + mov %edi,%ss
22912 + jmp 111f
22913 +112: cmp $1,%dil
22914 + jz 113f
22915 + ud2
22916 +113: sub $4097,%rdi
22917 + bts $63,%rdi
22918 + SET_RDI_INTO_CR3
22919 + mov $__UDEREF_KERNEL_DS,%edi
22920 + mov %edi,%ss
22921 +111:
22922 +#endif
22923 +
22924 +#ifdef CONFIG_PARAVIRT
22925 + PV_RESTORE_REGS(CLBR_RDI)
22926 +#endif
22927 +
22928 + popq %rdi
22929 + pax_force_retaddr
22930 + retq
22931 +
22932 +#ifdef CONFIG_PAX_KERNEXEC
22933 +2: ljmpq __KERNEL_CS,1b
22934 +3: ljmpq __KERNEXEC_KERNEL_CS,4f
22935 +4: SET_RDI_INTO_CR0
22936 + jmp 1b
22937 +#endif
22938 +ENDPROC(pax_enter_kernel)
22939 +
22940 +ENTRY(pax_exit_kernel)
22941 + pushq %rdi
22942 +
22943 +#ifdef CONFIG_PARAVIRT
22944 + PV_SAVE_REGS(CLBR_RDI)
22945 +#endif
22946 +
22947 +#ifdef CONFIG_PAX_KERNEXEC
22948 + mov %cs,%rdi
22949 + cmp $__KERNEXEC_KERNEL_CS,%edi
22950 + jz 2f
22951 + GET_CR0_INTO_RDI
22952 + bts $16,%rdi
22953 + jnc 4f
22954 +1:
22955 +#endif
22956 +
22957 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22958 + 661: jmp 111f
22959 + .pushsection .altinstr_replacement, "a"
22960 + 662: ASM_NOP2
22961 + .popsection
22962 + .pushsection .altinstructions, "a"
22963 + altinstruction_entry 661b, 662b, X86_FEATURE_PCID, 2, 2
22964 + .popsection
22965 + mov %ss,%edi
22966 + cmp $__UDEREF_KERNEL_DS,%edi
22967 + jnz 111f
22968 + GET_CR3_INTO_RDI
22969 + cmp $0,%dil
22970 + jz 112f
22971 + ud2
22972 +112: add $4097,%rdi
22973 + bts $63,%rdi
22974 + SET_RDI_INTO_CR3
22975 + mov $__KERNEL_DS,%edi
22976 + mov %edi,%ss
22977 +111:
22978 +#endif
22979 +
22980 +#ifdef CONFIG_PARAVIRT
22981 + PV_RESTORE_REGS(CLBR_RDI);
22982 +#endif
22983 +
22984 + popq %rdi
22985 + pax_force_retaddr
22986 + retq
22987 +
22988 +#ifdef CONFIG_PAX_KERNEXEC
22989 +2: GET_CR0_INTO_RDI
22990 + btr $16,%rdi
22991 + jnc 4f
22992 + ljmpq __KERNEL_CS,3f
22993 +3: SET_RDI_INTO_CR0
22994 + jmp 1b
22995 +4: ud2
22996 + jmp 4b
22997 +#endif
22998 +ENDPROC(pax_exit_kernel)
22999 +#endif
23000 +
23001 + .macro pax_enter_kernel_user
23002 + pax_set_fptr_mask
23003 +#ifdef CONFIG_PAX_MEMORY_UDEREF
23004 + call pax_enter_kernel_user
23005 +#endif
23006 + .endm
23007 +
23008 + .macro pax_exit_kernel_user
23009 +#ifdef CONFIG_PAX_MEMORY_UDEREF
23010 + call pax_exit_kernel_user
23011 +#endif
23012 +#ifdef CONFIG_PAX_RANDKSTACK
23013 + pushq %rax
23014 + pushq %r11
23015 + call pax_randomize_kstack
23016 + popq %r11
23017 + popq %rax
23018 +#endif
23019 + .endm
23020 +
23021 +#ifdef CONFIG_PAX_MEMORY_UDEREF
23022 +ENTRY(pax_enter_kernel_user)
23023 + pushq %rdi
23024 + pushq %rbx
23025 +
23026 +#ifdef CONFIG_PARAVIRT
23027 + PV_SAVE_REGS(CLBR_RDI)
23028 +#endif
23029 +
23030 + 661: jmp 111f
23031 + .pushsection .altinstr_replacement, "a"
23032 + 662: ASM_NOP2
23033 + .popsection
23034 + .pushsection .altinstructions, "a"
23035 + altinstruction_entry 661b, 662b, X86_FEATURE_PCID, 2, 2
23036 + .popsection
23037 + GET_CR3_INTO_RDI
23038 + cmp $1,%dil
23039 + jnz 4f
23040 + sub $4097,%rdi
23041 + bts $63,%rdi
23042 + SET_RDI_INTO_CR3
23043 + jmp 3f
23044 +111:
23045 +
23046 + GET_CR3_INTO_RDI
23047 + mov %rdi,%rbx
23048 + add $__START_KERNEL_map,%rbx
23049 + sub phys_base(%rip),%rbx
23050 +
23051 +#ifdef CONFIG_PARAVIRT
23052 + cmpl $0, pv_info+PARAVIRT_enabled
23053 + jz 1f
23054 + pushq %rdi
23055 + i = 0
23056 + .rept USER_PGD_PTRS
23057 + mov i*8(%rbx),%rsi
23058 + mov $0,%sil
23059 + lea i*8(%rbx),%rdi
23060 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_set_pgd_batched)
23061 + i = i + 1
23062 + .endr
23063 + popq %rdi
23064 + jmp 2f
23065 +1:
23066 +#endif
23067 +
23068 + i = 0
23069 + .rept USER_PGD_PTRS
23070 + movb $0,i*8(%rbx)
23071 + i = i + 1
23072 + .endr
23073 +
23074 +2: SET_RDI_INTO_CR3
23075 +
23076 +#ifdef CONFIG_PAX_KERNEXEC
23077 + GET_CR0_INTO_RDI
23078 + bts $16,%rdi
23079 + SET_RDI_INTO_CR0
23080 +#endif
23081 +
23082 +3:
23083 +
23084 +#ifdef CONFIG_PARAVIRT
23085 + PV_RESTORE_REGS(CLBR_RDI)
23086 +#endif
23087 +
23088 + popq %rbx
23089 + popq %rdi
23090 + pax_force_retaddr
23091 + retq
23092 +4: ud2
23093 +ENDPROC(pax_enter_kernel_user)
23094 +
23095 +ENTRY(pax_exit_kernel_user)
23096 + pushq %rdi
23097 + pushq %rbx
23098 +
23099 +#ifdef CONFIG_PARAVIRT
23100 + PV_SAVE_REGS(CLBR_RDI)
23101 +#endif
23102 +
23103 + GET_CR3_INTO_RDI
23104 + 661: jmp 1f
23105 + .pushsection .altinstr_replacement, "a"
23106 + 662: ASM_NOP2
23107 + .popsection
23108 + .pushsection .altinstructions, "a"
23109 + altinstruction_entry 661b, 662b, X86_FEATURE_PCID, 2, 2
23110 + .popsection
23111 + cmp $0,%dil
23112 + jnz 3f
23113 + add $4097,%rdi
23114 + bts $63,%rdi
23115 + SET_RDI_INTO_CR3
23116 + jmp 2f
23117 +1:
23118 +
23119 + mov %rdi,%rbx
23120 +
23121 +#ifdef CONFIG_PAX_KERNEXEC
23122 + GET_CR0_INTO_RDI
23123 + btr $16,%rdi
23124 + jnc 3f
23125 + SET_RDI_INTO_CR0
23126 +#endif
23127 +
23128 + add $__START_KERNEL_map,%rbx
23129 + sub phys_base(%rip),%rbx
23130 +
23131 +#ifdef CONFIG_PARAVIRT
23132 + cmpl $0, pv_info+PARAVIRT_enabled
23133 + jz 1f
23134 + i = 0
23135 + .rept USER_PGD_PTRS
23136 + mov i*8(%rbx),%rsi
23137 + mov $0x67,%sil
23138 + lea i*8(%rbx),%rdi
23139 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_set_pgd_batched)
23140 + i = i + 1
23141 + .endr
23142 + jmp 2f
23143 +1:
23144 +#endif
23145 +
23146 + i = 0
23147 + .rept USER_PGD_PTRS
23148 + movb $0x67,i*8(%rbx)
23149 + i = i + 1
23150 + .endr
23151 +2:
23152 +
23153 +#ifdef CONFIG_PARAVIRT
23154 + PV_RESTORE_REGS(CLBR_RDI)
23155 +#endif
23156 +
23157 + popq %rbx
23158 + popq %rdi
23159 + pax_force_retaddr
23160 + retq
23161 +3: ud2
23162 +ENDPROC(pax_exit_kernel_user)
23163 +#endif
23164 +
23165 + .macro pax_enter_kernel_nmi
23166 + pax_set_fptr_mask
23167 +
23168 +#ifdef CONFIG_PAX_KERNEXEC
23169 + GET_CR0_INTO_RDI
23170 + bts $16,%rdi
23171 + jc 110f
23172 + SET_RDI_INTO_CR0
23173 + or $2,%ebx
23174 +110:
23175 +#endif
23176 +
23177 +#ifdef CONFIG_PAX_MEMORY_UDEREF
23178 + 661: jmp 111f
23179 + .pushsection .altinstr_replacement, "a"
23180 + 662: ASM_NOP2
23181 + .popsection
23182 + .pushsection .altinstructions, "a"
23183 + altinstruction_entry 661b, 662b, X86_FEATURE_PCID, 2, 2
23184 + .popsection
23185 + GET_CR3_INTO_RDI
23186 + cmp $0,%dil
23187 + jz 111f
23188 + sub $4097,%rdi
23189 + or $4,%ebx
23190 + bts $63,%rdi
23191 + SET_RDI_INTO_CR3
23192 + mov $__UDEREF_KERNEL_DS,%edi
23193 + mov %edi,%ss
23194 +111:
23195 +#endif
23196 + .endm
23197 +
23198 + .macro pax_exit_kernel_nmi
23199 +#ifdef CONFIG_PAX_KERNEXEC
23200 + btr $1,%ebx
23201 + jnc 110f
23202 + GET_CR0_INTO_RDI
23203 + btr $16,%rdi
23204 + SET_RDI_INTO_CR0
23205 +110:
23206 +#endif
23207 +
23208 +#ifdef CONFIG_PAX_MEMORY_UDEREF
23209 + btr $2,%ebx
23210 + jnc 111f
23211 + GET_CR3_INTO_RDI
23212 + add $4097,%rdi
23213 + bts $63,%rdi
23214 + SET_RDI_INTO_CR3
23215 + mov $__KERNEL_DS,%edi
23216 + mov %edi,%ss
23217 +111:
23218 +#endif
23219 + .endm
23220 +
23221 + .macro pax_erase_kstack
23222 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
23223 + call pax_erase_kstack
23224 +#endif
23225 + .endm
23226 +
23227 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
23228 +ENTRY(pax_erase_kstack)
23229 + pushq %rdi
23230 + pushq %rcx
23231 + pushq %rax
23232 + pushq %r11
23233 +
23234 + GET_THREAD_INFO(%r11)
23235 + mov TI_lowest_stack(%r11), %rdi
23236 + mov $-0xBEEF, %rax
23237 + std
23238 +
23239 +1: mov %edi, %ecx
23240 + and $THREAD_SIZE_asm - 1, %ecx
23241 + shr $3, %ecx
23242 + repne scasq
23243 + jecxz 2f
23244 +
23245 + cmp $2*8, %ecx
23246 + jc 2f
23247 +
23248 + mov $2*8, %ecx
23249 + repe scasq
23250 + jecxz 2f
23251 + jne 1b
23252 +
23253 +2: cld
23254 + mov %esp, %ecx
23255 + sub %edi, %ecx
23256 +
23257 + cmp $THREAD_SIZE_asm, %rcx
23258 + jb 3f
23259 + ud2
23260 +3:
23261 +
23262 + shr $3, %ecx
23263 + rep stosq
23264 +
23265 + mov TI_task_thread_sp0(%r11), %rdi
23266 + sub $256, %rdi
23267 + mov %rdi, TI_lowest_stack(%r11)
23268 +
23269 + popq %r11
23270 + popq %rax
23271 + popq %rcx
23272 + popq %rdi
23273 + pax_force_retaddr
23274 + ret
23275 +ENDPROC(pax_erase_kstack)
23276 +#endif
23277
23278 .macro TRACE_IRQS_IRETQ offset=ARGOFFSET
23279 #ifdef CONFIG_TRACE_IRQFLAGS
23280 @@ -320,7 +753,7 @@ ENDPROC(native_usergs_sysret64)
23281 .endm
23282
23283 .macro TRACE_IRQS_IRETQ_DEBUG offset=ARGOFFSET
23284 - bt $9,EFLAGS-\offset(%rsp) /* interrupts off? */
23285 + bt $X86_EFLAGS_IF_BIT,EFLAGS-\offset(%rsp) /* interrupts off? */
23286 jnc 1f
23287 TRACE_IRQS_ON_DEBUG
23288 1:
23289 @@ -358,27 +791,6 @@ ENDPROC(native_usergs_sysret64)
23290 movq \tmp,R11+\offset(%rsp)
23291 .endm
23292
23293 - .macro FAKE_STACK_FRAME child_rip
23294 - /* push in order ss, rsp, eflags, cs, rip */
23295 - xorl %eax, %eax
23296 - pushq_cfi $__KERNEL_DS /* ss */
23297 - /*CFI_REL_OFFSET ss,0*/
23298 - pushq_cfi %rax /* rsp */
23299 - CFI_REL_OFFSET rsp,0
23300 - pushq_cfi $(X86_EFLAGS_IF|X86_EFLAGS_FIXED) /* eflags - interrupts on */
23301 - /*CFI_REL_OFFSET rflags,0*/
23302 - pushq_cfi $__KERNEL_CS /* cs */
23303 - /*CFI_REL_OFFSET cs,0*/
23304 - pushq_cfi \child_rip /* rip */
23305 - CFI_REL_OFFSET rip,0
23306 - pushq_cfi %rax /* orig rax */
23307 - .endm
23308 -
23309 - .macro UNFAKE_STACK_FRAME
23310 - addq $8*6, %rsp
23311 - CFI_ADJUST_CFA_OFFSET -(6*8)
23312 - .endm
23313 -
23314 /*
23315 * initial frame state for interrupts (and exceptions without error code)
23316 */
23317 @@ -445,25 +857,26 @@ ENDPROC(native_usergs_sysret64)
23318 /* save partial stack frame */
23319 .macro SAVE_ARGS_IRQ
23320 cld
23321 - /* start from rbp in pt_regs and jump over */
23322 - movq_cfi rdi, (RDI-RBP)
23323 - movq_cfi rsi, (RSI-RBP)
23324 - movq_cfi rdx, (RDX-RBP)
23325 - movq_cfi rcx, (RCX-RBP)
23326 - movq_cfi rax, (RAX-RBP)
23327 - movq_cfi r8, (R8-RBP)
23328 - movq_cfi r9, (R9-RBP)
23329 - movq_cfi r10, (R10-RBP)
23330 - movq_cfi r11, (R11-RBP)
23331 + /* start from r15 in pt_regs and jump over */
23332 + movq_cfi rdi, RDI
23333 + movq_cfi rsi, RSI
23334 + movq_cfi rdx, RDX
23335 + movq_cfi rcx, RCX
23336 + movq_cfi rax, RAX
23337 + movq_cfi r8, R8
23338 + movq_cfi r9, R9
23339 + movq_cfi r10, R10
23340 + movq_cfi r11, R11
23341 + movq_cfi r12, R12
23342
23343 /* Save rbp so that we can unwind from get_irq_regs() */
23344 - movq_cfi rbp, 0
23345 + movq_cfi rbp, RBP
23346
23347 /* Save previous stack value */
23348 movq %rsp, %rsi
23349
23350 - leaq -RBP(%rsp),%rdi /* arg1 for handler */
23351 - testl $3, CS-RBP(%rsi)
23352 + movq %rsp,%rdi /* arg1 for handler */
23353 + testb $3, CS(%rsi)
23354 je 1f
23355 SWAPGS
23356 /*
23357 @@ -483,6 +896,18 @@ ENDPROC(native_usergs_sysret64)
23358 0x06 /* DW_OP_deref */, \
23359 0x08 /* DW_OP_const1u */, SS+8-RBP, \
23360 0x22 /* DW_OP_plus */
23361 +
23362 +#ifdef CONFIG_PAX_MEMORY_UDEREF
23363 + testb $3, CS(%rdi)
23364 + jnz 1f
23365 + pax_enter_kernel
23366 + jmp 2f
23367 +1: pax_enter_kernel_user
23368 +2:
23369 +#else
23370 + pax_enter_kernel
23371 +#endif
23372 +
23373 /* We entered an interrupt context - irqs are off: */
23374 TRACE_IRQS_OFF
23375 .endm
23376 @@ -514,9 +939,52 @@ ENTRY(save_paranoid)
23377 js 1f /* negative -> in kernel */
23378 SWAPGS
23379 xorl %ebx,%ebx
23380 -1: ret
23381 +1:
23382 +#ifdef CONFIG_PAX_MEMORY_UDEREF
23383 + testb $3, CS+8(%rsp)
23384 + jnz 1f
23385 + pax_enter_kernel
23386 + jmp 2f
23387 +1: pax_enter_kernel_user
23388 +2:
23389 +#else
23390 + pax_enter_kernel
23391 +#endif
23392 + pax_force_retaddr
23393 + ret
23394 CFI_ENDPROC
23395 -END(save_paranoid)
23396 +ENDPROC(save_paranoid)
23397 +
23398 +ENTRY(save_paranoid_nmi)
23399 + XCPT_FRAME 1 RDI+8
23400 + cld
23401 + movq_cfi rdi, RDI+8
23402 + movq_cfi rsi, RSI+8
23403 + movq_cfi rdx, RDX+8
23404 + movq_cfi rcx, RCX+8
23405 + movq_cfi rax, RAX+8
23406 + movq_cfi r8, R8+8
23407 + movq_cfi r9, R9+8
23408 + movq_cfi r10, R10+8
23409 + movq_cfi r11, R11+8
23410 + movq_cfi rbx, RBX+8
23411 + movq_cfi rbp, RBP+8
23412 + movq_cfi r12, R12+8
23413 + movq_cfi r13, R13+8
23414 + movq_cfi r14, R14+8
23415 + movq_cfi r15, R15+8
23416 + movl $1,%ebx
23417 + movl $MSR_GS_BASE,%ecx
23418 + rdmsr
23419 + testl %edx,%edx
23420 + js 1f /* negative -> in kernel */
23421 + SWAPGS
23422 + xorl %ebx,%ebx
23423 +1: pax_enter_kernel_nmi
23424 + pax_force_retaddr
23425 + ret
23426 + CFI_ENDPROC
23427 +ENDPROC(save_paranoid_nmi)
23428 .popsection
23429
23430 /*
23431 @@ -538,7 +1006,7 @@ ENTRY(ret_from_fork)
23432
23433 RESTORE_REST
23434
23435 - testl $3, CS-ARGOFFSET(%rsp) # from kernel_thread?
23436 + testb $3, CS-ARGOFFSET(%rsp) # from kernel_thread?
23437 jz 1f
23438
23439 testl $_TIF_IA32, TI_flags(%rcx) # 32-bit compat task needs IRET
23440 @@ -548,15 +1016,13 @@ ENTRY(ret_from_fork)
23441 jmp ret_from_sys_call # go to the SYSRET fastpath
23442
23443 1:
23444 - subq $REST_SKIP, %rsp # leave space for volatiles
23445 - CFI_ADJUST_CFA_OFFSET REST_SKIP
23446 movq %rbp, %rdi
23447 call *%rbx
23448 movl $0, RAX(%rsp)
23449 RESTORE_REST
23450 jmp int_ret_from_sys_call
23451 CFI_ENDPROC
23452 -END(ret_from_fork)
23453 +ENDPROC(ret_from_fork)
23454
23455 /*
23456 * System call entry. Up to 6 arguments in registers are supported.
23457 @@ -593,7 +1059,7 @@ END(ret_from_fork)
23458 ENTRY(system_call)
23459 CFI_STARTPROC simple
23460 CFI_SIGNAL_FRAME
23461 - CFI_DEF_CFA rsp,KERNEL_STACK_OFFSET
23462 + CFI_DEF_CFA rsp,0
23463 CFI_REGISTER rip,rcx
23464 /*CFI_REGISTER rflags,r11*/
23465 SWAPGS_UNSAFE_STACK
23466 @@ -606,16 +1072,23 @@ GLOBAL(system_call_after_swapgs)
23467
23468 movq %rsp,PER_CPU_VAR(old_rsp)
23469 movq PER_CPU_VAR(kernel_stack),%rsp
23470 + SAVE_ARGS 8*6,0
23471 + pax_enter_kernel_user
23472 +
23473 +#ifdef CONFIG_PAX_RANDKSTACK
23474 + pax_erase_kstack
23475 +#endif
23476 +
23477 /*
23478 * No need to follow this irqs off/on section - it's straight
23479 * and short:
23480 */
23481 ENABLE_INTERRUPTS(CLBR_NONE)
23482 - SAVE_ARGS 8,0
23483 movq %rax,ORIG_RAX-ARGOFFSET(%rsp)
23484 movq %rcx,RIP-ARGOFFSET(%rsp)
23485 CFI_REL_OFFSET rip,RIP-ARGOFFSET
23486 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
23487 + GET_THREAD_INFO(%rcx)
23488 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%rcx)
23489 jnz tracesys
23490 system_call_fastpath:
23491 #if __SYSCALL_MASK == ~0
23492 @@ -639,10 +1112,13 @@ sysret_check:
23493 LOCKDEP_SYS_EXIT
23494 DISABLE_INTERRUPTS(CLBR_NONE)
23495 TRACE_IRQS_OFF
23496 - movl TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET),%edx
23497 + GET_THREAD_INFO(%rcx)
23498 + movl TI_flags(%rcx),%edx
23499 andl %edi,%edx
23500 jnz sysret_careful
23501 CFI_REMEMBER_STATE
23502 + pax_exit_kernel_user
23503 + pax_erase_kstack
23504 /*
23505 * sysretq will re-enable interrupts:
23506 */
23507 @@ -701,6 +1177,9 @@ auditsys:
23508 movq %rax,%rsi /* 2nd arg: syscall number */
23509 movl $AUDIT_ARCH_X86_64,%edi /* 1st arg: audit arch */
23510 call __audit_syscall_entry
23511 +
23512 + pax_erase_kstack
23513 +
23514 LOAD_ARGS 0 /* reload call-clobbered registers */
23515 jmp system_call_fastpath
23516
23517 @@ -722,7 +1201,7 @@ sysret_audit:
23518 /* Do syscall tracing */
23519 tracesys:
23520 #ifdef CONFIG_AUDITSYSCALL
23521 - testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
23522 + testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags(%rcx)
23523 jz auditsys
23524 #endif
23525 SAVE_REST
23526 @@ -730,12 +1209,15 @@ tracesys:
23527 FIXUP_TOP_OF_STACK %rdi
23528 movq %rsp,%rdi
23529 call syscall_trace_enter
23530 +
23531 + pax_erase_kstack
23532 +
23533 /*
23534 * Reload arg registers from stack in case ptrace changed them.
23535 * We don't reload %rax because syscall_trace_enter() returned
23536 * the value it wants us to use in the table lookup.
23537 */
23538 - LOAD_ARGS ARGOFFSET, 1
23539 + LOAD_ARGS 1
23540 RESTORE_REST
23541 #if __SYSCALL_MASK == ~0
23542 cmpq $__NR_syscall_max,%rax
23543 @@ -765,7 +1247,9 @@ GLOBAL(int_with_check)
23544 andl %edi,%edx
23545 jnz int_careful
23546 andl $~TS_COMPAT,TI_status(%rcx)
23547 - jmp retint_swapgs
23548 + pax_exit_kernel_user
23549 + pax_erase_kstack
23550 + jmp retint_swapgs_pax
23551
23552 /* Either reschedule or signal or syscall exit tracking needed. */
23553 /* First do a reschedule test. */
23554 @@ -811,7 +1295,7 @@ int_restore_rest:
23555 TRACE_IRQS_OFF
23556 jmp int_with_check
23557 CFI_ENDPROC
23558 -END(system_call)
23559 +ENDPROC(system_call)
23560
23561 .macro FORK_LIKE func
23562 ENTRY(stub_\func)
23563 @@ -824,9 +1308,10 @@ ENTRY(stub_\func)
23564 DEFAULT_FRAME 0 8 /* offset 8: return address */
23565 call sys_\func
23566 RESTORE_TOP_OF_STACK %r11, 8
23567 - ret $REST_SKIP /* pop extended registers */
23568 + pax_force_retaddr
23569 + ret
23570 CFI_ENDPROC
23571 -END(stub_\func)
23572 +ENDPROC(stub_\func)
23573 .endm
23574
23575 .macro FIXED_FRAME label,func
23576 @@ -836,9 +1321,10 @@ ENTRY(\label)
23577 FIXUP_TOP_OF_STACK %r11, 8-ARGOFFSET
23578 call \func
23579 RESTORE_TOP_OF_STACK %r11, 8-ARGOFFSET
23580 + pax_force_retaddr
23581 ret
23582 CFI_ENDPROC
23583 -END(\label)
23584 +ENDPROC(\label)
23585 .endm
23586
23587 FORK_LIKE clone
23588 @@ -846,19 +1332,6 @@ END(\label)
23589 FORK_LIKE vfork
23590 FIXED_FRAME stub_iopl, sys_iopl
23591
23592 -ENTRY(ptregscall_common)
23593 - DEFAULT_FRAME 1 8 /* offset 8: return address */
23594 - RESTORE_TOP_OF_STACK %r11, 8
23595 - movq_cfi_restore R15+8, r15
23596 - movq_cfi_restore R14+8, r14
23597 - movq_cfi_restore R13+8, r13
23598 - movq_cfi_restore R12+8, r12
23599 - movq_cfi_restore RBP+8, rbp
23600 - movq_cfi_restore RBX+8, rbx
23601 - ret $REST_SKIP /* pop extended registers */
23602 - CFI_ENDPROC
23603 -END(ptregscall_common)
23604 -
23605 ENTRY(stub_execve)
23606 CFI_STARTPROC
23607 addq $8, %rsp
23608 @@ -870,7 +1343,7 @@ ENTRY(stub_execve)
23609 RESTORE_REST
23610 jmp int_ret_from_sys_call
23611 CFI_ENDPROC
23612 -END(stub_execve)
23613 +ENDPROC(stub_execve)
23614
23615 /*
23616 * sigreturn is special because it needs to restore all registers on return.
23617 @@ -887,7 +1360,7 @@ ENTRY(stub_rt_sigreturn)
23618 RESTORE_REST
23619 jmp int_ret_from_sys_call
23620 CFI_ENDPROC
23621 -END(stub_rt_sigreturn)
23622 +ENDPROC(stub_rt_sigreturn)
23623
23624 #ifdef CONFIG_X86_X32_ABI
23625 ENTRY(stub_x32_rt_sigreturn)
23626 @@ -901,7 +1374,7 @@ ENTRY(stub_x32_rt_sigreturn)
23627 RESTORE_REST
23628 jmp int_ret_from_sys_call
23629 CFI_ENDPROC
23630 -END(stub_x32_rt_sigreturn)
23631 +ENDPROC(stub_x32_rt_sigreturn)
23632
23633 ENTRY(stub_x32_execve)
23634 CFI_STARTPROC
23635 @@ -915,7 +1388,7 @@ ENTRY(stub_x32_execve)
23636 RESTORE_REST
23637 jmp int_ret_from_sys_call
23638 CFI_ENDPROC
23639 -END(stub_x32_execve)
23640 +ENDPROC(stub_x32_execve)
23641
23642 #endif
23643
23644 @@ -952,7 +1425,7 @@ vector=vector+1
23645 2: jmp common_interrupt
23646 .endr
23647 CFI_ENDPROC
23648 -END(irq_entries_start)
23649 +ENDPROC(irq_entries_start)
23650
23651 .previous
23652 END(interrupt)
23653 @@ -969,8 +1442,8 @@ END(interrupt)
23654 /* 0(%rsp): ~(interrupt number) */
23655 .macro interrupt func
23656 /* reserve pt_regs for scratch regs and rbp */
23657 - subq $ORIG_RAX-RBP, %rsp
23658 - CFI_ADJUST_CFA_OFFSET ORIG_RAX-RBP
23659 + subq $ORIG_RAX, %rsp
23660 + CFI_ADJUST_CFA_OFFSET ORIG_RAX
23661 SAVE_ARGS_IRQ
23662 call \func
23663 .endm
23664 @@ -997,14 +1470,14 @@ ret_from_intr:
23665
23666 /* Restore saved previous stack */
23667 popq %rsi
23668 - CFI_DEF_CFA rsi,SS+8-RBP /* reg/off reset after def_cfa_expr */
23669 - leaq ARGOFFSET-RBP(%rsi), %rsp
23670 + CFI_DEF_CFA rsi,SS+8 /* reg/off reset after def_cfa_expr */
23671 + movq %rsi, %rsp
23672 CFI_DEF_CFA_REGISTER rsp
23673 - CFI_ADJUST_CFA_OFFSET RBP-ARGOFFSET
23674 + CFI_ADJUST_CFA_OFFSET -ARGOFFSET
23675
23676 exit_intr:
23677 GET_THREAD_INFO(%rcx)
23678 - testl $3,CS-ARGOFFSET(%rsp)
23679 + testb $3,CS-ARGOFFSET(%rsp)
23680 je retint_kernel
23681
23682 /* Interrupt came from user space */
23683 @@ -1026,12 +1499,16 @@ retint_swapgs: /* return to user-space */
23684 * The iretq could re-enable interrupts:
23685 */
23686 DISABLE_INTERRUPTS(CLBR_ANY)
23687 + pax_exit_kernel_user
23688 +retint_swapgs_pax:
23689 TRACE_IRQS_IRETQ
23690 SWAPGS
23691 jmp restore_args
23692
23693 retint_restore_args: /* return to kernel space */
23694 DISABLE_INTERRUPTS(CLBR_ANY)
23695 + pax_exit_kernel
23696 + pax_force_retaddr (RIP-ARGOFFSET)
23697 /*
23698 * The iretq could re-enable interrupts:
23699 */
23700 @@ -1112,7 +1589,7 @@ ENTRY(retint_kernel)
23701 #endif
23702
23703 CFI_ENDPROC
23704 -END(common_interrupt)
23705 +ENDPROC(common_interrupt)
23706 /*
23707 * End of kprobes section
23708 */
23709 @@ -1130,7 +1607,7 @@ ENTRY(\sym)
23710 interrupt \do_sym
23711 jmp ret_from_intr
23712 CFI_ENDPROC
23713 -END(\sym)
23714 +ENDPROC(\sym)
23715 .endm
23716
23717 #ifdef CONFIG_TRACING
23718 @@ -1218,7 +1695,7 @@ ENTRY(\sym)
23719 call \do_sym
23720 jmp error_exit /* %ebx: no swapgs flag */
23721 CFI_ENDPROC
23722 -END(\sym)
23723 +ENDPROC(\sym)
23724 .endm
23725
23726 .macro paranoidzeroentry sym do_sym
23727 @@ -1236,10 +1713,10 @@ ENTRY(\sym)
23728 call \do_sym
23729 jmp paranoid_exit /* %ebx: no swapgs flag */
23730 CFI_ENDPROC
23731 -END(\sym)
23732 +ENDPROC(\sym)
23733 .endm
23734
23735 -#define INIT_TSS_IST(x) PER_CPU_VAR(init_tss) + (TSS_ist + ((x) - 1) * 8)
23736 +#define INIT_TSS_IST(x) (TSS_ist + ((x) - 1) * 8)(%r13)
23737 .macro paranoidzeroentry_ist sym do_sym ist
23738 ENTRY(\sym)
23739 INTR_FRAME
23740 @@ -1252,12 +1729,18 @@ ENTRY(\sym)
23741 TRACE_IRQS_OFF_DEBUG
23742 movq %rsp,%rdi /* pt_regs pointer */
23743 xorl %esi,%esi /* no error code */
23744 +#ifdef CONFIG_SMP
23745 + imul $TSS_size, PER_CPU_VAR(cpu_number), %r13d
23746 + lea init_tss(%r13), %r13
23747 +#else
23748 + lea init_tss(%rip), %r13
23749 +#endif
23750 subq $EXCEPTION_STKSZ, INIT_TSS_IST(\ist)
23751 call \do_sym
23752 addq $EXCEPTION_STKSZ, INIT_TSS_IST(\ist)
23753 jmp paranoid_exit /* %ebx: no swapgs flag */
23754 CFI_ENDPROC
23755 -END(\sym)
23756 +ENDPROC(\sym)
23757 .endm
23758
23759 .macro errorentry sym do_sym
23760 @@ -1275,7 +1758,7 @@ ENTRY(\sym)
23761 call \do_sym
23762 jmp error_exit /* %ebx: no swapgs flag */
23763 CFI_ENDPROC
23764 -END(\sym)
23765 +ENDPROC(\sym)
23766 .endm
23767
23768 #ifdef CONFIG_TRACING
23769 @@ -1306,7 +1789,7 @@ ENTRY(\sym)
23770 call \do_sym
23771 jmp paranoid_exit /* %ebx: no swapgs flag */
23772 CFI_ENDPROC
23773 -END(\sym)
23774 +ENDPROC(\sym)
23775 .endm
23776
23777 zeroentry divide_error do_divide_error
23778 @@ -1336,9 +1819,10 @@ gs_change:
23779 2: mfence /* workaround */
23780 SWAPGS
23781 popfq_cfi
23782 + pax_force_retaddr
23783 ret
23784 CFI_ENDPROC
23785 -END(native_load_gs_index)
23786 +ENDPROC(native_load_gs_index)
23787
23788 _ASM_EXTABLE(gs_change,bad_gs)
23789 .section .fixup,"ax"
23790 @@ -1366,9 +1850,10 @@ ENTRY(do_softirq_own_stack)
23791 CFI_DEF_CFA_REGISTER rsp
23792 CFI_ADJUST_CFA_OFFSET -8
23793 decl PER_CPU_VAR(irq_count)
23794 + pax_force_retaddr
23795 ret
23796 CFI_ENDPROC
23797 -END(do_softirq_own_stack)
23798 +ENDPROC(do_softirq_own_stack)
23799
23800 #ifdef CONFIG_XEN
23801 zeroentry xen_hypervisor_callback xen_do_hypervisor_callback
23802 @@ -1406,7 +1891,7 @@ ENTRY(xen_do_hypervisor_callback) # do_hypervisor_callback(struct *pt_regs)
23803 decl PER_CPU_VAR(irq_count)
23804 jmp error_exit
23805 CFI_ENDPROC
23806 -END(xen_do_hypervisor_callback)
23807 +ENDPROC(xen_do_hypervisor_callback)
23808
23809 /*
23810 * Hypervisor uses this for application faults while it executes.
23811 @@ -1465,7 +1950,7 @@ ENTRY(xen_failsafe_callback)
23812 SAVE_ALL
23813 jmp error_exit
23814 CFI_ENDPROC
23815 -END(xen_failsafe_callback)
23816 +ENDPROC(xen_failsafe_callback)
23817
23818 apicinterrupt3 HYPERVISOR_CALLBACK_VECTOR \
23819 xen_hvm_callback_vector xen_evtchn_do_upcall
23820 @@ -1517,18 +2002,33 @@ ENTRY(paranoid_exit)
23821 DEFAULT_FRAME
23822 DISABLE_INTERRUPTS(CLBR_NONE)
23823 TRACE_IRQS_OFF_DEBUG
23824 - testl %ebx,%ebx /* swapgs needed? */
23825 + testl $1,%ebx /* swapgs needed? */
23826 jnz paranoid_restore
23827 - testl $3,CS(%rsp)
23828 + testb $3,CS(%rsp)
23829 jnz paranoid_userspace
23830 +#ifdef CONFIG_PAX_MEMORY_UDEREF
23831 + pax_exit_kernel
23832 + TRACE_IRQS_IRETQ 0
23833 + SWAPGS_UNSAFE_STACK
23834 + RESTORE_ALL 8
23835 + pax_force_retaddr_bts
23836 + jmp irq_return
23837 +#endif
23838 paranoid_swapgs:
23839 +#ifdef CONFIG_PAX_MEMORY_UDEREF
23840 + pax_exit_kernel_user
23841 +#else
23842 + pax_exit_kernel
23843 +#endif
23844 TRACE_IRQS_IRETQ 0
23845 SWAPGS_UNSAFE_STACK
23846 RESTORE_ALL 8
23847 jmp irq_return
23848 paranoid_restore:
23849 + pax_exit_kernel
23850 TRACE_IRQS_IRETQ_DEBUG 0
23851 RESTORE_ALL 8
23852 + pax_force_retaddr_bts
23853 jmp irq_return
23854 paranoid_userspace:
23855 GET_THREAD_INFO(%rcx)
23856 @@ -1557,7 +2057,7 @@ paranoid_schedule:
23857 TRACE_IRQS_OFF
23858 jmp paranoid_userspace
23859 CFI_ENDPROC
23860 -END(paranoid_exit)
23861 +ENDPROC(paranoid_exit)
23862
23863 /*
23864 * Exception entry point. This expects an error code/orig_rax on the stack.
23865 @@ -1584,12 +2084,23 @@ ENTRY(error_entry)
23866 movq_cfi r14, R14+8
23867 movq_cfi r15, R15+8
23868 xorl %ebx,%ebx
23869 - testl $3,CS+8(%rsp)
23870 + testb $3,CS+8(%rsp)
23871 je error_kernelspace
23872 error_swapgs:
23873 SWAPGS
23874 error_sti:
23875 +#ifdef CONFIG_PAX_MEMORY_UDEREF
23876 + testb $3, CS+8(%rsp)
23877 + jnz 1f
23878 + pax_enter_kernel
23879 + jmp 2f
23880 +1: pax_enter_kernel_user
23881 +2:
23882 +#else
23883 + pax_enter_kernel
23884 +#endif
23885 TRACE_IRQS_OFF
23886 + pax_force_retaddr
23887 ret
23888
23889 /*
23890 @@ -1616,7 +2127,7 @@ bstep_iret:
23891 movq %rcx,RIP+8(%rsp)
23892 jmp error_swapgs
23893 CFI_ENDPROC
23894 -END(error_entry)
23895 +ENDPROC(error_entry)
23896
23897
23898 /* ebx: no swapgs flag (1: don't need swapgs, 0: need it) */
23899 @@ -1627,7 +2138,7 @@ ENTRY(error_exit)
23900 DISABLE_INTERRUPTS(CLBR_NONE)
23901 TRACE_IRQS_OFF
23902 GET_THREAD_INFO(%rcx)
23903 - testl %eax,%eax
23904 + testl $1,%eax
23905 jne retint_kernel
23906 LOCKDEP_SYS_EXIT_IRQ
23907 movl TI_flags(%rcx),%edx
23908 @@ -1636,7 +2147,7 @@ ENTRY(error_exit)
23909 jnz retint_careful
23910 jmp retint_swapgs
23911 CFI_ENDPROC
23912 -END(error_exit)
23913 +ENDPROC(error_exit)
23914
23915 /*
23916 * Test if a given stack is an NMI stack or not.
23917 @@ -1694,9 +2205,11 @@ ENTRY(nmi)
23918 * If %cs was not the kernel segment, then the NMI triggered in user
23919 * space, which means it is definitely not nested.
23920 */
23921 + cmpl $__KERNEXEC_KERNEL_CS, 16(%rsp)
23922 + je 1f
23923 cmpl $__KERNEL_CS, 16(%rsp)
23924 jne first_nmi
23925 -
23926 +1:
23927 /*
23928 * Check the special variable on the stack to see if NMIs are
23929 * executing.
23930 @@ -1730,8 +2243,7 @@ nested_nmi:
23931
23932 1:
23933 /* Set up the interrupted NMIs stack to jump to repeat_nmi */
23934 - leaq -1*8(%rsp), %rdx
23935 - movq %rdx, %rsp
23936 + subq $8, %rsp
23937 CFI_ADJUST_CFA_OFFSET 1*8
23938 leaq -10*8(%rsp), %rdx
23939 pushq_cfi $__KERNEL_DS
23940 @@ -1749,6 +2261,7 @@ nested_nmi_out:
23941 CFI_RESTORE rdx
23942
23943 /* No need to check faults here */
23944 +# pax_force_retaddr_bts
23945 INTERRUPT_RETURN
23946
23947 CFI_RESTORE_STATE
23948 @@ -1845,13 +2358,13 @@ end_repeat_nmi:
23949 subq $ORIG_RAX-R15, %rsp
23950 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
23951 /*
23952 - * Use save_paranoid to handle SWAPGS, but no need to use paranoid_exit
23953 + * Use save_paranoid_nmi to handle SWAPGS, but no need to use paranoid_exit
23954 * as we should not be calling schedule in NMI context.
23955 * Even with normal interrupts enabled. An NMI should not be
23956 * setting NEED_RESCHED or anything that normal interrupts and
23957 * exceptions might do.
23958 */
23959 - call save_paranoid
23960 + call save_paranoid_nmi
23961 DEFAULT_FRAME 0
23962
23963 /*
23964 @@ -1861,9 +2374,9 @@ end_repeat_nmi:
23965 * NMI itself takes a page fault, the page fault that was preempted
23966 * will read the information from the NMI page fault and not the
23967 * origin fault. Save it off and restore it if it changes.
23968 - * Use the r12 callee-saved register.
23969 + * Use the r13 callee-saved register.
23970 */
23971 - movq %cr2, %r12
23972 + movq %cr2, %r13
23973
23974 /* paranoidentry do_nmi, 0; without TRACE_IRQS_OFF */
23975 movq %rsp,%rdi
23976 @@ -1872,31 +2385,36 @@ end_repeat_nmi:
23977
23978 /* Did the NMI take a page fault? Restore cr2 if it did */
23979 movq %cr2, %rcx
23980 - cmpq %rcx, %r12
23981 + cmpq %rcx, %r13
23982 je 1f
23983 - movq %r12, %cr2
23984 + movq %r13, %cr2
23985 1:
23986
23987 - testl %ebx,%ebx /* swapgs needed? */
23988 + testl $1,%ebx /* swapgs needed? */
23989 jnz nmi_restore
23990 nmi_swapgs:
23991 SWAPGS_UNSAFE_STACK
23992 nmi_restore:
23993 + pax_exit_kernel_nmi
23994 /* Pop the extra iret frame at once */
23995 RESTORE_ALL 6*8
23996 + testb $3, 8(%rsp)
23997 + jnz 1f
23998 + pax_force_retaddr_bts
23999 +1:
24000
24001 /* Clear the NMI executing stack variable */
24002 movq $0, 5*8(%rsp)
24003 jmp irq_return
24004 CFI_ENDPROC
24005 -END(nmi)
24006 +ENDPROC(nmi)
24007
24008 ENTRY(ignore_sysret)
24009 CFI_STARTPROC
24010 mov $-ENOSYS,%eax
24011 sysret
24012 CFI_ENDPROC
24013 -END(ignore_sysret)
24014 +ENDPROC(ignore_sysret)
24015
24016 /*
24017 * End of kprobes section
24018 diff --git a/arch/x86/kernel/ftrace.c b/arch/x86/kernel/ftrace.c
24019 index 52819e8..b6d1dbd 100644
24020 --- a/arch/x86/kernel/ftrace.c
24021 +++ b/arch/x86/kernel/ftrace.c
24022 @@ -104,6 +104,8 @@ ftrace_modify_code_direct(unsigned long ip, unsigned const char *old_code,
24023 {
24024 unsigned char replaced[MCOUNT_INSN_SIZE];
24025
24026 + ip = ktla_ktva(ip);
24027 +
24028 /*
24029 * Note: Due to modules and __init, code can
24030 * disappear and change, we need to protect against faulting
24031 @@ -229,7 +231,7 @@ static int update_ftrace_func(unsigned long ip, void *new)
24032 unsigned char old[MCOUNT_INSN_SIZE];
24033 int ret;
24034
24035 - memcpy(old, (void *)ip, MCOUNT_INSN_SIZE);
24036 + memcpy(old, (void *)ktla_ktva(ip), MCOUNT_INSN_SIZE);
24037
24038 ftrace_update_func = ip;
24039 /* Make sure the breakpoints see the ftrace_update_func update */
24040 @@ -306,7 +308,7 @@ static int ftrace_write(unsigned long ip, const char *val, int size)
24041 * kernel identity mapping to modify code.
24042 */
24043 if (within(ip, (unsigned long)_text, (unsigned long)_etext))
24044 - ip = (unsigned long)__va(__pa_symbol(ip));
24045 + ip = (unsigned long)__va(__pa_symbol(ktla_ktva(ip)));
24046
24047 if (probe_kernel_write((void *)ip, val, size))
24048 return -EPERM;
24049 @@ -319,7 +321,7 @@ static int add_break(unsigned long ip, const char *old)
24050 unsigned char replaced[MCOUNT_INSN_SIZE];
24051 unsigned char brk = BREAKPOINT_INSTRUCTION;
24052
24053 - if (probe_kernel_read(replaced, (void *)ip, MCOUNT_INSN_SIZE))
24054 + if (probe_kernel_read(replaced, (void *)ktla_ktva(ip), MCOUNT_INSN_SIZE))
24055 return -EFAULT;
24056
24057 /* Make sure it is what we expect it to be */
24058 diff --git a/arch/x86/kernel/head64.c b/arch/x86/kernel/head64.c
24059 index 068054f..c248bcd 100644
24060 --- a/arch/x86/kernel/head64.c
24061 +++ b/arch/x86/kernel/head64.c
24062 @@ -67,12 +67,12 @@ again:
24063 pgd = *pgd_p;
24064
24065 /*
24066 - * The use of __START_KERNEL_map rather than __PAGE_OFFSET here is
24067 - * critical -- __PAGE_OFFSET would point us back into the dynamic
24068 + * The use of __early_va rather than __va here is critical:
24069 + * __va would point us back into the dynamic
24070 * range and we might end up looping forever...
24071 */
24072 if (pgd)
24073 - pud_p = (pudval_t *)((pgd & PTE_PFN_MASK) + __START_KERNEL_map - phys_base);
24074 + pud_p = (pudval_t *)(__early_va(pgd & PTE_PFN_MASK));
24075 else {
24076 if (next_early_pgt >= EARLY_DYNAMIC_PAGE_TABLES) {
24077 reset_early_page_tables();
24078 @@ -82,13 +82,13 @@ again:
24079 pud_p = (pudval_t *)early_dynamic_pgts[next_early_pgt++];
24080 for (i = 0; i < PTRS_PER_PUD; i++)
24081 pud_p[i] = 0;
24082 - *pgd_p = (pgdval_t)pud_p - __START_KERNEL_map + phys_base + _KERNPG_TABLE;
24083 + *pgd_p = (pgdval_t)__pa(pud_p) + _KERNPG_TABLE;
24084 }
24085 pud_p += pud_index(address);
24086 pud = *pud_p;
24087
24088 if (pud)
24089 - pmd_p = (pmdval_t *)((pud & PTE_PFN_MASK) + __START_KERNEL_map - phys_base);
24090 + pmd_p = (pmdval_t *)(__early_va(pud & PTE_PFN_MASK));
24091 else {
24092 if (next_early_pgt >= EARLY_DYNAMIC_PAGE_TABLES) {
24093 reset_early_page_tables();
24094 @@ -98,7 +98,7 @@ again:
24095 pmd_p = (pmdval_t *)early_dynamic_pgts[next_early_pgt++];
24096 for (i = 0; i < PTRS_PER_PMD; i++)
24097 pmd_p[i] = 0;
24098 - *pud_p = (pudval_t)pmd_p - __START_KERNEL_map + phys_base + _KERNPG_TABLE;
24099 + *pud_p = (pudval_t)__pa(pmd_p) + _KERNPG_TABLE;
24100 }
24101 pmd = (physaddr & PMD_MASK) + early_pmd_flags;
24102 pmd_p[pmd_index(address)] = pmd;
24103 @@ -175,7 +175,6 @@ asmlinkage __visible void __init x86_64_start_kernel(char * real_mode_data)
24104 if (console_loglevel == 10)
24105 early_printk("Kernel alive\n");
24106
24107 - clear_page(init_level4_pgt);
24108 /* set init_level4_pgt kernel high mapping*/
24109 init_level4_pgt[511] = early_level4_pgt[511];
24110
24111 diff --git a/arch/x86/kernel/head_32.S b/arch/x86/kernel/head_32.S
24112 index f36bd42..56ee1534 100644
24113 --- a/arch/x86/kernel/head_32.S
24114 +++ b/arch/x86/kernel/head_32.S
24115 @@ -26,6 +26,12 @@
24116 /* Physical address */
24117 #define pa(X) ((X) - __PAGE_OFFSET)
24118
24119 +#ifdef CONFIG_PAX_KERNEXEC
24120 +#define ta(X) (X)
24121 +#else
24122 +#define ta(X) ((X) - __PAGE_OFFSET)
24123 +#endif
24124 +
24125 /*
24126 * References to members of the new_cpu_data structure.
24127 */
24128 @@ -55,11 +61,7 @@
24129 * and small than max_low_pfn, otherwise will waste some page table entries
24130 */
24131
24132 -#if PTRS_PER_PMD > 1
24133 -#define PAGE_TABLE_SIZE(pages) (((pages) / PTRS_PER_PMD) + PTRS_PER_PGD)
24134 -#else
24135 -#define PAGE_TABLE_SIZE(pages) ((pages) / PTRS_PER_PGD)
24136 -#endif
24137 +#define PAGE_TABLE_SIZE(pages) ((pages) / PTRS_PER_PTE)
24138
24139 /* Number of possible pages in the lowmem region */
24140 LOWMEM_PAGES = (((1<<32) - __PAGE_OFFSET) >> PAGE_SHIFT)
24141 @@ -78,6 +80,12 @@ INIT_MAP_SIZE = PAGE_TABLE_SIZE(KERNEL_PAGES) * PAGE_SIZE
24142 RESERVE_BRK(pagetables, INIT_MAP_SIZE)
24143
24144 /*
24145 + * Real beginning of normal "text" segment
24146 + */
24147 +ENTRY(stext)
24148 +ENTRY(_stext)
24149 +
24150 +/*
24151 * 32-bit kernel entrypoint; only used by the boot CPU. On entry,
24152 * %esi points to the real-mode code as a 32-bit pointer.
24153 * CS and DS must be 4 GB flat segments, but we don't depend on
24154 @@ -85,6 +93,13 @@ RESERVE_BRK(pagetables, INIT_MAP_SIZE)
24155 * can.
24156 */
24157 __HEAD
24158 +
24159 +#ifdef CONFIG_PAX_KERNEXEC
24160 + jmp startup_32
24161 +/* PaX: fill first page in .text with int3 to catch NULL derefs in kernel mode */
24162 +.fill PAGE_SIZE-5,1,0xcc
24163 +#endif
24164 +
24165 ENTRY(startup_32)
24166 movl pa(stack_start),%ecx
24167
24168 @@ -106,6 +121,59 @@ ENTRY(startup_32)
24169 2:
24170 leal -__PAGE_OFFSET(%ecx),%esp
24171
24172 +#ifdef CONFIG_SMP
24173 + movl $pa(cpu_gdt_table),%edi
24174 + movl $__per_cpu_load,%eax
24175 + movw %ax,GDT_ENTRY_PERCPU * 8 + 2(%edi)
24176 + rorl $16,%eax
24177 + movb %al,GDT_ENTRY_PERCPU * 8 + 4(%edi)
24178 + movb %ah,GDT_ENTRY_PERCPU * 8 + 7(%edi)
24179 + movl $__per_cpu_end - 1,%eax
24180 + subl $__per_cpu_start,%eax
24181 + movw %ax,GDT_ENTRY_PERCPU * 8 + 0(%edi)
24182 +#endif
24183 +
24184 +#ifdef CONFIG_PAX_MEMORY_UDEREF
24185 + movl $NR_CPUS,%ecx
24186 + movl $pa(cpu_gdt_table),%edi
24187 +1:
24188 + movl $((((__PAGE_OFFSET-1) & 0xf0000000) >> 12) | 0x00c09700),GDT_ENTRY_KERNEL_DS * 8 + 4(%edi)
24189 + movl $((((__PAGE_OFFSET-1) & 0xf0000000) >> 12) | 0x00c0fb00),GDT_ENTRY_DEFAULT_USER_CS * 8 + 4(%edi)
24190 + movl $((((__PAGE_OFFSET-1) & 0xf0000000) >> 12) | 0x00c0f300),GDT_ENTRY_DEFAULT_USER_DS * 8 + 4(%edi)
24191 + addl $PAGE_SIZE_asm,%edi
24192 + loop 1b
24193 +#endif
24194 +
24195 +#ifdef CONFIG_PAX_KERNEXEC
24196 + movl $pa(boot_gdt),%edi
24197 + movl $__LOAD_PHYSICAL_ADDR,%eax
24198 + movw %ax,GDT_ENTRY_BOOT_CS * 8 + 2(%edi)
24199 + rorl $16,%eax
24200 + movb %al,GDT_ENTRY_BOOT_CS * 8 + 4(%edi)
24201 + movb %ah,GDT_ENTRY_BOOT_CS * 8 + 7(%edi)
24202 + rorl $16,%eax
24203 +
24204 + ljmp $(__BOOT_CS),$1f
24205 +1:
24206 +
24207 + movl $NR_CPUS,%ecx
24208 + movl $pa(cpu_gdt_table),%edi
24209 + addl $__PAGE_OFFSET,%eax
24210 +1:
24211 + movb $0xc0,GDT_ENTRY_KERNEL_CS * 8 + 6(%edi)
24212 + movb $0xc0,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 6(%edi)
24213 + movw %ax,GDT_ENTRY_KERNEL_CS * 8 + 2(%edi)
24214 + movw %ax,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 2(%edi)
24215 + rorl $16,%eax
24216 + movb %al,GDT_ENTRY_KERNEL_CS * 8 + 4(%edi)
24217 + movb %al,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 4(%edi)
24218 + movb %ah,GDT_ENTRY_KERNEL_CS * 8 + 7(%edi)
24219 + movb %ah,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 7(%edi)
24220 + rorl $16,%eax
24221 + addl $PAGE_SIZE_asm,%edi
24222 + loop 1b
24223 +#endif
24224 +
24225 /*
24226 * Clear BSS first so that there are no surprises...
24227 */
24228 @@ -201,8 +269,11 @@ ENTRY(startup_32)
24229 movl %eax, pa(max_pfn_mapped)
24230
24231 /* Do early initialization of the fixmap area */
24232 - movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,%eax
24233 - movl %eax,pa(initial_pg_pmd+0x1000*KPMDS-8)
24234 +#ifdef CONFIG_COMPAT_VDSO
24235 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR+_PAGE_USER,pa(initial_pg_pmd+0x1000*KPMDS-8)
24236 +#else
24237 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,pa(initial_pg_pmd+0x1000*KPMDS-8)
24238 +#endif
24239 #else /* Not PAE */
24240
24241 page_pde_offset = (__PAGE_OFFSET >> 20);
24242 @@ -232,8 +303,11 @@ page_pde_offset = (__PAGE_OFFSET >> 20);
24243 movl %eax, pa(max_pfn_mapped)
24244
24245 /* Do early initialization of the fixmap area */
24246 - movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,%eax
24247 - movl %eax,pa(initial_page_table+0xffc)
24248 +#ifdef CONFIG_COMPAT_VDSO
24249 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR+_PAGE_USER,pa(initial_page_table+0xffc)
24250 +#else
24251 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,pa(initial_page_table+0xffc)
24252 +#endif
24253 #endif
24254
24255 #ifdef CONFIG_PARAVIRT
24256 @@ -247,9 +321,7 @@ page_pde_offset = (__PAGE_OFFSET >> 20);
24257 cmpl $num_subarch_entries, %eax
24258 jae bad_subarch
24259
24260 - movl pa(subarch_entries)(,%eax,4), %eax
24261 - subl $__PAGE_OFFSET, %eax
24262 - jmp *%eax
24263 + jmp *pa(subarch_entries)(,%eax,4)
24264
24265 bad_subarch:
24266 WEAK(lguest_entry)
24267 @@ -261,10 +333,10 @@ WEAK(xen_entry)
24268 __INITDATA
24269
24270 subarch_entries:
24271 - .long default_entry /* normal x86/PC */
24272 - .long lguest_entry /* lguest hypervisor */
24273 - .long xen_entry /* Xen hypervisor */
24274 - .long default_entry /* Moorestown MID */
24275 + .long ta(default_entry) /* normal x86/PC */
24276 + .long ta(lguest_entry) /* lguest hypervisor */
24277 + .long ta(xen_entry) /* Xen hypervisor */
24278 + .long ta(default_entry) /* Moorestown MID */
24279 num_subarch_entries = (. - subarch_entries) / 4
24280 .previous
24281 #else
24282 @@ -354,6 +426,7 @@ default_entry:
24283 movl pa(mmu_cr4_features),%eax
24284 movl %eax,%cr4
24285
24286 +#ifdef CONFIG_X86_PAE
24287 testb $X86_CR4_PAE, %al # check if PAE is enabled
24288 jz enable_paging
24289
24290 @@ -382,6 +455,9 @@ default_entry:
24291 /* Make changes effective */
24292 wrmsr
24293
24294 + btsl $_PAGE_BIT_NX-32,pa(__supported_pte_mask+4)
24295 +#endif
24296 +
24297 enable_paging:
24298
24299 /*
24300 @@ -449,14 +525,20 @@ is486:
24301 1: movl $(__KERNEL_DS),%eax # reload all the segment registers
24302 movl %eax,%ss # after changing gdt.
24303
24304 - movl $(__USER_DS),%eax # DS/ES contains default USER segment
24305 +# movl $(__KERNEL_DS),%eax # DS/ES contains default KERNEL segment
24306 movl %eax,%ds
24307 movl %eax,%es
24308
24309 movl $(__KERNEL_PERCPU), %eax
24310 movl %eax,%fs # set this cpu's percpu
24311
24312 +#ifdef CONFIG_CC_STACKPROTECTOR
24313 movl $(__KERNEL_STACK_CANARY),%eax
24314 +#elif defined(CONFIG_PAX_MEMORY_UDEREF)
24315 + movl $(__USER_DS),%eax
24316 +#else
24317 + xorl %eax,%eax
24318 +#endif
24319 movl %eax,%gs
24320
24321 xorl %eax,%eax # Clear LDT
24322 @@ -512,8 +594,11 @@ setup_once:
24323 * relocation. Manually set base address in stack canary
24324 * segment descriptor.
24325 */
24326 - movl $gdt_page,%eax
24327 + movl $cpu_gdt_table,%eax
24328 movl $stack_canary,%ecx
24329 +#ifdef CONFIG_SMP
24330 + addl $__per_cpu_load,%ecx
24331 +#endif
24332 movw %cx, 8 * GDT_ENTRY_STACK_CANARY + 2(%eax)
24333 shrl $16, %ecx
24334 movb %cl, 8 * GDT_ENTRY_STACK_CANARY + 4(%eax)
24335 @@ -548,7 +633,7 @@ ENTRY(early_idt_handler)
24336 cmpl $2,(%esp) # X86_TRAP_NMI
24337 je is_nmi # Ignore NMI
24338
24339 - cmpl $2,%ss:early_recursion_flag
24340 + cmpl $1,%ss:early_recursion_flag
24341 je hlt_loop
24342 incl %ss:early_recursion_flag
24343
24344 @@ -586,8 +671,8 @@ ENTRY(early_idt_handler)
24345 pushl (20+6*4)(%esp) /* trapno */
24346 pushl $fault_msg
24347 call printk
24348 -#endif
24349 call dump_stack
24350 +#endif
24351 hlt_loop:
24352 hlt
24353 jmp hlt_loop
24354 @@ -607,8 +692,11 @@ ENDPROC(early_idt_handler)
24355 /* This is the default interrupt "handler" :-) */
24356 ALIGN
24357 ignore_int:
24358 - cld
24359 #ifdef CONFIG_PRINTK
24360 + cmpl $2,%ss:early_recursion_flag
24361 + je hlt_loop
24362 + incl %ss:early_recursion_flag
24363 + cld
24364 pushl %eax
24365 pushl %ecx
24366 pushl %edx
24367 @@ -617,9 +705,6 @@ ignore_int:
24368 movl $(__KERNEL_DS),%eax
24369 movl %eax,%ds
24370 movl %eax,%es
24371 - cmpl $2,early_recursion_flag
24372 - je hlt_loop
24373 - incl early_recursion_flag
24374 pushl 16(%esp)
24375 pushl 24(%esp)
24376 pushl 32(%esp)
24377 @@ -653,29 +738,34 @@ ENTRY(setup_once_ref)
24378 /*
24379 * BSS section
24380 */
24381 -__PAGE_ALIGNED_BSS
24382 - .align PAGE_SIZE
24383 #ifdef CONFIG_X86_PAE
24384 +.section .initial_pg_pmd,"a",@progbits
24385 initial_pg_pmd:
24386 .fill 1024*KPMDS,4,0
24387 #else
24388 +.section .initial_page_table,"a",@progbits
24389 ENTRY(initial_page_table)
24390 .fill 1024,4,0
24391 #endif
24392 +.section .initial_pg_fixmap,"a",@progbits
24393 initial_pg_fixmap:
24394 .fill 1024,4,0
24395 +.section .empty_zero_page,"a",@progbits
24396 ENTRY(empty_zero_page)
24397 .fill 4096,1,0
24398 +.section .swapper_pg_dir,"a",@progbits
24399 ENTRY(swapper_pg_dir)
24400 +#ifdef CONFIG_X86_PAE
24401 + .fill 4,8,0
24402 +#else
24403 .fill 1024,4,0
24404 +#endif
24405
24406 /*
24407 * This starts the data section.
24408 */
24409 #ifdef CONFIG_X86_PAE
24410 -__PAGE_ALIGNED_DATA
24411 - /* Page-aligned for the benefit of paravirt? */
24412 - .align PAGE_SIZE
24413 +.section .initial_page_table,"a",@progbits
24414 ENTRY(initial_page_table)
24415 .long pa(initial_pg_pmd+PGD_IDENT_ATTR),0 /* low identity map */
24416 # if KPMDS == 3
24417 @@ -694,12 +784,20 @@ ENTRY(initial_page_table)
24418 # error "Kernel PMDs should be 1, 2 or 3"
24419 # endif
24420 .align PAGE_SIZE /* needs to be page-sized too */
24421 +
24422 +#ifdef CONFIG_PAX_PER_CPU_PGD
24423 +ENTRY(cpu_pgd)
24424 + .rept 2*NR_CPUS
24425 + .fill 4,8,0
24426 + .endr
24427 +#endif
24428 +
24429 #endif
24430
24431 .data
24432 .balign 4
24433 ENTRY(stack_start)
24434 - .long init_thread_union+THREAD_SIZE
24435 + .long init_thread_union+THREAD_SIZE-8
24436
24437 __INITRODATA
24438 int_msg:
24439 @@ -727,7 +825,7 @@ fault_msg:
24440 * segment size, and 32-bit linear address value:
24441 */
24442
24443 - .data
24444 +.section .rodata,"a",@progbits
24445 .globl boot_gdt_descr
24446 .globl idt_descr
24447
24448 @@ -736,7 +834,7 @@ fault_msg:
24449 .word 0 # 32 bit align gdt_desc.address
24450 boot_gdt_descr:
24451 .word __BOOT_DS+7
24452 - .long boot_gdt - __PAGE_OFFSET
24453 + .long pa(boot_gdt)
24454
24455 .word 0 # 32-bit align idt_desc.address
24456 idt_descr:
24457 @@ -747,7 +845,7 @@ idt_descr:
24458 .word 0 # 32 bit align gdt_desc.address
24459 ENTRY(early_gdt_descr)
24460 .word GDT_ENTRIES*8-1
24461 - .long gdt_page /* Overwritten for secondary CPUs */
24462 + .long cpu_gdt_table /* Overwritten for secondary CPUs */
24463
24464 /*
24465 * The boot_gdt must mirror the equivalent in setup.S and is
24466 @@ -756,5 +854,65 @@ ENTRY(early_gdt_descr)
24467 .align L1_CACHE_BYTES
24468 ENTRY(boot_gdt)
24469 .fill GDT_ENTRY_BOOT_CS,8,0
24470 - .quad 0x00cf9a000000ffff /* kernel 4GB code at 0x00000000 */
24471 - .quad 0x00cf92000000ffff /* kernel 4GB data at 0x00000000 */
24472 + .quad 0x00cf9b000000ffff /* kernel 4GB code at 0x00000000 */
24473 + .quad 0x00cf93000000ffff /* kernel 4GB data at 0x00000000 */
24474 +
24475 + .align PAGE_SIZE_asm
24476 +ENTRY(cpu_gdt_table)
24477 + .rept NR_CPUS
24478 + .quad 0x0000000000000000 /* NULL descriptor */
24479 + .quad 0x0000000000000000 /* 0x0b reserved */
24480 + .quad 0x0000000000000000 /* 0x13 reserved */
24481 + .quad 0x0000000000000000 /* 0x1b reserved */
24482 +
24483 +#ifdef CONFIG_PAX_KERNEXEC
24484 + .quad 0x00cf9b000000ffff /* 0x20 alternate kernel 4GB code at 0x00000000 */
24485 +#else
24486 + .quad 0x0000000000000000 /* 0x20 unused */
24487 +#endif
24488 +
24489 + .quad 0x0000000000000000 /* 0x28 unused */
24490 + .quad 0x0000000000000000 /* 0x33 TLS entry 1 */
24491 + .quad 0x0000000000000000 /* 0x3b TLS entry 2 */
24492 + .quad 0x0000000000000000 /* 0x43 TLS entry 3 */
24493 + .quad 0x0000000000000000 /* 0x4b reserved */
24494 + .quad 0x0000000000000000 /* 0x53 reserved */
24495 + .quad 0x0000000000000000 /* 0x5b reserved */
24496 +
24497 + .quad 0x00cf9b000000ffff /* 0x60 kernel 4GB code at 0x00000000 */
24498 + .quad 0x00cf93000000ffff /* 0x68 kernel 4GB data at 0x00000000 */
24499 + .quad 0x00cffb000000ffff /* 0x73 user 4GB code at 0x00000000 */
24500 + .quad 0x00cff3000000ffff /* 0x7b user 4GB data at 0x00000000 */
24501 +
24502 + .quad 0x0000000000000000 /* 0x80 TSS descriptor */
24503 + .quad 0x0000000000000000 /* 0x88 LDT descriptor */
24504 +
24505 + /*
24506 + * Segments used for calling PnP BIOS have byte granularity.
24507 + * The code segments and data segments have fixed 64k limits,
24508 + * the transfer segment sizes are set at run time.
24509 + */
24510 + .quad 0x00409b000000ffff /* 0x90 32-bit code */
24511 + .quad 0x00009b000000ffff /* 0x98 16-bit code */
24512 + .quad 0x000093000000ffff /* 0xa0 16-bit data */
24513 + .quad 0x0000930000000000 /* 0xa8 16-bit data */
24514 + .quad 0x0000930000000000 /* 0xb0 16-bit data */
24515 +
24516 + /*
24517 + * The APM segments have byte granularity and their bases
24518 + * are set at run time. All have 64k limits.
24519 + */
24520 + .quad 0x00409b000000ffff /* 0xb8 APM CS code */
24521 + .quad 0x00009b000000ffff /* 0xc0 APM CS 16 code (16 bit) */
24522 + .quad 0x004093000000ffff /* 0xc8 APM DS data */
24523 +
24524 + .quad 0x00c0930000000000 /* 0xd0 - ESPFIX SS */
24525 + .quad 0x0040930000000000 /* 0xd8 - PERCPU */
24526 + .quad 0x0040910000000017 /* 0xe0 - STACK_CANARY */
24527 + .quad 0x0000000000000000 /* 0xe8 - PCIBIOS_CS */
24528 + .quad 0x0000000000000000 /* 0xf0 - PCIBIOS_DS */
24529 + .quad 0x0000000000000000 /* 0xf8 - GDT entry 31: double-fault TSS */
24530 +
24531 + /* Be sure this is zeroed to avoid false validations in Xen */
24532 + .fill PAGE_SIZE_asm - GDT_SIZE,1,0
24533 + .endr
24534 diff --git a/arch/x86/kernel/head_64.S b/arch/x86/kernel/head_64.S
24535 index a468c0a..c7dec74 100644
24536 --- a/arch/x86/kernel/head_64.S
24537 +++ b/arch/x86/kernel/head_64.S
24538 @@ -20,6 +20,8 @@
24539 #include <asm/processor-flags.h>
24540 #include <asm/percpu.h>
24541 #include <asm/nops.h>
24542 +#include <asm/cpufeature.h>
24543 +#include <asm/alternative-asm.h>
24544
24545 #ifdef CONFIG_PARAVIRT
24546 #include <asm/asm-offsets.h>
24547 @@ -41,6 +43,12 @@ L4_PAGE_OFFSET = pgd_index(__PAGE_OFFSET)
24548 L3_PAGE_OFFSET = pud_index(__PAGE_OFFSET)
24549 L4_START_KERNEL = pgd_index(__START_KERNEL_map)
24550 L3_START_KERNEL = pud_index(__START_KERNEL_map)
24551 +L4_VMALLOC_START = pgd_index(VMALLOC_START)
24552 +L3_VMALLOC_START = pud_index(VMALLOC_START)
24553 +L4_VMALLOC_END = pgd_index(VMALLOC_END)
24554 +L3_VMALLOC_END = pud_index(VMALLOC_END)
24555 +L4_VMEMMAP_START = pgd_index(VMEMMAP_START)
24556 +L3_VMEMMAP_START = pud_index(VMEMMAP_START)
24557
24558 .text
24559 __HEAD
24560 @@ -89,11 +97,24 @@ startup_64:
24561 * Fixup the physical addresses in the page table
24562 */
24563 addq %rbp, early_level4_pgt + (L4_START_KERNEL*8)(%rip)
24564 + addq %rbp, init_level4_pgt + (L4_PAGE_OFFSET*8)(%rip)
24565 + addq %rbp, init_level4_pgt + (L4_VMALLOC_START*8)(%rip)
24566 + addq %rbp, init_level4_pgt + (L4_VMALLOC_END*8)(%rip)
24567 + addq %rbp, init_level4_pgt + (L4_VMEMMAP_START*8)(%rip)
24568 + addq %rbp, init_level4_pgt + (L4_START_KERNEL*8)(%rip)
24569
24570 - addq %rbp, level3_kernel_pgt + (510*8)(%rip)
24571 - addq %rbp, level3_kernel_pgt + (511*8)(%rip)
24572 + addq %rbp, level3_ident_pgt + (0*8)(%rip)
24573 +#ifndef CONFIG_XEN
24574 + addq %rbp, level3_ident_pgt + (1*8)(%rip)
24575 +#endif
24576 +
24577 + addq %rbp, level3_vmemmap_pgt + (L3_VMEMMAP_START*8)(%rip)
24578 +
24579 + addq %rbp, level3_kernel_pgt + (L3_START_KERNEL*8)(%rip)
24580 + addq %rbp, level3_kernel_pgt + ((L3_START_KERNEL+1)*8)(%rip)
24581
24582 addq %rbp, level2_fixmap_pgt + (506*8)(%rip)
24583 + addq %rbp, level2_fixmap_pgt + (507*8)(%rip)
24584
24585 /*
24586 * Set up the identity mapping for the switchover. These
24587 @@ -177,8 +198,8 @@ ENTRY(secondary_startup_64)
24588 movq $(init_level4_pgt - __START_KERNEL_map), %rax
24589 1:
24590
24591 - /* Enable PAE mode and PGE */
24592 - movl $(X86_CR4_PAE | X86_CR4_PGE), %ecx
24593 + /* Enable PAE mode and PSE/PGE */
24594 + movl $(X86_CR4_PSE | X86_CR4_PAE | X86_CR4_PGE), %ecx
24595 movq %rcx, %cr4
24596
24597 /* Setup early boot stage 4 level pagetables. */
24598 @@ -199,10 +220,19 @@ ENTRY(secondary_startup_64)
24599 movl $MSR_EFER, %ecx
24600 rdmsr
24601 btsl $_EFER_SCE, %eax /* Enable System Call */
24602 - btl $20,%edi /* No Execute supported? */
24603 + btl $(X86_FEATURE_NX & 31),%edi /* No Execute supported? */
24604 jnc 1f
24605 btsl $_EFER_NX, %eax
24606 btsq $_PAGE_BIT_NX,early_pmd_flags(%rip)
24607 +#ifndef CONFIG_EFI
24608 + btsq $_PAGE_BIT_NX, init_level4_pgt + 8*L4_PAGE_OFFSET(%rip)
24609 +#endif
24610 + btsq $_PAGE_BIT_NX, init_level4_pgt + 8*L4_VMALLOC_START(%rip)
24611 + btsq $_PAGE_BIT_NX, init_level4_pgt + 8*L4_VMALLOC_END(%rip)
24612 + btsq $_PAGE_BIT_NX, init_level4_pgt + 8*L4_VMEMMAP_START(%rip)
24613 + btsq $_PAGE_BIT_NX, level2_fixmap_pgt + 8*506(%rip)
24614 + btsq $_PAGE_BIT_NX, level2_fixmap_pgt + 8*507(%rip)
24615 + btsq $_PAGE_BIT_NX, __supported_pte_mask(%rip)
24616 1: wrmsr /* Make changes effective */
24617
24618 /* Setup cr0 */
24619 @@ -282,6 +312,7 @@ ENTRY(secondary_startup_64)
24620 * REX.W + FF /5 JMP m16:64 Jump far, absolute indirect,
24621 * address given in m16:64.
24622 */
24623 + pax_set_fptr_mask
24624 movq initial_code(%rip),%rax
24625 pushq $0 # fake return address to stop unwinder
24626 pushq $__KERNEL_CS # set correct cs
24627 @@ -313,7 +344,7 @@ ENDPROC(start_cpu0)
24628 .quad INIT_PER_CPU_VAR(irq_stack_union)
24629
24630 GLOBAL(stack_start)
24631 - .quad init_thread_union+THREAD_SIZE-8
24632 + .quad init_thread_union+THREAD_SIZE-16
24633 .word 0
24634 __FINITDATA
24635
24636 @@ -391,7 +422,7 @@ ENTRY(early_idt_handler)
24637 call dump_stack
24638 #ifdef CONFIG_KALLSYMS
24639 leaq early_idt_ripmsg(%rip),%rdi
24640 - movq 40(%rsp),%rsi # %rip again
24641 + movq 88(%rsp),%rsi # %rip again
24642 call __print_symbol
24643 #endif
24644 #endif /* EARLY_PRINTK */
24645 @@ -420,6 +451,7 @@ ENDPROC(early_idt_handler)
24646 early_recursion_flag:
24647 .long 0
24648
24649 + .section .rodata,"a",@progbits
24650 #ifdef CONFIG_EARLY_PRINTK
24651 early_idt_msg:
24652 .asciz "PANIC: early exception %02lx rip %lx:%lx error %lx cr2 %lx\n"
24653 @@ -447,29 +479,52 @@ NEXT_PAGE(early_level4_pgt)
24654 NEXT_PAGE(early_dynamic_pgts)
24655 .fill 512*EARLY_DYNAMIC_PAGE_TABLES,8,0
24656
24657 - .data
24658 + .section .rodata,"a",@progbits
24659
24660 -#ifndef CONFIG_XEN
24661 NEXT_PAGE(init_level4_pgt)
24662 - .fill 512,8,0
24663 -#else
24664 -NEXT_PAGE(init_level4_pgt)
24665 - .quad level3_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
24666 .org init_level4_pgt + L4_PAGE_OFFSET*8, 0
24667 .quad level3_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
24668 + .org init_level4_pgt + L4_VMALLOC_START*8, 0
24669 + .quad level3_vmalloc_start_pgt - __START_KERNEL_map + _KERNPG_TABLE
24670 + .org init_level4_pgt + L4_VMALLOC_END*8, 0
24671 + .quad level3_vmalloc_end_pgt - __START_KERNEL_map + _KERNPG_TABLE
24672 + .org init_level4_pgt + L4_VMEMMAP_START*8, 0
24673 + .quad level3_vmemmap_pgt - __START_KERNEL_map + _KERNPG_TABLE
24674 .org init_level4_pgt + L4_START_KERNEL*8, 0
24675 /* (2^48-(2*1024*1024*1024))/(2^39) = 511 */
24676 .quad level3_kernel_pgt - __START_KERNEL_map + _PAGE_TABLE
24677
24678 +#ifdef CONFIG_PAX_PER_CPU_PGD
24679 +NEXT_PAGE(cpu_pgd)
24680 + .rept 2*NR_CPUS
24681 + .fill 512,8,0
24682 + .endr
24683 +#endif
24684 +
24685 NEXT_PAGE(level3_ident_pgt)
24686 .quad level2_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
24687 +#ifdef CONFIG_XEN
24688 .fill 511, 8, 0
24689 +#else
24690 + .quad level2_ident_pgt + PAGE_SIZE - __START_KERNEL_map + _KERNPG_TABLE
24691 + .fill 510,8,0
24692 +#endif
24693 +
24694 +NEXT_PAGE(level3_vmalloc_start_pgt)
24695 + .fill 512,8,0
24696 +
24697 +NEXT_PAGE(level3_vmalloc_end_pgt)
24698 + .fill 512,8,0
24699 +
24700 +NEXT_PAGE(level3_vmemmap_pgt)
24701 + .fill L3_VMEMMAP_START,8,0
24702 + .quad level2_vmemmap_pgt - __START_KERNEL_map + _KERNPG_TABLE
24703 +
24704 NEXT_PAGE(level2_ident_pgt)
24705 - /* Since I easily can, map the first 1G.
24706 + /* Since I easily can, map the first 2G.
24707 * Don't set NX because code runs from these pages.
24708 */
24709 - PMDS(0, __PAGE_KERNEL_IDENT_LARGE_EXEC, PTRS_PER_PMD)
24710 -#endif
24711 + PMDS(0, __PAGE_KERNEL_IDENT_LARGE_EXEC, 2*PTRS_PER_PMD)
24712
24713 NEXT_PAGE(level3_kernel_pgt)
24714 .fill L3_START_KERNEL,8,0
24715 @@ -477,6 +532,9 @@ NEXT_PAGE(level3_kernel_pgt)
24716 .quad level2_kernel_pgt - __START_KERNEL_map + _KERNPG_TABLE
24717 .quad level2_fixmap_pgt - __START_KERNEL_map + _PAGE_TABLE
24718
24719 +NEXT_PAGE(level2_vmemmap_pgt)
24720 + .fill 512,8,0
24721 +
24722 NEXT_PAGE(level2_kernel_pgt)
24723 /*
24724 * 512 MB kernel mapping. We spend a full page on this pagetable
24725 @@ -494,28 +552,64 @@ NEXT_PAGE(level2_kernel_pgt)
24726 NEXT_PAGE(level2_fixmap_pgt)
24727 .fill 506,8,0
24728 .quad level1_fixmap_pgt - __START_KERNEL_map + _PAGE_TABLE
24729 - /* 8MB reserved for vsyscalls + a 2MB hole = 4 + 1 entries */
24730 - .fill 5,8,0
24731 + .quad level1_vsyscall_pgt - __START_KERNEL_map + _PAGE_TABLE
24732 + /* 6MB reserved for vsyscalls + a 2MB hole = 3 + 1 entries */
24733 + .fill 4,8,0
24734
24735 NEXT_PAGE(level1_fixmap_pgt)
24736 .fill 512,8,0
24737
24738 +NEXT_PAGE(level1_vsyscall_pgt)
24739 + .fill 512,8,0
24740 +
24741 #undef PMDS
24742
24743 - .data
24744 + .align PAGE_SIZE
24745 +ENTRY(cpu_gdt_table)
24746 + .rept NR_CPUS
24747 + .quad 0x0000000000000000 /* NULL descriptor */
24748 + .quad 0x00cf9b000000ffff /* __KERNEL32_CS */
24749 + .quad 0x00af9b000000ffff /* __KERNEL_CS */
24750 + .quad 0x00cf93000000ffff /* __KERNEL_DS */
24751 + .quad 0x00cffb000000ffff /* __USER32_CS */
24752 + .quad 0x00cff3000000ffff /* __USER_DS, __USER32_DS */
24753 + .quad 0x00affb000000ffff /* __USER_CS */
24754 +
24755 +#ifdef CONFIG_PAX_KERNEXEC
24756 + .quad 0x00af9b000000ffff /* __KERNEXEC_KERNEL_CS */
24757 +#else
24758 + .quad 0x0 /* unused */
24759 +#endif
24760 +
24761 + .quad 0,0 /* TSS */
24762 + .quad 0,0 /* LDT */
24763 + .quad 0,0,0 /* three TLS descriptors */
24764 + .quad 0x0000f40000000000 /* node/CPU stored in limit */
24765 + /* asm/segment.h:GDT_ENTRIES must match this */
24766 +
24767 +#ifdef CONFIG_PAX_MEMORY_UDEREF
24768 + .quad 0x00cf93000000ffff /* __UDEREF_KERNEL_DS */
24769 +#else
24770 + .quad 0x0 /* unused */
24771 +#endif
24772 +
24773 + /* zero the remaining page */
24774 + .fill PAGE_SIZE / 8 - GDT_ENTRIES,8,0
24775 + .endr
24776 +
24777 .align 16
24778 .globl early_gdt_descr
24779 early_gdt_descr:
24780 .word GDT_ENTRIES*8-1
24781 early_gdt_descr_base:
24782 - .quad INIT_PER_CPU_VAR(gdt_page)
24783 + .quad cpu_gdt_table
24784
24785 ENTRY(phys_base)
24786 /* This must match the first entry in level2_kernel_pgt */
24787 .quad 0x0000000000000000
24788
24789 #include "../../x86/xen/xen-head.S"
24790 -
24791 - __PAGE_ALIGNED_BSS
24792 +
24793 + .section .rodata,"a",@progbits
24794 NEXT_PAGE(empty_zero_page)
24795 .skip PAGE_SIZE
24796 diff --git a/arch/x86/kernel/i386_ksyms_32.c b/arch/x86/kernel/i386_ksyms_32.c
24797 index 05fd74f..c3548b1 100644
24798 --- a/arch/x86/kernel/i386_ksyms_32.c
24799 +++ b/arch/x86/kernel/i386_ksyms_32.c
24800 @@ -20,8 +20,12 @@ extern void cmpxchg8b_emu(void);
24801 EXPORT_SYMBOL(cmpxchg8b_emu);
24802 #endif
24803
24804 +EXPORT_SYMBOL_GPL(cpu_gdt_table);
24805 +
24806 /* Networking helper routines. */
24807 EXPORT_SYMBOL(csum_partial_copy_generic);
24808 +EXPORT_SYMBOL(csum_partial_copy_generic_to_user);
24809 +EXPORT_SYMBOL(csum_partial_copy_generic_from_user);
24810
24811 EXPORT_SYMBOL(__get_user_1);
24812 EXPORT_SYMBOL(__get_user_2);
24813 @@ -44,3 +48,11 @@ EXPORT_SYMBOL(___preempt_schedule);
24814 EXPORT_SYMBOL(___preempt_schedule_context);
24815 #endif
24816 #endif
24817 +
24818 +#ifdef CONFIG_PAX_KERNEXEC
24819 +EXPORT_SYMBOL(__LOAD_PHYSICAL_ADDR);
24820 +#endif
24821 +
24822 +#ifdef CONFIG_PAX_PER_CPU_PGD
24823 +EXPORT_SYMBOL(cpu_pgd);
24824 +#endif
24825 diff --git a/arch/x86/kernel/i387.c b/arch/x86/kernel/i387.c
24826 index d5dd808..b6432cf 100644
24827 --- a/arch/x86/kernel/i387.c
24828 +++ b/arch/x86/kernel/i387.c
24829 @@ -51,7 +51,7 @@ static inline bool interrupted_kernel_fpu_idle(void)
24830 static inline bool interrupted_user_mode(void)
24831 {
24832 struct pt_regs *regs = get_irq_regs();
24833 - return regs && user_mode_vm(regs);
24834 + return regs && user_mode(regs);
24835 }
24836
24837 /*
24838 diff --git a/arch/x86/kernel/i8259.c b/arch/x86/kernel/i8259.c
24839 index 2e977b5..5f2c273 100644
24840 --- a/arch/x86/kernel/i8259.c
24841 +++ b/arch/x86/kernel/i8259.c
24842 @@ -110,7 +110,7 @@ static int i8259A_irq_pending(unsigned int irq)
24843 static void make_8259A_irq(unsigned int irq)
24844 {
24845 disable_irq_nosync(irq);
24846 - io_apic_irqs &= ~(1<<irq);
24847 + io_apic_irqs &= ~(1UL<<irq);
24848 irq_set_chip_and_handler_name(irq, &i8259A_chip, handle_level_irq,
24849 i8259A_chip.name);
24850 enable_irq(irq);
24851 @@ -209,7 +209,7 @@ spurious_8259A_irq:
24852 "spurious 8259A interrupt: IRQ%d.\n", irq);
24853 spurious_irq_mask |= irqmask;
24854 }
24855 - atomic_inc(&irq_err_count);
24856 + atomic_inc_unchecked(&irq_err_count);
24857 /*
24858 * Theoretically we do not have to handle this IRQ,
24859 * but in Linux this does not cause problems and is
24860 @@ -332,14 +332,16 @@ static void init_8259A(int auto_eoi)
24861 /* (slave's support for AEOI in flat mode is to be investigated) */
24862 outb_pic(SLAVE_ICW4_DEFAULT, PIC_SLAVE_IMR);
24863
24864 + pax_open_kernel();
24865 if (auto_eoi)
24866 /*
24867 * In AEOI mode we just have to mask the interrupt
24868 * when acking.
24869 */
24870 - i8259A_chip.irq_mask_ack = disable_8259A_irq;
24871 + *(void **)&i8259A_chip.irq_mask_ack = disable_8259A_irq;
24872 else
24873 - i8259A_chip.irq_mask_ack = mask_and_ack_8259A;
24874 + *(void **)&i8259A_chip.irq_mask_ack = mask_and_ack_8259A;
24875 + pax_close_kernel();
24876
24877 udelay(100); /* wait for 8259A to initialize */
24878
24879 diff --git a/arch/x86/kernel/io_delay.c b/arch/x86/kernel/io_delay.c
24880 index a979b5b..1d6db75 100644
24881 --- a/arch/x86/kernel/io_delay.c
24882 +++ b/arch/x86/kernel/io_delay.c
24883 @@ -58,7 +58,7 @@ static int __init dmi_io_delay_0xed_port(const struct dmi_system_id *id)
24884 * Quirk table for systems that misbehave (lock up, etc.) if port
24885 * 0x80 is used:
24886 */
24887 -static struct dmi_system_id __initdata io_delay_0xed_port_dmi_table[] = {
24888 +static const struct dmi_system_id __initconst io_delay_0xed_port_dmi_table[] = {
24889 {
24890 .callback = dmi_io_delay_0xed_port,
24891 .ident = "Compaq Presario V6000",
24892 diff --git a/arch/x86/kernel/ioport.c b/arch/x86/kernel/ioport.c
24893 index 4ddaf66..49d5c18 100644
24894 --- a/arch/x86/kernel/ioport.c
24895 +++ b/arch/x86/kernel/ioport.c
24896 @@ -6,6 +6,7 @@
24897 #include <linux/sched.h>
24898 #include <linux/kernel.h>
24899 #include <linux/capability.h>
24900 +#include <linux/security.h>
24901 #include <linux/errno.h>
24902 #include <linux/types.h>
24903 #include <linux/ioport.h>
24904 @@ -30,6 +31,12 @@ asmlinkage long sys_ioperm(unsigned long from, unsigned long num, int turn_on)
24905 return -EINVAL;
24906 if (turn_on && !capable(CAP_SYS_RAWIO))
24907 return -EPERM;
24908 +#ifdef CONFIG_GRKERNSEC_IO
24909 + if (turn_on && grsec_disable_privio) {
24910 + gr_handle_ioperm();
24911 + return -ENODEV;
24912 + }
24913 +#endif
24914
24915 /*
24916 * If it's the first ioperm() call in this thread's lifetime, set the
24917 @@ -54,7 +61,7 @@ asmlinkage long sys_ioperm(unsigned long from, unsigned long num, int turn_on)
24918 * because the ->io_bitmap_max value must match the bitmap
24919 * contents:
24920 */
24921 - tss = &per_cpu(init_tss, get_cpu());
24922 + tss = init_tss + get_cpu();
24923
24924 if (turn_on)
24925 bitmap_clear(t->io_bitmap_ptr, from, num);
24926 @@ -105,6 +112,12 @@ SYSCALL_DEFINE1(iopl, unsigned int, level)
24927 if (level > old) {
24928 if (!capable(CAP_SYS_RAWIO))
24929 return -EPERM;
24930 +#ifdef CONFIG_GRKERNSEC_IO
24931 + if (grsec_disable_privio) {
24932 + gr_handle_iopl();
24933 + return -ENODEV;
24934 + }
24935 +#endif
24936 }
24937 regs->flags = (regs->flags & ~X86_EFLAGS_IOPL) | (level << 12);
24938 t->iopl = level << 12;
24939 diff --git a/arch/x86/kernel/irq.c b/arch/x86/kernel/irq.c
24940 index 11ccfb0..ec1e46f 100644
24941 --- a/arch/x86/kernel/irq.c
24942 +++ b/arch/x86/kernel/irq.c
24943 @@ -22,7 +22,7 @@
24944 #define CREATE_TRACE_POINTS
24945 #include <asm/trace/irq_vectors.h>
24946
24947 -atomic_t irq_err_count;
24948 +atomic_unchecked_t irq_err_count;
24949
24950 /* Function pointer for generic interrupt vector handling */
24951 void (*x86_platform_ipi_callback)(void) = NULL;
24952 @@ -132,9 +132,9 @@ int arch_show_interrupts(struct seq_file *p, int prec)
24953 seq_printf(p, "%10u ", irq_stats(j)->irq_hv_callback_count);
24954 seq_printf(p, " Hypervisor callback interrupts\n");
24955 #endif
24956 - seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read(&irq_err_count));
24957 + seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read_unchecked(&irq_err_count));
24958 #if defined(CONFIG_X86_IO_APIC)
24959 - seq_printf(p, "%*s: %10u\n", prec, "MIS", atomic_read(&irq_mis_count));
24960 + seq_printf(p, "%*s: %10u\n", prec, "MIS", atomic_read_unchecked(&irq_mis_count));
24961 #endif
24962 return 0;
24963 }
24964 @@ -174,7 +174,7 @@ u64 arch_irq_stat_cpu(unsigned int cpu)
24965
24966 u64 arch_irq_stat(void)
24967 {
24968 - u64 sum = atomic_read(&irq_err_count);
24969 + u64 sum = atomic_read_unchecked(&irq_err_count);
24970 return sum;
24971 }
24972
24973 diff --git a/arch/x86/kernel/irq_32.c b/arch/x86/kernel/irq_32.c
24974 index 63ce838..2ea3e06 100644
24975 --- a/arch/x86/kernel/irq_32.c
24976 +++ b/arch/x86/kernel/irq_32.c
24977 @@ -29,6 +29,8 @@ EXPORT_PER_CPU_SYMBOL(irq_regs);
24978
24979 #ifdef CONFIG_DEBUG_STACKOVERFLOW
24980
24981 +extern void gr_handle_kernel_exploit(void);
24982 +
24983 int sysctl_panic_on_stackoverflow __read_mostly;
24984
24985 /* Debugging check for stack overflow: is there less than 1KB free? */
24986 @@ -39,13 +41,14 @@ static int check_stack_overflow(void)
24987 __asm__ __volatile__("andl %%esp,%0" :
24988 "=r" (sp) : "0" (THREAD_SIZE - 1));
24989
24990 - return sp < (sizeof(struct thread_info) + STACK_WARN);
24991 + return sp < STACK_WARN;
24992 }
24993
24994 static void print_stack_overflow(void)
24995 {
24996 printk(KERN_WARNING "low stack detected by irq handler\n");
24997 dump_stack();
24998 + gr_handle_kernel_exploit();
24999 if (sysctl_panic_on_stackoverflow)
25000 panic("low stack detected by irq handler - check messages\n");
25001 }
25002 @@ -84,10 +87,9 @@ static inline void *current_stack(void)
25003 static inline int
25004 execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
25005 {
25006 - struct irq_stack *curstk, *irqstk;
25007 + struct irq_stack *irqstk;
25008 u32 *isp, *prev_esp, arg1, arg2;
25009
25010 - curstk = (struct irq_stack *) current_stack();
25011 irqstk = __this_cpu_read(hardirq_stack);
25012
25013 /*
25014 @@ -96,15 +98,19 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
25015 * handler) we can't do that and just have to keep using the
25016 * current stack (which is the irq stack already after all)
25017 */
25018 - if (unlikely(curstk == irqstk))
25019 + if (unlikely((void *)current_stack_pointer - (void *)irqstk < THREAD_SIZE))
25020 return 0;
25021
25022 - isp = (u32 *) ((char *)irqstk + sizeof(*irqstk));
25023 + isp = (u32 *) ((char *)irqstk + sizeof(*irqstk) - 8);
25024
25025 /* Save the next esp at the bottom of the stack */
25026 prev_esp = (u32 *)irqstk;
25027 *prev_esp = current_stack_pointer;
25028
25029 +#ifdef CONFIG_PAX_MEMORY_UDEREF
25030 + __set_fs(MAKE_MM_SEG(0));
25031 +#endif
25032 +
25033 if (unlikely(overflow))
25034 call_on_stack(print_stack_overflow, isp);
25035
25036 @@ -115,6 +121,11 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
25037 : "0" (irq), "1" (desc), "2" (isp),
25038 "D" (desc->handle_irq)
25039 : "memory", "cc", "ecx");
25040 +
25041 +#ifdef CONFIG_PAX_MEMORY_UDEREF
25042 + __set_fs(current_thread_info()->addr_limit);
25043 +#endif
25044 +
25045 return 1;
25046 }
25047
25048 @@ -123,32 +134,18 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
25049 */
25050 void irq_ctx_init(int cpu)
25051 {
25052 - struct irq_stack *irqstk;
25053 -
25054 if (per_cpu(hardirq_stack, cpu))
25055 return;
25056
25057 - irqstk = page_address(alloc_pages_node(cpu_to_node(cpu),
25058 - THREADINFO_GFP,
25059 - THREAD_SIZE_ORDER));
25060 - per_cpu(hardirq_stack, cpu) = irqstk;
25061 -
25062 - irqstk = page_address(alloc_pages_node(cpu_to_node(cpu),
25063 - THREADINFO_GFP,
25064 - THREAD_SIZE_ORDER));
25065 - per_cpu(softirq_stack, cpu) = irqstk;
25066 -
25067 - printk(KERN_DEBUG "CPU %u irqstacks, hard=%p soft=%p\n",
25068 - cpu, per_cpu(hardirq_stack, cpu), per_cpu(softirq_stack, cpu));
25069 + per_cpu(hardirq_stack, cpu) = page_address(alloc_pages_node(cpu_to_node(cpu), THREADINFO_GFP, THREAD_SIZE_ORDER));
25070 + per_cpu(softirq_stack, cpu) = page_address(alloc_pages_node(cpu_to_node(cpu), THREADINFO_GFP, THREAD_SIZE_ORDER));
25071 }
25072
25073 void do_softirq_own_stack(void)
25074 {
25075 - struct thread_info *curstk;
25076 struct irq_stack *irqstk;
25077 u32 *isp, *prev_esp;
25078
25079 - curstk = current_stack();
25080 irqstk = __this_cpu_read(softirq_stack);
25081
25082 /* build the stack frame on the softirq stack */
25083 @@ -158,7 +155,16 @@ void do_softirq_own_stack(void)
25084 prev_esp = (u32 *)irqstk;
25085 *prev_esp = current_stack_pointer;
25086
25087 +#ifdef CONFIG_PAX_MEMORY_UDEREF
25088 + __set_fs(MAKE_MM_SEG(0));
25089 +#endif
25090 +
25091 call_on_stack(__do_softirq, isp);
25092 +
25093 +#ifdef CONFIG_PAX_MEMORY_UDEREF
25094 + __set_fs(current_thread_info()->addr_limit);
25095 +#endif
25096 +
25097 }
25098
25099 bool handle_irq(unsigned irq, struct pt_regs *regs)
25100 @@ -172,7 +178,7 @@ bool handle_irq(unsigned irq, struct pt_regs *regs)
25101 if (unlikely(!desc))
25102 return false;
25103
25104 - if (user_mode_vm(regs) || !execute_on_irq_stack(overflow, desc, irq)) {
25105 + if (user_mode(regs) || !execute_on_irq_stack(overflow, desc, irq)) {
25106 if (unlikely(overflow))
25107 print_stack_overflow();
25108 desc->handle_irq(irq, desc);
25109 diff --git a/arch/x86/kernel/irq_64.c b/arch/x86/kernel/irq_64.c
25110 index 4d1c746..55a22d6 100644
25111 --- a/arch/x86/kernel/irq_64.c
25112 +++ b/arch/x86/kernel/irq_64.c
25113 @@ -26,6 +26,8 @@ EXPORT_PER_CPU_SYMBOL(irq_stat);
25114 DEFINE_PER_CPU(struct pt_regs *, irq_regs);
25115 EXPORT_PER_CPU_SYMBOL(irq_regs);
25116
25117 +extern void gr_handle_kernel_exploit(void);
25118 +
25119 int sysctl_panic_on_stackoverflow;
25120
25121 /*
25122 @@ -44,7 +46,7 @@ static inline void stack_overflow_check(struct pt_regs *regs)
25123 u64 estack_top, estack_bottom;
25124 u64 curbase = (u64)task_stack_page(current);
25125
25126 - if (user_mode_vm(regs))
25127 + if (user_mode(regs))
25128 return;
25129
25130 if (regs->sp >= curbase + sizeof(struct thread_info) +
25131 @@ -69,6 +71,8 @@ static inline void stack_overflow_check(struct pt_regs *regs)
25132 irq_stack_top, irq_stack_bottom,
25133 estack_top, estack_bottom);
25134
25135 + gr_handle_kernel_exploit();
25136 +
25137 if (sysctl_panic_on_stackoverflow)
25138 panic("low stack detected by irq handler - check messages\n");
25139 #endif
25140 diff --git a/arch/x86/kernel/jump_label.c b/arch/x86/kernel/jump_label.c
25141 index 26d5a55..a01160a 100644
25142 --- a/arch/x86/kernel/jump_label.c
25143 +++ b/arch/x86/kernel/jump_label.c
25144 @@ -51,7 +51,7 @@ static void __jump_label_transform(struct jump_entry *entry,
25145 * Jump label is enabled for the first time.
25146 * So we expect a default_nop...
25147 */
25148 - if (unlikely(memcmp((void *)entry->code, default_nop, 5)
25149 + if (unlikely(memcmp((void *)ktla_ktva(entry->code), default_nop, 5)
25150 != 0))
25151 bug_at((void *)entry->code, __LINE__);
25152 } else {
25153 @@ -59,7 +59,7 @@ static void __jump_label_transform(struct jump_entry *entry,
25154 * ...otherwise expect an ideal_nop. Otherwise
25155 * something went horribly wrong.
25156 */
25157 - if (unlikely(memcmp((void *)entry->code, ideal_nop, 5)
25158 + if (unlikely(memcmp((void *)ktla_ktva(entry->code), ideal_nop, 5)
25159 != 0))
25160 bug_at((void *)entry->code, __LINE__);
25161 }
25162 @@ -75,13 +75,13 @@ static void __jump_label_transform(struct jump_entry *entry,
25163 * are converting the default nop to the ideal nop.
25164 */
25165 if (init) {
25166 - if (unlikely(memcmp((void *)entry->code, default_nop, 5) != 0))
25167 + if (unlikely(memcmp((void *)ktla_ktva(entry->code), default_nop, 5) != 0))
25168 bug_at((void *)entry->code, __LINE__);
25169 } else {
25170 code.jump = 0xe9;
25171 code.offset = entry->target -
25172 (entry->code + JUMP_LABEL_NOP_SIZE);
25173 - if (unlikely(memcmp((void *)entry->code, &code, 5) != 0))
25174 + if (unlikely(memcmp((void *)ktla_ktva(entry->code), &code, 5) != 0))
25175 bug_at((void *)entry->code, __LINE__);
25176 }
25177 memcpy(&code, ideal_nops[NOP_ATOMIC5], JUMP_LABEL_NOP_SIZE);
25178 diff --git a/arch/x86/kernel/kgdb.c b/arch/x86/kernel/kgdb.c
25179 index 7ec1d5f..5a7d130 100644
25180 --- a/arch/x86/kernel/kgdb.c
25181 +++ b/arch/x86/kernel/kgdb.c
25182 @@ -126,11 +126,11 @@ char *dbg_get_reg(int regno, void *mem, struct pt_regs *regs)
25183 #ifdef CONFIG_X86_32
25184 switch (regno) {
25185 case GDB_SS:
25186 - if (!user_mode_vm(regs))
25187 + if (!user_mode(regs))
25188 *(unsigned long *)mem = __KERNEL_DS;
25189 break;
25190 case GDB_SP:
25191 - if (!user_mode_vm(regs))
25192 + if (!user_mode(regs))
25193 *(unsigned long *)mem = kernel_stack_pointer(regs);
25194 break;
25195 case GDB_GS:
25196 @@ -228,7 +228,10 @@ static void kgdb_correct_hw_break(void)
25197 bp->attr.bp_addr = breakinfo[breakno].addr;
25198 bp->attr.bp_len = breakinfo[breakno].len;
25199 bp->attr.bp_type = breakinfo[breakno].type;
25200 - info->address = breakinfo[breakno].addr;
25201 + if (breakinfo[breakno].type == X86_BREAKPOINT_EXECUTE)
25202 + info->address = ktla_ktva(breakinfo[breakno].addr);
25203 + else
25204 + info->address = breakinfo[breakno].addr;
25205 info->len = breakinfo[breakno].len;
25206 info->type = breakinfo[breakno].type;
25207 val = arch_install_hw_breakpoint(bp);
25208 @@ -475,12 +478,12 @@ int kgdb_arch_handle_exception(int e_vector, int signo, int err_code,
25209 case 'k':
25210 /* clear the trace bit */
25211 linux_regs->flags &= ~X86_EFLAGS_TF;
25212 - atomic_set(&kgdb_cpu_doing_single_step, -1);
25213 + atomic_set_unchecked(&kgdb_cpu_doing_single_step, -1);
25214
25215 /* set the trace bit if we're stepping */
25216 if (remcomInBuffer[0] == 's') {
25217 linux_regs->flags |= X86_EFLAGS_TF;
25218 - atomic_set(&kgdb_cpu_doing_single_step,
25219 + atomic_set_unchecked(&kgdb_cpu_doing_single_step,
25220 raw_smp_processor_id());
25221 }
25222
25223 @@ -545,7 +548,7 @@ static int __kgdb_notify(struct die_args *args, unsigned long cmd)
25224
25225 switch (cmd) {
25226 case DIE_DEBUG:
25227 - if (atomic_read(&kgdb_cpu_doing_single_step) != -1) {
25228 + if (atomic_read_unchecked(&kgdb_cpu_doing_single_step) != -1) {
25229 if (user_mode(regs))
25230 return single_step_cont(regs, args);
25231 break;
25232 @@ -750,11 +753,11 @@ int kgdb_arch_set_breakpoint(struct kgdb_bkpt *bpt)
25233 #endif /* CONFIG_DEBUG_RODATA */
25234
25235 bpt->type = BP_BREAKPOINT;
25236 - err = probe_kernel_read(bpt->saved_instr, (char *)bpt->bpt_addr,
25237 + err = probe_kernel_read(bpt->saved_instr, ktla_ktva((char *)bpt->bpt_addr),
25238 BREAK_INSTR_SIZE);
25239 if (err)
25240 return err;
25241 - err = probe_kernel_write((char *)bpt->bpt_addr,
25242 + err = probe_kernel_write(ktla_ktva((char *)bpt->bpt_addr),
25243 arch_kgdb_ops.gdb_bpt_instr, BREAK_INSTR_SIZE);
25244 #ifdef CONFIG_DEBUG_RODATA
25245 if (!err)
25246 @@ -767,7 +770,7 @@ int kgdb_arch_set_breakpoint(struct kgdb_bkpt *bpt)
25247 return -EBUSY;
25248 text_poke((void *)bpt->bpt_addr, arch_kgdb_ops.gdb_bpt_instr,
25249 BREAK_INSTR_SIZE);
25250 - err = probe_kernel_read(opc, (char *)bpt->bpt_addr, BREAK_INSTR_SIZE);
25251 + err = probe_kernel_read(opc, ktla_ktva((char *)bpt->bpt_addr), BREAK_INSTR_SIZE);
25252 if (err)
25253 return err;
25254 if (memcmp(opc, arch_kgdb_ops.gdb_bpt_instr, BREAK_INSTR_SIZE))
25255 @@ -792,13 +795,13 @@ int kgdb_arch_remove_breakpoint(struct kgdb_bkpt *bpt)
25256 if (mutex_is_locked(&text_mutex))
25257 goto knl_write;
25258 text_poke((void *)bpt->bpt_addr, bpt->saved_instr, BREAK_INSTR_SIZE);
25259 - err = probe_kernel_read(opc, (char *)bpt->bpt_addr, BREAK_INSTR_SIZE);
25260 + err = probe_kernel_read(opc, ktla_ktva((char *)bpt->bpt_addr), BREAK_INSTR_SIZE);
25261 if (err || memcmp(opc, bpt->saved_instr, BREAK_INSTR_SIZE))
25262 goto knl_write;
25263 return err;
25264 knl_write:
25265 #endif /* CONFIG_DEBUG_RODATA */
25266 - return probe_kernel_write((char *)bpt->bpt_addr,
25267 + return probe_kernel_write(ktla_ktva((char *)bpt->bpt_addr),
25268 (char *)bpt->saved_instr, BREAK_INSTR_SIZE);
25269 }
25270
25271 diff --git a/arch/x86/kernel/kprobes/core.c b/arch/x86/kernel/kprobes/core.c
25272 index 61b17dc..784bfe9 100644
25273 --- a/arch/x86/kernel/kprobes/core.c
25274 +++ b/arch/x86/kernel/kprobes/core.c
25275 @@ -119,9 +119,12 @@ static void __kprobes __synthesize_relative_insn(void *from, void *to, u8 op)
25276 s32 raddr;
25277 } __packed *insn;
25278
25279 - insn = (struct __arch_relative_insn *)from;
25280 + insn = (struct __arch_relative_insn *)ktla_ktva(from);
25281 +
25282 + pax_open_kernel();
25283 insn->raddr = (s32)((long)(to) - ((long)(from) + 5));
25284 insn->op = op;
25285 + pax_close_kernel();
25286 }
25287
25288 /* Insert a jump instruction at address 'from', which jumps to address 'to'.*/
25289 @@ -164,7 +167,7 @@ int __kprobes can_boost(kprobe_opcode_t *opcodes)
25290 kprobe_opcode_t opcode;
25291 kprobe_opcode_t *orig_opcodes = opcodes;
25292
25293 - if (search_exception_tables((unsigned long)opcodes))
25294 + if (search_exception_tables(ktva_ktla((unsigned long)opcodes)))
25295 return 0; /* Page fault may occur on this address. */
25296
25297 retry:
25298 @@ -238,9 +241,9 @@ __recover_probed_insn(kprobe_opcode_t *buf, unsigned long addr)
25299 * for the first byte, we can recover the original instruction
25300 * from it and kp->opcode.
25301 */
25302 - memcpy(buf, kp->addr, MAX_INSN_SIZE * sizeof(kprobe_opcode_t));
25303 + memcpy(buf, ktla_ktva(kp->addr), MAX_INSN_SIZE * sizeof(kprobe_opcode_t));
25304 buf[0] = kp->opcode;
25305 - return (unsigned long)buf;
25306 + return ktva_ktla((unsigned long)buf);
25307 }
25308
25309 /*
25310 @@ -332,7 +335,9 @@ int __kprobes __copy_instruction(u8 *dest, u8 *src)
25311 /* Another subsystem puts a breakpoint, failed to recover */
25312 if (insn.opcode.bytes[0] == BREAKPOINT_INSTRUCTION)
25313 return 0;
25314 + pax_open_kernel();
25315 memcpy(dest, insn.kaddr, insn.length);
25316 + pax_close_kernel();
25317
25318 #ifdef CONFIG_X86_64
25319 if (insn_rip_relative(&insn)) {
25320 @@ -359,7 +364,9 @@ int __kprobes __copy_instruction(u8 *dest, u8 *src)
25321 return 0;
25322 }
25323 disp = (u8 *) dest + insn_offset_displacement(&insn);
25324 + pax_open_kernel();
25325 *(s32 *) disp = (s32) newdisp;
25326 + pax_close_kernel();
25327 }
25328 #endif
25329 return insn.length;
25330 @@ -498,7 +505,7 @@ setup_singlestep(struct kprobe *p, struct pt_regs *regs, struct kprobe_ctlblk *k
25331 * nor set current_kprobe, because it doesn't use single
25332 * stepping.
25333 */
25334 - regs->ip = (unsigned long)p->ainsn.insn;
25335 + regs->ip = ktva_ktla((unsigned long)p->ainsn.insn);
25336 preempt_enable_no_resched();
25337 return;
25338 }
25339 @@ -515,9 +522,9 @@ setup_singlestep(struct kprobe *p, struct pt_regs *regs, struct kprobe_ctlblk *k
25340 regs->flags &= ~X86_EFLAGS_IF;
25341 /* single step inline if the instruction is an int3 */
25342 if (p->opcode == BREAKPOINT_INSTRUCTION)
25343 - regs->ip = (unsigned long)p->addr;
25344 + regs->ip = ktla_ktva((unsigned long)p->addr);
25345 else
25346 - regs->ip = (unsigned long)p->ainsn.insn;
25347 + regs->ip = ktva_ktla((unsigned long)p->ainsn.insn);
25348 }
25349
25350 /*
25351 @@ -596,7 +603,7 @@ static int __kprobes kprobe_handler(struct pt_regs *regs)
25352 setup_singlestep(p, regs, kcb, 0);
25353 return 1;
25354 }
25355 - } else if (*addr != BREAKPOINT_INSTRUCTION) {
25356 + } else if (*(kprobe_opcode_t *)ktla_ktva((unsigned long)addr) != BREAKPOINT_INSTRUCTION) {
25357 /*
25358 * The breakpoint instruction was removed right
25359 * after we hit it. Another cpu has removed
25360 @@ -642,6 +649,9 @@ static void __used __kprobes kretprobe_trampoline_holder(void)
25361 " movq %rax, 152(%rsp)\n"
25362 RESTORE_REGS_STRING
25363 " popfq\n"
25364 +#ifdef KERNEXEC_PLUGIN
25365 + " btsq $63,(%rsp)\n"
25366 +#endif
25367 #else
25368 " pushf\n"
25369 SAVE_REGS_STRING
25370 @@ -779,7 +789,7 @@ static void __kprobes
25371 resume_execution(struct kprobe *p, struct pt_regs *regs, struct kprobe_ctlblk *kcb)
25372 {
25373 unsigned long *tos = stack_addr(regs);
25374 - unsigned long copy_ip = (unsigned long)p->ainsn.insn;
25375 + unsigned long copy_ip = ktva_ktla((unsigned long)p->ainsn.insn);
25376 unsigned long orig_ip = (unsigned long)p->addr;
25377 kprobe_opcode_t *insn = p->ainsn.insn;
25378
25379 @@ -959,7 +969,7 @@ kprobe_exceptions_notify(struct notifier_block *self, unsigned long val, void *d
25380 struct die_args *args = data;
25381 int ret = NOTIFY_DONE;
25382
25383 - if (args->regs && user_mode_vm(args->regs))
25384 + if (args->regs && user_mode(args->regs))
25385 return ret;
25386
25387 switch (val) {
25388 diff --git a/arch/x86/kernel/kprobes/opt.c b/arch/x86/kernel/kprobes/opt.c
25389 index 898160b..758cde8 100644
25390 --- a/arch/x86/kernel/kprobes/opt.c
25391 +++ b/arch/x86/kernel/kprobes/opt.c
25392 @@ -79,6 +79,7 @@ found:
25393 /* Insert a move instruction which sets a pointer to eax/rdi (1st arg). */
25394 static void __kprobes synthesize_set_arg1(kprobe_opcode_t *addr, unsigned long val)
25395 {
25396 + pax_open_kernel();
25397 #ifdef CONFIG_X86_64
25398 *addr++ = 0x48;
25399 *addr++ = 0xbf;
25400 @@ -86,6 +87,7 @@ static void __kprobes synthesize_set_arg1(kprobe_opcode_t *addr, unsigned long v
25401 *addr++ = 0xb8;
25402 #endif
25403 *(unsigned long *)addr = val;
25404 + pax_close_kernel();
25405 }
25406
25407 asm (
25408 @@ -335,7 +337,7 @@ int __kprobes arch_prepare_optimized_kprobe(struct optimized_kprobe *op)
25409 * Verify if the address gap is in 2GB range, because this uses
25410 * a relative jump.
25411 */
25412 - rel = (long)op->optinsn.insn - (long)op->kp.addr + RELATIVEJUMP_SIZE;
25413 + rel = (long)op->optinsn.insn - ktla_ktva((long)op->kp.addr) + RELATIVEJUMP_SIZE;
25414 if (abs(rel) > 0x7fffffff)
25415 return -ERANGE;
25416
25417 @@ -350,16 +352,18 @@ int __kprobes arch_prepare_optimized_kprobe(struct optimized_kprobe *op)
25418 op->optinsn.size = ret;
25419
25420 /* Copy arch-dep-instance from template */
25421 - memcpy(buf, &optprobe_template_entry, TMPL_END_IDX);
25422 + pax_open_kernel();
25423 + memcpy(buf, ktla_ktva(&optprobe_template_entry), TMPL_END_IDX);
25424 + pax_close_kernel();
25425
25426 /* Set probe information */
25427 synthesize_set_arg1(buf + TMPL_MOVE_IDX, (unsigned long)op);
25428
25429 /* Set probe function call */
25430 - synthesize_relcall(buf + TMPL_CALL_IDX, optimized_callback);
25431 + synthesize_relcall(ktva_ktla(buf) + TMPL_CALL_IDX, optimized_callback);
25432
25433 /* Set returning jmp instruction at the tail of out-of-line buffer */
25434 - synthesize_reljump(buf + TMPL_END_IDX + op->optinsn.size,
25435 + synthesize_reljump(ktva_ktla(buf) + TMPL_END_IDX + op->optinsn.size,
25436 (u8 *)op->kp.addr + op->optinsn.size);
25437
25438 flush_icache_range((unsigned long) buf,
25439 @@ -384,7 +388,7 @@ void __kprobes arch_optimize_kprobes(struct list_head *oplist)
25440 WARN_ON(kprobe_disabled(&op->kp));
25441
25442 /* Backup instructions which will be replaced by jump address */
25443 - memcpy(op->optinsn.copied_insn, op->kp.addr + INT3_SIZE,
25444 + memcpy(op->optinsn.copied_insn, ktla_ktva(op->kp.addr) + INT3_SIZE,
25445 RELATIVE_ADDR_SIZE);
25446
25447 insn_buf[0] = RELATIVEJUMP_OPCODE;
25448 @@ -433,7 +437,7 @@ setup_detour_execution(struct kprobe *p, struct pt_regs *regs, int reenter)
25449 /* This kprobe is really able to run optimized path. */
25450 op = container_of(p, struct optimized_kprobe, kp);
25451 /* Detour through copied instructions */
25452 - regs->ip = (unsigned long)op->optinsn.insn + TMPL_END_IDX;
25453 + regs->ip = ktva_ktla((unsigned long)op->optinsn.insn) + TMPL_END_IDX;
25454 if (!reenter)
25455 reset_current_kprobe();
25456 preempt_enable_no_resched();
25457 diff --git a/arch/x86/kernel/ksysfs.c b/arch/x86/kernel/ksysfs.c
25458 index c2bedae..25e7ab6 100644
25459 --- a/arch/x86/kernel/ksysfs.c
25460 +++ b/arch/x86/kernel/ksysfs.c
25461 @@ -184,7 +184,7 @@ out:
25462
25463 static struct kobj_attribute type_attr = __ATTR_RO(type);
25464
25465 -static struct bin_attribute data_attr = {
25466 +static bin_attribute_no_const data_attr __read_only = {
25467 .attr = {
25468 .name = "data",
25469 .mode = S_IRUGO,
25470 diff --git a/arch/x86/kernel/ldt.c b/arch/x86/kernel/ldt.c
25471 index dcbbaa1..81ae763 100644
25472 --- a/arch/x86/kernel/ldt.c
25473 +++ b/arch/x86/kernel/ldt.c
25474 @@ -68,13 +68,13 @@ static int alloc_ldt(mm_context_t *pc, int mincount, int reload)
25475 if (reload) {
25476 #ifdef CONFIG_SMP
25477 preempt_disable();
25478 - load_LDT(pc);
25479 + load_LDT_nolock(pc);
25480 if (!cpumask_equal(mm_cpumask(current->mm),
25481 cpumask_of(smp_processor_id())))
25482 smp_call_function(flush_ldt, current->mm, 1);
25483 preempt_enable();
25484 #else
25485 - load_LDT(pc);
25486 + load_LDT_nolock(pc);
25487 #endif
25488 }
25489 if (oldsize) {
25490 @@ -96,7 +96,7 @@ static inline int copy_ldt(mm_context_t *new, mm_context_t *old)
25491 return err;
25492
25493 for (i = 0; i < old->size; i++)
25494 - write_ldt_entry(new->ldt, i, old->ldt + i * LDT_ENTRY_SIZE);
25495 + write_ldt_entry(new->ldt, i, old->ldt + i);
25496 return 0;
25497 }
25498
25499 @@ -117,6 +117,24 @@ int init_new_context(struct task_struct *tsk, struct mm_struct *mm)
25500 retval = copy_ldt(&mm->context, &old_mm->context);
25501 mutex_unlock(&old_mm->context.lock);
25502 }
25503 +
25504 + if (tsk == current) {
25505 + mm->context.vdso = 0;
25506 +
25507 +#ifdef CONFIG_X86_32
25508 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
25509 + mm->context.user_cs_base = 0UL;
25510 + mm->context.user_cs_limit = ~0UL;
25511 +
25512 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_SMP)
25513 + cpus_clear(mm->context.cpu_user_cs_mask);
25514 +#endif
25515 +
25516 +#endif
25517 +#endif
25518 +
25519 + }
25520 +
25521 return retval;
25522 }
25523
25524 @@ -231,6 +249,13 @@ static int write_ldt(void __user *ptr, unsigned long bytecount, int oldmode)
25525 }
25526 }
25527
25528 +#ifdef CONFIG_PAX_SEGMEXEC
25529 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (ldt_info.contents & MODIFY_LDT_CONTENTS_CODE)) {
25530 + error = -EINVAL;
25531 + goto out_unlock;
25532 + }
25533 +#endif
25534 +
25535 /*
25536 * On x86-64 we do not support 16-bit segments due to
25537 * IRET leaking the high bits of the kernel stack address.
25538 diff --git a/arch/x86/kernel/machine_kexec_32.c b/arch/x86/kernel/machine_kexec_32.c
25539 index 1667b1d..16492c5 100644
25540 --- a/arch/x86/kernel/machine_kexec_32.c
25541 +++ b/arch/x86/kernel/machine_kexec_32.c
25542 @@ -25,7 +25,7 @@
25543 #include <asm/cacheflush.h>
25544 #include <asm/debugreg.h>
25545
25546 -static void set_idt(void *newidt, __u16 limit)
25547 +static void set_idt(struct desc_struct *newidt, __u16 limit)
25548 {
25549 struct desc_ptr curidt;
25550
25551 @@ -37,7 +37,7 @@ static void set_idt(void *newidt, __u16 limit)
25552 }
25553
25554
25555 -static void set_gdt(void *newgdt, __u16 limit)
25556 +static void set_gdt(struct desc_struct *newgdt, __u16 limit)
25557 {
25558 struct desc_ptr curgdt;
25559
25560 @@ -215,7 +215,7 @@ void machine_kexec(struct kimage *image)
25561 }
25562
25563 control_page = page_address(image->control_code_page);
25564 - memcpy(control_page, relocate_kernel, KEXEC_CONTROL_CODE_MAX_SIZE);
25565 + memcpy(control_page, (void *)ktla_ktva((unsigned long)relocate_kernel), KEXEC_CONTROL_CODE_MAX_SIZE);
25566
25567 relocate_kernel_ptr = control_page;
25568 page_list[PA_CONTROL_PAGE] = __pa(control_page);
25569 diff --git a/arch/x86/kernel/module.c b/arch/x86/kernel/module.c
25570 index e69f988..da078ea 100644
25571 --- a/arch/x86/kernel/module.c
25572 +++ b/arch/x86/kernel/module.c
25573 @@ -81,17 +81,62 @@ static unsigned long int get_module_load_offset(void)
25574 }
25575 #endif
25576
25577 -void *module_alloc(unsigned long size)
25578 +static inline void *__module_alloc(unsigned long size, pgprot_t prot)
25579 {
25580 - if (PAGE_ALIGN(size) > MODULES_LEN)
25581 + if (!size || PAGE_ALIGN(size) > MODULES_LEN)
25582 return NULL;
25583 return __vmalloc_node_range(size, 1,
25584 MODULES_VADDR + get_module_load_offset(),
25585 - MODULES_END, GFP_KERNEL | __GFP_HIGHMEM,
25586 - PAGE_KERNEL_EXEC, NUMA_NO_NODE,
25587 + MODULES_END, GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO,
25588 + prot, NUMA_NO_NODE,
25589 __builtin_return_address(0));
25590 }
25591
25592 +void *module_alloc(unsigned long size)
25593 +{
25594 +
25595 +#ifdef CONFIG_PAX_KERNEXEC
25596 + return __module_alloc(size, PAGE_KERNEL);
25597 +#else
25598 + return __module_alloc(size, PAGE_KERNEL_EXEC);
25599 +#endif
25600 +
25601 +}
25602 +
25603 +#ifdef CONFIG_PAX_KERNEXEC
25604 +#ifdef CONFIG_X86_32
25605 +void *module_alloc_exec(unsigned long size)
25606 +{
25607 + struct vm_struct *area;
25608 +
25609 + if (size == 0)
25610 + return NULL;
25611 +
25612 + area = __get_vm_area(size, VM_ALLOC, (unsigned long)&MODULES_EXEC_VADDR, (unsigned long)&MODULES_EXEC_END);
25613 +return area ? area->addr : NULL;
25614 +}
25615 +EXPORT_SYMBOL(module_alloc_exec);
25616 +
25617 +void module_free_exec(struct module *mod, void *module_region)
25618 +{
25619 + vunmap(module_region);
25620 +}
25621 +EXPORT_SYMBOL(module_free_exec);
25622 +#else
25623 +void module_free_exec(struct module *mod, void *module_region)
25624 +{
25625 + module_free(mod, module_region);
25626 +}
25627 +EXPORT_SYMBOL(module_free_exec);
25628 +
25629 +void *module_alloc_exec(unsigned long size)
25630 +{
25631 + return __module_alloc(size, PAGE_KERNEL_RX);
25632 +}
25633 +EXPORT_SYMBOL(module_alloc_exec);
25634 +#endif
25635 +#endif
25636 +
25637 #ifdef CONFIG_X86_32
25638 int apply_relocate(Elf32_Shdr *sechdrs,
25639 const char *strtab,
25640 @@ -102,14 +147,16 @@ int apply_relocate(Elf32_Shdr *sechdrs,
25641 unsigned int i;
25642 Elf32_Rel *rel = (void *)sechdrs[relsec].sh_addr;
25643 Elf32_Sym *sym;
25644 - uint32_t *location;
25645 + uint32_t *plocation, location;
25646
25647 DEBUGP("Applying relocate section %u to %u\n",
25648 relsec, sechdrs[relsec].sh_info);
25649 for (i = 0; i < sechdrs[relsec].sh_size / sizeof(*rel); i++) {
25650 /* This is where to make the change */
25651 - location = (void *)sechdrs[sechdrs[relsec].sh_info].sh_addr
25652 - + rel[i].r_offset;
25653 + plocation = (void *)sechdrs[sechdrs[relsec].sh_info].sh_addr + rel[i].r_offset;
25654 + location = (uint32_t)plocation;
25655 + if (sechdrs[sechdrs[relsec].sh_info].sh_flags & SHF_EXECINSTR)
25656 + plocation = ktla_ktva((void *)plocation);
25657 /* This is the symbol it is referring to. Note that all
25658 undefined symbols have been resolved. */
25659 sym = (Elf32_Sym *)sechdrs[symindex].sh_addr
25660 @@ -118,11 +165,15 @@ int apply_relocate(Elf32_Shdr *sechdrs,
25661 switch (ELF32_R_TYPE(rel[i].r_info)) {
25662 case R_386_32:
25663 /* We add the value into the location given */
25664 - *location += sym->st_value;
25665 + pax_open_kernel();
25666 + *plocation += sym->st_value;
25667 + pax_close_kernel();
25668 break;
25669 case R_386_PC32:
25670 /* Add the value, subtract its position */
25671 - *location += sym->st_value - (uint32_t)location;
25672 + pax_open_kernel();
25673 + *plocation += sym->st_value - location;
25674 + pax_close_kernel();
25675 break;
25676 default:
25677 pr_err("%s: Unknown relocation: %u\n",
25678 @@ -167,21 +218,30 @@ int apply_relocate_add(Elf64_Shdr *sechdrs,
25679 case R_X86_64_NONE:
25680 break;
25681 case R_X86_64_64:
25682 + pax_open_kernel();
25683 *(u64 *)loc = val;
25684 + pax_close_kernel();
25685 break;
25686 case R_X86_64_32:
25687 + pax_open_kernel();
25688 *(u32 *)loc = val;
25689 + pax_close_kernel();
25690 if (val != *(u32 *)loc)
25691 goto overflow;
25692 break;
25693 case R_X86_64_32S:
25694 + pax_open_kernel();
25695 *(s32 *)loc = val;
25696 + pax_close_kernel();
25697 if ((s64)val != *(s32 *)loc)
25698 goto overflow;
25699 break;
25700 case R_X86_64_PC32:
25701 val -= (u64)loc;
25702 + pax_open_kernel();
25703 *(u32 *)loc = val;
25704 + pax_close_kernel();
25705 +
25706 #if 0
25707 if ((s64)val != *(s32 *)loc)
25708 goto overflow;
25709 diff --git a/arch/x86/kernel/msr.c b/arch/x86/kernel/msr.c
25710 index c9603ac..9f88728 100644
25711 --- a/arch/x86/kernel/msr.c
25712 +++ b/arch/x86/kernel/msr.c
25713 @@ -37,6 +37,7 @@
25714 #include <linux/notifier.h>
25715 #include <linux/uaccess.h>
25716 #include <linux/gfp.h>
25717 +#include <linux/grsecurity.h>
25718
25719 #include <asm/processor.h>
25720 #include <asm/msr.h>
25721 @@ -103,6 +104,11 @@ static ssize_t msr_write(struct file *file, const char __user *buf,
25722 int err = 0;
25723 ssize_t bytes = 0;
25724
25725 +#ifdef CONFIG_GRKERNSEC_KMEM
25726 + gr_handle_msr_write();
25727 + return -EPERM;
25728 +#endif
25729 +
25730 if (count % 8)
25731 return -EINVAL; /* Invalid chunk size */
25732
25733 @@ -150,6 +156,10 @@ static long msr_ioctl(struct file *file, unsigned int ioc, unsigned long arg)
25734 err = -EBADF;
25735 break;
25736 }
25737 +#ifdef CONFIG_GRKERNSEC_KMEM
25738 + gr_handle_msr_write();
25739 + return -EPERM;
25740 +#endif
25741 if (copy_from_user(&regs, uregs, sizeof regs)) {
25742 err = -EFAULT;
25743 break;
25744 @@ -233,7 +243,7 @@ static int msr_class_cpu_callback(struct notifier_block *nfb,
25745 return notifier_from_errno(err);
25746 }
25747
25748 -static struct notifier_block __refdata msr_class_cpu_notifier = {
25749 +static struct notifier_block msr_class_cpu_notifier = {
25750 .notifier_call = msr_class_cpu_callback,
25751 };
25752
25753 diff --git a/arch/x86/kernel/nmi.c b/arch/x86/kernel/nmi.c
25754 index b4872b9..5bf0684 100644
25755 --- a/arch/x86/kernel/nmi.c
25756 +++ b/arch/x86/kernel/nmi.c
25757 @@ -98,16 +98,16 @@ fs_initcall(nmi_warning_debugfs);
25758
25759 static void nmi_max_handler(struct irq_work *w)
25760 {
25761 - struct nmiaction *a = container_of(w, struct nmiaction, irq_work);
25762 + struct nmiwork *n = container_of(w, struct nmiwork, irq_work);
25763 int remainder_ns, decimal_msecs;
25764 - u64 whole_msecs = ACCESS_ONCE(a->max_duration);
25765 + u64 whole_msecs = ACCESS_ONCE(n->max_duration);
25766
25767 remainder_ns = do_div(whole_msecs, (1000 * 1000));
25768 decimal_msecs = remainder_ns / 1000;
25769
25770 printk_ratelimited(KERN_INFO
25771 "INFO: NMI handler (%ps) took too long to run: %lld.%03d msecs\n",
25772 - a->handler, whole_msecs, decimal_msecs);
25773 + n->action->handler, whole_msecs, decimal_msecs);
25774 }
25775
25776 static int __kprobes nmi_handle(unsigned int type, struct pt_regs *regs, bool b2b)
25777 @@ -134,11 +134,11 @@ static int __kprobes nmi_handle(unsigned int type, struct pt_regs *regs, bool b2
25778 delta = sched_clock() - delta;
25779 trace_nmi_handler(a->handler, (int)delta, thishandled);
25780
25781 - if (delta < nmi_longest_ns || delta < a->max_duration)
25782 + if (delta < nmi_longest_ns || delta < a->work->max_duration)
25783 continue;
25784
25785 - a->max_duration = delta;
25786 - irq_work_queue(&a->irq_work);
25787 + a->work->max_duration = delta;
25788 + irq_work_queue(&a->work->irq_work);
25789 }
25790
25791 rcu_read_unlock();
25792 @@ -147,7 +147,7 @@ static int __kprobes nmi_handle(unsigned int type, struct pt_regs *regs, bool b2
25793 return handled;
25794 }
25795
25796 -int __register_nmi_handler(unsigned int type, struct nmiaction *action)
25797 +int __register_nmi_handler(unsigned int type, const struct nmiaction *action)
25798 {
25799 struct nmi_desc *desc = nmi_to_desc(type);
25800 unsigned long flags;
25801 @@ -155,7 +155,8 @@ int __register_nmi_handler(unsigned int type, struct nmiaction *action)
25802 if (!action->handler)
25803 return -EINVAL;
25804
25805 - init_irq_work(&action->irq_work, nmi_max_handler);
25806 + action->work->action = action;
25807 + init_irq_work(&action->work->irq_work, nmi_max_handler);
25808
25809 spin_lock_irqsave(&desc->lock, flags);
25810
25811 @@ -173,9 +174,9 @@ int __register_nmi_handler(unsigned int type, struct nmiaction *action)
25812 * event confuses some handlers (kdump uses this flag)
25813 */
25814 if (action->flags & NMI_FLAG_FIRST)
25815 - list_add_rcu(&action->list, &desc->head);
25816 + pax_list_add_rcu((struct list_head *)&action->list, &desc->head);
25817 else
25818 - list_add_tail_rcu(&action->list, &desc->head);
25819 + pax_list_add_tail_rcu((struct list_head *)&action->list, &desc->head);
25820
25821 spin_unlock_irqrestore(&desc->lock, flags);
25822 return 0;
25823 @@ -198,7 +199,7 @@ void unregister_nmi_handler(unsigned int type, const char *name)
25824 if (!strcmp(n->name, name)) {
25825 WARN(in_nmi(),
25826 "Trying to free NMI (%s) from NMI context!\n", n->name);
25827 - list_del_rcu(&n->list);
25828 + pax_list_del_rcu((struct list_head *)&n->list);
25829 break;
25830 }
25831 }
25832 @@ -523,6 +524,17 @@ static inline void nmi_nesting_postprocess(void)
25833 dotraplinkage notrace __kprobes void
25834 do_nmi(struct pt_regs *regs, long error_code)
25835 {
25836 +
25837 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
25838 + if (!user_mode(regs)) {
25839 + unsigned long cs = regs->cs & 0xFFFF;
25840 + unsigned long ip = ktva_ktla(regs->ip);
25841 +
25842 + if ((cs == __KERNEL_CS || cs == __KERNEXEC_KERNEL_CS) && ip <= (unsigned long)_etext)
25843 + regs->ip = ip;
25844 + }
25845 +#endif
25846 +
25847 nmi_nesting_preprocess(regs);
25848
25849 nmi_enter();
25850 diff --git a/arch/x86/kernel/nmi_selftest.c b/arch/x86/kernel/nmi_selftest.c
25851 index 6d9582e..f746287 100644
25852 --- a/arch/x86/kernel/nmi_selftest.c
25853 +++ b/arch/x86/kernel/nmi_selftest.c
25854 @@ -43,7 +43,7 @@ static void __init init_nmi_testsuite(void)
25855 {
25856 /* trap all the unknown NMIs we may generate */
25857 register_nmi_handler(NMI_UNKNOWN, nmi_unk_cb, 0, "nmi_selftest_unk",
25858 - __initdata);
25859 + __initconst);
25860 }
25861
25862 static void __init cleanup_nmi_testsuite(void)
25863 @@ -66,7 +66,7 @@ static void __init test_nmi_ipi(struct cpumask *mask)
25864 unsigned long timeout;
25865
25866 if (register_nmi_handler(NMI_LOCAL, test_nmi_ipi_callback,
25867 - NMI_FLAG_FIRST, "nmi_selftest", __initdata)) {
25868 + NMI_FLAG_FIRST, "nmi_selftest", __initconst)) {
25869 nmi_fail = FAILURE;
25870 return;
25871 }
25872 diff --git a/arch/x86/kernel/paravirt-spinlocks.c b/arch/x86/kernel/paravirt-spinlocks.c
25873 index bbb6c73..24a58ef 100644
25874 --- a/arch/x86/kernel/paravirt-spinlocks.c
25875 +++ b/arch/x86/kernel/paravirt-spinlocks.c
25876 @@ -8,7 +8,7 @@
25877
25878 #include <asm/paravirt.h>
25879
25880 -struct pv_lock_ops pv_lock_ops = {
25881 +struct pv_lock_ops pv_lock_ops __read_only = {
25882 #ifdef CONFIG_SMP
25883 .lock_spinning = __PV_IS_CALLEE_SAVE(paravirt_nop),
25884 .unlock_kick = paravirt_nop,
25885 diff --git a/arch/x86/kernel/paravirt.c b/arch/x86/kernel/paravirt.c
25886 index 1b10af8..45bfbec 100644
25887 --- a/arch/x86/kernel/paravirt.c
25888 +++ b/arch/x86/kernel/paravirt.c
25889 @@ -55,6 +55,9 @@ u64 _paravirt_ident_64(u64 x)
25890 {
25891 return x;
25892 }
25893 +#if defined(CONFIG_X86_32) && defined(CONFIG_X86_PAE)
25894 +PV_CALLEE_SAVE_REGS_THUNK(_paravirt_ident_64);
25895 +#endif
25896
25897 void __init default_banner(void)
25898 {
25899 @@ -141,16 +144,20 @@ unsigned paravirt_patch_default(u8 type, u16 clobbers, void *insnbuf,
25900
25901 if (opfunc == NULL)
25902 /* If there's no function, patch it with a ud2a (BUG) */
25903 - ret = paravirt_patch_insns(insnbuf, len, ud2a, ud2a+sizeof(ud2a));
25904 - else if (opfunc == _paravirt_nop)
25905 + ret = paravirt_patch_insns(insnbuf, len, ktva_ktla(ud2a), ud2a+sizeof(ud2a));
25906 + else if (opfunc == (void *)_paravirt_nop)
25907 /* If the operation is a nop, then nop the callsite */
25908 ret = paravirt_patch_nop();
25909
25910 /* identity functions just return their single argument */
25911 - else if (opfunc == _paravirt_ident_32)
25912 + else if (opfunc == (void *)_paravirt_ident_32)
25913 ret = paravirt_patch_ident_32(insnbuf, len);
25914 - else if (opfunc == _paravirt_ident_64)
25915 + else if (opfunc == (void *)_paravirt_ident_64)
25916 ret = paravirt_patch_ident_64(insnbuf, len);
25917 +#if defined(CONFIG_X86_32) && defined(CONFIG_X86_PAE)
25918 + else if (opfunc == (void *)__raw_callee_save__paravirt_ident_64)
25919 + ret = paravirt_patch_ident_64(insnbuf, len);
25920 +#endif
25921
25922 else if (type == PARAVIRT_PATCH(pv_cpu_ops.iret) ||
25923 type == PARAVIRT_PATCH(pv_cpu_ops.irq_enable_sysexit) ||
25924 @@ -175,7 +182,7 @@ unsigned paravirt_patch_insns(void *insnbuf, unsigned len,
25925 if (insn_len > len || start == NULL)
25926 insn_len = len;
25927 else
25928 - memcpy(insnbuf, start, insn_len);
25929 + memcpy(insnbuf, ktla_ktva(start), insn_len);
25930
25931 return insn_len;
25932 }
25933 @@ -299,7 +306,7 @@ enum paravirt_lazy_mode paravirt_get_lazy_mode(void)
25934 return this_cpu_read(paravirt_lazy_mode);
25935 }
25936
25937 -struct pv_info pv_info = {
25938 +struct pv_info pv_info __read_only = {
25939 .name = "bare hardware",
25940 .paravirt_enabled = 0,
25941 .kernel_rpl = 0,
25942 @@ -310,16 +317,16 @@ struct pv_info pv_info = {
25943 #endif
25944 };
25945
25946 -struct pv_init_ops pv_init_ops = {
25947 +struct pv_init_ops pv_init_ops __read_only = {
25948 .patch = native_patch,
25949 };
25950
25951 -struct pv_time_ops pv_time_ops = {
25952 +struct pv_time_ops pv_time_ops __read_only = {
25953 .sched_clock = native_sched_clock,
25954 .steal_clock = native_steal_clock,
25955 };
25956
25957 -__visible struct pv_irq_ops pv_irq_ops = {
25958 +__visible struct pv_irq_ops pv_irq_ops __read_only = {
25959 .save_fl = __PV_IS_CALLEE_SAVE(native_save_fl),
25960 .restore_fl = __PV_IS_CALLEE_SAVE(native_restore_fl),
25961 .irq_disable = __PV_IS_CALLEE_SAVE(native_irq_disable),
25962 @@ -331,7 +338,7 @@ __visible struct pv_irq_ops pv_irq_ops = {
25963 #endif
25964 };
25965
25966 -__visible struct pv_cpu_ops pv_cpu_ops = {
25967 +__visible struct pv_cpu_ops pv_cpu_ops __read_only = {
25968 .cpuid = native_cpuid,
25969 .get_debugreg = native_get_debugreg,
25970 .set_debugreg = native_set_debugreg,
25971 @@ -389,21 +396,26 @@ __visible struct pv_cpu_ops pv_cpu_ops = {
25972 .end_context_switch = paravirt_nop,
25973 };
25974
25975 -struct pv_apic_ops pv_apic_ops = {
25976 +struct pv_apic_ops pv_apic_ops __read_only= {
25977 #ifdef CONFIG_X86_LOCAL_APIC
25978 .startup_ipi_hook = paravirt_nop,
25979 #endif
25980 };
25981
25982 -#if defined(CONFIG_X86_32) && !defined(CONFIG_X86_PAE)
25983 +#ifdef CONFIG_X86_32
25984 +#ifdef CONFIG_X86_PAE
25985 +/* 64-bit pagetable entries */
25986 +#define PTE_IDENT PV_CALLEE_SAVE(_paravirt_ident_64)
25987 +#else
25988 /* 32-bit pagetable entries */
25989 #define PTE_IDENT __PV_IS_CALLEE_SAVE(_paravirt_ident_32)
25990 +#endif
25991 #else
25992 /* 64-bit pagetable entries */
25993 #define PTE_IDENT __PV_IS_CALLEE_SAVE(_paravirt_ident_64)
25994 #endif
25995
25996 -struct pv_mmu_ops pv_mmu_ops = {
25997 +struct pv_mmu_ops pv_mmu_ops __read_only = {
25998
25999 .read_cr2 = native_read_cr2,
26000 .write_cr2 = native_write_cr2,
26001 @@ -453,6 +465,7 @@ struct pv_mmu_ops pv_mmu_ops = {
26002 .make_pud = PTE_IDENT,
26003
26004 .set_pgd = native_set_pgd,
26005 + .set_pgd_batched = native_set_pgd_batched,
26006 #endif
26007 #endif /* PAGETABLE_LEVELS >= 3 */
26008
26009 @@ -473,6 +486,12 @@ struct pv_mmu_ops pv_mmu_ops = {
26010 },
26011
26012 .set_fixmap = native_set_fixmap,
26013 +
26014 +#ifdef CONFIG_PAX_KERNEXEC
26015 + .pax_open_kernel = native_pax_open_kernel,
26016 + .pax_close_kernel = native_pax_close_kernel,
26017 +#endif
26018 +
26019 };
26020
26021 EXPORT_SYMBOL_GPL(pv_time_ops);
26022 diff --git a/arch/x86/kernel/pci-calgary_64.c b/arch/x86/kernel/pci-calgary_64.c
26023 index 0497f71..7186c0d 100644
26024 --- a/arch/x86/kernel/pci-calgary_64.c
26025 +++ b/arch/x86/kernel/pci-calgary_64.c
26026 @@ -1347,7 +1347,7 @@ static void __init get_tce_space_from_tar(void)
26027 tce_space = be64_to_cpu(readq(target));
26028 tce_space = tce_space & TAR_SW_BITS;
26029
26030 - tce_space = tce_space & (~specified_table_size);
26031 + tce_space = tce_space & (~(unsigned long)specified_table_size);
26032 info->tce_space = (u64 *)__va(tce_space);
26033 }
26034 }
26035 diff --git a/arch/x86/kernel/pci-iommu_table.c b/arch/x86/kernel/pci-iommu_table.c
26036 index 35ccf75..7a15747 100644
26037 --- a/arch/x86/kernel/pci-iommu_table.c
26038 +++ b/arch/x86/kernel/pci-iommu_table.c
26039 @@ -2,7 +2,7 @@
26040 #include <asm/iommu_table.h>
26041 #include <linux/string.h>
26042 #include <linux/kallsyms.h>
26043 -
26044 +#include <linux/sched.h>
26045
26046 #define DEBUG 1
26047
26048 diff --git a/arch/x86/kernel/pci-swiotlb.c b/arch/x86/kernel/pci-swiotlb.c
26049 index 6c483ba..d10ce2f 100644
26050 --- a/arch/x86/kernel/pci-swiotlb.c
26051 +++ b/arch/x86/kernel/pci-swiotlb.c
26052 @@ -32,7 +32,7 @@ static void x86_swiotlb_free_coherent(struct device *dev, size_t size,
26053 void *vaddr, dma_addr_t dma_addr,
26054 struct dma_attrs *attrs)
26055 {
26056 - swiotlb_free_coherent(dev, size, vaddr, dma_addr);
26057 + swiotlb_free_coherent(dev, size, vaddr, dma_addr, attrs);
26058 }
26059
26060 static struct dma_map_ops swiotlb_dma_ops = {
26061 diff --git a/arch/x86/kernel/preempt.S b/arch/x86/kernel/preempt.S
26062 index ca7f0d5..8996469 100644
26063 --- a/arch/x86/kernel/preempt.S
26064 +++ b/arch/x86/kernel/preempt.S
26065 @@ -3,12 +3,14 @@
26066 #include <asm/dwarf2.h>
26067 #include <asm/asm.h>
26068 #include <asm/calling.h>
26069 +#include <asm/alternative-asm.h>
26070
26071 ENTRY(___preempt_schedule)
26072 CFI_STARTPROC
26073 SAVE_ALL
26074 call preempt_schedule
26075 RESTORE_ALL
26076 + pax_force_retaddr
26077 ret
26078 CFI_ENDPROC
26079
26080 @@ -19,6 +21,7 @@ ENTRY(___preempt_schedule_context)
26081 SAVE_ALL
26082 call preempt_schedule_context
26083 RESTORE_ALL
26084 + pax_force_retaddr
26085 ret
26086 CFI_ENDPROC
26087
26088 diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c
26089 index 4505e2a..ae28b0d 100644
26090 --- a/arch/x86/kernel/process.c
26091 +++ b/arch/x86/kernel/process.c
26092 @@ -36,7 +36,8 @@
26093 * section. Since TSS's are completely CPU-local, we want them
26094 * on exact cacheline boundaries, to eliminate cacheline ping-pong.
26095 */
26096 -__visible DEFINE_PER_CPU_SHARED_ALIGNED(struct tss_struct, init_tss) = INIT_TSS;
26097 +struct tss_struct init_tss[NR_CPUS] __visible ____cacheline_internodealigned_in_smp = { [0 ... NR_CPUS-1] = INIT_TSS };
26098 +EXPORT_SYMBOL(init_tss);
26099
26100 #ifdef CONFIG_X86_64
26101 static DEFINE_PER_CPU(unsigned char, is_idle);
26102 @@ -92,7 +93,7 @@ void arch_task_cache_init(void)
26103 task_xstate_cachep =
26104 kmem_cache_create("task_xstate", xstate_size,
26105 __alignof__(union thread_xstate),
26106 - SLAB_PANIC | SLAB_NOTRACK, NULL);
26107 + SLAB_PANIC | SLAB_NOTRACK | SLAB_USERCOPY, NULL);
26108 }
26109
26110 /*
26111 @@ -105,7 +106,7 @@ void exit_thread(void)
26112 unsigned long *bp = t->io_bitmap_ptr;
26113
26114 if (bp) {
26115 - struct tss_struct *tss = &per_cpu(init_tss, get_cpu());
26116 + struct tss_struct *tss = init_tss + get_cpu();
26117
26118 t->io_bitmap_ptr = NULL;
26119 clear_thread_flag(TIF_IO_BITMAP);
26120 @@ -125,6 +126,9 @@ void flush_thread(void)
26121 {
26122 struct task_struct *tsk = current;
26123
26124 +#if defined(CONFIG_X86_32) && !defined(CONFIG_CC_STACKPROTECTOR) && !defined(CONFIG_PAX_MEMORY_UDEREF)
26125 + loadsegment(gs, 0);
26126 +#endif
26127 flush_ptrace_hw_breakpoint(tsk);
26128 memset(tsk->thread.tls_array, 0, sizeof(tsk->thread.tls_array));
26129 drop_init_fpu(tsk);
26130 @@ -271,7 +275,7 @@ static void __exit_idle(void)
26131 void exit_idle(void)
26132 {
26133 /* idle loop has pid 0 */
26134 - if (current->pid)
26135 + if (task_pid_nr(current))
26136 return;
26137 __exit_idle();
26138 }
26139 @@ -324,7 +328,7 @@ bool xen_set_default_idle(void)
26140 return ret;
26141 }
26142 #endif
26143 -void stop_this_cpu(void *dummy)
26144 +__noreturn void stop_this_cpu(void *dummy)
26145 {
26146 local_irq_disable();
26147 /*
26148 @@ -453,16 +457,37 @@ static int __init idle_setup(char *str)
26149 }
26150 early_param("idle", idle_setup);
26151
26152 -unsigned long arch_align_stack(unsigned long sp)
26153 +#ifdef CONFIG_PAX_RANDKSTACK
26154 +void pax_randomize_kstack(struct pt_regs *regs)
26155 {
26156 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
26157 - sp -= get_random_int() % 8192;
26158 - return sp & ~0xf;
26159 -}
26160 + struct thread_struct *thread = &current->thread;
26161 + unsigned long time;
26162
26163 -unsigned long arch_randomize_brk(struct mm_struct *mm)
26164 -{
26165 - unsigned long range_end = mm->brk + 0x02000000;
26166 - return randomize_range(mm->brk, range_end, 0) ? : mm->brk;
26167 -}
26168 + if (!randomize_va_space)
26169 + return;
26170 +
26171 + if (v8086_mode(regs))
26172 + return;
26173
26174 + rdtscl(time);
26175 +
26176 + /* P4 seems to return a 0 LSB, ignore it */
26177 +#ifdef CONFIG_MPENTIUM4
26178 + time &= 0x3EUL;
26179 + time <<= 2;
26180 +#elif defined(CONFIG_X86_64)
26181 + time &= 0xFUL;
26182 + time <<= 4;
26183 +#else
26184 + time &= 0x1FUL;
26185 + time <<= 3;
26186 +#endif
26187 +
26188 + thread->sp0 ^= time;
26189 + load_sp0(init_tss + smp_processor_id(), thread);
26190 +
26191 +#ifdef CONFIG_X86_64
26192 + this_cpu_write(kernel_stack, thread->sp0);
26193 +#endif
26194 +}
26195 +#endif
26196 diff --git a/arch/x86/kernel/process_32.c b/arch/x86/kernel/process_32.c
26197 index 7bc86bb..0ea06e8 100644
26198 --- a/arch/x86/kernel/process_32.c
26199 +++ b/arch/x86/kernel/process_32.c
26200 @@ -64,6 +64,7 @@ asmlinkage void ret_from_kernel_thread(void) __asm__("ret_from_kernel_thread");
26201 unsigned long thread_saved_pc(struct task_struct *tsk)
26202 {
26203 return ((unsigned long *)tsk->thread.sp)[3];
26204 +//XXX return tsk->thread.eip;
26205 }
26206
26207 void __show_regs(struct pt_regs *regs, int all)
26208 @@ -73,19 +74,18 @@ void __show_regs(struct pt_regs *regs, int all)
26209 unsigned long sp;
26210 unsigned short ss, gs;
26211
26212 - if (user_mode_vm(regs)) {
26213 + if (user_mode(regs)) {
26214 sp = regs->sp;
26215 ss = regs->ss & 0xffff;
26216 - gs = get_user_gs(regs);
26217 } else {
26218 sp = kernel_stack_pointer(regs);
26219 savesegment(ss, ss);
26220 - savesegment(gs, gs);
26221 }
26222 + gs = get_user_gs(regs);
26223
26224 printk(KERN_DEFAULT "EIP: %04x:[<%08lx>] EFLAGS: %08lx CPU: %d\n",
26225 (u16)regs->cs, regs->ip, regs->flags,
26226 - smp_processor_id());
26227 + raw_smp_processor_id());
26228 print_symbol("EIP is at %s\n", regs->ip);
26229
26230 printk(KERN_DEFAULT "EAX: %08lx EBX: %08lx ECX: %08lx EDX: %08lx\n",
26231 @@ -132,20 +132,21 @@ void release_thread(struct task_struct *dead_task)
26232 int copy_thread(unsigned long clone_flags, unsigned long sp,
26233 unsigned long arg, struct task_struct *p)
26234 {
26235 - struct pt_regs *childregs = task_pt_regs(p);
26236 + struct pt_regs *childregs = task_stack_page(p) + THREAD_SIZE - sizeof(struct pt_regs) - 8;
26237 struct task_struct *tsk;
26238 int err;
26239
26240 p->thread.sp = (unsigned long) childregs;
26241 p->thread.sp0 = (unsigned long) (childregs+1);
26242 + p->tinfo.lowest_stack = (unsigned long)task_stack_page(p);
26243
26244 if (unlikely(p->flags & PF_KTHREAD)) {
26245 /* kernel thread */
26246 memset(childregs, 0, sizeof(struct pt_regs));
26247 p->thread.ip = (unsigned long) ret_from_kernel_thread;
26248 - task_user_gs(p) = __KERNEL_STACK_CANARY;
26249 - childregs->ds = __USER_DS;
26250 - childregs->es = __USER_DS;
26251 + savesegment(gs, childregs->gs);
26252 + childregs->ds = __KERNEL_DS;
26253 + childregs->es = __KERNEL_DS;
26254 childregs->fs = __KERNEL_PERCPU;
26255 childregs->bx = sp; /* function */
26256 childregs->bp = arg;
26257 @@ -252,7 +253,7 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
26258 struct thread_struct *prev = &prev_p->thread,
26259 *next = &next_p->thread;
26260 int cpu = smp_processor_id();
26261 - struct tss_struct *tss = &per_cpu(init_tss, cpu);
26262 + struct tss_struct *tss = init_tss + cpu;
26263 fpu_switch_t fpu;
26264
26265 /* never put a printk in __switch_to... printk() calls wake_up*() indirectly */
26266 @@ -276,6 +277,10 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
26267 */
26268 lazy_save_gs(prev->gs);
26269
26270 +#ifdef CONFIG_PAX_MEMORY_UDEREF
26271 + __set_fs(task_thread_info(next_p)->addr_limit);
26272 +#endif
26273 +
26274 /*
26275 * Load the per-thread Thread-Local Storage descriptor.
26276 */
26277 @@ -314,9 +319,9 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
26278 */
26279 arch_end_context_switch(next_p);
26280
26281 - this_cpu_write(kernel_stack,
26282 - (unsigned long)task_stack_page(next_p) +
26283 - THREAD_SIZE - KERNEL_STACK_OFFSET);
26284 + this_cpu_write(current_task, next_p);
26285 + this_cpu_write(current_tinfo, &next_p->tinfo);
26286 + this_cpu_write(kernel_stack, next->sp0);
26287
26288 /*
26289 * Restore %gs if needed (which is common)
26290 @@ -326,8 +331,6 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
26291
26292 switch_fpu_finish(next_p, fpu);
26293
26294 - this_cpu_write(current_task, next_p);
26295 -
26296 return prev_p;
26297 }
26298
26299 @@ -357,4 +360,3 @@ unsigned long get_wchan(struct task_struct *p)
26300 } while (count++ < 16);
26301 return 0;
26302 }
26303 -
26304 diff --git a/arch/x86/kernel/process_64.c b/arch/x86/kernel/process_64.c
26305 index 898d077..4c458ff 100644
26306 --- a/arch/x86/kernel/process_64.c
26307 +++ b/arch/x86/kernel/process_64.c
26308 @@ -158,10 +158,11 @@ int copy_thread(unsigned long clone_flags, unsigned long sp,
26309 struct pt_regs *childregs;
26310 struct task_struct *me = current;
26311
26312 - p->thread.sp0 = (unsigned long)task_stack_page(p) + THREAD_SIZE;
26313 + p->thread.sp0 = (unsigned long)task_stack_page(p) + THREAD_SIZE - 16;
26314 childregs = task_pt_regs(p);
26315 p->thread.sp = (unsigned long) childregs;
26316 p->thread.usersp = me->thread.usersp;
26317 + p->tinfo.lowest_stack = (unsigned long)task_stack_page(p);
26318 set_tsk_thread_flag(p, TIF_FORK);
26319 p->thread.fpu_counter = 0;
26320 p->thread.io_bitmap_ptr = NULL;
26321 @@ -172,6 +173,8 @@ int copy_thread(unsigned long clone_flags, unsigned long sp,
26322 p->thread.fs = p->thread.fsindex ? 0 : me->thread.fs;
26323 savesegment(es, p->thread.es);
26324 savesegment(ds, p->thread.ds);
26325 + savesegment(ss, p->thread.ss);
26326 + BUG_ON(p->thread.ss == __UDEREF_KERNEL_DS);
26327 memset(p->thread.ptrace_bps, 0, sizeof(p->thread.ptrace_bps));
26328
26329 if (unlikely(p->flags & PF_KTHREAD)) {
26330 @@ -280,7 +283,7 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
26331 struct thread_struct *prev = &prev_p->thread;
26332 struct thread_struct *next = &next_p->thread;
26333 int cpu = smp_processor_id();
26334 - struct tss_struct *tss = &per_cpu(init_tss, cpu);
26335 + struct tss_struct *tss = init_tss + cpu;
26336 unsigned fsindex, gsindex;
26337 fpu_switch_t fpu;
26338
26339 @@ -303,6 +306,9 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
26340 if (unlikely(next->ds | prev->ds))
26341 loadsegment(ds, next->ds);
26342
26343 + savesegment(ss, prev->ss);
26344 + if (unlikely(next->ss != prev->ss))
26345 + loadsegment(ss, next->ss);
26346
26347 /* We must save %fs and %gs before load_TLS() because
26348 * %fs and %gs may be cleared by load_TLS().
26349 @@ -362,6 +368,7 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
26350 prev->usersp = this_cpu_read(old_rsp);
26351 this_cpu_write(old_rsp, next->usersp);
26352 this_cpu_write(current_task, next_p);
26353 + this_cpu_write(current_tinfo, &next_p->tinfo);
26354
26355 /*
26356 * If it were not for PREEMPT_ACTIVE we could guarantee that the
26357 @@ -371,9 +378,7 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
26358 task_thread_info(prev_p)->saved_preempt_count = this_cpu_read(__preempt_count);
26359 this_cpu_write(__preempt_count, task_thread_info(next_p)->saved_preempt_count);
26360
26361 - this_cpu_write(kernel_stack,
26362 - (unsigned long)task_stack_page(next_p) +
26363 - THREAD_SIZE - KERNEL_STACK_OFFSET);
26364 + this_cpu_write(kernel_stack, next->sp0);
26365
26366 /*
26367 * Now maybe reload the debug registers and handle I/O bitmaps
26368 @@ -442,12 +447,11 @@ unsigned long get_wchan(struct task_struct *p)
26369 if (!p || p == current || p->state == TASK_RUNNING)
26370 return 0;
26371 stack = (unsigned long)task_stack_page(p);
26372 - if (p->thread.sp < stack || p->thread.sp >= stack+THREAD_SIZE)
26373 + if (p->thread.sp < stack || p->thread.sp > stack+THREAD_SIZE-16-sizeof(u64))
26374 return 0;
26375 fp = *(u64 *)(p->thread.sp);
26376 do {
26377 - if (fp < (unsigned long)stack ||
26378 - fp >= (unsigned long)stack+THREAD_SIZE)
26379 + if (fp < stack || fp > stack+THREAD_SIZE-16-sizeof(u64))
26380 return 0;
26381 ip = *(u64 *)(fp+8);
26382 if (!in_sched_functions(ip))
26383 diff --git a/arch/x86/kernel/ptrace.c b/arch/x86/kernel/ptrace.c
26384 index 678c0ad..d309ccb 100644
26385 --- a/arch/x86/kernel/ptrace.c
26386 +++ b/arch/x86/kernel/ptrace.c
26387 @@ -186,10 +186,10 @@ unsigned long kernel_stack_pointer(struct pt_regs *regs)
26388 unsigned long sp = (unsigned long)&regs->sp;
26389 u32 *prev_esp;
26390
26391 - if (context == (sp & ~(THREAD_SIZE - 1)))
26392 + if (context == ((sp + 8) & ~(THREAD_SIZE - 1)))
26393 return sp;
26394
26395 - prev_esp = (u32 *)(context);
26396 + prev_esp = *(u32 **)(context);
26397 if (prev_esp)
26398 return (unsigned long)prev_esp;
26399
26400 @@ -588,7 +588,7 @@ static void ptrace_triggered(struct perf_event *bp,
26401 static unsigned long ptrace_get_dr7(struct perf_event *bp[])
26402 {
26403 int i;
26404 - int dr7 = 0;
26405 + unsigned long dr7 = 0;
26406 struct arch_hw_breakpoint *info;
26407
26408 for (i = 0; i < HBP_NUM; i++) {
26409 @@ -822,7 +822,7 @@ long arch_ptrace(struct task_struct *child, long request,
26410 unsigned long addr, unsigned long data)
26411 {
26412 int ret;
26413 - unsigned long __user *datap = (unsigned long __user *)data;
26414 + unsigned long __user *datap = (__force unsigned long __user *)data;
26415
26416 switch (request) {
26417 /* read the word at location addr in the USER area. */
26418 @@ -907,14 +907,14 @@ long arch_ptrace(struct task_struct *child, long request,
26419 if ((int) addr < 0)
26420 return -EIO;
26421 ret = do_get_thread_area(child, addr,
26422 - (struct user_desc __user *)data);
26423 + (__force struct user_desc __user *) data);
26424 break;
26425
26426 case PTRACE_SET_THREAD_AREA:
26427 if ((int) addr < 0)
26428 return -EIO;
26429 ret = do_set_thread_area(child, addr,
26430 - (struct user_desc __user *)data, 0);
26431 + (__force struct user_desc __user *) data, 0);
26432 break;
26433 #endif
26434
26435 @@ -1292,7 +1292,7 @@ long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
26436
26437 #ifdef CONFIG_X86_64
26438
26439 -static struct user_regset x86_64_regsets[] __read_mostly = {
26440 +static user_regset_no_const x86_64_regsets[] __read_only = {
26441 [REGSET_GENERAL] = {
26442 .core_note_type = NT_PRSTATUS,
26443 .n = sizeof(struct user_regs_struct) / sizeof(long),
26444 @@ -1333,7 +1333,7 @@ static const struct user_regset_view user_x86_64_view = {
26445 #endif /* CONFIG_X86_64 */
26446
26447 #if defined CONFIG_X86_32 || defined CONFIG_IA32_EMULATION
26448 -static struct user_regset x86_32_regsets[] __read_mostly = {
26449 +static user_regset_no_const x86_32_regsets[] __read_only = {
26450 [REGSET_GENERAL] = {
26451 .core_note_type = NT_PRSTATUS,
26452 .n = sizeof(struct user_regs_struct32) / sizeof(u32),
26453 @@ -1386,7 +1386,7 @@ static const struct user_regset_view user_x86_32_view = {
26454 */
26455 u64 xstate_fx_sw_bytes[USER_XSTATE_FX_SW_WORDS];
26456
26457 -void update_regset_xstate_info(unsigned int size, u64 xstate_mask)
26458 +void __init update_regset_xstate_info(unsigned int size, u64 xstate_mask)
26459 {
26460 #ifdef CONFIG_X86_64
26461 x86_64_regsets[REGSET_XSTATE].n = size / sizeof(u64);
26462 @@ -1421,7 +1421,7 @@ static void fill_sigtrap_info(struct task_struct *tsk,
26463 memset(info, 0, sizeof(*info));
26464 info->si_signo = SIGTRAP;
26465 info->si_code = si_code;
26466 - info->si_addr = user_mode_vm(regs) ? (void __user *)regs->ip : NULL;
26467 + info->si_addr = user_mode(regs) ? (__force void __user *)regs->ip : NULL;
26468 }
26469
26470 void user_single_step_siginfo(struct task_struct *tsk,
26471 @@ -1450,6 +1450,10 @@ void send_sigtrap(struct task_struct *tsk, struct pt_regs *regs,
26472 # define IS_IA32 0
26473 #endif
26474
26475 +#ifdef CONFIG_GRKERNSEC_SETXID
26476 +extern void gr_delayed_cred_worker(void);
26477 +#endif
26478 +
26479 /*
26480 * We must return the syscall number to actually look up in the table.
26481 * This can be -1L to skip running any syscall at all.
26482 @@ -1460,6 +1464,11 @@ long syscall_trace_enter(struct pt_regs *regs)
26483
26484 user_exit();
26485
26486 +#ifdef CONFIG_GRKERNSEC_SETXID
26487 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
26488 + gr_delayed_cred_worker();
26489 +#endif
26490 +
26491 /*
26492 * If we stepped into a sysenter/syscall insn, it trapped in
26493 * kernel mode; do_debug() cleared TF and set TIF_SINGLESTEP.
26494 @@ -1515,6 +1524,11 @@ void syscall_trace_leave(struct pt_regs *regs)
26495 */
26496 user_exit();
26497
26498 +#ifdef CONFIG_GRKERNSEC_SETXID
26499 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
26500 + gr_delayed_cred_worker();
26501 +#endif
26502 +
26503 audit_syscall_exit(regs);
26504
26505 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
26506 diff --git a/arch/x86/kernel/pvclock.c b/arch/x86/kernel/pvclock.c
26507 index 2f355d2..e75ed0a 100644
26508 --- a/arch/x86/kernel/pvclock.c
26509 +++ b/arch/x86/kernel/pvclock.c
26510 @@ -51,11 +51,11 @@ void pvclock_touch_watchdogs(void)
26511 reset_hung_task_detector();
26512 }
26513
26514 -static atomic64_t last_value = ATOMIC64_INIT(0);
26515 +static atomic64_unchecked_t last_value = ATOMIC64_INIT(0);
26516
26517 void pvclock_resume(void)
26518 {
26519 - atomic64_set(&last_value, 0);
26520 + atomic64_set_unchecked(&last_value, 0);
26521 }
26522
26523 u8 pvclock_read_flags(struct pvclock_vcpu_time_info *src)
26524 @@ -105,11 +105,11 @@ cycle_t pvclock_clocksource_read(struct pvclock_vcpu_time_info *src)
26525 * updating at the same time, and one of them could be slightly behind,
26526 * making the assumption that last_value always go forward fail to hold.
26527 */
26528 - last = atomic64_read(&last_value);
26529 + last = atomic64_read_unchecked(&last_value);
26530 do {
26531 if (ret < last)
26532 return last;
26533 - last = atomic64_cmpxchg(&last_value, last, ret);
26534 + last = atomic64_cmpxchg_unchecked(&last_value, last, ret);
26535 } while (unlikely(last != ret));
26536
26537 return ret;
26538 diff --git a/arch/x86/kernel/reboot.c b/arch/x86/kernel/reboot.c
26539 index 52b1157..c6e67c4 100644
26540 --- a/arch/x86/kernel/reboot.c
26541 +++ b/arch/x86/kernel/reboot.c
26542 @@ -68,6 +68,11 @@ static int __init set_bios_reboot(const struct dmi_system_id *d)
26543
26544 void __noreturn machine_real_restart(unsigned int type)
26545 {
26546 +
26547 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF))
26548 + struct desc_struct *gdt;
26549 +#endif
26550 +
26551 local_irq_disable();
26552
26553 /*
26554 @@ -95,7 +100,29 @@ void __noreturn machine_real_restart(unsigned int type)
26555
26556 /* Jump to the identity-mapped low memory code */
26557 #ifdef CONFIG_X86_32
26558 - asm volatile("jmpl *%0" : :
26559 +
26560 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
26561 + gdt = get_cpu_gdt_table(smp_processor_id());
26562 + pax_open_kernel();
26563 +#ifdef CONFIG_PAX_MEMORY_UDEREF
26564 + gdt[GDT_ENTRY_KERNEL_DS].type = 3;
26565 + gdt[GDT_ENTRY_KERNEL_DS].limit = 0xf;
26566 + loadsegment(ds, __KERNEL_DS);
26567 + loadsegment(es, __KERNEL_DS);
26568 + loadsegment(ss, __KERNEL_DS);
26569 +#endif
26570 +#ifdef CONFIG_PAX_KERNEXEC
26571 + gdt[GDT_ENTRY_KERNEL_CS].base0 = 0;
26572 + gdt[GDT_ENTRY_KERNEL_CS].base1 = 0;
26573 + gdt[GDT_ENTRY_KERNEL_CS].base2 = 0;
26574 + gdt[GDT_ENTRY_KERNEL_CS].limit0 = 0xffff;
26575 + gdt[GDT_ENTRY_KERNEL_CS].limit = 0xf;
26576 + gdt[GDT_ENTRY_KERNEL_CS].g = 1;
26577 +#endif
26578 + pax_close_kernel();
26579 +#endif
26580 +
26581 + asm volatile("ljmpl *%0" : :
26582 "rm" (real_mode_header->machine_real_restart_asm),
26583 "a" (type));
26584 #else
26585 @@ -486,7 +513,7 @@ void __attribute__((weak)) mach_reboot_fixups(void)
26586 * This means that this function can never return, it can misbehave
26587 * by not rebooting properly and hanging.
26588 */
26589 -static void native_machine_emergency_restart(void)
26590 +static void __noreturn native_machine_emergency_restart(void)
26591 {
26592 int i;
26593 int attempt = 0;
26594 @@ -610,13 +637,13 @@ void native_machine_shutdown(void)
26595 #endif
26596 }
26597
26598 -static void __machine_emergency_restart(int emergency)
26599 +static void __noreturn __machine_emergency_restart(int emergency)
26600 {
26601 reboot_emergency = emergency;
26602 machine_ops.emergency_restart();
26603 }
26604
26605 -static void native_machine_restart(char *__unused)
26606 +static void __noreturn native_machine_restart(char *__unused)
26607 {
26608 pr_notice("machine restart\n");
26609
26610 @@ -625,7 +652,7 @@ static void native_machine_restart(char *__unused)
26611 __machine_emergency_restart(0);
26612 }
26613
26614 -static void native_machine_halt(void)
26615 +static void __noreturn native_machine_halt(void)
26616 {
26617 /* Stop other cpus and apics */
26618 machine_shutdown();
26619 @@ -635,7 +662,7 @@ static void native_machine_halt(void)
26620 stop_this_cpu(NULL);
26621 }
26622
26623 -static void native_machine_power_off(void)
26624 +static void __noreturn native_machine_power_off(void)
26625 {
26626 if (pm_power_off) {
26627 if (!reboot_force)
26628 @@ -644,9 +671,10 @@ static void native_machine_power_off(void)
26629 }
26630 /* A fallback in case there is no PM info available */
26631 tboot_shutdown(TB_SHUTDOWN_HALT);
26632 + unreachable();
26633 }
26634
26635 -struct machine_ops machine_ops = {
26636 +struct machine_ops machine_ops __read_only = {
26637 .power_off = native_machine_power_off,
26638 .shutdown = native_machine_shutdown,
26639 .emergency_restart = native_machine_emergency_restart,
26640 diff --git a/arch/x86/kernel/reboot_fixups_32.c b/arch/x86/kernel/reboot_fixups_32.c
26641 index c8e41e9..64049ef 100644
26642 --- a/arch/x86/kernel/reboot_fixups_32.c
26643 +++ b/arch/x86/kernel/reboot_fixups_32.c
26644 @@ -57,7 +57,7 @@ struct device_fixup {
26645 unsigned int vendor;
26646 unsigned int device;
26647 void (*reboot_fixup)(struct pci_dev *);
26648 -};
26649 +} __do_const;
26650
26651 /*
26652 * PCI ids solely used for fixups_table go here
26653 diff --git a/arch/x86/kernel/relocate_kernel_64.S b/arch/x86/kernel/relocate_kernel_64.S
26654 index 3fd2c69..a444264 100644
26655 --- a/arch/x86/kernel/relocate_kernel_64.S
26656 +++ b/arch/x86/kernel/relocate_kernel_64.S
26657 @@ -96,8 +96,7 @@ relocate_kernel:
26658
26659 /* jump to identity mapped page */
26660 addq $(identity_mapped - relocate_kernel), %r8
26661 - pushq %r8
26662 - ret
26663 + jmp *%r8
26664
26665 identity_mapped:
26666 /* set return address to 0 if not preserving context */
26667 diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
26668 index 09c76d2..7f33fc2 100644
26669 --- a/arch/x86/kernel/setup.c
26670 +++ b/arch/x86/kernel/setup.c
26671 @@ -110,6 +110,7 @@
26672 #include <asm/mce.h>
26673 #include <asm/alternative.h>
26674 #include <asm/prom.h>
26675 +#include <asm/boot.h>
26676
26677 /*
26678 * max_low_pfn_mapped: highest direct mapped pfn under 4GB
26679 @@ -205,12 +206,50 @@ EXPORT_SYMBOL(boot_cpu_data);
26680 #endif
26681
26682
26683 -#if !defined(CONFIG_X86_PAE) || defined(CONFIG_X86_64)
26684 -__visible unsigned long mmu_cr4_features;
26685 +#ifdef CONFIG_X86_64
26686 +__visible unsigned long mmu_cr4_features __read_only = X86_CR4_PSE | X86_CR4_PAE | X86_CR4_PGE;
26687 +#elif defined(CONFIG_X86_PAE)
26688 +__visible unsigned long mmu_cr4_features __read_only = X86_CR4_PAE;
26689 #else
26690 -__visible unsigned long mmu_cr4_features = X86_CR4_PAE;
26691 +__visible unsigned long mmu_cr4_features __read_only;
26692 #endif
26693
26694 +void set_in_cr4(unsigned long mask)
26695 +{
26696 + unsigned long cr4 = read_cr4();
26697 +
26698 + if ((cr4 & mask) == mask && cr4 == mmu_cr4_features)
26699 + return;
26700 +
26701 + pax_open_kernel();
26702 + mmu_cr4_features |= mask;
26703 + pax_close_kernel();
26704 +
26705 + if (trampoline_cr4_features)
26706 + *trampoline_cr4_features = mmu_cr4_features;
26707 + cr4 |= mask;
26708 + write_cr4(cr4);
26709 +}
26710 +EXPORT_SYMBOL(set_in_cr4);
26711 +
26712 +void clear_in_cr4(unsigned long mask)
26713 +{
26714 + unsigned long cr4 = read_cr4();
26715 +
26716 + if (!(cr4 & mask) && cr4 == mmu_cr4_features)
26717 + return;
26718 +
26719 + pax_open_kernel();
26720 + mmu_cr4_features &= ~mask;
26721 + pax_close_kernel();
26722 +
26723 + if (trampoline_cr4_features)
26724 + *trampoline_cr4_features = mmu_cr4_features;
26725 + cr4 &= ~mask;
26726 + write_cr4(cr4);
26727 +}
26728 +EXPORT_SYMBOL(clear_in_cr4);
26729 +
26730 /* Boot loader ID and version as integers, for the benefit of proc_dointvec */
26731 int bootloader_type, bootloader_version;
26732
26733 @@ -772,7 +811,7 @@ static void __init trim_bios_range(void)
26734 * area (640->1Mb) as ram even though it is not.
26735 * take them out.
26736 */
26737 - e820_remove_range(BIOS_BEGIN, BIOS_END - BIOS_BEGIN, E820_RAM, 1);
26738 + e820_remove_range(ISA_START_ADDRESS, ISA_END_ADDRESS - ISA_START_ADDRESS, E820_RAM, 1);
26739
26740 sanitize_e820_map(e820.map, ARRAY_SIZE(e820.map), &e820.nr_map);
26741 }
26742 @@ -780,7 +819,7 @@ static void __init trim_bios_range(void)
26743 /* called before trim_bios_range() to spare extra sanitize */
26744 static void __init e820_add_kernel_range(void)
26745 {
26746 - u64 start = __pa_symbol(_text);
26747 + u64 start = __pa_symbol(ktla_ktva(_text));
26748 u64 size = __pa_symbol(_end) - start;
26749
26750 /*
26751 @@ -856,8 +895,12 @@ dump_kernel_offset(struct notifier_block *self, unsigned long v, void *p)
26752
26753 void __init setup_arch(char **cmdline_p)
26754 {
26755 +#ifdef CONFIG_X86_32
26756 + memblock_reserve(LOAD_PHYSICAL_ADDR, __pa_symbol(__bss_stop) - LOAD_PHYSICAL_ADDR);
26757 +#else
26758 memblock_reserve(__pa_symbol(_text),
26759 (unsigned long)__bss_stop - (unsigned long)_text);
26760 +#endif
26761
26762 early_reserve_initrd();
26763
26764 @@ -946,14 +989,14 @@ void __init setup_arch(char **cmdline_p)
26765
26766 if (!boot_params.hdr.root_flags)
26767 root_mountflags &= ~MS_RDONLY;
26768 - init_mm.start_code = (unsigned long) _text;
26769 - init_mm.end_code = (unsigned long) _etext;
26770 + init_mm.start_code = ktla_ktva((unsigned long) _text);
26771 + init_mm.end_code = ktla_ktva((unsigned long) _etext);
26772 init_mm.end_data = (unsigned long) _edata;
26773 init_mm.brk = _brk_end;
26774
26775 - code_resource.start = __pa_symbol(_text);
26776 - code_resource.end = __pa_symbol(_etext)-1;
26777 - data_resource.start = __pa_symbol(_etext);
26778 + code_resource.start = __pa_symbol(ktla_ktva(_text));
26779 + code_resource.end = __pa_symbol(ktla_ktva(_etext))-1;
26780 + data_resource.start = __pa_symbol(_sdata);
26781 data_resource.end = __pa_symbol(_edata)-1;
26782 bss_resource.start = __pa_symbol(__bss_start);
26783 bss_resource.end = __pa_symbol(__bss_stop)-1;
26784 diff --git a/arch/x86/kernel/setup_percpu.c b/arch/x86/kernel/setup_percpu.c
26785 index 5cdff03..80fa283 100644
26786 --- a/arch/x86/kernel/setup_percpu.c
26787 +++ b/arch/x86/kernel/setup_percpu.c
26788 @@ -21,19 +21,17 @@
26789 #include <asm/cpu.h>
26790 #include <asm/stackprotector.h>
26791
26792 -DEFINE_PER_CPU_READ_MOSTLY(int, cpu_number);
26793 +#ifdef CONFIG_SMP
26794 +DEFINE_PER_CPU_READ_MOSTLY(unsigned int, cpu_number);
26795 EXPORT_PER_CPU_SYMBOL(cpu_number);
26796 +#endif
26797
26798 -#ifdef CONFIG_X86_64
26799 #define BOOT_PERCPU_OFFSET ((unsigned long)__per_cpu_load)
26800 -#else
26801 -#define BOOT_PERCPU_OFFSET 0
26802 -#endif
26803
26804 DEFINE_PER_CPU(unsigned long, this_cpu_off) = BOOT_PERCPU_OFFSET;
26805 EXPORT_PER_CPU_SYMBOL(this_cpu_off);
26806
26807 -unsigned long __per_cpu_offset[NR_CPUS] __read_mostly = {
26808 +unsigned long __per_cpu_offset[NR_CPUS] __read_only = {
26809 [0 ... NR_CPUS-1] = BOOT_PERCPU_OFFSET,
26810 };
26811 EXPORT_SYMBOL(__per_cpu_offset);
26812 @@ -66,7 +64,7 @@ static bool __init pcpu_need_numa(void)
26813 {
26814 #ifdef CONFIG_NEED_MULTIPLE_NODES
26815 pg_data_t *last = NULL;
26816 - unsigned int cpu;
26817 + int cpu;
26818
26819 for_each_possible_cpu(cpu) {
26820 int node = early_cpu_to_node(cpu);
26821 @@ -155,10 +153,10 @@ static inline void setup_percpu_segment(int cpu)
26822 {
26823 #ifdef CONFIG_X86_32
26824 struct desc_struct gdt;
26825 + unsigned long base = per_cpu_offset(cpu);
26826
26827 - pack_descriptor(&gdt, per_cpu_offset(cpu), 0xFFFFF,
26828 - 0x2 | DESCTYPE_S, 0x8);
26829 - gdt.s = 1;
26830 + pack_descriptor(&gdt, base, (VMALLOC_END - base - 1) >> PAGE_SHIFT,
26831 + 0x83 | DESCTYPE_S, 0xC);
26832 write_gdt_entry(get_cpu_gdt_table(cpu),
26833 GDT_ENTRY_PERCPU, &gdt, DESCTYPE_S);
26834 #endif
26835 @@ -219,6 +217,11 @@ void __init setup_per_cpu_areas(void)
26836 /* alrighty, percpu areas up and running */
26837 delta = (unsigned long)pcpu_base_addr - (unsigned long)__per_cpu_start;
26838 for_each_possible_cpu(cpu) {
26839 +#ifdef CONFIG_CC_STACKPROTECTOR
26840 +#ifdef CONFIG_X86_32
26841 + unsigned long canary = per_cpu(stack_canary.canary, cpu);
26842 +#endif
26843 +#endif
26844 per_cpu_offset(cpu) = delta + pcpu_unit_offsets[cpu];
26845 per_cpu(this_cpu_off, cpu) = per_cpu_offset(cpu);
26846 per_cpu(cpu_number, cpu) = cpu;
26847 @@ -259,6 +262,12 @@ void __init setup_per_cpu_areas(void)
26848 */
26849 set_cpu_numa_node(cpu, early_cpu_to_node(cpu));
26850 #endif
26851 +#ifdef CONFIG_CC_STACKPROTECTOR
26852 +#ifdef CONFIG_X86_32
26853 + if (!cpu)
26854 + per_cpu(stack_canary.canary, cpu) = canary;
26855 +#endif
26856 +#endif
26857 /*
26858 * Up to this point, the boot CPU has been using .init.data
26859 * area. Reload any changed state for the boot CPU.
26860 diff --git a/arch/x86/kernel/signal.c b/arch/x86/kernel/signal.c
26861 index 9e5de68..16c53cb 100644
26862 --- a/arch/x86/kernel/signal.c
26863 +++ b/arch/x86/kernel/signal.c
26864 @@ -190,7 +190,7 @@ static unsigned long align_sigframe(unsigned long sp)
26865 * Align the stack pointer according to the i386 ABI,
26866 * i.e. so that on function entry ((sp + 4) & 15) == 0.
26867 */
26868 - sp = ((sp + 4) & -16ul) - 4;
26869 + sp = ((sp - 12) & -16ul) - 4;
26870 #else /* !CONFIG_X86_32 */
26871 sp = round_down(sp, 16) - 8;
26872 #endif
26873 @@ -298,9 +298,9 @@ __setup_frame(int sig, struct ksignal *ksig, sigset_t *set,
26874 }
26875
26876 if (current->mm->context.vdso)
26877 - restorer = VDSO32_SYMBOL(current->mm->context.vdso, sigreturn);
26878 + restorer = (__force void __user *)VDSO32_SYMBOL(current->mm->context.vdso, sigreturn);
26879 else
26880 - restorer = &frame->retcode;
26881 + restorer = (void __user *)&frame->retcode;
26882 if (ksig->ka.sa.sa_flags & SA_RESTORER)
26883 restorer = ksig->ka.sa.sa_restorer;
26884
26885 @@ -314,7 +314,7 @@ __setup_frame(int sig, struct ksignal *ksig, sigset_t *set,
26886 * reasons and because gdb uses it as a signature to notice
26887 * signal handler stack frames.
26888 */
26889 - err |= __put_user(*((u64 *)&retcode), (u64 *)frame->retcode);
26890 + err |= __put_user(*((u64 *)&retcode), (u64 __user *)frame->retcode);
26891
26892 if (err)
26893 return -EFAULT;
26894 @@ -361,7 +361,10 @@ static int __setup_rt_frame(int sig, struct ksignal *ksig,
26895 save_altstack_ex(&frame->uc.uc_stack, regs->sp);
26896
26897 /* Set up to return from userspace. */
26898 - restorer = VDSO32_SYMBOL(current->mm->context.vdso, rt_sigreturn);
26899 + if (current->mm->context.vdso)
26900 + restorer = (__force void __user *)VDSO32_SYMBOL(current->mm->context.vdso, rt_sigreturn);
26901 + else
26902 + restorer = (void __user *)&frame->retcode;
26903 if (ksig->ka.sa.sa_flags & SA_RESTORER)
26904 restorer = ksig->ka.sa.sa_restorer;
26905 put_user_ex(restorer, &frame->pretcode);
26906 @@ -373,7 +376,7 @@ static int __setup_rt_frame(int sig, struct ksignal *ksig,
26907 * reasons and because gdb uses it as a signature to notice
26908 * signal handler stack frames.
26909 */
26910 - put_user_ex(*((u64 *)&rt_retcode), (u64 *)frame->retcode);
26911 + put_user_ex(*((u64 *)&rt_retcode), (u64 __user *)frame->retcode);
26912 } put_user_catch(err);
26913
26914 err |= copy_siginfo_to_user(&frame->info, &ksig->info);
26915 @@ -609,7 +612,12 @@ setup_rt_frame(struct ksignal *ksig, struct pt_regs *regs)
26916 {
26917 int usig = signr_convert(ksig->sig);
26918 sigset_t *set = sigmask_to_save();
26919 - compat_sigset_t *cset = (compat_sigset_t *) set;
26920 + sigset_t sigcopy;
26921 + compat_sigset_t *cset;
26922 +
26923 + sigcopy = *set;
26924 +
26925 + cset = (compat_sigset_t *) &sigcopy;
26926
26927 /* Set up the stack frame */
26928 if (is_ia32_frame()) {
26929 @@ -620,7 +628,7 @@ setup_rt_frame(struct ksignal *ksig, struct pt_regs *regs)
26930 } else if (is_x32_frame()) {
26931 return x32_setup_rt_frame(ksig, cset, regs);
26932 } else {
26933 - return __setup_rt_frame(ksig->sig, ksig, set, regs);
26934 + return __setup_rt_frame(ksig->sig, ksig, &sigcopy, regs);
26935 }
26936 }
26937
26938 diff --git a/arch/x86/kernel/smp.c b/arch/x86/kernel/smp.c
26939 index be8e1bd..a3d93fa 100644
26940 --- a/arch/x86/kernel/smp.c
26941 +++ b/arch/x86/kernel/smp.c
26942 @@ -341,7 +341,7 @@ static int __init nonmi_ipi_setup(char *str)
26943
26944 __setup("nonmi_ipi", nonmi_ipi_setup);
26945
26946 -struct smp_ops smp_ops = {
26947 +struct smp_ops smp_ops __read_only = {
26948 .smp_prepare_boot_cpu = native_smp_prepare_boot_cpu,
26949 .smp_prepare_cpus = native_smp_prepare_cpus,
26950 .smp_cpus_done = native_smp_cpus_done,
26951 diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
26952 index ae2fd975..c0c8d10 100644
26953 --- a/arch/x86/kernel/smpboot.c
26954 +++ b/arch/x86/kernel/smpboot.c
26955 @@ -230,14 +230,17 @@ static void notrace start_secondary(void *unused)
26956
26957 enable_start_cpu0 = 0;
26958
26959 -#ifdef CONFIG_X86_32
26960 + /* otherwise gcc will move up smp_processor_id before the cpu_init */
26961 + barrier();
26962 +
26963 /* switch away from the initial page table */
26964 +#ifdef CONFIG_PAX_PER_CPU_PGD
26965 + load_cr3(get_cpu_pgd(smp_processor_id(), kernel));
26966 +#else
26967 load_cr3(swapper_pg_dir);
26968 +#endif
26969 __flush_tlb_all();
26970 -#endif
26971
26972 - /* otherwise gcc will move up smp_processor_id before the cpu_init */
26973 - barrier();
26974 /*
26975 * Check TSC synchronization with the BP:
26976 */
26977 @@ -757,8 +760,9 @@ static int do_boot_cpu(int apicid, int cpu, struct task_struct *idle)
26978 alternatives_enable_smp();
26979
26980 idle->thread.sp = (unsigned long) (((struct pt_regs *)
26981 - (THREAD_SIZE + task_stack_page(idle))) - 1);
26982 + (THREAD_SIZE - 16 + task_stack_page(idle))) - 1);
26983 per_cpu(current_task, cpu) = idle;
26984 + per_cpu(current_tinfo, cpu) = &idle->tinfo;
26985
26986 #ifdef CONFIG_X86_32
26987 /* Stack for startup_32 can be just as for start_secondary onwards */
26988 @@ -767,10 +771,10 @@ static int do_boot_cpu(int apicid, int cpu, struct task_struct *idle)
26989 clear_tsk_thread_flag(idle, TIF_FORK);
26990 initial_gs = per_cpu_offset(cpu);
26991 #endif
26992 - per_cpu(kernel_stack, cpu) =
26993 - (unsigned long)task_stack_page(idle) -
26994 - KERNEL_STACK_OFFSET + THREAD_SIZE;
26995 + per_cpu(kernel_stack, cpu) = (unsigned long)task_stack_page(idle) - 16 + THREAD_SIZE;
26996 + pax_open_kernel();
26997 early_gdt_descr.address = (unsigned long)get_cpu_gdt_table(cpu);
26998 + pax_close_kernel();
26999 initial_code = (unsigned long)start_secondary;
27000 stack_start = idle->thread.sp;
27001
27002 @@ -916,6 +920,15 @@ int native_cpu_up(unsigned int cpu, struct task_struct *tidle)
27003 /* the FPU context is blank, nobody can own it */
27004 __cpu_disable_lazy_restore(cpu);
27005
27006 +#ifdef CONFIG_PAX_PER_CPU_PGD
27007 + clone_pgd_range(get_cpu_pgd(cpu, kernel) + KERNEL_PGD_BOUNDARY,
27008 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
27009 + KERNEL_PGD_PTRS);
27010 + clone_pgd_range(get_cpu_pgd(cpu, user) + KERNEL_PGD_BOUNDARY,
27011 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
27012 + KERNEL_PGD_PTRS);
27013 +#endif
27014 +
27015 err = do_boot_cpu(apicid, cpu, tidle);
27016 if (err) {
27017 pr_err("do_boot_cpu failed(%d) to wakeup CPU#%u\n", err, cpu);
27018 diff --git a/arch/x86/kernel/step.c b/arch/x86/kernel/step.c
27019 index 9b4d51d..5d28b58 100644
27020 --- a/arch/x86/kernel/step.c
27021 +++ b/arch/x86/kernel/step.c
27022 @@ -27,10 +27,10 @@ unsigned long convert_ip_to_linear(struct task_struct *child, struct pt_regs *re
27023 struct desc_struct *desc;
27024 unsigned long base;
27025
27026 - seg &= ~7UL;
27027 + seg >>= 3;
27028
27029 mutex_lock(&child->mm->context.lock);
27030 - if (unlikely((seg >> 3) >= child->mm->context.size))
27031 + if (unlikely(seg >= child->mm->context.size))
27032 addr = -1L; /* bogus selector, access would fault */
27033 else {
27034 desc = child->mm->context.ldt + seg;
27035 @@ -42,7 +42,8 @@ unsigned long convert_ip_to_linear(struct task_struct *child, struct pt_regs *re
27036 addr += base;
27037 }
27038 mutex_unlock(&child->mm->context.lock);
27039 - }
27040 + } else if (seg == __KERNEL_CS || seg == __KERNEXEC_KERNEL_CS)
27041 + addr = ktla_ktva(addr);
27042
27043 return addr;
27044 }
27045 @@ -53,6 +54,9 @@ static int is_setting_trap_flag(struct task_struct *child, struct pt_regs *regs)
27046 unsigned char opcode[15];
27047 unsigned long addr = convert_ip_to_linear(child, regs);
27048
27049 + if (addr == -EINVAL)
27050 + return 0;
27051 +
27052 copied = access_process_vm(child, addr, opcode, sizeof(opcode), 0);
27053 for (i = 0; i < copied; i++) {
27054 switch (opcode[i]) {
27055 diff --git a/arch/x86/kernel/sys_i386_32.c b/arch/x86/kernel/sys_i386_32.c
27056 new file mode 100644
27057 index 0000000..5877189
27058 --- /dev/null
27059 +++ b/arch/x86/kernel/sys_i386_32.c
27060 @@ -0,0 +1,189 @@
27061 +/*
27062 + * This file contains various random system calls that
27063 + * have a non-standard calling sequence on the Linux/i386
27064 + * platform.
27065 + */
27066 +
27067 +#include <linux/errno.h>
27068 +#include <linux/sched.h>
27069 +#include <linux/mm.h>
27070 +#include <linux/fs.h>
27071 +#include <linux/smp.h>
27072 +#include <linux/sem.h>
27073 +#include <linux/msg.h>
27074 +#include <linux/shm.h>
27075 +#include <linux/stat.h>
27076 +#include <linux/syscalls.h>
27077 +#include <linux/mman.h>
27078 +#include <linux/file.h>
27079 +#include <linux/utsname.h>
27080 +#include <linux/ipc.h>
27081 +#include <linux/elf.h>
27082 +
27083 +#include <linux/uaccess.h>
27084 +#include <linux/unistd.h>
27085 +
27086 +#include <asm/syscalls.h>
27087 +
27088 +int i386_mmap_check(unsigned long addr, unsigned long len, unsigned long flags)
27089 +{
27090 + unsigned long pax_task_size = TASK_SIZE;
27091 +
27092 +#ifdef CONFIG_PAX_SEGMEXEC
27093 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC)
27094 + pax_task_size = SEGMEXEC_TASK_SIZE;
27095 +#endif
27096 +
27097 + if (flags & MAP_FIXED)
27098 + if (len > pax_task_size || addr > pax_task_size - len)
27099 + return -EINVAL;
27100 +
27101 + return 0;
27102 +}
27103 +
27104 +/*
27105 + * Align a virtual address to avoid aliasing in the I$ on AMD F15h.
27106 + */
27107 +static unsigned long get_align_mask(void)
27108 +{
27109 + if (va_align.flags < 0 || !(va_align.flags & ALIGN_VA_32))
27110 + return 0;
27111 +
27112 + if (!(current->flags & PF_RANDOMIZE))
27113 + return 0;
27114 +
27115 + return va_align.mask;
27116 +}
27117 +
27118 +unsigned long
27119 +arch_get_unmapped_area(struct file *filp, unsigned long addr,
27120 + unsigned long len, unsigned long pgoff, unsigned long flags)
27121 +{
27122 + struct mm_struct *mm = current->mm;
27123 + struct vm_area_struct *vma;
27124 + unsigned long pax_task_size = TASK_SIZE;
27125 + struct vm_unmapped_area_info info;
27126 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
27127 +
27128 +#ifdef CONFIG_PAX_SEGMEXEC
27129 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
27130 + pax_task_size = SEGMEXEC_TASK_SIZE;
27131 +#endif
27132 +
27133 + pax_task_size -= PAGE_SIZE;
27134 +
27135 + if (len > pax_task_size)
27136 + return -ENOMEM;
27137 +
27138 + if (flags & MAP_FIXED)
27139 + return addr;
27140 +
27141 +#ifdef CONFIG_PAX_RANDMMAP
27142 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
27143 +#endif
27144 +
27145 + if (addr) {
27146 + addr = PAGE_ALIGN(addr);
27147 + if (pax_task_size - len >= addr) {
27148 + vma = find_vma(mm, addr);
27149 + if (check_heap_stack_gap(vma, addr, len, offset))
27150 + return addr;
27151 + }
27152 + }
27153 +
27154 + info.flags = 0;
27155 + info.length = len;
27156 + info.align_mask = filp ? get_align_mask() : 0;
27157 + info.align_offset = pgoff << PAGE_SHIFT;
27158 + info.threadstack_offset = offset;
27159 +
27160 +#ifdef CONFIG_PAX_PAGEEXEC
27161 + if (!(__supported_pte_mask & _PAGE_NX) && (mm->pax_flags & MF_PAX_PAGEEXEC) && (flags & MAP_EXECUTABLE)) {
27162 + info.low_limit = 0x00110000UL;
27163 + info.high_limit = mm->start_code;
27164 +
27165 +#ifdef CONFIG_PAX_RANDMMAP
27166 + if (mm->pax_flags & MF_PAX_RANDMMAP)
27167 + info.low_limit += mm->delta_mmap & 0x03FFF000UL;
27168 +#endif
27169 +
27170 + if (info.low_limit < info.high_limit) {
27171 + addr = vm_unmapped_area(&info);
27172 + if (!IS_ERR_VALUE(addr))
27173 + return addr;
27174 + }
27175 + } else
27176 +#endif
27177 +
27178 + info.low_limit = mm->mmap_base;
27179 + info.high_limit = pax_task_size;
27180 +
27181 + return vm_unmapped_area(&info);
27182 +}
27183 +
27184 +unsigned long
27185 +arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
27186 + const unsigned long len, const unsigned long pgoff,
27187 + const unsigned long flags)
27188 +{
27189 + struct vm_area_struct *vma;
27190 + struct mm_struct *mm = current->mm;
27191 + unsigned long addr = addr0, pax_task_size = TASK_SIZE;
27192 + struct vm_unmapped_area_info info;
27193 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
27194 +
27195 +#ifdef CONFIG_PAX_SEGMEXEC
27196 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
27197 + pax_task_size = SEGMEXEC_TASK_SIZE;
27198 +#endif
27199 +
27200 + pax_task_size -= PAGE_SIZE;
27201 +
27202 + /* requested length too big for entire address space */
27203 + if (len > pax_task_size)
27204 + return -ENOMEM;
27205 +
27206 + if (flags & MAP_FIXED)
27207 + return addr;
27208 +
27209 +#ifdef CONFIG_PAX_PAGEEXEC
27210 + if (!(__supported_pte_mask & _PAGE_NX) && (mm->pax_flags & MF_PAX_PAGEEXEC) && (flags & MAP_EXECUTABLE))
27211 + goto bottomup;
27212 +#endif
27213 +
27214 +#ifdef CONFIG_PAX_RANDMMAP
27215 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
27216 +#endif
27217 +
27218 + /* requesting a specific address */
27219 + if (addr) {
27220 + addr = PAGE_ALIGN(addr);
27221 + if (pax_task_size - len >= addr) {
27222 + vma = find_vma(mm, addr);
27223 + if (check_heap_stack_gap(vma, addr, len, offset))
27224 + return addr;
27225 + }
27226 + }
27227 +
27228 + info.flags = VM_UNMAPPED_AREA_TOPDOWN;
27229 + info.length = len;
27230 + info.low_limit = PAGE_SIZE;
27231 + info.high_limit = mm->mmap_base;
27232 + info.align_mask = filp ? get_align_mask() : 0;
27233 + info.align_offset = pgoff << PAGE_SHIFT;
27234 + info.threadstack_offset = offset;
27235 +
27236 + addr = vm_unmapped_area(&info);
27237 + if (!(addr & ~PAGE_MASK))
27238 + return addr;
27239 + VM_BUG_ON(addr != -ENOMEM);
27240 +
27241 +bottomup:
27242 + /*
27243 + * A failed mmap() very likely causes application failure,
27244 + * so fall back to the bottom-up function here. This scenario
27245 + * can happen with large stack limits and large mmap()
27246 + * allocations.
27247 + */
27248 + return arch_get_unmapped_area(filp, addr0, len, pgoff, flags);
27249 +}
27250 diff --git a/arch/x86/kernel/sys_x86_64.c b/arch/x86/kernel/sys_x86_64.c
27251 index 30277e2..5664a29 100644
27252 --- a/arch/x86/kernel/sys_x86_64.c
27253 +++ b/arch/x86/kernel/sys_x86_64.c
27254 @@ -81,8 +81,8 @@ out:
27255 return error;
27256 }
27257
27258 -static void find_start_end(unsigned long flags, unsigned long *begin,
27259 - unsigned long *end)
27260 +static void find_start_end(struct mm_struct *mm, unsigned long flags,
27261 + unsigned long *begin, unsigned long *end)
27262 {
27263 if (!test_thread_flag(TIF_ADDR32) && (flags & MAP_32BIT)) {
27264 unsigned long new_begin;
27265 @@ -101,7 +101,7 @@ static void find_start_end(unsigned long flags, unsigned long *begin,
27266 *begin = new_begin;
27267 }
27268 } else {
27269 - *begin = current->mm->mmap_legacy_base;
27270 + *begin = mm->mmap_legacy_base;
27271 *end = TASK_SIZE;
27272 }
27273 }
27274 @@ -114,20 +114,24 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
27275 struct vm_area_struct *vma;
27276 struct vm_unmapped_area_info info;
27277 unsigned long begin, end;
27278 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
27279
27280 if (flags & MAP_FIXED)
27281 return addr;
27282
27283 - find_start_end(flags, &begin, &end);
27284 + find_start_end(mm, flags, &begin, &end);
27285
27286 if (len > end)
27287 return -ENOMEM;
27288
27289 +#ifdef CONFIG_PAX_RANDMMAP
27290 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
27291 +#endif
27292 +
27293 if (addr) {
27294 addr = PAGE_ALIGN(addr);
27295 vma = find_vma(mm, addr);
27296 - if (end - len >= addr &&
27297 - (!vma || addr + len <= vma->vm_start))
27298 + if (end - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
27299 return addr;
27300 }
27301
27302 @@ -137,6 +141,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
27303 info.high_limit = end;
27304 info.align_mask = filp ? get_align_mask() : 0;
27305 info.align_offset = pgoff << PAGE_SHIFT;
27306 + info.threadstack_offset = offset;
27307 return vm_unmapped_area(&info);
27308 }
27309
27310 @@ -149,6 +154,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
27311 struct mm_struct *mm = current->mm;
27312 unsigned long addr = addr0;
27313 struct vm_unmapped_area_info info;
27314 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
27315
27316 /* requested length too big for entire address space */
27317 if (len > TASK_SIZE)
27318 @@ -161,12 +167,15 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
27319 if (!test_thread_flag(TIF_ADDR32) && (flags & MAP_32BIT))
27320 goto bottomup;
27321
27322 +#ifdef CONFIG_PAX_RANDMMAP
27323 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
27324 +#endif
27325 +
27326 /* requesting a specific address */
27327 if (addr) {
27328 addr = PAGE_ALIGN(addr);
27329 vma = find_vma(mm, addr);
27330 - if (TASK_SIZE - len >= addr &&
27331 - (!vma || addr + len <= vma->vm_start))
27332 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
27333 return addr;
27334 }
27335
27336 @@ -176,6 +185,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
27337 info.high_limit = mm->mmap_base;
27338 info.align_mask = filp ? get_align_mask() : 0;
27339 info.align_offset = pgoff << PAGE_SHIFT;
27340 + info.threadstack_offset = offset;
27341 addr = vm_unmapped_area(&info);
27342 if (!(addr & ~PAGE_MASK))
27343 return addr;
27344 diff --git a/arch/x86/kernel/tboot.c b/arch/x86/kernel/tboot.c
27345 index 91a4496..bb87552 100644
27346 --- a/arch/x86/kernel/tboot.c
27347 +++ b/arch/x86/kernel/tboot.c
27348 @@ -221,7 +221,7 @@ static int tboot_setup_sleep(void)
27349
27350 void tboot_shutdown(u32 shutdown_type)
27351 {
27352 - void (*shutdown)(void);
27353 + void (* __noreturn shutdown)(void);
27354
27355 if (!tboot_enabled())
27356 return;
27357 @@ -243,7 +243,7 @@ void tboot_shutdown(u32 shutdown_type)
27358
27359 switch_to_tboot_pt();
27360
27361 - shutdown = (void(*)(void))(unsigned long)tboot->shutdown_entry;
27362 + shutdown = (void *)(unsigned long)tboot->shutdown_entry;
27363 shutdown();
27364
27365 /* should not reach here */
27366 @@ -310,7 +310,7 @@ static int tboot_extended_sleep(u8 sleep_state, u32 val_a, u32 val_b)
27367 return -ENODEV;
27368 }
27369
27370 -static atomic_t ap_wfs_count;
27371 +static atomic_unchecked_t ap_wfs_count;
27372
27373 static int tboot_wait_for_aps(int num_aps)
27374 {
27375 @@ -334,9 +334,9 @@ static int tboot_cpu_callback(struct notifier_block *nfb, unsigned long action,
27376 {
27377 switch (action) {
27378 case CPU_DYING:
27379 - atomic_inc(&ap_wfs_count);
27380 + atomic_inc_unchecked(&ap_wfs_count);
27381 if (num_online_cpus() == 1)
27382 - if (tboot_wait_for_aps(atomic_read(&ap_wfs_count)))
27383 + if (tboot_wait_for_aps(atomic_read_unchecked(&ap_wfs_count)))
27384 return NOTIFY_BAD;
27385 break;
27386 }
27387 @@ -422,7 +422,7 @@ static __init int tboot_late_init(void)
27388
27389 tboot_create_trampoline();
27390
27391 - atomic_set(&ap_wfs_count, 0);
27392 + atomic_set_unchecked(&ap_wfs_count, 0);
27393 register_hotcpu_notifier(&tboot_cpu_notifier);
27394
27395 #ifdef CONFIG_DEBUG_FS
27396 diff --git a/arch/x86/kernel/time.c b/arch/x86/kernel/time.c
27397 index bf7ef5c..59d0ac9 100644
27398 --- a/arch/x86/kernel/time.c
27399 +++ b/arch/x86/kernel/time.c
27400 @@ -30,9 +30,9 @@ unsigned long profile_pc(struct pt_regs *regs)
27401 {
27402 unsigned long pc = instruction_pointer(regs);
27403
27404 - if (!user_mode_vm(regs) && in_lock_functions(pc)) {
27405 + if (!user_mode(regs) && in_lock_functions(pc)) {
27406 #ifdef CONFIG_FRAME_POINTER
27407 - return *(unsigned long *)(regs->bp + sizeof(long));
27408 + return ktla_ktva(*(unsigned long *)(regs->bp + sizeof(long)));
27409 #else
27410 unsigned long *sp =
27411 (unsigned long *)kernel_stack_pointer(regs);
27412 @@ -41,11 +41,17 @@ unsigned long profile_pc(struct pt_regs *regs)
27413 * or above a saved flags. Eflags has bits 22-31 zero,
27414 * kernel addresses don't.
27415 */
27416 +
27417 +#ifdef CONFIG_PAX_KERNEXEC
27418 + return ktla_ktva(sp[0]);
27419 +#else
27420 if (sp[0] >> 22)
27421 return sp[0];
27422 if (sp[1] >> 22)
27423 return sp[1];
27424 #endif
27425 +
27426 +#endif
27427 }
27428 return pc;
27429 }
27430 diff --git a/arch/x86/kernel/tls.c b/arch/x86/kernel/tls.c
27431 index f7fec09..9991981 100644
27432 --- a/arch/x86/kernel/tls.c
27433 +++ b/arch/x86/kernel/tls.c
27434 @@ -84,6 +84,11 @@ int do_set_thread_area(struct task_struct *p, int idx,
27435 if (idx < GDT_ENTRY_TLS_MIN || idx > GDT_ENTRY_TLS_MAX)
27436 return -EINVAL;
27437
27438 +#ifdef CONFIG_PAX_SEGMEXEC
27439 + if ((p->mm->pax_flags & MF_PAX_SEGMEXEC) && (info.contents & MODIFY_LDT_CONTENTS_CODE))
27440 + return -EINVAL;
27441 +#endif
27442 +
27443 set_tls_desc(p, idx, &info, 1);
27444
27445 return 0;
27446 @@ -200,7 +205,7 @@ int regset_tls_set(struct task_struct *target, const struct user_regset *regset,
27447
27448 if (kbuf)
27449 info = kbuf;
27450 - else if (__copy_from_user(infobuf, ubuf, count))
27451 + else if (count > sizeof infobuf || __copy_from_user(infobuf, ubuf, count))
27452 return -EFAULT;
27453 else
27454 info = infobuf;
27455 diff --git a/arch/x86/kernel/tracepoint.c b/arch/x86/kernel/tracepoint.c
27456 index 1c113db..287b42e 100644
27457 --- a/arch/x86/kernel/tracepoint.c
27458 +++ b/arch/x86/kernel/tracepoint.c
27459 @@ -9,11 +9,11 @@
27460 #include <linux/atomic.h>
27461
27462 atomic_t trace_idt_ctr = ATOMIC_INIT(0);
27463 -struct desc_ptr trace_idt_descr = { NR_VECTORS * 16 - 1,
27464 +const struct desc_ptr trace_idt_descr = { NR_VECTORS * 16 - 1,
27465 (unsigned long) trace_idt_table };
27466
27467 /* No need to be aligned, but done to keep all IDTs defined the same way. */
27468 -gate_desc trace_idt_table[NR_VECTORS] __page_aligned_bss;
27469 +gate_desc trace_idt_table[NR_VECTORS] __page_aligned_rodata;
27470
27471 static int trace_irq_vector_refcount;
27472 static DEFINE_MUTEX(irq_vector_mutex);
27473 diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c
27474 index f73b5d4..0adcc9a 100644
27475 --- a/arch/x86/kernel/traps.c
27476 +++ b/arch/x86/kernel/traps.c
27477 @@ -66,7 +66,7 @@
27478 #include <asm/proto.h>
27479
27480 /* No need to be aligned, but done to keep all IDTs defined the same way. */
27481 -gate_desc debug_idt_table[NR_VECTORS] __page_aligned_bss;
27482 +gate_desc debug_idt_table[NR_VECTORS] __page_aligned_rodata;
27483 #else
27484 #include <asm/processor-flags.h>
27485 #include <asm/setup.h>
27486 @@ -75,7 +75,7 @@ asmlinkage int system_call(void);
27487 #endif
27488
27489 /* Must be page-aligned because the real IDT is used in a fixmap. */
27490 -gate_desc idt_table[NR_VECTORS] __page_aligned_bss;
27491 +gate_desc idt_table[NR_VECTORS] __page_aligned_rodata;
27492
27493 DECLARE_BITMAP(used_vectors, NR_VECTORS);
27494 EXPORT_SYMBOL_GPL(used_vectors);
27495 @@ -107,11 +107,11 @@ static inline void preempt_conditional_cli(struct pt_regs *regs)
27496 }
27497
27498 static int __kprobes
27499 -do_trap_no_signal(struct task_struct *tsk, int trapnr, char *str,
27500 +do_trap_no_signal(struct task_struct *tsk, int trapnr, const char *str,
27501 struct pt_regs *regs, long error_code)
27502 {
27503 #ifdef CONFIG_X86_32
27504 - if (regs->flags & X86_VM_MASK) {
27505 + if (v8086_mode(regs)) {
27506 /*
27507 * Traps 0, 1, 3, 4, and 5 should be forwarded to vm86.
27508 * On nmi (interrupt 2), do_trap should not be called.
27509 @@ -124,12 +124,24 @@ do_trap_no_signal(struct task_struct *tsk, int trapnr, char *str,
27510 return -1;
27511 }
27512 #endif
27513 - if (!user_mode(regs)) {
27514 + if (!user_mode_novm(regs)) {
27515 if (!fixup_exception(regs)) {
27516 tsk->thread.error_code = error_code;
27517 tsk->thread.trap_nr = trapnr;
27518 +
27519 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
27520 + if (trapnr == X86_TRAP_SS && ((regs->cs & 0xFFFF) == __KERNEL_CS || (regs->cs & 0xFFFF) == __KERNEXEC_KERNEL_CS))
27521 + str = "PAX: suspicious stack segment fault";
27522 +#endif
27523 +
27524 die(str, regs, error_code);
27525 }
27526 +
27527 +#ifdef CONFIG_PAX_REFCOUNT
27528 + if (trapnr == X86_TRAP_OF)
27529 + pax_report_refcount_overflow(regs);
27530 +#endif
27531 +
27532 return 0;
27533 }
27534
27535 @@ -137,7 +149,7 @@ do_trap_no_signal(struct task_struct *tsk, int trapnr, char *str,
27536 }
27537
27538 static void __kprobes
27539 -do_trap(int trapnr, int signr, char *str, struct pt_regs *regs,
27540 +do_trap(int trapnr, int signr, const char *str, struct pt_regs *regs,
27541 long error_code, siginfo_t *info)
27542 {
27543 struct task_struct *tsk = current;
27544 @@ -161,7 +173,7 @@ do_trap(int trapnr, int signr, char *str, struct pt_regs *regs,
27545 if (show_unhandled_signals && unhandled_signal(tsk, signr) &&
27546 printk_ratelimit()) {
27547 pr_info("%s[%d] trap %s ip:%lx sp:%lx error:%lx",
27548 - tsk->comm, tsk->pid, str,
27549 + tsk->comm, task_pid_nr(tsk), str,
27550 regs->ip, regs->sp, error_code);
27551 print_vma_addr(" in ", regs->ip);
27552 pr_cont("\n");
27553 @@ -251,6 +263,11 @@ dotraplinkage void do_double_fault(struct pt_regs *regs, long error_code)
27554 tsk->thread.error_code = error_code;
27555 tsk->thread.trap_nr = X86_TRAP_DF;
27556
27557 +#ifdef CONFIG_GRKERNSEC_KSTACKOVERFLOW
27558 + if ((unsigned long)tsk->stack - regs->sp <= PAGE_SIZE)
27559 + die("grsec: kernel stack overflow detected", regs, error_code);
27560 +#endif
27561 +
27562 #ifdef CONFIG_DOUBLEFAULT
27563 df_debug(regs, error_code);
27564 #endif
27565 @@ -273,7 +290,7 @@ do_general_protection(struct pt_regs *regs, long error_code)
27566 conditional_sti(regs);
27567
27568 #ifdef CONFIG_X86_32
27569 - if (regs->flags & X86_VM_MASK) {
27570 + if (v8086_mode(regs)) {
27571 local_irq_enable();
27572 handle_vm86_fault((struct kernel_vm86_regs *) regs, error_code);
27573 goto exit;
27574 @@ -281,18 +298,42 @@ do_general_protection(struct pt_regs *regs, long error_code)
27575 #endif
27576
27577 tsk = current;
27578 - if (!user_mode(regs)) {
27579 + if (!user_mode_novm(regs)) {
27580 if (fixup_exception(regs))
27581 goto exit;
27582
27583 tsk->thread.error_code = error_code;
27584 tsk->thread.trap_nr = X86_TRAP_GP;
27585 if (notify_die(DIE_GPF, "general protection fault", regs, error_code,
27586 - X86_TRAP_GP, SIGSEGV) != NOTIFY_STOP)
27587 + X86_TRAP_GP, SIGSEGV) != NOTIFY_STOP) {
27588 +
27589 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
27590 + if ((regs->cs & 0xFFFF) == __KERNEL_CS || (regs->cs & 0xFFFF) == __KERNEXEC_KERNEL_CS)
27591 + die("PAX: suspicious general protection fault", regs, error_code);
27592 + else
27593 +#endif
27594 +
27595 die("general protection fault", regs, error_code);
27596 + }
27597 goto exit;
27598 }
27599
27600 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
27601 + if (!(__supported_pte_mask & _PAGE_NX) && tsk->mm && (tsk->mm->pax_flags & MF_PAX_PAGEEXEC)) {
27602 + struct mm_struct *mm = tsk->mm;
27603 + unsigned long limit;
27604 +
27605 + down_write(&mm->mmap_sem);
27606 + limit = mm->context.user_cs_limit;
27607 + if (limit < TASK_SIZE) {
27608 + track_exec_limit(mm, limit, TASK_SIZE, VM_EXEC);
27609 + up_write(&mm->mmap_sem);
27610 + return;
27611 + }
27612 + up_write(&mm->mmap_sem);
27613 + }
27614 +#endif
27615 +
27616 tsk->thread.error_code = error_code;
27617 tsk->thread.trap_nr = X86_TRAP_GP;
27618
27619 @@ -453,7 +494,7 @@ dotraplinkage void __kprobes do_debug(struct pt_regs *regs, long error_code)
27620 /* It's safe to allow irq's after DR6 has been saved */
27621 preempt_conditional_sti(regs);
27622
27623 - if (regs->flags & X86_VM_MASK) {
27624 + if (v8086_mode(regs)) {
27625 handle_vm86_trap((struct kernel_vm86_regs *) regs, error_code,
27626 X86_TRAP_DB);
27627 preempt_conditional_cli(regs);
27628 @@ -468,7 +509,7 @@ dotraplinkage void __kprobes do_debug(struct pt_regs *regs, long error_code)
27629 * We already checked v86 mode above, so we can check for kernel mode
27630 * by just checking the CPL of CS.
27631 */
27632 - if ((dr6 & DR_STEP) && !user_mode(regs)) {
27633 + if ((dr6 & DR_STEP) && !user_mode_novm(regs)) {
27634 tsk->thread.debugreg6 &= ~DR_STEP;
27635 set_tsk_thread_flag(tsk, TIF_SINGLESTEP);
27636 regs->flags &= ~X86_EFLAGS_TF;
27637 @@ -500,7 +541,7 @@ void math_error(struct pt_regs *regs, int error_code, int trapnr)
27638 return;
27639 conditional_sti(regs);
27640
27641 - if (!user_mode_vm(regs))
27642 + if (!user_mode(regs))
27643 {
27644 if (!fixup_exception(regs)) {
27645 task->thread.error_code = error_code;
27646 diff --git a/arch/x86/kernel/tsc.c b/arch/x86/kernel/tsc.c
27647 index 57e5ce1..20b0040 100644
27648 --- a/arch/x86/kernel/tsc.c
27649 +++ b/arch/x86/kernel/tsc.c
27650 @@ -150,7 +150,7 @@ static void cyc2ns_write_end(int cpu, struct cyc2ns_data *data)
27651 */
27652 smp_wmb();
27653
27654 - ACCESS_ONCE(c2n->head) = data;
27655 + ACCESS_ONCE_RW(c2n->head) = data;
27656 }
27657
27658 /*
27659 diff --git a/arch/x86/kernel/uprobes.c b/arch/x86/kernel/uprobes.c
27660 index 2ed8459..7cf329f 100644
27661 --- a/arch/x86/kernel/uprobes.c
27662 +++ b/arch/x86/kernel/uprobes.c
27663 @@ -629,7 +629,7 @@ int arch_uprobe_exception_notify(struct notifier_block *self, unsigned long val,
27664 int ret = NOTIFY_DONE;
27665
27666 /* We are only interested in userspace traps */
27667 - if (regs && !user_mode_vm(regs))
27668 + if (regs && !user_mode(regs))
27669 return NOTIFY_DONE;
27670
27671 switch (val) {
27672 @@ -719,7 +719,7 @@ arch_uretprobe_hijack_return_addr(unsigned long trampoline_vaddr, struct pt_regs
27673
27674 if (ncopied != rasize) {
27675 pr_err("uprobe: return address clobbered: pid=%d, %%sp=%#lx, "
27676 - "%%ip=%#lx\n", current->pid, regs->sp, regs->ip);
27677 + "%%ip=%#lx\n", task_pid_nr(current), regs->sp, regs->ip);
27678
27679 force_sig_info(SIGSEGV, SEND_SIG_FORCED, current);
27680 }
27681 diff --git a/arch/x86/kernel/verify_cpu.S b/arch/x86/kernel/verify_cpu.S
27682 index b9242ba..50c5edd 100644
27683 --- a/arch/x86/kernel/verify_cpu.S
27684 +++ b/arch/x86/kernel/verify_cpu.S
27685 @@ -20,6 +20,7 @@
27686 * arch/x86/boot/compressed/head_64.S: Boot cpu verification
27687 * arch/x86/kernel/trampoline_64.S: secondary processor verification
27688 * arch/x86/kernel/head_32.S: processor startup
27689 + * arch/x86/kernel/acpi/realmode/wakeup.S: 32bit processor resume
27690 *
27691 * verify_cpu, returns the status of longmode and SSE in register %eax.
27692 * 0: Success 1: Failure
27693 diff --git a/arch/x86/kernel/vm86_32.c b/arch/x86/kernel/vm86_32.c
27694 index e8edcf5..27f9344 100644
27695 --- a/arch/x86/kernel/vm86_32.c
27696 +++ b/arch/x86/kernel/vm86_32.c
27697 @@ -44,6 +44,7 @@
27698 #include <linux/ptrace.h>
27699 #include <linux/audit.h>
27700 #include <linux/stddef.h>
27701 +#include <linux/grsecurity.h>
27702
27703 #include <asm/uaccess.h>
27704 #include <asm/io.h>
27705 @@ -150,7 +151,7 @@ struct pt_regs *save_v86_state(struct kernel_vm86_regs *regs)
27706 do_exit(SIGSEGV);
27707 }
27708
27709 - tss = &per_cpu(init_tss, get_cpu());
27710 + tss = init_tss + get_cpu();
27711 current->thread.sp0 = current->thread.saved_sp0;
27712 current->thread.sysenter_cs = __KERNEL_CS;
27713 load_sp0(tss, &current->thread);
27714 @@ -214,6 +215,14 @@ SYSCALL_DEFINE1(vm86old, struct vm86_struct __user *, v86)
27715
27716 if (tsk->thread.saved_sp0)
27717 return -EPERM;
27718 +
27719 +#ifdef CONFIG_GRKERNSEC_VM86
27720 + if (!capable(CAP_SYS_RAWIO)) {
27721 + gr_handle_vm86();
27722 + return -EPERM;
27723 + }
27724 +#endif
27725 +
27726 tmp = copy_vm86_regs_from_user(&info.regs, &v86->regs,
27727 offsetof(struct kernel_vm86_struct, vm86plus) -
27728 sizeof(info.regs));
27729 @@ -238,6 +247,13 @@ SYSCALL_DEFINE2(vm86, unsigned long, cmd, unsigned long, arg)
27730 int tmp;
27731 struct vm86plus_struct __user *v86;
27732
27733 +#ifdef CONFIG_GRKERNSEC_VM86
27734 + if (!capable(CAP_SYS_RAWIO)) {
27735 + gr_handle_vm86();
27736 + return -EPERM;
27737 + }
27738 +#endif
27739 +
27740 tsk = current;
27741 switch (cmd) {
27742 case VM86_REQUEST_IRQ:
27743 @@ -318,7 +334,7 @@ static void do_sys_vm86(struct kernel_vm86_struct *info, struct task_struct *tsk
27744 tsk->thread.saved_fs = info->regs32->fs;
27745 tsk->thread.saved_gs = get_user_gs(info->regs32);
27746
27747 - tss = &per_cpu(init_tss, get_cpu());
27748 + tss = init_tss + get_cpu();
27749 tsk->thread.sp0 = (unsigned long) &info->VM86_TSS_ESP0;
27750 if (cpu_has_sep)
27751 tsk->thread.sysenter_cs = 0;
27752 @@ -525,7 +541,7 @@ static void do_int(struct kernel_vm86_regs *regs, int i,
27753 goto cannot_handle;
27754 if (i == 0x21 && is_revectored(AH(regs), &KVM86->int21_revectored))
27755 goto cannot_handle;
27756 - intr_ptr = (unsigned long __user *) (i << 2);
27757 + intr_ptr = (__force unsigned long __user *) (i << 2);
27758 if (get_user(segoffs, intr_ptr))
27759 goto cannot_handle;
27760 if ((segoffs >> 16) == BIOSSEG)
27761 diff --git a/arch/x86/kernel/vmlinux.lds.S b/arch/x86/kernel/vmlinux.lds.S
27762 index 49edf2d..c0d1362 100644
27763 --- a/arch/x86/kernel/vmlinux.lds.S
27764 +++ b/arch/x86/kernel/vmlinux.lds.S
27765 @@ -26,6 +26,13 @@
27766 #include <asm/page_types.h>
27767 #include <asm/cache.h>
27768 #include <asm/boot.h>
27769 +#include <asm/segment.h>
27770 +
27771 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
27772 +#define __KERNEL_TEXT_OFFSET (LOAD_OFFSET + ____LOAD_PHYSICAL_ADDR)
27773 +#else
27774 +#define __KERNEL_TEXT_OFFSET 0
27775 +#endif
27776
27777 #undef i386 /* in case the preprocessor is a 32bit one */
27778
27779 @@ -69,30 +76,43 @@ jiffies_64 = jiffies;
27780
27781 PHDRS {
27782 text PT_LOAD FLAGS(5); /* R_E */
27783 +#ifdef CONFIG_X86_32
27784 + module PT_LOAD FLAGS(5); /* R_E */
27785 +#endif
27786 +#ifdef CONFIG_XEN
27787 + rodata PT_LOAD FLAGS(5); /* R_E */
27788 +#else
27789 + rodata PT_LOAD FLAGS(4); /* R__ */
27790 +#endif
27791 data PT_LOAD FLAGS(6); /* RW_ */
27792 -#ifdef CONFIG_X86_64
27793 + init.begin PT_LOAD FLAGS(6); /* RW_ */
27794 #ifdef CONFIG_SMP
27795 percpu PT_LOAD FLAGS(6); /* RW_ */
27796 #endif
27797 + text.init PT_LOAD FLAGS(5); /* R_E */
27798 + text.exit PT_LOAD FLAGS(5); /* R_E */
27799 init PT_LOAD FLAGS(7); /* RWE */
27800 -#endif
27801 note PT_NOTE FLAGS(0); /* ___ */
27802 }
27803
27804 SECTIONS
27805 {
27806 #ifdef CONFIG_X86_32
27807 - . = LOAD_OFFSET + LOAD_PHYSICAL_ADDR;
27808 - phys_startup_32 = startup_32 - LOAD_OFFSET;
27809 + . = LOAD_OFFSET + ____LOAD_PHYSICAL_ADDR;
27810 #else
27811 - . = __START_KERNEL;
27812 - phys_startup_64 = startup_64 - LOAD_OFFSET;
27813 + . = __START_KERNEL;
27814 #endif
27815
27816 /* Text and read-only data */
27817 - .text : AT(ADDR(.text) - LOAD_OFFSET) {
27818 - _text = .;
27819 + .text (. - __KERNEL_TEXT_OFFSET): AT(ADDR(.text) - LOAD_OFFSET + __KERNEL_TEXT_OFFSET) {
27820 /* bootstrapping code */
27821 +#ifdef CONFIG_X86_32
27822 + phys_startup_32 = startup_32 - LOAD_OFFSET + __KERNEL_TEXT_OFFSET;
27823 +#else
27824 + phys_startup_64 = startup_64 - LOAD_OFFSET + __KERNEL_TEXT_OFFSET;
27825 +#endif
27826 + __LOAD_PHYSICAL_ADDR = . - LOAD_OFFSET + __KERNEL_TEXT_OFFSET;
27827 + _text = .;
27828 HEAD_TEXT
27829 . = ALIGN(8);
27830 _stext = .;
27831 @@ -104,13 +124,47 @@ SECTIONS
27832 IRQENTRY_TEXT
27833 *(.fixup)
27834 *(.gnu.warning)
27835 - /* End of text section */
27836 - _etext = .;
27837 } :text = 0x9090
27838
27839 - NOTES :text :note
27840 + . += __KERNEL_TEXT_OFFSET;
27841
27842 - EXCEPTION_TABLE(16) :text = 0x9090
27843 +#ifdef CONFIG_X86_32
27844 + . = ALIGN(PAGE_SIZE);
27845 + .module.text : AT(ADDR(.module.text) - LOAD_OFFSET) {
27846 +
27847 +#ifdef CONFIG_PAX_KERNEXEC
27848 + MODULES_EXEC_VADDR = .;
27849 + BYTE(0)
27850 + . += (CONFIG_PAX_KERNEXEC_MODULE_TEXT * 1024 * 1024);
27851 + . = ALIGN(HPAGE_SIZE) - 1;
27852 + MODULES_EXEC_END = .;
27853 +#endif
27854 +
27855 + } :module
27856 +#endif
27857 +
27858 + .text.end : AT(ADDR(.text.end) - LOAD_OFFSET) {
27859 + /* End of text section */
27860 + BYTE(0)
27861 + _etext = . - __KERNEL_TEXT_OFFSET;
27862 + }
27863 +
27864 +#ifdef CONFIG_X86_32
27865 + . = ALIGN(PAGE_SIZE);
27866 + .rodata.page_aligned : AT(ADDR(.rodata.page_aligned) - LOAD_OFFSET) {
27867 + . = ALIGN(PAGE_SIZE);
27868 + *(.empty_zero_page)
27869 + *(.initial_pg_fixmap)
27870 + *(.initial_pg_pmd)
27871 + *(.initial_page_table)
27872 + *(.swapper_pg_dir)
27873 + } :rodata
27874 +#endif
27875 +
27876 + . = ALIGN(PAGE_SIZE);
27877 + NOTES :rodata :note
27878 +
27879 + EXCEPTION_TABLE(16) :rodata
27880
27881 #if defined(CONFIG_DEBUG_RODATA)
27882 /* .text should occupy whole number of pages */
27883 @@ -122,16 +176,20 @@ SECTIONS
27884
27885 /* Data */
27886 .data : AT(ADDR(.data) - LOAD_OFFSET) {
27887 +
27888 +#ifdef CONFIG_PAX_KERNEXEC
27889 + . = ALIGN(HPAGE_SIZE);
27890 +#else
27891 + . = ALIGN(PAGE_SIZE);
27892 +#endif
27893 +
27894 /* Start of data section */
27895 _sdata = .;
27896
27897 /* init_task */
27898 INIT_TASK_DATA(THREAD_SIZE)
27899
27900 -#ifdef CONFIG_X86_32
27901 - /* 32 bit has nosave before _edata */
27902 NOSAVE_DATA
27903 -#endif
27904
27905 PAGE_ALIGNED_DATA(PAGE_SIZE)
27906
27907 @@ -174,12 +232,19 @@ SECTIONS
27908 . = ALIGN(__vvar_page + PAGE_SIZE, PAGE_SIZE);
27909
27910 /* Init code and data - will be freed after init */
27911 - . = ALIGN(PAGE_SIZE);
27912 .init.begin : AT(ADDR(.init.begin) - LOAD_OFFSET) {
27913 + BYTE(0)
27914 +
27915 +#ifdef CONFIG_PAX_KERNEXEC
27916 + . = ALIGN(HPAGE_SIZE);
27917 +#else
27918 + . = ALIGN(PAGE_SIZE);
27919 +#endif
27920 +
27921 __init_begin = .; /* paired with __init_end */
27922 - }
27923 + } :init.begin
27924
27925 -#if defined(CONFIG_X86_64) && defined(CONFIG_SMP)
27926 +#ifdef CONFIG_SMP
27927 /*
27928 * percpu offsets are zero-based on SMP. PERCPU_VADDR() changes the
27929 * output PHDR, so the next output section - .init.text - should
27930 @@ -188,12 +253,27 @@ SECTIONS
27931 PERCPU_VADDR(INTERNODE_CACHE_BYTES, 0, :percpu)
27932 #endif
27933
27934 - INIT_TEXT_SECTION(PAGE_SIZE)
27935 -#ifdef CONFIG_X86_64
27936 - :init
27937 -#endif
27938 + . = ALIGN(PAGE_SIZE);
27939 + init_begin = .;
27940 + .init.text (. - __KERNEL_TEXT_OFFSET): AT(init_begin - LOAD_OFFSET) {
27941 + VMLINUX_SYMBOL(_sinittext) = .;
27942 + INIT_TEXT
27943 + VMLINUX_SYMBOL(_einittext) = .;
27944 + . = ALIGN(PAGE_SIZE);
27945 + } :text.init
27946
27947 - INIT_DATA_SECTION(16)
27948 + /*
27949 + * .exit.text is discard at runtime, not link time, to deal with
27950 + * references from .altinstructions and .eh_frame
27951 + */
27952 + .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET + __KERNEL_TEXT_OFFSET) {
27953 + EXIT_TEXT
27954 + . = ALIGN(16);
27955 + } :text.exit
27956 + . = init_begin + SIZEOF(.init.text) + SIZEOF(.exit.text);
27957 +
27958 + . = ALIGN(PAGE_SIZE);
27959 + INIT_DATA_SECTION(16) :init
27960
27961 .x86_cpu_dev.init : AT(ADDR(.x86_cpu_dev.init) - LOAD_OFFSET) {
27962 __x86_cpu_dev_start = .;
27963 @@ -264,19 +344,12 @@ SECTIONS
27964 }
27965
27966 . = ALIGN(8);
27967 - /*
27968 - * .exit.text is discard at runtime, not link time, to deal with
27969 - * references from .altinstructions and .eh_frame
27970 - */
27971 - .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET) {
27972 - EXIT_TEXT
27973 - }
27974
27975 .exit.data : AT(ADDR(.exit.data) - LOAD_OFFSET) {
27976 EXIT_DATA
27977 }
27978
27979 -#if !defined(CONFIG_X86_64) || !defined(CONFIG_SMP)
27980 +#ifndef CONFIG_SMP
27981 PERCPU_SECTION(INTERNODE_CACHE_BYTES)
27982 #endif
27983
27984 @@ -295,16 +368,10 @@ SECTIONS
27985 .smp_locks : AT(ADDR(.smp_locks) - LOAD_OFFSET) {
27986 __smp_locks = .;
27987 *(.smp_locks)
27988 - . = ALIGN(PAGE_SIZE);
27989 __smp_locks_end = .;
27990 + . = ALIGN(PAGE_SIZE);
27991 }
27992
27993 -#ifdef CONFIG_X86_64
27994 - .data_nosave : AT(ADDR(.data_nosave) - LOAD_OFFSET) {
27995 - NOSAVE_DATA
27996 - }
27997 -#endif
27998 -
27999 /* BSS */
28000 . = ALIGN(PAGE_SIZE);
28001 .bss : AT(ADDR(.bss) - LOAD_OFFSET) {
28002 @@ -320,6 +387,7 @@ SECTIONS
28003 __brk_base = .;
28004 . += 64 * 1024; /* 64k alignment slop space */
28005 *(.brk_reservation) /* areas brk users have reserved */
28006 + . = ALIGN(HPAGE_SIZE);
28007 __brk_limit = .;
28008 }
28009
28010 @@ -346,13 +414,12 @@ SECTIONS
28011 * for the boot processor.
28012 */
28013 #define INIT_PER_CPU(x) init_per_cpu__##x = x + __per_cpu_load
28014 -INIT_PER_CPU(gdt_page);
28015 INIT_PER_CPU(irq_stack_union);
28016
28017 /*
28018 * Build-time check on the image size:
28019 */
28020 -. = ASSERT((_end - _text <= KERNEL_IMAGE_SIZE),
28021 +. = ASSERT((_end - _text - __KERNEL_TEXT_OFFSET <= KERNEL_IMAGE_SIZE),
28022 "kernel image bigger than KERNEL_IMAGE_SIZE");
28023
28024 #ifdef CONFIG_SMP
28025 diff --git a/arch/x86/kernel/vsyscall_64.c b/arch/x86/kernel/vsyscall_64.c
28026 index 8b3b3eb..9395aa9 100644
28027 --- a/arch/x86/kernel/vsyscall_64.c
28028 +++ b/arch/x86/kernel/vsyscall_64.c
28029 @@ -54,15 +54,13 @@
28030
28031 DEFINE_VVAR(int, vgetcpu_mode);
28032
28033 -static enum { EMULATE, NATIVE, NONE } vsyscall_mode = EMULATE;
28034 +static enum { EMULATE, NONE } vsyscall_mode = EMULATE;
28035
28036 static int __init vsyscall_setup(char *str)
28037 {
28038 if (str) {
28039 if (!strcmp("emulate", str))
28040 vsyscall_mode = EMULATE;
28041 - else if (!strcmp("native", str))
28042 - vsyscall_mode = NATIVE;
28043 else if (!strcmp("none", str))
28044 vsyscall_mode = NONE;
28045 else
28046 @@ -279,8 +277,7 @@ do_ret:
28047 return true;
28048
28049 sigsegv:
28050 - force_sig(SIGSEGV, current);
28051 - return true;
28052 + do_group_exit(SIGKILL);
28053 }
28054
28055 /*
28056 @@ -332,10 +329,7 @@ void __init map_vsyscall(void)
28057 unsigned long physaddr_vsyscall = __pa_symbol(&__vsyscall_page);
28058 unsigned long physaddr_vvar_page = __pa_symbol(&__vvar_page);
28059
28060 - __set_fixmap(VSYSCALL_FIRST_PAGE, physaddr_vsyscall,
28061 - vsyscall_mode == NATIVE
28062 - ? PAGE_KERNEL_VSYSCALL
28063 - : PAGE_KERNEL_VVAR);
28064 + __set_fixmap(VSYSCALL_FIRST_PAGE, physaddr_vsyscall, PAGE_KERNEL_VVAR);
28065 BUILD_BUG_ON((unsigned long)__fix_to_virt(VSYSCALL_FIRST_PAGE) !=
28066 (unsigned long)VSYSCALL_START);
28067
28068 diff --git a/arch/x86/kernel/x8664_ksyms_64.c b/arch/x86/kernel/x8664_ksyms_64.c
28069 index 04068192..4d75aa6 100644
28070 --- a/arch/x86/kernel/x8664_ksyms_64.c
28071 +++ b/arch/x86/kernel/x8664_ksyms_64.c
28072 @@ -34,8 +34,6 @@ EXPORT_SYMBOL(copy_user_generic_string);
28073 EXPORT_SYMBOL(copy_user_generic_unrolled);
28074 EXPORT_SYMBOL(copy_user_enhanced_fast_string);
28075 EXPORT_SYMBOL(__copy_user_nocache);
28076 -EXPORT_SYMBOL(_copy_from_user);
28077 -EXPORT_SYMBOL(_copy_to_user);
28078
28079 EXPORT_SYMBOL(copy_page);
28080 EXPORT_SYMBOL(clear_page);
28081 @@ -73,3 +71,7 @@ EXPORT_SYMBOL(___preempt_schedule);
28082 EXPORT_SYMBOL(___preempt_schedule_context);
28083 #endif
28084 #endif
28085 +
28086 +#ifdef CONFIG_PAX_PER_CPU_PGD
28087 +EXPORT_SYMBOL(cpu_pgd);
28088 +#endif
28089 diff --git a/arch/x86/kernel/x86_init.c b/arch/x86/kernel/x86_init.c
28090 index e48b674..a451dd9 100644
28091 --- a/arch/x86/kernel/x86_init.c
28092 +++ b/arch/x86/kernel/x86_init.c
28093 @@ -93,7 +93,7 @@ struct x86_cpuinit_ops x86_cpuinit = {
28094 static void default_nmi_init(void) { };
28095 static int default_i8042_detect(void) { return 1; };
28096
28097 -struct x86_platform_ops x86_platform = {
28098 +struct x86_platform_ops x86_platform __read_only = {
28099 .calibrate_tsc = native_calibrate_tsc,
28100 .get_wallclock = mach_get_cmos_time,
28101 .set_wallclock = mach_set_rtc_mmss,
28102 @@ -109,7 +109,7 @@ struct x86_platform_ops x86_platform = {
28103 EXPORT_SYMBOL_GPL(x86_platform);
28104
28105 #if defined(CONFIG_PCI_MSI)
28106 -struct x86_msi_ops x86_msi = {
28107 +struct x86_msi_ops x86_msi __read_only = {
28108 .setup_msi_irqs = native_setup_msi_irqs,
28109 .compose_msi_msg = native_compose_msi_msg,
28110 .teardown_msi_irq = native_teardown_msi_irq,
28111 @@ -150,7 +150,7 @@ u32 arch_msix_mask_irq(struct msi_desc *desc, u32 flag)
28112 }
28113 #endif
28114
28115 -struct x86_io_apic_ops x86_io_apic_ops = {
28116 +struct x86_io_apic_ops x86_io_apic_ops __read_only = {
28117 .init = native_io_apic_init_mappings,
28118 .read = native_io_apic_read,
28119 .write = native_io_apic_write,
28120 diff --git a/arch/x86/kernel/xsave.c b/arch/x86/kernel/xsave.c
28121 index a4b451c..8dfe1ad 100644
28122 --- a/arch/x86/kernel/xsave.c
28123 +++ b/arch/x86/kernel/xsave.c
28124 @@ -164,18 +164,18 @@ static inline int save_xstate_epilog(void __user *buf, int ia32_frame)
28125
28126 /* Setup the bytes not touched by the [f]xsave and reserved for SW. */
28127 sw_bytes = ia32_frame ? &fx_sw_reserved_ia32 : &fx_sw_reserved;
28128 - err = __copy_to_user(&x->i387.sw_reserved, sw_bytes, sizeof(*sw_bytes));
28129 + err = __copy_to_user(x->i387.sw_reserved, sw_bytes, sizeof(*sw_bytes));
28130
28131 if (!use_xsave())
28132 return err;
28133
28134 - err |= __put_user(FP_XSTATE_MAGIC2, (__u32 *)(buf + xstate_size));
28135 + err |= __put_user(FP_XSTATE_MAGIC2, (__u32 __user *)(buf + xstate_size));
28136
28137 /*
28138 * Read the xstate_bv which we copied (directly from the cpu or
28139 * from the state in task struct) to the user buffers.
28140 */
28141 - err |= __get_user(xstate_bv, (__u32 *)&x->xsave_hdr.xstate_bv);
28142 + err |= __get_user(xstate_bv, (__u32 __user *)&x->xsave_hdr.xstate_bv);
28143
28144 /*
28145 * For legacy compatible, we always set FP/SSE bits in the bit
28146 @@ -190,7 +190,7 @@ static inline int save_xstate_epilog(void __user *buf, int ia32_frame)
28147 */
28148 xstate_bv |= XSTATE_FPSSE;
28149
28150 - err |= __put_user(xstate_bv, (__u32 *)&x->xsave_hdr.xstate_bv);
28151 + err |= __put_user(xstate_bv, (__u32 __user *)&x->xsave_hdr.xstate_bv);
28152
28153 return err;
28154 }
28155 @@ -199,6 +199,7 @@ static inline int save_user_xstate(struct xsave_struct __user *buf)
28156 {
28157 int err;
28158
28159 + buf = (struct xsave_struct __user *)____m(buf);
28160 if (use_xsave())
28161 err = xsave_user(buf);
28162 else if (use_fxsr())
28163 @@ -311,6 +312,7 @@ sanitize_restored_xstate(struct task_struct *tsk,
28164 */
28165 static inline int restore_user_xstate(void __user *buf, u64 xbv, int fx_only)
28166 {
28167 + buf = (void __user *)____m(buf);
28168 if (use_xsave()) {
28169 if ((unsigned long)buf % 64 || fx_only) {
28170 u64 init_bv = pcntxt_mask & ~XSTATE_FPSSE;
28171 diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
28172 index f47a104..5ce59a8 100644
28173 --- a/arch/x86/kvm/cpuid.c
28174 +++ b/arch/x86/kvm/cpuid.c
28175 @@ -166,15 +166,20 @@ int kvm_vcpu_ioctl_set_cpuid2(struct kvm_vcpu *vcpu,
28176 struct kvm_cpuid2 *cpuid,
28177 struct kvm_cpuid_entry2 __user *entries)
28178 {
28179 - int r;
28180 + int r, i;
28181
28182 r = -E2BIG;
28183 if (cpuid->nent > KVM_MAX_CPUID_ENTRIES)
28184 goto out;
28185 r = -EFAULT;
28186 - if (copy_from_user(&vcpu->arch.cpuid_entries, entries,
28187 - cpuid->nent * sizeof(struct kvm_cpuid_entry2)))
28188 + if (!access_ok(VERIFY_READ, entries, cpuid->nent * sizeof(struct kvm_cpuid_entry2)))
28189 goto out;
28190 + for (i = 0; i < cpuid->nent; ++i) {
28191 + struct kvm_cpuid_entry2 cpuid_entry;
28192 + if (__copy_from_user(&cpuid_entry, entries + i, sizeof(cpuid_entry)))
28193 + goto out;
28194 + vcpu->arch.cpuid_entries[i] = cpuid_entry;
28195 + }
28196 vcpu->arch.cpuid_nent = cpuid->nent;
28197 kvm_apic_set_version(vcpu);
28198 kvm_x86_ops->cpuid_update(vcpu);
28199 @@ -189,15 +194,19 @@ int kvm_vcpu_ioctl_get_cpuid2(struct kvm_vcpu *vcpu,
28200 struct kvm_cpuid2 *cpuid,
28201 struct kvm_cpuid_entry2 __user *entries)
28202 {
28203 - int r;
28204 + int r, i;
28205
28206 r = -E2BIG;
28207 if (cpuid->nent < vcpu->arch.cpuid_nent)
28208 goto out;
28209 r = -EFAULT;
28210 - if (copy_to_user(entries, &vcpu->arch.cpuid_entries,
28211 - vcpu->arch.cpuid_nent * sizeof(struct kvm_cpuid_entry2)))
28212 + if (!access_ok(VERIFY_WRITE, entries, vcpu->arch.cpuid_nent * sizeof(struct kvm_cpuid_entry2)))
28213 goto out;
28214 + for (i = 0; i < vcpu->arch.cpuid_nent; ++i) {
28215 + struct kvm_cpuid_entry2 cpuid_entry = vcpu->arch.cpuid_entries[i];
28216 + if (__copy_to_user(entries + i, &cpuid_entry, sizeof(cpuid_entry)))
28217 + goto out;
28218 + }
28219 return 0;
28220
28221 out:
28222 diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
28223 index 9736529..ab4f54c 100644
28224 --- a/arch/x86/kvm/lapic.c
28225 +++ b/arch/x86/kvm/lapic.c
28226 @@ -55,7 +55,7 @@
28227 #define APIC_BUS_CYCLE_NS 1
28228
28229 /* #define apic_debug(fmt,arg...) printk(KERN_WARNING fmt,##arg) */
28230 -#define apic_debug(fmt, arg...)
28231 +#define apic_debug(fmt, arg...) do {} while (0)
28232
28233 #define APIC_LVT_NUM 6
28234 /* 14 is the version for Xeon and Pentium 8.4.8*/
28235 diff --git a/arch/x86/kvm/paging_tmpl.h b/arch/x86/kvm/paging_tmpl.h
28236 index 123efd3..ad7726e 100644
28237 --- a/arch/x86/kvm/paging_tmpl.h
28238 +++ b/arch/x86/kvm/paging_tmpl.h
28239 @@ -331,7 +331,7 @@ retry_walk:
28240 if (unlikely(kvm_is_error_hva(host_addr)))
28241 goto error;
28242
28243 - ptep_user = (pt_element_t __user *)((void *)host_addr + offset);
28244 + ptep_user = (pt_element_t __force_user *)((void *)host_addr + offset);
28245 if (unlikely(__copy_from_user(&pte, ptep_user, sizeof(pte))))
28246 goto error;
28247 walker->ptep_user[walker->level - 1] = ptep_user;
28248 diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
28249 index 7f4f9c2..67b1db0 100644
28250 --- a/arch/x86/kvm/svm.c
28251 +++ b/arch/x86/kvm/svm.c
28252 @@ -3535,7 +3535,11 @@ static void reload_tss(struct kvm_vcpu *vcpu)
28253 int cpu = raw_smp_processor_id();
28254
28255 struct svm_cpu_data *sd = per_cpu(svm_data, cpu);
28256 +
28257 + pax_open_kernel();
28258 sd->tss_desc->type = 9; /* available 32/64-bit TSS */
28259 + pax_close_kernel();
28260 +
28261 load_TR_desc();
28262 }
28263
28264 @@ -3936,6 +3940,10 @@ static void svm_vcpu_run(struct kvm_vcpu *vcpu)
28265 #endif
28266 #endif
28267
28268 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
28269 + __set_fs(current_thread_info()->addr_limit);
28270 +#endif
28271 +
28272 reload_tss(vcpu);
28273
28274 local_irq_disable();
28275 diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
28276 index 138ceff..2e584f0 100644
28277 --- a/arch/x86/kvm/vmx.c
28278 +++ b/arch/x86/kvm/vmx.c
28279 @@ -1339,12 +1339,12 @@ static void vmcs_write64(unsigned long field, u64 value)
28280 #endif
28281 }
28282
28283 -static void vmcs_clear_bits(unsigned long field, u32 mask)
28284 +static void vmcs_clear_bits(unsigned long field, unsigned long mask)
28285 {
28286 vmcs_writel(field, vmcs_readl(field) & ~mask);
28287 }
28288
28289 -static void vmcs_set_bits(unsigned long field, u32 mask)
28290 +static void vmcs_set_bits(unsigned long field, unsigned long mask)
28291 {
28292 vmcs_writel(field, vmcs_readl(field) | mask);
28293 }
28294 @@ -1604,7 +1604,11 @@ static void reload_tss(void)
28295 struct desc_struct *descs;
28296
28297 descs = (void *)gdt->address;
28298 +
28299 + pax_open_kernel();
28300 descs[GDT_ENTRY_TSS].type = 9; /* available TSS */
28301 + pax_close_kernel();
28302 +
28303 load_TR_desc();
28304 }
28305
28306 @@ -1832,6 +1836,10 @@ static void vmx_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
28307 vmcs_writel(HOST_TR_BASE, kvm_read_tr_base()); /* 22.2.4 */
28308 vmcs_writel(HOST_GDTR_BASE, gdt->address); /* 22.2.4 */
28309
28310 +#ifdef CONFIG_PAX_PER_CPU_PGD
28311 + vmcs_writel(HOST_CR3, read_cr3()); /* 22.2.3 FIXME: shadow tables */
28312 +#endif
28313 +
28314 rdmsrl(MSR_IA32_SYSENTER_ESP, sysenter_esp);
28315 vmcs_writel(HOST_IA32_SYSENTER_ESP, sysenter_esp); /* 22.2.3 */
28316 vmx->loaded_vmcs->cpu = cpu;
28317 @@ -2121,7 +2129,7 @@ static void setup_msrs(struct vcpu_vmx *vmx)
28318 * reads and returns guest's timestamp counter "register"
28319 * guest_tsc = host_tsc + tsc_offset -- 21.3
28320 */
28321 -static u64 guest_read_tsc(void)
28322 +static u64 __intentional_overflow(-1) guest_read_tsc(void)
28323 {
28324 u64 host_tsc, tsc_offset;
28325
28326 @@ -3093,8 +3101,11 @@ static __init int hardware_setup(void)
28327 if (!cpu_has_vmx_flexpriority())
28328 flexpriority_enabled = 0;
28329
28330 - if (!cpu_has_vmx_tpr_shadow())
28331 - kvm_x86_ops->update_cr8_intercept = NULL;
28332 + if (!cpu_has_vmx_tpr_shadow()) {
28333 + pax_open_kernel();
28334 + *(void **)&kvm_x86_ops->update_cr8_intercept = NULL;
28335 + pax_close_kernel();
28336 + }
28337
28338 if (enable_ept && !cpu_has_vmx_ept_2m_page())
28339 kvm_disable_largepages();
28340 @@ -3105,13 +3116,15 @@ static __init int hardware_setup(void)
28341 if (!cpu_has_vmx_apicv())
28342 enable_apicv = 0;
28343
28344 + pax_open_kernel();
28345 if (enable_apicv)
28346 - kvm_x86_ops->update_cr8_intercept = NULL;
28347 + *(void **)&kvm_x86_ops->update_cr8_intercept = NULL;
28348 else {
28349 - kvm_x86_ops->hwapic_irr_update = NULL;
28350 - kvm_x86_ops->deliver_posted_interrupt = NULL;
28351 - kvm_x86_ops->sync_pir_to_irr = vmx_sync_pir_to_irr_dummy;
28352 + *(void **)&kvm_x86_ops->hwapic_irr_update = NULL;
28353 + *(void **)&kvm_x86_ops->deliver_posted_interrupt = NULL;
28354 + *(void **)&kvm_x86_ops->sync_pir_to_irr = vmx_sync_pir_to_irr_dummy;
28355 }
28356 + pax_close_kernel();
28357
28358 if (nested)
28359 nested_vmx_setup_ctls_msrs();
28360 @@ -4235,7 +4248,10 @@ static void vmx_set_constant_host_state(struct vcpu_vmx *vmx)
28361
28362 vmcs_writel(HOST_CR0, read_cr0() & ~X86_CR0_TS); /* 22.2.3 */
28363 vmcs_writel(HOST_CR4, read_cr4()); /* 22.2.3, 22.2.5 */
28364 +
28365 +#ifndef CONFIG_PAX_PER_CPU_PGD
28366 vmcs_writel(HOST_CR3, read_cr3()); /* 22.2.3 FIXME: shadow tables */
28367 +#endif
28368
28369 vmcs_write16(HOST_CS_SELECTOR, __KERNEL_CS); /* 22.2.4 */
28370 #ifdef CONFIG_X86_64
28371 @@ -4257,7 +4273,7 @@ static void vmx_set_constant_host_state(struct vcpu_vmx *vmx)
28372 vmcs_writel(HOST_IDTR_BASE, dt.address); /* 22.2.4 */
28373 vmx->host_idt_base = dt.address;
28374
28375 - vmcs_writel(HOST_RIP, vmx_return); /* 22.2.5 */
28376 + vmcs_writel(HOST_RIP, ktla_ktva(vmx_return)); /* 22.2.5 */
28377
28378 rdmsr(MSR_IA32_SYSENTER_CS, low32, high32);
28379 vmcs_write32(HOST_IA32_SYSENTER_CS, low32);
28380 @@ -7333,6 +7349,12 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
28381 "jmp 2f \n\t"
28382 "1: " __ex(ASM_VMX_VMRESUME) "\n\t"
28383 "2: "
28384 +
28385 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
28386 + "ljmp %[cs],$3f\n\t"
28387 + "3: "
28388 +#endif
28389 +
28390 /* Save guest registers, load host registers, keep flags */
28391 "mov %0, %c[wordsize](%%" _ASM_SP ") \n\t"
28392 "pop %0 \n\t"
28393 @@ -7385,6 +7407,11 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
28394 #endif
28395 [cr2]"i"(offsetof(struct vcpu_vmx, vcpu.arch.cr2)),
28396 [wordsize]"i"(sizeof(ulong))
28397 +
28398 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
28399 + ,[cs]"i"(__KERNEL_CS)
28400 +#endif
28401 +
28402 : "cc", "memory"
28403 #ifdef CONFIG_X86_64
28404 , "rax", "rbx", "rdi", "rsi"
28405 @@ -7398,7 +7425,7 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
28406 if (debugctlmsr)
28407 update_debugctlmsr(debugctlmsr);
28408
28409 -#ifndef CONFIG_X86_64
28410 +#ifdef CONFIG_X86_32
28411 /*
28412 * The sysexit path does not restore ds/es, so we must set them to
28413 * a reasonable value ourselves.
28414 @@ -7407,8 +7434,18 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
28415 * may be executed in interrupt context, which saves and restore segments
28416 * around it, nullifying its effect.
28417 */
28418 - loadsegment(ds, __USER_DS);
28419 - loadsegment(es, __USER_DS);
28420 + loadsegment(ds, __KERNEL_DS);
28421 + loadsegment(es, __KERNEL_DS);
28422 + loadsegment(ss, __KERNEL_DS);
28423 +
28424 +#ifdef CONFIG_PAX_KERNEXEC
28425 + loadsegment(fs, __KERNEL_PERCPU);
28426 +#endif
28427 +
28428 +#ifdef CONFIG_PAX_MEMORY_UDEREF
28429 + __set_fs(current_thread_info()->addr_limit);
28430 +#endif
28431 +
28432 #endif
28433
28434 vcpu->arch.regs_avail = ~((1 << VCPU_REGS_RIP) | (1 << VCPU_REGS_RSP)
28435 diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
28436 index 20316c6..9b3dddc 100644
28437 --- a/arch/x86/kvm/x86.c
28438 +++ b/arch/x86/kvm/x86.c
28439 @@ -1822,8 +1822,8 @@ static int xen_hvm_config(struct kvm_vcpu *vcpu, u64 data)
28440 {
28441 struct kvm *kvm = vcpu->kvm;
28442 int lm = is_long_mode(vcpu);
28443 - u8 *blob_addr = lm ? (u8 *)(long)kvm->arch.xen_hvm_config.blob_addr_64
28444 - : (u8 *)(long)kvm->arch.xen_hvm_config.blob_addr_32;
28445 + u8 __user *blob_addr = lm ? (u8 __user *)(long)kvm->arch.xen_hvm_config.blob_addr_64
28446 + : (u8 __user *)(long)kvm->arch.xen_hvm_config.blob_addr_32;
28447 u8 blob_size = lm ? kvm->arch.xen_hvm_config.blob_size_64
28448 : kvm->arch.xen_hvm_config.blob_size_32;
28449 u32 page_num = data & ~PAGE_MASK;
28450 @@ -2738,6 +2738,8 @@ long kvm_arch_dev_ioctl(struct file *filp,
28451 if (n < msr_list.nmsrs)
28452 goto out;
28453 r = -EFAULT;
28454 + if (num_msrs_to_save > ARRAY_SIZE(msrs_to_save))
28455 + goto out;
28456 if (copy_to_user(user_msr_list->indices, &msrs_to_save,
28457 num_msrs_to_save * sizeof(u32)))
28458 goto out;
28459 @@ -5574,7 +5576,7 @@ static struct notifier_block pvclock_gtod_notifier = {
28460 };
28461 #endif
28462
28463 -int kvm_arch_init(void *opaque)
28464 +int kvm_arch_init(const void *opaque)
28465 {
28466 int r;
28467 struct kvm_x86_ops *ops = opaque;
28468 diff --git a/arch/x86/lguest/boot.c b/arch/x86/lguest/boot.c
28469 index aae9413..d11e829 100644
28470 --- a/arch/x86/lguest/boot.c
28471 +++ b/arch/x86/lguest/boot.c
28472 @@ -1206,9 +1206,10 @@ static __init int early_put_chars(u32 vtermno, const char *buf, int count)
28473 * Rebooting also tells the Host we're finished, but the RESTART flag tells the
28474 * Launcher to reboot us.
28475 */
28476 -static void lguest_restart(char *reason)
28477 +static __noreturn void lguest_restart(char *reason)
28478 {
28479 hcall(LHCALL_SHUTDOWN, __pa(reason), LGUEST_SHUTDOWN_RESTART, 0, 0);
28480 + BUG();
28481 }
28482
28483 /*G:050
28484 diff --git a/arch/x86/lib/atomic64_386_32.S b/arch/x86/lib/atomic64_386_32.S
28485 index 00933d5..3a64af9 100644
28486 --- a/arch/x86/lib/atomic64_386_32.S
28487 +++ b/arch/x86/lib/atomic64_386_32.S
28488 @@ -48,6 +48,10 @@ BEGIN(read)
28489 movl (v), %eax
28490 movl 4(v), %edx
28491 RET_ENDP
28492 +BEGIN(read_unchecked)
28493 + movl (v), %eax
28494 + movl 4(v), %edx
28495 +RET_ENDP
28496 #undef v
28497
28498 #define v %esi
28499 @@ -55,6 +59,10 @@ BEGIN(set)
28500 movl %ebx, (v)
28501 movl %ecx, 4(v)
28502 RET_ENDP
28503 +BEGIN(set_unchecked)
28504 + movl %ebx, (v)
28505 + movl %ecx, 4(v)
28506 +RET_ENDP
28507 #undef v
28508
28509 #define v %esi
28510 @@ -70,6 +78,20 @@ RET_ENDP
28511 BEGIN(add)
28512 addl %eax, (v)
28513 adcl %edx, 4(v)
28514 +
28515 +#ifdef CONFIG_PAX_REFCOUNT
28516 + jno 0f
28517 + subl %eax, (v)
28518 + sbbl %edx, 4(v)
28519 + int $4
28520 +0:
28521 + _ASM_EXTABLE(0b, 0b)
28522 +#endif
28523 +
28524 +RET_ENDP
28525 +BEGIN(add_unchecked)
28526 + addl %eax, (v)
28527 + adcl %edx, 4(v)
28528 RET_ENDP
28529 #undef v
28530
28531 @@ -77,6 +99,24 @@ RET_ENDP
28532 BEGIN(add_return)
28533 addl (v), %eax
28534 adcl 4(v), %edx
28535 +
28536 +#ifdef CONFIG_PAX_REFCOUNT
28537 + into
28538 +1234:
28539 + _ASM_EXTABLE(1234b, 2f)
28540 +#endif
28541 +
28542 + movl %eax, (v)
28543 + movl %edx, 4(v)
28544 +
28545 +#ifdef CONFIG_PAX_REFCOUNT
28546 +2:
28547 +#endif
28548 +
28549 +RET_ENDP
28550 +BEGIN(add_return_unchecked)
28551 + addl (v), %eax
28552 + adcl 4(v), %edx
28553 movl %eax, (v)
28554 movl %edx, 4(v)
28555 RET_ENDP
28556 @@ -86,6 +126,20 @@ RET_ENDP
28557 BEGIN(sub)
28558 subl %eax, (v)
28559 sbbl %edx, 4(v)
28560 +
28561 +#ifdef CONFIG_PAX_REFCOUNT
28562 + jno 0f
28563 + addl %eax, (v)
28564 + adcl %edx, 4(v)
28565 + int $4
28566 +0:
28567 + _ASM_EXTABLE(0b, 0b)
28568 +#endif
28569 +
28570 +RET_ENDP
28571 +BEGIN(sub_unchecked)
28572 + subl %eax, (v)
28573 + sbbl %edx, 4(v)
28574 RET_ENDP
28575 #undef v
28576
28577 @@ -96,6 +150,27 @@ BEGIN(sub_return)
28578 sbbl $0, %edx
28579 addl (v), %eax
28580 adcl 4(v), %edx
28581 +
28582 +#ifdef CONFIG_PAX_REFCOUNT
28583 + into
28584 +1234:
28585 + _ASM_EXTABLE(1234b, 2f)
28586 +#endif
28587 +
28588 + movl %eax, (v)
28589 + movl %edx, 4(v)
28590 +
28591 +#ifdef CONFIG_PAX_REFCOUNT
28592 +2:
28593 +#endif
28594 +
28595 +RET_ENDP
28596 +BEGIN(sub_return_unchecked)
28597 + negl %edx
28598 + negl %eax
28599 + sbbl $0, %edx
28600 + addl (v), %eax
28601 + adcl 4(v), %edx
28602 movl %eax, (v)
28603 movl %edx, 4(v)
28604 RET_ENDP
28605 @@ -105,6 +180,20 @@ RET_ENDP
28606 BEGIN(inc)
28607 addl $1, (v)
28608 adcl $0, 4(v)
28609 +
28610 +#ifdef CONFIG_PAX_REFCOUNT
28611 + jno 0f
28612 + subl $1, (v)
28613 + sbbl $0, 4(v)
28614 + int $4
28615 +0:
28616 + _ASM_EXTABLE(0b, 0b)
28617 +#endif
28618 +
28619 +RET_ENDP
28620 +BEGIN(inc_unchecked)
28621 + addl $1, (v)
28622 + adcl $0, 4(v)
28623 RET_ENDP
28624 #undef v
28625
28626 @@ -114,6 +203,26 @@ BEGIN(inc_return)
28627 movl 4(v), %edx
28628 addl $1, %eax
28629 adcl $0, %edx
28630 +
28631 +#ifdef CONFIG_PAX_REFCOUNT
28632 + into
28633 +1234:
28634 + _ASM_EXTABLE(1234b, 2f)
28635 +#endif
28636 +
28637 + movl %eax, (v)
28638 + movl %edx, 4(v)
28639 +
28640 +#ifdef CONFIG_PAX_REFCOUNT
28641 +2:
28642 +#endif
28643 +
28644 +RET_ENDP
28645 +BEGIN(inc_return_unchecked)
28646 + movl (v), %eax
28647 + movl 4(v), %edx
28648 + addl $1, %eax
28649 + adcl $0, %edx
28650 movl %eax, (v)
28651 movl %edx, 4(v)
28652 RET_ENDP
28653 @@ -123,6 +232,20 @@ RET_ENDP
28654 BEGIN(dec)
28655 subl $1, (v)
28656 sbbl $0, 4(v)
28657 +
28658 +#ifdef CONFIG_PAX_REFCOUNT
28659 + jno 0f
28660 + addl $1, (v)
28661 + adcl $0, 4(v)
28662 + int $4
28663 +0:
28664 + _ASM_EXTABLE(0b, 0b)
28665 +#endif
28666 +
28667 +RET_ENDP
28668 +BEGIN(dec_unchecked)
28669 + subl $1, (v)
28670 + sbbl $0, 4(v)
28671 RET_ENDP
28672 #undef v
28673
28674 @@ -132,6 +255,26 @@ BEGIN(dec_return)
28675 movl 4(v), %edx
28676 subl $1, %eax
28677 sbbl $0, %edx
28678 +
28679 +#ifdef CONFIG_PAX_REFCOUNT
28680 + into
28681 +1234:
28682 + _ASM_EXTABLE(1234b, 2f)
28683 +#endif
28684 +
28685 + movl %eax, (v)
28686 + movl %edx, 4(v)
28687 +
28688 +#ifdef CONFIG_PAX_REFCOUNT
28689 +2:
28690 +#endif
28691 +
28692 +RET_ENDP
28693 +BEGIN(dec_return_unchecked)
28694 + movl (v), %eax
28695 + movl 4(v), %edx
28696 + subl $1, %eax
28697 + sbbl $0, %edx
28698 movl %eax, (v)
28699 movl %edx, 4(v)
28700 RET_ENDP
28701 @@ -143,6 +286,13 @@ BEGIN(add_unless)
28702 adcl %edx, %edi
28703 addl (v), %eax
28704 adcl 4(v), %edx
28705 +
28706 +#ifdef CONFIG_PAX_REFCOUNT
28707 + into
28708 +1234:
28709 + _ASM_EXTABLE(1234b, 2f)
28710 +#endif
28711 +
28712 cmpl %eax, %ecx
28713 je 3f
28714 1:
28715 @@ -168,6 +318,13 @@ BEGIN(inc_not_zero)
28716 1:
28717 addl $1, %eax
28718 adcl $0, %edx
28719 +
28720 +#ifdef CONFIG_PAX_REFCOUNT
28721 + into
28722 +1234:
28723 + _ASM_EXTABLE(1234b, 2f)
28724 +#endif
28725 +
28726 movl %eax, (v)
28727 movl %edx, 4(v)
28728 movl $1, %eax
28729 @@ -186,6 +343,13 @@ BEGIN(dec_if_positive)
28730 movl 4(v), %edx
28731 subl $1, %eax
28732 sbbl $0, %edx
28733 +
28734 +#ifdef CONFIG_PAX_REFCOUNT
28735 + into
28736 +1234:
28737 + _ASM_EXTABLE(1234b, 1f)
28738 +#endif
28739 +
28740 js 1f
28741 movl %eax, (v)
28742 movl %edx, 4(v)
28743 diff --git a/arch/x86/lib/atomic64_cx8_32.S b/arch/x86/lib/atomic64_cx8_32.S
28744 index f5cc9eb..51fa319 100644
28745 --- a/arch/x86/lib/atomic64_cx8_32.S
28746 +++ b/arch/x86/lib/atomic64_cx8_32.S
28747 @@ -35,10 +35,20 @@ ENTRY(atomic64_read_cx8)
28748 CFI_STARTPROC
28749
28750 read64 %ecx
28751 + pax_force_retaddr
28752 ret
28753 CFI_ENDPROC
28754 ENDPROC(atomic64_read_cx8)
28755
28756 +ENTRY(atomic64_read_unchecked_cx8)
28757 + CFI_STARTPROC
28758 +
28759 + read64 %ecx
28760 + pax_force_retaddr
28761 + ret
28762 + CFI_ENDPROC
28763 +ENDPROC(atomic64_read_unchecked_cx8)
28764 +
28765 ENTRY(atomic64_set_cx8)
28766 CFI_STARTPROC
28767
28768 @@ -48,10 +58,25 @@ ENTRY(atomic64_set_cx8)
28769 cmpxchg8b (%esi)
28770 jne 1b
28771
28772 + pax_force_retaddr
28773 ret
28774 CFI_ENDPROC
28775 ENDPROC(atomic64_set_cx8)
28776
28777 +ENTRY(atomic64_set_unchecked_cx8)
28778 + CFI_STARTPROC
28779 +
28780 +1:
28781 +/* we don't need LOCK_PREFIX since aligned 64-bit writes
28782 + * are atomic on 586 and newer */
28783 + cmpxchg8b (%esi)
28784 + jne 1b
28785 +
28786 + pax_force_retaddr
28787 + ret
28788 + CFI_ENDPROC
28789 +ENDPROC(atomic64_set_unchecked_cx8)
28790 +
28791 ENTRY(atomic64_xchg_cx8)
28792 CFI_STARTPROC
28793
28794 @@ -60,12 +85,13 @@ ENTRY(atomic64_xchg_cx8)
28795 cmpxchg8b (%esi)
28796 jne 1b
28797
28798 + pax_force_retaddr
28799 ret
28800 CFI_ENDPROC
28801 ENDPROC(atomic64_xchg_cx8)
28802
28803 -.macro addsub_return func ins insc
28804 -ENTRY(atomic64_\func\()_return_cx8)
28805 +.macro addsub_return func ins insc unchecked=""
28806 +ENTRY(atomic64_\func\()_return\unchecked\()_cx8)
28807 CFI_STARTPROC
28808 SAVE ebp
28809 SAVE ebx
28810 @@ -82,27 +108,44 @@ ENTRY(atomic64_\func\()_return_cx8)
28811 movl %edx, %ecx
28812 \ins\()l %esi, %ebx
28813 \insc\()l %edi, %ecx
28814 +
28815 +.ifb \unchecked
28816 +#ifdef CONFIG_PAX_REFCOUNT
28817 + into
28818 +2:
28819 + _ASM_EXTABLE(2b, 3f)
28820 +#endif
28821 +.endif
28822 +
28823 LOCK_PREFIX
28824 cmpxchg8b (%ebp)
28825 jne 1b
28826 -
28827 -10:
28828 movl %ebx, %eax
28829 movl %ecx, %edx
28830 +
28831 +.ifb \unchecked
28832 +#ifdef CONFIG_PAX_REFCOUNT
28833 +3:
28834 +#endif
28835 +.endif
28836 +
28837 RESTORE edi
28838 RESTORE esi
28839 RESTORE ebx
28840 RESTORE ebp
28841 + pax_force_retaddr
28842 ret
28843 CFI_ENDPROC
28844 -ENDPROC(atomic64_\func\()_return_cx8)
28845 +ENDPROC(atomic64_\func\()_return\unchecked\()_cx8)
28846 .endm
28847
28848 addsub_return add add adc
28849 addsub_return sub sub sbb
28850 +addsub_return add add adc _unchecked
28851 +addsub_return sub sub sbb _unchecked
28852
28853 -.macro incdec_return func ins insc
28854 -ENTRY(atomic64_\func\()_return_cx8)
28855 +.macro incdec_return func ins insc unchecked=""
28856 +ENTRY(atomic64_\func\()_return\unchecked\()_cx8)
28857 CFI_STARTPROC
28858 SAVE ebx
28859
28860 @@ -112,21 +155,39 @@ ENTRY(atomic64_\func\()_return_cx8)
28861 movl %edx, %ecx
28862 \ins\()l $1, %ebx
28863 \insc\()l $0, %ecx
28864 +
28865 +.ifb \unchecked
28866 +#ifdef CONFIG_PAX_REFCOUNT
28867 + into
28868 +2:
28869 + _ASM_EXTABLE(2b, 3f)
28870 +#endif
28871 +.endif
28872 +
28873 LOCK_PREFIX
28874 cmpxchg8b (%esi)
28875 jne 1b
28876
28877 -10:
28878 movl %ebx, %eax
28879 movl %ecx, %edx
28880 +
28881 +.ifb \unchecked
28882 +#ifdef CONFIG_PAX_REFCOUNT
28883 +3:
28884 +#endif
28885 +.endif
28886 +
28887 RESTORE ebx
28888 + pax_force_retaddr
28889 ret
28890 CFI_ENDPROC
28891 -ENDPROC(atomic64_\func\()_return_cx8)
28892 +ENDPROC(atomic64_\func\()_return\unchecked\()_cx8)
28893 .endm
28894
28895 incdec_return inc add adc
28896 incdec_return dec sub sbb
28897 +incdec_return inc add adc _unchecked
28898 +incdec_return dec sub sbb _unchecked
28899
28900 ENTRY(atomic64_dec_if_positive_cx8)
28901 CFI_STARTPROC
28902 @@ -138,6 +199,13 @@ ENTRY(atomic64_dec_if_positive_cx8)
28903 movl %edx, %ecx
28904 subl $1, %ebx
28905 sbb $0, %ecx
28906 +
28907 +#ifdef CONFIG_PAX_REFCOUNT
28908 + into
28909 +1234:
28910 + _ASM_EXTABLE(1234b, 2f)
28911 +#endif
28912 +
28913 js 2f
28914 LOCK_PREFIX
28915 cmpxchg8b (%esi)
28916 @@ -147,6 +215,7 @@ ENTRY(atomic64_dec_if_positive_cx8)
28917 movl %ebx, %eax
28918 movl %ecx, %edx
28919 RESTORE ebx
28920 + pax_force_retaddr
28921 ret
28922 CFI_ENDPROC
28923 ENDPROC(atomic64_dec_if_positive_cx8)
28924 @@ -171,6 +240,13 @@ ENTRY(atomic64_add_unless_cx8)
28925 movl %edx, %ecx
28926 addl %ebp, %ebx
28927 adcl %edi, %ecx
28928 +
28929 +#ifdef CONFIG_PAX_REFCOUNT
28930 + into
28931 +1234:
28932 + _ASM_EXTABLE(1234b, 3f)
28933 +#endif
28934 +
28935 LOCK_PREFIX
28936 cmpxchg8b (%esi)
28937 jne 1b
28938 @@ -181,6 +257,7 @@ ENTRY(atomic64_add_unless_cx8)
28939 CFI_ADJUST_CFA_OFFSET -8
28940 RESTORE ebx
28941 RESTORE ebp
28942 + pax_force_retaddr
28943 ret
28944 4:
28945 cmpl %edx, 4(%esp)
28946 @@ -203,6 +280,13 @@ ENTRY(atomic64_inc_not_zero_cx8)
28947 xorl %ecx, %ecx
28948 addl $1, %ebx
28949 adcl %edx, %ecx
28950 +
28951 +#ifdef CONFIG_PAX_REFCOUNT
28952 + into
28953 +1234:
28954 + _ASM_EXTABLE(1234b, 3f)
28955 +#endif
28956 +
28957 LOCK_PREFIX
28958 cmpxchg8b (%esi)
28959 jne 1b
28960 @@ -210,6 +294,7 @@ ENTRY(atomic64_inc_not_zero_cx8)
28961 movl $1, %eax
28962 3:
28963 RESTORE ebx
28964 + pax_force_retaddr
28965 ret
28966 CFI_ENDPROC
28967 ENDPROC(atomic64_inc_not_zero_cx8)
28968 diff --git a/arch/x86/lib/checksum_32.S b/arch/x86/lib/checksum_32.S
28969 index e78b8ee..7e173a8 100644
28970 --- a/arch/x86/lib/checksum_32.S
28971 +++ b/arch/x86/lib/checksum_32.S
28972 @@ -29,7 +29,8 @@
28973 #include <asm/dwarf2.h>
28974 #include <asm/errno.h>
28975 #include <asm/asm.h>
28976 -
28977 +#include <asm/segment.h>
28978 +
28979 /*
28980 * computes a partial checksum, e.g. for TCP/UDP fragments
28981 */
28982 @@ -293,9 +294,24 @@ unsigned int csum_partial_copy_generic (const char *src, char *dst,
28983
28984 #define ARGBASE 16
28985 #define FP 12
28986 -
28987 -ENTRY(csum_partial_copy_generic)
28988 +
28989 +ENTRY(csum_partial_copy_generic_to_user)
28990 CFI_STARTPROC
28991 +
28992 +#ifdef CONFIG_PAX_MEMORY_UDEREF
28993 + pushl_cfi %gs
28994 + popl_cfi %es
28995 + jmp csum_partial_copy_generic
28996 +#endif
28997 +
28998 +ENTRY(csum_partial_copy_generic_from_user)
28999 +
29000 +#ifdef CONFIG_PAX_MEMORY_UDEREF
29001 + pushl_cfi %gs
29002 + popl_cfi %ds
29003 +#endif
29004 +
29005 +ENTRY(csum_partial_copy_generic)
29006 subl $4,%esp
29007 CFI_ADJUST_CFA_OFFSET 4
29008 pushl_cfi %edi
29009 @@ -317,7 +333,7 @@ ENTRY(csum_partial_copy_generic)
29010 jmp 4f
29011 SRC(1: movw (%esi), %bx )
29012 addl $2, %esi
29013 -DST( movw %bx, (%edi) )
29014 +DST( movw %bx, %es:(%edi) )
29015 addl $2, %edi
29016 addw %bx, %ax
29017 adcl $0, %eax
29018 @@ -329,30 +345,30 @@ DST( movw %bx, (%edi) )
29019 SRC(1: movl (%esi), %ebx )
29020 SRC( movl 4(%esi), %edx )
29021 adcl %ebx, %eax
29022 -DST( movl %ebx, (%edi) )
29023 +DST( movl %ebx, %es:(%edi) )
29024 adcl %edx, %eax
29025 -DST( movl %edx, 4(%edi) )
29026 +DST( movl %edx, %es:4(%edi) )
29027
29028 SRC( movl 8(%esi), %ebx )
29029 SRC( movl 12(%esi), %edx )
29030 adcl %ebx, %eax
29031 -DST( movl %ebx, 8(%edi) )
29032 +DST( movl %ebx, %es:8(%edi) )
29033 adcl %edx, %eax
29034 -DST( movl %edx, 12(%edi) )
29035 +DST( movl %edx, %es:12(%edi) )
29036
29037 SRC( movl 16(%esi), %ebx )
29038 SRC( movl 20(%esi), %edx )
29039 adcl %ebx, %eax
29040 -DST( movl %ebx, 16(%edi) )
29041 +DST( movl %ebx, %es:16(%edi) )
29042 adcl %edx, %eax
29043 -DST( movl %edx, 20(%edi) )
29044 +DST( movl %edx, %es:20(%edi) )
29045
29046 SRC( movl 24(%esi), %ebx )
29047 SRC( movl 28(%esi), %edx )
29048 adcl %ebx, %eax
29049 -DST( movl %ebx, 24(%edi) )
29050 +DST( movl %ebx, %es:24(%edi) )
29051 adcl %edx, %eax
29052 -DST( movl %edx, 28(%edi) )
29053 +DST( movl %edx, %es:28(%edi) )
29054
29055 lea 32(%esi), %esi
29056 lea 32(%edi), %edi
29057 @@ -366,7 +382,7 @@ DST( movl %edx, 28(%edi) )
29058 shrl $2, %edx # This clears CF
29059 SRC(3: movl (%esi), %ebx )
29060 adcl %ebx, %eax
29061 -DST( movl %ebx, (%edi) )
29062 +DST( movl %ebx, %es:(%edi) )
29063 lea 4(%esi), %esi
29064 lea 4(%edi), %edi
29065 dec %edx
29066 @@ -378,12 +394,12 @@ DST( movl %ebx, (%edi) )
29067 jb 5f
29068 SRC( movw (%esi), %cx )
29069 leal 2(%esi), %esi
29070 -DST( movw %cx, (%edi) )
29071 +DST( movw %cx, %es:(%edi) )
29072 leal 2(%edi), %edi
29073 je 6f
29074 shll $16,%ecx
29075 SRC(5: movb (%esi), %cl )
29076 -DST( movb %cl, (%edi) )
29077 +DST( movb %cl, %es:(%edi) )
29078 6: addl %ecx, %eax
29079 adcl $0, %eax
29080 7:
29081 @@ -394,7 +410,7 @@ DST( movb %cl, (%edi) )
29082
29083 6001:
29084 movl ARGBASE+20(%esp), %ebx # src_err_ptr
29085 - movl $-EFAULT, (%ebx)
29086 + movl $-EFAULT, %ss:(%ebx)
29087
29088 # zero the complete destination - computing the rest
29089 # is too much work
29090 @@ -407,11 +423,15 @@ DST( movb %cl, (%edi) )
29091
29092 6002:
29093 movl ARGBASE+24(%esp), %ebx # dst_err_ptr
29094 - movl $-EFAULT,(%ebx)
29095 + movl $-EFAULT,%ss:(%ebx)
29096 jmp 5000b
29097
29098 .previous
29099
29100 + pushl_cfi %ss
29101 + popl_cfi %ds
29102 + pushl_cfi %ss
29103 + popl_cfi %es
29104 popl_cfi %ebx
29105 CFI_RESTORE ebx
29106 popl_cfi %esi
29107 @@ -421,26 +441,43 @@ DST( movb %cl, (%edi) )
29108 popl_cfi %ecx # equivalent to addl $4,%esp
29109 ret
29110 CFI_ENDPROC
29111 -ENDPROC(csum_partial_copy_generic)
29112 +ENDPROC(csum_partial_copy_generic_to_user)
29113
29114 #else
29115
29116 /* Version for PentiumII/PPro */
29117
29118 #define ROUND1(x) \
29119 + nop; nop; nop; \
29120 SRC(movl x(%esi), %ebx ) ; \
29121 addl %ebx, %eax ; \
29122 - DST(movl %ebx, x(%edi) ) ;
29123 + DST(movl %ebx, %es:x(%edi)) ;
29124
29125 #define ROUND(x) \
29126 + nop; nop; nop; \
29127 SRC(movl x(%esi), %ebx ) ; \
29128 adcl %ebx, %eax ; \
29129 - DST(movl %ebx, x(%edi) ) ;
29130 + DST(movl %ebx, %es:x(%edi)) ;
29131
29132 #define ARGBASE 12
29133 -
29134 -ENTRY(csum_partial_copy_generic)
29135 +
29136 +ENTRY(csum_partial_copy_generic_to_user)
29137 CFI_STARTPROC
29138 +
29139 +#ifdef CONFIG_PAX_MEMORY_UDEREF
29140 + pushl_cfi %gs
29141 + popl_cfi %es
29142 + jmp csum_partial_copy_generic
29143 +#endif
29144 +
29145 +ENTRY(csum_partial_copy_generic_from_user)
29146 +
29147 +#ifdef CONFIG_PAX_MEMORY_UDEREF
29148 + pushl_cfi %gs
29149 + popl_cfi %ds
29150 +#endif
29151 +
29152 +ENTRY(csum_partial_copy_generic)
29153 pushl_cfi %ebx
29154 CFI_REL_OFFSET ebx, 0
29155 pushl_cfi %edi
29156 @@ -461,7 +498,7 @@ ENTRY(csum_partial_copy_generic)
29157 subl %ebx, %edi
29158 lea -1(%esi),%edx
29159 andl $-32,%edx
29160 - lea 3f(%ebx,%ebx), %ebx
29161 + lea 3f(%ebx,%ebx,2), %ebx
29162 testl %esi, %esi
29163 jmp *%ebx
29164 1: addl $64,%esi
29165 @@ -482,19 +519,19 @@ ENTRY(csum_partial_copy_generic)
29166 jb 5f
29167 SRC( movw (%esi), %dx )
29168 leal 2(%esi), %esi
29169 -DST( movw %dx, (%edi) )
29170 +DST( movw %dx, %es:(%edi) )
29171 leal 2(%edi), %edi
29172 je 6f
29173 shll $16,%edx
29174 5:
29175 SRC( movb (%esi), %dl )
29176 -DST( movb %dl, (%edi) )
29177 +DST( movb %dl, %es:(%edi) )
29178 6: addl %edx, %eax
29179 adcl $0, %eax
29180 7:
29181 .section .fixup, "ax"
29182 6001: movl ARGBASE+20(%esp), %ebx # src_err_ptr
29183 - movl $-EFAULT, (%ebx)
29184 + movl $-EFAULT, %ss:(%ebx)
29185 # zero the complete destination (computing the rest is too much work)
29186 movl ARGBASE+8(%esp),%edi # dst
29187 movl ARGBASE+12(%esp),%ecx # len
29188 @@ -502,10 +539,17 @@ DST( movb %dl, (%edi) )
29189 rep; stosb
29190 jmp 7b
29191 6002: movl ARGBASE+24(%esp), %ebx # dst_err_ptr
29192 - movl $-EFAULT, (%ebx)
29193 + movl $-EFAULT, %ss:(%ebx)
29194 jmp 7b
29195 .previous
29196
29197 +#ifdef CONFIG_PAX_MEMORY_UDEREF
29198 + pushl_cfi %ss
29199 + popl_cfi %ds
29200 + pushl_cfi %ss
29201 + popl_cfi %es
29202 +#endif
29203 +
29204 popl_cfi %esi
29205 CFI_RESTORE esi
29206 popl_cfi %edi
29207 @@ -514,7 +558,7 @@ DST( movb %dl, (%edi) )
29208 CFI_RESTORE ebx
29209 ret
29210 CFI_ENDPROC
29211 -ENDPROC(csum_partial_copy_generic)
29212 +ENDPROC(csum_partial_copy_generic_to_user)
29213
29214 #undef ROUND
29215 #undef ROUND1
29216 diff --git a/arch/x86/lib/clear_page_64.S b/arch/x86/lib/clear_page_64.S
29217 index f2145cf..cea889d 100644
29218 --- a/arch/x86/lib/clear_page_64.S
29219 +++ b/arch/x86/lib/clear_page_64.S
29220 @@ -11,6 +11,7 @@ ENTRY(clear_page_c)
29221 movl $4096/8,%ecx
29222 xorl %eax,%eax
29223 rep stosq
29224 + pax_force_retaddr
29225 ret
29226 CFI_ENDPROC
29227 ENDPROC(clear_page_c)
29228 @@ -20,6 +21,7 @@ ENTRY(clear_page_c_e)
29229 movl $4096,%ecx
29230 xorl %eax,%eax
29231 rep stosb
29232 + pax_force_retaddr
29233 ret
29234 CFI_ENDPROC
29235 ENDPROC(clear_page_c_e)
29236 @@ -43,6 +45,7 @@ ENTRY(clear_page)
29237 leaq 64(%rdi),%rdi
29238 jnz .Lloop
29239 nop
29240 + pax_force_retaddr
29241 ret
29242 CFI_ENDPROC
29243 .Lclear_page_end:
29244 @@ -58,7 +61,7 @@ ENDPROC(clear_page)
29245
29246 #include <asm/cpufeature.h>
29247
29248 - .section .altinstr_replacement,"ax"
29249 + .section .altinstr_replacement,"a"
29250 1: .byte 0xeb /* jmp <disp8> */
29251 .byte (clear_page_c - clear_page) - (2f - 1b) /* offset */
29252 2: .byte 0xeb /* jmp <disp8> */
29253 diff --git a/arch/x86/lib/cmpxchg16b_emu.S b/arch/x86/lib/cmpxchg16b_emu.S
29254 index 1e572c5..2a162cd 100644
29255 --- a/arch/x86/lib/cmpxchg16b_emu.S
29256 +++ b/arch/x86/lib/cmpxchg16b_emu.S
29257 @@ -53,11 +53,13 @@ this_cpu_cmpxchg16b_emu:
29258
29259 popf
29260 mov $1, %al
29261 + pax_force_retaddr
29262 ret
29263
29264 not_same:
29265 popf
29266 xor %al,%al
29267 + pax_force_retaddr
29268 ret
29269
29270 CFI_ENDPROC
29271 diff --git a/arch/x86/lib/copy_page_64.S b/arch/x86/lib/copy_page_64.S
29272 index 176cca6..e0d658e 100644
29273 --- a/arch/x86/lib/copy_page_64.S
29274 +++ b/arch/x86/lib/copy_page_64.S
29275 @@ -9,6 +9,7 @@ copy_page_rep:
29276 CFI_STARTPROC
29277 movl $4096/8, %ecx
29278 rep movsq
29279 + pax_force_retaddr
29280 ret
29281 CFI_ENDPROC
29282 ENDPROC(copy_page_rep)
29283 @@ -24,8 +25,8 @@ ENTRY(copy_page)
29284 CFI_ADJUST_CFA_OFFSET 2*8
29285 movq %rbx, (%rsp)
29286 CFI_REL_OFFSET rbx, 0
29287 - movq %r12, 1*8(%rsp)
29288 - CFI_REL_OFFSET r12, 1*8
29289 + movq %r13, 1*8(%rsp)
29290 + CFI_REL_OFFSET r13, 1*8
29291
29292 movl $(4096/64)-5, %ecx
29293 .p2align 4
29294 @@ -38,7 +39,7 @@ ENTRY(copy_page)
29295 movq 0x8*4(%rsi), %r9
29296 movq 0x8*5(%rsi), %r10
29297 movq 0x8*6(%rsi), %r11
29298 - movq 0x8*7(%rsi), %r12
29299 + movq 0x8*7(%rsi), %r13
29300
29301 prefetcht0 5*64(%rsi)
29302
29303 @@ -49,7 +50,7 @@ ENTRY(copy_page)
29304 movq %r9, 0x8*4(%rdi)
29305 movq %r10, 0x8*5(%rdi)
29306 movq %r11, 0x8*6(%rdi)
29307 - movq %r12, 0x8*7(%rdi)
29308 + movq %r13, 0x8*7(%rdi)
29309
29310 leaq 64 (%rsi), %rsi
29311 leaq 64 (%rdi), %rdi
29312 @@ -68,7 +69,7 @@ ENTRY(copy_page)
29313 movq 0x8*4(%rsi), %r9
29314 movq 0x8*5(%rsi), %r10
29315 movq 0x8*6(%rsi), %r11
29316 - movq 0x8*7(%rsi), %r12
29317 + movq 0x8*7(%rsi), %r13
29318
29319 movq %rax, 0x8*0(%rdi)
29320 movq %rbx, 0x8*1(%rdi)
29321 @@ -77,7 +78,7 @@ ENTRY(copy_page)
29322 movq %r9, 0x8*4(%rdi)
29323 movq %r10, 0x8*5(%rdi)
29324 movq %r11, 0x8*6(%rdi)
29325 - movq %r12, 0x8*7(%rdi)
29326 + movq %r13, 0x8*7(%rdi)
29327
29328 leaq 64(%rdi), %rdi
29329 leaq 64(%rsi), %rsi
29330 @@ -85,10 +86,11 @@ ENTRY(copy_page)
29331
29332 movq (%rsp), %rbx
29333 CFI_RESTORE rbx
29334 - movq 1*8(%rsp), %r12
29335 - CFI_RESTORE r12
29336 + movq 1*8(%rsp), %r13
29337 + CFI_RESTORE r13
29338 addq $2*8, %rsp
29339 CFI_ADJUST_CFA_OFFSET -2*8
29340 + pax_force_retaddr
29341 ret
29342 .Lcopy_page_end:
29343 CFI_ENDPROC
29344 @@ -99,7 +101,7 @@ ENDPROC(copy_page)
29345
29346 #include <asm/cpufeature.h>
29347
29348 - .section .altinstr_replacement,"ax"
29349 + .section .altinstr_replacement,"a"
29350 1: .byte 0xeb /* jmp <disp8> */
29351 .byte (copy_page_rep - copy_page) - (2f - 1b) /* offset */
29352 2:
29353 diff --git a/arch/x86/lib/copy_user_64.S b/arch/x86/lib/copy_user_64.S
29354 index dee945d..a84067b 100644
29355 --- a/arch/x86/lib/copy_user_64.S
29356 +++ b/arch/x86/lib/copy_user_64.S
29357 @@ -18,31 +18,7 @@
29358 #include <asm/alternative-asm.h>
29359 #include <asm/asm.h>
29360 #include <asm/smap.h>
29361 -
29362 -/*
29363 - * By placing feature2 after feature1 in altinstructions section, we logically
29364 - * implement:
29365 - * If CPU has feature2, jmp to alt2 is used
29366 - * else if CPU has feature1, jmp to alt1 is used
29367 - * else jmp to orig is used.
29368 - */
29369 - .macro ALTERNATIVE_JUMP feature1,feature2,orig,alt1,alt2
29370 -0:
29371 - .byte 0xe9 /* 32bit jump */
29372 - .long \orig-1f /* by default jump to orig */
29373 -1:
29374 - .section .altinstr_replacement,"ax"
29375 -2: .byte 0xe9 /* near jump with 32bit immediate */
29376 - .long \alt1-1b /* offset */ /* or alternatively to alt1 */
29377 -3: .byte 0xe9 /* near jump with 32bit immediate */
29378 - .long \alt2-1b /* offset */ /* or alternatively to alt2 */
29379 - .previous
29380 -
29381 - .section .altinstructions,"a"
29382 - altinstruction_entry 0b,2b,\feature1,5,5
29383 - altinstruction_entry 0b,3b,\feature2,5,5
29384 - .previous
29385 - .endm
29386 +#include <asm/pgtable.h>
29387
29388 .macro ALIGN_DESTINATION
29389 #ifdef FIX_ALIGNMENT
29390 @@ -70,52 +46,6 @@
29391 #endif
29392 .endm
29393
29394 -/* Standard copy_to_user with segment limit checking */
29395 -ENTRY(_copy_to_user)
29396 - CFI_STARTPROC
29397 - GET_THREAD_INFO(%rax)
29398 - movq %rdi,%rcx
29399 - addq %rdx,%rcx
29400 - jc bad_to_user
29401 - cmpq TI_addr_limit(%rax),%rcx
29402 - ja bad_to_user
29403 - ALTERNATIVE_JUMP X86_FEATURE_REP_GOOD,X86_FEATURE_ERMS, \
29404 - copy_user_generic_unrolled,copy_user_generic_string, \
29405 - copy_user_enhanced_fast_string
29406 - CFI_ENDPROC
29407 -ENDPROC(_copy_to_user)
29408 -
29409 -/* Standard copy_from_user with segment limit checking */
29410 -ENTRY(_copy_from_user)
29411 - CFI_STARTPROC
29412 - GET_THREAD_INFO(%rax)
29413 - movq %rsi,%rcx
29414 - addq %rdx,%rcx
29415 - jc bad_from_user
29416 - cmpq TI_addr_limit(%rax),%rcx
29417 - ja bad_from_user
29418 - ALTERNATIVE_JUMP X86_FEATURE_REP_GOOD,X86_FEATURE_ERMS, \
29419 - copy_user_generic_unrolled,copy_user_generic_string, \
29420 - copy_user_enhanced_fast_string
29421 - CFI_ENDPROC
29422 -ENDPROC(_copy_from_user)
29423 -
29424 - .section .fixup,"ax"
29425 - /* must zero dest */
29426 -ENTRY(bad_from_user)
29427 -bad_from_user:
29428 - CFI_STARTPROC
29429 - movl %edx,%ecx
29430 - xorl %eax,%eax
29431 - rep
29432 - stosb
29433 -bad_to_user:
29434 - movl %edx,%eax
29435 - ret
29436 - CFI_ENDPROC
29437 -ENDPROC(bad_from_user)
29438 - .previous
29439 -
29440 /*
29441 * copy_user_generic_unrolled - memory copy with exception handling.
29442 * This version is for CPUs like P4 that don't have efficient micro
29443 @@ -131,6 +61,7 @@ ENDPROC(bad_from_user)
29444 */
29445 ENTRY(copy_user_generic_unrolled)
29446 CFI_STARTPROC
29447 + ASM_PAX_OPEN_USERLAND
29448 ASM_STAC
29449 cmpl $8,%edx
29450 jb 20f /* less then 8 bytes, go to byte copy loop */
29451 @@ -180,6 +111,8 @@ ENTRY(copy_user_generic_unrolled)
29452 jnz 21b
29453 23: xor %eax,%eax
29454 ASM_CLAC
29455 + ASM_PAX_CLOSE_USERLAND
29456 + pax_force_retaddr
29457 ret
29458
29459 .section .fixup,"ax"
29460 @@ -235,6 +168,7 @@ ENDPROC(copy_user_generic_unrolled)
29461 */
29462 ENTRY(copy_user_generic_string)
29463 CFI_STARTPROC
29464 + ASM_PAX_OPEN_USERLAND
29465 ASM_STAC
29466 cmpl $8,%edx
29467 jb 2f /* less than 8 bytes, go to byte copy loop */
29468 @@ -249,6 +183,8 @@ ENTRY(copy_user_generic_string)
29469 movsb
29470 xorl %eax,%eax
29471 ASM_CLAC
29472 + ASM_PAX_CLOSE_USERLAND
29473 + pax_force_retaddr
29474 ret
29475
29476 .section .fixup,"ax"
29477 @@ -276,12 +212,15 @@ ENDPROC(copy_user_generic_string)
29478 */
29479 ENTRY(copy_user_enhanced_fast_string)
29480 CFI_STARTPROC
29481 + ASM_PAX_OPEN_USERLAND
29482 ASM_STAC
29483 movl %edx,%ecx
29484 1: rep
29485 movsb
29486 xorl %eax,%eax
29487 ASM_CLAC
29488 + ASM_PAX_CLOSE_USERLAND
29489 + pax_force_retaddr
29490 ret
29491
29492 .section .fixup,"ax"
29493 diff --git a/arch/x86/lib/copy_user_nocache_64.S b/arch/x86/lib/copy_user_nocache_64.S
29494 index 6a4f43c..c70fb52 100644
29495 --- a/arch/x86/lib/copy_user_nocache_64.S
29496 +++ b/arch/x86/lib/copy_user_nocache_64.S
29497 @@ -8,6 +8,7 @@
29498
29499 #include <linux/linkage.h>
29500 #include <asm/dwarf2.h>
29501 +#include <asm/alternative-asm.h>
29502
29503 #define FIX_ALIGNMENT 1
29504
29505 @@ -16,6 +17,7 @@
29506 #include <asm/thread_info.h>
29507 #include <asm/asm.h>
29508 #include <asm/smap.h>
29509 +#include <asm/pgtable.h>
29510
29511 .macro ALIGN_DESTINATION
29512 #ifdef FIX_ALIGNMENT
29513 @@ -49,6 +51,16 @@
29514 */
29515 ENTRY(__copy_user_nocache)
29516 CFI_STARTPROC
29517 +
29518 +#ifdef CONFIG_PAX_MEMORY_UDEREF
29519 + mov pax_user_shadow_base,%rcx
29520 + cmp %rcx,%rsi
29521 + jae 1f
29522 + add %rcx,%rsi
29523 +1:
29524 +#endif
29525 +
29526 + ASM_PAX_OPEN_USERLAND
29527 ASM_STAC
29528 cmpl $8,%edx
29529 jb 20f /* less then 8 bytes, go to byte copy loop */
29530 @@ -98,7 +110,9 @@ ENTRY(__copy_user_nocache)
29531 jnz 21b
29532 23: xorl %eax,%eax
29533 ASM_CLAC
29534 + ASM_PAX_CLOSE_USERLAND
29535 sfence
29536 + pax_force_retaddr
29537 ret
29538
29539 .section .fixup,"ax"
29540 diff --git a/arch/x86/lib/csum-copy_64.S b/arch/x86/lib/csum-copy_64.S
29541 index 2419d5f..fe52d0e 100644
29542 --- a/arch/x86/lib/csum-copy_64.S
29543 +++ b/arch/x86/lib/csum-copy_64.S
29544 @@ -9,6 +9,7 @@
29545 #include <asm/dwarf2.h>
29546 #include <asm/errno.h>
29547 #include <asm/asm.h>
29548 +#include <asm/alternative-asm.h>
29549
29550 /*
29551 * Checksum copy with exception handling.
29552 @@ -56,8 +57,8 @@ ENTRY(csum_partial_copy_generic)
29553 CFI_ADJUST_CFA_OFFSET 7*8
29554 movq %rbx, 2*8(%rsp)
29555 CFI_REL_OFFSET rbx, 2*8
29556 - movq %r12, 3*8(%rsp)
29557 - CFI_REL_OFFSET r12, 3*8
29558 + movq %r15, 3*8(%rsp)
29559 + CFI_REL_OFFSET r15, 3*8
29560 movq %r14, 4*8(%rsp)
29561 CFI_REL_OFFSET r14, 4*8
29562 movq %r13, 5*8(%rsp)
29563 @@ -72,16 +73,16 @@ ENTRY(csum_partial_copy_generic)
29564 movl %edx, %ecx
29565
29566 xorl %r9d, %r9d
29567 - movq %rcx, %r12
29568 + movq %rcx, %r15
29569
29570 - shrq $6, %r12
29571 + shrq $6, %r15
29572 jz .Lhandle_tail /* < 64 */
29573
29574 clc
29575
29576 /* main loop. clear in 64 byte blocks */
29577 /* r9: zero, r8: temp2, rbx: temp1, rax: sum, rcx: saved length */
29578 - /* r11: temp3, rdx: temp4, r12 loopcnt */
29579 + /* r11: temp3, rdx: temp4, r15 loopcnt */
29580 /* r10: temp5, rbp: temp6, r14 temp7, r13 temp8 */
29581 .p2align 4
29582 .Lloop:
29583 @@ -115,7 +116,7 @@ ENTRY(csum_partial_copy_generic)
29584 adcq %r14, %rax
29585 adcq %r13, %rax
29586
29587 - decl %r12d
29588 + decl %r15d
29589
29590 dest
29591 movq %rbx, (%rsi)
29592 @@ -210,8 +211,8 @@ ENTRY(csum_partial_copy_generic)
29593 .Lende:
29594 movq 2*8(%rsp), %rbx
29595 CFI_RESTORE rbx
29596 - movq 3*8(%rsp), %r12
29597 - CFI_RESTORE r12
29598 + movq 3*8(%rsp), %r15
29599 + CFI_RESTORE r15
29600 movq 4*8(%rsp), %r14
29601 CFI_RESTORE r14
29602 movq 5*8(%rsp), %r13
29603 @@ -220,6 +221,7 @@ ENTRY(csum_partial_copy_generic)
29604 CFI_RESTORE rbp
29605 addq $7*8, %rsp
29606 CFI_ADJUST_CFA_OFFSET -7*8
29607 + pax_force_retaddr
29608 ret
29609 CFI_RESTORE_STATE
29610
29611 diff --git a/arch/x86/lib/csum-wrappers_64.c b/arch/x86/lib/csum-wrappers_64.c
29612 index 7609e0e..b449b98 100644
29613 --- a/arch/x86/lib/csum-wrappers_64.c
29614 +++ b/arch/x86/lib/csum-wrappers_64.c
29615 @@ -53,10 +53,12 @@ csum_partial_copy_from_user(const void __user *src, void *dst,
29616 len -= 2;
29617 }
29618 }
29619 + pax_open_userland();
29620 stac();
29621 - isum = csum_partial_copy_generic((__force const void *)src,
29622 + isum = csum_partial_copy_generic((const void __force_kernel *)____m(src),
29623 dst, len, isum, errp, NULL);
29624 clac();
29625 + pax_close_userland();
29626 if (unlikely(*errp))
29627 goto out_err;
29628
29629 @@ -110,10 +112,12 @@ csum_partial_copy_to_user(const void *src, void __user *dst,
29630 }
29631
29632 *errp = 0;
29633 + pax_open_userland();
29634 stac();
29635 - ret = csum_partial_copy_generic(src, (void __force *)dst,
29636 + ret = csum_partial_copy_generic(src, (void __force_kernel *)____m(dst),
29637 len, isum, NULL, errp);
29638 clac();
29639 + pax_close_userland();
29640 return ret;
29641 }
29642 EXPORT_SYMBOL(csum_partial_copy_to_user);
29643 diff --git a/arch/x86/lib/getuser.S b/arch/x86/lib/getuser.S
29644 index a451235..1daa956 100644
29645 --- a/arch/x86/lib/getuser.S
29646 +++ b/arch/x86/lib/getuser.S
29647 @@ -33,17 +33,40 @@
29648 #include <asm/thread_info.h>
29649 #include <asm/asm.h>
29650 #include <asm/smap.h>
29651 +#include <asm/segment.h>
29652 +#include <asm/pgtable.h>
29653 +#include <asm/alternative-asm.h>
29654 +
29655 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
29656 +#define __copyuser_seg gs;
29657 +#else
29658 +#define __copyuser_seg
29659 +#endif
29660
29661 .text
29662 ENTRY(__get_user_1)
29663 CFI_STARTPROC
29664 +
29665 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
29666 GET_THREAD_INFO(%_ASM_DX)
29667 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
29668 jae bad_get_user
29669 ASM_STAC
29670 -1: movzbl (%_ASM_AX),%edx
29671 +
29672 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
29673 + mov pax_user_shadow_base,%_ASM_DX
29674 + cmp %_ASM_DX,%_ASM_AX
29675 + jae 1234f
29676 + add %_ASM_DX,%_ASM_AX
29677 +1234:
29678 +#endif
29679 +
29680 +#endif
29681 +
29682 +1: __copyuser_seg movzbl (%_ASM_AX),%edx
29683 xor %eax,%eax
29684 ASM_CLAC
29685 + pax_force_retaddr
29686 ret
29687 CFI_ENDPROC
29688 ENDPROC(__get_user_1)
29689 @@ -51,14 +74,28 @@ ENDPROC(__get_user_1)
29690 ENTRY(__get_user_2)
29691 CFI_STARTPROC
29692 add $1,%_ASM_AX
29693 +
29694 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
29695 jc bad_get_user
29696 GET_THREAD_INFO(%_ASM_DX)
29697 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
29698 jae bad_get_user
29699 ASM_STAC
29700 -2: movzwl -1(%_ASM_AX),%edx
29701 +
29702 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
29703 + mov pax_user_shadow_base,%_ASM_DX
29704 + cmp %_ASM_DX,%_ASM_AX
29705 + jae 1234f
29706 + add %_ASM_DX,%_ASM_AX
29707 +1234:
29708 +#endif
29709 +
29710 +#endif
29711 +
29712 +2: __copyuser_seg movzwl -1(%_ASM_AX),%edx
29713 xor %eax,%eax
29714 ASM_CLAC
29715 + pax_force_retaddr
29716 ret
29717 CFI_ENDPROC
29718 ENDPROC(__get_user_2)
29719 @@ -66,14 +103,28 @@ ENDPROC(__get_user_2)
29720 ENTRY(__get_user_4)
29721 CFI_STARTPROC
29722 add $3,%_ASM_AX
29723 +
29724 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
29725 jc bad_get_user
29726 GET_THREAD_INFO(%_ASM_DX)
29727 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
29728 jae bad_get_user
29729 ASM_STAC
29730 -3: movl -3(%_ASM_AX),%edx
29731 +
29732 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
29733 + mov pax_user_shadow_base,%_ASM_DX
29734 + cmp %_ASM_DX,%_ASM_AX
29735 + jae 1234f
29736 + add %_ASM_DX,%_ASM_AX
29737 +1234:
29738 +#endif
29739 +
29740 +#endif
29741 +
29742 +3: __copyuser_seg movl -3(%_ASM_AX),%edx
29743 xor %eax,%eax
29744 ASM_CLAC
29745 + pax_force_retaddr
29746 ret
29747 CFI_ENDPROC
29748 ENDPROC(__get_user_4)
29749 @@ -86,10 +137,20 @@ ENTRY(__get_user_8)
29750 GET_THREAD_INFO(%_ASM_DX)
29751 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
29752 jae bad_get_user
29753 +
29754 +#ifdef CONFIG_PAX_MEMORY_UDEREF
29755 + mov pax_user_shadow_base,%_ASM_DX
29756 + cmp %_ASM_DX,%_ASM_AX
29757 + jae 1234f
29758 + add %_ASM_DX,%_ASM_AX
29759 +1234:
29760 +#endif
29761 +
29762 ASM_STAC
29763 4: movq -7(%_ASM_AX),%rdx
29764 xor %eax,%eax
29765 ASM_CLAC
29766 + pax_force_retaddr
29767 ret
29768 #else
29769 add $7,%_ASM_AX
29770 @@ -98,10 +159,11 @@ ENTRY(__get_user_8)
29771 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
29772 jae bad_get_user_8
29773 ASM_STAC
29774 -4: movl -7(%_ASM_AX),%edx
29775 -5: movl -3(%_ASM_AX),%ecx
29776 +4: __copyuser_seg movl -7(%_ASM_AX),%edx
29777 +5: __copyuser_seg movl -3(%_ASM_AX),%ecx
29778 xor %eax,%eax
29779 ASM_CLAC
29780 + pax_force_retaddr
29781 ret
29782 #endif
29783 CFI_ENDPROC
29784 @@ -113,6 +175,7 @@ bad_get_user:
29785 xor %edx,%edx
29786 mov $(-EFAULT),%_ASM_AX
29787 ASM_CLAC
29788 + pax_force_retaddr
29789 ret
29790 CFI_ENDPROC
29791 END(bad_get_user)
29792 @@ -124,6 +187,7 @@ bad_get_user_8:
29793 xor %ecx,%ecx
29794 mov $(-EFAULT),%_ASM_AX
29795 ASM_CLAC
29796 + pax_force_retaddr
29797 ret
29798 CFI_ENDPROC
29799 END(bad_get_user_8)
29800 diff --git a/arch/x86/lib/insn.c b/arch/x86/lib/insn.c
29801 index 54fcffe..7be149e 100644
29802 --- a/arch/x86/lib/insn.c
29803 +++ b/arch/x86/lib/insn.c
29804 @@ -20,8 +20,10 @@
29805
29806 #ifdef __KERNEL__
29807 #include <linux/string.h>
29808 +#include <asm/pgtable_types.h>
29809 #else
29810 #include <string.h>
29811 +#define ktla_ktva(addr) addr
29812 #endif
29813 #include <asm/inat.h>
29814 #include <asm/insn.h>
29815 @@ -53,8 +55,8 @@
29816 void insn_init(struct insn *insn, const void *kaddr, int x86_64)
29817 {
29818 memset(insn, 0, sizeof(*insn));
29819 - insn->kaddr = kaddr;
29820 - insn->next_byte = kaddr;
29821 + insn->kaddr = ktla_ktva(kaddr);
29822 + insn->next_byte = ktla_ktva(kaddr);
29823 insn->x86_64 = x86_64 ? 1 : 0;
29824 insn->opnd_bytes = 4;
29825 if (x86_64)
29826 diff --git a/arch/x86/lib/iomap_copy_64.S b/arch/x86/lib/iomap_copy_64.S
29827 index 05a95e7..326f2fa 100644
29828 --- a/arch/x86/lib/iomap_copy_64.S
29829 +++ b/arch/x86/lib/iomap_copy_64.S
29830 @@ -17,6 +17,7 @@
29831
29832 #include <linux/linkage.h>
29833 #include <asm/dwarf2.h>
29834 +#include <asm/alternative-asm.h>
29835
29836 /*
29837 * override generic version in lib/iomap_copy.c
29838 @@ -25,6 +26,7 @@ ENTRY(__iowrite32_copy)
29839 CFI_STARTPROC
29840 movl %edx,%ecx
29841 rep movsd
29842 + pax_force_retaddr
29843 ret
29844 CFI_ENDPROC
29845 ENDPROC(__iowrite32_copy)
29846 diff --git a/arch/x86/lib/memcpy_64.S b/arch/x86/lib/memcpy_64.S
29847 index 56313a3..0db417e 100644
29848 --- a/arch/x86/lib/memcpy_64.S
29849 +++ b/arch/x86/lib/memcpy_64.S
29850 @@ -24,7 +24,7 @@
29851 * This gets patched over the unrolled variant (below) via the
29852 * alternative instructions framework:
29853 */
29854 - .section .altinstr_replacement, "ax", @progbits
29855 + .section .altinstr_replacement, "a", @progbits
29856 .Lmemcpy_c:
29857 movq %rdi, %rax
29858 movq %rdx, %rcx
29859 @@ -33,6 +33,7 @@
29860 rep movsq
29861 movl %edx, %ecx
29862 rep movsb
29863 + pax_force_retaddr
29864 ret
29865 .Lmemcpy_e:
29866 .previous
29867 @@ -44,11 +45,12 @@
29868 * This gets patched over the unrolled variant (below) via the
29869 * alternative instructions framework:
29870 */
29871 - .section .altinstr_replacement, "ax", @progbits
29872 + .section .altinstr_replacement, "a", @progbits
29873 .Lmemcpy_c_e:
29874 movq %rdi, %rax
29875 movq %rdx, %rcx
29876 rep movsb
29877 + pax_force_retaddr
29878 ret
29879 .Lmemcpy_e_e:
29880 .previous
29881 @@ -136,6 +138,7 @@ ENTRY(memcpy)
29882 movq %r9, 1*8(%rdi)
29883 movq %r10, -2*8(%rdi, %rdx)
29884 movq %r11, -1*8(%rdi, %rdx)
29885 + pax_force_retaddr
29886 retq
29887 .p2align 4
29888 .Lless_16bytes:
29889 @@ -148,6 +151,7 @@ ENTRY(memcpy)
29890 movq -1*8(%rsi, %rdx), %r9
29891 movq %r8, 0*8(%rdi)
29892 movq %r9, -1*8(%rdi, %rdx)
29893 + pax_force_retaddr
29894 retq
29895 .p2align 4
29896 .Lless_8bytes:
29897 @@ -161,6 +165,7 @@ ENTRY(memcpy)
29898 movl -4(%rsi, %rdx), %r8d
29899 movl %ecx, (%rdi)
29900 movl %r8d, -4(%rdi, %rdx)
29901 + pax_force_retaddr
29902 retq
29903 .p2align 4
29904 .Lless_3bytes:
29905 @@ -179,6 +184,7 @@ ENTRY(memcpy)
29906 movb %cl, (%rdi)
29907
29908 .Lend:
29909 + pax_force_retaddr
29910 retq
29911 CFI_ENDPROC
29912 ENDPROC(memcpy)
29913 diff --git a/arch/x86/lib/memmove_64.S b/arch/x86/lib/memmove_64.S
29914 index 65268a6..dd1de11 100644
29915 --- a/arch/x86/lib/memmove_64.S
29916 +++ b/arch/x86/lib/memmove_64.S
29917 @@ -202,14 +202,16 @@ ENTRY(memmove)
29918 movb (%rsi), %r11b
29919 movb %r11b, (%rdi)
29920 13:
29921 + pax_force_retaddr
29922 retq
29923 CFI_ENDPROC
29924
29925 - .section .altinstr_replacement,"ax"
29926 + .section .altinstr_replacement,"a"
29927 .Lmemmove_begin_forward_efs:
29928 /* Forward moving data. */
29929 movq %rdx, %rcx
29930 rep movsb
29931 + pax_force_retaddr
29932 retq
29933 .Lmemmove_end_forward_efs:
29934 .previous
29935 diff --git a/arch/x86/lib/memset_64.S b/arch/x86/lib/memset_64.S
29936 index 2dcb380..2eb79fe 100644
29937 --- a/arch/x86/lib/memset_64.S
29938 +++ b/arch/x86/lib/memset_64.S
29939 @@ -16,7 +16,7 @@
29940 *
29941 * rax original destination
29942 */
29943 - .section .altinstr_replacement, "ax", @progbits
29944 + .section .altinstr_replacement, "a", @progbits
29945 .Lmemset_c:
29946 movq %rdi,%r9
29947 movq %rdx,%rcx
29948 @@ -30,6 +30,7 @@
29949 movl %edx,%ecx
29950 rep stosb
29951 movq %r9,%rax
29952 + pax_force_retaddr
29953 ret
29954 .Lmemset_e:
29955 .previous
29956 @@ -45,13 +46,14 @@
29957 *
29958 * rax original destination
29959 */
29960 - .section .altinstr_replacement, "ax", @progbits
29961 + .section .altinstr_replacement, "a", @progbits
29962 .Lmemset_c_e:
29963 movq %rdi,%r9
29964 movb %sil,%al
29965 movq %rdx,%rcx
29966 rep stosb
29967 movq %r9,%rax
29968 + pax_force_retaddr
29969 ret
29970 .Lmemset_e_e:
29971 .previous
29972 @@ -118,6 +120,7 @@ ENTRY(__memset)
29973
29974 .Lende:
29975 movq %r10,%rax
29976 + pax_force_retaddr
29977 ret
29978
29979 CFI_RESTORE_STATE
29980 diff --git a/arch/x86/lib/mmx_32.c b/arch/x86/lib/mmx_32.c
29981 index c9f2d9b..e7fd2c0 100644
29982 --- a/arch/x86/lib/mmx_32.c
29983 +++ b/arch/x86/lib/mmx_32.c
29984 @@ -29,6 +29,7 @@ void *_mmx_memcpy(void *to, const void *from, size_t len)
29985 {
29986 void *p;
29987 int i;
29988 + unsigned long cr0;
29989
29990 if (unlikely(in_interrupt()))
29991 return __memcpy(to, from, len);
29992 @@ -39,44 +40,72 @@ void *_mmx_memcpy(void *to, const void *from, size_t len)
29993 kernel_fpu_begin();
29994
29995 __asm__ __volatile__ (
29996 - "1: prefetch (%0)\n" /* This set is 28 bytes */
29997 - " prefetch 64(%0)\n"
29998 - " prefetch 128(%0)\n"
29999 - " prefetch 192(%0)\n"
30000 - " prefetch 256(%0)\n"
30001 + "1: prefetch (%1)\n" /* This set is 28 bytes */
30002 + " prefetch 64(%1)\n"
30003 + " prefetch 128(%1)\n"
30004 + " prefetch 192(%1)\n"
30005 + " prefetch 256(%1)\n"
30006 "2: \n"
30007 ".section .fixup, \"ax\"\n"
30008 - "3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
30009 + "3: \n"
30010 +
30011 +#ifdef CONFIG_PAX_KERNEXEC
30012 + " movl %%cr0, %0\n"
30013 + " movl %0, %%eax\n"
30014 + " andl $0xFFFEFFFF, %%eax\n"
30015 + " movl %%eax, %%cr0\n"
30016 +#endif
30017 +
30018 + " movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
30019 +
30020 +#ifdef CONFIG_PAX_KERNEXEC
30021 + " movl %0, %%cr0\n"
30022 +#endif
30023 +
30024 " jmp 2b\n"
30025 ".previous\n"
30026 _ASM_EXTABLE(1b, 3b)
30027 - : : "r" (from));
30028 + : "=&r" (cr0) : "r" (from) : "ax");
30029
30030 for ( ; i > 5; i--) {
30031 __asm__ __volatile__ (
30032 - "1: prefetch 320(%0)\n"
30033 - "2: movq (%0), %%mm0\n"
30034 - " movq 8(%0), %%mm1\n"
30035 - " movq 16(%0), %%mm2\n"
30036 - " movq 24(%0), %%mm3\n"
30037 - " movq %%mm0, (%1)\n"
30038 - " movq %%mm1, 8(%1)\n"
30039 - " movq %%mm2, 16(%1)\n"
30040 - " movq %%mm3, 24(%1)\n"
30041 - " movq 32(%0), %%mm0\n"
30042 - " movq 40(%0), %%mm1\n"
30043 - " movq 48(%0), %%mm2\n"
30044 - " movq 56(%0), %%mm3\n"
30045 - " movq %%mm0, 32(%1)\n"
30046 - " movq %%mm1, 40(%1)\n"
30047 - " movq %%mm2, 48(%1)\n"
30048 - " movq %%mm3, 56(%1)\n"
30049 + "1: prefetch 320(%1)\n"
30050 + "2: movq (%1), %%mm0\n"
30051 + " movq 8(%1), %%mm1\n"
30052 + " movq 16(%1), %%mm2\n"
30053 + " movq 24(%1), %%mm3\n"
30054 + " movq %%mm0, (%2)\n"
30055 + " movq %%mm1, 8(%2)\n"
30056 + " movq %%mm2, 16(%2)\n"
30057 + " movq %%mm3, 24(%2)\n"
30058 + " movq 32(%1), %%mm0\n"
30059 + " movq 40(%1), %%mm1\n"
30060 + " movq 48(%1), %%mm2\n"
30061 + " movq 56(%1), %%mm3\n"
30062 + " movq %%mm0, 32(%2)\n"
30063 + " movq %%mm1, 40(%2)\n"
30064 + " movq %%mm2, 48(%2)\n"
30065 + " movq %%mm3, 56(%2)\n"
30066 ".section .fixup, \"ax\"\n"
30067 - "3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */
30068 + "3:\n"
30069 +
30070 +#ifdef CONFIG_PAX_KERNEXEC
30071 + " movl %%cr0, %0\n"
30072 + " movl %0, %%eax\n"
30073 + " andl $0xFFFEFFFF, %%eax\n"
30074 + " movl %%eax, %%cr0\n"
30075 +#endif
30076 +
30077 + " movw $0x05EB, 1b\n" /* jmp on 5 bytes */
30078 +
30079 +#ifdef CONFIG_PAX_KERNEXEC
30080 + " movl %0, %%cr0\n"
30081 +#endif
30082 +
30083 " jmp 2b\n"
30084 ".previous\n"
30085 _ASM_EXTABLE(1b, 3b)
30086 - : : "r" (from), "r" (to) : "memory");
30087 + : "=&r" (cr0) : "r" (from), "r" (to) : "memory", "ax");
30088
30089 from += 64;
30090 to += 64;
30091 @@ -158,6 +187,7 @@ static void fast_clear_page(void *page)
30092 static void fast_copy_page(void *to, void *from)
30093 {
30094 int i;
30095 + unsigned long cr0;
30096
30097 kernel_fpu_begin();
30098
30099 @@ -166,42 +196,70 @@ static void fast_copy_page(void *to, void *from)
30100 * but that is for later. -AV
30101 */
30102 __asm__ __volatile__(
30103 - "1: prefetch (%0)\n"
30104 - " prefetch 64(%0)\n"
30105 - " prefetch 128(%0)\n"
30106 - " prefetch 192(%0)\n"
30107 - " prefetch 256(%0)\n"
30108 + "1: prefetch (%1)\n"
30109 + " prefetch 64(%1)\n"
30110 + " prefetch 128(%1)\n"
30111 + " prefetch 192(%1)\n"
30112 + " prefetch 256(%1)\n"
30113 "2: \n"
30114 ".section .fixup, \"ax\"\n"
30115 - "3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
30116 + "3: \n"
30117 +
30118 +#ifdef CONFIG_PAX_KERNEXEC
30119 + " movl %%cr0, %0\n"
30120 + " movl %0, %%eax\n"
30121 + " andl $0xFFFEFFFF, %%eax\n"
30122 + " movl %%eax, %%cr0\n"
30123 +#endif
30124 +
30125 + " movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
30126 +
30127 +#ifdef CONFIG_PAX_KERNEXEC
30128 + " movl %0, %%cr0\n"
30129 +#endif
30130 +
30131 " jmp 2b\n"
30132 ".previous\n"
30133 - _ASM_EXTABLE(1b, 3b) : : "r" (from));
30134 + _ASM_EXTABLE(1b, 3b) : "=&r" (cr0) : "r" (from) : "ax");
30135
30136 for (i = 0; i < (4096-320)/64; i++) {
30137 __asm__ __volatile__ (
30138 - "1: prefetch 320(%0)\n"
30139 - "2: movq (%0), %%mm0\n"
30140 - " movntq %%mm0, (%1)\n"
30141 - " movq 8(%0), %%mm1\n"
30142 - " movntq %%mm1, 8(%1)\n"
30143 - " movq 16(%0), %%mm2\n"
30144 - " movntq %%mm2, 16(%1)\n"
30145 - " movq 24(%0), %%mm3\n"
30146 - " movntq %%mm3, 24(%1)\n"
30147 - " movq 32(%0), %%mm4\n"
30148 - " movntq %%mm4, 32(%1)\n"
30149 - " movq 40(%0), %%mm5\n"
30150 - " movntq %%mm5, 40(%1)\n"
30151 - " movq 48(%0), %%mm6\n"
30152 - " movntq %%mm6, 48(%1)\n"
30153 - " movq 56(%0), %%mm7\n"
30154 - " movntq %%mm7, 56(%1)\n"
30155 + "1: prefetch 320(%1)\n"
30156 + "2: movq (%1), %%mm0\n"
30157 + " movntq %%mm0, (%2)\n"
30158 + " movq 8(%1), %%mm1\n"
30159 + " movntq %%mm1, 8(%2)\n"
30160 + " movq 16(%1), %%mm2\n"
30161 + " movntq %%mm2, 16(%2)\n"
30162 + " movq 24(%1), %%mm3\n"
30163 + " movntq %%mm3, 24(%2)\n"
30164 + " movq 32(%1), %%mm4\n"
30165 + " movntq %%mm4, 32(%2)\n"
30166 + " movq 40(%1), %%mm5\n"
30167 + " movntq %%mm5, 40(%2)\n"
30168 + " movq 48(%1), %%mm6\n"
30169 + " movntq %%mm6, 48(%2)\n"
30170 + " movq 56(%1), %%mm7\n"
30171 + " movntq %%mm7, 56(%2)\n"
30172 ".section .fixup, \"ax\"\n"
30173 - "3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */
30174 + "3:\n"
30175 +
30176 +#ifdef CONFIG_PAX_KERNEXEC
30177 + " movl %%cr0, %0\n"
30178 + " movl %0, %%eax\n"
30179 + " andl $0xFFFEFFFF, %%eax\n"
30180 + " movl %%eax, %%cr0\n"
30181 +#endif
30182 +
30183 + " movw $0x05EB, 1b\n" /* jmp on 5 bytes */
30184 +
30185 +#ifdef CONFIG_PAX_KERNEXEC
30186 + " movl %0, %%cr0\n"
30187 +#endif
30188 +
30189 " jmp 2b\n"
30190 ".previous\n"
30191 - _ASM_EXTABLE(1b, 3b) : : "r" (from), "r" (to) : "memory");
30192 + _ASM_EXTABLE(1b, 3b) : "=&r" (cr0) : "r" (from), "r" (to) : "memory", "ax");
30193
30194 from += 64;
30195 to += 64;
30196 @@ -280,47 +338,76 @@ static void fast_clear_page(void *page)
30197 static void fast_copy_page(void *to, void *from)
30198 {
30199 int i;
30200 + unsigned long cr0;
30201
30202 kernel_fpu_begin();
30203
30204 __asm__ __volatile__ (
30205 - "1: prefetch (%0)\n"
30206 - " prefetch 64(%0)\n"
30207 - " prefetch 128(%0)\n"
30208 - " prefetch 192(%0)\n"
30209 - " prefetch 256(%0)\n"
30210 + "1: prefetch (%1)\n"
30211 + " prefetch 64(%1)\n"
30212 + " prefetch 128(%1)\n"
30213 + " prefetch 192(%1)\n"
30214 + " prefetch 256(%1)\n"
30215 "2: \n"
30216 ".section .fixup, \"ax\"\n"
30217 - "3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
30218 + "3: \n"
30219 +
30220 +#ifdef CONFIG_PAX_KERNEXEC
30221 + " movl %%cr0, %0\n"
30222 + " movl %0, %%eax\n"
30223 + " andl $0xFFFEFFFF, %%eax\n"
30224 + " movl %%eax, %%cr0\n"
30225 +#endif
30226 +
30227 + " movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
30228 +
30229 +#ifdef CONFIG_PAX_KERNEXEC
30230 + " movl %0, %%cr0\n"
30231 +#endif
30232 +
30233 " jmp 2b\n"
30234 ".previous\n"
30235 - _ASM_EXTABLE(1b, 3b) : : "r" (from));
30236 + _ASM_EXTABLE(1b, 3b) : "=&r" (cr0) : "r" (from) : "ax");
30237
30238 for (i = 0; i < 4096/64; i++) {
30239 __asm__ __volatile__ (
30240 - "1: prefetch 320(%0)\n"
30241 - "2: movq (%0), %%mm0\n"
30242 - " movq 8(%0), %%mm1\n"
30243 - " movq 16(%0), %%mm2\n"
30244 - " movq 24(%0), %%mm3\n"
30245 - " movq %%mm0, (%1)\n"
30246 - " movq %%mm1, 8(%1)\n"
30247 - " movq %%mm2, 16(%1)\n"
30248 - " movq %%mm3, 24(%1)\n"
30249 - " movq 32(%0), %%mm0\n"
30250 - " movq 40(%0), %%mm1\n"
30251 - " movq 48(%0), %%mm2\n"
30252 - " movq 56(%0), %%mm3\n"
30253 - " movq %%mm0, 32(%1)\n"
30254 - " movq %%mm1, 40(%1)\n"
30255 - " movq %%mm2, 48(%1)\n"
30256 - " movq %%mm3, 56(%1)\n"
30257 + "1: prefetch 320(%1)\n"
30258 + "2: movq (%1), %%mm0\n"
30259 + " movq 8(%1), %%mm1\n"
30260 + " movq 16(%1), %%mm2\n"
30261 + " movq 24(%1), %%mm3\n"
30262 + " movq %%mm0, (%2)\n"
30263 + " movq %%mm1, 8(%2)\n"
30264 + " movq %%mm2, 16(%2)\n"
30265 + " movq %%mm3, 24(%2)\n"
30266 + " movq 32(%1), %%mm0\n"
30267 + " movq 40(%1), %%mm1\n"
30268 + " movq 48(%1), %%mm2\n"
30269 + " movq 56(%1), %%mm3\n"
30270 + " movq %%mm0, 32(%2)\n"
30271 + " movq %%mm1, 40(%2)\n"
30272 + " movq %%mm2, 48(%2)\n"
30273 + " movq %%mm3, 56(%2)\n"
30274 ".section .fixup, \"ax\"\n"
30275 - "3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */
30276 + "3:\n"
30277 +
30278 +#ifdef CONFIG_PAX_KERNEXEC
30279 + " movl %%cr0, %0\n"
30280 + " movl %0, %%eax\n"
30281 + " andl $0xFFFEFFFF, %%eax\n"
30282 + " movl %%eax, %%cr0\n"
30283 +#endif
30284 +
30285 + " movw $0x05EB, 1b\n" /* jmp on 5 bytes */
30286 +
30287 +#ifdef CONFIG_PAX_KERNEXEC
30288 + " movl %0, %%cr0\n"
30289 +#endif
30290 +
30291 " jmp 2b\n"
30292 ".previous\n"
30293 _ASM_EXTABLE(1b, 3b)
30294 - : : "r" (from), "r" (to) : "memory");
30295 + : "=&r" (cr0) : "r" (from), "r" (to) : "memory", "ax");
30296
30297 from += 64;
30298 to += 64;
30299 diff --git a/arch/x86/lib/msr-reg.S b/arch/x86/lib/msr-reg.S
30300 index f6d13ee..d789440 100644
30301 --- a/arch/x86/lib/msr-reg.S
30302 +++ b/arch/x86/lib/msr-reg.S
30303 @@ -3,6 +3,7 @@
30304 #include <asm/dwarf2.h>
30305 #include <asm/asm.h>
30306 #include <asm/msr.h>
30307 +#include <asm/alternative-asm.h>
30308
30309 #ifdef CONFIG_X86_64
30310 /*
30311 @@ -37,6 +38,7 @@ ENTRY(\op\()_safe_regs)
30312 movl %edi, 28(%r10)
30313 popq_cfi %rbp
30314 popq_cfi %rbx
30315 + pax_force_retaddr
30316 ret
30317 3:
30318 CFI_RESTORE_STATE
30319 diff --git a/arch/x86/lib/putuser.S b/arch/x86/lib/putuser.S
30320 index fc6ba17..d4d989d 100644
30321 --- a/arch/x86/lib/putuser.S
30322 +++ b/arch/x86/lib/putuser.S
30323 @@ -16,7 +16,9 @@
30324 #include <asm/errno.h>
30325 #include <asm/asm.h>
30326 #include <asm/smap.h>
30327 -
30328 +#include <asm/segment.h>
30329 +#include <asm/pgtable.h>
30330 +#include <asm/alternative-asm.h>
30331
30332 /*
30333 * __put_user_X
30334 @@ -30,57 +32,125 @@
30335 * as they get called from within inline assembly.
30336 */
30337
30338 -#define ENTER CFI_STARTPROC ; \
30339 - GET_THREAD_INFO(%_ASM_BX)
30340 -#define EXIT ASM_CLAC ; \
30341 - ret ; \
30342 +#define ENTER CFI_STARTPROC
30343 +#define EXIT ASM_CLAC ; \
30344 + pax_force_retaddr ; \
30345 + ret ; \
30346 CFI_ENDPROC
30347
30348 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
30349 +#define _DEST %_ASM_CX,%_ASM_BX
30350 +#else
30351 +#define _DEST %_ASM_CX
30352 +#endif
30353 +
30354 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
30355 +#define __copyuser_seg gs;
30356 +#else
30357 +#define __copyuser_seg
30358 +#endif
30359 +
30360 .text
30361 ENTRY(__put_user_1)
30362 ENTER
30363 +
30364 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
30365 + GET_THREAD_INFO(%_ASM_BX)
30366 cmp TI_addr_limit(%_ASM_BX),%_ASM_CX
30367 jae bad_put_user
30368 ASM_STAC
30369 -1: movb %al,(%_ASM_CX)
30370 +
30371 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
30372 + mov pax_user_shadow_base,%_ASM_BX
30373 + cmp %_ASM_BX,%_ASM_CX
30374 + jb 1234f
30375 + xor %ebx,%ebx
30376 +1234:
30377 +#endif
30378 +
30379 +#endif
30380 +
30381 +1: __copyuser_seg movb %al,(_DEST)
30382 xor %eax,%eax
30383 EXIT
30384 ENDPROC(__put_user_1)
30385
30386 ENTRY(__put_user_2)
30387 ENTER
30388 +
30389 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
30390 + GET_THREAD_INFO(%_ASM_BX)
30391 mov TI_addr_limit(%_ASM_BX),%_ASM_BX
30392 sub $1,%_ASM_BX
30393 cmp %_ASM_BX,%_ASM_CX
30394 jae bad_put_user
30395 ASM_STAC
30396 -2: movw %ax,(%_ASM_CX)
30397 +
30398 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
30399 + mov pax_user_shadow_base,%_ASM_BX
30400 + cmp %_ASM_BX,%_ASM_CX
30401 + jb 1234f
30402 + xor %ebx,%ebx
30403 +1234:
30404 +#endif
30405 +
30406 +#endif
30407 +
30408 +2: __copyuser_seg movw %ax,(_DEST)
30409 xor %eax,%eax
30410 EXIT
30411 ENDPROC(__put_user_2)
30412
30413 ENTRY(__put_user_4)
30414 ENTER
30415 +
30416 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
30417 + GET_THREAD_INFO(%_ASM_BX)
30418 mov TI_addr_limit(%_ASM_BX),%_ASM_BX
30419 sub $3,%_ASM_BX
30420 cmp %_ASM_BX,%_ASM_CX
30421 jae bad_put_user
30422 ASM_STAC
30423 -3: movl %eax,(%_ASM_CX)
30424 +
30425 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
30426 + mov pax_user_shadow_base,%_ASM_BX
30427 + cmp %_ASM_BX,%_ASM_CX
30428 + jb 1234f
30429 + xor %ebx,%ebx
30430 +1234:
30431 +#endif
30432 +
30433 +#endif
30434 +
30435 +3: __copyuser_seg movl %eax,(_DEST)
30436 xor %eax,%eax
30437 EXIT
30438 ENDPROC(__put_user_4)
30439
30440 ENTRY(__put_user_8)
30441 ENTER
30442 +
30443 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
30444 + GET_THREAD_INFO(%_ASM_BX)
30445 mov TI_addr_limit(%_ASM_BX),%_ASM_BX
30446 sub $7,%_ASM_BX
30447 cmp %_ASM_BX,%_ASM_CX
30448 jae bad_put_user
30449 ASM_STAC
30450 -4: mov %_ASM_AX,(%_ASM_CX)
30451 +
30452 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
30453 + mov pax_user_shadow_base,%_ASM_BX
30454 + cmp %_ASM_BX,%_ASM_CX
30455 + jb 1234f
30456 + xor %ebx,%ebx
30457 +1234:
30458 +#endif
30459 +
30460 +#endif
30461 +
30462 +4: __copyuser_seg mov %_ASM_AX,(_DEST)
30463 #ifdef CONFIG_X86_32
30464 -5: movl %edx,4(%_ASM_CX)
30465 +5: __copyuser_seg movl %edx,4(_DEST)
30466 #endif
30467 xor %eax,%eax
30468 EXIT
30469 diff --git a/arch/x86/lib/rwlock.S b/arch/x86/lib/rwlock.S
30470 index 1cad221..de671ee 100644
30471 --- a/arch/x86/lib/rwlock.S
30472 +++ b/arch/x86/lib/rwlock.S
30473 @@ -16,13 +16,34 @@ ENTRY(__write_lock_failed)
30474 FRAME
30475 0: LOCK_PREFIX
30476 WRITE_LOCK_ADD($RW_LOCK_BIAS) (%__lock_ptr)
30477 +
30478 +#ifdef CONFIG_PAX_REFCOUNT
30479 + jno 1234f
30480 + LOCK_PREFIX
30481 + WRITE_LOCK_SUB($RW_LOCK_BIAS) (%__lock_ptr)
30482 + int $4
30483 +1234:
30484 + _ASM_EXTABLE(1234b, 1234b)
30485 +#endif
30486 +
30487 1: rep; nop
30488 cmpl $WRITE_LOCK_CMP, (%__lock_ptr)
30489 jne 1b
30490 LOCK_PREFIX
30491 WRITE_LOCK_SUB($RW_LOCK_BIAS) (%__lock_ptr)
30492 +
30493 +#ifdef CONFIG_PAX_REFCOUNT
30494 + jno 1234f
30495 + LOCK_PREFIX
30496 + WRITE_LOCK_ADD($RW_LOCK_BIAS) (%__lock_ptr)
30497 + int $4
30498 +1234:
30499 + _ASM_EXTABLE(1234b, 1234b)
30500 +#endif
30501 +
30502 jnz 0b
30503 ENDFRAME
30504 + pax_force_retaddr
30505 ret
30506 CFI_ENDPROC
30507 END(__write_lock_failed)
30508 @@ -32,13 +53,34 @@ ENTRY(__read_lock_failed)
30509 FRAME
30510 0: LOCK_PREFIX
30511 READ_LOCK_SIZE(inc) (%__lock_ptr)
30512 +
30513 +#ifdef CONFIG_PAX_REFCOUNT
30514 + jno 1234f
30515 + LOCK_PREFIX
30516 + READ_LOCK_SIZE(dec) (%__lock_ptr)
30517 + int $4
30518 +1234:
30519 + _ASM_EXTABLE(1234b, 1234b)
30520 +#endif
30521 +
30522 1: rep; nop
30523 READ_LOCK_SIZE(cmp) $1, (%__lock_ptr)
30524 js 1b
30525 LOCK_PREFIX
30526 READ_LOCK_SIZE(dec) (%__lock_ptr)
30527 +
30528 +#ifdef CONFIG_PAX_REFCOUNT
30529 + jno 1234f
30530 + LOCK_PREFIX
30531 + READ_LOCK_SIZE(inc) (%__lock_ptr)
30532 + int $4
30533 +1234:
30534 + _ASM_EXTABLE(1234b, 1234b)
30535 +#endif
30536 +
30537 js 0b
30538 ENDFRAME
30539 + pax_force_retaddr
30540 ret
30541 CFI_ENDPROC
30542 END(__read_lock_failed)
30543 diff --git a/arch/x86/lib/rwsem.S b/arch/x86/lib/rwsem.S
30544 index 5dff5f0..cadebf4 100644
30545 --- a/arch/x86/lib/rwsem.S
30546 +++ b/arch/x86/lib/rwsem.S
30547 @@ -94,6 +94,7 @@ ENTRY(call_rwsem_down_read_failed)
30548 __ASM_SIZE(pop,_cfi) %__ASM_REG(dx)
30549 CFI_RESTORE __ASM_REG(dx)
30550 restore_common_regs
30551 + pax_force_retaddr
30552 ret
30553 CFI_ENDPROC
30554 ENDPROC(call_rwsem_down_read_failed)
30555 @@ -104,6 +105,7 @@ ENTRY(call_rwsem_down_write_failed)
30556 movq %rax,%rdi
30557 call rwsem_down_write_failed
30558 restore_common_regs
30559 + pax_force_retaddr
30560 ret
30561 CFI_ENDPROC
30562 ENDPROC(call_rwsem_down_write_failed)
30563 @@ -117,7 +119,8 @@ ENTRY(call_rwsem_wake)
30564 movq %rax,%rdi
30565 call rwsem_wake
30566 restore_common_regs
30567 -1: ret
30568 +1: pax_force_retaddr
30569 + ret
30570 CFI_ENDPROC
30571 ENDPROC(call_rwsem_wake)
30572
30573 @@ -131,6 +134,7 @@ ENTRY(call_rwsem_downgrade_wake)
30574 __ASM_SIZE(pop,_cfi) %__ASM_REG(dx)
30575 CFI_RESTORE __ASM_REG(dx)
30576 restore_common_regs
30577 + pax_force_retaddr
30578 ret
30579 CFI_ENDPROC
30580 ENDPROC(call_rwsem_downgrade_wake)
30581 diff --git a/arch/x86/lib/thunk_64.S b/arch/x86/lib/thunk_64.S
30582 index a63efd6..8149fbe 100644
30583 --- a/arch/x86/lib/thunk_64.S
30584 +++ b/arch/x86/lib/thunk_64.S
30585 @@ -8,6 +8,7 @@
30586 #include <linux/linkage.h>
30587 #include <asm/dwarf2.h>
30588 #include <asm/calling.h>
30589 +#include <asm/alternative-asm.h>
30590
30591 /* rdi: arg1 ... normal C conventions. rax is saved/restored. */
30592 .macro THUNK name, func, put_ret_addr_in_rdi=0
30593 @@ -15,11 +16,11 @@
30594 \name:
30595 CFI_STARTPROC
30596
30597 - /* this one pushes 9 elems, the next one would be %rIP */
30598 - SAVE_ARGS
30599 + /* this one pushes 15+1 elems, the next one would be %rIP */
30600 + SAVE_ARGS 8
30601
30602 .if \put_ret_addr_in_rdi
30603 - movq_cfi_restore 9*8, rdi
30604 + movq_cfi_restore RIP, rdi
30605 .endif
30606
30607 call \func
30608 @@ -38,8 +39,9 @@
30609
30610 /* SAVE_ARGS below is used only for the .cfi directives it contains. */
30611 CFI_STARTPROC
30612 - SAVE_ARGS
30613 + SAVE_ARGS 8
30614 restore:
30615 - RESTORE_ARGS
30616 + RESTORE_ARGS 1,8
30617 + pax_force_retaddr
30618 ret
30619 CFI_ENDPROC
30620 diff --git a/arch/x86/lib/usercopy_32.c b/arch/x86/lib/usercopy_32.c
30621 index e2f5e21..4b22130 100644
30622 --- a/arch/x86/lib/usercopy_32.c
30623 +++ b/arch/x86/lib/usercopy_32.c
30624 @@ -42,11 +42,13 @@ do { \
30625 int __d0; \
30626 might_fault(); \
30627 __asm__ __volatile__( \
30628 + __COPYUSER_SET_ES \
30629 ASM_STAC "\n" \
30630 "0: rep; stosl\n" \
30631 " movl %2,%0\n" \
30632 "1: rep; stosb\n" \
30633 "2: " ASM_CLAC "\n" \
30634 + __COPYUSER_RESTORE_ES \
30635 ".section .fixup,\"ax\"\n" \
30636 "3: lea 0(%2,%0,4),%0\n" \
30637 " jmp 2b\n" \
30638 @@ -98,7 +100,7 @@ EXPORT_SYMBOL(__clear_user);
30639
30640 #ifdef CONFIG_X86_INTEL_USERCOPY
30641 static unsigned long
30642 -__copy_user_intel(void __user *to, const void *from, unsigned long size)
30643 +__generic_copy_to_user_intel(void __user *to, const void *from, unsigned long size)
30644 {
30645 int d0, d1;
30646 __asm__ __volatile__(
30647 @@ -110,36 +112,36 @@ __copy_user_intel(void __user *to, const void *from, unsigned long size)
30648 " .align 2,0x90\n"
30649 "3: movl 0(%4), %%eax\n"
30650 "4: movl 4(%4), %%edx\n"
30651 - "5: movl %%eax, 0(%3)\n"
30652 - "6: movl %%edx, 4(%3)\n"
30653 + "5: "__copyuser_seg" movl %%eax, 0(%3)\n"
30654 + "6: "__copyuser_seg" movl %%edx, 4(%3)\n"
30655 "7: movl 8(%4), %%eax\n"
30656 "8: movl 12(%4),%%edx\n"
30657 - "9: movl %%eax, 8(%3)\n"
30658 - "10: movl %%edx, 12(%3)\n"
30659 + "9: "__copyuser_seg" movl %%eax, 8(%3)\n"
30660 + "10: "__copyuser_seg" movl %%edx, 12(%3)\n"
30661 "11: movl 16(%4), %%eax\n"
30662 "12: movl 20(%4), %%edx\n"
30663 - "13: movl %%eax, 16(%3)\n"
30664 - "14: movl %%edx, 20(%3)\n"
30665 + "13: "__copyuser_seg" movl %%eax, 16(%3)\n"
30666 + "14: "__copyuser_seg" movl %%edx, 20(%3)\n"
30667 "15: movl 24(%4), %%eax\n"
30668 "16: movl 28(%4), %%edx\n"
30669 - "17: movl %%eax, 24(%3)\n"
30670 - "18: movl %%edx, 28(%3)\n"
30671 + "17: "__copyuser_seg" movl %%eax, 24(%3)\n"
30672 + "18: "__copyuser_seg" movl %%edx, 28(%3)\n"
30673 "19: movl 32(%4), %%eax\n"
30674 "20: movl 36(%4), %%edx\n"
30675 - "21: movl %%eax, 32(%3)\n"
30676 - "22: movl %%edx, 36(%3)\n"
30677 + "21: "__copyuser_seg" movl %%eax, 32(%3)\n"
30678 + "22: "__copyuser_seg" movl %%edx, 36(%3)\n"
30679 "23: movl 40(%4), %%eax\n"
30680 "24: movl 44(%4), %%edx\n"
30681 - "25: movl %%eax, 40(%3)\n"
30682 - "26: movl %%edx, 44(%3)\n"
30683 + "25: "__copyuser_seg" movl %%eax, 40(%3)\n"
30684 + "26: "__copyuser_seg" movl %%edx, 44(%3)\n"
30685 "27: movl 48(%4), %%eax\n"
30686 "28: movl 52(%4), %%edx\n"
30687 - "29: movl %%eax, 48(%3)\n"
30688 - "30: movl %%edx, 52(%3)\n"
30689 + "29: "__copyuser_seg" movl %%eax, 48(%3)\n"
30690 + "30: "__copyuser_seg" movl %%edx, 52(%3)\n"
30691 "31: movl 56(%4), %%eax\n"
30692 "32: movl 60(%4), %%edx\n"
30693 - "33: movl %%eax, 56(%3)\n"
30694 - "34: movl %%edx, 60(%3)\n"
30695 + "33: "__copyuser_seg" movl %%eax, 56(%3)\n"
30696 + "34: "__copyuser_seg" movl %%edx, 60(%3)\n"
30697 " addl $-64, %0\n"
30698 " addl $64, %4\n"
30699 " addl $64, %3\n"
30700 @@ -149,10 +151,116 @@ __copy_user_intel(void __user *to, const void *from, unsigned long size)
30701 " shrl $2, %0\n"
30702 " andl $3, %%eax\n"
30703 " cld\n"
30704 + __COPYUSER_SET_ES
30705 "99: rep; movsl\n"
30706 "36: movl %%eax, %0\n"
30707 "37: rep; movsb\n"
30708 "100:\n"
30709 + __COPYUSER_RESTORE_ES
30710 + ".section .fixup,\"ax\"\n"
30711 + "101: lea 0(%%eax,%0,4),%0\n"
30712 + " jmp 100b\n"
30713 + ".previous\n"
30714 + _ASM_EXTABLE(1b,100b)
30715 + _ASM_EXTABLE(2b,100b)
30716 + _ASM_EXTABLE(3b,100b)
30717 + _ASM_EXTABLE(4b,100b)
30718 + _ASM_EXTABLE(5b,100b)
30719 + _ASM_EXTABLE(6b,100b)
30720 + _ASM_EXTABLE(7b,100b)
30721 + _ASM_EXTABLE(8b,100b)
30722 + _ASM_EXTABLE(9b,100b)
30723 + _ASM_EXTABLE(10b,100b)
30724 + _ASM_EXTABLE(11b,100b)
30725 + _ASM_EXTABLE(12b,100b)
30726 + _ASM_EXTABLE(13b,100b)
30727 + _ASM_EXTABLE(14b,100b)
30728 + _ASM_EXTABLE(15b,100b)
30729 + _ASM_EXTABLE(16b,100b)
30730 + _ASM_EXTABLE(17b,100b)
30731 + _ASM_EXTABLE(18b,100b)
30732 + _ASM_EXTABLE(19b,100b)
30733 + _ASM_EXTABLE(20b,100b)
30734 + _ASM_EXTABLE(21b,100b)
30735 + _ASM_EXTABLE(22b,100b)
30736 + _ASM_EXTABLE(23b,100b)
30737 + _ASM_EXTABLE(24b,100b)
30738 + _ASM_EXTABLE(25b,100b)
30739 + _ASM_EXTABLE(26b,100b)
30740 + _ASM_EXTABLE(27b,100b)
30741 + _ASM_EXTABLE(28b,100b)
30742 + _ASM_EXTABLE(29b,100b)
30743 + _ASM_EXTABLE(30b,100b)
30744 + _ASM_EXTABLE(31b,100b)
30745 + _ASM_EXTABLE(32b,100b)
30746 + _ASM_EXTABLE(33b,100b)
30747 + _ASM_EXTABLE(34b,100b)
30748 + _ASM_EXTABLE(35b,100b)
30749 + _ASM_EXTABLE(36b,100b)
30750 + _ASM_EXTABLE(37b,100b)
30751 + _ASM_EXTABLE(99b,101b)
30752 + : "=&c"(size), "=&D" (d0), "=&S" (d1)
30753 + : "1"(to), "2"(from), "0"(size)
30754 + : "eax", "edx", "memory");
30755 + return size;
30756 +}
30757 +
30758 +static unsigned long
30759 +__generic_copy_from_user_intel(void *to, const void __user *from, unsigned long size)
30760 +{
30761 + int d0, d1;
30762 + __asm__ __volatile__(
30763 + " .align 2,0x90\n"
30764 + "1: "__copyuser_seg" movl 32(%4), %%eax\n"
30765 + " cmpl $67, %0\n"
30766 + " jbe 3f\n"
30767 + "2: "__copyuser_seg" movl 64(%4), %%eax\n"
30768 + " .align 2,0x90\n"
30769 + "3: "__copyuser_seg" movl 0(%4), %%eax\n"
30770 + "4: "__copyuser_seg" movl 4(%4), %%edx\n"
30771 + "5: movl %%eax, 0(%3)\n"
30772 + "6: movl %%edx, 4(%3)\n"
30773 + "7: "__copyuser_seg" movl 8(%4), %%eax\n"
30774 + "8: "__copyuser_seg" movl 12(%4),%%edx\n"
30775 + "9: movl %%eax, 8(%3)\n"
30776 + "10: movl %%edx, 12(%3)\n"
30777 + "11: "__copyuser_seg" movl 16(%4), %%eax\n"
30778 + "12: "__copyuser_seg" movl 20(%4), %%edx\n"
30779 + "13: movl %%eax, 16(%3)\n"
30780 + "14: movl %%edx, 20(%3)\n"
30781 + "15: "__copyuser_seg" movl 24(%4), %%eax\n"
30782 + "16: "__copyuser_seg" movl 28(%4), %%edx\n"
30783 + "17: movl %%eax, 24(%3)\n"
30784 + "18: movl %%edx, 28(%3)\n"
30785 + "19: "__copyuser_seg" movl 32(%4), %%eax\n"
30786 + "20: "__copyuser_seg" movl 36(%4), %%edx\n"
30787 + "21: movl %%eax, 32(%3)\n"
30788 + "22: movl %%edx, 36(%3)\n"
30789 + "23: "__copyuser_seg" movl 40(%4), %%eax\n"
30790 + "24: "__copyuser_seg" movl 44(%4), %%edx\n"
30791 + "25: movl %%eax, 40(%3)\n"
30792 + "26: movl %%edx, 44(%3)\n"
30793 + "27: "__copyuser_seg" movl 48(%4), %%eax\n"
30794 + "28: "__copyuser_seg" movl 52(%4), %%edx\n"
30795 + "29: movl %%eax, 48(%3)\n"
30796 + "30: movl %%edx, 52(%3)\n"
30797 + "31: "__copyuser_seg" movl 56(%4), %%eax\n"
30798 + "32: "__copyuser_seg" movl 60(%4), %%edx\n"
30799 + "33: movl %%eax, 56(%3)\n"
30800 + "34: movl %%edx, 60(%3)\n"
30801 + " addl $-64, %0\n"
30802 + " addl $64, %4\n"
30803 + " addl $64, %3\n"
30804 + " cmpl $63, %0\n"
30805 + " ja 1b\n"
30806 + "35: movl %0, %%eax\n"
30807 + " shrl $2, %0\n"
30808 + " andl $3, %%eax\n"
30809 + " cld\n"
30810 + "99: rep; "__copyuser_seg" movsl\n"
30811 + "36: movl %%eax, %0\n"
30812 + "37: rep; "__copyuser_seg" movsb\n"
30813 + "100:\n"
30814 ".section .fixup,\"ax\"\n"
30815 "101: lea 0(%%eax,%0,4),%0\n"
30816 " jmp 100b\n"
30817 @@ -207,41 +315,41 @@ __copy_user_zeroing_intel(void *to, const void __user *from, unsigned long size)
30818 int d0, d1;
30819 __asm__ __volatile__(
30820 " .align 2,0x90\n"
30821 - "0: movl 32(%4), %%eax\n"
30822 + "0: "__copyuser_seg" movl 32(%4), %%eax\n"
30823 " cmpl $67, %0\n"
30824 " jbe 2f\n"
30825 - "1: movl 64(%4), %%eax\n"
30826 + "1: "__copyuser_seg" movl 64(%4), %%eax\n"
30827 " .align 2,0x90\n"
30828 - "2: movl 0(%4), %%eax\n"
30829 - "21: movl 4(%4), %%edx\n"
30830 + "2: "__copyuser_seg" movl 0(%4), %%eax\n"
30831 + "21: "__copyuser_seg" movl 4(%4), %%edx\n"
30832 " movl %%eax, 0(%3)\n"
30833 " movl %%edx, 4(%3)\n"
30834 - "3: movl 8(%4), %%eax\n"
30835 - "31: movl 12(%4),%%edx\n"
30836 + "3: "__copyuser_seg" movl 8(%4), %%eax\n"
30837 + "31: "__copyuser_seg" movl 12(%4),%%edx\n"
30838 " movl %%eax, 8(%3)\n"
30839 " movl %%edx, 12(%3)\n"
30840 - "4: movl 16(%4), %%eax\n"
30841 - "41: movl 20(%4), %%edx\n"
30842 + "4: "__copyuser_seg" movl 16(%4), %%eax\n"
30843 + "41: "__copyuser_seg" movl 20(%4), %%edx\n"
30844 " movl %%eax, 16(%3)\n"
30845 " movl %%edx, 20(%3)\n"
30846 - "10: movl 24(%4), %%eax\n"
30847 - "51: movl 28(%4), %%edx\n"
30848 + "10: "__copyuser_seg" movl 24(%4), %%eax\n"
30849 + "51: "__copyuser_seg" movl 28(%4), %%edx\n"
30850 " movl %%eax, 24(%3)\n"
30851 " movl %%edx, 28(%3)\n"
30852 - "11: movl 32(%4), %%eax\n"
30853 - "61: movl 36(%4), %%edx\n"
30854 + "11: "__copyuser_seg" movl 32(%4), %%eax\n"
30855 + "61: "__copyuser_seg" movl 36(%4), %%edx\n"
30856 " movl %%eax, 32(%3)\n"
30857 " movl %%edx, 36(%3)\n"
30858 - "12: movl 40(%4), %%eax\n"
30859 - "71: movl 44(%4), %%edx\n"
30860 + "12: "__copyuser_seg" movl 40(%4), %%eax\n"
30861 + "71: "__copyuser_seg" movl 44(%4), %%edx\n"
30862 " movl %%eax, 40(%3)\n"
30863 " movl %%edx, 44(%3)\n"
30864 - "13: movl 48(%4), %%eax\n"
30865 - "81: movl 52(%4), %%edx\n"
30866 + "13: "__copyuser_seg" movl 48(%4), %%eax\n"
30867 + "81: "__copyuser_seg" movl 52(%4), %%edx\n"
30868 " movl %%eax, 48(%3)\n"
30869 " movl %%edx, 52(%3)\n"
30870 - "14: movl 56(%4), %%eax\n"
30871 - "91: movl 60(%4), %%edx\n"
30872 + "14: "__copyuser_seg" movl 56(%4), %%eax\n"
30873 + "91: "__copyuser_seg" movl 60(%4), %%edx\n"
30874 " movl %%eax, 56(%3)\n"
30875 " movl %%edx, 60(%3)\n"
30876 " addl $-64, %0\n"
30877 @@ -253,9 +361,9 @@ __copy_user_zeroing_intel(void *to, const void __user *from, unsigned long size)
30878 " shrl $2, %0\n"
30879 " andl $3, %%eax\n"
30880 " cld\n"
30881 - "6: rep; movsl\n"
30882 + "6: rep; "__copyuser_seg" movsl\n"
30883 " movl %%eax,%0\n"
30884 - "7: rep; movsb\n"
30885 + "7: rep; "__copyuser_seg" movsb\n"
30886 "8:\n"
30887 ".section .fixup,\"ax\"\n"
30888 "9: lea 0(%%eax,%0,4),%0\n"
30889 @@ -305,41 +413,41 @@ static unsigned long __copy_user_zeroing_intel_nocache(void *to,
30890
30891 __asm__ __volatile__(
30892 " .align 2,0x90\n"
30893 - "0: movl 32(%4), %%eax\n"
30894 + "0: "__copyuser_seg" movl 32(%4), %%eax\n"
30895 " cmpl $67, %0\n"
30896 " jbe 2f\n"
30897 - "1: movl 64(%4), %%eax\n"
30898 + "1: "__copyuser_seg" movl 64(%4), %%eax\n"
30899 " .align 2,0x90\n"
30900 - "2: movl 0(%4), %%eax\n"
30901 - "21: movl 4(%4), %%edx\n"
30902 + "2: "__copyuser_seg" movl 0(%4), %%eax\n"
30903 + "21: "__copyuser_seg" movl 4(%4), %%edx\n"
30904 " movnti %%eax, 0(%3)\n"
30905 " movnti %%edx, 4(%3)\n"
30906 - "3: movl 8(%4), %%eax\n"
30907 - "31: movl 12(%4),%%edx\n"
30908 + "3: "__copyuser_seg" movl 8(%4), %%eax\n"
30909 + "31: "__copyuser_seg" movl 12(%4),%%edx\n"
30910 " movnti %%eax, 8(%3)\n"
30911 " movnti %%edx, 12(%3)\n"
30912 - "4: movl 16(%4), %%eax\n"
30913 - "41: movl 20(%4), %%edx\n"
30914 + "4: "__copyuser_seg" movl 16(%4), %%eax\n"
30915 + "41: "__copyuser_seg" movl 20(%4), %%edx\n"
30916 " movnti %%eax, 16(%3)\n"
30917 " movnti %%edx, 20(%3)\n"
30918 - "10: movl 24(%4), %%eax\n"
30919 - "51: movl 28(%4), %%edx\n"
30920 + "10: "__copyuser_seg" movl 24(%4), %%eax\n"
30921 + "51: "__copyuser_seg" movl 28(%4), %%edx\n"
30922 " movnti %%eax, 24(%3)\n"
30923 " movnti %%edx, 28(%3)\n"
30924 - "11: movl 32(%4), %%eax\n"
30925 - "61: movl 36(%4), %%edx\n"
30926 + "11: "__copyuser_seg" movl 32(%4), %%eax\n"
30927 + "61: "__copyuser_seg" movl 36(%4), %%edx\n"
30928 " movnti %%eax, 32(%3)\n"
30929 " movnti %%edx, 36(%3)\n"
30930 - "12: movl 40(%4), %%eax\n"
30931 - "71: movl 44(%4), %%edx\n"
30932 + "12: "__copyuser_seg" movl 40(%4), %%eax\n"
30933 + "71: "__copyuser_seg" movl 44(%4), %%edx\n"
30934 " movnti %%eax, 40(%3)\n"
30935 " movnti %%edx, 44(%3)\n"
30936 - "13: movl 48(%4), %%eax\n"
30937 - "81: movl 52(%4), %%edx\n"
30938 + "13: "__copyuser_seg" movl 48(%4), %%eax\n"
30939 + "81: "__copyuser_seg" movl 52(%4), %%edx\n"
30940 " movnti %%eax, 48(%3)\n"
30941 " movnti %%edx, 52(%3)\n"
30942 - "14: movl 56(%4), %%eax\n"
30943 - "91: movl 60(%4), %%edx\n"
30944 + "14: "__copyuser_seg" movl 56(%4), %%eax\n"
30945 + "91: "__copyuser_seg" movl 60(%4), %%edx\n"
30946 " movnti %%eax, 56(%3)\n"
30947 " movnti %%edx, 60(%3)\n"
30948 " addl $-64, %0\n"
30949 @@ -352,9 +460,9 @@ static unsigned long __copy_user_zeroing_intel_nocache(void *to,
30950 " shrl $2, %0\n"
30951 " andl $3, %%eax\n"
30952 " cld\n"
30953 - "6: rep; movsl\n"
30954 + "6: rep; "__copyuser_seg" movsl\n"
30955 " movl %%eax,%0\n"
30956 - "7: rep; movsb\n"
30957 + "7: rep; "__copyuser_seg" movsb\n"
30958 "8:\n"
30959 ".section .fixup,\"ax\"\n"
30960 "9: lea 0(%%eax,%0,4),%0\n"
30961 @@ -399,41 +507,41 @@ static unsigned long __copy_user_intel_nocache(void *to,
30962
30963 __asm__ __volatile__(
30964 " .align 2,0x90\n"
30965 - "0: movl 32(%4), %%eax\n"
30966 + "0: "__copyuser_seg" movl 32(%4), %%eax\n"
30967 " cmpl $67, %0\n"
30968 " jbe 2f\n"
30969 - "1: movl 64(%4), %%eax\n"
30970 + "1: "__copyuser_seg" movl 64(%4), %%eax\n"
30971 " .align 2,0x90\n"
30972 - "2: movl 0(%4), %%eax\n"
30973 - "21: movl 4(%4), %%edx\n"
30974 + "2: "__copyuser_seg" movl 0(%4), %%eax\n"
30975 + "21: "__copyuser_seg" movl 4(%4), %%edx\n"
30976 " movnti %%eax, 0(%3)\n"
30977 " movnti %%edx, 4(%3)\n"
30978 - "3: movl 8(%4), %%eax\n"
30979 - "31: movl 12(%4),%%edx\n"
30980 + "3: "__copyuser_seg" movl 8(%4), %%eax\n"
30981 + "31: "__copyuser_seg" movl 12(%4),%%edx\n"
30982 " movnti %%eax, 8(%3)\n"
30983 " movnti %%edx, 12(%3)\n"
30984 - "4: movl 16(%4), %%eax\n"
30985 - "41: movl 20(%4), %%edx\n"
30986 + "4: "__copyuser_seg" movl 16(%4), %%eax\n"
30987 + "41: "__copyuser_seg" movl 20(%4), %%edx\n"
30988 " movnti %%eax, 16(%3)\n"
30989 " movnti %%edx, 20(%3)\n"
30990 - "10: movl 24(%4), %%eax\n"
30991 - "51: movl 28(%4), %%edx\n"
30992 + "10: "__copyuser_seg" movl 24(%4), %%eax\n"
30993 + "51: "__copyuser_seg" movl 28(%4), %%edx\n"
30994 " movnti %%eax, 24(%3)\n"
30995 " movnti %%edx, 28(%3)\n"
30996 - "11: movl 32(%4), %%eax\n"
30997 - "61: movl 36(%4), %%edx\n"
30998 + "11: "__copyuser_seg" movl 32(%4), %%eax\n"
30999 + "61: "__copyuser_seg" movl 36(%4), %%edx\n"
31000 " movnti %%eax, 32(%3)\n"
31001 " movnti %%edx, 36(%3)\n"
31002 - "12: movl 40(%4), %%eax\n"
31003 - "71: movl 44(%4), %%edx\n"
31004 + "12: "__copyuser_seg" movl 40(%4), %%eax\n"
31005 + "71: "__copyuser_seg" movl 44(%4), %%edx\n"
31006 " movnti %%eax, 40(%3)\n"
31007 " movnti %%edx, 44(%3)\n"
31008 - "13: movl 48(%4), %%eax\n"
31009 - "81: movl 52(%4), %%edx\n"
31010 + "13: "__copyuser_seg" movl 48(%4), %%eax\n"
31011 + "81: "__copyuser_seg" movl 52(%4), %%edx\n"
31012 " movnti %%eax, 48(%3)\n"
31013 " movnti %%edx, 52(%3)\n"
31014 - "14: movl 56(%4), %%eax\n"
31015 - "91: movl 60(%4), %%edx\n"
31016 + "14: "__copyuser_seg" movl 56(%4), %%eax\n"
31017 + "91: "__copyuser_seg" movl 60(%4), %%edx\n"
31018 " movnti %%eax, 56(%3)\n"
31019 " movnti %%edx, 60(%3)\n"
31020 " addl $-64, %0\n"
31021 @@ -446,9 +554,9 @@ static unsigned long __copy_user_intel_nocache(void *to,
31022 " shrl $2, %0\n"
31023 " andl $3, %%eax\n"
31024 " cld\n"
31025 - "6: rep; movsl\n"
31026 + "6: rep; "__copyuser_seg" movsl\n"
31027 " movl %%eax,%0\n"
31028 - "7: rep; movsb\n"
31029 + "7: rep; "__copyuser_seg" movsb\n"
31030 "8:\n"
31031 ".section .fixup,\"ax\"\n"
31032 "9: lea 0(%%eax,%0,4),%0\n"
31033 @@ -488,32 +596,36 @@ static unsigned long __copy_user_intel_nocache(void *to,
31034 */
31035 unsigned long __copy_user_zeroing_intel(void *to, const void __user *from,
31036 unsigned long size);
31037 -unsigned long __copy_user_intel(void __user *to, const void *from,
31038 +unsigned long __generic_copy_to_user_intel(void __user *to, const void *from,
31039 + unsigned long size);
31040 +unsigned long __generic_copy_from_user_intel(void *to, const void __user *from,
31041 unsigned long size);
31042 unsigned long __copy_user_zeroing_intel_nocache(void *to,
31043 const void __user *from, unsigned long size);
31044 #endif /* CONFIG_X86_INTEL_USERCOPY */
31045
31046 /* Generic arbitrary sized copy. */
31047 -#define __copy_user(to, from, size) \
31048 +#define __copy_user(to, from, size, prefix, set, restore) \
31049 do { \
31050 int __d0, __d1, __d2; \
31051 __asm__ __volatile__( \
31052 + set \
31053 " cmp $7,%0\n" \
31054 " jbe 1f\n" \
31055 " movl %1,%0\n" \
31056 " negl %0\n" \
31057 " andl $7,%0\n" \
31058 " subl %0,%3\n" \
31059 - "4: rep; movsb\n" \
31060 + "4: rep; "prefix"movsb\n" \
31061 " movl %3,%0\n" \
31062 " shrl $2,%0\n" \
31063 " andl $3,%3\n" \
31064 " .align 2,0x90\n" \
31065 - "0: rep; movsl\n" \
31066 + "0: rep; "prefix"movsl\n" \
31067 " movl %3,%0\n" \
31068 - "1: rep; movsb\n" \
31069 + "1: rep; "prefix"movsb\n" \
31070 "2:\n" \
31071 + restore \
31072 ".section .fixup,\"ax\"\n" \
31073 "5: addl %3,%0\n" \
31074 " jmp 2b\n" \
31075 @@ -538,14 +650,14 @@ do { \
31076 " negl %0\n" \
31077 " andl $7,%0\n" \
31078 " subl %0,%3\n" \
31079 - "4: rep; movsb\n" \
31080 + "4: rep; "__copyuser_seg"movsb\n" \
31081 " movl %3,%0\n" \
31082 " shrl $2,%0\n" \
31083 " andl $3,%3\n" \
31084 " .align 2,0x90\n" \
31085 - "0: rep; movsl\n" \
31086 + "0: rep; "__copyuser_seg"movsl\n" \
31087 " movl %3,%0\n" \
31088 - "1: rep; movsb\n" \
31089 + "1: rep; "__copyuser_seg"movsb\n" \
31090 "2:\n" \
31091 ".section .fixup,\"ax\"\n" \
31092 "5: addl %3,%0\n" \
31093 @@ -572,9 +684,9 @@ unsigned long __copy_to_user_ll(void __user *to, const void *from,
31094 {
31095 stac();
31096 if (movsl_is_ok(to, from, n))
31097 - __copy_user(to, from, n);
31098 + __copy_user(to, from, n, "", __COPYUSER_SET_ES, __COPYUSER_RESTORE_ES);
31099 else
31100 - n = __copy_user_intel(to, from, n);
31101 + n = __generic_copy_to_user_intel(to, from, n);
31102 clac();
31103 return n;
31104 }
31105 @@ -598,10 +710,9 @@ unsigned long __copy_from_user_ll_nozero(void *to, const void __user *from,
31106 {
31107 stac();
31108 if (movsl_is_ok(to, from, n))
31109 - __copy_user(to, from, n);
31110 + __copy_user(to, from, n, __copyuser_seg, "", "");
31111 else
31112 - n = __copy_user_intel((void __user *)to,
31113 - (const void *)from, n);
31114 + n = __generic_copy_from_user_intel(to, from, n);
31115 clac();
31116 return n;
31117 }
31118 @@ -632,58 +743,38 @@ unsigned long __copy_from_user_ll_nocache_nozero(void *to, const void __user *fr
31119 if (n > 64 && cpu_has_xmm2)
31120 n = __copy_user_intel_nocache(to, from, n);
31121 else
31122 - __copy_user(to, from, n);
31123 + __copy_user(to, from, n, __copyuser_seg, "", "");
31124 #else
31125 - __copy_user(to, from, n);
31126 + __copy_user(to, from, n, __copyuser_seg, "", "");
31127 #endif
31128 clac();
31129 return n;
31130 }
31131 EXPORT_SYMBOL(__copy_from_user_ll_nocache_nozero);
31132
31133 -/**
31134 - * copy_to_user: - Copy a block of data into user space.
31135 - * @to: Destination address, in user space.
31136 - * @from: Source address, in kernel space.
31137 - * @n: Number of bytes to copy.
31138 - *
31139 - * Context: User context only. This function may sleep.
31140 - *
31141 - * Copy data from kernel space to user space.
31142 - *
31143 - * Returns number of bytes that could not be copied.
31144 - * On success, this will be zero.
31145 - */
31146 -unsigned long _copy_to_user(void __user *to, const void *from, unsigned n)
31147 +#ifdef CONFIG_PAX_MEMORY_UDEREF
31148 +void __set_fs(mm_segment_t x)
31149 {
31150 - if (access_ok(VERIFY_WRITE, to, n))
31151 - n = __copy_to_user(to, from, n);
31152 - return n;
31153 + switch (x.seg) {
31154 + case 0:
31155 + loadsegment(gs, 0);
31156 + break;
31157 + case TASK_SIZE_MAX:
31158 + loadsegment(gs, __USER_DS);
31159 + break;
31160 + case -1UL:
31161 + loadsegment(gs, __KERNEL_DS);
31162 + break;
31163 + default:
31164 + BUG();
31165 + }
31166 }
31167 -EXPORT_SYMBOL(_copy_to_user);
31168 +EXPORT_SYMBOL(__set_fs);
31169
31170 -/**
31171 - * copy_from_user: - Copy a block of data from user space.
31172 - * @to: Destination address, in kernel space.
31173 - * @from: Source address, in user space.
31174 - * @n: Number of bytes to copy.
31175 - *
31176 - * Context: User context only. This function may sleep.
31177 - *
31178 - * Copy data from user space to kernel space.
31179 - *
31180 - * Returns number of bytes that could not be copied.
31181 - * On success, this will be zero.
31182 - *
31183 - * If some data could not be copied, this function will pad the copied
31184 - * data to the requested size using zero bytes.
31185 - */
31186 -unsigned long _copy_from_user(void *to, const void __user *from, unsigned n)
31187 +void set_fs(mm_segment_t x)
31188 {
31189 - if (access_ok(VERIFY_READ, from, n))
31190 - n = __copy_from_user(to, from, n);
31191 - else
31192 - memset(to, 0, n);
31193 - return n;
31194 + current_thread_info()->addr_limit = x;
31195 + __set_fs(x);
31196 }
31197 -EXPORT_SYMBOL(_copy_from_user);
31198 +EXPORT_SYMBOL(set_fs);
31199 +#endif
31200 diff --git a/arch/x86/lib/usercopy_64.c b/arch/x86/lib/usercopy_64.c
31201 index c905e89..01ab928 100644
31202 --- a/arch/x86/lib/usercopy_64.c
31203 +++ b/arch/x86/lib/usercopy_64.c
31204 @@ -18,6 +18,7 @@ unsigned long __clear_user(void __user *addr, unsigned long size)
31205 might_fault();
31206 /* no memory constraint because it doesn't change any memory gcc knows
31207 about */
31208 + pax_open_userland();
31209 stac();
31210 asm volatile(
31211 " testq %[size8],%[size8]\n"
31212 @@ -39,9 +40,10 @@ unsigned long __clear_user(void __user *addr, unsigned long size)
31213 _ASM_EXTABLE(0b,3b)
31214 _ASM_EXTABLE(1b,2b)
31215 : [size8] "=&c"(size), [dst] "=&D" (__d0)
31216 - : [size1] "r"(size & 7), "[size8]" (size / 8), "[dst]"(addr),
31217 + : [size1] "r"(size & 7), "[size8]" (size / 8), "[dst]"(____m(addr)),
31218 [zero] "r" (0UL), [eight] "r" (8UL));
31219 clac();
31220 + pax_close_userland();
31221 return size;
31222 }
31223 EXPORT_SYMBOL(__clear_user);
31224 @@ -54,12 +56,11 @@ unsigned long clear_user(void __user *to, unsigned long n)
31225 }
31226 EXPORT_SYMBOL(clear_user);
31227
31228 -unsigned long copy_in_user(void __user *to, const void __user *from, unsigned len)
31229 +unsigned long copy_in_user(void __user *to, const void __user *from, unsigned long len)
31230 {
31231 - if (access_ok(VERIFY_WRITE, to, len) && access_ok(VERIFY_READ, from, len)) {
31232 - return copy_user_generic((__force void *)to, (__force void *)from, len);
31233 - }
31234 - return len;
31235 + if (access_ok(VERIFY_WRITE, to, len) && access_ok(VERIFY_READ, from, len))
31236 + return copy_user_generic((void __force_kernel *)____m(to), (void __force_kernel *)____m(from), len);
31237 + return len;
31238 }
31239 EXPORT_SYMBOL(copy_in_user);
31240
31241 @@ -69,11 +70,13 @@ EXPORT_SYMBOL(copy_in_user);
31242 * it is not necessary to optimize tail handling.
31243 */
31244 __visible unsigned long
31245 -copy_user_handle_tail(char *to, char *from, unsigned len, unsigned zerorest)
31246 +copy_user_handle_tail(char __user *to, char __user *from, unsigned long len, unsigned zerorest)
31247 {
31248 char c;
31249 unsigned zero_len;
31250
31251 + clac();
31252 + pax_close_userland();
31253 for (; len; --len, to++) {
31254 if (__get_user_nocheck(c, from++, sizeof(char)))
31255 break;
31256 @@ -84,6 +87,5 @@ copy_user_handle_tail(char *to, char *from, unsigned len, unsigned zerorest)
31257 for (c = 0, zero_len = len; zerorest && zero_len; --zero_len)
31258 if (__put_user_nocheck(c, to++, sizeof(char)))
31259 break;
31260 - clac();
31261 return len;
31262 }
31263 diff --git a/arch/x86/mm/Makefile b/arch/x86/mm/Makefile
31264 index 6a19ad9..1c48f9a 100644
31265 --- a/arch/x86/mm/Makefile
31266 +++ b/arch/x86/mm/Makefile
31267 @@ -30,3 +30,7 @@ obj-$(CONFIG_ACPI_NUMA) += srat.o
31268 obj-$(CONFIG_NUMA_EMU) += numa_emulation.o
31269
31270 obj-$(CONFIG_MEMTEST) += memtest.o
31271 +
31272 +quote:="
31273 +obj-$(CONFIG_X86_64) += uderef_64.o
31274 +CFLAGS_uderef_64.o := $(subst $(quote),,$(CONFIG_ARCH_HWEIGHT_CFLAGS))
31275 diff --git a/arch/x86/mm/extable.c b/arch/x86/mm/extable.c
31276 index 903ec1e..c4166b2 100644
31277 --- a/arch/x86/mm/extable.c
31278 +++ b/arch/x86/mm/extable.c
31279 @@ -6,12 +6,24 @@
31280 static inline unsigned long
31281 ex_insn_addr(const struct exception_table_entry *x)
31282 {
31283 - return (unsigned long)&x->insn + x->insn;
31284 + unsigned long reloc = 0;
31285 +
31286 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
31287 + reloc = ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
31288 +#endif
31289 +
31290 + return (unsigned long)&x->insn + x->insn + reloc;
31291 }
31292 static inline unsigned long
31293 ex_fixup_addr(const struct exception_table_entry *x)
31294 {
31295 - return (unsigned long)&x->fixup + x->fixup;
31296 + unsigned long reloc = 0;
31297 +
31298 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
31299 + reloc = ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
31300 +#endif
31301 +
31302 + return (unsigned long)&x->fixup + x->fixup + reloc;
31303 }
31304
31305 int fixup_exception(struct pt_regs *regs)
31306 @@ -20,7 +32,7 @@ int fixup_exception(struct pt_regs *regs)
31307 unsigned long new_ip;
31308
31309 #ifdef CONFIG_PNPBIOS
31310 - if (unlikely(SEGMENT_IS_PNP_CODE(regs->cs))) {
31311 + if (unlikely(!v8086_mode(regs) && SEGMENT_IS_PNP_CODE(regs->cs))) {
31312 extern u32 pnp_bios_fault_eip, pnp_bios_fault_esp;
31313 extern u32 pnp_bios_is_utter_crap;
31314 pnp_bios_is_utter_crap = 1;
31315 @@ -145,6 +157,13 @@ void sort_extable(struct exception_table_entry *start,
31316 i += 4;
31317 p->fixup -= i;
31318 i += 4;
31319 +
31320 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
31321 + BUILD_BUG_ON(!IS_ENABLED(CONFIG_BUILDTIME_EXTABLE_SORT));
31322 + p->insn -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
31323 + p->fixup -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
31324 +#endif
31325 +
31326 }
31327 }
31328
31329 diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c
31330 index 8e57229..31cce89 100644
31331 --- a/arch/x86/mm/fault.c
31332 +++ b/arch/x86/mm/fault.c
31333 @@ -14,11 +14,18 @@
31334 #include <linux/hugetlb.h> /* hstate_index_to_shift */
31335 #include <linux/prefetch.h> /* prefetchw */
31336 #include <linux/context_tracking.h> /* exception_enter(), ... */
31337 +#include <linux/unistd.h>
31338 +#include <linux/compiler.h>
31339
31340 #include <asm/traps.h> /* dotraplinkage, ... */
31341 #include <asm/pgalloc.h> /* pgd_*(), ... */
31342 #include <asm/kmemcheck.h> /* kmemcheck_*(), ... */
31343 #include <asm/fixmap.h> /* VSYSCALL_START */
31344 +#include <asm/tlbflush.h>
31345 +
31346 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
31347 +#include <asm/stacktrace.h>
31348 +#endif
31349
31350 #define CREATE_TRACE_POINTS
31351 #include <asm/trace/exceptions.h>
31352 @@ -59,7 +66,7 @@ static inline int __kprobes kprobes_fault(struct pt_regs *regs)
31353 int ret = 0;
31354
31355 /* kprobe_running() needs smp_processor_id() */
31356 - if (kprobes_built_in() && !user_mode_vm(regs)) {
31357 + if (kprobes_built_in() && !user_mode(regs)) {
31358 preempt_disable();
31359 if (kprobe_running() && kprobe_fault_handler(regs, 14))
31360 ret = 1;
31361 @@ -120,7 +127,10 @@ check_prefetch_opcode(struct pt_regs *regs, unsigned char *instr,
31362 return !instr_lo || (instr_lo>>1) == 1;
31363 case 0x00:
31364 /* Prefetch instruction is 0x0F0D or 0x0F18 */
31365 - if (probe_kernel_address(instr, opcode))
31366 + if (user_mode(regs)) {
31367 + if (__copy_from_user_inatomic(&opcode, (unsigned char __force_user *)(instr), 1))
31368 + return 0;
31369 + } else if (probe_kernel_address(instr, opcode))
31370 return 0;
31371
31372 *prefetch = (instr_lo == 0xF) &&
31373 @@ -154,7 +164,10 @@ is_prefetch(struct pt_regs *regs, unsigned long error_code, unsigned long addr)
31374 while (instr < max_instr) {
31375 unsigned char opcode;
31376
31377 - if (probe_kernel_address(instr, opcode))
31378 + if (user_mode(regs)) {
31379 + if (__copy_from_user_inatomic(&opcode, (unsigned char __force_user *)(instr), 1))
31380 + break;
31381 + } else if (probe_kernel_address(instr, opcode))
31382 break;
31383
31384 instr++;
31385 @@ -185,6 +198,34 @@ force_sig_info_fault(int si_signo, int si_code, unsigned long address,
31386 force_sig_info(si_signo, &info, tsk);
31387 }
31388
31389 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
31390 +static bool pax_is_fetch_fault(struct pt_regs *regs, unsigned long error_code, unsigned long address);
31391 +#endif
31392 +
31393 +#ifdef CONFIG_PAX_EMUTRAMP
31394 +static int pax_handle_fetch_fault(struct pt_regs *regs);
31395 +#endif
31396 +
31397 +#ifdef CONFIG_PAX_PAGEEXEC
31398 +static inline pmd_t * pax_get_pmd(struct mm_struct *mm, unsigned long address)
31399 +{
31400 + pgd_t *pgd;
31401 + pud_t *pud;
31402 + pmd_t *pmd;
31403 +
31404 + pgd = pgd_offset(mm, address);
31405 + if (!pgd_present(*pgd))
31406 + return NULL;
31407 + pud = pud_offset(pgd, address);
31408 + if (!pud_present(*pud))
31409 + return NULL;
31410 + pmd = pmd_offset(pud, address);
31411 + if (!pmd_present(*pmd))
31412 + return NULL;
31413 + return pmd;
31414 +}
31415 +#endif
31416 +
31417 DEFINE_SPINLOCK(pgd_lock);
31418 LIST_HEAD(pgd_list);
31419
31420 @@ -235,10 +276,27 @@ void vmalloc_sync_all(void)
31421 for (address = VMALLOC_START & PMD_MASK;
31422 address >= TASK_SIZE && address < FIXADDR_TOP;
31423 address += PMD_SIZE) {
31424 +
31425 +#ifdef CONFIG_PAX_PER_CPU_PGD
31426 + unsigned long cpu;
31427 +#else
31428 struct page *page;
31429 +#endif
31430
31431 spin_lock(&pgd_lock);
31432 +
31433 +#ifdef CONFIG_PAX_PER_CPU_PGD
31434 + for (cpu = 0; cpu < nr_cpu_ids; ++cpu) {
31435 + pgd_t *pgd = get_cpu_pgd(cpu, user);
31436 + pmd_t *ret;
31437 +
31438 + ret = vmalloc_sync_one(pgd, address);
31439 + if (!ret)
31440 + break;
31441 + pgd = get_cpu_pgd(cpu, kernel);
31442 +#else
31443 list_for_each_entry(page, &pgd_list, lru) {
31444 + pgd_t *pgd;
31445 spinlock_t *pgt_lock;
31446 pmd_t *ret;
31447
31448 @@ -246,8 +304,14 @@ void vmalloc_sync_all(void)
31449 pgt_lock = &pgd_page_get_mm(page)->page_table_lock;
31450
31451 spin_lock(pgt_lock);
31452 - ret = vmalloc_sync_one(page_address(page), address);
31453 + pgd = page_address(page);
31454 +#endif
31455 +
31456 + ret = vmalloc_sync_one(pgd, address);
31457 +
31458 +#ifndef CONFIG_PAX_PER_CPU_PGD
31459 spin_unlock(pgt_lock);
31460 +#endif
31461
31462 if (!ret)
31463 break;
31464 @@ -281,6 +345,12 @@ static noinline __kprobes int vmalloc_fault(unsigned long address)
31465 * an interrupt in the middle of a task switch..
31466 */
31467 pgd_paddr = read_cr3();
31468 +
31469 +#ifdef CONFIG_PAX_PER_CPU_PGD
31470 + BUG_ON(__pa(get_cpu_pgd(smp_processor_id(), kernel)) != (pgd_paddr & __PHYSICAL_MASK));
31471 + vmalloc_sync_one(__va(pgd_paddr + PAGE_SIZE), address);
31472 +#endif
31473 +
31474 pmd_k = vmalloc_sync_one(__va(pgd_paddr), address);
31475 if (!pmd_k)
31476 return -1;
31477 @@ -376,11 +446,25 @@ static noinline __kprobes int vmalloc_fault(unsigned long address)
31478 * happen within a race in page table update. In the later
31479 * case just flush:
31480 */
31481 - pgd = pgd_offset(current->active_mm, address);
31482 +
31483 pgd_ref = pgd_offset_k(address);
31484 if (pgd_none(*pgd_ref))
31485 return -1;
31486
31487 +#ifdef CONFIG_PAX_PER_CPU_PGD
31488 + BUG_ON(__pa(get_cpu_pgd(smp_processor_id(), kernel)) != (read_cr3() & __PHYSICAL_MASK));
31489 + pgd = pgd_offset_cpu(smp_processor_id(), user, address);
31490 + if (pgd_none(*pgd)) {
31491 + set_pgd(pgd, *pgd_ref);
31492 + arch_flush_lazy_mmu_mode();
31493 + } else {
31494 + BUG_ON(pgd_page_vaddr(*pgd) != pgd_page_vaddr(*pgd_ref));
31495 + }
31496 + pgd = pgd_offset_cpu(smp_processor_id(), kernel, address);
31497 +#else
31498 + pgd = pgd_offset(current->active_mm, address);
31499 +#endif
31500 +
31501 if (pgd_none(*pgd)) {
31502 set_pgd(pgd, *pgd_ref);
31503 arch_flush_lazy_mmu_mode();
31504 @@ -546,7 +630,7 @@ static int is_errata93(struct pt_regs *regs, unsigned long address)
31505 static int is_errata100(struct pt_regs *regs, unsigned long address)
31506 {
31507 #ifdef CONFIG_X86_64
31508 - if ((regs->cs == __USER32_CS || (regs->cs & (1<<2))) && (address >> 32))
31509 + if ((regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT)) && (address >> 32))
31510 return 1;
31511 #endif
31512 return 0;
31513 @@ -573,7 +657,7 @@ static int is_f00f_bug(struct pt_regs *regs, unsigned long address)
31514 }
31515
31516 static const char nx_warning[] = KERN_CRIT
31517 -"kernel tried to execute NX-protected page - exploit attempt? (uid: %d)\n";
31518 +"kernel tried to execute NX-protected page - exploit attempt? (uid: %d, task: %s, pid: %d)\n";
31519
31520 static void
31521 show_fault_oops(struct pt_regs *regs, unsigned long error_code,
31522 @@ -582,7 +666,7 @@ show_fault_oops(struct pt_regs *regs, unsigned long error_code,
31523 if (!oops_may_print())
31524 return;
31525
31526 - if (error_code & PF_INSTR) {
31527 + if ((__supported_pte_mask & _PAGE_NX) && (error_code & PF_INSTR)) {
31528 unsigned int level;
31529 pgd_t *pgd;
31530 pte_t *pte;
31531 @@ -593,9 +677,21 @@ show_fault_oops(struct pt_regs *regs, unsigned long error_code,
31532 pte = lookup_address_in_pgd(pgd, address, &level);
31533
31534 if (pte && pte_present(*pte) && !pte_exec(*pte))
31535 - printk(nx_warning, from_kuid(&init_user_ns, current_uid()));
31536 + printk(nx_warning, from_kuid_munged(&init_user_ns, current_uid()), current->comm, task_pid_nr(current));
31537 }
31538
31539 +#ifdef CONFIG_PAX_KERNEXEC
31540 + if (init_mm.start_code <= address && address < init_mm.end_code) {
31541 + if (current->signal->curr_ip)
31542 + printk(KERN_ERR "PAX: From %pI4: %s:%d, uid/euid: %u/%u, attempted to modify kernel code\n",
31543 + &current->signal->curr_ip, current->comm, task_pid_nr(current),
31544 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
31545 + else
31546 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to modify kernel code\n", current->comm, task_pid_nr(current),
31547 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
31548 + }
31549 +#endif
31550 +
31551 printk(KERN_ALERT "BUG: unable to handle kernel ");
31552 if (address < PAGE_SIZE)
31553 printk(KERN_CONT "NULL pointer dereference");
31554 @@ -776,6 +872,22 @@ __bad_area_nosemaphore(struct pt_regs *regs, unsigned long error_code,
31555 return;
31556 }
31557 #endif
31558 +
31559 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
31560 + if (pax_is_fetch_fault(regs, error_code, address)) {
31561 +
31562 +#ifdef CONFIG_PAX_EMUTRAMP
31563 + switch (pax_handle_fetch_fault(regs)) {
31564 + case 2:
31565 + return;
31566 + }
31567 +#endif
31568 +
31569 + pax_report_fault(regs, (void *)regs->ip, (void *)regs->sp);
31570 + do_group_exit(SIGKILL);
31571 + }
31572 +#endif
31573 +
31574 /* Kernel addresses are always protection faults: */
31575 if (address >= TASK_SIZE)
31576 error_code |= PF_PROT;
31577 @@ -861,7 +973,7 @@ do_sigbus(struct pt_regs *regs, unsigned long error_code, unsigned long address,
31578 if (fault & (VM_FAULT_HWPOISON|VM_FAULT_HWPOISON_LARGE)) {
31579 printk(KERN_ERR
31580 "MCE: Killing %s:%d due to hardware memory corruption fault at %lx\n",
31581 - tsk->comm, tsk->pid, address);
31582 + tsk->comm, task_pid_nr(tsk), address);
31583 code = BUS_MCEERR_AR;
31584 }
31585 #endif
31586 @@ -915,6 +1027,99 @@ static int spurious_fault_check(unsigned long error_code, pte_t *pte)
31587 return 1;
31588 }
31589
31590 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
31591 +static int pax_handle_pageexec_fault(struct pt_regs *regs, struct mm_struct *mm, unsigned long address, unsigned long error_code)
31592 +{
31593 + pte_t *pte;
31594 + pmd_t *pmd;
31595 + spinlock_t *ptl;
31596 + unsigned char pte_mask;
31597 +
31598 + if ((__supported_pte_mask & _PAGE_NX) || (error_code & (PF_PROT|PF_USER)) != (PF_PROT|PF_USER) || v8086_mode(regs) ||
31599 + !(mm->pax_flags & MF_PAX_PAGEEXEC))
31600 + return 0;
31601 +
31602 + /* PaX: it's our fault, let's handle it if we can */
31603 +
31604 + /* PaX: take a look at read faults before acquiring any locks */
31605 + if (unlikely(!(error_code & PF_WRITE) && (regs->ip == address))) {
31606 + /* instruction fetch attempt from a protected page in user mode */
31607 + up_read(&mm->mmap_sem);
31608 +
31609 +#ifdef CONFIG_PAX_EMUTRAMP
31610 + switch (pax_handle_fetch_fault(regs)) {
31611 + case 2:
31612 + return 1;
31613 + }
31614 +#endif
31615 +
31616 + pax_report_fault(regs, (void *)regs->ip, (void *)regs->sp);
31617 + do_group_exit(SIGKILL);
31618 + }
31619 +
31620 + pmd = pax_get_pmd(mm, address);
31621 + if (unlikely(!pmd))
31622 + return 0;
31623 +
31624 + pte = pte_offset_map_lock(mm, pmd, address, &ptl);
31625 + if (unlikely(!(pte_val(*pte) & _PAGE_PRESENT) || pte_user(*pte))) {
31626 + pte_unmap_unlock(pte, ptl);
31627 + return 0;
31628 + }
31629 +
31630 + if (unlikely((error_code & PF_WRITE) && !pte_write(*pte))) {
31631 + /* write attempt to a protected page in user mode */
31632 + pte_unmap_unlock(pte, ptl);
31633 + return 0;
31634 + }
31635 +
31636 +#ifdef CONFIG_SMP
31637 + if (likely(address > get_limit(regs->cs) && cpu_isset(smp_processor_id(), mm->context.cpu_user_cs_mask)))
31638 +#else
31639 + if (likely(address > get_limit(regs->cs)))
31640 +#endif
31641 + {
31642 + set_pte(pte, pte_mkread(*pte));
31643 + __flush_tlb_one(address);
31644 + pte_unmap_unlock(pte, ptl);
31645 + up_read(&mm->mmap_sem);
31646 + return 1;
31647 + }
31648 +
31649 + pte_mask = _PAGE_ACCESSED | _PAGE_USER | ((error_code & PF_WRITE) << (_PAGE_BIT_DIRTY-1));
31650 +
31651 + /*
31652 + * PaX: fill DTLB with user rights and retry
31653 + */
31654 + __asm__ __volatile__ (
31655 + "orb %2,(%1)\n"
31656 +#if defined(CONFIG_M586) || defined(CONFIG_M586TSC)
31657 +/*
31658 + * PaX: let this uncommented 'invlpg' remind us on the behaviour of Intel's
31659 + * (and AMD's) TLBs. namely, they do not cache PTEs that would raise *any*
31660 + * page fault when examined during a TLB load attempt. this is true not only
31661 + * for PTEs holding a non-present entry but also present entries that will
31662 + * raise a page fault (such as those set up by PaX, or the copy-on-write
31663 + * mechanism). in effect it means that we do *not* need to flush the TLBs
31664 + * for our target pages since their PTEs are simply not in the TLBs at all.
31665 +
31666 + * the best thing in omitting it is that we gain around 15-20% speed in the
31667 + * fast path of the page fault handler and can get rid of tracing since we
31668 + * can no longer flush unintended entries.
31669 + */
31670 + "invlpg (%0)\n"
31671 +#endif
31672 + __copyuser_seg"testb $0,(%0)\n"
31673 + "xorb %3,(%1)\n"
31674 + :
31675 + : "r" (address), "r" (pte), "q" (pte_mask), "i" (_PAGE_USER)
31676 + : "memory", "cc");
31677 + pte_unmap_unlock(pte, ptl);
31678 + up_read(&mm->mmap_sem);
31679 + return 1;
31680 +}
31681 +#endif
31682 +
31683 /*
31684 * Handle a spurious fault caused by a stale TLB entry.
31685 *
31686 @@ -981,6 +1186,9 @@ int show_unhandled_signals = 1;
31687 static inline int
31688 access_error(unsigned long error_code, struct vm_area_struct *vma)
31689 {
31690 + if ((__supported_pte_mask & _PAGE_NX) && (error_code & PF_INSTR) && !(vma->vm_flags & VM_EXEC))
31691 + return 1;
31692 +
31693 if (error_code & PF_WRITE) {
31694 /* write, present and write, not present: */
31695 if (unlikely(!(vma->vm_flags & VM_WRITE)))
31696 @@ -1015,7 +1223,7 @@ static inline bool smap_violation(int error_code, struct pt_regs *regs)
31697 if (error_code & PF_USER)
31698 return false;
31699
31700 - if (!user_mode_vm(regs) && (regs->flags & X86_EFLAGS_AC))
31701 + if (!user_mode(regs) && (regs->flags & X86_EFLAGS_AC))
31702 return false;
31703
31704 return true;
31705 @@ -1043,6 +1251,22 @@ __do_page_fault(struct pt_regs *regs, unsigned long error_code,
31706 tsk = current;
31707 mm = tsk->mm;
31708
31709 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
31710 + if (!user_mode(regs) && address < 2 * pax_user_shadow_base) {
31711 + if (!search_exception_tables(regs->ip)) {
31712 + printk(KERN_ERR "PAX: please report this to pageexec@freemail.hu\n");
31713 + bad_area_nosemaphore(regs, error_code, address);
31714 + return;
31715 + }
31716 + if (address < pax_user_shadow_base) {
31717 + printk(KERN_ERR "PAX: please report this to pageexec@freemail.hu\n");
31718 + printk(KERN_ERR "PAX: faulting IP: %pS\n", (void *)regs->ip);
31719 + show_trace_log_lvl(NULL, NULL, (void *)regs->sp, regs->bp, KERN_ERR);
31720 + } else
31721 + address -= pax_user_shadow_base;
31722 + }
31723 +#endif
31724 +
31725 /*
31726 * Detect and handle instructions that would cause a page fault for
31727 * both a tracked kernel page and a userspace page.
31728 @@ -1120,7 +1344,7 @@ __do_page_fault(struct pt_regs *regs, unsigned long error_code,
31729 * User-mode registers count as a user access even for any
31730 * potential system fault or CPU buglet:
31731 */
31732 - if (user_mode_vm(regs)) {
31733 + if (user_mode(regs)) {
31734 local_irq_enable();
31735 error_code |= PF_USER;
31736 flags |= FAULT_FLAG_USER;
31737 @@ -1167,6 +1391,11 @@ retry:
31738 might_sleep();
31739 }
31740
31741 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
31742 + if (pax_handle_pageexec_fault(regs, mm, address, error_code))
31743 + return;
31744 +#endif
31745 +
31746 vma = find_vma(mm, address);
31747 if (unlikely(!vma)) {
31748 bad_area(regs, error_code, address);
31749 @@ -1178,18 +1407,24 @@ retry:
31750 bad_area(regs, error_code, address);
31751 return;
31752 }
31753 - if (error_code & PF_USER) {
31754 - /*
31755 - * Accessing the stack below %sp is always a bug.
31756 - * The large cushion allows instructions like enter
31757 - * and pusha to work. ("enter $65535, $31" pushes
31758 - * 32 pointers and then decrements %sp by 65535.)
31759 - */
31760 - if (unlikely(address + 65536 + 32 * sizeof(unsigned long) < regs->sp)) {
31761 - bad_area(regs, error_code, address);
31762 - return;
31763 - }
31764 + /*
31765 + * Accessing the stack below %sp is always a bug.
31766 + * The large cushion allows instructions like enter
31767 + * and pusha to work. ("enter $65535, $31" pushes
31768 + * 32 pointers and then decrements %sp by 65535.)
31769 + */
31770 + if (unlikely(address + 65536 + 32 * sizeof(unsigned long) < task_pt_regs(tsk)->sp)) {
31771 + bad_area(regs, error_code, address);
31772 + return;
31773 }
31774 +
31775 +#ifdef CONFIG_PAX_SEGMEXEC
31776 + if (unlikely((mm->pax_flags & MF_PAX_SEGMEXEC) && vma->vm_end - SEGMEXEC_TASK_SIZE - 1 < address - SEGMEXEC_TASK_SIZE - 1)) {
31777 + bad_area(regs, error_code, address);
31778 + return;
31779 + }
31780 +#endif
31781 +
31782 if (unlikely(expand_stack(vma, address))) {
31783 bad_area(regs, error_code, address);
31784 return;
31785 @@ -1301,3 +1536,292 @@ trace_do_page_fault(struct pt_regs *regs, unsigned long error_code)
31786 exception_exit(prev_state);
31787 }
31788 #endif /* CONFIG_TRACING */
31789 +
31790 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
31791 +static bool pax_is_fetch_fault(struct pt_regs *regs, unsigned long error_code, unsigned long address)
31792 +{
31793 + struct mm_struct *mm = current->mm;
31794 + unsigned long ip = regs->ip;
31795 +
31796 + if (v8086_mode(regs))
31797 + ip = ((regs->cs & 0xffff) << 4) + (ip & 0xffff);
31798 +
31799 +#ifdef CONFIG_PAX_PAGEEXEC
31800 + if (mm->pax_flags & MF_PAX_PAGEEXEC) {
31801 + if ((__supported_pte_mask & _PAGE_NX) && (error_code & PF_INSTR))
31802 + return true;
31803 + if (!(error_code & (PF_PROT | PF_WRITE)) && ip == address)
31804 + return true;
31805 + return false;
31806 + }
31807 +#endif
31808 +
31809 +#ifdef CONFIG_PAX_SEGMEXEC
31810 + if (mm->pax_flags & MF_PAX_SEGMEXEC) {
31811 + if (!(error_code & (PF_PROT | PF_WRITE)) && (ip + SEGMEXEC_TASK_SIZE == address))
31812 + return true;
31813 + return false;
31814 + }
31815 +#endif
31816 +
31817 + return false;
31818 +}
31819 +#endif
31820 +
31821 +#ifdef CONFIG_PAX_EMUTRAMP
31822 +static int pax_handle_fetch_fault_32(struct pt_regs *regs)
31823 +{
31824 + int err;
31825 +
31826 + do { /* PaX: libffi trampoline emulation */
31827 + unsigned char mov, jmp;
31828 + unsigned int addr1, addr2;
31829 +
31830 +#ifdef CONFIG_X86_64
31831 + if ((regs->ip + 9) >> 32)
31832 + break;
31833 +#endif
31834 +
31835 + err = get_user(mov, (unsigned char __user *)regs->ip);
31836 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 1));
31837 + err |= get_user(jmp, (unsigned char __user *)(regs->ip + 5));
31838 + err |= get_user(addr2, (unsigned int __user *)(regs->ip + 6));
31839 +
31840 + if (err)
31841 + break;
31842 +
31843 + if (mov == 0xB8 && jmp == 0xE9) {
31844 + regs->ax = addr1;
31845 + regs->ip = (unsigned int)(regs->ip + addr2 + 10);
31846 + return 2;
31847 + }
31848 + } while (0);
31849 +
31850 + do { /* PaX: gcc trampoline emulation #1 */
31851 + unsigned char mov1, mov2;
31852 + unsigned short jmp;
31853 + unsigned int addr1, addr2;
31854 +
31855 +#ifdef CONFIG_X86_64
31856 + if ((regs->ip + 11) >> 32)
31857 + break;
31858 +#endif
31859 +
31860 + err = get_user(mov1, (unsigned char __user *)regs->ip);
31861 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 1));
31862 + err |= get_user(mov2, (unsigned char __user *)(regs->ip + 5));
31863 + err |= get_user(addr2, (unsigned int __user *)(regs->ip + 6));
31864 + err |= get_user(jmp, (unsigned short __user *)(regs->ip + 10));
31865 +
31866 + if (err)
31867 + break;
31868 +
31869 + if (mov1 == 0xB9 && mov2 == 0xB8 && jmp == 0xE0FF) {
31870 + regs->cx = addr1;
31871 + regs->ax = addr2;
31872 + regs->ip = addr2;
31873 + return 2;
31874 + }
31875 + } while (0);
31876 +
31877 + do { /* PaX: gcc trampoline emulation #2 */
31878 + unsigned char mov, jmp;
31879 + unsigned int addr1, addr2;
31880 +
31881 +#ifdef CONFIG_X86_64
31882 + if ((regs->ip + 9) >> 32)
31883 + break;
31884 +#endif
31885 +
31886 + err = get_user(mov, (unsigned char __user *)regs->ip);
31887 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 1));
31888 + err |= get_user(jmp, (unsigned char __user *)(regs->ip + 5));
31889 + err |= get_user(addr2, (unsigned int __user *)(regs->ip + 6));
31890 +
31891 + if (err)
31892 + break;
31893 +
31894 + if (mov == 0xB9 && jmp == 0xE9) {
31895 + regs->cx = addr1;
31896 + regs->ip = (unsigned int)(regs->ip + addr2 + 10);
31897 + return 2;
31898 + }
31899 + } while (0);
31900 +
31901 + return 1; /* PaX in action */
31902 +}
31903 +
31904 +#ifdef CONFIG_X86_64
31905 +static int pax_handle_fetch_fault_64(struct pt_regs *regs)
31906 +{
31907 + int err;
31908 +
31909 + do { /* PaX: libffi trampoline emulation */
31910 + unsigned short mov1, mov2, jmp1;
31911 + unsigned char stcclc, jmp2;
31912 + unsigned long addr1, addr2;
31913 +
31914 + err = get_user(mov1, (unsigned short __user *)regs->ip);
31915 + err |= get_user(addr1, (unsigned long __user *)(regs->ip + 2));
31916 + err |= get_user(mov2, (unsigned short __user *)(regs->ip + 10));
31917 + err |= get_user(addr2, (unsigned long __user *)(regs->ip + 12));
31918 + err |= get_user(stcclc, (unsigned char __user *)(regs->ip + 20));
31919 + err |= get_user(jmp1, (unsigned short __user *)(regs->ip + 21));
31920 + err |= get_user(jmp2, (unsigned char __user *)(regs->ip + 23));
31921 +
31922 + if (err)
31923 + break;
31924 +
31925 + if (mov1 == 0xBB49 && mov2 == 0xBA49 && (stcclc == 0xF8 || stcclc == 0xF9) && jmp1 == 0xFF49 && jmp2 == 0xE3) {
31926 + regs->r11 = addr1;
31927 + regs->r10 = addr2;
31928 + if (stcclc == 0xF8)
31929 + regs->flags &= ~X86_EFLAGS_CF;
31930 + else
31931 + regs->flags |= X86_EFLAGS_CF;
31932 + regs->ip = addr1;
31933 + return 2;
31934 + }
31935 + } while (0);
31936 +
31937 + do { /* PaX: gcc trampoline emulation #1 */
31938 + unsigned short mov1, mov2, jmp1;
31939 + unsigned char jmp2;
31940 + unsigned int addr1;
31941 + unsigned long addr2;
31942 +
31943 + err = get_user(mov1, (unsigned short __user *)regs->ip);
31944 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 2));
31945 + err |= get_user(mov2, (unsigned short __user *)(regs->ip + 6));
31946 + err |= get_user(addr2, (unsigned long __user *)(regs->ip + 8));
31947 + err |= get_user(jmp1, (unsigned short __user *)(regs->ip + 16));
31948 + err |= get_user(jmp2, (unsigned char __user *)(regs->ip + 18));
31949 +
31950 + if (err)
31951 + break;
31952 +
31953 + if (mov1 == 0xBB41 && mov2 == 0xBA49 && jmp1 == 0xFF49 && jmp2 == 0xE3) {
31954 + regs->r11 = addr1;
31955 + regs->r10 = addr2;
31956 + regs->ip = addr1;
31957 + return 2;
31958 + }
31959 + } while (0);
31960 +
31961 + do { /* PaX: gcc trampoline emulation #2 */
31962 + unsigned short mov1, mov2, jmp1;
31963 + unsigned char jmp2;
31964 + unsigned long addr1, addr2;
31965 +
31966 + err = get_user(mov1, (unsigned short __user *)regs->ip);
31967 + err |= get_user(addr1, (unsigned long __user *)(regs->ip + 2));
31968 + err |= get_user(mov2, (unsigned short __user *)(regs->ip + 10));
31969 + err |= get_user(addr2, (unsigned long __user *)(regs->ip + 12));
31970 + err |= get_user(jmp1, (unsigned short __user *)(regs->ip + 20));
31971 + err |= get_user(jmp2, (unsigned char __user *)(regs->ip + 22));
31972 +
31973 + if (err)
31974 + break;
31975 +
31976 + if (mov1 == 0xBB49 && mov2 == 0xBA49 && jmp1 == 0xFF49 && jmp2 == 0xE3) {
31977 + regs->r11 = addr1;
31978 + regs->r10 = addr2;
31979 + regs->ip = addr1;
31980 + return 2;
31981 + }
31982 + } while (0);
31983 +
31984 + return 1; /* PaX in action */
31985 +}
31986 +#endif
31987 +
31988 +/*
31989 + * PaX: decide what to do with offenders (regs->ip = fault address)
31990 + *
31991 + * returns 1 when task should be killed
31992 + * 2 when gcc trampoline was detected
31993 + */
31994 +static int pax_handle_fetch_fault(struct pt_regs *regs)
31995 +{
31996 + if (v8086_mode(regs))
31997 + return 1;
31998 +
31999 + if (!(current->mm->pax_flags & MF_PAX_EMUTRAMP))
32000 + return 1;
32001 +
32002 +#ifdef CONFIG_X86_32
32003 + return pax_handle_fetch_fault_32(regs);
32004 +#else
32005 + if (regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT))
32006 + return pax_handle_fetch_fault_32(regs);
32007 + else
32008 + return pax_handle_fetch_fault_64(regs);
32009 +#endif
32010 +}
32011 +#endif
32012 +
32013 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
32014 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
32015 +{
32016 + long i;
32017 +
32018 + printk(KERN_ERR "PAX: bytes at PC: ");
32019 + for (i = 0; i < 20; i++) {
32020 + unsigned char c;
32021 + if (get_user(c, (unsigned char __force_user *)pc+i))
32022 + printk(KERN_CONT "?? ");
32023 + else
32024 + printk(KERN_CONT "%02x ", c);
32025 + }
32026 + printk("\n");
32027 +
32028 + printk(KERN_ERR "PAX: bytes at SP-%lu: ", (unsigned long)sizeof(long));
32029 + for (i = -1; i < 80 / (long)sizeof(long); i++) {
32030 + unsigned long c;
32031 + if (get_user(c, (unsigned long __force_user *)sp+i)) {
32032 +#ifdef CONFIG_X86_32
32033 + printk(KERN_CONT "???????? ");
32034 +#else
32035 + if ((regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT)))
32036 + printk(KERN_CONT "???????? ???????? ");
32037 + else
32038 + printk(KERN_CONT "???????????????? ");
32039 +#endif
32040 + } else {
32041 +#ifdef CONFIG_X86_64
32042 + if ((regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT))) {
32043 + printk(KERN_CONT "%08x ", (unsigned int)c);
32044 + printk(KERN_CONT "%08x ", (unsigned int)(c >> 32));
32045 + } else
32046 +#endif
32047 + printk(KERN_CONT "%0*lx ", 2 * (int)sizeof(long), c);
32048 + }
32049 + }
32050 + printk("\n");
32051 +}
32052 +#endif
32053 +
32054 +/**
32055 + * probe_kernel_write(): safely attempt to write to a location
32056 + * @dst: address to write to
32057 + * @src: pointer to the data that shall be written
32058 + * @size: size of the data chunk
32059 + *
32060 + * Safely write to address @dst from the buffer at @src. If a kernel fault
32061 + * happens, handle that and return -EFAULT.
32062 + */
32063 +long notrace probe_kernel_write(void *dst, const void *src, size_t size)
32064 +{
32065 + long ret;
32066 + mm_segment_t old_fs = get_fs();
32067 +
32068 + set_fs(KERNEL_DS);
32069 + pagefault_disable();
32070 + pax_open_kernel();
32071 + ret = __copy_to_user_inatomic((void __force_user *)dst, src, size);
32072 + pax_close_kernel();
32073 + pagefault_enable();
32074 + set_fs(old_fs);
32075 +
32076 + return ret ? -EFAULT : 0;
32077 +}
32078 diff --git a/arch/x86/mm/gup.c b/arch/x86/mm/gup.c
32079 index 207d9aef..69030980 100644
32080 --- a/arch/x86/mm/gup.c
32081 +++ b/arch/x86/mm/gup.c
32082 @@ -268,7 +268,7 @@ int __get_user_pages_fast(unsigned long start, int nr_pages, int write,
32083 addr = start;
32084 len = (unsigned long) nr_pages << PAGE_SHIFT;
32085 end = start + len;
32086 - if (unlikely(!access_ok(write ? VERIFY_WRITE : VERIFY_READ,
32087 + if (unlikely(!access_ok_noprefault(write ? VERIFY_WRITE : VERIFY_READ,
32088 (void __user *)start, len)))
32089 return 0;
32090
32091 @@ -344,6 +344,10 @@ int get_user_pages_fast(unsigned long start, int nr_pages, int write,
32092 goto slow_irqon;
32093 #endif
32094
32095 + if (unlikely(!access_ok_noprefault(write ? VERIFY_WRITE : VERIFY_READ,
32096 + (void __user *)start, len)))
32097 + return 0;
32098 +
32099 /*
32100 * XXX: batch / limit 'nr', to avoid large irq off latency
32101 * needs some instrumenting to determine the common sizes used by
32102 diff --git a/arch/x86/mm/highmem_32.c b/arch/x86/mm/highmem_32.c
32103 index 4500142..53a363c 100644
32104 --- a/arch/x86/mm/highmem_32.c
32105 +++ b/arch/x86/mm/highmem_32.c
32106 @@ -45,7 +45,11 @@ void *kmap_atomic_prot(struct page *page, pgprot_t prot)
32107 idx = type + KM_TYPE_NR*smp_processor_id();
32108 vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
32109 BUG_ON(!pte_none(*(kmap_pte-idx)));
32110 +
32111 + pax_open_kernel();
32112 set_pte(kmap_pte-idx, mk_pte(page, prot));
32113 + pax_close_kernel();
32114 +
32115 arch_flush_lazy_mmu_mode();
32116
32117 return (void *)vaddr;
32118 diff --git a/arch/x86/mm/hugetlbpage.c b/arch/x86/mm/hugetlbpage.c
32119 index 8c9f647..57cb402 100644
32120 --- a/arch/x86/mm/hugetlbpage.c
32121 +++ b/arch/x86/mm/hugetlbpage.c
32122 @@ -90,23 +90,24 @@ int pmd_huge_support(void)
32123 #ifdef CONFIG_HUGETLB_PAGE
32124 static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *file,
32125 unsigned long addr, unsigned long len,
32126 - unsigned long pgoff, unsigned long flags)
32127 + unsigned long pgoff, unsigned long flags, unsigned long offset)
32128 {
32129 struct hstate *h = hstate_file(file);
32130 struct vm_unmapped_area_info info;
32131 -
32132 +
32133 info.flags = 0;
32134 info.length = len;
32135 info.low_limit = current->mm->mmap_legacy_base;
32136 info.high_limit = TASK_SIZE;
32137 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
32138 info.align_offset = 0;
32139 + info.threadstack_offset = offset;
32140 return vm_unmapped_area(&info);
32141 }
32142
32143 static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
32144 unsigned long addr0, unsigned long len,
32145 - unsigned long pgoff, unsigned long flags)
32146 + unsigned long pgoff, unsigned long flags, unsigned long offset)
32147 {
32148 struct hstate *h = hstate_file(file);
32149 struct vm_unmapped_area_info info;
32150 @@ -118,6 +119,7 @@ static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
32151 info.high_limit = current->mm->mmap_base;
32152 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
32153 info.align_offset = 0;
32154 + info.threadstack_offset = offset;
32155 addr = vm_unmapped_area(&info);
32156
32157 /*
32158 @@ -130,6 +132,12 @@ static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
32159 VM_BUG_ON(addr != -ENOMEM);
32160 info.flags = 0;
32161 info.low_limit = TASK_UNMAPPED_BASE;
32162 +
32163 +#ifdef CONFIG_PAX_RANDMMAP
32164 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
32165 + info.low_limit += current->mm->delta_mmap;
32166 +#endif
32167 +
32168 info.high_limit = TASK_SIZE;
32169 addr = vm_unmapped_area(&info);
32170 }
32171 @@ -144,10 +152,20 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
32172 struct hstate *h = hstate_file(file);
32173 struct mm_struct *mm = current->mm;
32174 struct vm_area_struct *vma;
32175 + unsigned long pax_task_size = TASK_SIZE;
32176 + unsigned long offset = gr_rand_threadstack_offset(mm, file, flags);
32177
32178 if (len & ~huge_page_mask(h))
32179 return -EINVAL;
32180 - if (len > TASK_SIZE)
32181 +
32182 +#ifdef CONFIG_PAX_SEGMEXEC
32183 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
32184 + pax_task_size = SEGMEXEC_TASK_SIZE;
32185 +#endif
32186 +
32187 + pax_task_size -= PAGE_SIZE;
32188 +
32189 + if (len > pax_task_size)
32190 return -ENOMEM;
32191
32192 if (flags & MAP_FIXED) {
32193 @@ -156,19 +174,22 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
32194 return addr;
32195 }
32196
32197 +#ifdef CONFIG_PAX_RANDMMAP
32198 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
32199 +#endif
32200 +
32201 if (addr) {
32202 addr = ALIGN(addr, huge_page_size(h));
32203 vma = find_vma(mm, addr);
32204 - if (TASK_SIZE - len >= addr &&
32205 - (!vma || addr + len <= vma->vm_start))
32206 + if (pax_task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
32207 return addr;
32208 }
32209 if (mm->get_unmapped_area == arch_get_unmapped_area)
32210 return hugetlb_get_unmapped_area_bottomup(file, addr, len,
32211 - pgoff, flags);
32212 + pgoff, flags, offset);
32213 else
32214 return hugetlb_get_unmapped_area_topdown(file, addr, len,
32215 - pgoff, flags);
32216 + pgoff, flags, offset);
32217 }
32218 #endif /* CONFIG_HUGETLB_PAGE */
32219
32220 diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c
32221 index f971306..e83e0f6 100644
32222 --- a/arch/x86/mm/init.c
32223 +++ b/arch/x86/mm/init.c
32224 @@ -4,6 +4,7 @@
32225 #include <linux/swap.h>
32226 #include <linux/memblock.h>
32227 #include <linux/bootmem.h> /* for max_low_pfn */
32228 +#include <linux/tboot.h>
32229
32230 #include <asm/cacheflush.h>
32231 #include <asm/e820.h>
32232 @@ -17,6 +18,8 @@
32233 #include <asm/proto.h>
32234 #include <asm/dma.h> /* for MAX_DMA_PFN */
32235 #include <asm/microcode.h>
32236 +#include <asm/desc.h>
32237 +#include <asm/bios_ebda.h>
32238
32239 #include "mm_internal.h"
32240
32241 @@ -563,7 +566,18 @@ void __init init_mem_mapping(void)
32242 early_ioremap_page_table_range_init();
32243 #endif
32244
32245 +#ifdef CONFIG_PAX_PER_CPU_PGD
32246 + clone_pgd_range(get_cpu_pgd(0, kernel) + KERNEL_PGD_BOUNDARY,
32247 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
32248 + KERNEL_PGD_PTRS);
32249 + clone_pgd_range(get_cpu_pgd(0, user) + KERNEL_PGD_BOUNDARY,
32250 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
32251 + KERNEL_PGD_PTRS);
32252 + load_cr3(get_cpu_pgd(0, kernel));
32253 +#else
32254 load_cr3(swapper_pg_dir);
32255 +#endif
32256 +
32257 __flush_tlb_all();
32258
32259 early_memtest(0, max_pfn_mapped << PAGE_SHIFT);
32260 @@ -579,10 +593,40 @@ void __init init_mem_mapping(void)
32261 * Access has to be given to non-kernel-ram areas as well, these contain the PCI
32262 * mmio resources as well as potential bios/acpi data regions.
32263 */
32264 +
32265 +#ifdef CONFIG_GRKERNSEC_KMEM
32266 +static unsigned int ebda_start __read_only;
32267 +static unsigned int ebda_end __read_only;
32268 +#endif
32269 +
32270 int devmem_is_allowed(unsigned long pagenr)
32271 {
32272 - if (pagenr < 256)
32273 +#ifdef CONFIG_GRKERNSEC_KMEM
32274 + /* allow BDA */
32275 + if (!pagenr)
32276 return 1;
32277 + /* allow EBDA */
32278 + if (pagenr >= ebda_start && pagenr < ebda_end)
32279 + return 1;
32280 + /* if tboot is in use, allow access to its hardcoded serial log range */
32281 + if (tboot_enabled() && ((0x60000 >> PAGE_SHIFT) <= pagenr) && (pagenr < (0x68000 >> PAGE_SHIFT)))
32282 + return 1;
32283 +#else
32284 + if (!pagenr)
32285 + return 1;
32286 +#ifdef CONFIG_VM86
32287 + if (pagenr < (ISA_START_ADDRESS >> PAGE_SHIFT))
32288 + return 1;
32289 +#endif
32290 +#endif
32291 +
32292 + if ((ISA_START_ADDRESS >> PAGE_SHIFT) <= pagenr && pagenr < (ISA_END_ADDRESS >> PAGE_SHIFT))
32293 + return 1;
32294 +#ifdef CONFIG_GRKERNSEC_KMEM
32295 + /* throw out everything else below 1MB */
32296 + if (pagenr <= 256)
32297 + return 0;
32298 +#endif
32299 if (iomem_is_exclusive(pagenr << PAGE_SHIFT))
32300 return 0;
32301 if (!page_is_ram(pagenr))
32302 @@ -628,8 +672,117 @@ void free_init_pages(char *what, unsigned long begin, unsigned long end)
32303 #endif
32304 }
32305
32306 +#ifdef CONFIG_GRKERNSEC_KMEM
32307 +static inline void gr_init_ebda(void)
32308 +{
32309 + unsigned int ebda_addr;
32310 + unsigned int ebda_size = 0;
32311 +
32312 + ebda_addr = get_bios_ebda();
32313 + if (ebda_addr) {
32314 + ebda_size = *(unsigned char *)phys_to_virt(ebda_addr);
32315 + ebda_size <<= 10;
32316 + }
32317 + if (ebda_addr && ebda_size) {
32318 + ebda_start = ebda_addr >> PAGE_SHIFT;
32319 + ebda_end = min((unsigned int)PAGE_ALIGN(ebda_addr + ebda_size), (unsigned int)0xa0000) >> PAGE_SHIFT;
32320 + } else {
32321 + ebda_start = 0x9f000 >> PAGE_SHIFT;
32322 + ebda_end = 0xa0000 >> PAGE_SHIFT;
32323 + }
32324 +}
32325 +#else
32326 +static inline void gr_init_ebda(void) { }
32327 +#endif
32328 +
32329 void free_initmem(void)
32330 {
32331 +#ifdef CONFIG_PAX_KERNEXEC
32332 +#ifdef CONFIG_X86_32
32333 + /* PaX: limit KERNEL_CS to actual size */
32334 + unsigned long addr, limit;
32335 + struct desc_struct d;
32336 + int cpu;
32337 +#else
32338 + pgd_t *pgd;
32339 + pud_t *pud;
32340 + pmd_t *pmd;
32341 + unsigned long addr, end;
32342 +#endif
32343 +#endif
32344 +
32345 + gr_init_ebda();
32346 +
32347 +#ifdef CONFIG_PAX_KERNEXEC
32348 +#ifdef CONFIG_X86_32
32349 + limit = paravirt_enabled() ? ktva_ktla(0xffffffff) : (unsigned long)&_etext;
32350 + limit = (limit - 1UL) >> PAGE_SHIFT;
32351 +
32352 + memset(__LOAD_PHYSICAL_ADDR + PAGE_OFFSET, POISON_FREE_INITMEM, PAGE_SIZE);
32353 + for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
32354 + pack_descriptor(&d, get_desc_base(&get_cpu_gdt_table(cpu)[GDT_ENTRY_KERNEL_CS]), limit, 0x9B, 0xC);
32355 + write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_KERNEL_CS, &d, DESCTYPE_S);
32356 + write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_KERNEXEC_KERNEL_CS, &d, DESCTYPE_S);
32357 + }
32358 +
32359 + /* PaX: make KERNEL_CS read-only */
32360 + addr = PFN_ALIGN(ktla_ktva((unsigned long)&_text));
32361 + if (!paravirt_enabled())
32362 + set_memory_ro(addr, (PFN_ALIGN(_sdata) - addr) >> PAGE_SHIFT);
32363 +/*
32364 + for (addr = ktla_ktva((unsigned long)&_text); addr < (unsigned long)&_sdata; addr += PMD_SIZE) {
32365 + pgd = pgd_offset_k(addr);
32366 + pud = pud_offset(pgd, addr);
32367 + pmd = pmd_offset(pud, addr);
32368 + set_pmd(pmd, __pmd(pmd_val(*pmd) & ~_PAGE_RW));
32369 + }
32370 +*/
32371 +#ifdef CONFIG_X86_PAE
32372 + set_memory_nx(PFN_ALIGN(__init_begin), (PFN_ALIGN(__init_end) - PFN_ALIGN(__init_begin)) >> PAGE_SHIFT);
32373 +/*
32374 + for (addr = (unsigned long)&__init_begin; addr < (unsigned long)&__init_end; addr += PMD_SIZE) {
32375 + pgd = pgd_offset_k(addr);
32376 + pud = pud_offset(pgd, addr);
32377 + pmd = pmd_offset(pud, addr);
32378 + set_pmd(pmd, __pmd(pmd_val(*pmd) | (_PAGE_NX & __supported_pte_mask)));
32379 + }
32380 +*/
32381 +#endif
32382 +
32383 +#ifdef CONFIG_MODULES
32384 + set_memory_4k((unsigned long)MODULES_EXEC_VADDR, (MODULES_EXEC_END - MODULES_EXEC_VADDR) >> PAGE_SHIFT);
32385 +#endif
32386 +
32387 +#else
32388 + /* PaX: make kernel code/rodata read-only, rest non-executable */
32389 + for (addr = __START_KERNEL_map; addr < __START_KERNEL_map + KERNEL_IMAGE_SIZE; addr += PMD_SIZE) {
32390 + pgd = pgd_offset_k(addr);
32391 + pud = pud_offset(pgd, addr);
32392 + pmd = pmd_offset(pud, addr);
32393 + if (!pmd_present(*pmd))
32394 + continue;
32395 + if ((unsigned long)_text <= addr && addr < (unsigned long)_sdata)
32396 + set_pmd(pmd, __pmd(pmd_val(*pmd) & ~_PAGE_RW));
32397 + else
32398 + set_pmd(pmd, __pmd(pmd_val(*pmd) | (_PAGE_NX & __supported_pte_mask)));
32399 + }
32400 +
32401 + addr = (unsigned long)__va(__pa(__START_KERNEL_map));
32402 + end = addr + KERNEL_IMAGE_SIZE;
32403 + for (; addr < end; addr += PMD_SIZE) {
32404 + pgd = pgd_offset_k(addr);
32405 + pud = pud_offset(pgd, addr);
32406 + pmd = pmd_offset(pud, addr);
32407 + if (!pmd_present(*pmd))
32408 + continue;
32409 + if ((unsigned long)__va(__pa(_text)) <= addr && addr < (unsigned long)__va(__pa(_sdata)))
32410 + set_pmd(pmd, __pmd(pmd_val(*pmd) & ~_PAGE_RW));
32411 + }
32412 +#endif
32413 +
32414 + flush_tlb_all();
32415 +#endif
32416 +
32417 free_init_pages("unused kernel",
32418 (unsigned long)(&__init_begin),
32419 (unsigned long)(&__init_end));
32420 diff --git a/arch/x86/mm/init_32.c b/arch/x86/mm/init_32.c
32421 index e395048..cd38278 100644
32422 --- a/arch/x86/mm/init_32.c
32423 +++ b/arch/x86/mm/init_32.c
32424 @@ -62,33 +62,6 @@ static noinline int do_test_wp_bit(void);
32425 bool __read_mostly __vmalloc_start_set = false;
32426
32427 /*
32428 - * Creates a middle page table and puts a pointer to it in the
32429 - * given global directory entry. This only returns the gd entry
32430 - * in non-PAE compilation mode, since the middle layer is folded.
32431 - */
32432 -static pmd_t * __init one_md_table_init(pgd_t *pgd)
32433 -{
32434 - pud_t *pud;
32435 - pmd_t *pmd_table;
32436 -
32437 -#ifdef CONFIG_X86_PAE
32438 - if (!(pgd_val(*pgd) & _PAGE_PRESENT)) {
32439 - pmd_table = (pmd_t *)alloc_low_page();
32440 - paravirt_alloc_pmd(&init_mm, __pa(pmd_table) >> PAGE_SHIFT);
32441 - set_pgd(pgd, __pgd(__pa(pmd_table) | _PAGE_PRESENT));
32442 - pud = pud_offset(pgd, 0);
32443 - BUG_ON(pmd_table != pmd_offset(pud, 0));
32444 -
32445 - return pmd_table;
32446 - }
32447 -#endif
32448 - pud = pud_offset(pgd, 0);
32449 - pmd_table = pmd_offset(pud, 0);
32450 -
32451 - return pmd_table;
32452 -}
32453 -
32454 -/*
32455 * Create a page table and place a pointer to it in a middle page
32456 * directory entry:
32457 */
32458 @@ -98,13 +71,28 @@ static pte_t * __init one_page_table_init(pmd_t *pmd)
32459 pte_t *page_table = (pte_t *)alloc_low_page();
32460
32461 paravirt_alloc_pte(&init_mm, __pa(page_table) >> PAGE_SHIFT);
32462 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
32463 + set_pmd(pmd, __pmd(__pa(page_table) | _KERNPG_TABLE));
32464 +#else
32465 set_pmd(pmd, __pmd(__pa(page_table) | _PAGE_TABLE));
32466 +#endif
32467 BUG_ON(page_table != pte_offset_kernel(pmd, 0));
32468 }
32469
32470 return pte_offset_kernel(pmd, 0);
32471 }
32472
32473 +static pmd_t * __init one_md_table_init(pgd_t *pgd)
32474 +{
32475 + pud_t *pud;
32476 + pmd_t *pmd_table;
32477 +
32478 + pud = pud_offset(pgd, 0);
32479 + pmd_table = pmd_offset(pud, 0);
32480 +
32481 + return pmd_table;
32482 +}
32483 +
32484 pmd_t * __init populate_extra_pmd(unsigned long vaddr)
32485 {
32486 int pgd_idx = pgd_index(vaddr);
32487 @@ -208,6 +196,7 @@ page_table_range_init(unsigned long start, unsigned long end, pgd_t *pgd_base)
32488 int pgd_idx, pmd_idx;
32489 unsigned long vaddr;
32490 pgd_t *pgd;
32491 + pud_t *pud;
32492 pmd_t *pmd;
32493 pte_t *pte = NULL;
32494 unsigned long count = page_table_range_init_count(start, end);
32495 @@ -222,8 +211,13 @@ page_table_range_init(unsigned long start, unsigned long end, pgd_t *pgd_base)
32496 pgd = pgd_base + pgd_idx;
32497
32498 for ( ; (pgd_idx < PTRS_PER_PGD) && (vaddr != end); pgd++, pgd_idx++) {
32499 - pmd = one_md_table_init(pgd);
32500 - pmd = pmd + pmd_index(vaddr);
32501 + pud = pud_offset(pgd, vaddr);
32502 + pmd = pmd_offset(pud, vaddr);
32503 +
32504 +#ifdef CONFIG_X86_PAE
32505 + paravirt_alloc_pmd(&init_mm, __pa(pmd) >> PAGE_SHIFT);
32506 +#endif
32507 +
32508 for (; (pmd_idx < PTRS_PER_PMD) && (vaddr != end);
32509 pmd++, pmd_idx++) {
32510 pte = page_table_kmap_check(one_page_table_init(pmd),
32511 @@ -235,11 +229,20 @@ page_table_range_init(unsigned long start, unsigned long end, pgd_t *pgd_base)
32512 }
32513 }
32514
32515 -static inline int is_kernel_text(unsigned long addr)
32516 +static inline int is_kernel_text(unsigned long start, unsigned long end)
32517 {
32518 - if (addr >= (unsigned long)_text && addr <= (unsigned long)__init_end)
32519 - return 1;
32520 - return 0;
32521 + if ((start >= ktla_ktva((unsigned long)_etext) ||
32522 + end <= ktla_ktva((unsigned long)_stext)) &&
32523 + (start >= ktla_ktva((unsigned long)_einittext) ||
32524 + end <= ktla_ktva((unsigned long)_sinittext)) &&
32525 +
32526 +#ifdef CONFIG_ACPI_SLEEP
32527 + (start >= (unsigned long)__va(acpi_wakeup_address) + 0x4000 || end <= (unsigned long)__va(acpi_wakeup_address)) &&
32528 +#endif
32529 +
32530 + (start > (unsigned long)__va(0xfffff) || end <= (unsigned long)__va(0xc0000)))
32531 + return 0;
32532 + return 1;
32533 }
32534
32535 /*
32536 @@ -256,9 +259,10 @@ kernel_physical_mapping_init(unsigned long start,
32537 unsigned long last_map_addr = end;
32538 unsigned long start_pfn, end_pfn;
32539 pgd_t *pgd_base = swapper_pg_dir;
32540 - int pgd_idx, pmd_idx, pte_ofs;
32541 + unsigned int pgd_idx, pmd_idx, pte_ofs;
32542 unsigned long pfn;
32543 pgd_t *pgd;
32544 + pud_t *pud;
32545 pmd_t *pmd;
32546 pte_t *pte;
32547 unsigned pages_2m, pages_4k;
32548 @@ -291,8 +295,13 @@ repeat:
32549 pfn = start_pfn;
32550 pgd_idx = pgd_index((pfn<<PAGE_SHIFT) + PAGE_OFFSET);
32551 pgd = pgd_base + pgd_idx;
32552 - for (; pgd_idx < PTRS_PER_PGD; pgd++, pgd_idx++) {
32553 - pmd = one_md_table_init(pgd);
32554 + for (; pgd_idx < PTRS_PER_PGD && pfn < max_low_pfn; pgd++, pgd_idx++) {
32555 + pud = pud_offset(pgd, 0);
32556 + pmd = pmd_offset(pud, 0);
32557 +
32558 +#ifdef CONFIG_X86_PAE
32559 + paravirt_alloc_pmd(&init_mm, __pa(pmd) >> PAGE_SHIFT);
32560 +#endif
32561
32562 if (pfn >= end_pfn)
32563 continue;
32564 @@ -304,14 +313,13 @@ repeat:
32565 #endif
32566 for (; pmd_idx < PTRS_PER_PMD && pfn < end_pfn;
32567 pmd++, pmd_idx++) {
32568 - unsigned int addr = pfn * PAGE_SIZE + PAGE_OFFSET;
32569 + unsigned long address = pfn * PAGE_SIZE + PAGE_OFFSET;
32570
32571 /*
32572 * Map with big pages if possible, otherwise
32573 * create normal page tables:
32574 */
32575 if (use_pse) {
32576 - unsigned int addr2;
32577 pgprot_t prot = PAGE_KERNEL_LARGE;
32578 /*
32579 * first pass will use the same initial
32580 @@ -322,11 +330,7 @@ repeat:
32581 _PAGE_PSE);
32582
32583 pfn &= PMD_MASK >> PAGE_SHIFT;
32584 - addr2 = (pfn + PTRS_PER_PTE-1) * PAGE_SIZE +
32585 - PAGE_OFFSET + PAGE_SIZE-1;
32586 -
32587 - if (is_kernel_text(addr) ||
32588 - is_kernel_text(addr2))
32589 + if (is_kernel_text(address, address + PMD_SIZE))
32590 prot = PAGE_KERNEL_LARGE_EXEC;
32591
32592 pages_2m++;
32593 @@ -343,7 +347,7 @@ repeat:
32594 pte_ofs = pte_index((pfn<<PAGE_SHIFT) + PAGE_OFFSET);
32595 pte += pte_ofs;
32596 for (; pte_ofs < PTRS_PER_PTE && pfn < end_pfn;
32597 - pte++, pfn++, pte_ofs++, addr += PAGE_SIZE) {
32598 + pte++, pfn++, pte_ofs++, address += PAGE_SIZE) {
32599 pgprot_t prot = PAGE_KERNEL;
32600 /*
32601 * first pass will use the same initial
32602 @@ -351,7 +355,7 @@ repeat:
32603 */
32604 pgprot_t init_prot = __pgprot(PTE_IDENT_ATTR);
32605
32606 - if (is_kernel_text(addr))
32607 + if (is_kernel_text(address, address + PAGE_SIZE))
32608 prot = PAGE_KERNEL_EXEC;
32609
32610 pages_4k++;
32611 @@ -474,7 +478,7 @@ void __init native_pagetable_init(void)
32612
32613 pud = pud_offset(pgd, va);
32614 pmd = pmd_offset(pud, va);
32615 - if (!pmd_present(*pmd))
32616 + if (!pmd_present(*pmd)) // PAX TODO || pmd_large(*pmd))
32617 break;
32618
32619 /* should not be large page here */
32620 @@ -532,12 +536,10 @@ void __init early_ioremap_page_table_range_init(void)
32621
32622 static void __init pagetable_init(void)
32623 {
32624 - pgd_t *pgd_base = swapper_pg_dir;
32625 -
32626 - permanent_kmaps_init(pgd_base);
32627 + permanent_kmaps_init(swapper_pg_dir);
32628 }
32629
32630 -pteval_t __supported_pte_mask __read_mostly = ~(_PAGE_NX | _PAGE_GLOBAL | _PAGE_IOMAP);
32631 +pteval_t __supported_pte_mask __read_only = ~(_PAGE_NX | _PAGE_GLOBAL | _PAGE_IOMAP);
32632 EXPORT_SYMBOL_GPL(__supported_pte_mask);
32633
32634 /* user-defined highmem size */
32635 @@ -787,10 +789,10 @@ void __init mem_init(void)
32636 ((unsigned long)&__init_end -
32637 (unsigned long)&__init_begin) >> 10,
32638
32639 - (unsigned long)&_etext, (unsigned long)&_edata,
32640 - ((unsigned long)&_edata - (unsigned long)&_etext) >> 10,
32641 + (unsigned long)&_sdata, (unsigned long)&_edata,
32642 + ((unsigned long)&_edata - (unsigned long)&_sdata) >> 10,
32643
32644 - (unsigned long)&_text, (unsigned long)&_etext,
32645 + ktla_ktva((unsigned long)&_text), ktla_ktva((unsigned long)&_etext),
32646 ((unsigned long)&_etext - (unsigned long)&_text) >> 10);
32647
32648 /*
32649 @@ -883,6 +885,7 @@ void set_kernel_text_rw(void)
32650 if (!kernel_set_to_readonly)
32651 return;
32652
32653 + start = ktla_ktva(start);
32654 pr_debug("Set kernel text: %lx - %lx for read write\n",
32655 start, start+size);
32656
32657 @@ -897,6 +900,7 @@ void set_kernel_text_ro(void)
32658 if (!kernel_set_to_readonly)
32659 return;
32660
32661 + start = ktla_ktva(start);
32662 pr_debug("Set kernel text: %lx - %lx for read only\n",
32663 start, start+size);
32664
32665 @@ -925,6 +929,7 @@ void mark_rodata_ro(void)
32666 unsigned long start = PFN_ALIGN(_text);
32667 unsigned long size = PFN_ALIGN(_etext) - start;
32668
32669 + start = ktla_ktva(start);
32670 set_pages_ro(virt_to_page(start), size >> PAGE_SHIFT);
32671 printk(KERN_INFO "Write protecting the kernel text: %luk\n",
32672 size >> 10);
32673 diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
32674 index f35c66c..84b95ef 100644
32675 --- a/arch/x86/mm/init_64.c
32676 +++ b/arch/x86/mm/init_64.c
32677 @@ -151,7 +151,7 @@ early_param("gbpages", parse_direct_gbpages_on);
32678 * around without checking the pgd every time.
32679 */
32680
32681 -pteval_t __supported_pte_mask __read_mostly = ~_PAGE_IOMAP;
32682 +pteval_t __supported_pte_mask __read_only = ~(_PAGE_NX | _PAGE_IOMAP);
32683 EXPORT_SYMBOL_GPL(__supported_pte_mask);
32684
32685 int force_personality32;
32686 @@ -184,12 +184,29 @@ void sync_global_pgds(unsigned long start, unsigned long end)
32687
32688 for (address = start; address <= end; address += PGDIR_SIZE) {
32689 const pgd_t *pgd_ref = pgd_offset_k(address);
32690 +
32691 +#ifdef CONFIG_PAX_PER_CPU_PGD
32692 + unsigned long cpu;
32693 +#else
32694 struct page *page;
32695 +#endif
32696
32697 if (pgd_none(*pgd_ref))
32698 continue;
32699
32700 spin_lock(&pgd_lock);
32701 +
32702 +#ifdef CONFIG_PAX_PER_CPU_PGD
32703 + for (cpu = 0; cpu < nr_cpu_ids; ++cpu) {
32704 + pgd_t *pgd = pgd_offset_cpu(cpu, user, address);
32705 +
32706 + if (pgd_none(*pgd))
32707 + set_pgd(pgd, *pgd_ref);
32708 + else
32709 + BUG_ON(pgd_page_vaddr(*pgd)
32710 + != pgd_page_vaddr(*pgd_ref));
32711 + pgd = pgd_offset_cpu(cpu, kernel, address);
32712 +#else
32713 list_for_each_entry(page, &pgd_list, lru) {
32714 pgd_t *pgd;
32715 spinlock_t *pgt_lock;
32716 @@ -198,6 +215,7 @@ void sync_global_pgds(unsigned long start, unsigned long end)
32717 /* the pgt_lock only for Xen */
32718 pgt_lock = &pgd_page_get_mm(page)->page_table_lock;
32719 spin_lock(pgt_lock);
32720 +#endif
32721
32722 if (pgd_none(*pgd))
32723 set_pgd(pgd, *pgd_ref);
32724 @@ -205,7 +223,10 @@ void sync_global_pgds(unsigned long start, unsigned long end)
32725 BUG_ON(pgd_page_vaddr(*pgd)
32726 != pgd_page_vaddr(*pgd_ref));
32727
32728 +#ifndef CONFIG_PAX_PER_CPU_PGD
32729 spin_unlock(pgt_lock);
32730 +#endif
32731 +
32732 }
32733 spin_unlock(&pgd_lock);
32734 }
32735 @@ -238,7 +259,7 @@ static pud_t *fill_pud(pgd_t *pgd, unsigned long vaddr)
32736 {
32737 if (pgd_none(*pgd)) {
32738 pud_t *pud = (pud_t *)spp_getpage();
32739 - pgd_populate(&init_mm, pgd, pud);
32740 + pgd_populate_kernel(&init_mm, pgd, pud);
32741 if (pud != pud_offset(pgd, 0))
32742 printk(KERN_ERR "PAGETABLE BUG #00! %p <-> %p\n",
32743 pud, pud_offset(pgd, 0));
32744 @@ -250,7 +271,7 @@ static pmd_t *fill_pmd(pud_t *pud, unsigned long vaddr)
32745 {
32746 if (pud_none(*pud)) {
32747 pmd_t *pmd = (pmd_t *) spp_getpage();
32748 - pud_populate(&init_mm, pud, pmd);
32749 + pud_populate_kernel(&init_mm, pud, pmd);
32750 if (pmd != pmd_offset(pud, 0))
32751 printk(KERN_ERR "PAGETABLE BUG #01! %p <-> %p\n",
32752 pmd, pmd_offset(pud, 0));
32753 @@ -279,7 +300,9 @@ void set_pte_vaddr_pud(pud_t *pud_page, unsigned long vaddr, pte_t new_pte)
32754 pmd = fill_pmd(pud, vaddr);
32755 pte = fill_pte(pmd, vaddr);
32756
32757 + pax_open_kernel();
32758 set_pte(pte, new_pte);
32759 + pax_close_kernel();
32760
32761 /*
32762 * It's enough to flush this one mapping.
32763 @@ -338,14 +361,12 @@ static void __init __init_extra_mapping(unsigned long phys, unsigned long size,
32764 pgd = pgd_offset_k((unsigned long)__va(phys));
32765 if (pgd_none(*pgd)) {
32766 pud = (pud_t *) spp_getpage();
32767 - set_pgd(pgd, __pgd(__pa(pud) | _KERNPG_TABLE |
32768 - _PAGE_USER));
32769 + set_pgd(pgd, __pgd(__pa(pud) | _PAGE_TABLE));
32770 }
32771 pud = pud_offset(pgd, (unsigned long)__va(phys));
32772 if (pud_none(*pud)) {
32773 pmd = (pmd_t *) spp_getpage();
32774 - set_pud(pud, __pud(__pa(pmd) | _KERNPG_TABLE |
32775 - _PAGE_USER));
32776 + set_pud(pud, __pud(__pa(pmd) | _PAGE_TABLE));
32777 }
32778 pmd = pmd_offset(pud, phys);
32779 BUG_ON(!pmd_none(*pmd));
32780 @@ -586,7 +607,7 @@ phys_pud_init(pud_t *pud_page, unsigned long addr, unsigned long end,
32781 prot);
32782
32783 spin_lock(&init_mm.page_table_lock);
32784 - pud_populate(&init_mm, pud, pmd);
32785 + pud_populate_kernel(&init_mm, pud, pmd);
32786 spin_unlock(&init_mm.page_table_lock);
32787 }
32788 __flush_tlb_all();
32789 @@ -627,7 +648,7 @@ kernel_physical_mapping_init(unsigned long start,
32790 page_size_mask);
32791
32792 spin_lock(&init_mm.page_table_lock);
32793 - pgd_populate(&init_mm, pgd, pud);
32794 + pgd_populate_kernel(&init_mm, pgd, pud);
32795 spin_unlock(&init_mm.page_table_lock);
32796 pgd_changed = true;
32797 }
32798 @@ -1188,8 +1209,8 @@ int kern_addr_valid(unsigned long addr)
32799 static struct vm_area_struct gate_vma = {
32800 .vm_start = VSYSCALL_START,
32801 .vm_end = VSYSCALL_START + (VSYSCALL_MAPPED_PAGES * PAGE_SIZE),
32802 - .vm_page_prot = PAGE_READONLY_EXEC,
32803 - .vm_flags = VM_READ | VM_EXEC
32804 + .vm_page_prot = PAGE_READONLY,
32805 + .vm_flags = VM_READ
32806 };
32807
32808 struct vm_area_struct *get_gate_vma(struct mm_struct *mm)
32809 @@ -1223,7 +1244,7 @@ int in_gate_area_no_mm(unsigned long addr)
32810
32811 const char *arch_vma_name(struct vm_area_struct *vma)
32812 {
32813 - if (vma->vm_mm && vma->vm_start == (long)vma->vm_mm->context.vdso)
32814 + if (vma->vm_mm && vma->vm_start == vma->vm_mm->context.vdso)
32815 return "[vdso]";
32816 if (vma == &gate_vma)
32817 return "[vsyscall]";
32818 diff --git a/arch/x86/mm/iomap_32.c b/arch/x86/mm/iomap_32.c
32819 index 7b179b4..6bd17777 100644
32820 --- a/arch/x86/mm/iomap_32.c
32821 +++ b/arch/x86/mm/iomap_32.c
32822 @@ -64,7 +64,11 @@ void *kmap_atomic_prot_pfn(unsigned long pfn, pgprot_t prot)
32823 type = kmap_atomic_idx_push();
32824 idx = type + KM_TYPE_NR * smp_processor_id();
32825 vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
32826 +
32827 + pax_open_kernel();
32828 set_pte(kmap_pte - idx, pfn_pte(pfn, prot));
32829 + pax_close_kernel();
32830 +
32831 arch_flush_lazy_mmu_mode();
32832
32833 return (void *)vaddr;
32834 diff --git a/arch/x86/mm/ioremap.c b/arch/x86/mm/ioremap.c
32835 index 597ac15..49841be 100644
32836 --- a/arch/x86/mm/ioremap.c
32837 +++ b/arch/x86/mm/ioremap.c
32838 @@ -97,7 +97,7 @@ static void __iomem *__ioremap_caller(resource_size_t phys_addr,
32839 for (pfn = phys_addr >> PAGE_SHIFT; pfn <= last_pfn; pfn++) {
32840 int is_ram = page_is_ram(pfn);
32841
32842 - if (is_ram && pfn_valid(pfn) && !PageReserved(pfn_to_page(pfn)))
32843 + if (is_ram && pfn_valid(pfn) && (pfn >= 0x100 || !PageReserved(pfn_to_page(pfn))))
32844 return NULL;
32845 WARN_ON_ONCE(is_ram);
32846 }
32847 @@ -256,7 +256,7 @@ EXPORT_SYMBOL(ioremap_prot);
32848 *
32849 * Caller must ensure there is only one unmapping for the same pointer.
32850 */
32851 -void iounmap(volatile void __iomem *addr)
32852 +void iounmap(const volatile void __iomem *addr)
32853 {
32854 struct vm_struct *p, *o;
32855
32856 @@ -310,6 +310,9 @@ void *xlate_dev_mem_ptr(unsigned long phys)
32857
32858 /* If page is RAM, we can use __va. Otherwise ioremap and unmap. */
32859 if (page_is_ram(start >> PAGE_SHIFT))
32860 +#ifdef CONFIG_HIGHMEM
32861 + if ((start >> PAGE_SHIFT) < max_low_pfn)
32862 +#endif
32863 return __va(phys);
32864
32865 addr = (void __force *)ioremap_cache(start, PAGE_SIZE);
32866 @@ -322,13 +325,16 @@ void *xlate_dev_mem_ptr(unsigned long phys)
32867 void unxlate_dev_mem_ptr(unsigned long phys, void *addr)
32868 {
32869 if (page_is_ram(phys >> PAGE_SHIFT))
32870 +#ifdef CONFIG_HIGHMEM
32871 + if ((phys >> PAGE_SHIFT) < max_low_pfn)
32872 +#endif
32873 return;
32874
32875 iounmap((void __iomem *)((unsigned long)addr & PAGE_MASK));
32876 return;
32877 }
32878
32879 -static pte_t bm_pte[PAGE_SIZE/sizeof(pte_t)] __page_aligned_bss;
32880 +static pte_t bm_pte[PAGE_SIZE/sizeof(pte_t)] __read_only __aligned(PAGE_SIZE);
32881
32882 static inline pmd_t * __init early_ioremap_pmd(unsigned long addr)
32883 {
32884 @@ -358,8 +364,7 @@ void __init early_ioremap_init(void)
32885 early_ioremap_setup();
32886
32887 pmd = early_ioremap_pmd(fix_to_virt(FIX_BTMAP_BEGIN));
32888 - memset(bm_pte, 0, sizeof(bm_pte));
32889 - pmd_populate_kernel(&init_mm, pmd, bm_pte);
32890 + pmd_populate_user(&init_mm, pmd, bm_pte);
32891
32892 /*
32893 * The boot-ioremap range spans multiple pmds, for which
32894 diff --git a/arch/x86/mm/kmemcheck/kmemcheck.c b/arch/x86/mm/kmemcheck/kmemcheck.c
32895 index dd89a13..d77bdcc 100644
32896 --- a/arch/x86/mm/kmemcheck/kmemcheck.c
32897 +++ b/arch/x86/mm/kmemcheck/kmemcheck.c
32898 @@ -628,9 +628,9 @@ bool kmemcheck_fault(struct pt_regs *regs, unsigned long address,
32899 * memory (e.g. tracked pages)? For now, we need this to avoid
32900 * invoking kmemcheck for PnP BIOS calls.
32901 */
32902 - if (regs->flags & X86_VM_MASK)
32903 + if (v8086_mode(regs))
32904 return false;
32905 - if (regs->cs != __KERNEL_CS)
32906 + if (regs->cs != __KERNEL_CS && regs->cs != __KERNEXEC_KERNEL_CS)
32907 return false;
32908
32909 pte = kmemcheck_pte_lookup(address);
32910 diff --git a/arch/x86/mm/mmap.c b/arch/x86/mm/mmap.c
32911 index 25e7e13..1964579 100644
32912 --- a/arch/x86/mm/mmap.c
32913 +++ b/arch/x86/mm/mmap.c
32914 @@ -52,7 +52,7 @@ static unsigned int stack_maxrandom_size(void)
32915 * Leave an at least ~128 MB hole with possible stack randomization.
32916 */
32917 #define MIN_GAP (128*1024*1024UL + stack_maxrandom_size())
32918 -#define MAX_GAP (TASK_SIZE/6*5)
32919 +#define MAX_GAP (pax_task_size/6*5)
32920
32921 static int mmap_is_legacy(void)
32922 {
32923 @@ -82,27 +82,40 @@ static unsigned long mmap_rnd(void)
32924 return rnd << PAGE_SHIFT;
32925 }
32926
32927 -static unsigned long mmap_base(void)
32928 +static unsigned long mmap_base(struct mm_struct *mm)
32929 {
32930 unsigned long gap = rlimit(RLIMIT_STACK);
32931 + unsigned long pax_task_size = TASK_SIZE;
32932 +
32933 +#ifdef CONFIG_PAX_SEGMEXEC
32934 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
32935 + pax_task_size = SEGMEXEC_TASK_SIZE;
32936 +#endif
32937
32938 if (gap < MIN_GAP)
32939 gap = MIN_GAP;
32940 else if (gap > MAX_GAP)
32941 gap = MAX_GAP;
32942
32943 - return PAGE_ALIGN(TASK_SIZE - gap - mmap_rnd());
32944 + return PAGE_ALIGN(pax_task_size - gap - mmap_rnd());
32945 }
32946
32947 /*
32948 * Bottom-up (legacy) layout on X86_32 did not support randomization, X86_64
32949 * does, but not when emulating X86_32
32950 */
32951 -static unsigned long mmap_legacy_base(void)
32952 +static unsigned long mmap_legacy_base(struct mm_struct *mm)
32953 {
32954 - if (mmap_is_ia32())
32955 + if (mmap_is_ia32()) {
32956 +
32957 +#ifdef CONFIG_PAX_SEGMEXEC
32958 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
32959 + return SEGMEXEC_TASK_UNMAPPED_BASE;
32960 + else
32961 +#endif
32962 +
32963 return TASK_UNMAPPED_BASE;
32964 - else
32965 + } else
32966 return TASK_UNMAPPED_BASE + mmap_rnd();
32967 }
32968
32969 @@ -112,8 +125,15 @@ static unsigned long mmap_legacy_base(void)
32970 */
32971 void arch_pick_mmap_layout(struct mm_struct *mm)
32972 {
32973 - mm->mmap_legacy_base = mmap_legacy_base();
32974 - mm->mmap_base = mmap_base();
32975 + mm->mmap_legacy_base = mmap_legacy_base(mm);
32976 + mm->mmap_base = mmap_base(mm);
32977 +
32978 +#ifdef CONFIG_PAX_RANDMMAP
32979 + if (mm->pax_flags & MF_PAX_RANDMMAP) {
32980 + mm->mmap_legacy_base += mm->delta_mmap;
32981 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
32982 + }
32983 +#endif
32984
32985 if (mmap_is_legacy()) {
32986 mm->mmap_base = mm->mmap_legacy_base;
32987 diff --git a/arch/x86/mm/mmio-mod.c b/arch/x86/mm/mmio-mod.c
32988 index 0057a7a..95c7edd 100644
32989 --- a/arch/x86/mm/mmio-mod.c
32990 +++ b/arch/x86/mm/mmio-mod.c
32991 @@ -194,7 +194,7 @@ static void pre(struct kmmio_probe *p, struct pt_regs *regs,
32992 break;
32993 default:
32994 {
32995 - unsigned char *ip = (unsigned char *)instptr;
32996 + unsigned char *ip = (unsigned char *)ktla_ktva(instptr);
32997 my_trace->opcode = MMIO_UNKNOWN_OP;
32998 my_trace->width = 0;
32999 my_trace->value = (*ip) << 16 | *(ip + 1) << 8 |
33000 @@ -234,7 +234,7 @@ static void post(struct kmmio_probe *p, unsigned long condition,
33001 static void ioremap_trace_core(resource_size_t offset, unsigned long size,
33002 void __iomem *addr)
33003 {
33004 - static atomic_t next_id;
33005 + static atomic_unchecked_t next_id;
33006 struct remap_trace *trace = kmalloc(sizeof(*trace), GFP_KERNEL);
33007 /* These are page-unaligned. */
33008 struct mmiotrace_map map = {
33009 @@ -258,7 +258,7 @@ static void ioremap_trace_core(resource_size_t offset, unsigned long size,
33010 .private = trace
33011 },
33012 .phys = offset,
33013 - .id = atomic_inc_return(&next_id)
33014 + .id = atomic_inc_return_unchecked(&next_id)
33015 };
33016 map.map_id = trace->id;
33017
33018 @@ -290,7 +290,7 @@ void mmiotrace_ioremap(resource_size_t offset, unsigned long size,
33019 ioremap_trace_core(offset, size, addr);
33020 }
33021
33022 -static void iounmap_trace_core(volatile void __iomem *addr)
33023 +static void iounmap_trace_core(const volatile void __iomem *addr)
33024 {
33025 struct mmiotrace_map map = {
33026 .phys = 0,
33027 @@ -328,7 +328,7 @@ not_enabled:
33028 }
33029 }
33030
33031 -void mmiotrace_iounmap(volatile void __iomem *addr)
33032 +void mmiotrace_iounmap(const volatile void __iomem *addr)
33033 {
33034 might_sleep();
33035 if (is_enabled()) /* recheck and proper locking in *_core() */
33036 diff --git a/arch/x86/mm/numa.c b/arch/x86/mm/numa.c
33037 index 1d045f9..3a00249 100644
33038 --- a/arch/x86/mm/numa.c
33039 +++ b/arch/x86/mm/numa.c
33040 @@ -478,7 +478,7 @@ static bool __init numa_meminfo_cover_memory(const struct numa_meminfo *mi)
33041 return true;
33042 }
33043
33044 -static int __init numa_register_memblks(struct numa_meminfo *mi)
33045 +static int __init __intentional_overflow(-1) numa_register_memblks(struct numa_meminfo *mi)
33046 {
33047 unsigned long uninitialized_var(pfn_align);
33048 int i, nid;
33049 diff --git a/arch/x86/mm/pageattr-test.c b/arch/x86/mm/pageattr-test.c
33050 index 461bc82..4e091a3 100644
33051 --- a/arch/x86/mm/pageattr-test.c
33052 +++ b/arch/x86/mm/pageattr-test.c
33053 @@ -35,7 +35,7 @@ enum {
33054
33055 static int pte_testbit(pte_t pte)
33056 {
33057 - return pte_flags(pte) & _PAGE_UNUSED1;
33058 + return pte_flags(pte) & _PAGE_CPA_TEST;
33059 }
33060
33061 struct split_state {
33062 diff --git a/arch/x86/mm/pageattr.c b/arch/x86/mm/pageattr.c
33063 index ae242a7..1c7998f 100644
33064 --- a/arch/x86/mm/pageattr.c
33065 +++ b/arch/x86/mm/pageattr.c
33066 @@ -262,7 +262,7 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
33067 */
33068 #ifdef CONFIG_PCI_BIOS
33069 if (pcibios_enabled && within(pfn, BIOS_BEGIN >> PAGE_SHIFT, BIOS_END >> PAGE_SHIFT))
33070 - pgprot_val(forbidden) |= _PAGE_NX;
33071 + pgprot_val(forbidden) |= _PAGE_NX & __supported_pte_mask;
33072 #endif
33073
33074 /*
33075 @@ -270,9 +270,10 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
33076 * Does not cover __inittext since that is gone later on. On
33077 * 64bit we do not enforce !NX on the low mapping
33078 */
33079 - if (within(address, (unsigned long)_text, (unsigned long)_etext))
33080 - pgprot_val(forbidden) |= _PAGE_NX;
33081 + if (within(address, ktla_ktva((unsigned long)_text), ktla_ktva((unsigned long)_etext)))
33082 + pgprot_val(forbidden) |= _PAGE_NX & __supported_pte_mask;
33083
33084 +#ifdef CONFIG_DEBUG_RODATA
33085 /*
33086 * The .rodata section needs to be read-only. Using the pfn
33087 * catches all aliases.
33088 @@ -280,6 +281,7 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
33089 if (within(pfn, __pa_symbol(__start_rodata) >> PAGE_SHIFT,
33090 __pa_symbol(__end_rodata) >> PAGE_SHIFT))
33091 pgprot_val(forbidden) |= _PAGE_RW;
33092 +#endif
33093
33094 #if defined(CONFIG_X86_64) && defined(CONFIG_DEBUG_RODATA)
33095 /*
33096 @@ -318,6 +320,13 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
33097 }
33098 #endif
33099
33100 +#ifdef CONFIG_PAX_KERNEXEC
33101 + if (within(pfn, __pa(ktla_ktva((unsigned long)&_text)), __pa((unsigned long)&_sdata))) {
33102 + pgprot_val(forbidden) |= _PAGE_RW;
33103 + pgprot_val(forbidden) |= _PAGE_NX & __supported_pte_mask;
33104 + }
33105 +#endif
33106 +
33107 prot = __pgprot(pgprot_val(prot) & ~pgprot_val(forbidden));
33108
33109 return prot;
33110 @@ -420,23 +429,37 @@ EXPORT_SYMBOL_GPL(slow_virt_to_phys);
33111 static void __set_pmd_pte(pte_t *kpte, unsigned long address, pte_t pte)
33112 {
33113 /* change init_mm */
33114 + pax_open_kernel();
33115 set_pte_atomic(kpte, pte);
33116 +
33117 #ifdef CONFIG_X86_32
33118 if (!SHARED_KERNEL_PMD) {
33119 +
33120 +#ifdef CONFIG_PAX_PER_CPU_PGD
33121 + unsigned long cpu;
33122 +#else
33123 struct page *page;
33124 +#endif
33125
33126 +#ifdef CONFIG_PAX_PER_CPU_PGD
33127 + for (cpu = 0; cpu < nr_cpu_ids; ++cpu) {
33128 + pgd_t *pgd = get_cpu_pgd(cpu, kernel);
33129 +#else
33130 list_for_each_entry(page, &pgd_list, lru) {
33131 - pgd_t *pgd;
33132 + pgd_t *pgd = (pgd_t *)page_address(page);
33133 +#endif
33134 +
33135 pud_t *pud;
33136 pmd_t *pmd;
33137
33138 - pgd = (pgd_t *)page_address(page) + pgd_index(address);
33139 + pgd += pgd_index(address);
33140 pud = pud_offset(pgd, address);
33141 pmd = pmd_offset(pud, address);
33142 set_pte_atomic((pte_t *)pmd, pte);
33143 }
33144 }
33145 #endif
33146 + pax_close_kernel();
33147 }
33148
33149 static int
33150 diff --git a/arch/x86/mm/pat.c b/arch/x86/mm/pat.c
33151 index 6574388..87e9bef 100644
33152 --- a/arch/x86/mm/pat.c
33153 +++ b/arch/x86/mm/pat.c
33154 @@ -376,7 +376,7 @@ int free_memtype(u64 start, u64 end)
33155
33156 if (!entry) {
33157 printk(KERN_INFO "%s:%d freeing invalid memtype [mem %#010Lx-%#010Lx]\n",
33158 - current->comm, current->pid, start, end - 1);
33159 + current->comm, task_pid_nr(current), start, end - 1);
33160 return -EINVAL;
33161 }
33162
33163 @@ -506,8 +506,8 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size)
33164
33165 while (cursor < to) {
33166 if (!devmem_is_allowed(pfn)) {
33167 - printk(KERN_INFO "Program %s tried to access /dev/mem between [mem %#010Lx-%#010Lx]\n",
33168 - current->comm, from, to - 1);
33169 + printk(KERN_INFO "Program %s tried to access /dev/mem between [mem %#010Lx-%#010Lx] (%#010Lx)\n",
33170 + current->comm, from, to - 1, cursor);
33171 return 0;
33172 }
33173 cursor += PAGE_SIZE;
33174 @@ -577,7 +577,7 @@ int kernel_map_sync_memtype(u64 base, unsigned long size, unsigned long flags)
33175 if (ioremap_change_attr((unsigned long)__va(base), id_sz, flags) < 0) {
33176 printk(KERN_INFO "%s:%d ioremap_change_attr failed %s "
33177 "for [mem %#010Lx-%#010Lx]\n",
33178 - current->comm, current->pid,
33179 + current->comm, task_pid_nr(current),
33180 cattr_name(flags),
33181 base, (unsigned long long)(base + size-1));
33182 return -EINVAL;
33183 @@ -612,7 +612,7 @@ static int reserve_pfn_range(u64 paddr, unsigned long size, pgprot_t *vma_prot,
33184 flags = lookup_memtype(paddr);
33185 if (want_flags != flags) {
33186 printk(KERN_WARNING "%s:%d map pfn RAM range req %s for [mem %#010Lx-%#010Lx], got %s\n",
33187 - current->comm, current->pid,
33188 + current->comm, task_pid_nr(current),
33189 cattr_name(want_flags),
33190 (unsigned long long)paddr,
33191 (unsigned long long)(paddr + size - 1),
33192 @@ -634,7 +634,7 @@ static int reserve_pfn_range(u64 paddr, unsigned long size, pgprot_t *vma_prot,
33193 free_memtype(paddr, paddr + size);
33194 printk(KERN_ERR "%s:%d map pfn expected mapping type %s"
33195 " for [mem %#010Lx-%#010Lx], got %s\n",
33196 - current->comm, current->pid,
33197 + current->comm, task_pid_nr(current),
33198 cattr_name(want_flags),
33199 (unsigned long long)paddr,
33200 (unsigned long long)(paddr + size - 1),
33201 diff --git a/arch/x86/mm/pat_rbtree.c b/arch/x86/mm/pat_rbtree.c
33202 index 415f6c4..d319983 100644
33203 --- a/arch/x86/mm/pat_rbtree.c
33204 +++ b/arch/x86/mm/pat_rbtree.c
33205 @@ -160,7 +160,7 @@ success:
33206
33207 failure:
33208 printk(KERN_INFO "%s:%d conflicting memory types "
33209 - "%Lx-%Lx %s<->%s\n", current->comm, current->pid, start,
33210 + "%Lx-%Lx %s<->%s\n", current->comm, task_pid_nr(current), start,
33211 end, cattr_name(found_type), cattr_name(match->type));
33212 return -EBUSY;
33213 }
33214 diff --git a/arch/x86/mm/pf_in.c b/arch/x86/mm/pf_in.c
33215 index 9f0614d..92ae64a 100644
33216 --- a/arch/x86/mm/pf_in.c
33217 +++ b/arch/x86/mm/pf_in.c
33218 @@ -148,7 +148,7 @@ enum reason_type get_ins_type(unsigned long ins_addr)
33219 int i;
33220 enum reason_type rv = OTHERS;
33221
33222 - p = (unsigned char *)ins_addr;
33223 + p = (unsigned char *)ktla_ktva(ins_addr);
33224 p += skip_prefix(p, &prf);
33225 p += get_opcode(p, &opcode);
33226
33227 @@ -168,7 +168,7 @@ static unsigned int get_ins_reg_width(unsigned long ins_addr)
33228 struct prefix_bits prf;
33229 int i;
33230
33231 - p = (unsigned char *)ins_addr;
33232 + p = (unsigned char *)ktla_ktva(ins_addr);
33233 p += skip_prefix(p, &prf);
33234 p += get_opcode(p, &opcode);
33235
33236 @@ -191,7 +191,7 @@ unsigned int get_ins_mem_width(unsigned long ins_addr)
33237 struct prefix_bits prf;
33238 int i;
33239
33240 - p = (unsigned char *)ins_addr;
33241 + p = (unsigned char *)ktla_ktva(ins_addr);
33242 p += skip_prefix(p, &prf);
33243 p += get_opcode(p, &opcode);
33244
33245 @@ -415,7 +415,7 @@ unsigned long get_ins_reg_val(unsigned long ins_addr, struct pt_regs *regs)
33246 struct prefix_bits prf;
33247 int i;
33248
33249 - p = (unsigned char *)ins_addr;
33250 + p = (unsigned char *)ktla_ktva(ins_addr);
33251 p += skip_prefix(p, &prf);
33252 p += get_opcode(p, &opcode);
33253 for (i = 0; i < ARRAY_SIZE(reg_rop); i++)
33254 @@ -470,7 +470,7 @@ unsigned long get_ins_imm_val(unsigned long ins_addr)
33255 struct prefix_bits prf;
33256 int i;
33257
33258 - p = (unsigned char *)ins_addr;
33259 + p = (unsigned char *)ktla_ktva(ins_addr);
33260 p += skip_prefix(p, &prf);
33261 p += get_opcode(p, &opcode);
33262 for (i = 0; i < ARRAY_SIZE(imm_wop); i++)
33263 diff --git a/arch/x86/mm/pgtable.c b/arch/x86/mm/pgtable.c
33264 index c96314a..433b127 100644
33265 --- a/arch/x86/mm/pgtable.c
33266 +++ b/arch/x86/mm/pgtable.c
33267 @@ -97,10 +97,71 @@ static inline void pgd_list_del(pgd_t *pgd)
33268 list_del(&page->lru);
33269 }
33270
33271 -#define UNSHARED_PTRS_PER_PGD \
33272 - (SHARED_KERNEL_PMD ? KERNEL_PGD_BOUNDARY : PTRS_PER_PGD)
33273 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
33274 +pgdval_t clone_pgd_mask __read_only = ~_PAGE_PRESENT;
33275
33276 +void __shadow_user_pgds(pgd_t *dst, const pgd_t *src)
33277 +{
33278 + unsigned int count = USER_PGD_PTRS;
33279
33280 + if (!pax_user_shadow_base)
33281 + return;
33282 +
33283 + while (count--)
33284 + *dst++ = __pgd((pgd_val(*src++) | (_PAGE_NX & __supported_pte_mask)) & ~_PAGE_USER);
33285 +}
33286 +#endif
33287 +
33288 +#ifdef CONFIG_PAX_PER_CPU_PGD
33289 +void __clone_user_pgds(pgd_t *dst, const pgd_t *src)
33290 +{
33291 + unsigned int count = USER_PGD_PTRS;
33292 +
33293 + while (count--) {
33294 + pgd_t pgd;
33295 +
33296 +#ifdef CONFIG_X86_64
33297 + pgd = __pgd(pgd_val(*src++) | _PAGE_USER);
33298 +#else
33299 + pgd = *src++;
33300 +#endif
33301 +
33302 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
33303 + pgd = __pgd(pgd_val(pgd) & clone_pgd_mask);
33304 +#endif
33305 +
33306 + *dst++ = pgd;
33307 + }
33308 +
33309 +}
33310 +#endif
33311 +
33312 +#ifdef CONFIG_X86_64
33313 +#define pxd_t pud_t
33314 +#define pyd_t pgd_t
33315 +#define paravirt_release_pxd(pfn) paravirt_release_pud(pfn)
33316 +#define pgtable_pxd_page_ctor(page) true
33317 +#define pgtable_pxd_page_dtor(page)
33318 +#define pxd_free(mm, pud) pud_free((mm), (pud))
33319 +#define pyd_populate(mm, pgd, pud) pgd_populate((mm), (pgd), (pud))
33320 +#define pyd_offset(mm, address) pgd_offset((mm), (address))
33321 +#define PYD_SIZE PGDIR_SIZE
33322 +#else
33323 +#define pxd_t pmd_t
33324 +#define pyd_t pud_t
33325 +#define paravirt_release_pxd(pfn) paravirt_release_pmd(pfn)
33326 +#define pgtable_pxd_page_ctor(page) pgtable_pmd_page_ctor(page)
33327 +#define pgtable_pxd_page_dtor(page) pgtable_pmd_page_dtor(page)
33328 +#define pxd_free(mm, pud) pmd_free((mm), (pud))
33329 +#define pyd_populate(mm, pgd, pud) pud_populate((mm), (pgd), (pud))
33330 +#define pyd_offset(mm, address) pud_offset((mm), (address))
33331 +#define PYD_SIZE PUD_SIZE
33332 +#endif
33333 +
33334 +#ifdef CONFIG_PAX_PER_CPU_PGD
33335 +static inline void pgd_ctor(struct mm_struct *mm, pgd_t *pgd) {}
33336 +static inline void pgd_dtor(pgd_t *pgd) {}
33337 +#else
33338 static void pgd_set_mm(pgd_t *pgd, struct mm_struct *mm)
33339 {
33340 BUILD_BUG_ON(sizeof(virt_to_page(pgd)->index) < sizeof(mm));
33341 @@ -141,6 +202,7 @@ static void pgd_dtor(pgd_t *pgd)
33342 pgd_list_del(pgd);
33343 spin_unlock(&pgd_lock);
33344 }
33345 +#endif
33346
33347 /*
33348 * List of all pgd's needed for non-PAE so it can invalidate entries
33349 @@ -153,7 +215,7 @@ static void pgd_dtor(pgd_t *pgd)
33350 * -- nyc
33351 */
33352
33353 -#ifdef CONFIG_X86_PAE
33354 +#if defined(CONFIG_X86_32) && defined(CONFIG_X86_PAE)
33355 /*
33356 * In PAE mode, we need to do a cr3 reload (=tlb flush) when
33357 * updating the top-level pagetable entries to guarantee the
33358 @@ -165,7 +227,7 @@ static void pgd_dtor(pgd_t *pgd)
33359 * not shared between pagetables (!SHARED_KERNEL_PMDS), we allocate
33360 * and initialize the kernel pmds here.
33361 */
33362 -#define PREALLOCATED_PMDS UNSHARED_PTRS_PER_PGD
33363 +#define PREALLOCATED_PXDS (SHARED_KERNEL_PMD ? KERNEL_PGD_BOUNDARY : PTRS_PER_PGD)
33364
33365 void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd)
33366 {
33367 @@ -183,43 +245,45 @@ void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd)
33368 */
33369 flush_tlb_mm(mm);
33370 }
33371 +#elif defined(CONFIG_X86_64) && defined(CONFIG_PAX_PER_CPU_PGD)
33372 +#define PREALLOCATED_PXDS USER_PGD_PTRS
33373 #else /* !CONFIG_X86_PAE */
33374
33375 /* No need to prepopulate any pagetable entries in non-PAE modes. */
33376 -#define PREALLOCATED_PMDS 0
33377 +#define PREALLOCATED_PXDS 0
33378
33379 #endif /* CONFIG_X86_PAE */
33380
33381 -static void free_pmds(pmd_t *pmds[])
33382 +static void free_pxds(pxd_t *pxds[])
33383 {
33384 int i;
33385
33386 - for(i = 0; i < PREALLOCATED_PMDS; i++)
33387 - if (pmds[i]) {
33388 - pgtable_pmd_page_dtor(virt_to_page(pmds[i]));
33389 - free_page((unsigned long)pmds[i]);
33390 + for(i = 0; i < PREALLOCATED_PXDS; i++)
33391 + if (pxds[i]) {
33392 + pgtable_pxd_page_dtor(virt_to_page(pxds[i]));
33393 + free_page((unsigned long)pxds[i]);
33394 }
33395 }
33396
33397 -static int preallocate_pmds(pmd_t *pmds[])
33398 +static int preallocate_pxds(pxd_t *pxds[])
33399 {
33400 int i;
33401 bool failed = false;
33402
33403 - for(i = 0; i < PREALLOCATED_PMDS; i++) {
33404 - pmd_t *pmd = (pmd_t *)__get_free_page(PGALLOC_GFP);
33405 - if (!pmd)
33406 + for(i = 0; i < PREALLOCATED_PXDS; i++) {
33407 + pxd_t *pxd = (pxd_t *)__get_free_page(PGALLOC_GFP);
33408 + if (!pxd)
33409 failed = true;
33410 - if (pmd && !pgtable_pmd_page_ctor(virt_to_page(pmd))) {
33411 - free_page((unsigned long)pmd);
33412 - pmd = NULL;
33413 + if (pxd && !pgtable_pxd_page_ctor(virt_to_page(pxd))) {
33414 + free_page((unsigned long)pxd);
33415 + pxd = NULL;
33416 failed = true;
33417 }
33418 - pmds[i] = pmd;
33419 + pxds[i] = pxd;
33420 }
33421
33422 if (failed) {
33423 - free_pmds(pmds);
33424 + free_pxds(pxds);
33425 return -ENOMEM;
33426 }
33427
33428 @@ -232,49 +296,52 @@ static int preallocate_pmds(pmd_t *pmds[])
33429 * preallocate which never got a corresponding vma will need to be
33430 * freed manually.
33431 */
33432 -static void pgd_mop_up_pmds(struct mm_struct *mm, pgd_t *pgdp)
33433 +static void pgd_mop_up_pxds(struct mm_struct *mm, pgd_t *pgdp)
33434 {
33435 int i;
33436
33437 - for(i = 0; i < PREALLOCATED_PMDS; i++) {
33438 + for(i = 0; i < PREALLOCATED_PXDS; i++) {
33439 pgd_t pgd = pgdp[i];
33440
33441 if (pgd_val(pgd) != 0) {
33442 - pmd_t *pmd = (pmd_t *)pgd_page_vaddr(pgd);
33443 + pxd_t *pxd = (pxd_t *)pgd_page_vaddr(pgd);
33444
33445 - pgdp[i] = native_make_pgd(0);
33446 + set_pgd(pgdp + i, native_make_pgd(0));
33447
33448 - paravirt_release_pmd(pgd_val(pgd) >> PAGE_SHIFT);
33449 - pmd_free(mm, pmd);
33450 + paravirt_release_pxd(pgd_val(pgd) >> PAGE_SHIFT);
33451 + pxd_free(mm, pxd);
33452 }
33453 }
33454 }
33455
33456 -static void pgd_prepopulate_pmd(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmds[])
33457 +static void pgd_prepopulate_pxd(struct mm_struct *mm, pgd_t *pgd, pxd_t *pxds[])
33458 {
33459 - pud_t *pud;
33460 + pyd_t *pyd;
33461 int i;
33462
33463 - if (PREALLOCATED_PMDS == 0) /* Work around gcc-3.4.x bug */
33464 + if (PREALLOCATED_PXDS == 0) /* Work around gcc-3.4.x bug */
33465 return;
33466
33467 - pud = pud_offset(pgd, 0);
33468 -
33469 - for (i = 0; i < PREALLOCATED_PMDS; i++, pud++) {
33470 - pmd_t *pmd = pmds[i];
33471 +#ifdef CONFIG_X86_64
33472 + pyd = pyd_offset(mm, 0L);
33473 +#else
33474 + pyd = pyd_offset(pgd, 0L);
33475 +#endif
33476
33477 + for (i = 0; i < PREALLOCATED_PXDS; i++, pyd++) {
33478 + pxd_t *pxd = pxds[i];
33479 if (i >= KERNEL_PGD_BOUNDARY)
33480 - memcpy(pmd, (pmd_t *)pgd_page_vaddr(swapper_pg_dir[i]),
33481 - sizeof(pmd_t) * PTRS_PER_PMD);
33482 + memcpy(pxd, (pxd_t *)pgd_page_vaddr(swapper_pg_dir[i]),
33483 + sizeof(pxd_t) * PTRS_PER_PMD);
33484
33485 - pud_populate(mm, pud, pmd);
33486 + pyd_populate(mm, pyd, pxd);
33487 }
33488 }
33489
33490 pgd_t *pgd_alloc(struct mm_struct *mm)
33491 {
33492 pgd_t *pgd;
33493 - pmd_t *pmds[PREALLOCATED_PMDS];
33494 + pxd_t *pxds[PREALLOCATED_PXDS];
33495
33496 pgd = (pgd_t *)__get_free_page(PGALLOC_GFP);
33497
33498 @@ -283,11 +350,11 @@ pgd_t *pgd_alloc(struct mm_struct *mm)
33499
33500 mm->pgd = pgd;
33501
33502 - if (preallocate_pmds(pmds) != 0)
33503 + if (preallocate_pxds(pxds) != 0)
33504 goto out_free_pgd;
33505
33506 if (paravirt_pgd_alloc(mm) != 0)
33507 - goto out_free_pmds;
33508 + goto out_free_pxds;
33509
33510 /*
33511 * Make sure that pre-populating the pmds is atomic with
33512 @@ -297,14 +364,14 @@ pgd_t *pgd_alloc(struct mm_struct *mm)
33513 spin_lock(&pgd_lock);
33514
33515 pgd_ctor(mm, pgd);
33516 - pgd_prepopulate_pmd(mm, pgd, pmds);
33517 + pgd_prepopulate_pxd(mm, pgd, pxds);
33518
33519 spin_unlock(&pgd_lock);
33520
33521 return pgd;
33522
33523 -out_free_pmds:
33524 - free_pmds(pmds);
33525 +out_free_pxds:
33526 + free_pxds(pxds);
33527 out_free_pgd:
33528 free_page((unsigned long)pgd);
33529 out:
33530 @@ -313,7 +380,7 @@ out:
33531
33532 void pgd_free(struct mm_struct *mm, pgd_t *pgd)
33533 {
33534 - pgd_mop_up_pmds(mm, pgd);
33535 + pgd_mop_up_pxds(mm, pgd);
33536 pgd_dtor(pgd);
33537 paravirt_pgd_free(mm, pgd);
33538 free_page((unsigned long)pgd);
33539 diff --git a/arch/x86/mm/pgtable_32.c b/arch/x86/mm/pgtable_32.c
33540 index 4dd8cf6..f9d143e 100644
33541 --- a/arch/x86/mm/pgtable_32.c
33542 +++ b/arch/x86/mm/pgtable_32.c
33543 @@ -47,10 +47,13 @@ void set_pte_vaddr(unsigned long vaddr, pte_t pteval)
33544 return;
33545 }
33546 pte = pte_offset_kernel(pmd, vaddr);
33547 +
33548 + pax_open_kernel();
33549 if (pte_val(pteval))
33550 set_pte_at(&init_mm, vaddr, pte, pteval);
33551 else
33552 pte_clear(&init_mm, vaddr, pte);
33553 + pax_close_kernel();
33554
33555 /*
33556 * It's enough to flush this one mapping.
33557 diff --git a/arch/x86/mm/physaddr.c b/arch/x86/mm/physaddr.c
33558 index e666cbb..61788c45 100644
33559 --- a/arch/x86/mm/physaddr.c
33560 +++ b/arch/x86/mm/physaddr.c
33561 @@ -10,7 +10,7 @@
33562 #ifdef CONFIG_X86_64
33563
33564 #ifdef CONFIG_DEBUG_VIRTUAL
33565 -unsigned long __phys_addr(unsigned long x)
33566 +unsigned long __intentional_overflow(-1) __phys_addr(unsigned long x)
33567 {
33568 unsigned long y = x - __START_KERNEL_map;
33569
33570 @@ -67,7 +67,7 @@ EXPORT_SYMBOL(__virt_addr_valid);
33571 #else
33572
33573 #ifdef CONFIG_DEBUG_VIRTUAL
33574 -unsigned long __phys_addr(unsigned long x)
33575 +unsigned long __intentional_overflow(-1) __phys_addr(unsigned long x)
33576 {
33577 unsigned long phys_addr = x - PAGE_OFFSET;
33578 /* VMALLOC_* aren't constants */
33579 diff --git a/arch/x86/mm/setup_nx.c b/arch/x86/mm/setup_nx.c
33580 index 90555bf..f5f1828 100644
33581 --- a/arch/x86/mm/setup_nx.c
33582 +++ b/arch/x86/mm/setup_nx.c
33583 @@ -5,8 +5,10 @@
33584 #include <asm/pgtable.h>
33585 #include <asm/proto.h>
33586
33587 +#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
33588 static int disable_nx;
33589
33590 +#ifndef CONFIG_PAX_PAGEEXEC
33591 /*
33592 * noexec = on|off
33593 *
33594 @@ -28,12 +30,17 @@ static int __init noexec_setup(char *str)
33595 return 0;
33596 }
33597 early_param("noexec", noexec_setup);
33598 +#endif
33599 +
33600 +#endif
33601
33602 void x86_configure_nx(void)
33603 {
33604 +#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
33605 if (cpu_has_nx && !disable_nx)
33606 __supported_pte_mask |= _PAGE_NX;
33607 else
33608 +#endif
33609 __supported_pte_mask &= ~_PAGE_NX;
33610 }
33611
33612 diff --git a/arch/x86/mm/tlb.c b/arch/x86/mm/tlb.c
33613 index dd8dda1..9e9b0f6 100644
33614 --- a/arch/x86/mm/tlb.c
33615 +++ b/arch/x86/mm/tlb.c
33616 @@ -48,7 +48,11 @@ void leave_mm(int cpu)
33617 BUG();
33618 if (cpumask_test_cpu(cpu, mm_cpumask(active_mm))) {
33619 cpumask_clear_cpu(cpu, mm_cpumask(active_mm));
33620 +
33621 +#ifndef CONFIG_PAX_PER_CPU_PGD
33622 load_cr3(swapper_pg_dir);
33623 +#endif
33624 +
33625 }
33626 }
33627 EXPORT_SYMBOL_GPL(leave_mm);
33628 diff --git a/arch/x86/mm/uderef_64.c b/arch/x86/mm/uderef_64.c
33629 new file mode 100644
33630 index 0000000..dace51c
33631 --- /dev/null
33632 +++ b/arch/x86/mm/uderef_64.c
33633 @@ -0,0 +1,37 @@
33634 +#include <linux/mm.h>
33635 +#include <asm/pgtable.h>
33636 +#include <asm/uaccess.h>
33637 +
33638 +#ifdef CONFIG_PAX_MEMORY_UDEREF
33639 +/* PaX: due to the special call convention these functions must
33640 + * - remain leaf functions under all configurations,
33641 + * - never be called directly, only dereferenced from the wrappers.
33642 + */
33643 +void __pax_open_userland(void)
33644 +{
33645 + unsigned int cpu;
33646 +
33647 + if (unlikely(!segment_eq(get_fs(), USER_DS)))
33648 + return;
33649 +
33650 + cpu = raw_get_cpu();
33651 + BUG_ON((read_cr3() & ~PAGE_MASK) != PCID_KERNEL);
33652 + write_cr3(__pa(get_cpu_pgd(cpu, user)) | PCID_USER | PCID_NOFLUSH);
33653 + raw_put_cpu_no_resched();
33654 +}
33655 +EXPORT_SYMBOL(__pax_open_userland);
33656 +
33657 +void __pax_close_userland(void)
33658 +{
33659 + unsigned int cpu;
33660 +
33661 + if (unlikely(!segment_eq(get_fs(), USER_DS)))
33662 + return;
33663 +
33664 + cpu = raw_get_cpu();
33665 + BUG_ON((read_cr3() & ~PAGE_MASK) != PCID_USER);
33666 + write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL | PCID_NOFLUSH);
33667 + raw_put_cpu_no_resched();
33668 +}
33669 +EXPORT_SYMBOL(__pax_close_userland);
33670 +#endif
33671 diff --git a/arch/x86/net/bpf_jit.S b/arch/x86/net/bpf_jit.S
33672 index 0149575..f746de8 100644
33673 --- a/arch/x86/net/bpf_jit.S
33674 +++ b/arch/x86/net/bpf_jit.S
33675 @@ -9,6 +9,7 @@
33676 */
33677 #include <linux/linkage.h>
33678 #include <asm/dwarf2.h>
33679 +#include <asm/alternative-asm.h>
33680
33681 /*
33682 * Calling convention :
33683 @@ -35,6 +36,7 @@ sk_load_word_positive_offset:
33684 jle bpf_slow_path_word
33685 mov (SKBDATA,%rsi),%eax
33686 bswap %eax /* ntohl() */
33687 + pax_force_retaddr
33688 ret
33689
33690 sk_load_half:
33691 @@ -52,6 +54,7 @@ sk_load_half_positive_offset:
33692 jle bpf_slow_path_half
33693 movzwl (SKBDATA,%rsi),%eax
33694 rol $8,%ax # ntohs()
33695 + pax_force_retaddr
33696 ret
33697
33698 sk_load_byte:
33699 @@ -66,6 +69,7 @@ sk_load_byte_positive_offset:
33700 cmp %esi,%r9d /* if (offset >= hlen) goto bpf_slow_path_byte */
33701 jle bpf_slow_path_byte
33702 movzbl (SKBDATA,%rsi),%eax
33703 + pax_force_retaddr
33704 ret
33705
33706 /**
33707 @@ -87,6 +91,7 @@ sk_load_byte_msh_positive_offset:
33708 movzbl (SKBDATA,%rsi),%ebx
33709 and $15,%bl
33710 shl $2,%bl
33711 + pax_force_retaddr
33712 ret
33713
33714 /* rsi contains offset and can be scratched */
33715 @@ -109,6 +114,7 @@ bpf_slow_path_word:
33716 js bpf_error
33717 mov -12(%rbp),%eax
33718 bswap %eax
33719 + pax_force_retaddr
33720 ret
33721
33722 bpf_slow_path_half:
33723 @@ -117,12 +123,14 @@ bpf_slow_path_half:
33724 mov -12(%rbp),%ax
33725 rol $8,%ax
33726 movzwl %ax,%eax
33727 + pax_force_retaddr
33728 ret
33729
33730 bpf_slow_path_byte:
33731 bpf_slow_path_common(1)
33732 js bpf_error
33733 movzbl -12(%rbp),%eax
33734 + pax_force_retaddr
33735 ret
33736
33737 bpf_slow_path_byte_msh:
33738 @@ -133,6 +141,7 @@ bpf_slow_path_byte_msh:
33739 and $15,%al
33740 shl $2,%al
33741 xchg %eax,%ebx
33742 + pax_force_retaddr
33743 ret
33744
33745 #define sk_negative_common(SIZE) \
33746 @@ -157,6 +166,7 @@ sk_load_word_negative_offset:
33747 sk_negative_common(4)
33748 mov (%rax), %eax
33749 bswap %eax
33750 + pax_force_retaddr
33751 ret
33752
33753 bpf_slow_path_half_neg:
33754 @@ -168,6 +178,7 @@ sk_load_half_negative_offset:
33755 mov (%rax),%ax
33756 rol $8,%ax
33757 movzwl %ax,%eax
33758 + pax_force_retaddr
33759 ret
33760
33761 bpf_slow_path_byte_neg:
33762 @@ -177,6 +188,7 @@ sk_load_byte_negative_offset:
33763 .globl sk_load_byte_negative_offset
33764 sk_negative_common(1)
33765 movzbl (%rax), %eax
33766 + pax_force_retaddr
33767 ret
33768
33769 bpf_slow_path_byte_msh_neg:
33770 @@ -190,6 +202,7 @@ sk_load_byte_msh_negative_offset:
33771 and $15,%al
33772 shl $2,%al
33773 xchg %eax,%ebx
33774 + pax_force_retaddr
33775 ret
33776
33777 bpf_error:
33778 @@ -197,4 +210,5 @@ bpf_error:
33779 xor %eax,%eax
33780 mov -8(%rbp),%rbx
33781 leaveq
33782 + pax_force_retaddr
33783 ret
33784 diff --git a/arch/x86/net/bpf_jit_comp.c b/arch/x86/net/bpf_jit_comp.c
33785 index 6d5663a..f1ec380 100644
33786 --- a/arch/x86/net/bpf_jit_comp.c
33787 +++ b/arch/x86/net/bpf_jit_comp.c
33788 @@ -50,13 +50,90 @@ static inline u8 *emit_code(u8 *ptr, u32 bytes, unsigned int len)
33789 return ptr + len;
33790 }
33791
33792 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
33793 +#define MAX_INSTR_CODE_SIZE 96
33794 +#else
33795 +#define MAX_INSTR_CODE_SIZE 64
33796 +#endif
33797 +
33798 #define EMIT(bytes, len) do { prog = emit_code(prog, bytes, len); } while (0)
33799
33800 #define EMIT1(b1) EMIT(b1, 1)
33801 #define EMIT2(b1, b2) EMIT((b1) + ((b2) << 8), 2)
33802 #define EMIT3(b1, b2, b3) EMIT((b1) + ((b2) << 8) + ((b3) << 16), 3)
33803 #define EMIT4(b1, b2, b3, b4) EMIT((b1) + ((b2) << 8) + ((b3) << 16) + ((b4) << 24), 4)
33804 +
33805 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
33806 +/* original constant will appear in ecx */
33807 +#define DILUTE_CONST_SEQUENCE(_off, _key) \
33808 +do { \
33809 + /* mov ecx, randkey */ \
33810 + EMIT1(0xb9); \
33811 + EMIT(_key, 4); \
33812 + /* xor ecx, randkey ^ off */ \
33813 + EMIT2(0x81, 0xf1); \
33814 + EMIT((_key) ^ (_off), 4); \
33815 +} while (0)
33816 +
33817 +#define EMIT1_off32(b1, _off) \
33818 +do { \
33819 + switch (b1) { \
33820 + case 0x05: /* add eax, imm32 */ \
33821 + case 0x2d: /* sub eax, imm32 */ \
33822 + case 0x25: /* and eax, imm32 */ \
33823 + case 0x0d: /* or eax, imm32 */ \
33824 + case 0xb8: /* mov eax, imm32 */ \
33825 + case 0x35: /* xor eax, imm32 */ \
33826 + case 0x3d: /* cmp eax, imm32 */ \
33827 + case 0xa9: /* test eax, imm32 */ \
33828 + DILUTE_CONST_SEQUENCE(_off, randkey); \
33829 + EMIT2((b1) - 4, 0xc8); /* convert imm instruction to eax, ecx */\
33830 + break; \
33831 + case 0xbb: /* mov ebx, imm32 */ \
33832 + DILUTE_CONST_SEQUENCE(_off, randkey); \
33833 + /* mov ebx, ecx */ \
33834 + EMIT2(0x89, 0xcb); \
33835 + break; \
33836 + case 0xbe: /* mov esi, imm32 */ \
33837 + DILUTE_CONST_SEQUENCE(_off, randkey); \
33838 + /* mov esi, ecx */ \
33839 + EMIT2(0x89, 0xce); \
33840 + break; \
33841 + case 0xe8: /* call rel imm32, always to known funcs */ \
33842 + EMIT1(b1); \
33843 + EMIT(_off, 4); \
33844 + break; \
33845 + case 0xe9: /* jmp rel imm32 */ \
33846 + EMIT1(b1); \
33847 + EMIT(_off, 4); \
33848 + /* prevent fall-through, we're not called if off = 0 */ \
33849 + EMIT(0xcccccccc, 4); \
33850 + EMIT(0xcccccccc, 4); \
33851 + break; \
33852 + default: \
33853 + BUILD_BUG(); \
33854 + } \
33855 +} while (0)
33856 +
33857 +#define EMIT2_off32(b1, b2, _off) \
33858 +do { \
33859 + if ((b1) == 0x8d && (b2) == 0xb3) { /* lea esi, [rbx+imm32] */ \
33860 + EMIT2(0x8d, 0xb3); /* lea esi, [rbx+randkey] */ \
33861 + EMIT(randkey, 4); \
33862 + EMIT2(0x8d, 0xb6); /* lea esi, [esi+off-randkey] */ \
33863 + EMIT((_off) - randkey, 4); \
33864 + } else if ((b1) == 0x69 && (b2) == 0xc0) { /* imul eax, imm32 */\
33865 + DILUTE_CONST_SEQUENCE(_off, randkey); \
33866 + /* imul eax, ecx */ \
33867 + EMIT3(0x0f, 0xaf, 0xc1); \
33868 + } else { \
33869 + BUILD_BUG(); \
33870 + } \
33871 +} while (0)
33872 +#else
33873 #define EMIT1_off32(b1, off) do { EMIT1(b1); EMIT(off, 4);} while (0)
33874 +#define EMIT2_off32(b1, b2, off) do { EMIT2(b1, b2); EMIT(off, 4);} while (0)
33875 +#endif
33876
33877 #define CLEAR_A() EMIT2(0x31, 0xc0) /* xor %eax,%eax */
33878 #define CLEAR_X() EMIT2(0x31, 0xdb) /* xor %ebx,%ebx */
33879 @@ -91,6 +168,24 @@ do { \
33880 #define X86_JBE 0x76
33881 #define X86_JA 0x77
33882
33883 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
33884 +#define APPEND_FLOW_VERIFY() \
33885 +do { \
33886 + /* mov ecx, randkey */ \
33887 + EMIT1(0xb9); \
33888 + EMIT(randkey, 4); \
33889 + /* cmp ecx, randkey */ \
33890 + EMIT2(0x81, 0xf9); \
33891 + EMIT(randkey, 4); \
33892 + /* jz after 8 int 3s */ \
33893 + EMIT2(0x74, 0x08); \
33894 + EMIT(0xcccccccc, 4); \
33895 + EMIT(0xcccccccc, 4); \
33896 +} while (0)
33897 +#else
33898 +#define APPEND_FLOW_VERIFY() do { } while (0)
33899 +#endif
33900 +
33901 #define EMIT_COND_JMP(op, offset) \
33902 do { \
33903 if (is_near(offset)) \
33904 @@ -98,6 +193,7 @@ do { \
33905 else { \
33906 EMIT2(0x0f, op + 0x10); \
33907 EMIT(offset, 4); /* jxx .+off32 */ \
33908 + APPEND_FLOW_VERIFY(); \
33909 } \
33910 } while (0)
33911
33912 @@ -145,55 +241,54 @@ static int pkt_type_offset(void)
33913 return -1;
33914 }
33915
33916 -struct bpf_binary_header {
33917 - unsigned int pages;
33918 - /* Note : for security reasons, bpf code will follow a randomly
33919 - * sized amount of int3 instructions
33920 - */
33921 - u8 image[];
33922 -};
33923 -
33924 -static struct bpf_binary_header *bpf_alloc_binary(unsigned int proglen,
33925 +/* Note : for security reasons, bpf code will follow a randomly
33926 + * sized amount of int3 instructions
33927 + */
33928 +static u8 *bpf_alloc_binary(unsigned int proglen,
33929 u8 **image_ptr)
33930 {
33931 unsigned int sz, hole;
33932 - struct bpf_binary_header *header;
33933 + u8 *header;
33934
33935 /* Most of BPF filters are really small,
33936 * but if some of them fill a page, allow at least
33937 * 128 extra bytes to insert a random section of int3
33938 */
33939 - sz = round_up(proglen + sizeof(*header) + 128, PAGE_SIZE);
33940 - header = module_alloc(sz);
33941 + sz = round_up(proglen + 128, PAGE_SIZE);
33942 + header = module_alloc_exec(sz);
33943 if (!header)
33944 return NULL;
33945
33946 + pax_open_kernel();
33947 memset(header, 0xcc, sz); /* fill whole space with int3 instructions */
33948 + pax_close_kernel();
33949
33950 - header->pages = sz / PAGE_SIZE;
33951 - hole = min(sz - (proglen + sizeof(*header)), PAGE_SIZE - sizeof(*header));
33952 + hole = PAGE_SIZE - (proglen & ~PAGE_MASK);
33953
33954 /* insert a random number of int3 instructions before BPF code */
33955 - *image_ptr = &header->image[prandom_u32() % hole];
33956 + *image_ptr = &header[prandom_u32() % hole];
33957 return header;
33958 }
33959
33960 void bpf_jit_compile(struct sk_filter *fp)
33961 {
33962 - u8 temp[64];
33963 + u8 temp[MAX_INSTR_CODE_SIZE];
33964 u8 *prog;
33965 unsigned int proglen, oldproglen = 0;
33966 int ilen, i;
33967 int t_offset, f_offset;
33968 u8 t_op, f_op, seen = 0, pass;
33969 u8 *image = NULL;
33970 - struct bpf_binary_header *header = NULL;
33971 + u8 *header = NULL;
33972 u8 *func;
33973 int pc_ret0 = -1; /* bpf index of first RET #0 instruction (if any) */
33974 unsigned int cleanup_addr; /* epilogue code offset */
33975 unsigned int *addrs;
33976 const struct sock_filter *filter = fp->insns;
33977 int flen = fp->len;
33978 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
33979 + unsigned int randkey;
33980 +#endif
33981
33982 if (!bpf_jit_enable)
33983 return;
33984 @@ -203,10 +298,10 @@ void bpf_jit_compile(struct sk_filter *fp)
33985 return;
33986
33987 /* Before first pass, make a rough estimation of addrs[]
33988 - * each bpf instruction is translated to less than 64 bytes
33989 + * each bpf instruction is translated to less than MAX_INSTR_CODE_SIZE bytes
33990 */
33991 for (proglen = 0, i = 0; i < flen; i++) {
33992 - proglen += 64;
33993 + proglen += MAX_INSTR_CODE_SIZE;
33994 addrs[i] = proglen;
33995 }
33996 cleanup_addr = proglen; /* epilogue address */
33997 @@ -285,6 +380,10 @@ void bpf_jit_compile(struct sk_filter *fp)
33998 for (i = 0; i < flen; i++) {
33999 unsigned int K = filter[i].k;
34000
34001 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
34002 + randkey = prandom_u32();
34003 +#endif
34004 +
34005 switch (filter[i].code) {
34006 case BPF_S_ALU_ADD_X: /* A += X; */
34007 seen |= SEEN_XREG;
34008 @@ -317,10 +416,8 @@ void bpf_jit_compile(struct sk_filter *fp)
34009 case BPF_S_ALU_MUL_K: /* A *= K */
34010 if (is_imm8(K))
34011 EMIT3(0x6b, 0xc0, K); /* imul imm8,%eax,%eax */
34012 - else {
34013 - EMIT2(0x69, 0xc0); /* imul imm32,%eax */
34014 - EMIT(K, 4);
34015 - }
34016 + else
34017 + EMIT2_off32(0x69, 0xc0, K); /* imul imm32,%eax */
34018 break;
34019 case BPF_S_ALU_DIV_X: /* A /= X; */
34020 seen |= SEEN_XREG;
34021 @@ -364,7 +461,11 @@ void bpf_jit_compile(struct sk_filter *fp)
34022 break;
34023 }
34024 EMIT2(0x31, 0xd2); /* xor %edx,%edx */
34025 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
34026 + DILUTE_CONST_SEQUENCE(K, randkey);
34027 +#else
34028 EMIT1(0xb9);EMIT(K, 4); /* mov imm32,%ecx */
34029 +#endif
34030 EMIT2(0xf7, 0xf1); /* div %ecx */
34031 EMIT2(0x89, 0xd0); /* mov %edx,%eax */
34032 break;
34033 @@ -372,7 +473,11 @@ void bpf_jit_compile(struct sk_filter *fp)
34034 if (K == 1)
34035 break;
34036 EMIT2(0x31, 0xd2); /* xor %edx,%edx */
34037 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
34038 + DILUTE_CONST_SEQUENCE(K, randkey);
34039 +#else
34040 EMIT1(0xb9);EMIT(K, 4); /* mov imm32,%ecx */
34041 +#endif
34042 EMIT2(0xf7, 0xf1); /* div %ecx */
34043 break;
34044 case BPF_S_ALU_AND_X:
34045 @@ -643,8 +748,7 @@ common_load_ind: seen |= SEEN_DATAREF | SEEN_XREG;
34046 if (is_imm8(K)) {
34047 EMIT3(0x8d, 0x73, K); /* lea imm8(%rbx), %esi */
34048 } else {
34049 - EMIT2(0x8d, 0xb3); /* lea imm32(%rbx),%esi */
34050 - EMIT(K, 4);
34051 + EMIT2_off32(0x8d, 0xb3, K); /* lea imm32(%rbx),%esi */
34052 }
34053 } else {
34054 EMIT2(0x89,0xde); /* mov %ebx,%esi */
34055 @@ -734,10 +838,12 @@ cond_branch: f_offset = addrs[i + filter[i].jf] - addrs[i];
34056 if (unlikely(proglen + ilen > oldproglen)) {
34057 pr_err("bpb_jit_compile fatal error\n");
34058 kfree(addrs);
34059 - module_free(NULL, header);
34060 + module_free_exec(NULL, image);
34061 return;
34062 }
34063 + pax_open_kernel();
34064 memcpy(image + proglen, temp, ilen);
34065 + pax_close_kernel();
34066 }
34067 proglen += ilen;
34068 addrs[i] = proglen;
34069 @@ -770,7 +876,6 @@ cond_branch: f_offset = addrs[i + filter[i].jf] - addrs[i];
34070
34071 if (image) {
34072 bpf_flush_icache(header, image + proglen);
34073 - set_memory_ro((unsigned long)header, header->pages);
34074 fp->bpf_func = (void *)image;
34075 fp->jited = 1;
34076 }
34077 @@ -783,10 +888,9 @@ static void bpf_jit_free_deferred(struct work_struct *work)
34078 {
34079 struct sk_filter *fp = container_of(work, struct sk_filter, work);
34080 unsigned long addr = (unsigned long)fp->bpf_func & PAGE_MASK;
34081 - struct bpf_binary_header *header = (void *)addr;
34082
34083 - set_memory_rw(addr, header->pages);
34084 - module_free(NULL, header);
34085 + set_memory_rw(addr, 1);
34086 + module_free_exec(NULL, (void *)addr);
34087 kfree(fp);
34088 }
34089
34090 diff --git a/arch/x86/oprofile/backtrace.c b/arch/x86/oprofile/backtrace.c
34091 index 5d04be5..2beeaa2 100644
34092 --- a/arch/x86/oprofile/backtrace.c
34093 +++ b/arch/x86/oprofile/backtrace.c
34094 @@ -46,11 +46,11 @@ dump_user_backtrace_32(struct stack_frame_ia32 *head)
34095 struct stack_frame_ia32 *fp;
34096 unsigned long bytes;
34097
34098 - bytes = copy_from_user_nmi(bufhead, head, sizeof(bufhead));
34099 + bytes = copy_from_user_nmi(bufhead, (const char __force_user *)head, sizeof(bufhead));
34100 if (bytes != 0)
34101 return NULL;
34102
34103 - fp = (struct stack_frame_ia32 *) compat_ptr(bufhead[0].next_frame);
34104 + fp = (struct stack_frame_ia32 __force_kernel *) compat_ptr(bufhead[0].next_frame);
34105
34106 oprofile_add_trace(bufhead[0].return_address);
34107
34108 @@ -92,7 +92,7 @@ static struct stack_frame *dump_user_backtrace(struct stack_frame *head)
34109 struct stack_frame bufhead[2];
34110 unsigned long bytes;
34111
34112 - bytes = copy_from_user_nmi(bufhead, head, sizeof(bufhead));
34113 + bytes = copy_from_user_nmi(bufhead, (const char __force_user *)head, sizeof(bufhead));
34114 if (bytes != 0)
34115 return NULL;
34116
34117 @@ -111,7 +111,7 @@ x86_backtrace(struct pt_regs * const regs, unsigned int depth)
34118 {
34119 struct stack_frame *head = (struct stack_frame *)frame_pointer(regs);
34120
34121 - if (!user_mode_vm(regs)) {
34122 + if (!user_mode(regs)) {
34123 unsigned long stack = kernel_stack_pointer(regs);
34124 if (depth)
34125 dump_trace(NULL, regs, (unsigned long *)stack, 0,
34126 diff --git a/arch/x86/oprofile/nmi_int.c b/arch/x86/oprofile/nmi_int.c
34127 index 379e8bd..6386e09 100644
34128 --- a/arch/x86/oprofile/nmi_int.c
34129 +++ b/arch/x86/oprofile/nmi_int.c
34130 @@ -23,6 +23,7 @@
34131 #include <asm/nmi.h>
34132 #include <asm/msr.h>
34133 #include <asm/apic.h>
34134 +#include <asm/pgtable.h>
34135
34136 #include "op_counter.h"
34137 #include "op_x86_model.h"
34138 @@ -785,8 +786,11 @@ int __init op_nmi_init(struct oprofile_operations *ops)
34139 if (ret)
34140 return ret;
34141
34142 - if (!model->num_virt_counters)
34143 - model->num_virt_counters = model->num_counters;
34144 + if (!model->num_virt_counters) {
34145 + pax_open_kernel();
34146 + *(unsigned int *)&model->num_virt_counters = model->num_counters;
34147 + pax_close_kernel();
34148 + }
34149
34150 mux_init(ops);
34151
34152 diff --git a/arch/x86/oprofile/op_model_amd.c b/arch/x86/oprofile/op_model_amd.c
34153 index 50d86c0..7985318 100644
34154 --- a/arch/x86/oprofile/op_model_amd.c
34155 +++ b/arch/x86/oprofile/op_model_amd.c
34156 @@ -519,9 +519,11 @@ static int op_amd_init(struct oprofile_operations *ops)
34157 num_counters = AMD64_NUM_COUNTERS;
34158 }
34159
34160 - op_amd_spec.num_counters = num_counters;
34161 - op_amd_spec.num_controls = num_counters;
34162 - op_amd_spec.num_virt_counters = max(num_counters, NUM_VIRT_COUNTERS);
34163 + pax_open_kernel();
34164 + *(unsigned int *)&op_amd_spec.num_counters = num_counters;
34165 + *(unsigned int *)&op_amd_spec.num_controls = num_counters;
34166 + *(unsigned int *)&op_amd_spec.num_virt_counters = max(num_counters, NUM_VIRT_COUNTERS);
34167 + pax_close_kernel();
34168
34169 return 0;
34170 }
34171 diff --git a/arch/x86/oprofile/op_model_ppro.c b/arch/x86/oprofile/op_model_ppro.c
34172 index d90528e..0127e2b 100644
34173 --- a/arch/x86/oprofile/op_model_ppro.c
34174 +++ b/arch/x86/oprofile/op_model_ppro.c
34175 @@ -19,6 +19,7 @@
34176 #include <asm/msr.h>
34177 #include <asm/apic.h>
34178 #include <asm/nmi.h>
34179 +#include <asm/pgtable.h>
34180
34181 #include "op_x86_model.h"
34182 #include "op_counter.h"
34183 @@ -221,8 +222,10 @@ static void arch_perfmon_setup_counters(void)
34184
34185 num_counters = min((int)eax.split.num_counters, OP_MAX_COUNTER);
34186
34187 - op_arch_perfmon_spec.num_counters = num_counters;
34188 - op_arch_perfmon_spec.num_controls = num_counters;
34189 + pax_open_kernel();
34190 + *(unsigned int *)&op_arch_perfmon_spec.num_counters = num_counters;
34191 + *(unsigned int *)&op_arch_perfmon_spec.num_controls = num_counters;
34192 + pax_close_kernel();
34193 }
34194
34195 static int arch_perfmon_init(struct oprofile_operations *ignore)
34196 diff --git a/arch/x86/oprofile/op_x86_model.h b/arch/x86/oprofile/op_x86_model.h
34197 index 71e8a67..6a313bb 100644
34198 --- a/arch/x86/oprofile/op_x86_model.h
34199 +++ b/arch/x86/oprofile/op_x86_model.h
34200 @@ -52,7 +52,7 @@ struct op_x86_model_spec {
34201 void (*switch_ctrl)(struct op_x86_model_spec const *model,
34202 struct op_msrs const * const msrs);
34203 #endif
34204 -};
34205 +} __do_const;
34206
34207 struct op_counter_config;
34208
34209 diff --git a/arch/x86/pci/intel_mid_pci.c b/arch/x86/pci/intel_mid_pci.c
34210 index 84b9d67..260e5ff 100644
34211 --- a/arch/x86/pci/intel_mid_pci.c
34212 +++ b/arch/x86/pci/intel_mid_pci.c
34213 @@ -245,7 +245,7 @@ int __init intel_mid_pci_init(void)
34214 pr_info("Intel MID platform detected, using MID PCI ops\n");
34215 pci_mmcfg_late_init();
34216 pcibios_enable_irq = intel_mid_pci_irq_enable;
34217 - pci_root_ops = intel_mid_pci_ops;
34218 + memcpy((void *)&pci_root_ops, &intel_mid_pci_ops, sizeof pci_root_ops);
34219 pci_soc_mode = 1;
34220 /* Continue with standard init */
34221 return 1;
34222 diff --git a/arch/x86/pci/irq.c b/arch/x86/pci/irq.c
34223 index 84112f5..6334d60 100644
34224 --- a/arch/x86/pci/irq.c
34225 +++ b/arch/x86/pci/irq.c
34226 @@ -50,7 +50,7 @@ struct irq_router {
34227 struct irq_router_handler {
34228 u16 vendor;
34229 int (*probe)(struct irq_router *r, struct pci_dev *router, u16 device);
34230 -};
34231 +} __do_const;
34232
34233 int (*pcibios_enable_irq)(struct pci_dev *dev) = pirq_enable_irq;
34234 void (*pcibios_disable_irq)(struct pci_dev *dev) = NULL;
34235 @@ -790,7 +790,7 @@ static __init int pico_router_probe(struct irq_router *r, struct pci_dev *router
34236 return 0;
34237 }
34238
34239 -static __initdata struct irq_router_handler pirq_routers[] = {
34240 +static __initconst const struct irq_router_handler pirq_routers[] = {
34241 { PCI_VENDOR_ID_INTEL, intel_router_probe },
34242 { PCI_VENDOR_ID_AL, ali_router_probe },
34243 { PCI_VENDOR_ID_ITE, ite_router_probe },
34244 @@ -817,7 +817,7 @@ static struct pci_dev *pirq_router_dev;
34245 static void __init pirq_find_router(struct irq_router *r)
34246 {
34247 struct irq_routing_table *rt = pirq_table;
34248 - struct irq_router_handler *h;
34249 + const struct irq_router_handler *h;
34250
34251 #ifdef CONFIG_PCI_BIOS
34252 if (!rt->signature) {
34253 @@ -1090,7 +1090,7 @@ static int __init fix_acer_tm360_irqrouting(const struct dmi_system_id *d)
34254 return 0;
34255 }
34256
34257 -static struct dmi_system_id __initdata pciirq_dmi_table[] = {
34258 +static const struct dmi_system_id __initconst pciirq_dmi_table[] = {
34259 {
34260 .callback = fix_broken_hp_bios_irq9,
34261 .ident = "HP Pavilion N5400 Series Laptop",
34262 diff --git a/arch/x86/pci/pcbios.c b/arch/x86/pci/pcbios.c
34263 index c77b24a..c979855 100644
34264 --- a/arch/x86/pci/pcbios.c
34265 +++ b/arch/x86/pci/pcbios.c
34266 @@ -79,7 +79,7 @@ union bios32 {
34267 static struct {
34268 unsigned long address;
34269 unsigned short segment;
34270 -} bios32_indirect = { 0, __KERNEL_CS };
34271 +} bios32_indirect __read_only = { 0, __PCIBIOS_CS };
34272
34273 /*
34274 * Returns the entry point for the given service, NULL on error
34275 @@ -92,37 +92,80 @@ static unsigned long bios32_service(unsigned long service)
34276 unsigned long length; /* %ecx */
34277 unsigned long entry; /* %edx */
34278 unsigned long flags;
34279 + struct desc_struct d, *gdt;
34280
34281 local_irq_save(flags);
34282 - __asm__("lcall *(%%edi); cld"
34283 +
34284 + gdt = get_cpu_gdt_table(smp_processor_id());
34285 +
34286 + pack_descriptor(&d, 0UL, 0xFFFFFUL, 0x9B, 0xC);
34287 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_CS, &d, DESCTYPE_S);
34288 + pack_descriptor(&d, 0UL, 0xFFFFFUL, 0x93, 0xC);
34289 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_DS, &d, DESCTYPE_S);
34290 +
34291 + __asm__("movw %w7, %%ds; lcall *(%%edi); push %%ss; pop %%ds; cld"
34292 : "=a" (return_code),
34293 "=b" (address),
34294 "=c" (length),
34295 "=d" (entry)
34296 : "0" (service),
34297 "1" (0),
34298 - "D" (&bios32_indirect));
34299 + "D" (&bios32_indirect),
34300 + "r"(__PCIBIOS_DS)
34301 + : "memory");
34302 +
34303 + pax_open_kernel();
34304 + gdt[GDT_ENTRY_PCIBIOS_CS].a = 0;
34305 + gdt[GDT_ENTRY_PCIBIOS_CS].b = 0;
34306 + gdt[GDT_ENTRY_PCIBIOS_DS].a = 0;
34307 + gdt[GDT_ENTRY_PCIBIOS_DS].b = 0;
34308 + pax_close_kernel();
34309 +
34310 local_irq_restore(flags);
34311
34312 switch (return_code) {
34313 - case 0:
34314 - return address + entry;
34315 - case 0x80: /* Not present */
34316 - printk(KERN_WARNING "bios32_service(0x%lx): not present\n", service);
34317 - return 0;
34318 - default: /* Shouldn't happen */
34319 - printk(KERN_WARNING "bios32_service(0x%lx): returned 0x%x -- BIOS bug!\n",
34320 - service, return_code);
34321 + case 0: {
34322 + int cpu;
34323 + unsigned char flags;
34324 +
34325 + printk(KERN_INFO "bios32_service: base:%08lx length:%08lx entry:%08lx\n", address, length, entry);
34326 + if (address >= 0xFFFF0 || length > 0x100000 - address || length <= entry) {
34327 + printk(KERN_WARNING "bios32_service: not valid\n");
34328 return 0;
34329 + }
34330 + address = address + PAGE_OFFSET;
34331 + length += 16UL; /* some BIOSs underreport this... */
34332 + flags = 4;
34333 + if (length >= 64*1024*1024) {
34334 + length >>= PAGE_SHIFT;
34335 + flags |= 8;
34336 + }
34337 +
34338 + for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
34339 + gdt = get_cpu_gdt_table(cpu);
34340 + pack_descriptor(&d, address, length, 0x9b, flags);
34341 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_CS, &d, DESCTYPE_S);
34342 + pack_descriptor(&d, address, length, 0x93, flags);
34343 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_DS, &d, DESCTYPE_S);
34344 + }
34345 + return entry;
34346 + }
34347 + case 0x80: /* Not present */
34348 + printk(KERN_WARNING "bios32_service(0x%lx): not present\n", service);
34349 + return 0;
34350 + default: /* Shouldn't happen */
34351 + printk(KERN_WARNING "bios32_service(0x%lx): returned 0x%x -- BIOS bug!\n",
34352 + service, return_code);
34353 + return 0;
34354 }
34355 }
34356
34357 static struct {
34358 unsigned long address;
34359 unsigned short segment;
34360 -} pci_indirect = { 0, __KERNEL_CS };
34361 +} pci_indirect __read_only = { 0, __PCIBIOS_CS };
34362
34363 -static int pci_bios_present;
34364 +static int pci_bios_present __read_only;
34365
34366 static int check_pcibios(void)
34367 {
34368 @@ -131,11 +174,13 @@ static int check_pcibios(void)
34369 unsigned long flags, pcibios_entry;
34370
34371 if ((pcibios_entry = bios32_service(PCI_SERVICE))) {
34372 - pci_indirect.address = pcibios_entry + PAGE_OFFSET;
34373 + pci_indirect.address = pcibios_entry;
34374
34375 local_irq_save(flags);
34376 - __asm__(
34377 - "lcall *(%%edi); cld\n\t"
34378 + __asm__("movw %w6, %%ds\n\t"
34379 + "lcall *%%ss:(%%edi); cld\n\t"
34380 + "push %%ss\n\t"
34381 + "pop %%ds\n\t"
34382 "jc 1f\n\t"
34383 "xor %%ah, %%ah\n"
34384 "1:"
34385 @@ -144,7 +189,8 @@ static int check_pcibios(void)
34386 "=b" (ebx),
34387 "=c" (ecx)
34388 : "1" (PCIBIOS_PCI_BIOS_PRESENT),
34389 - "D" (&pci_indirect)
34390 + "D" (&pci_indirect),
34391 + "r" (__PCIBIOS_DS)
34392 : "memory");
34393 local_irq_restore(flags);
34394
34395 @@ -189,7 +235,10 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
34396
34397 switch (len) {
34398 case 1:
34399 - __asm__("lcall *(%%esi); cld\n\t"
34400 + __asm__("movw %w6, %%ds\n\t"
34401 + "lcall *%%ss:(%%esi); cld\n\t"
34402 + "push %%ss\n\t"
34403 + "pop %%ds\n\t"
34404 "jc 1f\n\t"
34405 "xor %%ah, %%ah\n"
34406 "1:"
34407 @@ -198,7 +247,8 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
34408 : "1" (PCIBIOS_READ_CONFIG_BYTE),
34409 "b" (bx),
34410 "D" ((long)reg),
34411 - "S" (&pci_indirect));
34412 + "S" (&pci_indirect),
34413 + "r" (__PCIBIOS_DS));
34414 /*
34415 * Zero-extend the result beyond 8 bits, do not trust the
34416 * BIOS having done it:
34417 @@ -206,7 +256,10 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
34418 *value &= 0xff;
34419 break;
34420 case 2:
34421 - __asm__("lcall *(%%esi); cld\n\t"
34422 + __asm__("movw %w6, %%ds\n\t"
34423 + "lcall *%%ss:(%%esi); cld\n\t"
34424 + "push %%ss\n\t"
34425 + "pop %%ds\n\t"
34426 "jc 1f\n\t"
34427 "xor %%ah, %%ah\n"
34428 "1:"
34429 @@ -215,7 +268,8 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
34430 : "1" (PCIBIOS_READ_CONFIG_WORD),
34431 "b" (bx),
34432 "D" ((long)reg),
34433 - "S" (&pci_indirect));
34434 + "S" (&pci_indirect),
34435 + "r" (__PCIBIOS_DS));
34436 /*
34437 * Zero-extend the result beyond 16 bits, do not trust the
34438 * BIOS having done it:
34439 @@ -223,7 +277,10 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
34440 *value &= 0xffff;
34441 break;
34442 case 4:
34443 - __asm__("lcall *(%%esi); cld\n\t"
34444 + __asm__("movw %w6, %%ds\n\t"
34445 + "lcall *%%ss:(%%esi); cld\n\t"
34446 + "push %%ss\n\t"
34447 + "pop %%ds\n\t"
34448 "jc 1f\n\t"
34449 "xor %%ah, %%ah\n"
34450 "1:"
34451 @@ -232,7 +289,8 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
34452 : "1" (PCIBIOS_READ_CONFIG_DWORD),
34453 "b" (bx),
34454 "D" ((long)reg),
34455 - "S" (&pci_indirect));
34456 + "S" (&pci_indirect),
34457 + "r" (__PCIBIOS_DS));
34458 break;
34459 }
34460
34461 @@ -256,7 +314,10 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
34462
34463 switch (len) {
34464 case 1:
34465 - __asm__("lcall *(%%esi); cld\n\t"
34466 + __asm__("movw %w6, %%ds\n\t"
34467 + "lcall *%%ss:(%%esi); cld\n\t"
34468 + "push %%ss\n\t"
34469 + "pop %%ds\n\t"
34470 "jc 1f\n\t"
34471 "xor %%ah, %%ah\n"
34472 "1:"
34473 @@ -265,10 +326,14 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
34474 "c" (value),
34475 "b" (bx),
34476 "D" ((long)reg),
34477 - "S" (&pci_indirect));
34478 + "S" (&pci_indirect),
34479 + "r" (__PCIBIOS_DS));
34480 break;
34481 case 2:
34482 - __asm__("lcall *(%%esi); cld\n\t"
34483 + __asm__("movw %w6, %%ds\n\t"
34484 + "lcall *%%ss:(%%esi); cld\n\t"
34485 + "push %%ss\n\t"
34486 + "pop %%ds\n\t"
34487 "jc 1f\n\t"
34488 "xor %%ah, %%ah\n"
34489 "1:"
34490 @@ -277,10 +342,14 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
34491 "c" (value),
34492 "b" (bx),
34493 "D" ((long)reg),
34494 - "S" (&pci_indirect));
34495 + "S" (&pci_indirect),
34496 + "r" (__PCIBIOS_DS));
34497 break;
34498 case 4:
34499 - __asm__("lcall *(%%esi); cld\n\t"
34500 + __asm__("movw %w6, %%ds\n\t"
34501 + "lcall *%%ss:(%%esi); cld\n\t"
34502 + "push %%ss\n\t"
34503 + "pop %%ds\n\t"
34504 "jc 1f\n\t"
34505 "xor %%ah, %%ah\n"
34506 "1:"
34507 @@ -289,7 +358,8 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
34508 "c" (value),
34509 "b" (bx),
34510 "D" ((long)reg),
34511 - "S" (&pci_indirect));
34512 + "S" (&pci_indirect),
34513 + "r" (__PCIBIOS_DS));
34514 break;
34515 }
34516
34517 @@ -394,10 +464,13 @@ struct irq_routing_table * pcibios_get_irq_routing_table(void)
34518
34519 DBG("PCI: Fetching IRQ routing table... ");
34520 __asm__("push %%es\n\t"
34521 + "movw %w8, %%ds\n\t"
34522 "push %%ds\n\t"
34523 "pop %%es\n\t"
34524 - "lcall *(%%esi); cld\n\t"
34525 + "lcall *%%ss:(%%esi); cld\n\t"
34526 "pop %%es\n\t"
34527 + "push %%ss\n\t"
34528 + "pop %%ds\n"
34529 "jc 1f\n\t"
34530 "xor %%ah, %%ah\n"
34531 "1:"
34532 @@ -408,7 +481,8 @@ struct irq_routing_table * pcibios_get_irq_routing_table(void)
34533 "1" (0),
34534 "D" ((long) &opt),
34535 "S" (&pci_indirect),
34536 - "m" (opt)
34537 + "m" (opt),
34538 + "r" (__PCIBIOS_DS)
34539 : "memory");
34540 DBG("OK ret=%d, size=%d, map=%x\n", ret, opt.size, map);
34541 if (ret & 0xff00)
34542 @@ -432,7 +506,10 @@ int pcibios_set_irq_routing(struct pci_dev *dev, int pin, int irq)
34543 {
34544 int ret;
34545
34546 - __asm__("lcall *(%%esi); cld\n\t"
34547 + __asm__("movw %w5, %%ds\n\t"
34548 + "lcall *%%ss:(%%esi); cld\n\t"
34549 + "push %%ss\n\t"
34550 + "pop %%ds\n"
34551 "jc 1f\n\t"
34552 "xor %%ah, %%ah\n"
34553 "1:"
34554 @@ -440,7 +517,8 @@ int pcibios_set_irq_routing(struct pci_dev *dev, int pin, int irq)
34555 : "0" (PCIBIOS_SET_PCI_HW_INT),
34556 "b" ((dev->bus->number << 8) | dev->devfn),
34557 "c" ((irq << 8) | (pin + 10)),
34558 - "S" (&pci_indirect));
34559 + "S" (&pci_indirect),
34560 + "r" (__PCIBIOS_DS));
34561 return !(ret & 0xff00);
34562 }
34563 EXPORT_SYMBOL(pcibios_set_irq_routing);
34564 diff --git a/arch/x86/platform/efi/efi_32.c b/arch/x86/platform/efi/efi_32.c
34565 index 9ee3491..872192f 100644
34566 --- a/arch/x86/platform/efi/efi_32.c
34567 +++ b/arch/x86/platform/efi/efi_32.c
34568 @@ -59,11 +59,22 @@ void efi_call_phys_prelog(void)
34569 {
34570 struct desc_ptr gdt_descr;
34571
34572 +#ifdef CONFIG_PAX_KERNEXEC
34573 + struct desc_struct d;
34574 +#endif
34575 +
34576 local_irq_save(efi_rt_eflags);
34577
34578 load_cr3(initial_page_table);
34579 __flush_tlb_all();
34580
34581 +#ifdef CONFIG_PAX_KERNEXEC
34582 + pack_descriptor(&d, 0, 0xFFFFF, 0x9B, 0xC);
34583 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_CS, &d, DESCTYPE_S);
34584 + pack_descriptor(&d, 0, 0xFFFFF, 0x93, 0xC);
34585 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_DS, &d, DESCTYPE_S);
34586 +#endif
34587 +
34588 gdt_descr.address = __pa(get_cpu_gdt_table(0));
34589 gdt_descr.size = GDT_SIZE - 1;
34590 load_gdt(&gdt_descr);
34591 @@ -73,11 +84,24 @@ void efi_call_phys_epilog(void)
34592 {
34593 struct desc_ptr gdt_descr;
34594
34595 +#ifdef CONFIG_PAX_KERNEXEC
34596 + struct desc_struct d;
34597 +
34598 + memset(&d, 0, sizeof d);
34599 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_CS, &d, DESCTYPE_S);
34600 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_DS, &d, DESCTYPE_S);
34601 +#endif
34602 +
34603 gdt_descr.address = (unsigned long)get_cpu_gdt_table(0);
34604 gdt_descr.size = GDT_SIZE - 1;
34605 load_gdt(&gdt_descr);
34606
34607 +#ifdef CONFIG_PAX_PER_CPU_PGD
34608 + load_cr3(get_cpu_pgd(smp_processor_id(), kernel));
34609 +#else
34610 load_cr3(swapper_pg_dir);
34611 +#endif
34612 +
34613 __flush_tlb_all();
34614
34615 local_irq_restore(efi_rt_eflags);
34616 diff --git a/arch/x86/platform/efi/efi_64.c b/arch/x86/platform/efi/efi_64.c
34617 index 290d397..3906bcd 100644
34618 --- a/arch/x86/platform/efi/efi_64.c
34619 +++ b/arch/x86/platform/efi/efi_64.c
34620 @@ -99,6 +99,11 @@ void __init efi_call_phys_prelog(void)
34621 vaddress = (unsigned long)__va(pgd * PGDIR_SIZE);
34622 set_pgd(pgd_offset_k(pgd * PGDIR_SIZE), *pgd_offset_k(vaddress));
34623 }
34624 +
34625 +#ifdef CONFIG_PAX_PER_CPU_PGD
34626 + load_cr3(swapper_pg_dir);
34627 +#endif
34628 +
34629 __flush_tlb_all();
34630 }
34631
34632 @@ -116,6 +121,11 @@ void __init efi_call_phys_epilog(void)
34633 for (pgd = 0; pgd < n_pgds; pgd++)
34634 set_pgd(pgd_offset_k(pgd * PGDIR_SIZE), save_pgd[pgd]);
34635 kfree(save_pgd);
34636 +
34637 +#ifdef CONFIG_PAX_PER_CPU_PGD
34638 + load_cr3(get_cpu_pgd(smp_processor_id(), kernel));
34639 +#endif
34640 +
34641 __flush_tlb_all();
34642 local_irq_restore(efi_flags);
34643 early_code_mapping_set_exec(0);
34644 diff --git a/arch/x86/platform/efi/efi_stub_32.S b/arch/x86/platform/efi/efi_stub_32.S
34645 index fbe66e6..eae5e38 100644
34646 --- a/arch/x86/platform/efi/efi_stub_32.S
34647 +++ b/arch/x86/platform/efi/efi_stub_32.S
34648 @@ -6,7 +6,9 @@
34649 */
34650
34651 #include <linux/linkage.h>
34652 +#include <linux/init.h>
34653 #include <asm/page_types.h>
34654 +#include <asm/segment.h>
34655
34656 /*
34657 * efi_call_phys(void *, ...) is a function with variable parameters.
34658 @@ -20,7 +22,7 @@
34659 * service functions will comply with gcc calling convention, too.
34660 */
34661
34662 -.text
34663 +__INIT
34664 ENTRY(efi_call_phys)
34665 /*
34666 * 0. The function can only be called in Linux kernel. So CS has been
34667 @@ -36,10 +38,24 @@ ENTRY(efi_call_phys)
34668 * The mapping of lower virtual memory has been created in prelog and
34669 * epilog.
34670 */
34671 - movl $1f, %edx
34672 - subl $__PAGE_OFFSET, %edx
34673 - jmp *%edx
34674 +#ifdef CONFIG_PAX_KERNEXEC
34675 + movl $(__KERNEXEC_EFI_DS), %edx
34676 + mov %edx, %ds
34677 + mov %edx, %es
34678 + mov %edx, %ss
34679 + addl $2f,(1f)
34680 + ljmp *(1f)
34681 +
34682 +__INITDATA
34683 +1: .long __LOAD_PHYSICAL_ADDR, __KERNEXEC_EFI_CS
34684 +.previous
34685 +
34686 +2:
34687 + subl $2b,(1b)
34688 +#else
34689 + jmp 1f-__PAGE_OFFSET
34690 1:
34691 +#endif
34692
34693 /*
34694 * 2. Now on the top of stack is the return
34695 @@ -47,14 +63,8 @@ ENTRY(efi_call_phys)
34696 * parameter 2, ..., param n. To make things easy, we save the return
34697 * address of efi_call_phys in a global variable.
34698 */
34699 - popl %edx
34700 - movl %edx, saved_return_addr
34701 - /* get the function pointer into ECX*/
34702 - popl %ecx
34703 - movl %ecx, efi_rt_function_ptr
34704 - movl $2f, %edx
34705 - subl $__PAGE_OFFSET, %edx
34706 - pushl %edx
34707 + popl (saved_return_addr)
34708 + popl (efi_rt_function_ptr)
34709
34710 /*
34711 * 3. Clear PG bit in %CR0.
34712 @@ -73,9 +83,8 @@ ENTRY(efi_call_phys)
34713 /*
34714 * 5. Call the physical function.
34715 */
34716 - jmp *%ecx
34717 + call *(efi_rt_function_ptr-__PAGE_OFFSET)
34718
34719 -2:
34720 /*
34721 * 6. After EFI runtime service returns, control will return to
34722 * following instruction. We'd better readjust stack pointer first.
34723 @@ -88,35 +97,36 @@ ENTRY(efi_call_phys)
34724 movl %cr0, %edx
34725 orl $0x80000000, %edx
34726 movl %edx, %cr0
34727 - jmp 1f
34728 -1:
34729 +
34730 /*
34731 * 8. Now restore the virtual mode from flat mode by
34732 * adding EIP with PAGE_OFFSET.
34733 */
34734 - movl $1f, %edx
34735 - jmp *%edx
34736 +#ifdef CONFIG_PAX_KERNEXEC
34737 + movl $(__KERNEL_DS), %edx
34738 + mov %edx, %ds
34739 + mov %edx, %es
34740 + mov %edx, %ss
34741 + ljmp $(__KERNEL_CS),$1f
34742 +#else
34743 + jmp 1f+__PAGE_OFFSET
34744 +#endif
34745 1:
34746
34747 /*
34748 * 9. Balance the stack. And because EAX contain the return value,
34749 * we'd better not clobber it.
34750 */
34751 - leal efi_rt_function_ptr, %edx
34752 - movl (%edx), %ecx
34753 - pushl %ecx
34754 + pushl (efi_rt_function_ptr)
34755
34756 /*
34757 - * 10. Push the saved return address onto the stack and return.
34758 + * 10. Return to the saved return address.
34759 */
34760 - leal saved_return_addr, %edx
34761 - movl (%edx), %ecx
34762 - pushl %ecx
34763 - ret
34764 + jmpl *(saved_return_addr)
34765 ENDPROC(efi_call_phys)
34766 .previous
34767
34768 -.data
34769 +__INITDATA
34770 saved_return_addr:
34771 .long 0
34772 efi_rt_function_ptr:
34773 diff --git a/arch/x86/platform/efi/efi_stub_64.S b/arch/x86/platform/efi/efi_stub_64.S
34774 index e0984ef..a062dac 100644
34775 --- a/arch/x86/platform/efi/efi_stub_64.S
34776 +++ b/arch/x86/platform/efi/efi_stub_64.S
34777 @@ -11,6 +11,7 @@
34778 #include <asm/msr.h>
34779 #include <asm/processor-flags.h>
34780 #include <asm/page_types.h>
34781 +#include <asm/alternative-asm.h>
34782
34783 #define SAVE_XMM \
34784 mov %rsp, %rax; \
34785 @@ -81,6 +82,7 @@ ENTRY(efi_call0)
34786 RESTORE_PGT
34787 addq $32, %rsp
34788 RESTORE_XMM
34789 + pax_force_retaddr 0, 1
34790 ret
34791 ENDPROC(efi_call0)
34792
34793 @@ -93,6 +95,7 @@ ENTRY(efi_call1)
34794 RESTORE_PGT
34795 addq $32, %rsp
34796 RESTORE_XMM
34797 + pax_force_retaddr 0, 1
34798 ret
34799 ENDPROC(efi_call1)
34800
34801 @@ -105,6 +108,7 @@ ENTRY(efi_call2)
34802 RESTORE_PGT
34803 addq $32, %rsp
34804 RESTORE_XMM
34805 + pax_force_retaddr 0, 1
34806 ret
34807 ENDPROC(efi_call2)
34808
34809 @@ -118,6 +122,7 @@ ENTRY(efi_call3)
34810 RESTORE_PGT
34811 addq $32, %rsp
34812 RESTORE_XMM
34813 + pax_force_retaddr 0, 1
34814 ret
34815 ENDPROC(efi_call3)
34816
34817 @@ -132,6 +137,7 @@ ENTRY(efi_call4)
34818 RESTORE_PGT
34819 addq $32, %rsp
34820 RESTORE_XMM
34821 + pax_force_retaddr 0, 1
34822 ret
34823 ENDPROC(efi_call4)
34824
34825 @@ -147,6 +153,7 @@ ENTRY(efi_call5)
34826 RESTORE_PGT
34827 addq $48, %rsp
34828 RESTORE_XMM
34829 + pax_force_retaddr 0, 1
34830 ret
34831 ENDPROC(efi_call5)
34832
34833 @@ -165,6 +172,7 @@ ENTRY(efi_call6)
34834 RESTORE_PGT
34835 addq $48, %rsp
34836 RESTORE_XMM
34837 + pax_force_retaddr 0, 1
34838 ret
34839 ENDPROC(efi_call6)
34840
34841 diff --git a/arch/x86/platform/intel-mid/intel-mid.c b/arch/x86/platform/intel-mid/intel-mid.c
34842 index 1bbedc4..eb795b5 100644
34843 --- a/arch/x86/platform/intel-mid/intel-mid.c
34844 +++ b/arch/x86/platform/intel-mid/intel-mid.c
34845 @@ -71,9 +71,10 @@ static void intel_mid_power_off(void)
34846 {
34847 };
34848
34849 -static void intel_mid_reboot(void)
34850 +static void __noreturn intel_mid_reboot(void)
34851 {
34852 intel_scu_ipc_simple_command(IPCMSG_COLD_BOOT, 0);
34853 + BUG();
34854 }
34855
34856 static unsigned long __init intel_mid_calibrate_tsc(void)
34857 diff --git a/arch/x86/platform/olpc/olpc_dt.c b/arch/x86/platform/olpc/olpc_dt.c
34858 index d6ee929..3637cb5 100644
34859 --- a/arch/x86/platform/olpc/olpc_dt.c
34860 +++ b/arch/x86/platform/olpc/olpc_dt.c
34861 @@ -156,7 +156,7 @@ void * __init prom_early_alloc(unsigned long size)
34862 return res;
34863 }
34864
34865 -static struct of_pdt_ops prom_olpc_ops __initdata = {
34866 +static struct of_pdt_ops prom_olpc_ops __initconst = {
34867 .nextprop = olpc_dt_nextprop,
34868 .getproplen = olpc_dt_getproplen,
34869 .getproperty = olpc_dt_getproperty,
34870 diff --git a/arch/x86/power/cpu.c b/arch/x86/power/cpu.c
34871 index 424f4c9..f2a2988 100644
34872 --- a/arch/x86/power/cpu.c
34873 +++ b/arch/x86/power/cpu.c
34874 @@ -137,11 +137,8 @@ static void do_fpu_end(void)
34875 static void fix_processor_context(void)
34876 {
34877 int cpu = smp_processor_id();
34878 - struct tss_struct *t = &per_cpu(init_tss, cpu);
34879 -#ifdef CONFIG_X86_64
34880 - struct desc_struct *desc = get_cpu_gdt_table(cpu);
34881 - tss_desc tss;
34882 -#endif
34883 + struct tss_struct *t = init_tss + cpu;
34884 +
34885 set_tss_desc(cpu, t); /*
34886 * This just modifies memory; should not be
34887 * necessary. But... This is necessary, because
34888 @@ -150,10 +147,6 @@ static void fix_processor_context(void)
34889 */
34890
34891 #ifdef CONFIG_X86_64
34892 - memcpy(&tss, &desc[GDT_ENTRY_TSS], sizeof(tss_desc));
34893 - tss.type = 0x9; /* The available 64-bit TSS (see AMD vol 2, pg 91 */
34894 - write_gdt_entry(desc, GDT_ENTRY_TSS, &tss, DESC_TSS);
34895 -
34896 syscall_init(); /* This sets MSR_*STAR and related */
34897 #endif
34898 load_TR_desc(); /* This does ltr */
34899 diff --git a/arch/x86/realmode/init.c b/arch/x86/realmode/init.c
34900 index bad628a..a102610 100644
34901 --- a/arch/x86/realmode/init.c
34902 +++ b/arch/x86/realmode/init.c
34903 @@ -68,7 +68,13 @@ void __init setup_real_mode(void)
34904 __va(real_mode_header->trampoline_header);
34905
34906 #ifdef CONFIG_X86_32
34907 - trampoline_header->start = __pa_symbol(startup_32_smp);
34908 + trampoline_header->start = __pa_symbol(ktla_ktva(startup_32_smp));
34909 +
34910 +#ifdef CONFIG_PAX_KERNEXEC
34911 + trampoline_header->start -= LOAD_PHYSICAL_ADDR;
34912 +#endif
34913 +
34914 + trampoline_header->boot_cs = __BOOT_CS;
34915 trampoline_header->gdt_limit = __BOOT_DS + 7;
34916 trampoline_header->gdt_base = __pa_symbol(boot_gdt);
34917 #else
34918 @@ -84,7 +90,7 @@ void __init setup_real_mode(void)
34919 *trampoline_cr4_features = read_cr4();
34920
34921 trampoline_pgd = (u64 *) __va(real_mode_header->trampoline_pgd);
34922 - trampoline_pgd[0] = init_level4_pgt[pgd_index(__PAGE_OFFSET)].pgd;
34923 + trampoline_pgd[0] = init_level4_pgt[pgd_index(__PAGE_OFFSET)].pgd & ~_PAGE_NX;
34924 trampoline_pgd[511] = init_level4_pgt[511].pgd;
34925 #endif
34926 }
34927 diff --git a/arch/x86/realmode/rm/Makefile b/arch/x86/realmode/rm/Makefile
34928 index 3497f14..cc73b92 100644
34929 --- a/arch/x86/realmode/rm/Makefile
34930 +++ b/arch/x86/realmode/rm/Makefile
34931 @@ -66,5 +66,8 @@ $(obj)/realmode.relocs: $(obj)/realmode.elf FORCE
34932
34933 KBUILD_CFLAGS := $(LINUXINCLUDE) $(REALMODE_CFLAGS) -D_SETUP -D_WAKEUP \
34934 -I$(srctree)/arch/x86/boot
34935 +ifdef CONSTIFY_PLUGIN
34936 +KBUILD_CFLAGS += -fplugin-arg-constify_plugin-no-constify
34937 +endif
34938 KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
34939 GCOV_PROFILE := n
34940 diff --git a/arch/x86/realmode/rm/header.S b/arch/x86/realmode/rm/header.S
34941 index a28221d..93c40f1 100644
34942 --- a/arch/x86/realmode/rm/header.S
34943 +++ b/arch/x86/realmode/rm/header.S
34944 @@ -30,7 +30,9 @@ GLOBAL(real_mode_header)
34945 #endif
34946 /* APM/BIOS reboot */
34947 .long pa_machine_real_restart_asm
34948 -#ifdef CONFIG_X86_64
34949 +#ifdef CONFIG_X86_32
34950 + .long __KERNEL_CS
34951 +#else
34952 .long __KERNEL32_CS
34953 #endif
34954 END(real_mode_header)
34955 diff --git a/arch/x86/realmode/rm/trampoline_32.S b/arch/x86/realmode/rm/trampoline_32.S
34956 index 48ddd76..c26749f 100644
34957 --- a/arch/x86/realmode/rm/trampoline_32.S
34958 +++ b/arch/x86/realmode/rm/trampoline_32.S
34959 @@ -24,6 +24,12 @@
34960 #include <asm/page_types.h>
34961 #include "realmode.h"
34962
34963 +#ifdef CONFIG_PAX_KERNEXEC
34964 +#define ta(X) (X)
34965 +#else
34966 +#define ta(X) (pa_ ## X)
34967 +#endif
34968 +
34969 .text
34970 .code16
34971
34972 @@ -38,8 +44,6 @@ ENTRY(trampoline_start)
34973
34974 cli # We should be safe anyway
34975
34976 - movl tr_start, %eax # where we need to go
34977 -
34978 movl $0xA5A5A5A5, trampoline_status
34979 # write marker for master knows we're running
34980
34981 @@ -55,7 +59,7 @@ ENTRY(trampoline_start)
34982 movw $1, %dx # protected mode (PE) bit
34983 lmsw %dx # into protected mode
34984
34985 - ljmpl $__BOOT_CS, $pa_startup_32
34986 + ljmpl *(trampoline_header)
34987
34988 .section ".text32","ax"
34989 .code32
34990 @@ -66,7 +70,7 @@ ENTRY(startup_32) # note: also used from wakeup_asm.S
34991 .balign 8
34992 GLOBAL(trampoline_header)
34993 tr_start: .space 4
34994 - tr_gdt_pad: .space 2
34995 + tr_boot_cs: .space 2
34996 tr_gdt: .space 6
34997 END(trampoline_header)
34998
34999 diff --git a/arch/x86/realmode/rm/trampoline_64.S b/arch/x86/realmode/rm/trampoline_64.S
35000 index dac7b20..72dbaca 100644
35001 --- a/arch/x86/realmode/rm/trampoline_64.S
35002 +++ b/arch/x86/realmode/rm/trampoline_64.S
35003 @@ -93,6 +93,7 @@ ENTRY(startup_32)
35004 movl %edx, %gs
35005
35006 movl pa_tr_cr4, %eax
35007 + andl $~X86_CR4_PCIDE, %eax
35008 movl %eax, %cr4 # Enable PAE mode
35009
35010 # Setup trampoline 4 level pagetables
35011 @@ -106,7 +107,7 @@ ENTRY(startup_32)
35012 wrmsr
35013
35014 # Enable paging and in turn activate Long Mode
35015 - movl $(X86_CR0_PG | X86_CR0_WP | X86_CR0_PE), %eax
35016 + movl $(X86_CR0_PG | X86_CR0_PE), %eax
35017 movl %eax, %cr0
35018
35019 /*
35020 diff --git a/arch/x86/realmode/rm/wakeup_asm.S b/arch/x86/realmode/rm/wakeup_asm.S
35021 index 9e7e147..25a4158 100644
35022 --- a/arch/x86/realmode/rm/wakeup_asm.S
35023 +++ b/arch/x86/realmode/rm/wakeup_asm.S
35024 @@ -126,11 +126,10 @@ ENTRY(wakeup_start)
35025 lgdtl pmode_gdt
35026
35027 /* This really couldn't... */
35028 - movl pmode_entry, %eax
35029 movl pmode_cr0, %ecx
35030 movl %ecx, %cr0
35031 - ljmpl $__KERNEL_CS, $pa_startup_32
35032 - /* -> jmp *%eax in trampoline_32.S */
35033 +
35034 + ljmpl *pmode_entry
35035 #else
35036 jmp trampoline_start
35037 #endif
35038 diff --git a/arch/x86/tools/Makefile b/arch/x86/tools/Makefile
35039 index 604a37e..e49702a 100644
35040 --- a/arch/x86/tools/Makefile
35041 +++ b/arch/x86/tools/Makefile
35042 @@ -37,7 +37,7 @@ $(obj)/test_get_len.o: $(srctree)/arch/x86/lib/insn.c $(srctree)/arch/x86/lib/in
35043
35044 $(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
35045
35046 -HOST_EXTRACFLAGS += -I$(srctree)/tools/include
35047 +HOST_EXTRACFLAGS += -I$(srctree)/tools/include -ggdb
35048 hostprogs-y += relocs
35049 relocs-objs := relocs_32.o relocs_64.o relocs_common.o
35050 PHONY += relocs
35051 diff --git a/arch/x86/tools/relocs.c b/arch/x86/tools/relocs.c
35052 index bbb1d22..e505211 100644
35053 --- a/arch/x86/tools/relocs.c
35054 +++ b/arch/x86/tools/relocs.c
35055 @@ -1,5 +1,7 @@
35056 /* This is included from relocs_32/64.c */
35057
35058 +#include "../../../include/generated/autoconf.h"
35059 +
35060 #define ElfW(type) _ElfW(ELF_BITS, type)
35061 #define _ElfW(bits, type) __ElfW(bits, type)
35062 #define __ElfW(bits, type) Elf##bits##_##type
35063 @@ -11,6 +13,7 @@
35064 #define Elf_Sym ElfW(Sym)
35065
35066 static Elf_Ehdr ehdr;
35067 +static Elf_Phdr *phdr;
35068
35069 struct relocs {
35070 uint32_t *offset;
35071 @@ -383,9 +386,39 @@ static void read_ehdr(FILE *fp)
35072 }
35073 }
35074
35075 +static void read_phdrs(FILE *fp)
35076 +{
35077 + unsigned int i;
35078 +
35079 + phdr = calloc(ehdr.e_phnum, sizeof(Elf_Phdr));
35080 + if (!phdr) {
35081 + die("Unable to allocate %d program headers\n",
35082 + ehdr.e_phnum);
35083 + }
35084 + if (fseek(fp, ehdr.e_phoff, SEEK_SET) < 0) {
35085 + die("Seek to %d failed: %s\n",
35086 + ehdr.e_phoff, strerror(errno));
35087 + }
35088 + if (fread(phdr, sizeof(*phdr), ehdr.e_phnum, fp) != ehdr.e_phnum) {
35089 + die("Cannot read ELF program headers: %s\n",
35090 + strerror(errno));
35091 + }
35092 + for(i = 0; i < ehdr.e_phnum; i++) {
35093 + phdr[i].p_type = elf_word_to_cpu(phdr[i].p_type);
35094 + phdr[i].p_offset = elf_off_to_cpu(phdr[i].p_offset);
35095 + phdr[i].p_vaddr = elf_addr_to_cpu(phdr[i].p_vaddr);
35096 + phdr[i].p_paddr = elf_addr_to_cpu(phdr[i].p_paddr);
35097 + phdr[i].p_filesz = elf_word_to_cpu(phdr[i].p_filesz);
35098 + phdr[i].p_memsz = elf_word_to_cpu(phdr[i].p_memsz);
35099 + phdr[i].p_flags = elf_word_to_cpu(phdr[i].p_flags);
35100 + phdr[i].p_align = elf_word_to_cpu(phdr[i].p_align);
35101 + }
35102 +
35103 +}
35104 +
35105 static void read_shdrs(FILE *fp)
35106 {
35107 - int i;
35108 + unsigned int i;
35109 Elf_Shdr shdr;
35110
35111 secs = calloc(ehdr.e_shnum, sizeof(struct section));
35112 @@ -420,7 +453,7 @@ static void read_shdrs(FILE *fp)
35113
35114 static void read_strtabs(FILE *fp)
35115 {
35116 - int i;
35117 + unsigned int i;
35118 for (i = 0; i < ehdr.e_shnum; i++) {
35119 struct section *sec = &secs[i];
35120 if (sec->shdr.sh_type != SHT_STRTAB) {
35121 @@ -445,7 +478,7 @@ static void read_strtabs(FILE *fp)
35122
35123 static void read_symtabs(FILE *fp)
35124 {
35125 - int i,j;
35126 + unsigned int i,j;
35127 for (i = 0; i < ehdr.e_shnum; i++) {
35128 struct section *sec = &secs[i];
35129 if (sec->shdr.sh_type != SHT_SYMTAB) {
35130 @@ -476,9 +509,11 @@ static void read_symtabs(FILE *fp)
35131 }
35132
35133
35134 -static void read_relocs(FILE *fp)
35135 +static void read_relocs(FILE *fp, int use_real_mode)
35136 {
35137 - int i,j;
35138 + unsigned int i,j;
35139 + uint32_t base;
35140 +
35141 for (i = 0; i < ehdr.e_shnum; i++) {
35142 struct section *sec = &secs[i];
35143 if (sec->shdr.sh_type != SHT_REL_TYPE) {
35144 @@ -498,9 +533,22 @@ static void read_relocs(FILE *fp)
35145 die("Cannot read symbol table: %s\n",
35146 strerror(errno));
35147 }
35148 + base = 0;
35149 +
35150 +#ifdef CONFIG_X86_32
35151 + for (j = 0; !use_real_mode && j < ehdr.e_phnum; j++) {
35152 + if (phdr[j].p_type != PT_LOAD )
35153 + continue;
35154 + 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)
35155 + continue;
35156 + base = CONFIG_PAGE_OFFSET + phdr[j].p_paddr - phdr[j].p_vaddr;
35157 + break;
35158 + }
35159 +#endif
35160 +
35161 for (j = 0; j < sec->shdr.sh_size/sizeof(Elf_Rel); j++) {
35162 Elf_Rel *rel = &sec->reltab[j];
35163 - rel->r_offset = elf_addr_to_cpu(rel->r_offset);
35164 + rel->r_offset = elf_addr_to_cpu(rel->r_offset) + base;
35165 rel->r_info = elf_xword_to_cpu(rel->r_info);
35166 #if (SHT_REL_TYPE == SHT_RELA)
35167 rel->r_addend = elf_xword_to_cpu(rel->r_addend);
35168 @@ -512,7 +560,7 @@ static void read_relocs(FILE *fp)
35169
35170 static void print_absolute_symbols(void)
35171 {
35172 - int i;
35173 + unsigned int i;
35174 const char *format;
35175
35176 if (ELF_BITS == 64)
35177 @@ -525,7 +573,7 @@ static void print_absolute_symbols(void)
35178 for (i = 0; i < ehdr.e_shnum; i++) {
35179 struct section *sec = &secs[i];
35180 char *sym_strtab;
35181 - int j;
35182 + unsigned int j;
35183
35184 if (sec->shdr.sh_type != SHT_SYMTAB) {
35185 continue;
35186 @@ -552,7 +600,7 @@ static void print_absolute_symbols(void)
35187
35188 static void print_absolute_relocs(void)
35189 {
35190 - int i, printed = 0;
35191 + unsigned int i, printed = 0;
35192 const char *format;
35193
35194 if (ELF_BITS == 64)
35195 @@ -565,7 +613,7 @@ static void print_absolute_relocs(void)
35196 struct section *sec_applies, *sec_symtab;
35197 char *sym_strtab;
35198 Elf_Sym *sh_symtab;
35199 - int j;
35200 + unsigned int j;
35201 if (sec->shdr.sh_type != SHT_REL_TYPE) {
35202 continue;
35203 }
35204 @@ -642,13 +690,13 @@ static void add_reloc(struct relocs *r, uint32_t offset)
35205 static void walk_relocs(int (*process)(struct section *sec, Elf_Rel *rel,
35206 Elf_Sym *sym, const char *symname))
35207 {
35208 - int i;
35209 + unsigned int i;
35210 /* Walk through the relocations */
35211 for (i = 0; i < ehdr.e_shnum; i++) {
35212 char *sym_strtab;
35213 Elf_Sym *sh_symtab;
35214 struct section *sec_applies, *sec_symtab;
35215 - int j;
35216 + unsigned int j;
35217 struct section *sec = &secs[i];
35218
35219 if (sec->shdr.sh_type != SHT_REL_TYPE) {
35220 @@ -822,6 +870,23 @@ static int do_reloc32(struct section *sec, Elf_Rel *rel, Elf_Sym *sym,
35221 {
35222 unsigned r_type = ELF32_R_TYPE(rel->r_info);
35223 int shn_abs = (sym->st_shndx == SHN_ABS) && !is_reloc(S_REL, symname);
35224 + char *sym_strtab = sec->link->link->strtab;
35225 +
35226 + /* Don't relocate actual per-cpu variables, they are absolute indices, not addresses */
35227 + if (!strcmp(sec_name(sym->st_shndx), ".data..percpu") && strcmp(sym_name(sym_strtab, sym), "__per_cpu_load"))
35228 + return 0;
35229 +
35230 +#ifdef CONFIG_PAX_KERNEXEC
35231 + /* Don't relocate actual code, they are relocated implicitly by the base address of KERNEL_CS */
35232 + if (!strcmp(sec_name(sym->st_shndx), ".text.end") && !strcmp(sym_name(sym_strtab, sym), "_etext"))
35233 + return 0;
35234 + if (!strcmp(sec_name(sym->st_shndx), ".init.text"))
35235 + return 0;
35236 + if (!strcmp(sec_name(sym->st_shndx), ".exit.text"))
35237 + return 0;
35238 + if (!strcmp(sec_name(sym->st_shndx), ".text") && strcmp(sym_name(sym_strtab, sym), "__LOAD_PHYSICAL_ADDR"))
35239 + return 0;
35240 +#endif
35241
35242 switch (r_type) {
35243 case R_386_NONE:
35244 @@ -960,7 +1025,7 @@ static int write32_as_text(uint32_t v, FILE *f)
35245
35246 static void emit_relocs(int as_text, int use_real_mode)
35247 {
35248 - int i;
35249 + unsigned int i;
35250 int (*write_reloc)(uint32_t, FILE *) = write32;
35251 int (*do_reloc)(struct section *sec, Elf_Rel *rel, Elf_Sym *sym,
35252 const char *symname);
35253 @@ -1060,10 +1125,11 @@ void process(FILE *fp, int use_real_mode, int as_text,
35254 {
35255 regex_init(use_real_mode);
35256 read_ehdr(fp);
35257 + read_phdrs(fp);
35258 read_shdrs(fp);
35259 read_strtabs(fp);
35260 read_symtabs(fp);
35261 - read_relocs(fp);
35262 + read_relocs(fp, use_real_mode);
35263 if (ELF_BITS == 64)
35264 percpu_init();
35265 if (show_absolute_syms) {
35266 diff --git a/arch/x86/um/mem_32.c b/arch/x86/um/mem_32.c
35267 index f40281e..92728c9 100644
35268 --- a/arch/x86/um/mem_32.c
35269 +++ b/arch/x86/um/mem_32.c
35270 @@ -21,7 +21,7 @@ static int __init gate_vma_init(void)
35271 gate_vma.vm_start = FIXADDR_USER_START;
35272 gate_vma.vm_end = FIXADDR_USER_END;
35273 gate_vma.vm_flags = VM_READ | VM_MAYREAD | VM_EXEC | VM_MAYEXEC;
35274 - gate_vma.vm_page_prot = __P101;
35275 + gate_vma.vm_page_prot = vm_get_page_prot(gate_vma.vm_flags);
35276
35277 return 0;
35278 }
35279 diff --git a/arch/x86/um/tls_32.c b/arch/x86/um/tls_32.c
35280 index 80ffa5b..a33bd15 100644
35281 --- a/arch/x86/um/tls_32.c
35282 +++ b/arch/x86/um/tls_32.c
35283 @@ -260,7 +260,7 @@ out:
35284 if (unlikely(task == current &&
35285 !t->arch.tls_array[idx - GDT_ENTRY_TLS_MIN].flushed)) {
35286 printk(KERN_ERR "get_tls_entry: task with pid %d got here "
35287 - "without flushed TLS.", current->pid);
35288 + "without flushed TLS.", task_pid_nr(current));
35289 }
35290
35291 return 0;
35292 diff --git a/arch/x86/vdso/Makefile b/arch/x86/vdso/Makefile
35293 index c580d12..0a0ba35 100644
35294 --- a/arch/x86/vdso/Makefile
35295 +++ b/arch/x86/vdso/Makefile
35296 @@ -196,7 +196,7 @@ quiet_cmd_vdso = VDSO $@
35297 -Wl,-T,$(filter %.lds,$^) $(filter %.o,$^) && \
35298 sh $(srctree)/$(src)/checkundef.sh '$(NM)' '$@'
35299
35300 -VDSO_LDFLAGS = -fPIC -shared $(call cc-ldoption, -Wl$(comma)--hash-style=sysv) \
35301 +VDSO_LDFLAGS = -fPIC -shared -Wl,--no-undefined $(call cc-ldoption, -Wl$(comma)--hash-style=sysv) \
35302 $(LTO_CFLAGS)
35303 GCOV_PROFILE := n
35304
35305 diff --git a/arch/x86/vdso/vdso32-setup.c b/arch/x86/vdso/vdso32-setup.c
35306 index 310c5f0..766d0a7 100644
35307 --- a/arch/x86/vdso/vdso32-setup.c
35308 +++ b/arch/x86/vdso/vdso32-setup.c
35309 @@ -29,6 +29,7 @@
35310 #include <asm/fixmap.h>
35311 #include <asm/hpet.h>
35312 #include <asm/vvar.h>
35313 +#include <asm/mman.h>
35314
35315 #ifdef CONFIG_COMPAT_VDSO
35316 #define VDSO_DEFAULT 0
35317 @@ -99,7 +100,7 @@ void syscall32_cpu_init(void)
35318 void enable_sep_cpu(void)
35319 {
35320 int cpu = get_cpu();
35321 - struct tss_struct *tss = &per_cpu(init_tss, cpu);
35322 + struct tss_struct *tss = init_tss + cpu;
35323
35324 if (!boot_cpu_has(X86_FEATURE_SEP)) {
35325 put_cpu();
35326 @@ -167,7 +168,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
35327
35328 down_write(&mm->mmap_sem);
35329
35330 - addr = get_unmapped_area(NULL, 0, vdso32_size + VDSO_OFFSET(VDSO_PREV_PAGES), 0, 0);
35331 + addr = get_unmapped_area(NULL, 0, vdso32_size + VDSO_OFFSET(VDSO_PREV_PAGES), 0, MAP_EXECUTABLE);
35332 if (IS_ERR_VALUE(addr)) {
35333 ret = addr;
35334 goto up_fail;
35335 @@ -175,7 +176,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
35336
35337 addr += VDSO_OFFSET(VDSO_PREV_PAGES);
35338
35339 - current->mm->context.vdso = (void *)addr;
35340 + current->mm->context.vdso = addr;
35341
35342 /*
35343 * MAYWRITE to allow gdb to COW and set breakpoints
35344 @@ -224,11 +225,11 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
35345 #endif
35346
35347 current_thread_info()->sysenter_return =
35348 - VDSO32_SYMBOL(addr, SYSENTER_RETURN);
35349 + (void __force_user *)VDSO32_SYMBOL(addr, SYSENTER_RETURN);
35350
35351 up_fail:
35352 if (ret)
35353 - current->mm->context.vdso = NULL;
35354 + current->mm->context.vdso = 0;
35355
35356 up_write(&mm->mmap_sem);
35357
35358 @@ -282,8 +283,14 @@ __initcall(ia32_binfmt_init);
35359
35360 const char *arch_vma_name(struct vm_area_struct *vma)
35361 {
35362 - if (vma->vm_mm && vma->vm_start == (long)vma->vm_mm->context.vdso)
35363 + if (vma->vm_mm && vma->vm_start == vma->vm_mm->context.vdso)
35364 return "[vdso]";
35365 +
35366 +#ifdef CONFIG_PAX_SEGMEXEC
35367 + if (vma->vm_mm && vma->vm_mirror && vma->vm_mirror->vm_start == vma->vm_mm->context.vdso)
35368 + return "[vdso]";
35369 +#endif
35370 +
35371 return NULL;
35372 }
35373
35374 diff --git a/arch/x86/vdso/vma.c b/arch/x86/vdso/vma.c
35375 index 1ad1026..1a08abe 100644
35376 --- a/arch/x86/vdso/vma.c
35377 +++ b/arch/x86/vdso/vma.c
35378 @@ -17,8 +17,6 @@
35379 #include <asm/page.h>
35380
35381 #if defined(CONFIG_X86_64)
35382 -unsigned int __read_mostly vdso_enabled = 1;
35383 -
35384 DECLARE_VDSO_IMAGE(vdso);
35385 extern unsigned short vdso_sync_cpuid;
35386 static unsigned vdso_size;
35387 @@ -144,7 +142,6 @@ static unsigned long vdso_addr(unsigned long start, unsigned len)
35388 * unaligned here as a result of stack start randomization.
35389 */
35390 addr = PAGE_ALIGN(addr);
35391 - addr = align_vdso_addr(addr);
35392
35393 return addr;
35394 }
35395 @@ -157,30 +154,31 @@ static int setup_additional_pages(struct linux_binprm *bprm,
35396 unsigned size)
35397 {
35398 struct mm_struct *mm = current->mm;
35399 - unsigned long addr;
35400 + unsigned long addr = 0;
35401 int ret;
35402
35403 - if (!vdso_enabled)
35404 - return 0;
35405 -
35406 down_write(&mm->mmap_sem);
35407 +
35408 +#ifdef CONFIG_PAX_RANDMMAP
35409 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
35410 +#endif
35411 +
35412 addr = vdso_addr(mm->start_stack, size);
35413 + addr = align_vdso_addr(addr);
35414 addr = get_unmapped_area(NULL, addr, size, 0, 0);
35415 if (IS_ERR_VALUE(addr)) {
35416 ret = addr;
35417 goto up_fail;
35418 }
35419
35420 - current->mm->context.vdso = (void *)addr;
35421 + mm->context.vdso = addr;
35422
35423 ret = install_special_mapping(mm, addr, size,
35424 VM_READ|VM_EXEC|
35425 VM_MAYREAD|VM_MAYWRITE|VM_MAYEXEC,
35426 pages);
35427 - if (ret) {
35428 - current->mm->context.vdso = NULL;
35429 - goto up_fail;
35430 - }
35431 + if (ret)
35432 + mm->context.vdso = 0;
35433
35434 up_fail:
35435 up_write(&mm->mmap_sem);
35436 @@ -200,11 +198,4 @@ int x32_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
35437 vdsox32_size);
35438 }
35439 #endif
35440 -
35441 -static __init int vdso_setup(char *s)
35442 -{
35443 - vdso_enabled = simple_strtoul(s, NULL, 0);
35444 - return 0;
35445 -}
35446 -__setup("vdso=", vdso_setup);
35447 #endif
35448 diff --git a/arch/x86/xen/Kconfig b/arch/x86/xen/Kconfig
35449 index e88fda8..76ce7ce 100644
35450 --- a/arch/x86/xen/Kconfig
35451 +++ b/arch/x86/xen/Kconfig
35452 @@ -9,6 +9,7 @@ config XEN
35453 select XEN_HAVE_PVMMU
35454 depends on X86_64 || (X86_32 && X86_PAE)
35455 depends on X86_TSC
35456 + depends on !GRKERNSEC_CONFIG_AUTO || GRKERNSEC_CONFIG_VIRT_XEN
35457 help
35458 This is the Linux Xen port. Enabling this will allow the
35459 kernel to boot in a paravirtualized environment under the
35460 diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
35461 index c34bfc4..e599673 100644
35462 --- a/arch/x86/xen/enlighten.c
35463 +++ b/arch/x86/xen/enlighten.c
35464 @@ -123,8 +123,6 @@ EXPORT_SYMBOL_GPL(xen_start_info);
35465
35466 struct shared_info xen_dummy_shared_info;
35467
35468 -void *xen_initial_gdt;
35469 -
35470 RESERVE_BRK(shared_info_page_brk, PAGE_SIZE);
35471 __read_mostly int xen_have_vector_callback;
35472 EXPORT_SYMBOL_GPL(xen_have_vector_callback);
35473 @@ -542,8 +540,7 @@ static void xen_load_gdt(const struct desc_ptr *dtr)
35474 {
35475 unsigned long va = dtr->address;
35476 unsigned int size = dtr->size + 1;
35477 - unsigned pages = (size + PAGE_SIZE - 1) / PAGE_SIZE;
35478 - unsigned long frames[pages];
35479 + unsigned long frames[65536 / PAGE_SIZE];
35480 int f;
35481
35482 /*
35483 @@ -591,8 +588,7 @@ static void __init xen_load_gdt_boot(const struct desc_ptr *dtr)
35484 {
35485 unsigned long va = dtr->address;
35486 unsigned int size = dtr->size + 1;
35487 - unsigned pages = (size + PAGE_SIZE - 1) / PAGE_SIZE;
35488 - unsigned long frames[pages];
35489 + unsigned long frames[(GDT_SIZE + PAGE_SIZE - 1) / PAGE_SIZE];
35490 int f;
35491
35492 /*
35493 @@ -600,7 +596,7 @@ static void __init xen_load_gdt_boot(const struct desc_ptr *dtr)
35494 * 8-byte entries, or 16 4k pages..
35495 */
35496
35497 - BUG_ON(size > 65536);
35498 + BUG_ON(size > GDT_SIZE);
35499 BUG_ON(va & ~PAGE_MASK);
35500
35501 for (f = 0; va < dtr->address + size; va += PAGE_SIZE, f++) {
35502 @@ -989,7 +985,7 @@ static u32 xen_safe_apic_wait_icr_idle(void)
35503 return 0;
35504 }
35505
35506 -static void set_xen_basic_apic_ops(void)
35507 +static void __init set_xen_basic_apic_ops(void)
35508 {
35509 apic->read = xen_apic_read;
35510 apic->write = xen_apic_write;
35511 @@ -1295,30 +1291,30 @@ static const struct pv_apic_ops xen_apic_ops __initconst = {
35512 #endif
35513 };
35514
35515 -static void xen_reboot(int reason)
35516 +static __noreturn void xen_reboot(int reason)
35517 {
35518 struct sched_shutdown r = { .reason = reason };
35519
35520 - if (HYPERVISOR_sched_op(SCHEDOP_shutdown, &r))
35521 - BUG();
35522 + HYPERVISOR_sched_op(SCHEDOP_shutdown, &r);
35523 + BUG();
35524 }
35525
35526 -static void xen_restart(char *msg)
35527 +static __noreturn void xen_restart(char *msg)
35528 {
35529 xen_reboot(SHUTDOWN_reboot);
35530 }
35531
35532 -static void xen_emergency_restart(void)
35533 +static __noreturn void xen_emergency_restart(void)
35534 {
35535 xen_reboot(SHUTDOWN_reboot);
35536 }
35537
35538 -static void xen_machine_halt(void)
35539 +static __noreturn void xen_machine_halt(void)
35540 {
35541 xen_reboot(SHUTDOWN_poweroff);
35542 }
35543
35544 -static void xen_machine_power_off(void)
35545 +static __noreturn void xen_machine_power_off(void)
35546 {
35547 if (pm_power_off)
35548 pm_power_off();
35549 @@ -1564,7 +1560,17 @@ asmlinkage __visible void __init xen_start_kernel(void)
35550 __userpte_alloc_gfp &= ~__GFP_HIGHMEM;
35551
35552 /* Work out if we support NX */
35553 - x86_configure_nx();
35554 +#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
35555 + if ((cpuid_eax(0x80000000) & 0xffff0000) == 0x80000000 &&
35556 + (cpuid_edx(0x80000001) & (1U << (X86_FEATURE_NX & 31)))) {
35557 + unsigned l, h;
35558 +
35559 + __supported_pte_mask |= _PAGE_NX;
35560 + rdmsr(MSR_EFER, l, h);
35561 + l |= EFER_NX;
35562 + wrmsr(MSR_EFER, l, h);
35563 + }
35564 +#endif
35565
35566 /* Get mfn list */
35567 xen_build_dynamic_phys_to_machine();
35568 @@ -1592,13 +1598,6 @@ asmlinkage __visible void __init xen_start_kernel(void)
35569
35570 machine_ops = xen_machine_ops;
35571
35572 - /*
35573 - * The only reliable way to retain the initial address of the
35574 - * percpu gdt_page is to remember it here, so we can go and
35575 - * mark it RW later, when the initial percpu area is freed.
35576 - */
35577 - xen_initial_gdt = &per_cpu(gdt_page, 0);
35578 -
35579 xen_smp_init();
35580
35581 #ifdef CONFIG_ACPI_NUMA
35582 diff --git a/arch/x86/xen/mmu.c b/arch/x86/xen/mmu.c
35583 index 86e02ea..e3705ca 100644
35584 --- a/arch/x86/xen/mmu.c
35585 +++ b/arch/x86/xen/mmu.c
35586 @@ -379,7 +379,7 @@ static pteval_t pte_mfn_to_pfn(pteval_t val)
35587 return val;
35588 }
35589
35590 -static pteval_t pte_pfn_to_mfn(pteval_t val)
35591 +static pteval_t __intentional_overflow(-1) pte_pfn_to_mfn(pteval_t val)
35592 {
35593 if (val & _PAGE_PRESENT) {
35594 unsigned long pfn = (val & PTE_PFN_MASK) >> PAGE_SHIFT;
35595 @@ -1904,6 +1904,9 @@ void __init xen_setup_kernel_pagetable(pgd_t *pgd, unsigned long max_pfn)
35596 /* L3_k[510] -> level2_kernel_pgt
35597 * L3_i[511] -> level2_fixmap_pgt */
35598 convert_pfn_mfn(level3_kernel_pgt);
35599 + convert_pfn_mfn(level3_vmalloc_start_pgt);
35600 + convert_pfn_mfn(level3_vmalloc_end_pgt);
35601 + convert_pfn_mfn(level3_vmemmap_pgt);
35602 }
35603 /* We get [511][511] and have Xen's version of level2_kernel_pgt */
35604 l3 = m2v(pgd[pgd_index(__START_KERNEL_map)].pgd);
35605 @@ -1933,8 +1936,12 @@ void __init xen_setup_kernel_pagetable(pgd_t *pgd, unsigned long max_pfn)
35606 set_page_prot(init_level4_pgt, PAGE_KERNEL_RO);
35607 set_page_prot(level3_ident_pgt, PAGE_KERNEL_RO);
35608 set_page_prot(level3_kernel_pgt, PAGE_KERNEL_RO);
35609 + set_page_prot(level3_vmalloc_start_pgt, PAGE_KERNEL_RO);
35610 + set_page_prot(level3_vmalloc_end_pgt, PAGE_KERNEL_RO);
35611 + set_page_prot(level3_vmemmap_pgt, PAGE_KERNEL_RO);
35612 set_page_prot(level3_user_vsyscall, PAGE_KERNEL_RO);
35613 set_page_prot(level2_ident_pgt, PAGE_KERNEL_RO);
35614 + set_page_prot(level2_vmemmap_pgt, PAGE_KERNEL_RO);
35615 set_page_prot(level2_kernel_pgt, PAGE_KERNEL_RO);
35616 set_page_prot(level2_fixmap_pgt, PAGE_KERNEL_RO);
35617
35618 @@ -2122,6 +2129,7 @@ static void __init xen_post_allocator_init(void)
35619 pv_mmu_ops.set_pud = xen_set_pud;
35620 #if PAGETABLE_LEVELS == 4
35621 pv_mmu_ops.set_pgd = xen_set_pgd;
35622 + pv_mmu_ops.set_pgd_batched = xen_set_pgd;
35623 #endif
35624
35625 /* This will work as long as patching hasn't happened yet
35626 @@ -2200,6 +2208,7 @@ static const struct pv_mmu_ops xen_mmu_ops __initconst = {
35627 .pud_val = PV_CALLEE_SAVE(xen_pud_val),
35628 .make_pud = PV_CALLEE_SAVE(xen_make_pud),
35629 .set_pgd = xen_set_pgd_hyper,
35630 + .set_pgd_batched = xen_set_pgd_hyper,
35631
35632 .alloc_pud = xen_alloc_pmd_init,
35633 .release_pud = xen_release_pmd_init,
35634 diff --git a/arch/x86/xen/smp.c b/arch/x86/xen/smp.c
35635 index 7005974..54fb05f 100644
35636 --- a/arch/x86/xen/smp.c
35637 +++ b/arch/x86/xen/smp.c
35638 @@ -283,17 +283,13 @@ static void __init xen_smp_prepare_boot_cpu(void)
35639
35640 if (xen_pv_domain()) {
35641 if (!xen_feature(XENFEAT_writable_page_tables))
35642 - /* We've switched to the "real" per-cpu gdt, so make
35643 - * sure the old memory can be recycled. */
35644 - make_lowmem_page_readwrite(xen_initial_gdt);
35645 -
35646 #ifdef CONFIG_X86_32
35647 /*
35648 * Xen starts us with XEN_FLAT_RING1_DS, but linux code
35649 * expects __USER_DS
35650 */
35651 - loadsegment(ds, __USER_DS);
35652 - loadsegment(es, __USER_DS);
35653 + loadsegment(ds, __KERNEL_DS);
35654 + loadsegment(es, __KERNEL_DS);
35655 #endif
35656
35657 xen_filter_cpu_maps();
35658 @@ -372,7 +368,7 @@ cpu_initialize_context(unsigned int cpu, struct task_struct *idle)
35659 #ifdef CONFIG_X86_32
35660 /* Note: PVH is not yet supported on x86_32. */
35661 ctxt->user_regs.fs = __KERNEL_PERCPU;
35662 - ctxt->user_regs.gs = __KERNEL_STACK_CANARY;
35663 + savesegment(gs, ctxt->user_regs.gs);
35664 #endif
35665 ctxt->user_regs.eip = (unsigned long)cpu_bringup_and_idle;
35666
35667 @@ -381,8 +377,8 @@ cpu_initialize_context(unsigned int cpu, struct task_struct *idle)
35668 if (!xen_feature(XENFEAT_auto_translated_physmap)) {
35669 ctxt->flags = VGCF_IN_KERNEL;
35670 ctxt->user_regs.eflags = 0x1000; /* IOPL_RING1 */
35671 - ctxt->user_regs.ds = __USER_DS;
35672 - ctxt->user_regs.es = __USER_DS;
35673 + ctxt->user_regs.ds = __KERNEL_DS;
35674 + ctxt->user_regs.es = __KERNEL_DS;
35675 ctxt->user_regs.ss = __KERNEL_DS;
35676
35677 xen_copy_trap_info(ctxt->trap_ctxt);
35678 @@ -437,14 +433,13 @@ static int xen_cpu_up(unsigned int cpu, struct task_struct *idle)
35679 int rc;
35680
35681 per_cpu(current_task, cpu) = idle;
35682 + per_cpu(current_tinfo, cpu) = &idle->tinfo;
35683 #ifdef CONFIG_X86_32
35684 irq_ctx_init(cpu);
35685 #else
35686 clear_tsk_thread_flag(idle, TIF_FORK);
35687 #endif
35688 - per_cpu(kernel_stack, cpu) =
35689 - (unsigned long)task_stack_page(idle) -
35690 - KERNEL_STACK_OFFSET + THREAD_SIZE;
35691 + per_cpu(kernel_stack, cpu) = (unsigned long)task_stack_page(idle) - 16 + THREAD_SIZE;
35692
35693 xen_setup_runstate_info(cpu);
35694 xen_setup_timer(cpu);
35695 @@ -720,7 +715,7 @@ static const struct smp_ops xen_smp_ops __initconst = {
35696
35697 void __init xen_smp_init(void)
35698 {
35699 - smp_ops = xen_smp_ops;
35700 + memcpy((void *)&smp_ops, &xen_smp_ops, sizeof smp_ops);
35701 xen_fill_possible_map();
35702 }
35703
35704 diff --git a/arch/x86/xen/xen-asm_32.S b/arch/x86/xen/xen-asm_32.S
35705 index fd92a64..1f72641 100644
35706 --- a/arch/x86/xen/xen-asm_32.S
35707 +++ b/arch/x86/xen/xen-asm_32.S
35708 @@ -99,7 +99,7 @@ ENTRY(xen_iret)
35709 pushw %fs
35710 movl $(__KERNEL_PERCPU), %eax
35711 movl %eax, %fs
35712 - movl %fs:xen_vcpu, %eax
35713 + mov PER_CPU_VAR(xen_vcpu), %eax
35714 POP_FS
35715 #else
35716 movl %ss:xen_vcpu, %eax
35717 diff --git a/arch/x86/xen/xen-head.S b/arch/x86/xen/xen-head.S
35718 index 485b695..fda3e7c 100644
35719 --- a/arch/x86/xen/xen-head.S
35720 +++ b/arch/x86/xen/xen-head.S
35721 @@ -39,6 +39,17 @@ ENTRY(startup_xen)
35722 #ifdef CONFIG_X86_32
35723 mov %esi,xen_start_info
35724 mov $init_thread_union+THREAD_SIZE,%esp
35725 +#ifdef CONFIG_SMP
35726 + movl $cpu_gdt_table,%edi
35727 + movl $__per_cpu_load,%eax
35728 + movw %ax,__KERNEL_PERCPU + 2(%edi)
35729 + rorl $16,%eax
35730 + movb %al,__KERNEL_PERCPU + 4(%edi)
35731 + movb %ah,__KERNEL_PERCPU + 7(%edi)
35732 + movl $__per_cpu_end - 1,%eax
35733 + subl $__per_cpu_start,%eax
35734 + movw %ax,__KERNEL_PERCPU + 0(%edi)
35735 +#endif
35736 #else
35737 mov %rsi,xen_start_info
35738 mov $init_thread_union+THREAD_SIZE,%rsp
35739 diff --git a/arch/x86/xen/xen-ops.h b/arch/x86/xen/xen-ops.h
35740 index 1cb6f4c..9981524 100644
35741 --- a/arch/x86/xen/xen-ops.h
35742 +++ b/arch/x86/xen/xen-ops.h
35743 @@ -10,8 +10,6 @@
35744 extern const char xen_hypervisor_callback[];
35745 extern const char xen_failsafe_callback[];
35746
35747 -extern void *xen_initial_gdt;
35748 -
35749 struct trap_info;
35750 void xen_copy_trap_info(struct trap_info *traps);
35751
35752 diff --git a/arch/xtensa/variants/dc232b/include/variant/core.h b/arch/xtensa/variants/dc232b/include/variant/core.h
35753 index 525bd3d..ef888b1 100644
35754 --- a/arch/xtensa/variants/dc232b/include/variant/core.h
35755 +++ b/arch/xtensa/variants/dc232b/include/variant/core.h
35756 @@ -119,9 +119,9 @@
35757 ----------------------------------------------------------------------*/
35758
35759 #define XCHAL_ICACHE_LINESIZE 32 /* I-cache line size in bytes */
35760 -#define XCHAL_DCACHE_LINESIZE 32 /* D-cache line size in bytes */
35761 #define XCHAL_ICACHE_LINEWIDTH 5 /* log2(I line size in bytes) */
35762 #define XCHAL_DCACHE_LINEWIDTH 5 /* log2(D line size in bytes) */
35763 +#define XCHAL_DCACHE_LINESIZE (_AC(1,UL) << XCHAL_DCACHE_LINEWIDTH) /* D-cache line size in bytes */
35764
35765 #define XCHAL_ICACHE_SIZE 16384 /* I-cache size in bytes or 0 */
35766 #define XCHAL_DCACHE_SIZE 16384 /* D-cache size in bytes or 0 */
35767 diff --git a/arch/xtensa/variants/fsf/include/variant/core.h b/arch/xtensa/variants/fsf/include/variant/core.h
35768 index 2f33760..835e50a 100644
35769 --- a/arch/xtensa/variants/fsf/include/variant/core.h
35770 +++ b/arch/xtensa/variants/fsf/include/variant/core.h
35771 @@ -11,6 +11,7 @@
35772 #ifndef _XTENSA_CORE_H
35773 #define _XTENSA_CORE_H
35774
35775 +#include <linux/const.h>
35776
35777 /****************************************************************************
35778 Parameters Useful for Any Code, USER or PRIVILEGED
35779 @@ -112,9 +113,9 @@
35780 ----------------------------------------------------------------------*/
35781
35782 #define XCHAL_ICACHE_LINESIZE 16 /* I-cache line size in bytes */
35783 -#define XCHAL_DCACHE_LINESIZE 16 /* D-cache line size in bytes */
35784 #define XCHAL_ICACHE_LINEWIDTH 4 /* log2(I line size in bytes) */
35785 #define XCHAL_DCACHE_LINEWIDTH 4 /* log2(D line size in bytes) */
35786 +#define XCHAL_DCACHE_LINESIZE (_AC(1,UL) << XCHAL_DCACHE_LINEWIDTH) /* D-cache line size in bytes */
35787
35788 #define XCHAL_ICACHE_SIZE 8192 /* I-cache size in bytes or 0 */
35789 #define XCHAL_DCACHE_SIZE 8192 /* D-cache size in bytes or 0 */
35790 diff --git a/arch/xtensa/variants/s6000/include/variant/core.h b/arch/xtensa/variants/s6000/include/variant/core.h
35791 index af00795..2bb8105 100644
35792 --- a/arch/xtensa/variants/s6000/include/variant/core.h
35793 +++ b/arch/xtensa/variants/s6000/include/variant/core.h
35794 @@ -11,6 +11,7 @@
35795 #ifndef _XTENSA_CORE_CONFIGURATION_H
35796 #define _XTENSA_CORE_CONFIGURATION_H
35797
35798 +#include <linux/const.h>
35799
35800 /****************************************************************************
35801 Parameters Useful for Any Code, USER or PRIVILEGED
35802 @@ -118,9 +119,9 @@
35803 ----------------------------------------------------------------------*/
35804
35805 #define XCHAL_ICACHE_LINESIZE 16 /* I-cache line size in bytes */
35806 -#define XCHAL_DCACHE_LINESIZE 16 /* D-cache line size in bytes */
35807 #define XCHAL_ICACHE_LINEWIDTH 4 /* log2(I line size in bytes) */
35808 #define XCHAL_DCACHE_LINEWIDTH 4 /* log2(D line size in bytes) */
35809 +#define XCHAL_DCACHE_LINESIZE (_AC(1,UL) << XCHAL_DCACHE_LINEWIDTH) /* D-cache line size in bytes */
35810
35811 #define XCHAL_ICACHE_SIZE 32768 /* I-cache size in bytes or 0 */
35812 #define XCHAL_DCACHE_SIZE 32768 /* D-cache size in bytes or 0 */
35813 diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c
35814 index 1039fb9..d7c0d9a 100644
35815 --- a/block/blk-cgroup.c
35816 +++ b/block/blk-cgroup.c
35817 @@ -825,7 +825,7 @@ static void blkcg_css_free(struct cgroup_subsys_state *css)
35818 static struct cgroup_subsys_state *
35819 blkcg_css_alloc(struct cgroup_subsys_state *parent_css)
35820 {
35821 - static atomic64_t id_seq = ATOMIC64_INIT(0);
35822 + static atomic64_unchecked_t id_seq = ATOMIC64_INIT(0);
35823 struct blkcg *blkcg;
35824
35825 if (!parent_css) {
35826 @@ -839,7 +839,7 @@ blkcg_css_alloc(struct cgroup_subsys_state *parent_css)
35827
35828 blkcg->cfq_weight = CFQ_WEIGHT_DEFAULT;
35829 blkcg->cfq_leaf_weight = CFQ_WEIGHT_DEFAULT;
35830 - blkcg->id = atomic64_inc_return(&id_seq); /* root is 0, start from 1 */
35831 + blkcg->id = atomic64_inc_return_unchecked(&id_seq); /* root is 0, start from 1 */
35832 done:
35833 spin_lock_init(&blkcg->lock);
35834 INIT_RADIX_TREE(&blkcg->blkg_tree, GFP_ATOMIC);
35835 diff --git a/block/blk-iopoll.c b/block/blk-iopoll.c
35836 index c11d24e..e915d24 100644
35837 --- a/block/blk-iopoll.c
35838 +++ b/block/blk-iopoll.c
35839 @@ -74,7 +74,7 @@ void blk_iopoll_complete(struct blk_iopoll *iopoll)
35840 }
35841 EXPORT_SYMBOL(blk_iopoll_complete);
35842
35843 -static void blk_iopoll_softirq(struct softirq_action *h)
35844 +static __latent_entropy void blk_iopoll_softirq(void)
35845 {
35846 struct list_head *list = this_cpu_ptr(&blk_cpu_iopoll);
35847 int rearm = 0, budget = blk_iopoll_budget;
35848 diff --git a/block/blk-map.c b/block/blk-map.c
35849 index f7b22bc..ec2ddf4 100644
35850 --- a/block/blk-map.c
35851 +++ b/block/blk-map.c
35852 @@ -302,7 +302,7 @@ int blk_rq_map_kern(struct request_queue *q, struct request *rq, void *kbuf,
35853 if (!len || !kbuf)
35854 return -EINVAL;
35855
35856 - do_copy = !blk_rq_aligned(q, addr, len) || object_is_on_stack(kbuf);
35857 + do_copy = !blk_rq_aligned(q, addr, len) || object_starts_on_stack(kbuf);
35858 if (do_copy)
35859 bio = bio_copy_kern(q, kbuf, len, gfp_mask, reading);
35860 else
35861 diff --git a/block/blk-softirq.c b/block/blk-softirq.c
35862 index 53b1737..08177d2e 100644
35863 --- a/block/blk-softirq.c
35864 +++ b/block/blk-softirq.c
35865 @@ -18,7 +18,7 @@ static DEFINE_PER_CPU(struct list_head, blk_cpu_done);
35866 * Softirq action handler - move entries to local list and loop over them
35867 * while passing them to the queue registered handler.
35868 */
35869 -static void blk_done_softirq(struct softirq_action *h)
35870 +static __latent_entropy void blk_done_softirq(void)
35871 {
35872 struct list_head *cpu_list, local_list;
35873
35874 diff --git a/block/bsg.c b/block/bsg.c
35875 index 420a5a9..23834aa 100644
35876 --- a/block/bsg.c
35877 +++ b/block/bsg.c
35878 @@ -176,16 +176,24 @@ static int blk_fill_sgv4_hdr_rq(struct request_queue *q, struct request *rq,
35879 struct sg_io_v4 *hdr, struct bsg_device *bd,
35880 fmode_t has_write_perm)
35881 {
35882 + unsigned char tmpcmd[sizeof(rq->__cmd)];
35883 + unsigned char *cmdptr;
35884 +
35885 if (hdr->request_len > BLK_MAX_CDB) {
35886 rq->cmd = kzalloc(hdr->request_len, GFP_KERNEL);
35887 if (!rq->cmd)
35888 return -ENOMEM;
35889 - }
35890 + cmdptr = rq->cmd;
35891 + } else
35892 + cmdptr = tmpcmd;
35893
35894 - if (copy_from_user(rq->cmd, (void __user *)(unsigned long)hdr->request,
35895 + if (copy_from_user(cmdptr, (void __user *)(unsigned long)hdr->request,
35896 hdr->request_len))
35897 return -EFAULT;
35898
35899 + if (cmdptr != rq->cmd)
35900 + memcpy(rq->cmd, cmdptr, hdr->request_len);
35901 +
35902 if (hdr->subprotocol == BSG_SUB_PROTOCOL_SCSI_CMD) {
35903 if (blk_verify_command(rq->cmd, has_write_perm))
35904 return -EPERM;
35905 diff --git a/block/compat_ioctl.c b/block/compat_ioctl.c
35906 index fbd5a67..f24fd95 100644
35907 --- a/block/compat_ioctl.c
35908 +++ b/block/compat_ioctl.c
35909 @@ -156,7 +156,7 @@ static int compat_cdrom_generic_command(struct block_device *bdev, fmode_t mode,
35910 cgc = compat_alloc_user_space(sizeof(*cgc));
35911 cgc32 = compat_ptr(arg);
35912
35913 - if (copy_in_user(&cgc->cmd, &cgc32->cmd, sizeof(cgc->cmd)) ||
35914 + if (copy_in_user(cgc->cmd, cgc32->cmd, sizeof(cgc->cmd)) ||
35915 get_user(data, &cgc32->buffer) ||
35916 put_user(compat_ptr(data), &cgc->buffer) ||
35917 copy_in_user(&cgc->buflen, &cgc32->buflen,
35918 @@ -341,7 +341,7 @@ static int compat_fd_ioctl(struct block_device *bdev, fmode_t mode,
35919 err |= __get_user(f->spec1, &uf->spec1);
35920 err |= __get_user(f->fmt_gap, &uf->fmt_gap);
35921 err |= __get_user(name, &uf->name);
35922 - f->name = compat_ptr(name);
35923 + f->name = (void __force_kernel *)compat_ptr(name);
35924 if (err) {
35925 err = -EFAULT;
35926 goto out;
35927 diff --git a/block/genhd.c b/block/genhd.c
35928 index 791f419..89f21c4 100644
35929 --- a/block/genhd.c
35930 +++ b/block/genhd.c
35931 @@ -467,21 +467,24 @@ static char *bdevt_str(dev_t devt, char *buf)
35932
35933 /*
35934 * Register device numbers dev..(dev+range-1)
35935 - * range must be nonzero
35936 + * Noop if @range is zero.
35937 * The hash chain is sorted on range, so that subranges can override.
35938 */
35939 void blk_register_region(dev_t devt, unsigned long range, struct module *module,
35940 struct kobject *(*probe)(dev_t, int *, void *),
35941 int (*lock)(dev_t, void *), void *data)
35942 {
35943 - kobj_map(bdev_map, devt, range, module, probe, lock, data);
35944 + if (range)
35945 + kobj_map(bdev_map, devt, range, module, probe, lock, data);
35946 }
35947
35948 EXPORT_SYMBOL(blk_register_region);
35949
35950 +/* undo blk_register_region(), noop if @range is zero */
35951 void blk_unregister_region(dev_t devt, unsigned long range)
35952 {
35953 - kobj_unmap(bdev_map, devt, range);
35954 + if (range)
35955 + kobj_unmap(bdev_map, devt, range);
35956 }
35957
35958 EXPORT_SYMBOL(blk_unregister_region);
35959 diff --git a/block/partitions/efi.c b/block/partitions/efi.c
35960 index dc51f46..d5446a8 100644
35961 --- a/block/partitions/efi.c
35962 +++ b/block/partitions/efi.c
35963 @@ -293,14 +293,14 @@ static gpt_entry *alloc_read_gpt_entries(struct parsed_partitions *state,
35964 if (!gpt)
35965 return NULL;
35966
35967 + if (!le32_to_cpu(gpt->num_partition_entries))
35968 + return NULL;
35969 + pte = kcalloc(le32_to_cpu(gpt->num_partition_entries), le32_to_cpu(gpt->sizeof_partition_entry), GFP_KERNEL);
35970 + if (!pte)
35971 + return NULL;
35972 +
35973 count = le32_to_cpu(gpt->num_partition_entries) *
35974 le32_to_cpu(gpt->sizeof_partition_entry);
35975 - if (!count)
35976 - return NULL;
35977 - pte = kmalloc(count, GFP_KERNEL);
35978 - if (!pte)
35979 - return NULL;
35980 -
35981 if (read_lba(state, le64_to_cpu(gpt->partition_entry_lba),
35982 (u8 *) pte, count) < count) {
35983 kfree(pte);
35984 diff --git a/block/scsi_ioctl.c b/block/scsi_ioctl.c
35985 index 2648797..92ed21f 100644
35986 --- a/block/scsi_ioctl.c
35987 +++ b/block/scsi_ioctl.c
35988 @@ -67,7 +67,7 @@ static int scsi_get_bus(struct request_queue *q, int __user *p)
35989 return put_user(0, p);
35990 }
35991
35992 -static int sg_get_timeout(struct request_queue *q)
35993 +static int __intentional_overflow(-1) sg_get_timeout(struct request_queue *q)
35994 {
35995 return jiffies_to_clock_t(q->sg_timeout);
35996 }
35997 @@ -224,8 +224,20 @@ EXPORT_SYMBOL(blk_verify_command);
35998 static int blk_fill_sghdr_rq(struct request_queue *q, struct request *rq,
35999 struct sg_io_hdr *hdr, fmode_t mode)
36000 {
36001 - if (copy_from_user(rq->cmd, hdr->cmdp, hdr->cmd_len))
36002 + unsigned char tmpcmd[sizeof(rq->__cmd)];
36003 + unsigned char *cmdptr;
36004 +
36005 + if (rq->cmd != rq->__cmd)
36006 + cmdptr = rq->cmd;
36007 + else
36008 + cmdptr = tmpcmd;
36009 +
36010 + if (copy_from_user(cmdptr, hdr->cmdp, hdr->cmd_len))
36011 return -EFAULT;
36012 +
36013 + if (cmdptr != rq->cmd)
36014 + memcpy(rq->cmd, cmdptr, hdr->cmd_len);
36015 +
36016 if (blk_verify_command(rq->cmd, mode & FMODE_WRITE))
36017 return -EPERM;
36018
36019 @@ -417,6 +429,8 @@ int sg_scsi_ioctl(struct request_queue *q, struct gendisk *disk, fmode_t mode,
36020 int err;
36021 unsigned int in_len, out_len, bytes, opcode, cmdlen;
36022 char *buffer = NULL, sense[SCSI_SENSE_BUFFERSIZE];
36023 + unsigned char tmpcmd[sizeof(rq->__cmd)];
36024 + unsigned char *cmdptr;
36025
36026 if (!sic)
36027 return -EINVAL;
36028 @@ -450,9 +464,18 @@ int sg_scsi_ioctl(struct request_queue *q, struct gendisk *disk, fmode_t mode,
36029 */
36030 err = -EFAULT;
36031 rq->cmd_len = cmdlen;
36032 - if (copy_from_user(rq->cmd, sic->data, cmdlen))
36033 +
36034 + if (rq->cmd != rq->__cmd)
36035 + cmdptr = rq->cmd;
36036 + else
36037 + cmdptr = tmpcmd;
36038 +
36039 + if (copy_from_user(cmdptr, sic->data, cmdlen))
36040 goto error;
36041
36042 + if (rq->cmd != cmdptr)
36043 + memcpy(rq->cmd, cmdptr, cmdlen);
36044 +
36045 if (in_len && copy_from_user(buffer, sic->data + cmdlen, in_len))
36046 goto error;
36047
36048 diff --git a/crypto/cryptd.c b/crypto/cryptd.c
36049 index 7bdd61b..afec999 100644
36050 --- a/crypto/cryptd.c
36051 +++ b/crypto/cryptd.c
36052 @@ -63,7 +63,7 @@ struct cryptd_blkcipher_ctx {
36053
36054 struct cryptd_blkcipher_request_ctx {
36055 crypto_completion_t complete;
36056 -};
36057 +} __no_const;
36058
36059 struct cryptd_hash_ctx {
36060 struct crypto_shash *child;
36061 @@ -80,7 +80,7 @@ struct cryptd_aead_ctx {
36062
36063 struct cryptd_aead_request_ctx {
36064 crypto_completion_t complete;
36065 -};
36066 +} __no_const;
36067
36068 static void cryptd_queue_worker(struct work_struct *work);
36069
36070 diff --git a/crypto/pcrypt.c b/crypto/pcrypt.c
36071 index 309d345..1632720 100644
36072 --- a/crypto/pcrypt.c
36073 +++ b/crypto/pcrypt.c
36074 @@ -440,7 +440,7 @@ static int pcrypt_sysfs_add(struct padata_instance *pinst, const char *name)
36075 int ret;
36076
36077 pinst->kobj.kset = pcrypt_kset;
36078 - ret = kobject_add(&pinst->kobj, NULL, name);
36079 + ret = kobject_add(&pinst->kobj, NULL, "%s", name);
36080 if (!ret)
36081 kobject_uevent(&pinst->kobj, KOBJ_ADD);
36082
36083 diff --git a/drivers/acpi/acpica/hwxfsleep.c b/drivers/acpi/acpica/hwxfsleep.c
36084 index 6921c7f..78e1af7 100644
36085 --- a/drivers/acpi/acpica/hwxfsleep.c
36086 +++ b/drivers/acpi/acpica/hwxfsleep.c
36087 @@ -63,11 +63,12 @@ static acpi_status acpi_hw_sleep_dispatch(u8 sleep_state, u32 function_id);
36088 /* Legacy functions are optional, based upon ACPI_REDUCED_HARDWARE */
36089
36090 static struct acpi_sleep_functions acpi_sleep_dispatch[] = {
36091 - {ACPI_HW_OPTIONAL_FUNCTION(acpi_hw_legacy_sleep),
36092 - acpi_hw_extended_sleep},
36093 - {ACPI_HW_OPTIONAL_FUNCTION(acpi_hw_legacy_wake_prep),
36094 - acpi_hw_extended_wake_prep},
36095 - {ACPI_HW_OPTIONAL_FUNCTION(acpi_hw_legacy_wake), acpi_hw_extended_wake}
36096 + {.legacy_function = ACPI_HW_OPTIONAL_FUNCTION(acpi_hw_legacy_sleep),
36097 + .extended_function = acpi_hw_extended_sleep},
36098 + {.legacy_function = ACPI_HW_OPTIONAL_FUNCTION(acpi_hw_legacy_wake_prep),
36099 + .extended_function = acpi_hw_extended_wake_prep},
36100 + {.legacy_function = ACPI_HW_OPTIONAL_FUNCTION(acpi_hw_legacy_wake),
36101 + .extended_function = acpi_hw_extended_wake}
36102 };
36103
36104 /*
36105 diff --git a/drivers/acpi/apei/apei-internal.h b/drivers/acpi/apei/apei-internal.h
36106 index e5bcd91..74f050d 100644
36107 --- a/drivers/acpi/apei/apei-internal.h
36108 +++ b/drivers/acpi/apei/apei-internal.h
36109 @@ -19,7 +19,7 @@ typedef int (*apei_exec_ins_func_t)(struct apei_exec_context *ctx,
36110 struct apei_exec_ins_type {
36111 u32 flags;
36112 apei_exec_ins_func_t run;
36113 -};
36114 +} __do_const;
36115
36116 struct apei_exec_context {
36117 u32 ip;
36118 diff --git a/drivers/acpi/apei/ghes.c b/drivers/acpi/apei/ghes.c
36119 index dab7cb7..f0d2994 100644
36120 --- a/drivers/acpi/apei/ghes.c
36121 +++ b/drivers/acpi/apei/ghes.c
36122 @@ -500,7 +500,7 @@ static void __ghes_print_estatus(const char *pfx,
36123 const struct acpi_hest_generic *generic,
36124 const struct acpi_generic_status *estatus)
36125 {
36126 - static atomic_t seqno;
36127 + static atomic_unchecked_t seqno;
36128 unsigned int curr_seqno;
36129 char pfx_seq[64];
36130
36131 @@ -511,7 +511,7 @@ static void __ghes_print_estatus(const char *pfx,
36132 else
36133 pfx = KERN_ERR;
36134 }
36135 - curr_seqno = atomic_inc_return(&seqno);
36136 + curr_seqno = atomic_inc_return_unchecked(&seqno);
36137 snprintf(pfx_seq, sizeof(pfx_seq), "%s{%u}" HW_ERR, pfx, curr_seqno);
36138 printk("%s""Hardware error from APEI Generic Hardware Error Source: %d\n",
36139 pfx_seq, generic->header.source_id);
36140 diff --git a/drivers/acpi/bgrt.c b/drivers/acpi/bgrt.c
36141 index a83e3c6..c3d617f 100644
36142 --- a/drivers/acpi/bgrt.c
36143 +++ b/drivers/acpi/bgrt.c
36144 @@ -86,8 +86,10 @@ static int __init bgrt_init(void)
36145 if (!bgrt_image)
36146 return -ENODEV;
36147
36148 - bin_attr_image.private = bgrt_image;
36149 - bin_attr_image.size = bgrt_image_size;
36150 + pax_open_kernel();
36151 + *(void **)&bin_attr_image.private = bgrt_image;
36152 + *(size_t *)&bin_attr_image.size = bgrt_image_size;
36153 + pax_close_kernel();
36154
36155 bgrt_kobj = kobject_create_and_add("bgrt", acpi_kobj);
36156 if (!bgrt_kobj)
36157 diff --git a/drivers/acpi/blacklist.c b/drivers/acpi/blacklist.c
36158 index 3d8413d..95f638c 100644
36159 --- a/drivers/acpi/blacklist.c
36160 +++ b/drivers/acpi/blacklist.c
36161 @@ -51,7 +51,7 @@ struct acpi_blacklist_item {
36162 u32 is_critical_error;
36163 };
36164
36165 -static struct dmi_system_id acpi_osi_dmi_table[] __initdata;
36166 +static const struct dmi_system_id acpi_osi_dmi_table[] __initconst;
36167
36168 /*
36169 * POLICY: If *anything* doesn't work, put it on the blacklist.
36170 @@ -163,7 +163,7 @@ static int __init dmi_disable_osi_win8(const struct dmi_system_id *d)
36171 return 0;
36172 }
36173
36174 -static struct dmi_system_id acpi_osi_dmi_table[] __initdata = {
36175 +static const struct dmi_system_id acpi_osi_dmi_table[] __initconst = {
36176 {
36177 .callback = dmi_disable_osi_vista,
36178 .ident = "Fujitsu Siemens",
36179 diff --git a/drivers/acpi/custom_method.c b/drivers/acpi/custom_method.c
36180 index c68e724..e863008 100644
36181 --- a/drivers/acpi/custom_method.c
36182 +++ b/drivers/acpi/custom_method.c
36183 @@ -29,6 +29,10 @@ static ssize_t cm_write(struct file *file, const char __user * user_buf,
36184 struct acpi_table_header table;
36185 acpi_status status;
36186
36187 +#ifdef CONFIG_GRKERNSEC_KMEM
36188 + return -EPERM;
36189 +#endif
36190 +
36191 if (!(*ppos)) {
36192 /* parse the table header to get the table length */
36193 if (count <= sizeof(struct acpi_table_header))
36194 diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c
36195 index 3dca36d..abaf070 100644
36196 --- a/drivers/acpi/processor_idle.c
36197 +++ b/drivers/acpi/processor_idle.c
36198 @@ -952,7 +952,7 @@ static int acpi_processor_setup_cpuidle_states(struct acpi_processor *pr)
36199 {
36200 int i, count = CPUIDLE_DRIVER_STATE_START;
36201 struct acpi_processor_cx *cx;
36202 - struct cpuidle_state *state;
36203 + cpuidle_state_no_const *state;
36204 struct cpuidle_driver *drv = &acpi_idle_driver;
36205
36206 if (!pr->flags.power_setup_done)
36207 diff --git a/drivers/acpi/sysfs.c b/drivers/acpi/sysfs.c
36208 index 38cb978..352c761 100644
36209 --- a/drivers/acpi/sysfs.c
36210 +++ b/drivers/acpi/sysfs.c
36211 @@ -423,11 +423,11 @@ static u32 num_counters;
36212 static struct attribute **all_attrs;
36213 static u32 acpi_gpe_count;
36214
36215 -static struct attribute_group interrupt_stats_attr_group = {
36216 +static attribute_group_no_const interrupt_stats_attr_group = {
36217 .name = "interrupts",
36218 };
36219
36220 -static struct kobj_attribute *counter_attrs;
36221 +static kobj_attribute_no_const *counter_attrs;
36222
36223 static void delete_gpe_attr_array(void)
36224 {
36225 diff --git a/drivers/ata/libahci.c b/drivers/ata/libahci.c
36226 index b986145..82bddb8 100644
36227 --- a/drivers/ata/libahci.c
36228 +++ b/drivers/ata/libahci.c
36229 @@ -1252,7 +1252,7 @@ int ahci_kick_engine(struct ata_port *ap)
36230 }
36231 EXPORT_SYMBOL_GPL(ahci_kick_engine);
36232
36233 -static int ahci_exec_polled_cmd(struct ata_port *ap, int pmp,
36234 +static int __intentional_overflow(-1) ahci_exec_polled_cmd(struct ata_port *ap, int pmp,
36235 struct ata_taskfile *tf, int is_cmd, u16 flags,
36236 unsigned long timeout_msec)
36237 {
36238 diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
36239 index 18d97d5..be690af 100644
36240 --- a/drivers/ata/libata-core.c
36241 +++ b/drivers/ata/libata-core.c
36242 @@ -98,7 +98,7 @@ static unsigned int ata_dev_set_xfermode(struct ata_device *dev);
36243 static void ata_dev_xfermask(struct ata_device *dev);
36244 static unsigned long ata_dev_blacklisted(const struct ata_device *dev);
36245
36246 -atomic_t ata_print_id = ATOMIC_INIT(0);
36247 +atomic_unchecked_t ata_print_id = ATOMIC_INIT(0);
36248
36249 struct ata_force_param {
36250 const char *name;
36251 @@ -4858,7 +4858,7 @@ void ata_qc_free(struct ata_queued_cmd *qc)
36252 struct ata_port *ap;
36253 unsigned int tag;
36254
36255 - WARN_ON_ONCE(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
36256 + BUG_ON(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
36257 ap = qc->ap;
36258
36259 qc->flags = 0;
36260 @@ -4874,7 +4874,7 @@ void __ata_qc_complete(struct ata_queued_cmd *qc)
36261 struct ata_port *ap;
36262 struct ata_link *link;
36263
36264 - WARN_ON_ONCE(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
36265 + BUG_ON(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
36266 WARN_ON_ONCE(!(qc->flags & ATA_QCFLAG_ACTIVE));
36267 ap = qc->ap;
36268 link = qc->dev->link;
36269 @@ -5978,6 +5978,7 @@ static void ata_finalize_port_ops(struct ata_port_operations *ops)
36270 return;
36271
36272 spin_lock(&lock);
36273 + pax_open_kernel();
36274
36275 for (cur = ops->inherits; cur; cur = cur->inherits) {
36276 void **inherit = (void **)cur;
36277 @@ -5991,8 +5992,9 @@ static void ata_finalize_port_ops(struct ata_port_operations *ops)
36278 if (IS_ERR(*pp))
36279 *pp = NULL;
36280
36281 - ops->inherits = NULL;
36282 + *(struct ata_port_operations **)&ops->inherits = NULL;
36283
36284 + pax_close_kernel();
36285 spin_unlock(&lock);
36286 }
36287
36288 @@ -6185,7 +6187,7 @@ int ata_host_register(struct ata_host *host, struct scsi_host_template *sht)
36289
36290 /* give ports names and add SCSI hosts */
36291 for (i = 0; i < host->n_ports; i++) {
36292 - host->ports[i]->print_id = atomic_inc_return(&ata_print_id);
36293 + host->ports[i]->print_id = atomic_inc_return_unchecked(&ata_print_id);
36294 host->ports[i]->local_port_no = i + 1;
36295 }
36296
36297 diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
36298 index ef8567d..8bdbd03 100644
36299 --- a/drivers/ata/libata-scsi.c
36300 +++ b/drivers/ata/libata-scsi.c
36301 @@ -4147,7 +4147,7 @@ int ata_sas_port_init(struct ata_port *ap)
36302
36303 if (rc)
36304 return rc;
36305 - ap->print_id = atomic_inc_return(&ata_print_id);
36306 + ap->print_id = atomic_inc_return_unchecked(&ata_print_id);
36307 return 0;
36308 }
36309 EXPORT_SYMBOL_GPL(ata_sas_port_init);
36310 diff --git a/drivers/ata/libata.h b/drivers/ata/libata.h
36311 index 45b5ab3..98446b8 100644
36312 --- a/drivers/ata/libata.h
36313 +++ b/drivers/ata/libata.h
36314 @@ -53,7 +53,7 @@ enum {
36315 ATA_DNXFER_QUIET = (1 << 31),
36316 };
36317
36318 -extern atomic_t ata_print_id;
36319 +extern atomic_unchecked_t ata_print_id;
36320 extern int atapi_passthru16;
36321 extern int libata_fua;
36322 extern int libata_noacpi;
36323 diff --git a/drivers/ata/pata_arasan_cf.c b/drivers/ata/pata_arasan_cf.c
36324 index 4edb1a8..84e1658 100644
36325 --- a/drivers/ata/pata_arasan_cf.c
36326 +++ b/drivers/ata/pata_arasan_cf.c
36327 @@ -865,7 +865,9 @@ static int arasan_cf_probe(struct platform_device *pdev)
36328 /* Handle platform specific quirks */
36329 if (quirk) {
36330 if (quirk & CF_BROKEN_PIO) {
36331 - ap->ops->set_piomode = NULL;
36332 + pax_open_kernel();
36333 + *(void **)&ap->ops->set_piomode = NULL;
36334 + pax_close_kernel();
36335 ap->pio_mask = 0;
36336 }
36337 if (quirk & CF_BROKEN_MWDMA)
36338 diff --git a/drivers/atm/adummy.c b/drivers/atm/adummy.c
36339 index f9b983a..887b9d8 100644
36340 --- a/drivers/atm/adummy.c
36341 +++ b/drivers/atm/adummy.c
36342 @@ -114,7 +114,7 @@ adummy_send(struct atm_vcc *vcc, struct sk_buff *skb)
36343 vcc->pop(vcc, skb);
36344 else
36345 dev_kfree_skb_any(skb);
36346 - atomic_inc(&vcc->stats->tx);
36347 + atomic_inc_unchecked(&vcc->stats->tx);
36348
36349 return 0;
36350 }
36351 diff --git a/drivers/atm/ambassador.c b/drivers/atm/ambassador.c
36352 index f1a9198..f466a4a 100644
36353 --- a/drivers/atm/ambassador.c
36354 +++ b/drivers/atm/ambassador.c
36355 @@ -454,7 +454,7 @@ static void tx_complete (amb_dev * dev, tx_out * tx) {
36356 PRINTD (DBG_FLOW|DBG_TX, "tx_complete %p %p", dev, tx);
36357
36358 // VC layer stats
36359 - atomic_inc(&ATM_SKB(skb)->vcc->stats->tx);
36360 + atomic_inc_unchecked(&ATM_SKB(skb)->vcc->stats->tx);
36361
36362 // free the descriptor
36363 kfree (tx_descr);
36364 @@ -495,7 +495,7 @@ static void rx_complete (amb_dev * dev, rx_out * rx) {
36365 dump_skb ("<<<", vc, skb);
36366
36367 // VC layer stats
36368 - atomic_inc(&atm_vcc->stats->rx);
36369 + atomic_inc_unchecked(&atm_vcc->stats->rx);
36370 __net_timestamp(skb);
36371 // end of our responsibility
36372 atm_vcc->push (atm_vcc, skb);
36373 @@ -510,7 +510,7 @@ static void rx_complete (amb_dev * dev, rx_out * rx) {
36374 } else {
36375 PRINTK (KERN_INFO, "dropped over-size frame");
36376 // should we count this?
36377 - atomic_inc(&atm_vcc->stats->rx_drop);
36378 + atomic_inc_unchecked(&atm_vcc->stats->rx_drop);
36379 }
36380
36381 } else {
36382 @@ -1338,7 +1338,7 @@ static int amb_send (struct atm_vcc * atm_vcc, struct sk_buff * skb) {
36383 }
36384
36385 if (check_area (skb->data, skb->len)) {
36386 - atomic_inc(&atm_vcc->stats->tx_err);
36387 + atomic_inc_unchecked(&atm_vcc->stats->tx_err);
36388 return -ENOMEM; // ?
36389 }
36390
36391 diff --git a/drivers/atm/atmtcp.c b/drivers/atm/atmtcp.c
36392 index 0e3f8f9..765a7a5 100644
36393 --- a/drivers/atm/atmtcp.c
36394 +++ b/drivers/atm/atmtcp.c
36395 @@ -206,7 +206,7 @@ static int atmtcp_v_send(struct atm_vcc *vcc,struct sk_buff *skb)
36396 if (vcc->pop) vcc->pop(vcc,skb);
36397 else dev_kfree_skb(skb);
36398 if (dev_data) return 0;
36399 - atomic_inc(&vcc->stats->tx_err);
36400 + atomic_inc_unchecked(&vcc->stats->tx_err);
36401 return -ENOLINK;
36402 }
36403 size = skb->len+sizeof(struct atmtcp_hdr);
36404 @@ -214,7 +214,7 @@ static int atmtcp_v_send(struct atm_vcc *vcc,struct sk_buff *skb)
36405 if (!new_skb) {
36406 if (vcc->pop) vcc->pop(vcc,skb);
36407 else dev_kfree_skb(skb);
36408 - atomic_inc(&vcc->stats->tx_err);
36409 + atomic_inc_unchecked(&vcc->stats->tx_err);
36410 return -ENOBUFS;
36411 }
36412 hdr = (void *) skb_put(new_skb,sizeof(struct atmtcp_hdr));
36413 @@ -225,8 +225,8 @@ static int atmtcp_v_send(struct atm_vcc *vcc,struct sk_buff *skb)
36414 if (vcc->pop) vcc->pop(vcc,skb);
36415 else dev_kfree_skb(skb);
36416 out_vcc->push(out_vcc,new_skb);
36417 - atomic_inc(&vcc->stats->tx);
36418 - atomic_inc(&out_vcc->stats->rx);
36419 + atomic_inc_unchecked(&vcc->stats->tx);
36420 + atomic_inc_unchecked(&out_vcc->stats->rx);
36421 return 0;
36422 }
36423
36424 @@ -299,7 +299,7 @@ static int atmtcp_c_send(struct atm_vcc *vcc,struct sk_buff *skb)
36425 out_vcc = find_vcc(dev, ntohs(hdr->vpi), ntohs(hdr->vci));
36426 read_unlock(&vcc_sklist_lock);
36427 if (!out_vcc) {
36428 - atomic_inc(&vcc->stats->tx_err);
36429 + atomic_inc_unchecked(&vcc->stats->tx_err);
36430 goto done;
36431 }
36432 skb_pull(skb,sizeof(struct atmtcp_hdr));
36433 @@ -311,8 +311,8 @@ static int atmtcp_c_send(struct atm_vcc *vcc,struct sk_buff *skb)
36434 __net_timestamp(new_skb);
36435 skb_copy_from_linear_data(skb, skb_put(new_skb, skb->len), skb->len);
36436 out_vcc->push(out_vcc,new_skb);
36437 - atomic_inc(&vcc->stats->tx);
36438 - atomic_inc(&out_vcc->stats->rx);
36439 + atomic_inc_unchecked(&vcc->stats->tx);
36440 + atomic_inc_unchecked(&out_vcc->stats->rx);
36441 done:
36442 if (vcc->pop) vcc->pop(vcc,skb);
36443 else dev_kfree_skb(skb);
36444 diff --git a/drivers/atm/eni.c b/drivers/atm/eni.c
36445 index b1955ba..b179940 100644
36446 --- a/drivers/atm/eni.c
36447 +++ b/drivers/atm/eni.c
36448 @@ -522,7 +522,7 @@ static int rx_aal0(struct atm_vcc *vcc)
36449 DPRINTK(DEV_LABEL "(itf %d): trashing empty cell\n",
36450 vcc->dev->number);
36451 length = 0;
36452 - atomic_inc(&vcc->stats->rx_err);
36453 + atomic_inc_unchecked(&vcc->stats->rx_err);
36454 }
36455 else {
36456 length = ATM_CELL_SIZE-1; /* no HEC */
36457 @@ -577,7 +577,7 @@ static int rx_aal5(struct atm_vcc *vcc)
36458 size);
36459 }
36460 eff = length = 0;
36461 - atomic_inc(&vcc->stats->rx_err);
36462 + atomic_inc_unchecked(&vcc->stats->rx_err);
36463 }
36464 else {
36465 size = (descr & MID_RED_COUNT)*(ATM_CELL_PAYLOAD >> 2);
36466 @@ -594,7 +594,7 @@ static int rx_aal5(struct atm_vcc *vcc)
36467 "(VCI=%d,length=%ld,size=%ld (descr 0x%lx))\n",
36468 vcc->dev->number,vcc->vci,length,size << 2,descr);
36469 length = eff = 0;
36470 - atomic_inc(&vcc->stats->rx_err);
36471 + atomic_inc_unchecked(&vcc->stats->rx_err);
36472 }
36473 }
36474 skb = eff ? atm_alloc_charge(vcc,eff << 2,GFP_ATOMIC) : NULL;
36475 @@ -767,7 +767,7 @@ rx_dequeued++;
36476 vcc->push(vcc,skb);
36477 pushed++;
36478 }
36479 - atomic_inc(&vcc->stats->rx);
36480 + atomic_inc_unchecked(&vcc->stats->rx);
36481 }
36482 wake_up(&eni_dev->rx_wait);
36483 }
36484 @@ -1227,7 +1227,7 @@ static void dequeue_tx(struct atm_dev *dev)
36485 PCI_DMA_TODEVICE);
36486 if (vcc->pop) vcc->pop(vcc,skb);
36487 else dev_kfree_skb_irq(skb);
36488 - atomic_inc(&vcc->stats->tx);
36489 + atomic_inc_unchecked(&vcc->stats->tx);
36490 wake_up(&eni_dev->tx_wait);
36491 dma_complete++;
36492 }
36493 diff --git a/drivers/atm/firestream.c b/drivers/atm/firestream.c
36494 index 82f2ae0..f205c02 100644
36495 --- a/drivers/atm/firestream.c
36496 +++ b/drivers/atm/firestream.c
36497 @@ -749,7 +749,7 @@ static void process_txdone_queue (struct fs_dev *dev, struct queue *q)
36498 }
36499 }
36500
36501 - atomic_inc(&ATM_SKB(skb)->vcc->stats->tx);
36502 + atomic_inc_unchecked(&ATM_SKB(skb)->vcc->stats->tx);
36503
36504 fs_dprintk (FS_DEBUG_TXMEM, "i");
36505 fs_dprintk (FS_DEBUG_ALLOC, "Free t-skb: %p\n", skb);
36506 @@ -816,7 +816,7 @@ static void process_incoming (struct fs_dev *dev, struct queue *q)
36507 #endif
36508 skb_put (skb, qe->p1 & 0xffff);
36509 ATM_SKB(skb)->vcc = atm_vcc;
36510 - atomic_inc(&atm_vcc->stats->rx);
36511 + atomic_inc_unchecked(&atm_vcc->stats->rx);
36512 __net_timestamp(skb);
36513 fs_dprintk (FS_DEBUG_ALLOC, "Free rec-skb: %p (pushed)\n", skb);
36514 atm_vcc->push (atm_vcc, skb);
36515 @@ -837,12 +837,12 @@ static void process_incoming (struct fs_dev *dev, struct queue *q)
36516 kfree (pe);
36517 }
36518 if (atm_vcc)
36519 - atomic_inc(&atm_vcc->stats->rx_drop);
36520 + atomic_inc_unchecked(&atm_vcc->stats->rx_drop);
36521 break;
36522 case 0x1f: /* Reassembly abort: no buffers. */
36523 /* Silently increment error counter. */
36524 if (atm_vcc)
36525 - atomic_inc(&atm_vcc->stats->rx_drop);
36526 + atomic_inc_unchecked(&atm_vcc->stats->rx_drop);
36527 break;
36528 default: /* Hmm. Haven't written the code to handle the others yet... -- REW */
36529 printk (KERN_WARNING "Don't know what to do with RX status %x: %s.\n",
36530 diff --git a/drivers/atm/fore200e.c b/drivers/atm/fore200e.c
36531 index 204814e..cede831 100644
36532 --- a/drivers/atm/fore200e.c
36533 +++ b/drivers/atm/fore200e.c
36534 @@ -931,9 +931,9 @@ fore200e_tx_irq(struct fore200e* fore200e)
36535 #endif
36536 /* check error condition */
36537 if (*entry->status & STATUS_ERROR)
36538 - atomic_inc(&vcc->stats->tx_err);
36539 + atomic_inc_unchecked(&vcc->stats->tx_err);
36540 else
36541 - atomic_inc(&vcc->stats->tx);
36542 + atomic_inc_unchecked(&vcc->stats->tx);
36543 }
36544 }
36545
36546 @@ -1082,7 +1082,7 @@ fore200e_push_rpd(struct fore200e* fore200e, struct atm_vcc* vcc, struct rpd* rp
36547 if (skb == NULL) {
36548 DPRINTK(2, "unable to alloc new skb, rx PDU length = %d\n", pdu_len);
36549
36550 - atomic_inc(&vcc->stats->rx_drop);
36551 + atomic_inc_unchecked(&vcc->stats->rx_drop);
36552 return -ENOMEM;
36553 }
36554
36555 @@ -1125,14 +1125,14 @@ fore200e_push_rpd(struct fore200e* fore200e, struct atm_vcc* vcc, struct rpd* rp
36556
36557 dev_kfree_skb_any(skb);
36558
36559 - atomic_inc(&vcc->stats->rx_drop);
36560 + atomic_inc_unchecked(&vcc->stats->rx_drop);
36561 return -ENOMEM;
36562 }
36563
36564 ASSERT(atomic_read(&sk_atm(vcc)->sk_wmem_alloc) >= 0);
36565
36566 vcc->push(vcc, skb);
36567 - atomic_inc(&vcc->stats->rx);
36568 + atomic_inc_unchecked(&vcc->stats->rx);
36569
36570 ASSERT(atomic_read(&sk_atm(vcc)->sk_wmem_alloc) >= 0);
36571
36572 @@ -1210,7 +1210,7 @@ fore200e_rx_irq(struct fore200e* fore200e)
36573 DPRINTK(2, "damaged PDU on %d.%d.%d\n",
36574 fore200e->atm_dev->number,
36575 entry->rpd->atm_header.vpi, entry->rpd->atm_header.vci);
36576 - atomic_inc(&vcc->stats->rx_err);
36577 + atomic_inc_unchecked(&vcc->stats->rx_err);
36578 }
36579 }
36580
36581 @@ -1655,7 +1655,7 @@ fore200e_send(struct atm_vcc *vcc, struct sk_buff *skb)
36582 goto retry_here;
36583 }
36584
36585 - atomic_inc(&vcc->stats->tx_err);
36586 + atomic_inc_unchecked(&vcc->stats->tx_err);
36587
36588 fore200e->tx_sat++;
36589 DPRINTK(2, "tx queue of device %s is saturated, PDU dropped - heartbeat is %08x\n",
36590 diff --git a/drivers/atm/he.c b/drivers/atm/he.c
36591 index aa6be26..f70a785 100644
36592 --- a/drivers/atm/he.c
36593 +++ b/drivers/atm/he.c
36594 @@ -1690,7 +1690,7 @@ he_service_rbrq(struct he_dev *he_dev, int group)
36595
36596 if (RBRQ_HBUF_ERR(he_dev->rbrq_head)) {
36597 hprintk("HBUF_ERR! (cid 0x%x)\n", cid);
36598 - atomic_inc(&vcc->stats->rx_drop);
36599 + atomic_inc_unchecked(&vcc->stats->rx_drop);
36600 goto return_host_buffers;
36601 }
36602
36603 @@ -1717,7 +1717,7 @@ he_service_rbrq(struct he_dev *he_dev, int group)
36604 RBRQ_LEN_ERR(he_dev->rbrq_head)
36605 ? "LEN_ERR" : "",
36606 vcc->vpi, vcc->vci);
36607 - atomic_inc(&vcc->stats->rx_err);
36608 + atomic_inc_unchecked(&vcc->stats->rx_err);
36609 goto return_host_buffers;
36610 }
36611
36612 @@ -1769,7 +1769,7 @@ he_service_rbrq(struct he_dev *he_dev, int group)
36613 vcc->push(vcc, skb);
36614 spin_lock(&he_dev->global_lock);
36615
36616 - atomic_inc(&vcc->stats->rx);
36617 + atomic_inc_unchecked(&vcc->stats->rx);
36618
36619 return_host_buffers:
36620 ++pdus_assembled;
36621 @@ -2095,7 +2095,7 @@ __enqueue_tpd(struct he_dev *he_dev, struct he_tpd *tpd, unsigned cid)
36622 tpd->vcc->pop(tpd->vcc, tpd->skb);
36623 else
36624 dev_kfree_skb_any(tpd->skb);
36625 - atomic_inc(&tpd->vcc->stats->tx_err);
36626 + atomic_inc_unchecked(&tpd->vcc->stats->tx_err);
36627 }
36628 pci_pool_free(he_dev->tpd_pool, tpd, TPD_ADDR(tpd->status));
36629 return;
36630 @@ -2507,7 +2507,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
36631 vcc->pop(vcc, skb);
36632 else
36633 dev_kfree_skb_any(skb);
36634 - atomic_inc(&vcc->stats->tx_err);
36635 + atomic_inc_unchecked(&vcc->stats->tx_err);
36636 return -EINVAL;
36637 }
36638
36639 @@ -2518,7 +2518,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
36640 vcc->pop(vcc, skb);
36641 else
36642 dev_kfree_skb_any(skb);
36643 - atomic_inc(&vcc->stats->tx_err);
36644 + atomic_inc_unchecked(&vcc->stats->tx_err);
36645 return -EINVAL;
36646 }
36647 #endif
36648 @@ -2530,7 +2530,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
36649 vcc->pop(vcc, skb);
36650 else
36651 dev_kfree_skb_any(skb);
36652 - atomic_inc(&vcc->stats->tx_err);
36653 + atomic_inc_unchecked(&vcc->stats->tx_err);
36654 spin_unlock_irqrestore(&he_dev->global_lock, flags);
36655 return -ENOMEM;
36656 }
36657 @@ -2572,7 +2572,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
36658 vcc->pop(vcc, skb);
36659 else
36660 dev_kfree_skb_any(skb);
36661 - atomic_inc(&vcc->stats->tx_err);
36662 + atomic_inc_unchecked(&vcc->stats->tx_err);
36663 spin_unlock_irqrestore(&he_dev->global_lock, flags);
36664 return -ENOMEM;
36665 }
36666 @@ -2603,7 +2603,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
36667 __enqueue_tpd(he_dev, tpd, cid);
36668 spin_unlock_irqrestore(&he_dev->global_lock, flags);
36669
36670 - atomic_inc(&vcc->stats->tx);
36671 + atomic_inc_unchecked(&vcc->stats->tx);
36672
36673 return 0;
36674 }
36675 diff --git a/drivers/atm/horizon.c b/drivers/atm/horizon.c
36676 index 1dc0519..1aadaf7 100644
36677 --- a/drivers/atm/horizon.c
36678 +++ b/drivers/atm/horizon.c
36679 @@ -1034,7 +1034,7 @@ static void rx_schedule (hrz_dev * dev, int irq) {
36680 {
36681 struct atm_vcc * vcc = ATM_SKB(skb)->vcc;
36682 // VC layer stats
36683 - atomic_inc(&vcc->stats->rx);
36684 + atomic_inc_unchecked(&vcc->stats->rx);
36685 __net_timestamp(skb);
36686 // end of our responsibility
36687 vcc->push (vcc, skb);
36688 @@ -1186,7 +1186,7 @@ static void tx_schedule (hrz_dev * const dev, int irq) {
36689 dev->tx_iovec = NULL;
36690
36691 // VC layer stats
36692 - atomic_inc(&ATM_SKB(skb)->vcc->stats->tx);
36693 + atomic_inc_unchecked(&ATM_SKB(skb)->vcc->stats->tx);
36694
36695 // free the skb
36696 hrz_kfree_skb (skb);
36697 diff --git a/drivers/atm/idt77252.c b/drivers/atm/idt77252.c
36698 index 1bdf104..9dc44b1 100644
36699 --- a/drivers/atm/idt77252.c
36700 +++ b/drivers/atm/idt77252.c
36701 @@ -812,7 +812,7 @@ drain_scq(struct idt77252_dev *card, struct vc_map *vc)
36702 else
36703 dev_kfree_skb(skb);
36704
36705 - atomic_inc(&vcc->stats->tx);
36706 + atomic_inc_unchecked(&vcc->stats->tx);
36707 }
36708
36709 atomic_dec(&scq->used);
36710 @@ -1075,13 +1075,13 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
36711 if ((sb = dev_alloc_skb(64)) == NULL) {
36712 printk("%s: Can't allocate buffers for aal0.\n",
36713 card->name);
36714 - atomic_add(i, &vcc->stats->rx_drop);
36715 + atomic_add_unchecked(i, &vcc->stats->rx_drop);
36716 break;
36717 }
36718 if (!atm_charge(vcc, sb->truesize)) {
36719 RXPRINTK("%s: atm_charge() dropped aal0 packets.\n",
36720 card->name);
36721 - atomic_add(i - 1, &vcc->stats->rx_drop);
36722 + atomic_add_unchecked(i - 1, &vcc->stats->rx_drop);
36723 dev_kfree_skb(sb);
36724 break;
36725 }
36726 @@ -1098,7 +1098,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
36727 ATM_SKB(sb)->vcc = vcc;
36728 __net_timestamp(sb);
36729 vcc->push(vcc, sb);
36730 - atomic_inc(&vcc->stats->rx);
36731 + atomic_inc_unchecked(&vcc->stats->rx);
36732
36733 cell += ATM_CELL_PAYLOAD;
36734 }
36735 @@ -1135,13 +1135,13 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
36736 "(CDC: %08x)\n",
36737 card->name, len, rpp->len, readl(SAR_REG_CDC));
36738 recycle_rx_pool_skb(card, rpp);
36739 - atomic_inc(&vcc->stats->rx_err);
36740 + atomic_inc_unchecked(&vcc->stats->rx_err);
36741 return;
36742 }
36743 if (stat & SAR_RSQE_CRC) {
36744 RXPRINTK("%s: AAL5 CRC error.\n", card->name);
36745 recycle_rx_pool_skb(card, rpp);
36746 - atomic_inc(&vcc->stats->rx_err);
36747 + atomic_inc_unchecked(&vcc->stats->rx_err);
36748 return;
36749 }
36750 if (skb_queue_len(&rpp->queue) > 1) {
36751 @@ -1152,7 +1152,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
36752 RXPRINTK("%s: Can't alloc RX skb.\n",
36753 card->name);
36754 recycle_rx_pool_skb(card, rpp);
36755 - atomic_inc(&vcc->stats->rx_err);
36756 + atomic_inc_unchecked(&vcc->stats->rx_err);
36757 return;
36758 }
36759 if (!atm_charge(vcc, skb->truesize)) {
36760 @@ -1171,7 +1171,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
36761 __net_timestamp(skb);
36762
36763 vcc->push(vcc, skb);
36764 - atomic_inc(&vcc->stats->rx);
36765 + atomic_inc_unchecked(&vcc->stats->rx);
36766
36767 return;
36768 }
36769 @@ -1193,7 +1193,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
36770 __net_timestamp(skb);
36771
36772 vcc->push(vcc, skb);
36773 - atomic_inc(&vcc->stats->rx);
36774 + atomic_inc_unchecked(&vcc->stats->rx);
36775
36776 if (skb->truesize > SAR_FB_SIZE_3)
36777 add_rx_skb(card, 3, SAR_FB_SIZE_3, 1);
36778 @@ -1304,14 +1304,14 @@ idt77252_rx_raw(struct idt77252_dev *card)
36779 if (vcc->qos.aal != ATM_AAL0) {
36780 RPRINTK("%s: raw cell for non AAL0 vc %u.%u\n",
36781 card->name, vpi, vci);
36782 - atomic_inc(&vcc->stats->rx_drop);
36783 + atomic_inc_unchecked(&vcc->stats->rx_drop);
36784 goto drop;
36785 }
36786
36787 if ((sb = dev_alloc_skb(64)) == NULL) {
36788 printk("%s: Can't allocate buffers for AAL0.\n",
36789 card->name);
36790 - atomic_inc(&vcc->stats->rx_err);
36791 + atomic_inc_unchecked(&vcc->stats->rx_err);
36792 goto drop;
36793 }
36794
36795 @@ -1330,7 +1330,7 @@ idt77252_rx_raw(struct idt77252_dev *card)
36796 ATM_SKB(sb)->vcc = vcc;
36797 __net_timestamp(sb);
36798 vcc->push(vcc, sb);
36799 - atomic_inc(&vcc->stats->rx);
36800 + atomic_inc_unchecked(&vcc->stats->rx);
36801
36802 drop:
36803 skb_pull(queue, 64);
36804 @@ -1955,13 +1955,13 @@ idt77252_send_skb(struct atm_vcc *vcc, struct sk_buff *skb, int oam)
36805
36806 if (vc == NULL) {
36807 printk("%s: NULL connection in send().\n", card->name);
36808 - atomic_inc(&vcc->stats->tx_err);
36809 + atomic_inc_unchecked(&vcc->stats->tx_err);
36810 dev_kfree_skb(skb);
36811 return -EINVAL;
36812 }
36813 if (!test_bit(VCF_TX, &vc->flags)) {
36814 printk("%s: Trying to transmit on a non-tx VC.\n", card->name);
36815 - atomic_inc(&vcc->stats->tx_err);
36816 + atomic_inc_unchecked(&vcc->stats->tx_err);
36817 dev_kfree_skb(skb);
36818 return -EINVAL;
36819 }
36820 @@ -1973,14 +1973,14 @@ idt77252_send_skb(struct atm_vcc *vcc, struct sk_buff *skb, int oam)
36821 break;
36822 default:
36823 printk("%s: Unsupported AAL: %d\n", card->name, vcc->qos.aal);
36824 - atomic_inc(&vcc->stats->tx_err);
36825 + atomic_inc_unchecked(&vcc->stats->tx_err);
36826 dev_kfree_skb(skb);
36827 return -EINVAL;
36828 }
36829
36830 if (skb_shinfo(skb)->nr_frags != 0) {
36831 printk("%s: No scatter-gather yet.\n", card->name);
36832 - atomic_inc(&vcc->stats->tx_err);
36833 + atomic_inc_unchecked(&vcc->stats->tx_err);
36834 dev_kfree_skb(skb);
36835 return -EINVAL;
36836 }
36837 @@ -1988,7 +1988,7 @@ idt77252_send_skb(struct atm_vcc *vcc, struct sk_buff *skb, int oam)
36838
36839 err = queue_skb(card, vc, skb, oam);
36840 if (err) {
36841 - atomic_inc(&vcc->stats->tx_err);
36842 + atomic_inc_unchecked(&vcc->stats->tx_err);
36843 dev_kfree_skb(skb);
36844 return err;
36845 }
36846 @@ -2011,7 +2011,7 @@ idt77252_send_oam(struct atm_vcc *vcc, void *cell, int flags)
36847 skb = dev_alloc_skb(64);
36848 if (!skb) {
36849 printk("%s: Out of memory in send_oam().\n", card->name);
36850 - atomic_inc(&vcc->stats->tx_err);
36851 + atomic_inc_unchecked(&vcc->stats->tx_err);
36852 return -ENOMEM;
36853 }
36854 atomic_add(skb->truesize, &sk_atm(vcc)->sk_wmem_alloc);
36855 diff --git a/drivers/atm/iphase.c b/drivers/atm/iphase.c
36856 index 4217f29..88f547a 100644
36857 --- a/drivers/atm/iphase.c
36858 +++ b/drivers/atm/iphase.c
36859 @@ -1145,7 +1145,7 @@ static int rx_pkt(struct atm_dev *dev)
36860 status = (u_short) (buf_desc_ptr->desc_mode);
36861 if (status & (RX_CER | RX_PTE | RX_OFL))
36862 {
36863 - atomic_inc(&vcc->stats->rx_err);
36864 + atomic_inc_unchecked(&vcc->stats->rx_err);
36865 IF_ERR(printk("IA: bad packet, dropping it");)
36866 if (status & RX_CER) {
36867 IF_ERR(printk(" cause: packet CRC error\n");)
36868 @@ -1168,7 +1168,7 @@ static int rx_pkt(struct atm_dev *dev)
36869 len = dma_addr - buf_addr;
36870 if (len > iadev->rx_buf_sz) {
36871 printk("Over %d bytes sdu received, dropped!!!\n", iadev->rx_buf_sz);
36872 - atomic_inc(&vcc->stats->rx_err);
36873 + atomic_inc_unchecked(&vcc->stats->rx_err);
36874 goto out_free_desc;
36875 }
36876
36877 @@ -1318,7 +1318,7 @@ static void rx_dle_intr(struct atm_dev *dev)
36878 ia_vcc = INPH_IA_VCC(vcc);
36879 if (ia_vcc == NULL)
36880 {
36881 - atomic_inc(&vcc->stats->rx_err);
36882 + atomic_inc_unchecked(&vcc->stats->rx_err);
36883 atm_return(vcc, skb->truesize);
36884 dev_kfree_skb_any(skb);
36885 goto INCR_DLE;
36886 @@ -1330,7 +1330,7 @@ static void rx_dle_intr(struct atm_dev *dev)
36887 if ((length > iadev->rx_buf_sz) || (length >
36888 (skb->len - sizeof(struct cpcs_trailer))))
36889 {
36890 - atomic_inc(&vcc->stats->rx_err);
36891 + atomic_inc_unchecked(&vcc->stats->rx_err);
36892 IF_ERR(printk("rx_dle_intr: Bad AAL5 trailer %d (skb len %d)",
36893 length, skb->len);)
36894 atm_return(vcc, skb->truesize);
36895 @@ -1346,7 +1346,7 @@ static void rx_dle_intr(struct atm_dev *dev)
36896
36897 IF_RX(printk("rx_dle_intr: skb push");)
36898 vcc->push(vcc,skb);
36899 - atomic_inc(&vcc->stats->rx);
36900 + atomic_inc_unchecked(&vcc->stats->rx);
36901 iadev->rx_pkt_cnt++;
36902 }
36903 INCR_DLE:
36904 @@ -2826,15 +2826,15 @@ static int ia_ioctl(struct atm_dev *dev, unsigned int cmd, void __user *arg)
36905 {
36906 struct k_sonet_stats *stats;
36907 stats = &PRIV(_ia_dev[board])->sonet_stats;
36908 - printk("section_bip: %d\n", atomic_read(&stats->section_bip));
36909 - printk("line_bip : %d\n", atomic_read(&stats->line_bip));
36910 - printk("path_bip : %d\n", atomic_read(&stats->path_bip));
36911 - printk("line_febe : %d\n", atomic_read(&stats->line_febe));
36912 - printk("path_febe : %d\n", atomic_read(&stats->path_febe));
36913 - printk("corr_hcs : %d\n", atomic_read(&stats->corr_hcs));
36914 - printk("uncorr_hcs : %d\n", atomic_read(&stats->uncorr_hcs));
36915 - printk("tx_cells : %d\n", atomic_read(&stats->tx_cells));
36916 - printk("rx_cells : %d\n", atomic_read(&stats->rx_cells));
36917 + printk("section_bip: %d\n", atomic_read_unchecked(&stats->section_bip));
36918 + printk("line_bip : %d\n", atomic_read_unchecked(&stats->line_bip));
36919 + printk("path_bip : %d\n", atomic_read_unchecked(&stats->path_bip));
36920 + printk("line_febe : %d\n", atomic_read_unchecked(&stats->line_febe));
36921 + printk("path_febe : %d\n", atomic_read_unchecked(&stats->path_febe));
36922 + printk("corr_hcs : %d\n", atomic_read_unchecked(&stats->corr_hcs));
36923 + printk("uncorr_hcs : %d\n", atomic_read_unchecked(&stats->uncorr_hcs));
36924 + printk("tx_cells : %d\n", atomic_read_unchecked(&stats->tx_cells));
36925 + printk("rx_cells : %d\n", atomic_read_unchecked(&stats->rx_cells));
36926 }
36927 ia_cmds.status = 0;
36928 break;
36929 @@ -2939,7 +2939,7 @@ static int ia_pkt_tx (struct atm_vcc *vcc, struct sk_buff *skb) {
36930 if ((desc == 0) || (desc > iadev->num_tx_desc))
36931 {
36932 IF_ERR(printk(DEV_LABEL "invalid desc for send: %d\n", desc);)
36933 - atomic_inc(&vcc->stats->tx);
36934 + atomic_inc_unchecked(&vcc->stats->tx);
36935 if (vcc->pop)
36936 vcc->pop(vcc, skb);
36937 else
36938 @@ -3044,14 +3044,14 @@ static int ia_pkt_tx (struct atm_vcc *vcc, struct sk_buff *skb) {
36939 ATM_DESC(skb) = vcc->vci;
36940 skb_queue_tail(&iadev->tx_dma_q, skb);
36941
36942 - atomic_inc(&vcc->stats->tx);
36943 + atomic_inc_unchecked(&vcc->stats->tx);
36944 iadev->tx_pkt_cnt++;
36945 /* Increment transaction counter */
36946 writel(2, iadev->dma+IPHASE5575_TX_COUNTER);
36947
36948 #if 0
36949 /* add flow control logic */
36950 - if (atomic_read(&vcc->stats->tx) % 20 == 0) {
36951 + if (atomic_read_unchecked(&vcc->stats->tx) % 20 == 0) {
36952 if (iavcc->vc_desc_cnt > 10) {
36953 vcc->tx_quota = vcc->tx_quota * 3 / 4;
36954 printk("Tx1: vcc->tx_quota = %d \n", (u32)vcc->tx_quota );
36955 diff --git a/drivers/atm/lanai.c b/drivers/atm/lanai.c
36956 index fa7d701..1e404c7 100644
36957 --- a/drivers/atm/lanai.c
36958 +++ b/drivers/atm/lanai.c
36959 @@ -1303,7 +1303,7 @@ static void lanai_send_one_aal5(struct lanai_dev *lanai,
36960 vcc_tx_add_aal5_trailer(lvcc, skb->len, 0, 0);
36961 lanai_endtx(lanai, lvcc);
36962 lanai_free_skb(lvcc->tx.atmvcc, skb);
36963 - atomic_inc(&lvcc->tx.atmvcc->stats->tx);
36964 + atomic_inc_unchecked(&lvcc->tx.atmvcc->stats->tx);
36965 }
36966
36967 /* Try to fill the buffer - don't call unless there is backlog */
36968 @@ -1426,7 +1426,7 @@ static void vcc_rx_aal5(struct lanai_vcc *lvcc, int endptr)
36969 ATM_SKB(skb)->vcc = lvcc->rx.atmvcc;
36970 __net_timestamp(skb);
36971 lvcc->rx.atmvcc->push(lvcc->rx.atmvcc, skb);
36972 - atomic_inc(&lvcc->rx.atmvcc->stats->rx);
36973 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx);
36974 out:
36975 lvcc->rx.buf.ptr = end;
36976 cardvcc_write(lvcc, endptr, vcc_rxreadptr);
36977 @@ -1667,7 +1667,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
36978 DPRINTK("(itf %d) got RX service entry 0x%X for non-AAL5 "
36979 "vcc %d\n", lanai->number, (unsigned int) s, vci);
36980 lanai->stats.service_rxnotaal5++;
36981 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
36982 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
36983 return 0;
36984 }
36985 if (likely(!(s & (SERVICE_TRASH | SERVICE_STREAM | SERVICE_CRCERR)))) {
36986 @@ -1679,7 +1679,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
36987 int bytes;
36988 read_unlock(&vcc_sklist_lock);
36989 DPRINTK("got trashed rx pdu on vci %d\n", vci);
36990 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
36991 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
36992 lvcc->stats.x.aal5.service_trash++;
36993 bytes = (SERVICE_GET_END(s) * 16) -
36994 (((unsigned long) lvcc->rx.buf.ptr) -
36995 @@ -1691,7 +1691,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
36996 }
36997 if (s & SERVICE_STREAM) {
36998 read_unlock(&vcc_sklist_lock);
36999 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
37000 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
37001 lvcc->stats.x.aal5.service_stream++;
37002 printk(KERN_ERR DEV_LABEL "(itf %d): Got AAL5 stream "
37003 "PDU on VCI %d!\n", lanai->number, vci);
37004 @@ -1699,7 +1699,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
37005 return 0;
37006 }
37007 DPRINTK("got rx crc error on vci %d\n", vci);
37008 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
37009 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
37010 lvcc->stats.x.aal5.service_rxcrc++;
37011 lvcc->rx.buf.ptr = &lvcc->rx.buf.start[SERVICE_GET_END(s) * 4];
37012 cardvcc_write(lvcc, SERVICE_GET_END(s), vcc_rxreadptr);
37013 diff --git a/drivers/atm/nicstar.c b/drivers/atm/nicstar.c
37014 index 9988ac9..7c52585 100644
37015 --- a/drivers/atm/nicstar.c
37016 +++ b/drivers/atm/nicstar.c
37017 @@ -1640,7 +1640,7 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
37018 if ((vc = (vc_map *) vcc->dev_data) == NULL) {
37019 printk("nicstar%d: vcc->dev_data == NULL on ns_send().\n",
37020 card->index);
37021 - atomic_inc(&vcc->stats->tx_err);
37022 + atomic_inc_unchecked(&vcc->stats->tx_err);
37023 dev_kfree_skb_any(skb);
37024 return -EINVAL;
37025 }
37026 @@ -1648,7 +1648,7 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
37027 if (!vc->tx) {
37028 printk("nicstar%d: Trying to transmit on a non-tx VC.\n",
37029 card->index);
37030 - atomic_inc(&vcc->stats->tx_err);
37031 + atomic_inc_unchecked(&vcc->stats->tx_err);
37032 dev_kfree_skb_any(skb);
37033 return -EINVAL;
37034 }
37035 @@ -1656,14 +1656,14 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
37036 if (vcc->qos.aal != ATM_AAL5 && vcc->qos.aal != ATM_AAL0) {
37037 printk("nicstar%d: Only AAL0 and AAL5 are supported.\n",
37038 card->index);
37039 - atomic_inc(&vcc->stats->tx_err);
37040 + atomic_inc_unchecked(&vcc->stats->tx_err);
37041 dev_kfree_skb_any(skb);
37042 return -EINVAL;
37043 }
37044
37045 if (skb_shinfo(skb)->nr_frags != 0) {
37046 printk("nicstar%d: No scatter-gather yet.\n", card->index);
37047 - atomic_inc(&vcc->stats->tx_err);
37048 + atomic_inc_unchecked(&vcc->stats->tx_err);
37049 dev_kfree_skb_any(skb);
37050 return -EINVAL;
37051 }
37052 @@ -1711,11 +1711,11 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
37053 }
37054
37055 if (push_scqe(card, vc, scq, &scqe, skb) != 0) {
37056 - atomic_inc(&vcc->stats->tx_err);
37057 + atomic_inc_unchecked(&vcc->stats->tx_err);
37058 dev_kfree_skb_any(skb);
37059 return -EIO;
37060 }
37061 - atomic_inc(&vcc->stats->tx);
37062 + atomic_inc_unchecked(&vcc->stats->tx);
37063
37064 return 0;
37065 }
37066 @@ -2032,14 +2032,14 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
37067 printk
37068 ("nicstar%d: Can't allocate buffers for aal0.\n",
37069 card->index);
37070 - atomic_add(i, &vcc->stats->rx_drop);
37071 + atomic_add_unchecked(i, &vcc->stats->rx_drop);
37072 break;
37073 }
37074 if (!atm_charge(vcc, sb->truesize)) {
37075 RXPRINTK
37076 ("nicstar%d: atm_charge() dropped aal0 packets.\n",
37077 card->index);
37078 - atomic_add(i - 1, &vcc->stats->rx_drop); /* already increased by 1 */
37079 + atomic_add_unchecked(i - 1, &vcc->stats->rx_drop); /* already increased by 1 */
37080 dev_kfree_skb_any(sb);
37081 break;
37082 }
37083 @@ -2054,7 +2054,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
37084 ATM_SKB(sb)->vcc = vcc;
37085 __net_timestamp(sb);
37086 vcc->push(vcc, sb);
37087 - atomic_inc(&vcc->stats->rx);
37088 + atomic_inc_unchecked(&vcc->stats->rx);
37089 cell += ATM_CELL_PAYLOAD;
37090 }
37091
37092 @@ -2071,7 +2071,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
37093 if (iovb == NULL) {
37094 printk("nicstar%d: Out of iovec buffers.\n",
37095 card->index);
37096 - atomic_inc(&vcc->stats->rx_drop);
37097 + atomic_inc_unchecked(&vcc->stats->rx_drop);
37098 recycle_rx_buf(card, skb);
37099 return;
37100 }
37101 @@ -2095,7 +2095,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
37102 small or large buffer itself. */
37103 } else if (NS_PRV_IOVCNT(iovb) >= NS_MAX_IOVECS) {
37104 printk("nicstar%d: received too big AAL5 SDU.\n", card->index);
37105 - atomic_inc(&vcc->stats->rx_err);
37106 + atomic_inc_unchecked(&vcc->stats->rx_err);
37107 recycle_iovec_rx_bufs(card, (struct iovec *)iovb->data,
37108 NS_MAX_IOVECS);
37109 NS_PRV_IOVCNT(iovb) = 0;
37110 @@ -2115,7 +2115,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
37111 ("nicstar%d: Expected a small buffer, and this is not one.\n",
37112 card->index);
37113 which_list(card, skb);
37114 - atomic_inc(&vcc->stats->rx_err);
37115 + atomic_inc_unchecked(&vcc->stats->rx_err);
37116 recycle_rx_buf(card, skb);
37117 vc->rx_iov = NULL;
37118 recycle_iov_buf(card, iovb);
37119 @@ -2128,7 +2128,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
37120 ("nicstar%d: Expected a large buffer, and this is not one.\n",
37121 card->index);
37122 which_list(card, skb);
37123 - atomic_inc(&vcc->stats->rx_err);
37124 + atomic_inc_unchecked(&vcc->stats->rx_err);
37125 recycle_iovec_rx_bufs(card, (struct iovec *)iovb->data,
37126 NS_PRV_IOVCNT(iovb));
37127 vc->rx_iov = NULL;
37128 @@ -2151,7 +2151,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
37129 printk(" - PDU size mismatch.\n");
37130 else
37131 printk(".\n");
37132 - atomic_inc(&vcc->stats->rx_err);
37133 + atomic_inc_unchecked(&vcc->stats->rx_err);
37134 recycle_iovec_rx_bufs(card, (struct iovec *)iovb->data,
37135 NS_PRV_IOVCNT(iovb));
37136 vc->rx_iov = NULL;
37137 @@ -2165,7 +2165,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
37138 /* skb points to a small buffer */
37139 if (!atm_charge(vcc, skb->truesize)) {
37140 push_rxbufs(card, skb);
37141 - atomic_inc(&vcc->stats->rx_drop);
37142 + atomic_inc_unchecked(&vcc->stats->rx_drop);
37143 } else {
37144 skb_put(skb, len);
37145 dequeue_sm_buf(card, skb);
37146 @@ -2175,7 +2175,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
37147 ATM_SKB(skb)->vcc = vcc;
37148 __net_timestamp(skb);
37149 vcc->push(vcc, skb);
37150 - atomic_inc(&vcc->stats->rx);
37151 + atomic_inc_unchecked(&vcc->stats->rx);
37152 }
37153 } else if (NS_PRV_IOVCNT(iovb) == 2) { /* One small plus one large buffer */
37154 struct sk_buff *sb;
37155 @@ -2186,7 +2186,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
37156 if (len <= NS_SMBUFSIZE) {
37157 if (!atm_charge(vcc, sb->truesize)) {
37158 push_rxbufs(card, sb);
37159 - atomic_inc(&vcc->stats->rx_drop);
37160 + atomic_inc_unchecked(&vcc->stats->rx_drop);
37161 } else {
37162 skb_put(sb, len);
37163 dequeue_sm_buf(card, sb);
37164 @@ -2196,7 +2196,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
37165 ATM_SKB(sb)->vcc = vcc;
37166 __net_timestamp(sb);
37167 vcc->push(vcc, sb);
37168 - atomic_inc(&vcc->stats->rx);
37169 + atomic_inc_unchecked(&vcc->stats->rx);
37170 }
37171
37172 push_rxbufs(card, skb);
37173 @@ -2205,7 +2205,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
37174
37175 if (!atm_charge(vcc, skb->truesize)) {
37176 push_rxbufs(card, skb);
37177 - atomic_inc(&vcc->stats->rx_drop);
37178 + atomic_inc_unchecked(&vcc->stats->rx_drop);
37179 } else {
37180 dequeue_lg_buf(card, skb);
37181 #ifdef NS_USE_DESTRUCTORS
37182 @@ -2218,7 +2218,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
37183 ATM_SKB(skb)->vcc = vcc;
37184 __net_timestamp(skb);
37185 vcc->push(vcc, skb);
37186 - atomic_inc(&vcc->stats->rx);
37187 + atomic_inc_unchecked(&vcc->stats->rx);
37188 }
37189
37190 push_rxbufs(card, sb);
37191 @@ -2239,7 +2239,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
37192 printk
37193 ("nicstar%d: Out of huge buffers.\n",
37194 card->index);
37195 - atomic_inc(&vcc->stats->rx_drop);
37196 + atomic_inc_unchecked(&vcc->stats->rx_drop);
37197 recycle_iovec_rx_bufs(card,
37198 (struct iovec *)
37199 iovb->data,
37200 @@ -2290,7 +2290,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
37201 card->hbpool.count++;
37202 } else
37203 dev_kfree_skb_any(hb);
37204 - atomic_inc(&vcc->stats->rx_drop);
37205 + atomic_inc_unchecked(&vcc->stats->rx_drop);
37206 } else {
37207 /* Copy the small buffer to the huge buffer */
37208 sb = (struct sk_buff *)iov->iov_base;
37209 @@ -2327,7 +2327,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
37210 #endif /* NS_USE_DESTRUCTORS */
37211 __net_timestamp(hb);
37212 vcc->push(vcc, hb);
37213 - atomic_inc(&vcc->stats->rx);
37214 + atomic_inc_unchecked(&vcc->stats->rx);
37215 }
37216 }
37217
37218 diff --git a/drivers/atm/solos-pci.c b/drivers/atm/solos-pci.c
37219 index 943cf0d..37d15d5 100644
37220 --- a/drivers/atm/solos-pci.c
37221 +++ b/drivers/atm/solos-pci.c
37222 @@ -838,7 +838,7 @@ static void solos_bh(unsigned long card_arg)
37223 }
37224 atm_charge(vcc, skb->truesize);
37225 vcc->push(vcc, skb);
37226 - atomic_inc(&vcc->stats->rx);
37227 + atomic_inc_unchecked(&vcc->stats->rx);
37228 break;
37229
37230 case PKT_STATUS:
37231 @@ -1116,7 +1116,7 @@ static uint32_t fpga_tx(struct solos_card *card)
37232 vcc = SKB_CB(oldskb)->vcc;
37233
37234 if (vcc) {
37235 - atomic_inc(&vcc->stats->tx);
37236 + atomic_inc_unchecked(&vcc->stats->tx);
37237 solos_pop(vcc, oldskb);
37238 } else {
37239 dev_kfree_skb_irq(oldskb);
37240 diff --git a/drivers/atm/suni.c b/drivers/atm/suni.c
37241 index 0215934..ce9f5b1 100644
37242 --- a/drivers/atm/suni.c
37243 +++ b/drivers/atm/suni.c
37244 @@ -49,8 +49,8 @@ static DEFINE_SPINLOCK(sunis_lock);
37245
37246
37247 #define ADD_LIMITED(s,v) \
37248 - atomic_add((v),&stats->s); \
37249 - if (atomic_read(&stats->s) < 0) atomic_set(&stats->s,INT_MAX);
37250 + atomic_add_unchecked((v),&stats->s); \
37251 + if (atomic_read_unchecked(&stats->s) < 0) atomic_set_unchecked(&stats->s,INT_MAX);
37252
37253
37254 static void suni_hz(unsigned long from_timer)
37255 diff --git a/drivers/atm/uPD98402.c b/drivers/atm/uPD98402.c
37256 index 5120a96..e2572bd 100644
37257 --- a/drivers/atm/uPD98402.c
37258 +++ b/drivers/atm/uPD98402.c
37259 @@ -42,7 +42,7 @@ static int fetch_stats(struct atm_dev *dev,struct sonet_stats __user *arg,int ze
37260 struct sonet_stats tmp;
37261 int error = 0;
37262
37263 - atomic_add(GET(HECCT),&PRIV(dev)->sonet_stats.uncorr_hcs);
37264 + atomic_add_unchecked(GET(HECCT),&PRIV(dev)->sonet_stats.uncorr_hcs);
37265 sonet_copy_stats(&PRIV(dev)->sonet_stats,&tmp);
37266 if (arg) error = copy_to_user(arg,&tmp,sizeof(tmp));
37267 if (zero && !error) {
37268 @@ -161,9 +161,9 @@ static int uPD98402_ioctl(struct atm_dev *dev,unsigned int cmd,void __user *arg)
37269
37270
37271 #define ADD_LIMITED(s,v) \
37272 - { atomic_add(GET(v),&PRIV(dev)->sonet_stats.s); \
37273 - if (atomic_read(&PRIV(dev)->sonet_stats.s) < 0) \
37274 - atomic_set(&PRIV(dev)->sonet_stats.s,INT_MAX); }
37275 + { atomic_add_unchecked(GET(v),&PRIV(dev)->sonet_stats.s); \
37276 + if (atomic_read_unchecked(&PRIV(dev)->sonet_stats.s) < 0) \
37277 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.s,INT_MAX); }
37278
37279
37280 static void stat_event(struct atm_dev *dev)
37281 @@ -194,7 +194,7 @@ static void uPD98402_int(struct atm_dev *dev)
37282 if (reason & uPD98402_INT_PFM) stat_event(dev);
37283 if (reason & uPD98402_INT_PCO) {
37284 (void) GET(PCOCR); /* clear interrupt cause */
37285 - atomic_add(GET(HECCT),
37286 + atomic_add_unchecked(GET(HECCT),
37287 &PRIV(dev)->sonet_stats.uncorr_hcs);
37288 }
37289 if ((reason & uPD98402_INT_RFO) &&
37290 @@ -222,9 +222,9 @@ static int uPD98402_start(struct atm_dev *dev)
37291 PUT(~(uPD98402_INT_PFM | uPD98402_INT_ALM | uPD98402_INT_RFO |
37292 uPD98402_INT_LOS),PIMR); /* enable them */
37293 (void) fetch_stats(dev,NULL,1); /* clear kernel counters */
37294 - atomic_set(&PRIV(dev)->sonet_stats.corr_hcs,-1);
37295 - atomic_set(&PRIV(dev)->sonet_stats.tx_cells,-1);
37296 - atomic_set(&PRIV(dev)->sonet_stats.rx_cells,-1);
37297 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.corr_hcs,-1);
37298 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.tx_cells,-1);
37299 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.rx_cells,-1);
37300 return 0;
37301 }
37302
37303 diff --git a/drivers/atm/zatm.c b/drivers/atm/zatm.c
37304 index 969c3c2..9b72956 100644
37305 --- a/drivers/atm/zatm.c
37306 +++ b/drivers/atm/zatm.c
37307 @@ -459,7 +459,7 @@ printk("dummy: 0x%08lx, 0x%08lx\n",dummy[0],dummy[1]);
37308 }
37309 if (!size) {
37310 dev_kfree_skb_irq(skb);
37311 - if (vcc) atomic_inc(&vcc->stats->rx_err);
37312 + if (vcc) atomic_inc_unchecked(&vcc->stats->rx_err);
37313 continue;
37314 }
37315 if (!atm_charge(vcc,skb->truesize)) {
37316 @@ -469,7 +469,7 @@ printk("dummy: 0x%08lx, 0x%08lx\n",dummy[0],dummy[1]);
37317 skb->len = size;
37318 ATM_SKB(skb)->vcc = vcc;
37319 vcc->push(vcc,skb);
37320 - atomic_inc(&vcc->stats->rx);
37321 + atomic_inc_unchecked(&vcc->stats->rx);
37322 }
37323 zout(pos & 0xffff,MTA(mbx));
37324 #if 0 /* probably a stupid idea */
37325 @@ -733,7 +733,7 @@ if (*ZATM_PRV_DSC(skb) != (uPD98401_TXPD_V | uPD98401_TXPD_DP |
37326 skb_queue_head(&zatm_vcc->backlog,skb);
37327 break;
37328 }
37329 - atomic_inc(&vcc->stats->tx);
37330 + atomic_inc_unchecked(&vcc->stats->tx);
37331 wake_up(&zatm_vcc->tx_wait);
37332 }
37333
37334 diff --git a/drivers/base/bus.c b/drivers/base/bus.c
37335 index 83e910a..b224a73 100644
37336 --- a/drivers/base/bus.c
37337 +++ b/drivers/base/bus.c
37338 @@ -1124,7 +1124,7 @@ int subsys_interface_register(struct subsys_interface *sif)
37339 return -EINVAL;
37340
37341 mutex_lock(&subsys->p->mutex);
37342 - list_add_tail(&sif->node, &subsys->p->interfaces);
37343 + pax_list_add_tail((struct list_head *)&sif->node, &subsys->p->interfaces);
37344 if (sif->add_dev) {
37345 subsys_dev_iter_init(&iter, subsys, NULL, NULL);
37346 while ((dev = subsys_dev_iter_next(&iter)))
37347 @@ -1149,7 +1149,7 @@ void subsys_interface_unregister(struct subsys_interface *sif)
37348 subsys = sif->subsys;
37349
37350 mutex_lock(&subsys->p->mutex);
37351 - list_del_init(&sif->node);
37352 + pax_list_del_init((struct list_head *)&sif->node);
37353 if (sif->remove_dev) {
37354 subsys_dev_iter_init(&iter, subsys, NULL, NULL);
37355 while ((dev = subsys_dev_iter_next(&iter)))
37356 diff --git a/drivers/base/devtmpfs.c b/drivers/base/devtmpfs.c
37357 index 25798db..15f130e 100644
37358 --- a/drivers/base/devtmpfs.c
37359 +++ b/drivers/base/devtmpfs.c
37360 @@ -354,7 +354,7 @@ int devtmpfs_mount(const char *mntdir)
37361 if (!thread)
37362 return 0;
37363
37364 - err = sys_mount("devtmpfs", (char *)mntdir, "devtmpfs", MS_SILENT, NULL);
37365 + err = sys_mount((char __force_user *)"devtmpfs", (char __force_user *)mntdir, (char __force_user *)"devtmpfs", MS_SILENT, NULL);
37366 if (err)
37367 printk(KERN_INFO "devtmpfs: error mounting %i\n", err);
37368 else
37369 @@ -380,11 +380,11 @@ static int devtmpfsd(void *p)
37370 *err = sys_unshare(CLONE_NEWNS);
37371 if (*err)
37372 goto out;
37373 - *err = sys_mount("devtmpfs", "/", "devtmpfs", MS_SILENT, options);
37374 + *err = sys_mount((char __force_user *)"devtmpfs", (char __force_user *)"/", (char __force_user *)"devtmpfs", MS_SILENT, (char __force_user *)options);
37375 if (*err)
37376 goto out;
37377 - sys_chdir("/.."); /* will traverse into overmounted root */
37378 - sys_chroot(".");
37379 + sys_chdir((char __force_user *)"/.."); /* will traverse into overmounted root */
37380 + sys_chroot((char __force_user *)".");
37381 complete(&setup_done);
37382 while (1) {
37383 spin_lock(&req_lock);
37384 diff --git a/drivers/base/node.c b/drivers/base/node.c
37385 index 8f7ed99..700dd0c 100644
37386 --- a/drivers/base/node.c
37387 +++ b/drivers/base/node.c
37388 @@ -624,7 +624,7 @@ static ssize_t print_nodes_state(enum node_states state, char *buf)
37389 struct node_attr {
37390 struct device_attribute attr;
37391 enum node_states state;
37392 -};
37393 +} __do_const;
37394
37395 static ssize_t show_node_state(struct device *dev,
37396 struct device_attribute *attr, char *buf)
37397 diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
37398 index ae098a2..0999830 100644
37399 --- a/drivers/base/power/domain.c
37400 +++ b/drivers/base/power/domain.c
37401 @@ -1821,9 +1821,9 @@ int __pm_genpd_remove_callbacks(struct device *dev, bool clear_td)
37402
37403 if (dev->power.subsys_data->domain_data) {
37404 gpd_data = to_gpd_data(dev->power.subsys_data->domain_data);
37405 - gpd_data->ops = (struct gpd_dev_ops){ NULL };
37406 + memset(&gpd_data->ops, 0, sizeof(gpd_data->ops));
37407 if (clear_td)
37408 - gpd_data->td = (struct gpd_timing_data){ 0 };
37409 + memset(&gpd_data->td, 0, sizeof(gpd_data->td));
37410
37411 if (--gpd_data->refcount == 0) {
37412 dev->power.subsys_data->domain_data = NULL;
37413 @@ -1862,7 +1862,7 @@ int pm_genpd_attach_cpuidle(struct generic_pm_domain *genpd, int state)
37414 {
37415 struct cpuidle_driver *cpuidle_drv;
37416 struct gpd_cpu_data *cpu_data;
37417 - struct cpuidle_state *idle_state;
37418 + cpuidle_state_no_const *idle_state;
37419 int ret = 0;
37420
37421 if (IS_ERR_OR_NULL(genpd) || state < 0)
37422 @@ -1930,7 +1930,7 @@ int pm_genpd_name_attach_cpuidle(const char *name, int state)
37423 int pm_genpd_detach_cpuidle(struct generic_pm_domain *genpd)
37424 {
37425 struct gpd_cpu_data *cpu_data;
37426 - struct cpuidle_state *idle_state;
37427 + cpuidle_state_no_const *idle_state;
37428 int ret = 0;
37429
37430 if (IS_ERR_OR_NULL(genpd))
37431 diff --git a/drivers/base/power/sysfs.c b/drivers/base/power/sysfs.c
37432 index 95b181d1..c4f0e19 100644
37433 --- a/drivers/base/power/sysfs.c
37434 +++ b/drivers/base/power/sysfs.c
37435 @@ -185,7 +185,7 @@ static ssize_t rtpm_status_show(struct device *dev,
37436 return -EIO;
37437 }
37438 }
37439 - return sprintf(buf, p);
37440 + return sprintf(buf, "%s", p);
37441 }
37442
37443 static DEVICE_ATTR(runtime_status, 0444, rtpm_status_show, NULL);
37444 diff --git a/drivers/base/power/wakeup.c b/drivers/base/power/wakeup.c
37445 index 2d56f41..8830f19 100644
37446 --- a/drivers/base/power/wakeup.c
37447 +++ b/drivers/base/power/wakeup.c
37448 @@ -29,14 +29,14 @@ bool events_check_enabled __read_mostly;
37449 * They need to be modified together atomically, so it's better to use one
37450 * atomic variable to hold them both.
37451 */
37452 -static atomic_t combined_event_count = ATOMIC_INIT(0);
37453 +static atomic_unchecked_t combined_event_count = ATOMIC_INIT(0);
37454
37455 #define IN_PROGRESS_BITS (sizeof(int) * 4)
37456 #define MAX_IN_PROGRESS ((1 << IN_PROGRESS_BITS) - 1)
37457
37458 static void split_counters(unsigned int *cnt, unsigned int *inpr)
37459 {
37460 - unsigned int comb = atomic_read(&combined_event_count);
37461 + unsigned int comb = atomic_read_unchecked(&combined_event_count);
37462
37463 *cnt = (comb >> IN_PROGRESS_BITS);
37464 *inpr = comb & MAX_IN_PROGRESS;
37465 @@ -395,7 +395,7 @@ static void wakeup_source_activate(struct wakeup_source *ws)
37466 ws->start_prevent_time = ws->last_time;
37467
37468 /* Increment the counter of events in progress. */
37469 - cec = atomic_inc_return(&combined_event_count);
37470 + cec = atomic_inc_return_unchecked(&combined_event_count);
37471
37472 trace_wakeup_source_activate(ws->name, cec);
37473 }
37474 @@ -521,7 +521,7 @@ static void wakeup_source_deactivate(struct wakeup_source *ws)
37475 * Increment the counter of registered wakeup events and decrement the
37476 * couter of wakeup events in progress simultaneously.
37477 */
37478 - cec = atomic_add_return(MAX_IN_PROGRESS, &combined_event_count);
37479 + cec = atomic_add_return_unchecked(MAX_IN_PROGRESS, &combined_event_count);
37480 trace_wakeup_source_deactivate(ws->name, cec);
37481
37482 split_counters(&cnt, &inpr);
37483 diff --git a/drivers/base/syscore.c b/drivers/base/syscore.c
37484 index e8d11b6..7b1b36f 100644
37485 --- a/drivers/base/syscore.c
37486 +++ b/drivers/base/syscore.c
37487 @@ -21,7 +21,7 @@ static DEFINE_MUTEX(syscore_ops_lock);
37488 void register_syscore_ops(struct syscore_ops *ops)
37489 {
37490 mutex_lock(&syscore_ops_lock);
37491 - list_add_tail(&ops->node, &syscore_ops_list);
37492 + pax_list_add_tail((struct list_head *)&ops->node, &syscore_ops_list);
37493 mutex_unlock(&syscore_ops_lock);
37494 }
37495 EXPORT_SYMBOL_GPL(register_syscore_ops);
37496 @@ -33,7 +33,7 @@ EXPORT_SYMBOL_GPL(register_syscore_ops);
37497 void unregister_syscore_ops(struct syscore_ops *ops)
37498 {
37499 mutex_lock(&syscore_ops_lock);
37500 - list_del(&ops->node);
37501 + pax_list_del((struct list_head *)&ops->node);
37502 mutex_unlock(&syscore_ops_lock);
37503 }
37504 EXPORT_SYMBOL_GPL(unregister_syscore_ops);
37505 diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
37506 index 73894ca..69f64ef 100644
37507 --- a/drivers/block/cciss.c
37508 +++ b/drivers/block/cciss.c
37509 @@ -3011,7 +3011,7 @@ static void start_io(ctlr_info_t *h)
37510 while (!list_empty(&h->reqQ)) {
37511 c = list_entry(h->reqQ.next, CommandList_struct, list);
37512 /* can't do anything if fifo is full */
37513 - if ((h->access.fifo_full(h))) {
37514 + if ((h->access->fifo_full(h))) {
37515 dev_warn(&h->pdev->dev, "fifo full\n");
37516 break;
37517 }
37518 @@ -3021,7 +3021,7 @@ static void start_io(ctlr_info_t *h)
37519 h->Qdepth--;
37520
37521 /* Tell the controller execute command */
37522 - h->access.submit_command(h, c);
37523 + h->access->submit_command(h, c);
37524
37525 /* Put job onto the completed Q */
37526 addQ(&h->cmpQ, c);
37527 @@ -3447,17 +3447,17 @@ startio:
37528
37529 static inline unsigned long get_next_completion(ctlr_info_t *h)
37530 {
37531 - return h->access.command_completed(h);
37532 + return h->access->command_completed(h);
37533 }
37534
37535 static inline int interrupt_pending(ctlr_info_t *h)
37536 {
37537 - return h->access.intr_pending(h);
37538 + return h->access->intr_pending(h);
37539 }
37540
37541 static inline long interrupt_not_for_us(ctlr_info_t *h)
37542 {
37543 - return ((h->access.intr_pending(h) == 0) ||
37544 + return ((h->access->intr_pending(h) == 0) ||
37545 (h->interrupts_enabled == 0));
37546 }
37547
37548 @@ -3490,7 +3490,7 @@ static inline u32 next_command(ctlr_info_t *h)
37549 u32 a;
37550
37551 if (unlikely(!(h->transMethod & CFGTBL_Trans_Performant)))
37552 - return h->access.command_completed(h);
37553 + return h->access->command_completed(h);
37554
37555 if ((*(h->reply_pool_head) & 1) == (h->reply_pool_wraparound)) {
37556 a = *(h->reply_pool_head); /* Next cmd in ring buffer */
37557 @@ -4047,7 +4047,7 @@ static void cciss_put_controller_into_performant_mode(ctlr_info_t *h)
37558 trans_support & CFGTBL_Trans_use_short_tags);
37559
37560 /* Change the access methods to the performant access methods */
37561 - h->access = SA5_performant_access;
37562 + h->access = &SA5_performant_access;
37563 h->transMethod = CFGTBL_Trans_Performant;
37564
37565 return;
37566 @@ -4325,7 +4325,7 @@ static int cciss_pci_init(ctlr_info_t *h)
37567 if (prod_index < 0)
37568 return -ENODEV;
37569 h->product_name = products[prod_index].product_name;
37570 - h->access = *(products[prod_index].access);
37571 + h->access = products[prod_index].access;
37572
37573 if (cciss_board_disabled(h)) {
37574 dev_warn(&h->pdev->dev, "controller appears to be disabled\n");
37575 @@ -5057,7 +5057,7 @@ reinit_after_soft_reset:
37576 }
37577
37578 /* make sure the board interrupts are off */
37579 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
37580 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
37581 rc = cciss_request_irq(h, do_cciss_msix_intr, do_cciss_intx);
37582 if (rc)
37583 goto clean2;
37584 @@ -5107,7 +5107,7 @@ reinit_after_soft_reset:
37585 * fake ones to scoop up any residual completions.
37586 */
37587 spin_lock_irqsave(&h->lock, flags);
37588 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
37589 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
37590 spin_unlock_irqrestore(&h->lock, flags);
37591 free_irq(h->intr[h->intr_mode], h);
37592 rc = cciss_request_irq(h, cciss_msix_discard_completions,
37593 @@ -5127,9 +5127,9 @@ reinit_after_soft_reset:
37594 dev_info(&h->pdev->dev, "Board READY.\n");
37595 dev_info(&h->pdev->dev,
37596 "Waiting for stale completions to drain.\n");
37597 - h->access.set_intr_mask(h, CCISS_INTR_ON);
37598 + h->access->set_intr_mask(h, CCISS_INTR_ON);
37599 msleep(10000);
37600 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
37601 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
37602
37603 rc = controller_reset_failed(h->cfgtable);
37604 if (rc)
37605 @@ -5152,7 +5152,7 @@ reinit_after_soft_reset:
37606 cciss_scsi_setup(h);
37607
37608 /* Turn the interrupts on so we can service requests */
37609 - h->access.set_intr_mask(h, CCISS_INTR_ON);
37610 + h->access->set_intr_mask(h, CCISS_INTR_ON);
37611
37612 /* Get the firmware version */
37613 inq_buff = kzalloc(sizeof(InquiryData_struct), GFP_KERNEL);
37614 @@ -5224,7 +5224,7 @@ static void cciss_shutdown(struct pci_dev *pdev)
37615 kfree(flush_buf);
37616 if (return_code != IO_OK)
37617 dev_warn(&h->pdev->dev, "Error flushing cache\n");
37618 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
37619 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
37620 free_irq(h->intr[h->intr_mode], h);
37621 }
37622
37623 diff --git a/drivers/block/cciss.h b/drivers/block/cciss.h
37624 index 7fda30e..2f27946 100644
37625 --- a/drivers/block/cciss.h
37626 +++ b/drivers/block/cciss.h
37627 @@ -101,7 +101,7 @@ struct ctlr_info
37628 /* information about each logical volume */
37629 drive_info_struct *drv[CISS_MAX_LUN];
37630
37631 - struct access_method access;
37632 + struct access_method *access;
37633
37634 /* queue and queue Info */
37635 struct list_head reqQ;
37636 @@ -402,27 +402,27 @@ static bool SA5_performant_intr_pending(ctlr_info_t *h)
37637 }
37638
37639 static struct access_method SA5_access = {
37640 - SA5_submit_command,
37641 - SA5_intr_mask,
37642 - SA5_fifo_full,
37643 - SA5_intr_pending,
37644 - SA5_completed,
37645 + .submit_command = SA5_submit_command,
37646 + .set_intr_mask = SA5_intr_mask,
37647 + .fifo_full = SA5_fifo_full,
37648 + .intr_pending = SA5_intr_pending,
37649 + .command_completed = SA5_completed,
37650 };
37651
37652 static struct access_method SA5B_access = {
37653 - SA5_submit_command,
37654 - SA5B_intr_mask,
37655 - SA5_fifo_full,
37656 - SA5B_intr_pending,
37657 - SA5_completed,
37658 + .submit_command = SA5_submit_command,
37659 + .set_intr_mask = SA5B_intr_mask,
37660 + .fifo_full = SA5_fifo_full,
37661 + .intr_pending = SA5B_intr_pending,
37662 + .command_completed = SA5_completed,
37663 };
37664
37665 static struct access_method SA5_performant_access = {
37666 - SA5_submit_command,
37667 - SA5_performant_intr_mask,
37668 - SA5_fifo_full,
37669 - SA5_performant_intr_pending,
37670 - SA5_performant_completed,
37671 + .submit_command = SA5_submit_command,
37672 + .set_intr_mask = SA5_performant_intr_mask,
37673 + .fifo_full = SA5_fifo_full,
37674 + .intr_pending = SA5_performant_intr_pending,
37675 + .command_completed = SA5_performant_completed,
37676 };
37677
37678 struct board_type {
37679 diff --git a/drivers/block/cpqarray.c b/drivers/block/cpqarray.c
37680 index 2b94403..fd6ad1f 100644
37681 --- a/drivers/block/cpqarray.c
37682 +++ b/drivers/block/cpqarray.c
37683 @@ -404,7 +404,7 @@ static int cpqarray_register_ctlr(int i, struct pci_dev *pdev)
37684 if (register_blkdev(COMPAQ_SMART2_MAJOR+i, hba[i]->devname)) {
37685 goto Enomem4;
37686 }
37687 - hba[i]->access.set_intr_mask(hba[i], 0);
37688 + hba[i]->access->set_intr_mask(hba[i], 0);
37689 if (request_irq(hba[i]->intr, do_ida_intr,
37690 IRQF_DISABLED|IRQF_SHARED, hba[i]->devname, hba[i]))
37691 {
37692 @@ -459,7 +459,7 @@ static int cpqarray_register_ctlr(int i, struct pci_dev *pdev)
37693 add_timer(&hba[i]->timer);
37694
37695 /* Enable IRQ now that spinlock and rate limit timer are set up */
37696 - hba[i]->access.set_intr_mask(hba[i], FIFO_NOT_EMPTY);
37697 + hba[i]->access->set_intr_mask(hba[i], FIFO_NOT_EMPTY);
37698
37699 for(j=0; j<NWD; j++) {
37700 struct gendisk *disk = ida_gendisk[i][j];
37701 @@ -694,7 +694,7 @@ DBGINFO(
37702 for(i=0; i<NR_PRODUCTS; i++) {
37703 if (board_id == products[i].board_id) {
37704 c->product_name = products[i].product_name;
37705 - c->access = *(products[i].access);
37706 + c->access = products[i].access;
37707 break;
37708 }
37709 }
37710 @@ -792,7 +792,7 @@ static int cpqarray_eisa_detect(void)
37711 hba[ctlr]->intr = intr;
37712 sprintf(hba[ctlr]->devname, "ida%d", nr_ctlr);
37713 hba[ctlr]->product_name = products[j].product_name;
37714 - hba[ctlr]->access = *(products[j].access);
37715 + hba[ctlr]->access = products[j].access;
37716 hba[ctlr]->ctlr = ctlr;
37717 hba[ctlr]->board_id = board_id;
37718 hba[ctlr]->pci_dev = NULL; /* not PCI */
37719 @@ -978,7 +978,7 @@ static void start_io(ctlr_info_t *h)
37720
37721 while((c = h->reqQ) != NULL) {
37722 /* Can't do anything if we're busy */
37723 - if (h->access.fifo_full(h) == 0)
37724 + if (h->access->fifo_full(h) == 0)
37725 return;
37726
37727 /* Get the first entry from the request Q */
37728 @@ -986,7 +986,7 @@ static void start_io(ctlr_info_t *h)
37729 h->Qdepth--;
37730
37731 /* Tell the controller to do our bidding */
37732 - h->access.submit_command(h, c);
37733 + h->access->submit_command(h, c);
37734
37735 /* Get onto the completion Q */
37736 addQ(&h->cmpQ, c);
37737 @@ -1048,7 +1048,7 @@ static irqreturn_t do_ida_intr(int irq, void *dev_id)
37738 unsigned long flags;
37739 __u32 a,a1;
37740
37741 - istat = h->access.intr_pending(h);
37742 + istat = h->access->intr_pending(h);
37743 /* Is this interrupt for us? */
37744 if (istat == 0)
37745 return IRQ_NONE;
37746 @@ -1059,7 +1059,7 @@ static irqreturn_t do_ida_intr(int irq, void *dev_id)
37747 */
37748 spin_lock_irqsave(IDA_LOCK(h->ctlr), flags);
37749 if (istat & FIFO_NOT_EMPTY) {
37750 - while((a = h->access.command_completed(h))) {
37751 + while((a = h->access->command_completed(h))) {
37752 a1 = a; a &= ~3;
37753 if ((c = h->cmpQ) == NULL)
37754 {
37755 @@ -1448,11 +1448,11 @@ static int sendcmd(
37756 /*
37757 * Disable interrupt
37758 */
37759 - info_p->access.set_intr_mask(info_p, 0);
37760 + info_p->access->set_intr_mask(info_p, 0);
37761 /* Make sure there is room in the command FIFO */
37762 /* Actually it should be completely empty at this time. */
37763 for (i = 200000; i > 0; i--) {
37764 - temp = info_p->access.fifo_full(info_p);
37765 + temp = info_p->access->fifo_full(info_p);
37766 if (temp != 0) {
37767 break;
37768 }
37769 @@ -1465,7 +1465,7 @@ DBG(
37770 /*
37771 * Send the cmd
37772 */
37773 - info_p->access.submit_command(info_p, c);
37774 + info_p->access->submit_command(info_p, c);
37775 complete = pollcomplete(ctlr);
37776
37777 pci_unmap_single(info_p->pci_dev, (dma_addr_t) c->req.sg[0].addr,
37778 @@ -1548,9 +1548,9 @@ static int revalidate_allvol(ctlr_info_t *host)
37779 * we check the new geometry. Then turn interrupts back on when
37780 * we're done.
37781 */
37782 - host->access.set_intr_mask(host, 0);
37783 + host->access->set_intr_mask(host, 0);
37784 getgeometry(ctlr);
37785 - host->access.set_intr_mask(host, FIFO_NOT_EMPTY);
37786 + host->access->set_intr_mask(host, FIFO_NOT_EMPTY);
37787
37788 for(i=0; i<NWD; i++) {
37789 struct gendisk *disk = ida_gendisk[ctlr][i];
37790 @@ -1590,7 +1590,7 @@ static int pollcomplete(int ctlr)
37791 /* Wait (up to 2 seconds) for a command to complete */
37792
37793 for (i = 200000; i > 0; i--) {
37794 - done = hba[ctlr]->access.command_completed(hba[ctlr]);
37795 + done = hba[ctlr]->access->command_completed(hba[ctlr]);
37796 if (done == 0) {
37797 udelay(10); /* a short fixed delay */
37798 } else
37799 diff --git a/drivers/block/cpqarray.h b/drivers/block/cpqarray.h
37800 index be73e9d..7fbf140 100644
37801 --- a/drivers/block/cpqarray.h
37802 +++ b/drivers/block/cpqarray.h
37803 @@ -99,7 +99,7 @@ struct ctlr_info {
37804 drv_info_t drv[NWD];
37805 struct proc_dir_entry *proc;
37806
37807 - struct access_method access;
37808 + struct access_method *access;
37809
37810 cmdlist_t *reqQ;
37811 cmdlist_t *cmpQ;
37812 diff --git a/drivers/block/drbd/drbd_int.h b/drivers/block/drbd/drbd_int.h
37813 index e7093d4..b364085 100644
37814 --- a/drivers/block/drbd/drbd_int.h
37815 +++ b/drivers/block/drbd/drbd_int.h
37816 @@ -331,7 +331,7 @@ struct drbd_epoch {
37817 struct drbd_connection *connection;
37818 struct list_head list;
37819 unsigned int barrier_nr;
37820 - atomic_t epoch_size; /* increased on every request added. */
37821 + atomic_unchecked_t epoch_size; /* increased on every request added. */
37822 atomic_t active; /* increased on every req. added, and dec on every finished. */
37823 unsigned long flags;
37824 };
37825 @@ -787,7 +787,7 @@ struct drbd_device {
37826 unsigned int al_tr_number;
37827 int al_tr_cycle;
37828 wait_queue_head_t seq_wait;
37829 - atomic_t packet_seq;
37830 + atomic_unchecked_t packet_seq;
37831 unsigned int peer_seq;
37832 spinlock_t peer_seq_lock;
37833 unsigned int minor;
37834 @@ -1361,7 +1361,7 @@ static inline int drbd_setsockopt(struct socket *sock, int level, int optname,
37835 char __user *uoptval;
37836 int err;
37837
37838 - uoptval = (char __user __force *)optval;
37839 + uoptval = (char __force_user *)optval;
37840
37841 set_fs(KERNEL_DS);
37842 if (level == SOL_SOCKET)
37843 diff --git a/drivers/block/drbd/drbd_interval.c b/drivers/block/drbd/drbd_interval.c
37844 index 89c497c..9c736ae 100644
37845 --- a/drivers/block/drbd/drbd_interval.c
37846 +++ b/drivers/block/drbd/drbd_interval.c
37847 @@ -67,9 +67,9 @@ static void augment_rotate(struct rb_node *rb_old, struct rb_node *rb_new)
37848 }
37849
37850 static const struct rb_augment_callbacks augment_callbacks = {
37851 - augment_propagate,
37852 - augment_copy,
37853 - augment_rotate,
37854 + .propagate = augment_propagate,
37855 + .copy = augment_copy,
37856 + .rotate = augment_rotate,
37857 };
37858
37859 /**
37860 diff --git a/drivers/block/drbd/drbd_main.c b/drivers/block/drbd/drbd_main.c
37861 index 331e5cc..6d657bce 100644
37862 --- a/drivers/block/drbd/drbd_main.c
37863 +++ b/drivers/block/drbd/drbd_main.c
37864 @@ -1322,7 +1322,7 @@ static int _drbd_send_ack(struct drbd_peer_device *peer_device, enum drbd_packet
37865 p->sector = sector;
37866 p->block_id = block_id;
37867 p->blksize = blksize;
37868 - p->seq_num = cpu_to_be32(atomic_inc_return(&peer_device->device->packet_seq));
37869 + p->seq_num = cpu_to_be32(atomic_inc_return_unchecked(&peer_device->device->packet_seq));
37870 return drbd_send_command(peer_device, sock, cmd, sizeof(*p), NULL, 0);
37871 }
37872
37873 @@ -1628,7 +1628,7 @@ int drbd_send_dblock(struct drbd_peer_device *peer_device, struct drbd_request *
37874 return -EIO;
37875 p->sector = cpu_to_be64(req->i.sector);
37876 p->block_id = (unsigned long)req;
37877 - p->seq_num = cpu_to_be32(atomic_inc_return(&device->packet_seq));
37878 + p->seq_num = cpu_to_be32(atomic_inc_return_unchecked(&device->packet_seq));
37879 dp_flags = bio_flags_to_wire(peer_device->connection, req->master_bio->bi_rw);
37880 if (device->state.conn >= C_SYNC_SOURCE &&
37881 device->state.conn <= C_PAUSED_SYNC_T)
37882 @@ -2658,8 +2658,8 @@ void drbd_destroy_connection(struct kref *kref)
37883 struct drbd_connection *connection = container_of(kref, struct drbd_connection, kref);
37884 struct drbd_resource *resource = connection->resource;
37885
37886 - if (atomic_read(&connection->current_epoch->epoch_size) != 0)
37887 - drbd_err(connection, "epoch_size:%d\n", atomic_read(&connection->current_epoch->epoch_size));
37888 + if (atomic_read_unchecked(&connection->current_epoch->epoch_size) != 0)
37889 + drbd_err(connection, "epoch_size:%d\n", atomic_read_unchecked(&connection->current_epoch->epoch_size));
37890 kfree(connection->current_epoch);
37891
37892 idr_destroy(&connection->peer_devices);
37893 diff --git a/drivers/block/drbd/drbd_nl.c b/drivers/block/drbd/drbd_nl.c
37894 index 526414b..4eb8184 100644
37895 --- a/drivers/block/drbd/drbd_nl.c
37896 +++ b/drivers/block/drbd/drbd_nl.c
37897 @@ -3505,7 +3505,7 @@ out:
37898
37899 void drbd_bcast_event(struct drbd_device *device, const struct sib_info *sib)
37900 {
37901 - static atomic_t drbd_genl_seq = ATOMIC_INIT(2); /* two. */
37902 + static atomic_unchecked_t drbd_genl_seq = ATOMIC_INIT(2); /* two. */
37903 struct sk_buff *msg;
37904 struct drbd_genlmsghdr *d_out;
37905 unsigned seq;
37906 @@ -3518,7 +3518,7 @@ void drbd_bcast_event(struct drbd_device *device, const struct sib_info *sib)
37907 return;
37908 }
37909
37910 - seq = atomic_inc_return(&drbd_genl_seq);
37911 + seq = atomic_inc_return_unchecked(&drbd_genl_seq);
37912 msg = genlmsg_new(NLMSG_GOODSIZE, GFP_NOIO);
37913 if (!msg)
37914 goto failed;
37915 diff --git a/drivers/block/drbd/drbd_receiver.c b/drivers/block/drbd/drbd_receiver.c
37916 index 68e3992..1aca24a 100644
37917 --- a/drivers/block/drbd/drbd_receiver.c
37918 +++ b/drivers/block/drbd/drbd_receiver.c
37919 @@ -826,7 +826,7 @@ int drbd_connected(struct drbd_peer_device *peer_device)
37920 struct drbd_device *device = peer_device->device;
37921 int err;
37922
37923 - atomic_set(&device->packet_seq, 0);
37924 + atomic_set_unchecked(&device->packet_seq, 0);
37925 device->peer_seq = 0;
37926
37927 device->state_mutex = peer_device->connection->agreed_pro_version < 100 ?
37928 @@ -1188,7 +1188,7 @@ static enum finish_epoch drbd_may_finish_epoch(struct drbd_connection *connectio
37929 do {
37930 next_epoch = NULL;
37931
37932 - epoch_size = atomic_read(&epoch->epoch_size);
37933 + epoch_size = atomic_read_unchecked(&epoch->epoch_size);
37934
37935 switch (ev & ~EV_CLEANUP) {
37936 case EV_PUT:
37937 @@ -1228,7 +1228,7 @@ static enum finish_epoch drbd_may_finish_epoch(struct drbd_connection *connectio
37938 rv = FE_DESTROYED;
37939 } else {
37940 epoch->flags = 0;
37941 - atomic_set(&epoch->epoch_size, 0);
37942 + atomic_set_unchecked(&epoch->epoch_size, 0);
37943 /* atomic_set(&epoch->active, 0); is already zero */
37944 if (rv == FE_STILL_LIVE)
37945 rv = FE_RECYCLED;
37946 @@ -1456,7 +1456,7 @@ static int receive_Barrier(struct drbd_connection *connection, struct packet_inf
37947 conn_wait_active_ee_empty(connection);
37948 drbd_flush(connection);
37949
37950 - if (atomic_read(&connection->current_epoch->epoch_size)) {
37951 + if (atomic_read_unchecked(&connection->current_epoch->epoch_size)) {
37952 epoch = kmalloc(sizeof(struct drbd_epoch), GFP_NOIO);
37953 if (epoch)
37954 break;
37955 @@ -1469,11 +1469,11 @@ static int receive_Barrier(struct drbd_connection *connection, struct packet_inf
37956 }
37957
37958 epoch->flags = 0;
37959 - atomic_set(&epoch->epoch_size, 0);
37960 + atomic_set_unchecked(&epoch->epoch_size, 0);
37961 atomic_set(&epoch->active, 0);
37962
37963 spin_lock(&connection->epoch_lock);
37964 - if (atomic_read(&connection->current_epoch->epoch_size)) {
37965 + if (atomic_read_unchecked(&connection->current_epoch->epoch_size)) {
37966 list_add(&epoch->list, &connection->current_epoch->list);
37967 connection->current_epoch = epoch;
37968 connection->epochs++;
37969 @@ -2182,7 +2182,7 @@ static int receive_Data(struct drbd_connection *connection, struct packet_info *
37970
37971 err = wait_for_and_update_peer_seq(peer_device, peer_seq);
37972 drbd_send_ack_dp(peer_device, P_NEG_ACK, p, pi->size);
37973 - atomic_inc(&connection->current_epoch->epoch_size);
37974 + atomic_inc_unchecked(&connection->current_epoch->epoch_size);
37975 err2 = drbd_drain_block(peer_device, pi->size);
37976 if (!err)
37977 err = err2;
37978 @@ -2216,7 +2216,7 @@ static int receive_Data(struct drbd_connection *connection, struct packet_info *
37979
37980 spin_lock(&connection->epoch_lock);
37981 peer_req->epoch = connection->current_epoch;
37982 - atomic_inc(&peer_req->epoch->epoch_size);
37983 + atomic_inc_unchecked(&peer_req->epoch->epoch_size);
37984 atomic_inc(&peer_req->epoch->active);
37985 spin_unlock(&connection->epoch_lock);
37986
37987 @@ -4396,7 +4396,7 @@ struct data_cmd {
37988 int expect_payload;
37989 size_t pkt_size;
37990 int (*fn)(struct drbd_connection *, struct packet_info *);
37991 -};
37992 +} __do_const;
37993
37994 static struct data_cmd drbd_cmd_handler[] = {
37995 [P_DATA] = { 1, sizeof(struct p_data), receive_Data },
37996 @@ -4506,7 +4506,7 @@ static void conn_disconnect(struct drbd_connection *connection)
37997 if (!list_empty(&connection->current_epoch->list))
37998 drbd_err(connection, "ASSERTION FAILED: connection->current_epoch->list not empty\n");
37999 /* ok, no more ee's on the fly, it is safe to reset the epoch_size */
38000 - atomic_set(&connection->current_epoch->epoch_size, 0);
38001 + atomic_set_unchecked(&connection->current_epoch->epoch_size, 0);
38002 connection->send.seen_any_write_yet = false;
38003
38004 drbd_info(connection, "Connection closed\n");
38005 @@ -5281,7 +5281,7 @@ static int connection_finish_peer_reqs(struct drbd_connection *connection)
38006 struct asender_cmd {
38007 size_t pkt_size;
38008 int (*fn)(struct drbd_connection *connection, struct packet_info *);
38009 -};
38010 +} __do_const;
38011
38012 static struct asender_cmd asender_tbl[] = {
38013 [P_PING] = { 0, got_Ping },
38014 diff --git a/drivers/block/loop.c b/drivers/block/loop.c
38015 index f70a230..9dc90d5 100644
38016 --- a/drivers/block/loop.c
38017 +++ b/drivers/block/loop.c
38018 @@ -232,7 +232,7 @@ static int __do_lo_send_write(struct file *file,
38019
38020 file_start_write(file);
38021 set_fs(get_ds());
38022 - bw = file->f_op->write(file, buf, len, &pos);
38023 + bw = file->f_op->write(file, (const char __force_user *)buf, len, &pos);
38024 set_fs(old_fs);
38025 file_end_write(file);
38026 if (likely(bw == len))
38027 diff --git a/drivers/block/null_blk.c b/drivers/block/null_blk.c
38028 index 091b9ea..f5428f8 100644
38029 --- a/drivers/block/null_blk.c
38030 +++ b/drivers/block/null_blk.c
38031 @@ -382,15 +382,25 @@ static int null_init_hctx(struct blk_mq_hw_ctx *hctx, void *data,
38032 return 0;
38033 }
38034
38035 -static struct blk_mq_ops null_mq_ops = {
38036 - .queue_rq = null_queue_rq,
38037 - .map_queue = blk_mq_map_queue,
38038 +static struct blk_mq_ops null_mq_single_ops = {
38039 + .queue_rq = null_queue_rq,
38040 + .map_queue = blk_mq_map_queue,
38041 .init_hctx = null_init_hctx,
38042 .complete = null_softirq_done_fn,
38043 + .alloc_hctx = blk_mq_alloc_single_hw_queue,
38044 + .free_hctx = blk_mq_free_single_hw_queue,
38045 +};
38046 +
38047 +static struct blk_mq_ops null_mq_per_node_ops = {
38048 + .queue_rq = null_queue_rq,
38049 + .map_queue = blk_mq_map_queue,
38050 + .init_hctx = null_init_hctx,
38051 + .alloc_hctx = null_alloc_hctx,
38052 + .free_hctx = null_free_hctx,
38053 };
38054
38055 static struct blk_mq_reg null_mq_reg = {
38056 - .ops = &null_mq_ops,
38057 + .ops = &null_mq_single_ops,
38058 .queue_depth = 64,
38059 .cmd_size = sizeof(struct nullb_cmd),
38060 .flags = BLK_MQ_F_SHOULD_MERGE,
38061 @@ -521,13 +531,8 @@ static int null_add_dev(void)
38062 null_mq_reg.queue_depth = hw_queue_depth;
38063 null_mq_reg.nr_hw_queues = submit_queues;
38064
38065 - if (use_per_node_hctx) {
38066 - null_mq_reg.ops->alloc_hctx = null_alloc_hctx;
38067 - null_mq_reg.ops->free_hctx = null_free_hctx;
38068 - } else {
38069 - null_mq_reg.ops->alloc_hctx = blk_mq_alloc_single_hw_queue;
38070 - null_mq_reg.ops->free_hctx = blk_mq_free_single_hw_queue;
38071 - }
38072 + if (use_per_node_hctx)
38073 + null_mq_reg.ops = &null_mq_per_node_ops;
38074
38075 nullb->q = blk_mq_init_queue(&null_mq_reg, nullb);
38076 } else if (queue_mode == NULL_Q_BIO) {
38077 diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c
38078 index a2af73d..c0b8f61 100644
38079 --- a/drivers/block/pktcdvd.c
38080 +++ b/drivers/block/pktcdvd.c
38081 @@ -108,7 +108,7 @@ static int pkt_seq_show(struct seq_file *m, void *p);
38082
38083 static sector_t get_zone(sector_t sector, struct pktcdvd_device *pd)
38084 {
38085 - return (sector + pd->offset) & ~(sector_t)(pd->settings.size - 1);
38086 + return (sector + pd->offset) & ~(sector_t)(pd->settings.size - 1UL);
38087 }
38088
38089 /*
38090 @@ -1888,7 +1888,7 @@ static noinline_for_stack int pkt_probe_settings(struct pktcdvd_device *pd)
38091 return -EROFS;
38092 }
38093 pd->settings.fp = ti.fp;
38094 - pd->offset = (be32_to_cpu(ti.track_start) << 2) & (pd->settings.size - 1);
38095 + pd->offset = (be32_to_cpu(ti.track_start) << 2) & (pd->settings.size - 1UL);
38096
38097 if (ti.nwa_v) {
38098 pd->nwa = be32_to_cpu(ti.next_writable);
38099 diff --git a/drivers/block/smart1,2.h b/drivers/block/smart1,2.h
38100 index e5565fb..71be10b4 100644
38101 --- a/drivers/block/smart1,2.h
38102 +++ b/drivers/block/smart1,2.h
38103 @@ -108,11 +108,11 @@ static unsigned long smart4_intr_pending(ctlr_info_t *h)
38104 }
38105
38106 static struct access_method smart4_access = {
38107 - smart4_submit_command,
38108 - smart4_intr_mask,
38109 - smart4_fifo_full,
38110 - smart4_intr_pending,
38111 - smart4_completed,
38112 + .submit_command = smart4_submit_command,
38113 + .set_intr_mask = smart4_intr_mask,
38114 + .fifo_full = smart4_fifo_full,
38115 + .intr_pending = smart4_intr_pending,
38116 + .command_completed = smart4_completed,
38117 };
38118
38119 /*
38120 @@ -144,11 +144,11 @@ static unsigned long smart2_intr_pending(ctlr_info_t *h)
38121 }
38122
38123 static struct access_method smart2_access = {
38124 - smart2_submit_command,
38125 - smart2_intr_mask,
38126 - smart2_fifo_full,
38127 - smart2_intr_pending,
38128 - smart2_completed,
38129 + .submit_command = smart2_submit_command,
38130 + .set_intr_mask = smart2_intr_mask,
38131 + .fifo_full = smart2_fifo_full,
38132 + .intr_pending = smart2_intr_pending,
38133 + .command_completed = smart2_completed,
38134 };
38135
38136 /*
38137 @@ -180,11 +180,11 @@ static unsigned long smart2e_intr_pending(ctlr_info_t *h)
38138 }
38139
38140 static struct access_method smart2e_access = {
38141 - smart2e_submit_command,
38142 - smart2e_intr_mask,
38143 - smart2e_fifo_full,
38144 - smart2e_intr_pending,
38145 - smart2e_completed,
38146 + .submit_command = smart2e_submit_command,
38147 + .set_intr_mask = smart2e_intr_mask,
38148 + .fifo_full = smart2e_fifo_full,
38149 + .intr_pending = smart2e_intr_pending,
38150 + .command_completed = smart2e_completed,
38151 };
38152
38153 /*
38154 @@ -270,9 +270,9 @@ static unsigned long smart1_intr_pending(ctlr_info_t *h)
38155 }
38156
38157 static struct access_method smart1_access = {
38158 - smart1_submit_command,
38159 - smart1_intr_mask,
38160 - smart1_fifo_full,
38161 - smart1_intr_pending,
38162 - smart1_completed,
38163 + .submit_command = smart1_submit_command,
38164 + .set_intr_mask = smart1_intr_mask,
38165 + .fifo_full = smart1_fifo_full,
38166 + .intr_pending = smart1_intr_pending,
38167 + .command_completed = smart1_completed,
38168 };
38169 diff --git a/drivers/bluetooth/btwilink.c b/drivers/bluetooth/btwilink.c
38170 index f038dba..bb74c08 100644
38171 --- a/drivers/bluetooth/btwilink.c
38172 +++ b/drivers/bluetooth/btwilink.c
38173 @@ -288,7 +288,7 @@ static int ti_st_send_frame(struct hci_dev *hdev, struct sk_buff *skb)
38174
38175 static int bt_ti_probe(struct platform_device *pdev)
38176 {
38177 - static struct ti_st *hst;
38178 + struct ti_st *hst;
38179 struct hci_dev *hdev;
38180 int err;
38181
38182 diff --git a/drivers/cdrom/cdrom.c b/drivers/cdrom/cdrom.c
38183 index 8a3aff7..d7538c2 100644
38184 --- a/drivers/cdrom/cdrom.c
38185 +++ b/drivers/cdrom/cdrom.c
38186 @@ -416,7 +416,6 @@ int register_cdrom(struct cdrom_device_info *cdi)
38187 ENSURE(reset, CDC_RESET);
38188 ENSURE(generic_packet, CDC_GENERIC_PACKET);
38189 cdi->mc_flags = 0;
38190 - cdo->n_minors = 0;
38191 cdi->options = CDO_USE_FFLAGS;
38192
38193 if (autoclose==1 && CDROM_CAN(CDC_CLOSE_TRAY))
38194 @@ -436,8 +435,11 @@ int register_cdrom(struct cdrom_device_info *cdi)
38195 else
38196 cdi->cdda_method = CDDA_OLD;
38197
38198 - if (!cdo->generic_packet)
38199 - cdo->generic_packet = cdrom_dummy_generic_packet;
38200 + if (!cdo->generic_packet) {
38201 + pax_open_kernel();
38202 + *(void **)&cdo->generic_packet = cdrom_dummy_generic_packet;
38203 + pax_close_kernel();
38204 + }
38205
38206 cdinfo(CD_REG_UNREG, "drive \"/dev/%s\" registered\n", cdi->name);
38207 mutex_lock(&cdrom_mutex);
38208 @@ -458,7 +460,6 @@ void unregister_cdrom(struct cdrom_device_info *cdi)
38209 if (cdi->exit)
38210 cdi->exit(cdi);
38211
38212 - cdi->ops->n_minors--;
38213 cdinfo(CD_REG_UNREG, "drive \"/dev/%s\" unregistered\n", cdi->name);
38214 }
38215
38216 @@ -2107,7 +2108,7 @@ static int cdrom_read_cdda_old(struct cdrom_device_info *cdi, __u8 __user *ubuf,
38217 */
38218 nr = nframes;
38219 do {
38220 - cgc.buffer = kmalloc(CD_FRAMESIZE_RAW * nr, GFP_KERNEL);
38221 + cgc.buffer = kzalloc(CD_FRAMESIZE_RAW * nr, GFP_KERNEL);
38222 if (cgc.buffer)
38223 break;
38224
38225 @@ -3429,7 +3430,7 @@ static int cdrom_print_info(const char *header, int val, char *info,
38226 struct cdrom_device_info *cdi;
38227 int ret;
38228
38229 - ret = scnprintf(info + *pos, max_size - *pos, header);
38230 + ret = scnprintf(info + *pos, max_size - *pos, "%s", header);
38231 if (!ret)
38232 return 1;
38233
38234 diff --git a/drivers/cdrom/gdrom.c b/drivers/cdrom/gdrom.c
38235 index 51e75ad..39c4c76 100644
38236 --- a/drivers/cdrom/gdrom.c
38237 +++ b/drivers/cdrom/gdrom.c
38238 @@ -491,7 +491,6 @@ static struct cdrom_device_ops gdrom_ops = {
38239 .audio_ioctl = gdrom_audio_ioctl,
38240 .capability = CDC_MULTI_SESSION | CDC_MEDIA_CHANGED |
38241 CDC_RESET | CDC_DRIVE_STATUS | CDC_CD_R,
38242 - .n_minors = 1,
38243 };
38244
38245 static int gdrom_bdops_open(struct block_device *bdev, fmode_t mode)
38246 diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig
38247 index 6e9f74a..50c7ceae 100644
38248 --- a/drivers/char/Kconfig
38249 +++ b/drivers/char/Kconfig
38250 @@ -8,7 +8,8 @@ source "drivers/tty/Kconfig"
38251
38252 config DEVKMEM
38253 bool "/dev/kmem virtual device support"
38254 - default y
38255 + default n
38256 + depends on !GRKERNSEC_KMEM
38257 help
38258 Say Y here if you want to support the /dev/kmem device. The
38259 /dev/kmem device is rarely used, but can be used for certain
38260 @@ -577,6 +578,7 @@ config DEVPORT
38261 bool
38262 depends on !M68K
38263 depends on ISA || PCI
38264 + depends on !GRKERNSEC_KMEM
38265 default y
38266
38267 source "drivers/s390/char/Kconfig"
38268 diff --git a/drivers/char/agp/compat_ioctl.c b/drivers/char/agp/compat_ioctl.c
38269 index a48e05b..6bac831 100644
38270 --- a/drivers/char/agp/compat_ioctl.c
38271 +++ b/drivers/char/agp/compat_ioctl.c
38272 @@ -108,7 +108,7 @@ static int compat_agpioc_reserve_wrap(struct agp_file_private *priv, void __user
38273 return -ENOMEM;
38274 }
38275
38276 - if (copy_from_user(usegment, (void __user *) ureserve.seg_list,
38277 + if (copy_from_user(usegment, (void __force_user *) ureserve.seg_list,
38278 sizeof(*usegment) * ureserve.seg_count)) {
38279 kfree(usegment);
38280 kfree(ksegment);
38281 diff --git a/drivers/char/agp/frontend.c b/drivers/char/agp/frontend.c
38282 index b297033..fa217ca 100644
38283 --- a/drivers/char/agp/frontend.c
38284 +++ b/drivers/char/agp/frontend.c
38285 @@ -819,7 +819,7 @@ static int agpioc_reserve_wrap(struct agp_file_private *priv, void __user *arg)
38286 if (copy_from_user(&reserve, arg, sizeof(struct agp_region)))
38287 return -EFAULT;
38288
38289 - if ((unsigned) reserve.seg_count >= ~0U/sizeof(struct agp_segment))
38290 + if ((unsigned) reserve.seg_count >= ~0U/sizeof(struct agp_segment_priv))
38291 return -EFAULT;
38292
38293 client = agp_find_client_by_pid(reserve.pid);
38294 @@ -849,7 +849,7 @@ static int agpioc_reserve_wrap(struct agp_file_private *priv, void __user *arg)
38295 if (segment == NULL)
38296 return -ENOMEM;
38297
38298 - if (copy_from_user(segment, (void __user *) reserve.seg_list,
38299 + if (copy_from_user(segment, (void __force_user *) reserve.seg_list,
38300 sizeof(struct agp_segment) * reserve.seg_count)) {
38301 kfree(segment);
38302 return -EFAULT;
38303 diff --git a/drivers/char/genrtc.c b/drivers/char/genrtc.c
38304 index 4f94375..413694e 100644
38305 --- a/drivers/char/genrtc.c
38306 +++ b/drivers/char/genrtc.c
38307 @@ -273,6 +273,7 @@ static int gen_rtc_ioctl(struct file *file,
38308 switch (cmd) {
38309
38310 case RTC_PLL_GET:
38311 + memset(&pll, 0, sizeof(pll));
38312 if (get_rtc_pll(&pll))
38313 return -EINVAL;
38314 else
38315 diff --git a/drivers/char/hpet.c b/drivers/char/hpet.c
38316 index d5d4cd8..22d561d 100644
38317 --- a/drivers/char/hpet.c
38318 +++ b/drivers/char/hpet.c
38319 @@ -575,7 +575,7 @@ static inline unsigned long hpet_time_div(struct hpets *hpets,
38320 }
38321
38322 static int
38323 -hpet_ioctl_common(struct hpet_dev *devp, int cmd, unsigned long arg,
38324 +hpet_ioctl_common(struct hpet_dev *devp, unsigned int cmd, unsigned long arg,
38325 struct hpet_info *info)
38326 {
38327 struct hpet_timer __iomem *timer;
38328 diff --git a/drivers/char/hw_random/intel-rng.c b/drivers/char/hw_random/intel-rng.c
38329 index 86fe45c..c0ea948 100644
38330 --- a/drivers/char/hw_random/intel-rng.c
38331 +++ b/drivers/char/hw_random/intel-rng.c
38332 @@ -314,7 +314,7 @@ PFX "RNG, try using the 'no_fwh_detect' option.\n";
38333
38334 if (no_fwh_detect)
38335 return -ENODEV;
38336 - printk(warning);
38337 + printk("%s", warning);
38338 return -EBUSY;
38339 }
38340
38341 diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c
38342 index e6db938..835e3a2 100644
38343 --- a/drivers/char/ipmi/ipmi_msghandler.c
38344 +++ b/drivers/char/ipmi/ipmi_msghandler.c
38345 @@ -438,7 +438,7 @@ struct ipmi_smi {
38346 struct proc_dir_entry *proc_dir;
38347 char proc_dir_name[10];
38348
38349 - atomic_t stats[IPMI_NUM_STATS];
38350 + atomic_unchecked_t stats[IPMI_NUM_STATS];
38351
38352 /*
38353 * run_to_completion duplicate of smb_info, smi_info
38354 @@ -470,9 +470,9 @@ static LIST_HEAD(smi_watchers);
38355 static DEFINE_MUTEX(smi_watchers_mutex);
38356
38357 #define ipmi_inc_stat(intf, stat) \
38358 - atomic_inc(&(intf)->stats[IPMI_STAT_ ## stat])
38359 + atomic_inc_unchecked(&(intf)->stats[IPMI_STAT_ ## stat])
38360 #define ipmi_get_stat(intf, stat) \
38361 - ((unsigned int) atomic_read(&(intf)->stats[IPMI_STAT_ ## stat]))
38362 + ((unsigned int) atomic_read_unchecked(&(intf)->stats[IPMI_STAT_ ## stat]))
38363
38364 static int is_lan_addr(struct ipmi_addr *addr)
38365 {
38366 @@ -2926,7 +2926,7 @@ int ipmi_register_smi(struct ipmi_smi_handlers *handlers,
38367 INIT_LIST_HEAD(&intf->cmd_rcvrs);
38368 init_waitqueue_head(&intf->waitq);
38369 for (i = 0; i < IPMI_NUM_STATS; i++)
38370 - atomic_set(&intf->stats[i], 0);
38371 + atomic_set_unchecked(&intf->stats[i], 0);
38372
38373 intf->proc_dir = NULL;
38374
38375 diff --git a/drivers/char/ipmi/ipmi_si_intf.c b/drivers/char/ipmi/ipmi_si_intf.c
38376 index 1c4bb4f..719e873 100644
38377 --- a/drivers/char/ipmi/ipmi_si_intf.c
38378 +++ b/drivers/char/ipmi/ipmi_si_intf.c
38379 @@ -285,7 +285,7 @@ struct smi_info {
38380 unsigned char slave_addr;
38381
38382 /* Counters and things for the proc filesystem. */
38383 - atomic_t stats[SI_NUM_STATS];
38384 + atomic_unchecked_t stats[SI_NUM_STATS];
38385
38386 struct task_struct *thread;
38387
38388 @@ -294,9 +294,9 @@ struct smi_info {
38389 };
38390
38391 #define smi_inc_stat(smi, stat) \
38392 - atomic_inc(&(smi)->stats[SI_STAT_ ## stat])
38393 + atomic_inc_unchecked(&(smi)->stats[SI_STAT_ ## stat])
38394 #define smi_get_stat(smi, stat) \
38395 - ((unsigned int) atomic_read(&(smi)->stats[SI_STAT_ ## stat]))
38396 + ((unsigned int) atomic_read_unchecked(&(smi)->stats[SI_STAT_ ## stat]))
38397
38398 #define SI_MAX_PARMS 4
38399
38400 @@ -3374,7 +3374,7 @@ static int try_smi_init(struct smi_info *new_smi)
38401 atomic_set(&new_smi->req_events, 0);
38402 new_smi->run_to_completion = false;
38403 for (i = 0; i < SI_NUM_STATS; i++)
38404 - atomic_set(&new_smi->stats[i], 0);
38405 + atomic_set_unchecked(&new_smi->stats[i], 0);
38406
38407 new_smi->interrupt_disabled = true;
38408 atomic_set(&new_smi->stop_operation, 0);
38409 diff --git a/drivers/char/mem.c b/drivers/char/mem.c
38410 index 917403f..dddd899 100644
38411 --- a/drivers/char/mem.c
38412 +++ b/drivers/char/mem.c
38413 @@ -18,6 +18,7 @@
38414 #include <linux/raw.h>
38415 #include <linux/tty.h>
38416 #include <linux/capability.h>
38417 +#include <linux/security.h>
38418 #include <linux/ptrace.h>
38419 #include <linux/device.h>
38420 #include <linux/highmem.h>
38421 @@ -36,6 +37,10 @@
38422
38423 #define DEVPORT_MINOR 4
38424
38425 +#if defined(CONFIG_GRKERNSEC) && !defined(CONFIG_GRKERNSEC_NO_RBAC)
38426 +extern const struct file_operations grsec_fops;
38427 +#endif
38428 +
38429 static inline unsigned long size_inside_page(unsigned long start,
38430 unsigned long size)
38431 {
38432 @@ -67,9 +72,13 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size)
38433
38434 while (cursor < to) {
38435 if (!devmem_is_allowed(pfn)) {
38436 +#ifdef CONFIG_GRKERNSEC_KMEM
38437 + gr_handle_mem_readwrite(from, to);
38438 +#else
38439 printk(KERN_INFO
38440 "Program %s tried to access /dev/mem between %Lx->%Lx.\n",
38441 current->comm, from, to);
38442 +#endif
38443 return 0;
38444 }
38445 cursor += PAGE_SIZE;
38446 @@ -77,6 +86,11 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size)
38447 }
38448 return 1;
38449 }
38450 +#elif defined(CONFIG_GRKERNSEC_KMEM)
38451 +static inline int range_is_allowed(unsigned long pfn, unsigned long size)
38452 +{
38453 + return 0;
38454 +}
38455 #else
38456 static inline int range_is_allowed(unsigned long pfn, unsigned long size)
38457 {
38458 @@ -122,6 +136,7 @@ static ssize_t read_mem(struct file *file, char __user *buf,
38459
38460 while (count > 0) {
38461 unsigned long remaining;
38462 + char *temp;
38463
38464 sz = size_inside_page(p, count);
38465
38466 @@ -137,7 +152,23 @@ static ssize_t read_mem(struct file *file, char __user *buf,
38467 if (!ptr)
38468 return -EFAULT;
38469
38470 - remaining = copy_to_user(buf, ptr, sz);
38471 +#ifdef CONFIG_PAX_USERCOPY
38472 + temp = kmalloc(sz, GFP_KERNEL|GFP_USERCOPY);
38473 + if (!temp) {
38474 + unxlate_dev_mem_ptr(p, ptr);
38475 + return -ENOMEM;
38476 + }
38477 + memcpy(temp, ptr, sz);
38478 +#else
38479 + temp = ptr;
38480 +#endif
38481 +
38482 + remaining = copy_to_user(buf, temp, sz);
38483 +
38484 +#ifdef CONFIG_PAX_USERCOPY
38485 + kfree(temp);
38486 +#endif
38487 +
38488 unxlate_dev_mem_ptr(p, ptr);
38489 if (remaining)
38490 return -EFAULT;
38491 @@ -369,9 +400,8 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
38492 size_t count, loff_t *ppos)
38493 {
38494 unsigned long p = *ppos;
38495 - ssize_t low_count, read, sz;
38496 + ssize_t low_count, read, sz, err = 0;
38497 char *kbuf; /* k-addr because vread() takes vmlist_lock rwlock */
38498 - int err = 0;
38499
38500 read = 0;
38501 if (p < (unsigned long) high_memory) {
38502 @@ -393,6 +423,8 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
38503 }
38504 #endif
38505 while (low_count > 0) {
38506 + char *temp;
38507 +
38508 sz = size_inside_page(p, low_count);
38509
38510 /*
38511 @@ -402,7 +434,22 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
38512 */
38513 kbuf = xlate_dev_kmem_ptr((char *)p);
38514
38515 - if (copy_to_user(buf, kbuf, sz))
38516 +#ifdef CONFIG_PAX_USERCOPY
38517 + temp = kmalloc(sz, GFP_KERNEL|GFP_USERCOPY);
38518 + if (!temp)
38519 + return -ENOMEM;
38520 + memcpy(temp, kbuf, sz);
38521 +#else
38522 + temp = kbuf;
38523 +#endif
38524 +
38525 + err = copy_to_user(buf, temp, sz);
38526 +
38527 +#ifdef CONFIG_PAX_USERCOPY
38528 + kfree(temp);
38529 +#endif
38530 +
38531 + if (err)
38532 return -EFAULT;
38533 buf += sz;
38534 p += sz;
38535 @@ -827,6 +874,9 @@ static const struct memdev {
38536 #ifdef CONFIG_PRINTK
38537 [11] = { "kmsg", 0644, &kmsg_fops, NULL },
38538 #endif
38539 +#if defined(CONFIG_GRKERNSEC) && !defined(CONFIG_GRKERNSEC_NO_RBAC)
38540 + [13] = { "grsec",S_IRUSR | S_IWUGO, &grsec_fops, NULL },
38541 +#endif
38542 };
38543
38544 static int memory_open(struct inode *inode, struct file *filp)
38545 @@ -898,7 +948,7 @@ static int __init chr_dev_init(void)
38546 continue;
38547
38548 device_create(mem_class, NULL, MKDEV(MEM_MAJOR, minor),
38549 - NULL, devlist[minor].name);
38550 + NULL, "%s", devlist[minor].name);
38551 }
38552
38553 return tty_init();
38554 diff --git a/drivers/char/nvram.c b/drivers/char/nvram.c
38555 index 9df78e2..01ba9ae 100644
38556 --- a/drivers/char/nvram.c
38557 +++ b/drivers/char/nvram.c
38558 @@ -247,7 +247,7 @@ static ssize_t nvram_read(struct file *file, char __user *buf,
38559
38560 spin_unlock_irq(&rtc_lock);
38561
38562 - if (copy_to_user(buf, contents, tmp - contents))
38563 + if (tmp - contents > sizeof(contents) || copy_to_user(buf, contents, tmp - contents))
38564 return -EFAULT;
38565
38566 *ppos = i;
38567 diff --git a/drivers/char/pcmcia/synclink_cs.c b/drivers/char/pcmcia/synclink_cs.c
38568 index 8320abd..ec48108 100644
38569 --- a/drivers/char/pcmcia/synclink_cs.c
38570 +++ b/drivers/char/pcmcia/synclink_cs.c
38571 @@ -2345,9 +2345,9 @@ static void mgslpc_close(struct tty_struct *tty, struct file * filp)
38572
38573 if (debug_level >= DEBUG_LEVEL_INFO)
38574 printk("%s(%d):mgslpc_close(%s) entry, count=%d\n",
38575 - __FILE__, __LINE__, info->device_name, port->count);
38576 + __FILE__, __LINE__, info->device_name, atomic_read(&port->count));
38577
38578 - WARN_ON(!port->count);
38579 + WARN_ON(!atomic_read(&port->count));
38580
38581 if (tty_port_close_start(port, tty, filp) == 0)
38582 goto cleanup;
38583 @@ -2365,7 +2365,7 @@ static void mgslpc_close(struct tty_struct *tty, struct file * filp)
38584 cleanup:
38585 if (debug_level >= DEBUG_LEVEL_INFO)
38586 printk("%s(%d):mgslpc_close(%s) exit, count=%d\n", __FILE__, __LINE__,
38587 - tty->driver->name, port->count);
38588 + tty->driver->name, atomic_read(&port->count));
38589 }
38590
38591 /* Wait until the transmitter is empty.
38592 @@ -2507,7 +2507,7 @@ static int mgslpc_open(struct tty_struct *tty, struct file * filp)
38593
38594 if (debug_level >= DEBUG_LEVEL_INFO)
38595 printk("%s(%d):mgslpc_open(%s), old ref count = %d\n",
38596 - __FILE__, __LINE__, tty->driver->name, port->count);
38597 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
38598
38599 /* If port is closing, signal caller to try again */
38600 if (tty_hung_up_p(filp) || port->flags & ASYNC_CLOSING){
38601 @@ -2527,11 +2527,11 @@ static int mgslpc_open(struct tty_struct *tty, struct file * filp)
38602 goto cleanup;
38603 }
38604 spin_lock(&port->lock);
38605 - port->count++;
38606 + atomic_inc(&port->count);
38607 spin_unlock(&port->lock);
38608 spin_unlock_irqrestore(&info->netlock, flags);
38609
38610 - if (port->count == 1) {
38611 + if (atomic_read(&port->count) == 1) {
38612 /* 1st open on this device, init hardware */
38613 retval = startup(info, tty);
38614 if (retval < 0)
38615 @@ -3920,7 +3920,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
38616 unsigned short new_crctype;
38617
38618 /* return error if TTY interface open */
38619 - if (info->port.count)
38620 + if (atomic_read(&info->port.count))
38621 return -EBUSY;
38622
38623 switch (encoding)
38624 @@ -4024,7 +4024,7 @@ static int hdlcdev_open(struct net_device *dev)
38625
38626 /* arbitrate between network and tty opens */
38627 spin_lock_irqsave(&info->netlock, flags);
38628 - if (info->port.count != 0 || info->netcount != 0) {
38629 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
38630 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name);
38631 spin_unlock_irqrestore(&info->netlock, flags);
38632 return -EBUSY;
38633 @@ -4114,7 +4114,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
38634 printk("%s:hdlcdev_ioctl(%s)\n", __FILE__, dev->name);
38635
38636 /* return error if TTY interface open */
38637 - if (info->port.count)
38638 + if (atomic_read(&info->port.count))
38639 return -EBUSY;
38640
38641 if (cmd != SIOCWANDEV)
38642 diff --git a/drivers/char/random.c b/drivers/char/random.c
38643 index 102c50d..1295f12 100644
38644 --- a/drivers/char/random.c
38645 +++ b/drivers/char/random.c
38646 @@ -270,10 +270,17 @@
38647 /*
38648 * Configuration information
38649 */
38650 +#ifdef CONFIG_GRKERNSEC_RANDNET
38651 +#define INPUT_POOL_SHIFT 14
38652 +#define INPUT_POOL_WORDS (1 << (INPUT_POOL_SHIFT-5))
38653 +#define OUTPUT_POOL_SHIFT 12
38654 +#define OUTPUT_POOL_WORDS (1 << (OUTPUT_POOL_SHIFT-5))
38655 +#else
38656 #define INPUT_POOL_SHIFT 12
38657 #define INPUT_POOL_WORDS (1 << (INPUT_POOL_SHIFT-5))
38658 #define OUTPUT_POOL_SHIFT 10
38659 #define OUTPUT_POOL_WORDS (1 << (OUTPUT_POOL_SHIFT-5))
38660 +#endif
38661 #define SEC_XFER_SIZE 512
38662 #define EXTRACT_SIZE 10
38663
38664 @@ -284,9 +291,6 @@
38665 /*
38666 * To allow fractional bits to be tracked, the entropy_count field is
38667 * denominated in units of 1/8th bits.
38668 - *
38669 - * 2*(ENTROPY_SHIFT + log2(poolbits)) must <= 31, or the multiply in
38670 - * credit_entropy_bits() needs to be 64 bits wide.
38671 */
38672 #define ENTROPY_SHIFT 3
38673 #define ENTROPY_BITS(r) ((r)->entropy_count >> ENTROPY_SHIFT)
38674 @@ -361,12 +365,19 @@ static struct poolinfo {
38675 #define S(x) ilog2(x)+5, (x), (x)*4, (x)*32, (x) << (ENTROPY_SHIFT+5)
38676 int tap1, tap2, tap3, tap4, tap5;
38677 } poolinfo_table[] = {
38678 +#ifdef CONFIG_GRKERNSEC_RANDNET
38679 + /* x^512 + x^411 + x^308 + x^208 +x^104 + x + 1 -- 225 */
38680 + { S(512), 411, 308, 208, 104, 1 },
38681 + /* x^128 + x^104 + x^76 + x^51 + x^25 + x + 1 -- 105 */
38682 + { S(128), 104, 76, 51, 25, 1 },
38683 +#else
38684 /* was: x^128 + x^103 + x^76 + x^51 +x^25 + x + 1 */
38685 /* x^128 + x^104 + x^76 + x^51 +x^25 + x + 1 */
38686 { S(128), 104, 76, 51, 25, 1 },
38687 /* was: x^32 + x^26 + x^20 + x^14 + x^7 + x + 1 */
38688 /* x^32 + x^26 + x^19 + x^14 + x^7 + x + 1 */
38689 { S(32), 26, 19, 14, 7, 1 },
38690 +#endif
38691 #if 0
38692 /* x^2048 + x^1638 + x^1231 + x^819 + x^411 + x + 1 -- 115 */
38693 { S(2048), 1638, 1231, 819, 411, 1 },
38694 @@ -433,9 +444,9 @@ struct entropy_store {
38695 };
38696
38697 static void push_to_pool(struct work_struct *work);
38698 -static __u32 input_pool_data[INPUT_POOL_WORDS];
38699 -static __u32 blocking_pool_data[OUTPUT_POOL_WORDS];
38700 -static __u32 nonblocking_pool_data[OUTPUT_POOL_WORDS];
38701 +static __u32 input_pool_data[INPUT_POOL_WORDS] __latent_entropy;
38702 +static __u32 blocking_pool_data[OUTPUT_POOL_WORDS] __latent_entropy;
38703 +static __u32 nonblocking_pool_data[OUTPUT_POOL_WORDS] __latent_entropy;
38704
38705 static struct entropy_store input_pool = {
38706 .poolinfo = &poolinfo_table[0],
38707 @@ -524,8 +535,8 @@ static void _mix_pool_bytes(struct entropy_store *r, const void *in,
38708 input_rotate = (input_rotate + (i ? 7 : 14)) & 31;
38709 }
38710
38711 - ACCESS_ONCE(r->input_rotate) = input_rotate;
38712 - ACCESS_ONCE(r->add_ptr) = i;
38713 + ACCESS_ONCE_RW(r->input_rotate) = input_rotate;
38714 + ACCESS_ONCE_RW(r->add_ptr) = i;
38715 smp_wmb();
38716
38717 if (out)
38718 @@ -632,7 +643,7 @@ retry:
38719 /* The +2 corresponds to the /4 in the denominator */
38720
38721 do {
38722 - unsigned int anfrac = min(pnfrac, pool_size/2);
38723 + u64 anfrac = min(pnfrac, pool_size/2);
38724 unsigned int add =
38725 ((pool_size - entropy_count)*anfrac*3) >> s;
38726
38727 @@ -1165,7 +1176,7 @@ static ssize_t extract_entropy_user(struct entropy_store *r, void __user *buf,
38728
38729 extract_buf(r, tmp);
38730 i = min_t(int, nbytes, EXTRACT_SIZE);
38731 - if (copy_to_user(buf, tmp, i)) {
38732 + if (i > sizeof(tmp) || copy_to_user(buf, tmp, i)) {
38733 ret = -EFAULT;
38734 break;
38735 }
38736 @@ -1554,7 +1565,7 @@ static char sysctl_bootid[16];
38737 static int proc_do_uuid(struct ctl_table *table, int write,
38738 void __user *buffer, size_t *lenp, loff_t *ppos)
38739 {
38740 - struct ctl_table fake_table;
38741 + ctl_table_no_const fake_table;
38742 unsigned char buf[64], tmp_uuid[16], *uuid;
38743
38744 uuid = table->data;
38745 @@ -1584,7 +1595,7 @@ static int proc_do_uuid(struct ctl_table *table, int write,
38746 static int proc_do_entropy(ctl_table *table, int write,
38747 void __user *buffer, size_t *lenp, loff_t *ppos)
38748 {
38749 - ctl_table fake_table;
38750 + ctl_table_no_const fake_table;
38751 int entropy_count;
38752
38753 entropy_count = *(int *)table->data >> ENTROPY_SHIFT;
38754 diff --git a/drivers/char/sonypi.c b/drivers/char/sonypi.c
38755 index 7cc1fe22..b602d6b 100644
38756 --- a/drivers/char/sonypi.c
38757 +++ b/drivers/char/sonypi.c
38758 @@ -54,6 +54,7 @@
38759
38760 #include <asm/uaccess.h>
38761 #include <asm/io.h>
38762 +#include <asm/local.h>
38763
38764 #include <linux/sonypi.h>
38765
38766 @@ -490,7 +491,7 @@ static struct sonypi_device {
38767 spinlock_t fifo_lock;
38768 wait_queue_head_t fifo_proc_list;
38769 struct fasync_struct *fifo_async;
38770 - int open_count;
38771 + local_t open_count;
38772 int model;
38773 struct input_dev *input_jog_dev;
38774 struct input_dev *input_key_dev;
38775 @@ -892,7 +893,7 @@ static int sonypi_misc_fasync(int fd, struct file *filp, int on)
38776 static int sonypi_misc_release(struct inode *inode, struct file *file)
38777 {
38778 mutex_lock(&sonypi_device.lock);
38779 - sonypi_device.open_count--;
38780 + local_dec(&sonypi_device.open_count);
38781 mutex_unlock(&sonypi_device.lock);
38782 return 0;
38783 }
38784 @@ -901,9 +902,9 @@ static int sonypi_misc_open(struct inode *inode, struct file *file)
38785 {
38786 mutex_lock(&sonypi_device.lock);
38787 /* Flush input queue on first open */
38788 - if (!sonypi_device.open_count)
38789 + if (!local_read(&sonypi_device.open_count))
38790 kfifo_reset(&sonypi_device.fifo);
38791 - sonypi_device.open_count++;
38792 + local_inc(&sonypi_device.open_count);
38793 mutex_unlock(&sonypi_device.lock);
38794
38795 return 0;
38796 diff --git a/drivers/char/tpm/tpm_acpi.c b/drivers/char/tpm/tpm_acpi.c
38797 index b9a57fa..5bb9e38 100644
38798 --- a/drivers/char/tpm/tpm_acpi.c
38799 +++ b/drivers/char/tpm/tpm_acpi.c
38800 @@ -98,11 +98,12 @@ int read_log(struct tpm_bios_log *log)
38801 virt = acpi_os_map_memory(start, len);
38802 if (!virt) {
38803 kfree(log->bios_event_log);
38804 + log->bios_event_log = NULL;
38805 printk("%s: ERROR - Unable to map memory\n", __func__);
38806 return -EIO;
38807 }
38808
38809 - memcpy_fromio(log->bios_event_log, virt, len);
38810 + memcpy_fromio(log->bios_event_log, (const char __force_kernel *)virt, len);
38811
38812 acpi_os_unmap_memory(virt, len);
38813 return 0;
38814 diff --git a/drivers/char/tpm/tpm_eventlog.c b/drivers/char/tpm/tpm_eventlog.c
38815 index 59f7cb2..bac8b6d 100644
38816 --- a/drivers/char/tpm/tpm_eventlog.c
38817 +++ b/drivers/char/tpm/tpm_eventlog.c
38818 @@ -95,7 +95,7 @@ static void *tpm_bios_measurements_start(struct seq_file *m, loff_t *pos)
38819 event = addr;
38820
38821 if ((event->event_type == 0 && event->event_size == 0) ||
38822 - ((addr + sizeof(struct tcpa_event) + event->event_size) >= limit))
38823 + (event->event_size >= limit - addr - sizeof(struct tcpa_event)))
38824 return NULL;
38825
38826 return addr;
38827 @@ -120,7 +120,7 @@ static void *tpm_bios_measurements_next(struct seq_file *m, void *v,
38828 return NULL;
38829
38830 if ((event->event_type == 0 && event->event_size == 0) ||
38831 - ((v + sizeof(struct tcpa_event) + event->event_size) >= limit))
38832 + (event->event_size >= limit - v - sizeof(struct tcpa_event)))
38833 return NULL;
38834
38835 (*pos)++;
38836 @@ -213,7 +213,8 @@ static int tpm_binary_bios_measurements_show(struct seq_file *m, void *v)
38837 int i;
38838
38839 for (i = 0; i < sizeof(struct tcpa_event) + event->event_size; i++)
38840 - seq_putc(m, data[i]);
38841 + if (!seq_putc(m, data[i]))
38842 + return -EFAULT;
38843
38844 return 0;
38845 }
38846 diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c
38847 index 60aafb8..10c08e0 100644
38848 --- a/drivers/char/virtio_console.c
38849 +++ b/drivers/char/virtio_console.c
38850 @@ -684,7 +684,7 @@ static ssize_t fill_readbuf(struct port *port, char *out_buf, size_t out_count,
38851 if (to_user) {
38852 ssize_t ret;
38853
38854 - ret = copy_to_user(out_buf, buf->buf + buf->offset, out_count);
38855 + ret = copy_to_user((char __force_user *)out_buf, buf->buf + buf->offset, out_count);
38856 if (ret)
38857 return -EFAULT;
38858 } else {
38859 @@ -787,7 +787,7 @@ static ssize_t port_fops_read(struct file *filp, char __user *ubuf,
38860 if (!port_has_data(port) && !port->host_connected)
38861 return 0;
38862
38863 - return fill_readbuf(port, ubuf, count, true);
38864 + return fill_readbuf(port, (char __force_kernel *)ubuf, count, true);
38865 }
38866
38867 static int wait_port_writable(struct port *port, bool nonblock)
38868 diff --git a/drivers/clk/clk-composite.c b/drivers/clk/clk-composite.c
38869 index 57a078e..c17cde8 100644
38870 --- a/drivers/clk/clk-composite.c
38871 +++ b/drivers/clk/clk-composite.c
38872 @@ -146,7 +146,7 @@ struct clk *clk_register_composite(struct device *dev, const char *name,
38873 struct clk *clk;
38874 struct clk_init_data init;
38875 struct clk_composite *composite;
38876 - struct clk_ops *clk_composite_ops;
38877 + clk_ops_no_const *clk_composite_ops;
38878
38879 composite = kzalloc(sizeof(*composite), GFP_KERNEL);
38880 if (!composite) {
38881 diff --git a/drivers/clk/socfpga/clk-gate.c b/drivers/clk/socfpga/clk-gate.c
38882 index 501d513..fb0ecf9 100644
38883 --- a/drivers/clk/socfpga/clk-gate.c
38884 +++ b/drivers/clk/socfpga/clk-gate.c
38885 @@ -22,6 +22,7 @@
38886 #include <linux/mfd/syscon.h>
38887 #include <linux/of.h>
38888 #include <linux/regmap.h>
38889 +#include <asm/pgtable.h>
38890
38891 #include "clk.h"
38892
38893 @@ -175,7 +176,7 @@ static int socfpga_clk_prepare(struct clk_hw *hwclk)
38894 return 0;
38895 }
38896
38897 -static struct clk_ops gateclk_ops = {
38898 +static clk_ops_no_const gateclk_ops __read_only = {
38899 .prepare = socfpga_clk_prepare,
38900 .recalc_rate = socfpga_clk_recalc_rate,
38901 .get_parent = socfpga_clk_get_parent,
38902 @@ -209,8 +210,10 @@ static void __init __socfpga_gate_init(struct device_node *node,
38903 socfpga_clk->hw.reg = clk_mgr_base_addr + clk_gate[0];
38904 socfpga_clk->hw.bit_idx = clk_gate[1];
38905
38906 - gateclk_ops.enable = clk_gate_ops.enable;
38907 - gateclk_ops.disable = clk_gate_ops.disable;
38908 + pax_open_kernel();
38909 + *(void **)&gateclk_ops.enable = clk_gate_ops.enable;
38910 + *(void **)&gateclk_ops.disable = clk_gate_ops.disable;
38911 + pax_close_kernel();
38912 }
38913
38914 rc = of_property_read_u32(node, "fixed-divider", &fixed_div);
38915 diff --git a/drivers/clk/socfpga/clk-pll.c b/drivers/clk/socfpga/clk-pll.c
38916 index de6da95..a2e72c0 100644
38917 --- a/drivers/clk/socfpga/clk-pll.c
38918 +++ b/drivers/clk/socfpga/clk-pll.c
38919 @@ -21,6 +21,7 @@
38920 #include <linux/io.h>
38921 #include <linux/of.h>
38922 #include <linux/of_address.h>
38923 +#include <asm/pgtable.h>
38924
38925 #include "clk.h"
38926
38927 @@ -76,7 +77,7 @@ static u8 clk_pll_get_parent(struct clk_hw *hwclk)
38928 CLK_MGR_PLL_CLK_SRC_MASK;
38929 }
38930
38931 -static struct clk_ops clk_pll_ops = {
38932 +static struct clk_ops_no_const clk_pll_ops __read_only = {
38933 .recalc_rate = clk_pll_recalc_rate,
38934 .get_parent = clk_pll_get_parent,
38935 };
38936 @@ -120,8 +121,10 @@ static __init struct clk *__socfpga_pll_init(struct device_node *node,
38937 pll_clk->hw.hw.init = &init;
38938
38939 pll_clk->hw.bit_idx = SOCFPGA_PLL_EXT_ENA;
38940 - clk_pll_ops.enable = clk_gate_ops.enable;
38941 - clk_pll_ops.disable = clk_gate_ops.disable;
38942 + pax_open_kernel();
38943 + *(void **)&clk_pll_ops.enable = clk_gate_ops.enable;
38944 + *(void **)&clk_pll_ops.disable = clk_gate_ops.disable;
38945 + pax_close_kernel();
38946
38947 clk = clk_register(NULL, &pll_clk->hw.hw);
38948 if (WARN_ON(IS_ERR(clk))) {
38949 diff --git a/drivers/cpufreq/acpi-cpufreq.c b/drivers/cpufreq/acpi-cpufreq.c
38950 index 000e4e0..4770351 100644
38951 --- a/drivers/cpufreq/acpi-cpufreq.c
38952 +++ b/drivers/cpufreq/acpi-cpufreq.c
38953 @@ -676,8 +676,11 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
38954 data->acpi_data = per_cpu_ptr(acpi_perf_data, cpu);
38955 per_cpu(acfreq_data, cpu) = data;
38956
38957 - if (cpu_has(c, X86_FEATURE_CONSTANT_TSC))
38958 - acpi_cpufreq_driver.flags |= CPUFREQ_CONST_LOOPS;
38959 + if (cpu_has(c, X86_FEATURE_CONSTANT_TSC)) {
38960 + pax_open_kernel();
38961 + *(u8 *)&acpi_cpufreq_driver.flags |= CPUFREQ_CONST_LOOPS;
38962 + pax_close_kernel();
38963 + }
38964
38965 result = acpi_processor_register_performance(data->acpi_data, cpu);
38966 if (result)
38967 @@ -810,7 +813,9 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
38968 policy->cur = acpi_cpufreq_guess_freq(data, policy->cpu);
38969 break;
38970 case ACPI_ADR_SPACE_FIXED_HARDWARE:
38971 - acpi_cpufreq_driver.get = get_cur_freq_on_cpu;
38972 + pax_open_kernel();
38973 + *(void **)&acpi_cpufreq_driver.get = get_cur_freq_on_cpu;
38974 + pax_close_kernel();
38975 break;
38976 default:
38977 break;
38978 @@ -904,8 +909,10 @@ static void __init acpi_cpufreq_boost_init(void)
38979 if (!msrs)
38980 return;
38981
38982 - acpi_cpufreq_driver.boost_supported = true;
38983 - acpi_cpufreq_driver.boost_enabled = boost_state(0);
38984 + pax_open_kernel();
38985 + *(bool *)&acpi_cpufreq_driver.boost_supported = true;
38986 + *(bool *)&acpi_cpufreq_driver.boost_enabled = boost_state(0);
38987 + pax_close_kernel();
38988
38989 cpu_notifier_register_begin();
38990
38991 diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
38992 index abda660..f1d1de0 100644
38993 --- a/drivers/cpufreq/cpufreq.c
38994 +++ b/drivers/cpufreq/cpufreq.c
38995 @@ -2022,7 +2022,7 @@ void cpufreq_unregister_governor(struct cpufreq_governor *governor)
38996 }
38997
38998 mutex_lock(&cpufreq_governor_mutex);
38999 - list_del(&governor->governor_list);
39000 + pax_list_del(&governor->governor_list);
39001 mutex_unlock(&cpufreq_governor_mutex);
39002 return;
39003 }
39004 @@ -2240,7 +2240,7 @@ static int cpufreq_cpu_callback(struct notifier_block *nfb,
39005 return NOTIFY_OK;
39006 }
39007
39008 -static struct notifier_block __refdata cpufreq_cpu_notifier = {
39009 +static struct notifier_block cpufreq_cpu_notifier = {
39010 .notifier_call = cpufreq_cpu_callback,
39011 };
39012
39013 @@ -2280,13 +2280,17 @@ int cpufreq_boost_trigger_state(int state)
39014 return 0;
39015
39016 write_lock_irqsave(&cpufreq_driver_lock, flags);
39017 - cpufreq_driver->boost_enabled = state;
39018 + pax_open_kernel();
39019 + *(bool *)&cpufreq_driver->boost_enabled = state;
39020 + pax_close_kernel();
39021 write_unlock_irqrestore(&cpufreq_driver_lock, flags);
39022
39023 ret = cpufreq_driver->set_boost(state);
39024 if (ret) {
39025 write_lock_irqsave(&cpufreq_driver_lock, flags);
39026 - cpufreq_driver->boost_enabled = !state;
39027 + pax_open_kernel();
39028 + *(bool *)&cpufreq_driver->boost_enabled = !state;
39029 + pax_close_kernel();
39030 write_unlock_irqrestore(&cpufreq_driver_lock, flags);
39031
39032 pr_err("%s: Cannot %s BOOST\n",
39033 @@ -2342,8 +2346,11 @@ int cpufreq_register_driver(struct cpufreq_driver *driver_data)
39034
39035 pr_debug("trying to register driver %s\n", driver_data->name);
39036
39037 - if (driver_data->setpolicy)
39038 - driver_data->flags |= CPUFREQ_CONST_LOOPS;
39039 + if (driver_data->setpolicy) {
39040 + pax_open_kernel();
39041 + *(u8 *)&driver_data->flags |= CPUFREQ_CONST_LOOPS;
39042 + pax_close_kernel();
39043 + }
39044
39045 write_lock_irqsave(&cpufreq_driver_lock, flags);
39046 if (cpufreq_driver) {
39047 @@ -2358,8 +2365,11 @@ int cpufreq_register_driver(struct cpufreq_driver *driver_data)
39048 * Check if driver provides function to enable boost -
39049 * if not, use cpufreq_boost_set_sw as default
39050 */
39051 - if (!cpufreq_driver->set_boost)
39052 - cpufreq_driver->set_boost = cpufreq_boost_set_sw;
39053 + if (!cpufreq_driver->set_boost) {
39054 + pax_open_kernel();
39055 + *(void **)&cpufreq_driver->set_boost = cpufreq_boost_set_sw;
39056 + pax_close_kernel();
39057 + }
39058
39059 ret = cpufreq_sysfs_create_file(&boost.attr);
39060 if (ret) {
39061 diff --git a/drivers/cpufreq/cpufreq_governor.c b/drivers/cpufreq/cpufreq_governor.c
39062 index e1c6433..31203ae 100644
39063 --- a/drivers/cpufreq/cpufreq_governor.c
39064 +++ b/drivers/cpufreq/cpufreq_governor.c
39065 @@ -191,7 +191,7 @@ int cpufreq_governor_dbs(struct cpufreq_policy *policy,
39066 struct dbs_data *dbs_data;
39067 struct od_cpu_dbs_info_s *od_dbs_info = NULL;
39068 struct cs_cpu_dbs_info_s *cs_dbs_info = NULL;
39069 - struct od_ops *od_ops = NULL;
39070 + const struct od_ops *od_ops = NULL;
39071 struct od_dbs_tuners *od_tuners = NULL;
39072 struct cs_dbs_tuners *cs_tuners = NULL;
39073 struct cpu_dbs_common_info *cpu_cdbs;
39074 @@ -257,7 +257,7 @@ int cpufreq_governor_dbs(struct cpufreq_policy *policy,
39075
39076 if ((cdata->governor == GOV_CONSERVATIVE) &&
39077 (!policy->governor->initialized)) {
39078 - struct cs_ops *cs_ops = dbs_data->cdata->gov_ops;
39079 + const struct cs_ops *cs_ops = dbs_data->cdata->gov_ops;
39080
39081 cpufreq_register_notifier(cs_ops->notifier_block,
39082 CPUFREQ_TRANSITION_NOTIFIER);
39083 @@ -277,7 +277,7 @@ int cpufreq_governor_dbs(struct cpufreq_policy *policy,
39084
39085 if ((dbs_data->cdata->governor == GOV_CONSERVATIVE) &&
39086 (policy->governor->initialized == 1)) {
39087 - struct cs_ops *cs_ops = dbs_data->cdata->gov_ops;
39088 + const struct cs_ops *cs_ops = dbs_data->cdata->gov_ops;
39089
39090 cpufreq_unregister_notifier(cs_ops->notifier_block,
39091 CPUFREQ_TRANSITION_NOTIFIER);
39092 diff --git a/drivers/cpufreq/cpufreq_governor.h b/drivers/cpufreq/cpufreq_governor.h
39093 index bfb9ae1..e1d3a7e 100644
39094 --- a/drivers/cpufreq/cpufreq_governor.h
39095 +++ b/drivers/cpufreq/cpufreq_governor.h
39096 @@ -205,7 +205,7 @@ struct common_dbs_data {
39097 void (*exit)(struct dbs_data *dbs_data);
39098
39099 /* Governor specific ops, see below */
39100 - void *gov_ops;
39101 + const void *gov_ops;
39102 };
39103
39104 /* Governor Per policy data */
39105 @@ -225,7 +225,7 @@ struct od_ops {
39106 unsigned int (*powersave_bias_target)(struct cpufreq_policy *policy,
39107 unsigned int freq_next, unsigned int relation);
39108 void (*freq_increase)(struct cpufreq_policy *policy, unsigned int freq);
39109 -};
39110 +} __no_const;
39111
39112 struct cs_ops {
39113 struct notifier_block *notifier_block;
39114 diff --git a/drivers/cpufreq/cpufreq_ondemand.c b/drivers/cpufreq/cpufreq_ondemand.c
39115 index 18d4091..434be15 100644
39116 --- a/drivers/cpufreq/cpufreq_ondemand.c
39117 +++ b/drivers/cpufreq/cpufreq_ondemand.c
39118 @@ -521,7 +521,7 @@ static void od_exit(struct dbs_data *dbs_data)
39119
39120 define_get_cpu_dbs_routines(od_cpu_dbs_info);
39121
39122 -static struct od_ops od_ops = {
39123 +static struct od_ops od_ops __read_only = {
39124 .powersave_bias_init_cpu = ondemand_powersave_bias_init_cpu,
39125 .powersave_bias_target = generic_powersave_bias_target,
39126 .freq_increase = dbs_freq_increase,
39127 @@ -576,14 +576,18 @@ void od_register_powersave_bias_handler(unsigned int (*f)
39128 (struct cpufreq_policy *, unsigned int, unsigned int),
39129 unsigned int powersave_bias)
39130 {
39131 - od_ops.powersave_bias_target = f;
39132 + pax_open_kernel();
39133 + *(void **)&od_ops.powersave_bias_target = f;
39134 + pax_close_kernel();
39135 od_set_powersave_bias(powersave_bias);
39136 }
39137 EXPORT_SYMBOL_GPL(od_register_powersave_bias_handler);
39138
39139 void od_unregister_powersave_bias_handler(void)
39140 {
39141 - od_ops.powersave_bias_target = generic_powersave_bias_target;
39142 + pax_open_kernel();
39143 + *(void **)&od_ops.powersave_bias_target = generic_powersave_bias_target;
39144 + pax_close_kernel();
39145 od_set_powersave_bias(0);
39146 }
39147 EXPORT_SYMBOL_GPL(od_unregister_powersave_bias_handler);
39148 diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c
39149 index db2e45b..72c7d37 100644
39150 --- a/drivers/cpufreq/intel_pstate.c
39151 +++ b/drivers/cpufreq/intel_pstate.c
39152 @@ -125,10 +125,10 @@ struct pstate_funcs {
39153 struct cpu_defaults {
39154 struct pstate_adjust_policy pid_policy;
39155 struct pstate_funcs funcs;
39156 -};
39157 +} __do_const;
39158
39159 static struct pstate_adjust_policy pid_params;
39160 -static struct pstate_funcs pstate_funcs;
39161 +static struct pstate_funcs *pstate_funcs;
39162
39163 struct perf_limits {
39164 int no_turbo;
39165 @@ -529,7 +529,7 @@ static void intel_pstate_set_pstate(struct cpudata *cpu, int pstate)
39166
39167 cpu->pstate.current_pstate = pstate;
39168
39169 - pstate_funcs.set(cpu, pstate);
39170 + pstate_funcs->set(cpu, pstate);
39171 }
39172
39173 static inline void intel_pstate_pstate_increase(struct cpudata *cpu, int steps)
39174 @@ -551,12 +551,12 @@ static void intel_pstate_get_cpu_pstates(struct cpudata *cpu)
39175 {
39176 sprintf(cpu->name, "Intel 2nd generation core");
39177
39178 - cpu->pstate.min_pstate = pstate_funcs.get_min();
39179 - cpu->pstate.max_pstate = pstate_funcs.get_max();
39180 - cpu->pstate.turbo_pstate = pstate_funcs.get_turbo();
39181 + cpu->pstate.min_pstate = pstate_funcs->get_min();
39182 + cpu->pstate.max_pstate = pstate_funcs->get_max();
39183 + cpu->pstate.turbo_pstate = pstate_funcs->get_turbo();
39184
39185 - if (pstate_funcs.get_vid)
39186 - pstate_funcs.get_vid(cpu);
39187 + if (pstate_funcs->get_vid)
39188 + pstate_funcs->get_vid(cpu);
39189 intel_pstate_set_pstate(cpu, cpu->pstate.min_pstate);
39190 }
39191
39192 @@ -841,9 +841,9 @@ static int intel_pstate_msrs_not_valid(void)
39193 rdmsrl(MSR_IA32_APERF, aperf);
39194 rdmsrl(MSR_IA32_MPERF, mperf);
39195
39196 - if (!pstate_funcs.get_max() ||
39197 - !pstate_funcs.get_min() ||
39198 - !pstate_funcs.get_turbo())
39199 + if (!pstate_funcs->get_max() ||
39200 + !pstate_funcs->get_min() ||
39201 + !pstate_funcs->get_turbo())
39202 return -ENODEV;
39203
39204 rdmsrl(MSR_IA32_APERF, tmp);
39205 @@ -857,7 +857,7 @@ static int intel_pstate_msrs_not_valid(void)
39206 return 0;
39207 }
39208
39209 -static void copy_pid_params(struct pstate_adjust_policy *policy)
39210 +static void copy_pid_params(const struct pstate_adjust_policy *policy)
39211 {
39212 pid_params.sample_rate_ms = policy->sample_rate_ms;
39213 pid_params.p_gain_pct = policy->p_gain_pct;
39214 @@ -869,11 +869,7 @@ static void copy_pid_params(struct pstate_adjust_policy *policy)
39215
39216 static void copy_cpu_funcs(struct pstate_funcs *funcs)
39217 {
39218 - pstate_funcs.get_max = funcs->get_max;
39219 - pstate_funcs.get_min = funcs->get_min;
39220 - pstate_funcs.get_turbo = funcs->get_turbo;
39221 - pstate_funcs.set = funcs->set;
39222 - pstate_funcs.get_vid = funcs->get_vid;
39223 + pstate_funcs = funcs;
39224 }
39225
39226 #if IS_ENABLED(CONFIG_ACPI)
39227 diff --git a/drivers/cpufreq/p4-clockmod.c b/drivers/cpufreq/p4-clockmod.c
39228 index 529cfd9..0e28fff 100644
39229 --- a/drivers/cpufreq/p4-clockmod.c
39230 +++ b/drivers/cpufreq/p4-clockmod.c
39231 @@ -134,10 +134,14 @@ static unsigned int cpufreq_p4_get_frequency(struct cpuinfo_x86 *c)
39232 case 0x0F: /* Core Duo */
39233 case 0x16: /* Celeron Core */
39234 case 0x1C: /* Atom */
39235 - p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
39236 + pax_open_kernel();
39237 + *(u8 *)&p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
39238 + pax_close_kernel();
39239 return speedstep_get_frequency(SPEEDSTEP_CPU_PCORE);
39240 case 0x0D: /* Pentium M (Dothan) */
39241 - p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
39242 + pax_open_kernel();
39243 + *(u8 *)&p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
39244 + pax_close_kernel();
39245 /* fall through */
39246 case 0x09: /* Pentium M (Banias) */
39247 return speedstep_get_frequency(SPEEDSTEP_CPU_PM);
39248 @@ -149,7 +153,9 @@ static unsigned int cpufreq_p4_get_frequency(struct cpuinfo_x86 *c)
39249
39250 /* on P-4s, the TSC runs with constant frequency independent whether
39251 * throttling is active or not. */
39252 - p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
39253 + pax_open_kernel();
39254 + *(u8 *)&p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
39255 + pax_close_kernel();
39256
39257 if (speedstep_detect_processor() == SPEEDSTEP_CPU_P4M) {
39258 printk(KERN_WARNING PFX "Warning: Pentium 4-M detected. "
39259 diff --git a/drivers/cpufreq/sparc-us3-cpufreq.c b/drivers/cpufreq/sparc-us3-cpufreq.c
39260 index 9bb42ba..b01b4a2 100644
39261 --- a/drivers/cpufreq/sparc-us3-cpufreq.c
39262 +++ b/drivers/cpufreq/sparc-us3-cpufreq.c
39263 @@ -18,14 +18,12 @@
39264 #include <asm/head.h>
39265 #include <asm/timer.h>
39266
39267 -static struct cpufreq_driver *cpufreq_us3_driver;
39268 -
39269 struct us3_freq_percpu_info {
39270 struct cpufreq_frequency_table table[4];
39271 };
39272
39273 /* Indexed by cpu number. */
39274 -static struct us3_freq_percpu_info *us3_freq_table;
39275 +static struct us3_freq_percpu_info us3_freq_table[NR_CPUS];
39276
39277 /* UltraSPARC-III has three dividers: 1, 2, and 32. These are controlled
39278 * in the Safari config register.
39279 @@ -156,16 +154,27 @@ static int __init us3_freq_cpu_init(struct cpufreq_policy *policy)
39280
39281 static int us3_freq_cpu_exit(struct cpufreq_policy *policy)
39282 {
39283 - if (cpufreq_us3_driver)
39284 - us3_freq_target(policy, 0);
39285 + us3_freq_target(policy, 0);
39286
39287 return 0;
39288 }
39289
39290 +static int __init us3_freq_init(void);
39291 +static void __exit us3_freq_exit(void);
39292 +
39293 +static struct cpufreq_driver cpufreq_us3_driver = {
39294 + .init = us3_freq_cpu_init,
39295 + .verify = cpufreq_generic_frequency_table_verify,
39296 + .target_index = us3_freq_target,
39297 + .get = us3_freq_get,
39298 + .exit = us3_freq_cpu_exit,
39299 + .name = "UltraSPARC-III",
39300 +
39301 +};
39302 +
39303 static int __init us3_freq_init(void)
39304 {
39305 unsigned long manuf, impl, ver;
39306 - int ret;
39307
39308 if (tlb_type != cheetah && tlb_type != cheetah_plus)
39309 return -ENODEV;
39310 @@ -178,55 +187,15 @@ static int __init us3_freq_init(void)
39311 (impl == CHEETAH_IMPL ||
39312 impl == CHEETAH_PLUS_IMPL ||
39313 impl == JAGUAR_IMPL ||
39314 - impl == PANTHER_IMPL)) {
39315 - struct cpufreq_driver *driver;
39316 -
39317 - ret = -ENOMEM;
39318 - driver = kzalloc(sizeof(*driver), GFP_KERNEL);
39319 - if (!driver)
39320 - goto err_out;
39321 -
39322 - us3_freq_table = kzalloc((NR_CPUS * sizeof(*us3_freq_table)),
39323 - GFP_KERNEL);
39324 - if (!us3_freq_table)
39325 - goto err_out;
39326 -
39327 - driver->init = us3_freq_cpu_init;
39328 - driver->verify = cpufreq_generic_frequency_table_verify;
39329 - driver->target_index = us3_freq_target;
39330 - driver->get = us3_freq_get;
39331 - driver->exit = us3_freq_cpu_exit;
39332 - strcpy(driver->name, "UltraSPARC-III");
39333 -
39334 - cpufreq_us3_driver = driver;
39335 - ret = cpufreq_register_driver(driver);
39336 - if (ret)
39337 - goto err_out;
39338 -
39339 - return 0;
39340 -
39341 -err_out:
39342 - if (driver) {
39343 - kfree(driver);
39344 - cpufreq_us3_driver = NULL;
39345 - }
39346 - kfree(us3_freq_table);
39347 - us3_freq_table = NULL;
39348 - return ret;
39349 - }
39350 + impl == PANTHER_IMPL))
39351 + return cpufreq_register_driver(&cpufreq_us3_driver);
39352
39353 return -ENODEV;
39354 }
39355
39356 static void __exit us3_freq_exit(void)
39357 {
39358 - if (cpufreq_us3_driver) {
39359 - cpufreq_unregister_driver(cpufreq_us3_driver);
39360 - kfree(cpufreq_us3_driver);
39361 - cpufreq_us3_driver = NULL;
39362 - kfree(us3_freq_table);
39363 - us3_freq_table = NULL;
39364 - }
39365 + cpufreq_unregister_driver(&cpufreq_us3_driver);
39366 }
39367
39368 MODULE_AUTHOR("David S. Miller <davem@redhat.com>");
39369 diff --git a/drivers/cpufreq/speedstep-centrino.c b/drivers/cpufreq/speedstep-centrino.c
39370 index 6723f03..3465190 100644
39371 --- a/drivers/cpufreq/speedstep-centrino.c
39372 +++ b/drivers/cpufreq/speedstep-centrino.c
39373 @@ -351,8 +351,11 @@ static int centrino_cpu_init(struct cpufreq_policy *policy)
39374 !cpu_has(cpu, X86_FEATURE_EST))
39375 return -ENODEV;
39376
39377 - if (cpu_has(cpu, X86_FEATURE_CONSTANT_TSC))
39378 - centrino_driver.flags |= CPUFREQ_CONST_LOOPS;
39379 + if (cpu_has(cpu, X86_FEATURE_CONSTANT_TSC)) {
39380 + pax_open_kernel();
39381 + *(u8 *)&centrino_driver.flags |= CPUFREQ_CONST_LOOPS;
39382 + pax_close_kernel();
39383 + }
39384
39385 if (policy->cpu != 0)
39386 return -ENODEV;
39387 diff --git a/drivers/cpuidle/driver.c b/drivers/cpuidle/driver.c
39388 index 136d6a2..06e373d 100644
39389 --- a/drivers/cpuidle/driver.c
39390 +++ b/drivers/cpuidle/driver.c
39391 @@ -202,7 +202,7 @@ static int poll_idle(struct cpuidle_device *dev,
39392
39393 static void poll_idle_init(struct cpuidle_driver *drv)
39394 {
39395 - struct cpuidle_state *state = &drv->states[0];
39396 + cpuidle_state_no_const *state = &drv->states[0];
39397
39398 snprintf(state->name, CPUIDLE_NAME_LEN, "POLL");
39399 snprintf(state->desc, CPUIDLE_DESC_LEN, "CPUIDLE CORE POLL IDLE");
39400 diff --git a/drivers/cpuidle/governor.c b/drivers/cpuidle/governor.c
39401 index ca89412..a7b9c49 100644
39402 --- a/drivers/cpuidle/governor.c
39403 +++ b/drivers/cpuidle/governor.c
39404 @@ -87,7 +87,7 @@ int cpuidle_register_governor(struct cpuidle_governor *gov)
39405 mutex_lock(&cpuidle_lock);
39406 if (__cpuidle_find_governor(gov->name) == NULL) {
39407 ret = 0;
39408 - list_add_tail(&gov->governor_list, &cpuidle_governors);
39409 + pax_list_add_tail((struct list_head *)&gov->governor_list, &cpuidle_governors);
39410 if (!cpuidle_curr_governor ||
39411 cpuidle_curr_governor->rating < gov->rating)
39412 cpuidle_switch_governor(gov);
39413 diff --git a/drivers/cpuidle/sysfs.c b/drivers/cpuidle/sysfs.c
39414 index efe2f17..b8124f9 100644
39415 --- a/drivers/cpuidle/sysfs.c
39416 +++ b/drivers/cpuidle/sysfs.c
39417 @@ -135,7 +135,7 @@ static struct attribute *cpuidle_switch_attrs[] = {
39418 NULL
39419 };
39420
39421 -static struct attribute_group cpuidle_attr_group = {
39422 +static attribute_group_no_const cpuidle_attr_group = {
39423 .attrs = cpuidle_default_attrs,
39424 .name = "cpuidle",
39425 };
39426 diff --git a/drivers/crypto/hifn_795x.c b/drivers/crypto/hifn_795x.c
39427 index 12fea3e..1e28f47 100644
39428 --- a/drivers/crypto/hifn_795x.c
39429 +++ b/drivers/crypto/hifn_795x.c
39430 @@ -51,7 +51,7 @@ module_param_string(hifn_pll_ref, hifn_pll_ref, sizeof(hifn_pll_ref), 0444);
39431 MODULE_PARM_DESC(hifn_pll_ref,
39432 "PLL reference clock (pci[freq] or ext[freq], default ext)");
39433
39434 -static atomic_t hifn_dev_number;
39435 +static atomic_unchecked_t hifn_dev_number;
39436
39437 #define ACRYPTO_OP_DECRYPT 0
39438 #define ACRYPTO_OP_ENCRYPT 1
39439 @@ -2577,7 +2577,7 @@ static int hifn_probe(struct pci_dev *pdev, const struct pci_device_id *id)
39440 goto err_out_disable_pci_device;
39441
39442 snprintf(name, sizeof(name), "hifn%d",
39443 - atomic_inc_return(&hifn_dev_number)-1);
39444 + atomic_inc_return_unchecked(&hifn_dev_number)-1);
39445
39446 err = pci_request_regions(pdev, name);
39447 if (err)
39448 diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
39449 index 2042ec3..a9ce67f 100644
39450 --- a/drivers/devfreq/devfreq.c
39451 +++ b/drivers/devfreq/devfreq.c
39452 @@ -616,7 +616,7 @@ int devfreq_add_governor(struct devfreq_governor *governor)
39453 goto err_out;
39454 }
39455
39456 - list_add(&governor->node, &devfreq_governor_list);
39457 + pax_list_add((struct list_head *)&governor->node, &devfreq_governor_list);
39458
39459 list_for_each_entry(devfreq, &devfreq_list, node) {
39460 int ret = 0;
39461 @@ -704,7 +704,7 @@ int devfreq_remove_governor(struct devfreq_governor *governor)
39462 }
39463 }
39464
39465 - list_del(&governor->node);
39466 + pax_list_del((struct list_head *)&governor->node);
39467 err_out:
39468 mutex_unlock(&devfreq_list_lock);
39469
39470 diff --git a/drivers/dma/sh/shdma-base.c b/drivers/dma/sh/shdma-base.c
39471 index 5239677..1cb71a8 100644
39472 --- a/drivers/dma/sh/shdma-base.c
39473 +++ b/drivers/dma/sh/shdma-base.c
39474 @@ -267,8 +267,8 @@ static int shdma_alloc_chan_resources(struct dma_chan *chan)
39475 schan->slave_id = -EINVAL;
39476 }
39477
39478 - schan->desc = kcalloc(NR_DESCS_PER_CHANNEL,
39479 - sdev->desc_size, GFP_KERNEL);
39480 + schan->desc = kcalloc(sdev->desc_size,
39481 + NR_DESCS_PER_CHANNEL, GFP_KERNEL);
39482 if (!schan->desc) {
39483 ret = -ENOMEM;
39484 goto edescalloc;
39485 diff --git a/drivers/dma/sh/shdmac.c b/drivers/dma/sh/shdmac.c
39486 index dda7e75..0a4c867 100644
39487 --- a/drivers/dma/sh/shdmac.c
39488 +++ b/drivers/dma/sh/shdmac.c
39489 @@ -513,7 +513,7 @@ static int sh_dmae_nmi_handler(struct notifier_block *self,
39490 return ret;
39491 }
39492
39493 -static struct notifier_block sh_dmae_nmi_notifier __read_mostly = {
39494 +static struct notifier_block sh_dmae_nmi_notifier = {
39495 .notifier_call = sh_dmae_nmi_handler,
39496
39497 /* Run before NMI debug handler and KGDB */
39498 diff --git a/drivers/edac/edac_device.c b/drivers/edac/edac_device.c
39499 index 592af5f..bb1d583 100644
39500 --- a/drivers/edac/edac_device.c
39501 +++ b/drivers/edac/edac_device.c
39502 @@ -477,9 +477,9 @@ void edac_device_reset_delay_period(struct edac_device_ctl_info *edac_dev,
39503 */
39504 int edac_device_alloc_index(void)
39505 {
39506 - static atomic_t device_indexes = ATOMIC_INIT(0);
39507 + static atomic_unchecked_t device_indexes = ATOMIC_INIT(0);
39508
39509 - return atomic_inc_return(&device_indexes) - 1;
39510 + return atomic_inc_return_unchecked(&device_indexes) - 1;
39511 }
39512 EXPORT_SYMBOL_GPL(edac_device_alloc_index);
39513
39514 diff --git a/drivers/edac/edac_mc_sysfs.c b/drivers/edac/edac_mc_sysfs.c
39515 index 01fae82..1dd8289 100644
39516 --- a/drivers/edac/edac_mc_sysfs.c
39517 +++ b/drivers/edac/edac_mc_sysfs.c
39518 @@ -152,7 +152,7 @@ static const char * const edac_caps[] = {
39519 struct dev_ch_attribute {
39520 struct device_attribute attr;
39521 int channel;
39522 -};
39523 +} __do_const;
39524
39525 #define DEVICE_CHANNEL(_name, _mode, _show, _store, _var) \
39526 struct dev_ch_attribute dev_attr_legacy_##_name = \
39527 @@ -1009,14 +1009,16 @@ int edac_create_sysfs_mci_device(struct mem_ctl_info *mci)
39528 }
39529
39530 if (mci->set_sdram_scrub_rate || mci->get_sdram_scrub_rate) {
39531 + pax_open_kernel();
39532 if (mci->get_sdram_scrub_rate) {
39533 - dev_attr_sdram_scrub_rate.attr.mode |= S_IRUGO;
39534 - dev_attr_sdram_scrub_rate.show = &mci_sdram_scrub_rate_show;
39535 + *(umode_t *)&dev_attr_sdram_scrub_rate.attr.mode |= S_IRUGO;
39536 + *(void **)&dev_attr_sdram_scrub_rate.show = &mci_sdram_scrub_rate_show;
39537 }
39538 if (mci->set_sdram_scrub_rate) {
39539 - dev_attr_sdram_scrub_rate.attr.mode |= S_IWUSR;
39540 - dev_attr_sdram_scrub_rate.store = &mci_sdram_scrub_rate_store;
39541 + *(umode_t *)&dev_attr_sdram_scrub_rate.attr.mode |= S_IWUSR;
39542 + *(void **)&dev_attr_sdram_scrub_rate.store = &mci_sdram_scrub_rate_store;
39543 }
39544 + pax_close_kernel();
39545 err = device_create_file(&mci->dev,
39546 &dev_attr_sdram_scrub_rate);
39547 if (err) {
39548 diff --git a/drivers/edac/edac_pci.c b/drivers/edac/edac_pci.c
39549 index 2cf44b4d..6dd2dc7 100644
39550 --- a/drivers/edac/edac_pci.c
39551 +++ b/drivers/edac/edac_pci.c
39552 @@ -29,7 +29,7 @@
39553
39554 static DEFINE_MUTEX(edac_pci_ctls_mutex);
39555 static LIST_HEAD(edac_pci_list);
39556 -static atomic_t pci_indexes = ATOMIC_INIT(0);
39557 +static atomic_unchecked_t pci_indexes = ATOMIC_INIT(0);
39558
39559 /*
39560 * edac_pci_alloc_ctl_info
39561 @@ -315,7 +315,7 @@ EXPORT_SYMBOL_GPL(edac_pci_reset_delay_period);
39562 */
39563 int edac_pci_alloc_index(void)
39564 {
39565 - return atomic_inc_return(&pci_indexes) - 1;
39566 + return atomic_inc_return_unchecked(&pci_indexes) - 1;
39567 }
39568 EXPORT_SYMBOL_GPL(edac_pci_alloc_index);
39569
39570 diff --git a/drivers/edac/edac_pci_sysfs.c b/drivers/edac/edac_pci_sysfs.c
39571 index e8658e4..22746d6 100644
39572 --- a/drivers/edac/edac_pci_sysfs.c
39573 +++ b/drivers/edac/edac_pci_sysfs.c
39574 @@ -26,8 +26,8 @@ static int edac_pci_log_pe = 1; /* log PCI parity errors */
39575 static int edac_pci_log_npe = 1; /* log PCI non-parity error errors */
39576 static int edac_pci_poll_msec = 1000; /* one second workq period */
39577
39578 -static atomic_t pci_parity_count = ATOMIC_INIT(0);
39579 -static atomic_t pci_nonparity_count = ATOMIC_INIT(0);
39580 +static atomic_unchecked_t pci_parity_count = ATOMIC_INIT(0);
39581 +static atomic_unchecked_t pci_nonparity_count = ATOMIC_INIT(0);
39582
39583 static struct kobject *edac_pci_top_main_kobj;
39584 static atomic_t edac_pci_sysfs_refcount = ATOMIC_INIT(0);
39585 @@ -235,7 +235,7 @@ struct edac_pci_dev_attribute {
39586 void *value;
39587 ssize_t(*show) (void *, char *);
39588 ssize_t(*store) (void *, const char *, size_t);
39589 -};
39590 +} __do_const;
39591
39592 /* Set of show/store abstract level functions for PCI Parity object */
39593 static ssize_t edac_pci_dev_show(struct kobject *kobj, struct attribute *attr,
39594 @@ -579,7 +579,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
39595 edac_printk(KERN_CRIT, EDAC_PCI,
39596 "Signaled System Error on %s\n",
39597 pci_name(dev));
39598 - atomic_inc(&pci_nonparity_count);
39599 + atomic_inc_unchecked(&pci_nonparity_count);
39600 }
39601
39602 if (status & (PCI_STATUS_PARITY)) {
39603 @@ -587,7 +587,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
39604 "Master Data Parity Error on %s\n",
39605 pci_name(dev));
39606
39607 - atomic_inc(&pci_parity_count);
39608 + atomic_inc_unchecked(&pci_parity_count);
39609 }
39610
39611 if (status & (PCI_STATUS_DETECTED_PARITY)) {
39612 @@ -595,7 +595,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
39613 "Detected Parity Error on %s\n",
39614 pci_name(dev));
39615
39616 - atomic_inc(&pci_parity_count);
39617 + atomic_inc_unchecked(&pci_parity_count);
39618 }
39619 }
39620
39621 @@ -618,7 +618,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
39622 edac_printk(KERN_CRIT, EDAC_PCI, "Bridge "
39623 "Signaled System Error on %s\n",
39624 pci_name(dev));
39625 - atomic_inc(&pci_nonparity_count);
39626 + atomic_inc_unchecked(&pci_nonparity_count);
39627 }
39628
39629 if (status & (PCI_STATUS_PARITY)) {
39630 @@ -626,7 +626,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
39631 "Master Data Parity Error on "
39632 "%s\n", pci_name(dev));
39633
39634 - atomic_inc(&pci_parity_count);
39635 + atomic_inc_unchecked(&pci_parity_count);
39636 }
39637
39638 if (status & (PCI_STATUS_DETECTED_PARITY)) {
39639 @@ -634,7 +634,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
39640 "Detected Parity Error on %s\n",
39641 pci_name(dev));
39642
39643 - atomic_inc(&pci_parity_count);
39644 + atomic_inc_unchecked(&pci_parity_count);
39645 }
39646 }
39647 }
39648 @@ -672,7 +672,7 @@ void edac_pci_do_parity_check(void)
39649 if (!check_pci_errors)
39650 return;
39651
39652 - before_count = atomic_read(&pci_parity_count);
39653 + before_count = atomic_read_unchecked(&pci_parity_count);
39654
39655 /* scan all PCI devices looking for a Parity Error on devices and
39656 * bridges.
39657 @@ -684,7 +684,7 @@ void edac_pci_do_parity_check(void)
39658 /* Only if operator has selected panic on PCI Error */
39659 if (edac_pci_get_panic_on_pe()) {
39660 /* If the count is different 'after' from 'before' */
39661 - if (before_count != atomic_read(&pci_parity_count))
39662 + if (before_count != atomic_read_unchecked(&pci_parity_count))
39663 panic("EDAC: PCI Parity Error");
39664 }
39665 }
39666 diff --git a/drivers/edac/mce_amd.h b/drivers/edac/mce_amd.h
39667 index 51b7e3a..aa8a3e8 100644
39668 --- a/drivers/edac/mce_amd.h
39669 +++ b/drivers/edac/mce_amd.h
39670 @@ -77,7 +77,7 @@ struct amd_decoder_ops {
39671 bool (*mc0_mce)(u16, u8);
39672 bool (*mc1_mce)(u16, u8);
39673 bool (*mc2_mce)(u16, u8);
39674 -};
39675 +} __no_const;
39676
39677 void amd_report_gart_errors(bool);
39678 void amd_register_ecc_decoder(void (*f)(int, struct mce *));
39679 diff --git a/drivers/firewire/core-card.c b/drivers/firewire/core-card.c
39680 index 57ea7f4..af06b76 100644
39681 --- a/drivers/firewire/core-card.c
39682 +++ b/drivers/firewire/core-card.c
39683 @@ -528,9 +528,9 @@ void fw_card_initialize(struct fw_card *card,
39684 const struct fw_card_driver *driver,
39685 struct device *device)
39686 {
39687 - static atomic_t index = ATOMIC_INIT(-1);
39688 + static atomic_unchecked_t index = ATOMIC_INIT(-1);
39689
39690 - card->index = atomic_inc_return(&index);
39691 + card->index = atomic_inc_return_unchecked(&index);
39692 card->driver = driver;
39693 card->device = device;
39694 card->current_tlabel = 0;
39695 @@ -680,7 +680,7 @@ EXPORT_SYMBOL_GPL(fw_card_release);
39696
39697 void fw_core_remove_card(struct fw_card *card)
39698 {
39699 - struct fw_card_driver dummy_driver = dummy_driver_template;
39700 + fw_card_driver_no_const dummy_driver = dummy_driver_template;
39701
39702 card->driver->update_phy_reg(card, 4,
39703 PHY_LINK_ACTIVE | PHY_CONTENDER, 0);
39704 diff --git a/drivers/firewire/core-device.c b/drivers/firewire/core-device.c
39705 index 2c6d5e1..a2cca6b 100644
39706 --- a/drivers/firewire/core-device.c
39707 +++ b/drivers/firewire/core-device.c
39708 @@ -253,7 +253,7 @@ EXPORT_SYMBOL(fw_device_enable_phys_dma);
39709 struct config_rom_attribute {
39710 struct device_attribute attr;
39711 u32 key;
39712 -};
39713 +} __do_const;
39714
39715 static ssize_t show_immediate(struct device *dev,
39716 struct device_attribute *dattr, char *buf)
39717 diff --git a/drivers/firewire/core-transaction.c b/drivers/firewire/core-transaction.c
39718 index eb6935c..3cc2bfa 100644
39719 --- a/drivers/firewire/core-transaction.c
39720 +++ b/drivers/firewire/core-transaction.c
39721 @@ -38,6 +38,7 @@
39722 #include <linux/timer.h>
39723 #include <linux/types.h>
39724 #include <linux/workqueue.h>
39725 +#include <linux/sched.h>
39726
39727 #include <asm/byteorder.h>
39728
39729 diff --git a/drivers/firewire/core.h b/drivers/firewire/core.h
39730 index f477308..2795f24 100644
39731 --- a/drivers/firewire/core.h
39732 +++ b/drivers/firewire/core.h
39733 @@ -111,6 +111,7 @@ struct fw_card_driver {
39734
39735 int (*stop_iso)(struct fw_iso_context *ctx);
39736 };
39737 +typedef struct fw_card_driver __no_const fw_card_driver_no_const;
39738
39739 void fw_card_initialize(struct fw_card *card,
39740 const struct fw_card_driver *driver, struct device *device);
39741 diff --git a/drivers/firewire/ohci.c b/drivers/firewire/ohci.c
39742 index 586f2f7..3545ad2 100644
39743 --- a/drivers/firewire/ohci.c
39744 +++ b/drivers/firewire/ohci.c
39745 @@ -2049,10 +2049,12 @@ static void bus_reset_work(struct work_struct *work)
39746 be32_to_cpu(ohci->next_header));
39747 }
39748
39749 +#ifndef CONFIG_GRKERNSEC
39750 if (param_remote_dma) {
39751 reg_write(ohci, OHCI1394_PhyReqFilterHiSet, ~0);
39752 reg_write(ohci, OHCI1394_PhyReqFilterLoSet, ~0);
39753 }
39754 +#endif
39755
39756 spin_unlock_irq(&ohci->lock);
39757
39758 @@ -2584,8 +2586,10 @@ static int ohci_enable_phys_dma(struct fw_card *card,
39759 unsigned long flags;
39760 int n, ret = 0;
39761
39762 +#ifndef CONFIG_GRKERNSEC
39763 if (param_remote_dma)
39764 return 0;
39765 +#endif
39766
39767 /*
39768 * FIXME: Make sure this bitmask is cleared when we clear the busReset
39769 diff --git a/drivers/firmware/dmi-id.c b/drivers/firmware/dmi-id.c
39770 index 94a58a0..f5eba42 100644
39771 --- a/drivers/firmware/dmi-id.c
39772 +++ b/drivers/firmware/dmi-id.c
39773 @@ -16,7 +16,7 @@
39774 struct dmi_device_attribute{
39775 struct device_attribute dev_attr;
39776 int field;
39777 -};
39778 +} __do_const;
39779 #define to_dmi_dev_attr(_dev_attr) \
39780 container_of(_dev_attr, struct dmi_device_attribute, dev_attr)
39781
39782 diff --git a/drivers/firmware/dmi_scan.c b/drivers/firmware/dmi_scan.c
39783 index 17afc51..0ef90cd 100644
39784 --- a/drivers/firmware/dmi_scan.c
39785 +++ b/drivers/firmware/dmi_scan.c
39786 @@ -835,7 +835,7 @@ int dmi_walk(void (*decode)(const struct dmi_header *, void *),
39787 if (buf == NULL)
39788 return -1;
39789
39790 - dmi_table(buf, dmi_len, dmi_num, decode, private_data);
39791 + dmi_table((char __force_kernel *)buf, dmi_len, dmi_num, decode, private_data);
39792
39793 dmi_unmap(buf);
39794 return 0;
39795 diff --git a/drivers/firmware/efi/cper.c b/drivers/firmware/efi/cper.c
39796 index 1491dd4..aa910db 100644
39797 --- a/drivers/firmware/efi/cper.c
39798 +++ b/drivers/firmware/efi/cper.c
39799 @@ -41,12 +41,12 @@
39800 */
39801 u64 cper_next_record_id(void)
39802 {
39803 - static atomic64_t seq;
39804 + static atomic64_unchecked_t seq;
39805
39806 - if (!atomic64_read(&seq))
39807 - atomic64_set(&seq, ((u64)get_seconds()) << 32);
39808 + if (!atomic64_read_unchecked(&seq))
39809 + atomic64_set_unchecked(&seq, ((u64)get_seconds()) << 32);
39810
39811 - return atomic64_inc_return(&seq);
39812 + return atomic64_inc_return_unchecked(&seq);
39813 }
39814 EXPORT_SYMBOL_GPL(cper_next_record_id);
39815
39816 diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c
39817 index af20f17..4e4e545 100644
39818 --- a/drivers/firmware/efi/efi.c
39819 +++ b/drivers/firmware/efi/efi.c
39820 @@ -120,14 +120,16 @@ static struct attribute_group efi_subsys_attr_group = {
39821 };
39822
39823 static struct efivars generic_efivars;
39824 -static struct efivar_operations generic_ops;
39825 +static efivar_operations_no_const generic_ops __read_only;
39826
39827 static int generic_ops_register(void)
39828 {
39829 - generic_ops.get_variable = efi.get_variable;
39830 - generic_ops.set_variable = efi.set_variable;
39831 - generic_ops.get_next_variable = efi.get_next_variable;
39832 - generic_ops.query_variable_store = efi_query_variable_store;
39833 + pax_open_kernel();
39834 + *(void **)&generic_ops.get_variable = efi.get_variable;
39835 + *(void **)&generic_ops.set_variable = efi.set_variable;
39836 + *(void **)&generic_ops.get_next_variable = efi.get_next_variable;
39837 + *(void **)&generic_ops.query_variable_store = efi_query_variable_store;
39838 + pax_close_kernel();
39839
39840 return efivars_register(&generic_efivars, &generic_ops, efi_kobj);
39841 }
39842 diff --git a/drivers/firmware/efi/efivars.c b/drivers/firmware/efi/efivars.c
39843 index 50ea412..caccd6e9 100644
39844 --- a/drivers/firmware/efi/efivars.c
39845 +++ b/drivers/firmware/efi/efivars.c
39846 @@ -456,7 +456,7 @@ efivar_create_sysfs_entry(struct efivar_entry *new_var)
39847 static int
39848 create_efivars_bin_attributes(void)
39849 {
39850 - struct bin_attribute *attr;
39851 + bin_attribute_no_const *attr;
39852 int error;
39853
39854 /* new_var */
39855 diff --git a/drivers/firmware/google/memconsole.c b/drivers/firmware/google/memconsole.c
39856 index 2f569aa..c95f4fb 100644
39857 --- a/drivers/firmware/google/memconsole.c
39858 +++ b/drivers/firmware/google/memconsole.c
39859 @@ -155,7 +155,10 @@ static int __init memconsole_init(void)
39860 if (!found_memconsole())
39861 return -ENODEV;
39862
39863 - memconsole_bin_attr.size = memconsole_length;
39864 + pax_open_kernel();
39865 + *(size_t *)&memconsole_bin_attr.size = memconsole_length;
39866 + pax_close_kernel();
39867 +
39868 return sysfs_create_bin_file(firmware_kobj, &memconsole_bin_attr);
39869 }
39870
39871 diff --git a/drivers/gpio/gpio-em.c b/drivers/gpio/gpio-em.c
39872 index 8765bd6..2e5b147 100644
39873 --- a/drivers/gpio/gpio-em.c
39874 +++ b/drivers/gpio/gpio-em.c
39875 @@ -278,7 +278,7 @@ static int em_gio_probe(struct platform_device *pdev)
39876 struct em_gio_priv *p;
39877 struct resource *io[2], *irq[2];
39878 struct gpio_chip *gpio_chip;
39879 - struct irq_chip *irq_chip;
39880 + irq_chip_no_const *irq_chip;
39881 const char *name = dev_name(&pdev->dev);
39882 int ret;
39883
39884 diff --git a/drivers/gpio/gpio-ich.c b/drivers/gpio/gpio-ich.c
39885 index 7030422..42a3fe9 100644
39886 --- a/drivers/gpio/gpio-ich.c
39887 +++ b/drivers/gpio/gpio-ich.c
39888 @@ -94,7 +94,7 @@ struct ichx_desc {
39889 * this option allows driver caching written output values
39890 */
39891 bool use_outlvl_cache;
39892 -};
39893 +} __do_const;
39894
39895 static struct {
39896 spinlock_t lock;
39897 diff --git a/drivers/gpio/gpio-rcar.c b/drivers/gpio/gpio-rcar.c
39898 index 03c9148..c66e753 100644
39899 --- a/drivers/gpio/gpio-rcar.c
39900 +++ b/drivers/gpio/gpio-rcar.c
39901 @@ -355,7 +355,7 @@ static int gpio_rcar_probe(struct platform_device *pdev)
39902 struct gpio_rcar_priv *p;
39903 struct resource *io, *irq;
39904 struct gpio_chip *gpio_chip;
39905 - struct irq_chip *irq_chip;
39906 + irq_chip_no_const *irq_chip;
39907 struct device *dev = &pdev->dev;
39908 const char *name = dev_name(dev);
39909 int ret;
39910 diff --git a/drivers/gpio/gpio-vr41xx.c b/drivers/gpio/gpio-vr41xx.c
39911 index 66cbcc1..0c5e622 100644
39912 --- a/drivers/gpio/gpio-vr41xx.c
39913 +++ b/drivers/gpio/gpio-vr41xx.c
39914 @@ -224,7 +224,7 @@ static int giu_get_irq(unsigned int irq)
39915 printk(KERN_ERR "spurious GIU interrupt: %04x(%04x),%04x(%04x)\n",
39916 maskl, pendl, maskh, pendh);
39917
39918 - atomic_inc(&irq_err_count);
39919 + atomic_inc_unchecked(&irq_err_count);
39920
39921 return -EINVAL;
39922 }
39923 diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
39924 index d8b7099..8a314a5 100644
39925 --- a/drivers/gpu/drm/drm_crtc.c
39926 +++ b/drivers/gpu/drm/drm_crtc.c
39927 @@ -3500,7 +3500,7 @@ int drm_mode_getproperty_ioctl(struct drm_device *dev,
39928 goto done;
39929 }
39930
39931 - if (copy_to_user(&enum_ptr[copied].name,
39932 + if (copy_to_user(enum_ptr[copied].name,
39933 &prop_enum->name, DRM_PROP_NAME_LEN)) {
39934 ret = -EFAULT;
39935 goto done;
39936 diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
39937 index 03711d0..40e985f 100644
39938 --- a/drivers/gpu/drm/drm_drv.c
39939 +++ b/drivers/gpu/drm/drm_drv.c
39940 @@ -233,7 +233,7 @@ module_exit(drm_core_exit);
39941 /**
39942 * Copy and IOCTL return string to user space
39943 */
39944 -static int drm_copy_field(char *buf, size_t *buf_len, const char *value)
39945 +static int drm_copy_field(char __user *buf, size_t *buf_len, const char *value)
39946 {
39947 int len;
39948
39949 @@ -342,7 +342,7 @@ long drm_ioctl(struct file *filp,
39950 struct drm_file *file_priv = filp->private_data;
39951 struct drm_device *dev;
39952 const struct drm_ioctl_desc *ioctl = NULL;
39953 - drm_ioctl_t *func;
39954 + drm_ioctl_no_const_t func;
39955 unsigned int nr = DRM_IOCTL_NR(cmd);
39956 int retcode = -EINVAL;
39957 char stack_kdata[128];
39958 diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c
39959 index e1eba0b..98f69f9 100644
39960 --- a/drivers/gpu/drm/drm_fops.c
39961 +++ b/drivers/gpu/drm/drm_fops.c
39962 @@ -89,7 +89,7 @@ int drm_open(struct inode *inode, struct file *filp)
39963 return PTR_ERR(minor);
39964
39965 dev = minor->dev;
39966 - if (!dev->open_count++)
39967 + if (local_inc_return(&dev->open_count) == 1)
39968 need_setup = 1;
39969
39970 /* share address_space across all char-devs of a single device */
39971 @@ -106,7 +106,7 @@ int drm_open(struct inode *inode, struct file *filp)
39972 return 0;
39973
39974 err_undo:
39975 - dev->open_count--;
39976 + local_dec(&dev->open_count);
39977 drm_minor_release(minor);
39978 return retcode;
39979 }
39980 @@ -430,7 +430,7 @@ int drm_release(struct inode *inode, struct file *filp)
39981
39982 mutex_lock(&drm_global_mutex);
39983
39984 - DRM_DEBUG("open_count = %d\n", dev->open_count);
39985 + DRM_DEBUG("open_count = %ld\n", local_read(&dev->open_count));
39986
39987 if (dev->driver->preclose)
39988 dev->driver->preclose(dev, file_priv);
39989 @@ -439,10 +439,10 @@ int drm_release(struct inode *inode, struct file *filp)
39990 * Begin inline drm_release
39991 */
39992
39993 - DRM_DEBUG("pid = %d, device = 0x%lx, open_count = %d\n",
39994 + DRM_DEBUG("pid = %d, device = 0x%lx, open_count = %ld\n",
39995 task_pid_nr(current),
39996 (long)old_encode_dev(file_priv->minor->kdev->devt),
39997 - dev->open_count);
39998 + local_read(&dev->open_count));
39999
40000 /* Release any auth tokens that might point to this file_priv,
40001 (do that under the drm_global_mutex) */
40002 @@ -543,7 +543,7 @@ int drm_release(struct inode *inode, struct file *filp)
40003 * End inline drm_release
40004 */
40005
40006 - if (!--dev->open_count) {
40007 + if (local_dec_and_test(&dev->open_count)) {
40008 retcode = drm_lastclose(dev);
40009 if (drm_device_is_unplugged(dev))
40010 drm_put_dev(dev);
40011 diff --git a/drivers/gpu/drm/drm_global.c b/drivers/gpu/drm/drm_global.c
40012 index 3d2e91c..d31c4c9 100644
40013 --- a/drivers/gpu/drm/drm_global.c
40014 +++ b/drivers/gpu/drm/drm_global.c
40015 @@ -36,7 +36,7 @@
40016 struct drm_global_item {
40017 struct mutex mutex;
40018 void *object;
40019 - int refcount;
40020 + atomic_t refcount;
40021 };
40022
40023 static struct drm_global_item glob[DRM_GLOBAL_NUM];
40024 @@ -49,7 +49,7 @@ void drm_global_init(void)
40025 struct drm_global_item *item = &glob[i];
40026 mutex_init(&item->mutex);
40027 item->object = NULL;
40028 - item->refcount = 0;
40029 + atomic_set(&item->refcount, 0);
40030 }
40031 }
40032
40033 @@ -59,7 +59,7 @@ void drm_global_release(void)
40034 for (i = 0; i < DRM_GLOBAL_NUM; ++i) {
40035 struct drm_global_item *item = &glob[i];
40036 BUG_ON(item->object != NULL);
40037 - BUG_ON(item->refcount != 0);
40038 + BUG_ON(atomic_read(&item->refcount) != 0);
40039 }
40040 }
40041
40042 @@ -69,7 +69,7 @@ int drm_global_item_ref(struct drm_global_reference *ref)
40043 struct drm_global_item *item = &glob[ref->global_type];
40044
40045 mutex_lock(&item->mutex);
40046 - if (item->refcount == 0) {
40047 + if (atomic_read(&item->refcount) == 0) {
40048 item->object = kzalloc(ref->size, GFP_KERNEL);
40049 if (unlikely(item->object == NULL)) {
40050 ret = -ENOMEM;
40051 @@ -82,7 +82,7 @@ int drm_global_item_ref(struct drm_global_reference *ref)
40052 goto out_err;
40053
40054 }
40055 - ++item->refcount;
40056 + atomic_inc(&item->refcount);
40057 ref->object = item->object;
40058 mutex_unlock(&item->mutex);
40059 return 0;
40060 @@ -98,9 +98,9 @@ void drm_global_item_unref(struct drm_global_reference *ref)
40061 struct drm_global_item *item = &glob[ref->global_type];
40062
40063 mutex_lock(&item->mutex);
40064 - BUG_ON(item->refcount == 0);
40065 + BUG_ON(atomic_read(&item->refcount) == 0);
40066 BUG_ON(ref->object != item->object);
40067 - if (--item->refcount == 0) {
40068 + if (atomic_dec_and_test(&item->refcount)) {
40069 ref->release(ref);
40070 item->object = NULL;
40071 }
40072 diff --git a/drivers/gpu/drm/drm_info.c b/drivers/gpu/drm/drm_info.c
40073 index 7473035..a48b9c5 100644
40074 --- a/drivers/gpu/drm/drm_info.c
40075 +++ b/drivers/gpu/drm/drm_info.c
40076 @@ -75,10 +75,13 @@ int drm_vm_info(struct seq_file *m, void *data)
40077 struct drm_local_map *map;
40078 struct drm_map_list *r_list;
40079
40080 - /* Hardcoded from _DRM_FRAME_BUFFER,
40081 - _DRM_REGISTERS, _DRM_SHM, _DRM_AGP, and
40082 - _DRM_SCATTER_GATHER and _DRM_CONSISTENT */
40083 - const char *types[] = { "FB", "REG", "SHM", "AGP", "SG", "PCI" };
40084 + static const char * const types[] = {
40085 + [_DRM_FRAME_BUFFER] = "FB",
40086 + [_DRM_REGISTERS] = "REG",
40087 + [_DRM_SHM] = "SHM",
40088 + [_DRM_AGP] = "AGP",
40089 + [_DRM_SCATTER_GATHER] = "SG",
40090 + [_DRM_CONSISTENT] = "PCI"};
40091 const char *type;
40092 int i;
40093
40094 @@ -89,7 +92,7 @@ int drm_vm_info(struct seq_file *m, void *data)
40095 map = r_list->map;
40096 if (!map)
40097 continue;
40098 - if (map->type < 0 || map->type > 5)
40099 + if (map->type >= ARRAY_SIZE(types))
40100 type = "??";
40101 else
40102 type = types[map->type];
40103 @@ -261,7 +264,11 @@ int drm_vma_info(struct seq_file *m, void *data)
40104 vma->vm_flags & VM_MAYSHARE ? 's' : 'p',
40105 vma->vm_flags & VM_LOCKED ? 'l' : '-',
40106 vma->vm_flags & VM_IO ? 'i' : '-',
40107 +#ifdef CONFIG_GRKERNSEC_HIDESYM
40108 + 0);
40109 +#else
40110 vma->vm_pgoff);
40111 +#endif
40112
40113 #if defined(__i386__)
40114 pgprot = pgprot_val(vma->vm_page_prot);
40115 diff --git a/drivers/gpu/drm/drm_ioc32.c b/drivers/gpu/drm/drm_ioc32.c
40116 index 2f4c4343..dd12cd2 100644
40117 --- a/drivers/gpu/drm/drm_ioc32.c
40118 +++ b/drivers/gpu/drm/drm_ioc32.c
40119 @@ -457,7 +457,7 @@ static int compat_drm_infobufs(struct file *file, unsigned int cmd,
40120 request = compat_alloc_user_space(nbytes);
40121 if (!access_ok(VERIFY_WRITE, request, nbytes))
40122 return -EFAULT;
40123 - list = (struct drm_buf_desc *) (request + 1);
40124 + list = (struct drm_buf_desc __user *) (request + 1);
40125
40126 if (__put_user(count, &request->count)
40127 || __put_user(list, &request->list))
40128 @@ -518,7 +518,7 @@ static int compat_drm_mapbufs(struct file *file, unsigned int cmd,
40129 request = compat_alloc_user_space(nbytes);
40130 if (!access_ok(VERIFY_WRITE, request, nbytes))
40131 return -EFAULT;
40132 - list = (struct drm_buf_pub *) (request + 1);
40133 + list = (struct drm_buf_pub __user *) (request + 1);
40134
40135 if (__put_user(count, &request->count)
40136 || __put_user(list, &request->list))
40137 @@ -1016,7 +1016,7 @@ static int compat_drm_wait_vblank(struct file *file, unsigned int cmd,
40138 return 0;
40139 }
40140
40141 -drm_ioctl_compat_t *drm_compat_ioctls[] = {
40142 +drm_ioctl_compat_t drm_compat_ioctls[] = {
40143 [DRM_IOCTL_NR(DRM_IOCTL_VERSION32)] = compat_drm_version,
40144 [DRM_IOCTL_NR(DRM_IOCTL_GET_UNIQUE32)] = compat_drm_getunique,
40145 [DRM_IOCTL_NR(DRM_IOCTL_GET_MAP32)] = compat_drm_getmap,
40146 @@ -1062,7 +1062,6 @@ drm_ioctl_compat_t *drm_compat_ioctls[] = {
40147 long drm_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
40148 {
40149 unsigned int nr = DRM_IOCTL_NR(cmd);
40150 - drm_ioctl_compat_t *fn;
40151 int ret;
40152
40153 /* Assume that ioctls without an explicit compat routine will just
40154 @@ -1072,10 +1071,8 @@ long drm_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
40155 if (nr >= ARRAY_SIZE(drm_compat_ioctls))
40156 return drm_ioctl(filp, cmd, arg);
40157
40158 - fn = drm_compat_ioctls[nr];
40159 -
40160 - if (fn != NULL)
40161 - ret = (*fn) (filp, cmd, arg);
40162 + if (drm_compat_ioctls[nr] != NULL)
40163 + ret = (*drm_compat_ioctls[nr]) (filp, cmd, arg);
40164 else
40165 ret = drm_ioctl(filp, cmd, arg);
40166
40167 diff --git a/drivers/gpu/drm/drm_stub.c b/drivers/gpu/drm/drm_stub.c
40168 index 4c24c3a..c903cab 100644
40169 --- a/drivers/gpu/drm/drm_stub.c
40170 +++ b/drivers/gpu/drm/drm_stub.c
40171 @@ -455,7 +455,7 @@ void drm_unplug_dev(struct drm_device *dev)
40172
40173 drm_device_set_unplugged(dev);
40174
40175 - if (dev->open_count == 0) {
40176 + if (local_read(&dev->open_count) == 0) {
40177 drm_put_dev(dev);
40178 }
40179 mutex_unlock(&drm_global_mutex);
40180 diff --git a/drivers/gpu/drm/drm_sysfs.c b/drivers/gpu/drm/drm_sysfs.c
40181 index c22c309..ae758c3 100644
40182 --- a/drivers/gpu/drm/drm_sysfs.c
40183 +++ b/drivers/gpu/drm/drm_sysfs.c
40184 @@ -505,7 +505,7 @@ static void drm_sysfs_release(struct device *dev)
40185 */
40186 int drm_sysfs_device_add(struct drm_minor *minor)
40187 {
40188 - char *minor_str;
40189 + const char *minor_str;
40190 int r;
40191
40192 if (minor->type == DRM_MINOR_CONTROL)
40193 diff --git a/drivers/gpu/drm/i810/i810_drv.h b/drivers/gpu/drm/i810/i810_drv.h
40194 index d4d16ed..8fb0b51 100644
40195 --- a/drivers/gpu/drm/i810/i810_drv.h
40196 +++ b/drivers/gpu/drm/i810/i810_drv.h
40197 @@ -108,8 +108,8 @@ typedef struct drm_i810_private {
40198 int page_flipping;
40199
40200 wait_queue_head_t irq_queue;
40201 - atomic_t irq_received;
40202 - atomic_t irq_emitted;
40203 + atomic_unchecked_t irq_received;
40204 + atomic_unchecked_t irq_emitted;
40205
40206 int front_offset;
40207 } drm_i810_private_t;
40208 diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
40209 index eedb023..25076a4 100644
40210 --- a/drivers/gpu/drm/i915/i915_dma.c
40211 +++ b/drivers/gpu/drm/i915/i915_dma.c
40212 @@ -1280,7 +1280,7 @@ static bool i915_switcheroo_can_switch(struct pci_dev *pdev)
40213 bool can_switch;
40214
40215 spin_lock(&dev->count_lock);
40216 - can_switch = (dev->open_count == 0);
40217 + can_switch = (local_read(&dev->open_count) == 0);
40218 spin_unlock(&dev->count_lock);
40219 return can_switch;
40220 }
40221 diff --git a/drivers/gpu/drm/i915/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
40222 index 20fef6c..76c78fb 100644
40223 --- a/drivers/gpu/drm/i915/i915_gem_execbuffer.c
40224 +++ b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
40225 @@ -886,9 +886,9 @@ i915_gem_check_execbuffer(struct drm_i915_gem_execbuffer2 *exec)
40226
40227 static int
40228 validate_exec_list(struct drm_i915_gem_exec_object2 *exec,
40229 - int count)
40230 + unsigned int count)
40231 {
40232 - int i;
40233 + unsigned int i;
40234 unsigned relocs_total = 0;
40235 unsigned relocs_max = UINT_MAX / sizeof(struct drm_i915_gem_relocation_entry);
40236
40237 diff --git a/drivers/gpu/drm/i915/i915_ioc32.c b/drivers/gpu/drm/i915/i915_ioc32.c
40238 index 3c59584..500f2e9 100644
40239 --- a/drivers/gpu/drm/i915/i915_ioc32.c
40240 +++ b/drivers/gpu/drm/i915/i915_ioc32.c
40241 @@ -181,7 +181,7 @@ static int compat_i915_alloc(struct file *file, unsigned int cmd,
40242 (unsigned long)request);
40243 }
40244
40245 -static drm_ioctl_compat_t *i915_compat_ioctls[] = {
40246 +static drm_ioctl_compat_t i915_compat_ioctls[] = {
40247 [DRM_I915_BATCHBUFFER] = compat_i915_batchbuffer,
40248 [DRM_I915_CMDBUFFER] = compat_i915_cmdbuffer,
40249 [DRM_I915_GETPARAM] = compat_i915_getparam,
40250 @@ -202,18 +202,15 @@ static drm_ioctl_compat_t *i915_compat_ioctls[] = {
40251 long i915_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
40252 {
40253 unsigned int nr = DRM_IOCTL_NR(cmd);
40254 - drm_ioctl_compat_t *fn = NULL;
40255 int ret;
40256
40257 if (nr < DRM_COMMAND_BASE)
40258 return drm_compat_ioctl(filp, cmd, arg);
40259
40260 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(i915_compat_ioctls))
40261 - fn = i915_compat_ioctls[nr - DRM_COMMAND_BASE];
40262 -
40263 - if (fn != NULL)
40264 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(i915_compat_ioctls)) {
40265 + drm_ioctl_compat_t fn = i915_compat_ioctls[nr - DRM_COMMAND_BASE];
40266 ret = (*fn) (filp, cmd, arg);
40267 - else
40268 + } else
40269 ret = drm_ioctl(filp, cmd, arg);
40270
40271 return ret;
40272 diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
40273 index 5b60e25..eac1625 100644
40274 --- a/drivers/gpu/drm/i915/intel_display.c
40275 +++ b/drivers/gpu/drm/i915/intel_display.c
40276 @@ -11171,13 +11171,13 @@ struct intel_quirk {
40277 int subsystem_vendor;
40278 int subsystem_device;
40279 void (*hook)(struct drm_device *dev);
40280 -};
40281 +} __do_const;
40282
40283 /* For systems that don't have a meaningful PCI subdevice/subvendor ID */
40284 struct intel_dmi_quirk {
40285 void (*hook)(struct drm_device *dev);
40286 const struct dmi_system_id (*dmi_id_list)[];
40287 -};
40288 +} __do_const;
40289
40290 static int intel_dmi_reverse_brightness(const struct dmi_system_id *id)
40291 {
40292 @@ -11185,18 +11185,20 @@ static int intel_dmi_reverse_brightness(const struct dmi_system_id *id)
40293 return 1;
40294 }
40295
40296 -static const struct intel_dmi_quirk intel_dmi_quirks[] = {
40297 +static const struct dmi_system_id intel_dmi_quirks_table[] = {
40298 {
40299 - .dmi_id_list = &(const struct dmi_system_id[]) {
40300 - {
40301 - .callback = intel_dmi_reverse_brightness,
40302 - .ident = "NCR Corporation",
40303 - .matches = {DMI_MATCH(DMI_SYS_VENDOR, "NCR Corporation"),
40304 - DMI_MATCH(DMI_PRODUCT_NAME, ""),
40305 - },
40306 - },
40307 - { } /* terminating entry */
40308 + .callback = intel_dmi_reverse_brightness,
40309 + .ident = "NCR Corporation",
40310 + .matches = {DMI_MATCH(DMI_SYS_VENDOR, "NCR Corporation"),
40311 + DMI_MATCH(DMI_PRODUCT_NAME, ""),
40312 },
40313 + },
40314 + { } /* terminating entry */
40315 +};
40316 +
40317 +static const struct intel_dmi_quirk intel_dmi_quirks[] = {
40318 + {
40319 + .dmi_id_list = &intel_dmi_quirks_table,
40320 .hook = quirk_invert_brightness,
40321 },
40322 };
40323 diff --git a/drivers/gpu/drm/mga/mga_drv.h b/drivers/gpu/drm/mga/mga_drv.h
40324 index fe45321..836fdca 100644
40325 --- a/drivers/gpu/drm/mga/mga_drv.h
40326 +++ b/drivers/gpu/drm/mga/mga_drv.h
40327 @@ -120,9 +120,9 @@ typedef struct drm_mga_private {
40328 u32 clear_cmd;
40329 u32 maccess;
40330
40331 - atomic_t vbl_received; /**< Number of vblanks received. */
40332 + atomic_unchecked_t vbl_received; /**< Number of vblanks received. */
40333 wait_queue_head_t fence_queue;
40334 - atomic_t last_fence_retired;
40335 + atomic_unchecked_t last_fence_retired;
40336 u32 next_fence_to_post;
40337
40338 unsigned int fb_cpp;
40339 diff --git a/drivers/gpu/drm/mga/mga_ioc32.c b/drivers/gpu/drm/mga/mga_ioc32.c
40340 index 86b4bb8..ae237ad 100644
40341 --- a/drivers/gpu/drm/mga/mga_ioc32.c
40342 +++ b/drivers/gpu/drm/mga/mga_ioc32.c
40343 @@ -190,7 +190,7 @@ static int compat_mga_dma_bootstrap(struct file *file, unsigned int cmd,
40344 return 0;
40345 }
40346
40347 -drm_ioctl_compat_t *mga_compat_ioctls[] = {
40348 +drm_ioctl_compat_t mga_compat_ioctls[] = {
40349 [DRM_MGA_INIT] = compat_mga_init,
40350 [DRM_MGA_GETPARAM] = compat_mga_getparam,
40351 [DRM_MGA_DMA_BOOTSTRAP] = compat_mga_dma_bootstrap,
40352 @@ -208,18 +208,15 @@ drm_ioctl_compat_t *mga_compat_ioctls[] = {
40353 long mga_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
40354 {
40355 unsigned int nr = DRM_IOCTL_NR(cmd);
40356 - drm_ioctl_compat_t *fn = NULL;
40357 int ret;
40358
40359 if (nr < DRM_COMMAND_BASE)
40360 return drm_compat_ioctl(filp, cmd, arg);
40361
40362 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(mga_compat_ioctls))
40363 - fn = mga_compat_ioctls[nr - DRM_COMMAND_BASE];
40364 -
40365 - if (fn != NULL)
40366 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(mga_compat_ioctls)) {
40367 + drm_ioctl_compat_t fn = mga_compat_ioctls[nr - DRM_COMMAND_BASE];
40368 ret = (*fn) (filp, cmd, arg);
40369 - else
40370 + } else
40371 ret = drm_ioctl(filp, cmd, arg);
40372
40373 return ret;
40374 diff --git a/drivers/gpu/drm/mga/mga_irq.c b/drivers/gpu/drm/mga/mga_irq.c
40375 index 1b071b8..de8601a 100644
40376 --- a/drivers/gpu/drm/mga/mga_irq.c
40377 +++ b/drivers/gpu/drm/mga/mga_irq.c
40378 @@ -43,7 +43,7 @@ u32 mga_get_vblank_counter(struct drm_device *dev, int crtc)
40379 if (crtc != 0)
40380 return 0;
40381
40382 - return atomic_read(&dev_priv->vbl_received);
40383 + return atomic_read_unchecked(&dev_priv->vbl_received);
40384 }
40385
40386
40387 @@ -59,7 +59,7 @@ irqreturn_t mga_driver_irq_handler(int irq, void *arg)
40388 /* VBLANK interrupt */
40389 if (status & MGA_VLINEPEN) {
40390 MGA_WRITE(MGA_ICLEAR, MGA_VLINEICLR);
40391 - atomic_inc(&dev_priv->vbl_received);
40392 + atomic_inc_unchecked(&dev_priv->vbl_received);
40393 drm_handle_vblank(dev, 0);
40394 handled = 1;
40395 }
40396 @@ -78,7 +78,7 @@ irqreturn_t mga_driver_irq_handler(int irq, void *arg)
40397 if ((prim_start & ~0x03) != (prim_end & ~0x03))
40398 MGA_WRITE(MGA_PRIMEND, prim_end);
40399
40400 - atomic_inc(&dev_priv->last_fence_retired);
40401 + atomic_inc_unchecked(&dev_priv->last_fence_retired);
40402 wake_up(&dev_priv->fence_queue);
40403 handled = 1;
40404 }
40405 @@ -129,7 +129,7 @@ int mga_driver_fence_wait(struct drm_device *dev, unsigned int *sequence)
40406 * using fences.
40407 */
40408 DRM_WAIT_ON(ret, dev_priv->fence_queue, 3 * HZ,
40409 - (((cur_fence = atomic_read(&dev_priv->last_fence_retired))
40410 + (((cur_fence = atomic_read_unchecked(&dev_priv->last_fence_retired))
40411 - *sequence) <= (1 << 23)));
40412
40413 *sequence = cur_fence;
40414 diff --git a/drivers/gpu/drm/nouveau/nouveau_bios.c b/drivers/gpu/drm/nouveau/nouveau_bios.c
40415 index 8268a4c..5105708 100644
40416 --- a/drivers/gpu/drm/nouveau/nouveau_bios.c
40417 +++ b/drivers/gpu/drm/nouveau/nouveau_bios.c
40418 @@ -965,7 +965,7 @@ static int parse_bit_tmds_tbl_entry(struct drm_device *dev, struct nvbios *bios,
40419 struct bit_table {
40420 const char id;
40421 int (* const parse_fn)(struct drm_device *, struct nvbios *, struct bit_entry *);
40422 -};
40423 +} __no_const;
40424
40425 #define BIT_TABLE(id, funcid) ((struct bit_table){ id, parse_bit_##funcid##_tbl_entry })
40426
40427 diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.h b/drivers/gpu/drm/nouveau/nouveau_drm.h
40428 index 7efbafa..19f8087 100644
40429 --- a/drivers/gpu/drm/nouveau/nouveau_drm.h
40430 +++ b/drivers/gpu/drm/nouveau/nouveau_drm.h
40431 @@ -97,7 +97,6 @@ struct nouveau_drm {
40432 struct drm_global_reference mem_global_ref;
40433 struct ttm_bo_global_ref bo_global_ref;
40434 struct ttm_bo_device bdev;
40435 - atomic_t validate_sequence;
40436 int (*move)(struct nouveau_channel *,
40437 struct ttm_buffer_object *,
40438 struct ttm_mem_reg *, struct ttm_mem_reg *);
40439 diff --git a/drivers/gpu/drm/nouveau/nouveau_ioc32.c b/drivers/gpu/drm/nouveau/nouveau_ioc32.c
40440 index c1a7e5a..38b8539 100644
40441 --- a/drivers/gpu/drm/nouveau/nouveau_ioc32.c
40442 +++ b/drivers/gpu/drm/nouveau/nouveau_ioc32.c
40443 @@ -50,7 +50,7 @@ long nouveau_compat_ioctl(struct file *filp, unsigned int cmd,
40444 unsigned long arg)
40445 {
40446 unsigned int nr = DRM_IOCTL_NR(cmd);
40447 - drm_ioctl_compat_t *fn = NULL;
40448 + drm_ioctl_compat_t fn = NULL;
40449 int ret;
40450
40451 if (nr < DRM_COMMAND_BASE)
40452 diff --git a/drivers/gpu/drm/nouveau/nouveau_ttm.c b/drivers/gpu/drm/nouveau/nouveau_ttm.c
40453 index ab0228f..20b756b 100644
40454 --- a/drivers/gpu/drm/nouveau/nouveau_ttm.c
40455 +++ b/drivers/gpu/drm/nouveau/nouveau_ttm.c
40456 @@ -130,11 +130,11 @@ nouveau_vram_manager_debug(struct ttm_mem_type_manager *man, const char *prefix)
40457 }
40458
40459 const struct ttm_mem_type_manager_func nouveau_vram_manager = {
40460 - nouveau_vram_manager_init,
40461 - nouveau_vram_manager_fini,
40462 - nouveau_vram_manager_new,
40463 - nouveau_vram_manager_del,
40464 - nouveau_vram_manager_debug
40465 + .init = nouveau_vram_manager_init,
40466 + .takedown = nouveau_vram_manager_fini,
40467 + .get_node = nouveau_vram_manager_new,
40468 + .put_node = nouveau_vram_manager_del,
40469 + .debug = nouveau_vram_manager_debug
40470 };
40471
40472 static int
40473 @@ -199,11 +199,11 @@ nouveau_gart_manager_debug(struct ttm_mem_type_manager *man, const char *prefix)
40474 }
40475
40476 const struct ttm_mem_type_manager_func nouveau_gart_manager = {
40477 - nouveau_gart_manager_init,
40478 - nouveau_gart_manager_fini,
40479 - nouveau_gart_manager_new,
40480 - nouveau_gart_manager_del,
40481 - nouveau_gart_manager_debug
40482 + .init = nouveau_gart_manager_init,
40483 + .takedown = nouveau_gart_manager_fini,
40484 + .get_node = nouveau_gart_manager_new,
40485 + .put_node = nouveau_gart_manager_del,
40486 + .debug = nouveau_gart_manager_debug
40487 };
40488
40489 #include <core/subdev/vm/nv04.h>
40490 @@ -271,11 +271,11 @@ nv04_gart_manager_debug(struct ttm_mem_type_manager *man, const char *prefix)
40491 }
40492
40493 const struct ttm_mem_type_manager_func nv04_gart_manager = {
40494 - nv04_gart_manager_init,
40495 - nv04_gart_manager_fini,
40496 - nv04_gart_manager_new,
40497 - nv04_gart_manager_del,
40498 - nv04_gart_manager_debug
40499 + .init = nv04_gart_manager_init,
40500 + .takedown = nv04_gart_manager_fini,
40501 + .get_node = nv04_gart_manager_new,
40502 + .put_node = nv04_gart_manager_del,
40503 + .debug = nv04_gart_manager_debug
40504 };
40505
40506 int
40507 diff --git a/drivers/gpu/drm/nouveau/nouveau_vga.c b/drivers/gpu/drm/nouveau/nouveau_vga.c
40508 index fb84da3..d7ee463 100644
40509 --- a/drivers/gpu/drm/nouveau/nouveau_vga.c
40510 +++ b/drivers/gpu/drm/nouveau/nouveau_vga.c
40511 @@ -67,7 +67,7 @@ nouveau_switcheroo_can_switch(struct pci_dev *pdev)
40512 bool can_switch;
40513
40514 spin_lock(&dev->count_lock);
40515 - can_switch = (dev->open_count == 0);
40516 + can_switch = (local_read(&dev->open_count) == 0);
40517 spin_unlock(&dev->count_lock);
40518 return can_switch;
40519 }
40520 diff --git a/drivers/gpu/drm/qxl/qxl_cmd.c b/drivers/gpu/drm/qxl/qxl_cmd.c
40521 index eb89653..613cf71 100644
40522 --- a/drivers/gpu/drm/qxl/qxl_cmd.c
40523 +++ b/drivers/gpu/drm/qxl/qxl_cmd.c
40524 @@ -285,27 +285,27 @@ static int wait_for_io_cmd_user(struct qxl_device *qdev, uint8_t val, long port,
40525 int ret;
40526
40527 mutex_lock(&qdev->async_io_mutex);
40528 - irq_num = atomic_read(&qdev->irq_received_io_cmd);
40529 + irq_num = atomic_read_unchecked(&qdev->irq_received_io_cmd);
40530 if (qdev->last_sent_io_cmd > irq_num) {
40531 if (intr)
40532 ret = wait_event_interruptible_timeout(qdev->io_cmd_event,
40533 - atomic_read(&qdev->irq_received_io_cmd) > irq_num, 5*HZ);
40534 + atomic_read_unchecked(&qdev->irq_received_io_cmd) > irq_num, 5*HZ);
40535 else
40536 ret = wait_event_timeout(qdev->io_cmd_event,
40537 - atomic_read(&qdev->irq_received_io_cmd) > irq_num, 5*HZ);
40538 + atomic_read_unchecked(&qdev->irq_received_io_cmd) > irq_num, 5*HZ);
40539 /* 0 is timeout, just bail the "hw" has gone away */
40540 if (ret <= 0)
40541 goto out;
40542 - irq_num = atomic_read(&qdev->irq_received_io_cmd);
40543 + irq_num = atomic_read_unchecked(&qdev->irq_received_io_cmd);
40544 }
40545 outb(val, addr);
40546 qdev->last_sent_io_cmd = irq_num + 1;
40547 if (intr)
40548 ret = wait_event_interruptible_timeout(qdev->io_cmd_event,
40549 - atomic_read(&qdev->irq_received_io_cmd) > irq_num, 5*HZ);
40550 + atomic_read_unchecked(&qdev->irq_received_io_cmd) > irq_num, 5*HZ);
40551 else
40552 ret = wait_event_timeout(qdev->io_cmd_event,
40553 - atomic_read(&qdev->irq_received_io_cmd) > irq_num, 5*HZ);
40554 + atomic_read_unchecked(&qdev->irq_received_io_cmd) > irq_num, 5*HZ);
40555 out:
40556 if (ret > 0)
40557 ret = 0;
40558 diff --git a/drivers/gpu/drm/qxl/qxl_debugfs.c b/drivers/gpu/drm/qxl/qxl_debugfs.c
40559 index c3c2bbd..bc3c0fb 100644
40560 --- a/drivers/gpu/drm/qxl/qxl_debugfs.c
40561 +++ b/drivers/gpu/drm/qxl/qxl_debugfs.c
40562 @@ -42,10 +42,10 @@ qxl_debugfs_irq_received(struct seq_file *m, void *data)
40563 struct drm_info_node *node = (struct drm_info_node *) m->private;
40564 struct qxl_device *qdev = node->minor->dev->dev_private;
40565
40566 - seq_printf(m, "%d\n", atomic_read(&qdev->irq_received));
40567 - seq_printf(m, "%d\n", atomic_read(&qdev->irq_received_display));
40568 - seq_printf(m, "%d\n", atomic_read(&qdev->irq_received_cursor));
40569 - seq_printf(m, "%d\n", atomic_read(&qdev->irq_received_io_cmd));
40570 + seq_printf(m, "%d\n", atomic_read_unchecked(&qdev->irq_received));
40571 + seq_printf(m, "%d\n", atomic_read_unchecked(&qdev->irq_received_display));
40572 + seq_printf(m, "%d\n", atomic_read_unchecked(&qdev->irq_received_cursor));
40573 + seq_printf(m, "%d\n", atomic_read_unchecked(&qdev->irq_received_io_cmd));
40574 seq_printf(m, "%d\n", qdev->irq_received_error);
40575 return 0;
40576 }
40577 diff --git a/drivers/gpu/drm/qxl/qxl_drv.h b/drivers/gpu/drm/qxl/qxl_drv.h
40578 index 36ed40b..0397633 100644
40579 --- a/drivers/gpu/drm/qxl/qxl_drv.h
40580 +++ b/drivers/gpu/drm/qxl/qxl_drv.h
40581 @@ -290,10 +290,10 @@ struct qxl_device {
40582 unsigned int last_sent_io_cmd;
40583
40584 /* interrupt handling */
40585 - atomic_t irq_received;
40586 - atomic_t irq_received_display;
40587 - atomic_t irq_received_cursor;
40588 - atomic_t irq_received_io_cmd;
40589 + atomic_unchecked_t irq_received;
40590 + atomic_unchecked_t irq_received_display;
40591 + atomic_unchecked_t irq_received_cursor;
40592 + atomic_unchecked_t irq_received_io_cmd;
40593 unsigned irq_received_error;
40594 wait_queue_head_t display_event;
40595 wait_queue_head_t cursor_event;
40596 diff --git a/drivers/gpu/drm/qxl/qxl_ioctl.c b/drivers/gpu/drm/qxl/qxl_ioctl.c
40597 index 0bb86e6..d41416d 100644
40598 --- a/drivers/gpu/drm/qxl/qxl_ioctl.c
40599 +++ b/drivers/gpu/drm/qxl/qxl_ioctl.c
40600 @@ -181,7 +181,7 @@ static int qxl_process_single_command(struct qxl_device *qdev,
40601
40602 /* TODO copy slow path code from i915 */
40603 fb_cmd = qxl_bo_kmap_atomic_page(qdev, cmd_bo, (release->release_offset & PAGE_SIZE));
40604 - unwritten = __copy_from_user_inatomic_nocache(fb_cmd + sizeof(union qxl_release_info) + (release->release_offset & ~PAGE_SIZE), (void *)(unsigned long)cmd->command, cmd->command_size);
40605 + unwritten = __copy_from_user_inatomic_nocache(fb_cmd + sizeof(union qxl_release_info) + (release->release_offset & ~PAGE_SIZE), (void __force_user *)(unsigned long)cmd->command, cmd->command_size);
40606
40607 {
40608 struct qxl_drawable *draw = fb_cmd;
40609 @@ -201,7 +201,7 @@ static int qxl_process_single_command(struct qxl_device *qdev,
40610 struct drm_qxl_reloc reloc;
40611
40612 if (copy_from_user(&reloc,
40613 - &((struct drm_qxl_reloc *)(uintptr_t)cmd->relocs)[i],
40614 + &((struct drm_qxl_reloc __force_user *)(uintptr_t)cmd->relocs)[i],
40615 sizeof(reloc))) {
40616 ret = -EFAULT;
40617 goto out_free_bos;
40618 @@ -294,10 +294,10 @@ static int qxl_execbuffer_ioctl(struct drm_device *dev, void *data,
40619
40620 for (cmd_num = 0; cmd_num < execbuffer->commands_num; ++cmd_num) {
40621
40622 - struct drm_qxl_command *commands =
40623 - (struct drm_qxl_command *)(uintptr_t)execbuffer->commands;
40624 + struct drm_qxl_command __user *commands =
40625 + (struct drm_qxl_command __user *)(uintptr_t)execbuffer->commands;
40626
40627 - if (copy_from_user(&user_cmd, &commands[cmd_num],
40628 + if (copy_from_user(&user_cmd, (struct drm_qxl_command __force_user *)&commands[cmd_num],
40629 sizeof(user_cmd)))
40630 return -EFAULT;
40631
40632 diff --git a/drivers/gpu/drm/qxl/qxl_irq.c b/drivers/gpu/drm/qxl/qxl_irq.c
40633 index 28f84b4..fb3e224 100644
40634 --- a/drivers/gpu/drm/qxl/qxl_irq.c
40635 +++ b/drivers/gpu/drm/qxl/qxl_irq.c
40636 @@ -33,19 +33,19 @@ irqreturn_t qxl_irq_handler(int irq, void *arg)
40637
40638 pending = xchg(&qdev->ram_header->int_pending, 0);
40639
40640 - atomic_inc(&qdev->irq_received);
40641 + atomic_inc_unchecked(&qdev->irq_received);
40642
40643 if (pending & QXL_INTERRUPT_DISPLAY) {
40644 - atomic_inc(&qdev->irq_received_display);
40645 + atomic_inc_unchecked(&qdev->irq_received_display);
40646 wake_up_all(&qdev->display_event);
40647 qxl_queue_garbage_collect(qdev, false);
40648 }
40649 if (pending & QXL_INTERRUPT_CURSOR) {
40650 - atomic_inc(&qdev->irq_received_cursor);
40651 + atomic_inc_unchecked(&qdev->irq_received_cursor);
40652 wake_up_all(&qdev->cursor_event);
40653 }
40654 if (pending & QXL_INTERRUPT_IO_CMD) {
40655 - atomic_inc(&qdev->irq_received_io_cmd);
40656 + atomic_inc_unchecked(&qdev->irq_received_io_cmd);
40657 wake_up_all(&qdev->io_cmd_event);
40658 }
40659 if (pending & QXL_INTERRUPT_ERROR) {
40660 @@ -82,10 +82,10 @@ int qxl_irq_init(struct qxl_device *qdev)
40661 init_waitqueue_head(&qdev->io_cmd_event);
40662 INIT_WORK(&qdev->client_monitors_config_work,
40663 qxl_client_monitors_config_work_func);
40664 - atomic_set(&qdev->irq_received, 0);
40665 - atomic_set(&qdev->irq_received_display, 0);
40666 - atomic_set(&qdev->irq_received_cursor, 0);
40667 - atomic_set(&qdev->irq_received_io_cmd, 0);
40668 + atomic_set_unchecked(&qdev->irq_received, 0);
40669 + atomic_set_unchecked(&qdev->irq_received_display, 0);
40670 + atomic_set_unchecked(&qdev->irq_received_cursor, 0);
40671 + atomic_set_unchecked(&qdev->irq_received_io_cmd, 0);
40672 qdev->irq_received_error = 0;
40673 ret = drm_irq_install(qdev->ddev);
40674 qdev->ram_header->int_mask = QXL_INTERRUPT_MASK;
40675 diff --git a/drivers/gpu/drm/qxl/qxl_ttm.c b/drivers/gpu/drm/qxl/qxl_ttm.c
40676 index d52c275..4e6b43d 100644
40677 --- a/drivers/gpu/drm/qxl/qxl_ttm.c
40678 +++ b/drivers/gpu/drm/qxl/qxl_ttm.c
40679 @@ -103,7 +103,7 @@ static void qxl_ttm_global_fini(struct qxl_device *qdev)
40680 }
40681 }
40682
40683 -static struct vm_operations_struct qxl_ttm_vm_ops;
40684 +static vm_operations_struct_no_const qxl_ttm_vm_ops __read_only;
40685 static const struct vm_operations_struct *ttm_vm_ops;
40686
40687 static int qxl_ttm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
40688 @@ -147,8 +147,10 @@ int qxl_mmap(struct file *filp, struct vm_area_struct *vma)
40689 return r;
40690 if (unlikely(ttm_vm_ops == NULL)) {
40691 ttm_vm_ops = vma->vm_ops;
40692 + pax_open_kernel();
40693 qxl_ttm_vm_ops = *ttm_vm_ops;
40694 qxl_ttm_vm_ops.fault = &qxl_ttm_fault;
40695 + pax_close_kernel();
40696 }
40697 vma->vm_ops = &qxl_ttm_vm_ops;
40698 return 0;
40699 @@ -561,25 +563,23 @@ static int qxl_mm_dump_table(struct seq_file *m, void *data)
40700 static int qxl_ttm_debugfs_init(struct qxl_device *qdev)
40701 {
40702 #if defined(CONFIG_DEBUG_FS)
40703 - static struct drm_info_list qxl_mem_types_list[QXL_DEBUGFS_MEM_TYPES];
40704 - static char qxl_mem_types_names[QXL_DEBUGFS_MEM_TYPES][32];
40705 - unsigned i;
40706 + static struct drm_info_list qxl_mem_types_list[QXL_DEBUGFS_MEM_TYPES] = {
40707 + {
40708 + .name = "qxl_mem_mm",
40709 + .show = &qxl_mm_dump_table,
40710 + },
40711 + {
40712 + .name = "qxl_surf_mm",
40713 + .show = &qxl_mm_dump_table,
40714 + }
40715 + };
40716
40717 - for (i = 0; i < QXL_DEBUGFS_MEM_TYPES; i++) {
40718 - if (i == 0)
40719 - sprintf(qxl_mem_types_names[i], "qxl_mem_mm");
40720 - else
40721 - sprintf(qxl_mem_types_names[i], "qxl_surf_mm");
40722 - qxl_mem_types_list[i].name = qxl_mem_types_names[i];
40723 - qxl_mem_types_list[i].show = &qxl_mm_dump_table;
40724 - qxl_mem_types_list[i].driver_features = 0;
40725 - if (i == 0)
40726 - qxl_mem_types_list[i].data = qdev->mman.bdev.man[TTM_PL_VRAM].priv;
40727 - else
40728 - qxl_mem_types_list[i].data = qdev->mman.bdev.man[TTM_PL_PRIV0].priv;
40729 + pax_open_kernel();
40730 + *(void **)&qxl_mem_types_list[0].data = qdev->mman.bdev.man[TTM_PL_VRAM].priv;
40731 + *(void **)&qxl_mem_types_list[1].data = qdev->mman.bdev.man[TTM_PL_PRIV0].priv;
40732 + pax_close_kernel();
40733
40734 - }
40735 - return qxl_debugfs_add_files(qdev, qxl_mem_types_list, i);
40736 + return qxl_debugfs_add_files(qdev, qxl_mem_types_list, QXL_DEBUGFS_MEM_TYPES);
40737 #else
40738 return 0;
40739 #endif
40740 diff --git a/drivers/gpu/drm/r128/r128_cce.c b/drivers/gpu/drm/r128/r128_cce.c
40741 index 59459fe..be26b31 100644
40742 --- a/drivers/gpu/drm/r128/r128_cce.c
40743 +++ b/drivers/gpu/drm/r128/r128_cce.c
40744 @@ -377,7 +377,7 @@ static int r128_do_init_cce(struct drm_device *dev, drm_r128_init_t *init)
40745
40746 /* GH: Simple idle check.
40747 */
40748 - atomic_set(&dev_priv->idle_count, 0);
40749 + atomic_set_unchecked(&dev_priv->idle_count, 0);
40750
40751 /* We don't support anything other than bus-mastering ring mode,
40752 * but the ring can be in either AGP or PCI space for the ring
40753 diff --git a/drivers/gpu/drm/r128/r128_drv.h b/drivers/gpu/drm/r128/r128_drv.h
40754 index 5bf3f5f..7000661 100644
40755 --- a/drivers/gpu/drm/r128/r128_drv.h
40756 +++ b/drivers/gpu/drm/r128/r128_drv.h
40757 @@ -90,14 +90,14 @@ typedef struct drm_r128_private {
40758 int is_pci;
40759 unsigned long cce_buffers_offset;
40760
40761 - atomic_t idle_count;
40762 + atomic_unchecked_t idle_count;
40763
40764 int page_flipping;
40765 int current_page;
40766 u32 crtc_offset;
40767 u32 crtc_offset_cntl;
40768
40769 - atomic_t vbl_received;
40770 + atomic_unchecked_t vbl_received;
40771
40772 u32 color_fmt;
40773 unsigned int front_offset;
40774 diff --git a/drivers/gpu/drm/r128/r128_ioc32.c b/drivers/gpu/drm/r128/r128_ioc32.c
40775 index b0d0fd3..a6fbbe4 100644
40776 --- a/drivers/gpu/drm/r128/r128_ioc32.c
40777 +++ b/drivers/gpu/drm/r128/r128_ioc32.c
40778 @@ -178,7 +178,7 @@ static int compat_r128_getparam(struct file *file, unsigned int cmd,
40779 return drm_ioctl(file, DRM_IOCTL_R128_GETPARAM, (unsigned long)getparam);
40780 }
40781
40782 -drm_ioctl_compat_t *r128_compat_ioctls[] = {
40783 +drm_ioctl_compat_t r128_compat_ioctls[] = {
40784 [DRM_R128_INIT] = compat_r128_init,
40785 [DRM_R128_DEPTH] = compat_r128_depth,
40786 [DRM_R128_STIPPLE] = compat_r128_stipple,
40787 @@ -197,18 +197,15 @@ drm_ioctl_compat_t *r128_compat_ioctls[] = {
40788 long r128_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
40789 {
40790 unsigned int nr = DRM_IOCTL_NR(cmd);
40791 - drm_ioctl_compat_t *fn = NULL;
40792 int ret;
40793
40794 if (nr < DRM_COMMAND_BASE)
40795 return drm_compat_ioctl(filp, cmd, arg);
40796
40797 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(r128_compat_ioctls))
40798 - fn = r128_compat_ioctls[nr - DRM_COMMAND_BASE];
40799 -
40800 - if (fn != NULL)
40801 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(r128_compat_ioctls)) {
40802 + drm_ioctl_compat_t fn = r128_compat_ioctls[nr - DRM_COMMAND_BASE];
40803 ret = (*fn) (filp, cmd, arg);
40804 - else
40805 + } else
40806 ret = drm_ioctl(filp, cmd, arg);
40807
40808 return ret;
40809 diff --git a/drivers/gpu/drm/r128/r128_irq.c b/drivers/gpu/drm/r128/r128_irq.c
40810 index c2ae496..30b5993 100644
40811 --- a/drivers/gpu/drm/r128/r128_irq.c
40812 +++ b/drivers/gpu/drm/r128/r128_irq.c
40813 @@ -41,7 +41,7 @@ u32 r128_get_vblank_counter(struct drm_device *dev, int crtc)
40814 if (crtc != 0)
40815 return 0;
40816
40817 - return atomic_read(&dev_priv->vbl_received);
40818 + return atomic_read_unchecked(&dev_priv->vbl_received);
40819 }
40820
40821 irqreturn_t r128_driver_irq_handler(int irq, void *arg)
40822 @@ -55,7 +55,7 @@ irqreturn_t r128_driver_irq_handler(int irq, void *arg)
40823 /* VBLANK interrupt */
40824 if (status & R128_CRTC_VBLANK_INT) {
40825 R128_WRITE(R128_GEN_INT_STATUS, R128_CRTC_VBLANK_INT_AK);
40826 - atomic_inc(&dev_priv->vbl_received);
40827 + atomic_inc_unchecked(&dev_priv->vbl_received);
40828 drm_handle_vblank(dev, 0);
40829 return IRQ_HANDLED;
40830 }
40831 diff --git a/drivers/gpu/drm/r128/r128_state.c b/drivers/gpu/drm/r128/r128_state.c
40832 index e806dac..f81d32f 100644
40833 --- a/drivers/gpu/drm/r128/r128_state.c
40834 +++ b/drivers/gpu/drm/r128/r128_state.c
40835 @@ -320,10 +320,10 @@ static void r128_clear_box(drm_r128_private_t *dev_priv,
40836
40837 static void r128_cce_performance_boxes(drm_r128_private_t *dev_priv)
40838 {
40839 - if (atomic_read(&dev_priv->idle_count) == 0)
40840 + if (atomic_read_unchecked(&dev_priv->idle_count) == 0)
40841 r128_clear_box(dev_priv, 64, 4, 8, 8, 0, 255, 0);
40842 else
40843 - atomic_set(&dev_priv->idle_count, 0);
40844 + atomic_set_unchecked(&dev_priv->idle_count, 0);
40845 }
40846
40847 #endif
40848 diff --git a/drivers/gpu/drm/radeon/mkregtable.c b/drivers/gpu/drm/radeon/mkregtable.c
40849 index 4a85bb6..aaea819 100644
40850 --- a/drivers/gpu/drm/radeon/mkregtable.c
40851 +++ b/drivers/gpu/drm/radeon/mkregtable.c
40852 @@ -624,14 +624,14 @@ static int parser_auth(struct table *t, const char *filename)
40853 regex_t mask_rex;
40854 regmatch_t match[4];
40855 char buf[1024];
40856 - size_t end;
40857 + long end;
40858 int len;
40859 int done = 0;
40860 int r;
40861 unsigned o;
40862 struct offset *offset;
40863 char last_reg_s[10];
40864 - int last_reg;
40865 + unsigned long last_reg;
40866
40867 if (regcomp
40868 (&mask_rex, "(0x[0-9a-fA-F]*) *([_a-zA-Z0-9]*)", REG_EXTENDED)) {
40869 diff --git a/drivers/gpu/drm/radeon/radeon_device.c b/drivers/gpu/drm/radeon/radeon_device.c
40870 index 2cd144c..a01c95a 100644
40871 --- a/drivers/gpu/drm/radeon/radeon_device.c
40872 +++ b/drivers/gpu/drm/radeon/radeon_device.c
40873 @@ -1129,7 +1129,7 @@ static bool radeon_switcheroo_can_switch(struct pci_dev *pdev)
40874 bool can_switch;
40875
40876 spin_lock(&dev->count_lock);
40877 - can_switch = (dev->open_count == 0);
40878 + can_switch = (local_read(&dev->open_count) == 0);
40879 spin_unlock(&dev->count_lock);
40880 return can_switch;
40881 }
40882 diff --git a/drivers/gpu/drm/radeon/radeon_drv.h b/drivers/gpu/drm/radeon/radeon_drv.h
40883 index dafd812..1bf20c7 100644
40884 --- a/drivers/gpu/drm/radeon/radeon_drv.h
40885 +++ b/drivers/gpu/drm/radeon/radeon_drv.h
40886 @@ -262,7 +262,7 @@ typedef struct drm_radeon_private {
40887
40888 /* SW interrupt */
40889 wait_queue_head_t swi_queue;
40890 - atomic_t swi_emitted;
40891 + atomic_unchecked_t swi_emitted;
40892 int vblank_crtc;
40893 uint32_t irq_enable_reg;
40894 uint32_t r500_disp_irq_reg;
40895 diff --git a/drivers/gpu/drm/radeon/radeon_ioc32.c b/drivers/gpu/drm/radeon/radeon_ioc32.c
40896 index bdb0f93..5ff558f 100644
40897 --- a/drivers/gpu/drm/radeon/radeon_ioc32.c
40898 +++ b/drivers/gpu/drm/radeon/radeon_ioc32.c
40899 @@ -358,7 +358,7 @@ static int compat_radeon_cp_setparam(struct file *file, unsigned int cmd,
40900 request = compat_alloc_user_space(sizeof(*request));
40901 if (!access_ok(VERIFY_WRITE, request, sizeof(*request))
40902 || __put_user(req32.param, &request->param)
40903 - || __put_user((void __user *)(unsigned long)req32.value,
40904 + || __put_user((unsigned long)req32.value,
40905 &request->value))
40906 return -EFAULT;
40907
40908 @@ -368,7 +368,7 @@ static int compat_radeon_cp_setparam(struct file *file, unsigned int cmd,
40909 #define compat_radeon_cp_setparam NULL
40910 #endif /* X86_64 || IA64 */
40911
40912 -static drm_ioctl_compat_t *radeon_compat_ioctls[] = {
40913 +static drm_ioctl_compat_t radeon_compat_ioctls[] = {
40914 [DRM_RADEON_CP_INIT] = compat_radeon_cp_init,
40915 [DRM_RADEON_CLEAR] = compat_radeon_cp_clear,
40916 [DRM_RADEON_STIPPLE] = compat_radeon_cp_stipple,
40917 @@ -393,18 +393,15 @@ static drm_ioctl_compat_t *radeon_compat_ioctls[] = {
40918 long radeon_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
40919 {
40920 unsigned int nr = DRM_IOCTL_NR(cmd);
40921 - drm_ioctl_compat_t *fn = NULL;
40922 int ret;
40923
40924 if (nr < DRM_COMMAND_BASE)
40925 return drm_compat_ioctl(filp, cmd, arg);
40926
40927 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(radeon_compat_ioctls))
40928 - fn = radeon_compat_ioctls[nr - DRM_COMMAND_BASE];
40929 -
40930 - if (fn != NULL)
40931 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(radeon_compat_ioctls)) {
40932 + drm_ioctl_compat_t fn = radeon_compat_ioctls[nr - DRM_COMMAND_BASE];
40933 ret = (*fn) (filp, cmd, arg);
40934 - else
40935 + } else
40936 ret = drm_ioctl(filp, cmd, arg);
40937
40938 return ret;
40939 diff --git a/drivers/gpu/drm/radeon/radeon_irq.c b/drivers/gpu/drm/radeon/radeon_irq.c
40940 index 244b19b..c19226d 100644
40941 --- a/drivers/gpu/drm/radeon/radeon_irq.c
40942 +++ b/drivers/gpu/drm/radeon/radeon_irq.c
40943 @@ -226,8 +226,8 @@ static int radeon_emit_irq(struct drm_device * dev)
40944 unsigned int ret;
40945 RING_LOCALS;
40946
40947 - atomic_inc(&dev_priv->swi_emitted);
40948 - ret = atomic_read(&dev_priv->swi_emitted);
40949 + atomic_inc_unchecked(&dev_priv->swi_emitted);
40950 + ret = atomic_read_unchecked(&dev_priv->swi_emitted);
40951
40952 BEGIN_RING(4);
40953 OUT_RING_REG(RADEON_LAST_SWI_REG, ret);
40954 @@ -353,7 +353,7 @@ int radeon_driver_irq_postinstall(struct drm_device *dev)
40955 drm_radeon_private_t *dev_priv =
40956 (drm_radeon_private_t *) dev->dev_private;
40957
40958 - atomic_set(&dev_priv->swi_emitted, 0);
40959 + atomic_set_unchecked(&dev_priv->swi_emitted, 0);
40960 init_waitqueue_head(&dev_priv->swi_queue);
40961
40962 dev->max_vblank_count = 0x001fffff;
40963 diff --git a/drivers/gpu/drm/radeon/radeon_state.c b/drivers/gpu/drm/radeon/radeon_state.c
40964 index 956ab7f..fbd36d8 100644
40965 --- a/drivers/gpu/drm/radeon/radeon_state.c
40966 +++ b/drivers/gpu/drm/radeon/radeon_state.c
40967 @@ -2168,7 +2168,7 @@ static int radeon_cp_clear(struct drm_device *dev, void *data, struct drm_file *
40968 if (sarea_priv->nbox > RADEON_NR_SAREA_CLIPRECTS)
40969 sarea_priv->nbox = RADEON_NR_SAREA_CLIPRECTS;
40970
40971 - if (copy_from_user(&depth_boxes, clear->depth_boxes,
40972 + if (sarea_priv->nbox > RADEON_NR_SAREA_CLIPRECTS || copy_from_user(&depth_boxes, clear->depth_boxes,
40973 sarea_priv->nbox * sizeof(depth_boxes[0])))
40974 return -EFAULT;
40975
40976 @@ -3031,7 +3031,7 @@ static int radeon_cp_getparam(struct drm_device *dev, void *data, struct drm_fil
40977 {
40978 drm_radeon_private_t *dev_priv = dev->dev_private;
40979 drm_radeon_getparam_t *param = data;
40980 - int value;
40981 + int value = 0;
40982
40983 DRM_DEBUG("pid=%d\n", DRM_CURRENTPID);
40984
40985 diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c b/drivers/gpu/drm/radeon/radeon_ttm.c
40986 index c8a8a51..219dacc 100644
40987 --- a/drivers/gpu/drm/radeon/radeon_ttm.c
40988 +++ b/drivers/gpu/drm/radeon/radeon_ttm.c
40989 @@ -797,7 +797,7 @@ void radeon_ttm_set_active_vram_size(struct radeon_device *rdev, u64 size)
40990 man->size = size >> PAGE_SHIFT;
40991 }
40992
40993 -static struct vm_operations_struct radeon_ttm_vm_ops;
40994 +static vm_operations_struct_no_const radeon_ttm_vm_ops __read_only;
40995 static const struct vm_operations_struct *ttm_vm_ops = NULL;
40996
40997 static int radeon_ttm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
40998 @@ -838,8 +838,10 @@ int radeon_mmap(struct file *filp, struct vm_area_struct *vma)
40999 }
41000 if (unlikely(ttm_vm_ops == NULL)) {
41001 ttm_vm_ops = vma->vm_ops;
41002 + pax_open_kernel();
41003 radeon_ttm_vm_ops = *ttm_vm_ops;
41004 radeon_ttm_vm_ops.fault = &radeon_ttm_fault;
41005 + pax_close_kernel();
41006 }
41007 vma->vm_ops = &radeon_ttm_vm_ops;
41008 return 0;
41009 diff --git a/drivers/gpu/drm/tegra/dc.c b/drivers/gpu/drm/tegra/dc.c
41010 index edb871d..a275c6ed 100644
41011 --- a/drivers/gpu/drm/tegra/dc.c
41012 +++ b/drivers/gpu/drm/tegra/dc.c
41013 @@ -1057,7 +1057,7 @@ static int tegra_dc_debugfs_init(struct tegra_dc *dc, struct drm_minor *minor)
41014 }
41015
41016 for (i = 0; i < ARRAY_SIZE(debugfs_files); i++)
41017 - dc->debugfs_files[i].data = dc;
41018 + *(void **)&dc->debugfs_files[i].data = dc;
41019
41020 err = drm_debugfs_create_files(dc->debugfs_files,
41021 ARRAY_SIZE(debugfs_files),
41022 diff --git a/drivers/gpu/drm/tegra/dsi.c b/drivers/gpu/drm/tegra/dsi.c
41023 index 0e599f0..c9ea7c7 100644
41024 --- a/drivers/gpu/drm/tegra/dsi.c
41025 +++ b/drivers/gpu/drm/tegra/dsi.c
41026 @@ -39,7 +39,7 @@ struct tegra_dsi {
41027 struct clk *clk_lp;
41028 struct clk *clk;
41029
41030 - struct drm_info_list *debugfs_files;
41031 + drm_info_list_no_const *debugfs_files;
41032 struct drm_minor *minor;
41033 struct dentry *debugfs;
41034
41035 diff --git a/drivers/gpu/drm/tegra/hdmi.c b/drivers/gpu/drm/tegra/hdmi.c
41036 index 6928015..c9853e7 100644
41037 --- a/drivers/gpu/drm/tegra/hdmi.c
41038 +++ b/drivers/gpu/drm/tegra/hdmi.c
41039 @@ -59,7 +59,7 @@ struct tegra_hdmi {
41040 bool stereo;
41041 bool dvi;
41042
41043 - struct drm_info_list *debugfs_files;
41044 + drm_info_list_no_const *debugfs_files;
41045 struct drm_minor *minor;
41046 struct dentry *debugfs;
41047 };
41048 diff --git a/drivers/gpu/drm/ttm/ttm_bo_manager.c b/drivers/gpu/drm/ttm/ttm_bo_manager.c
41049 index bd850c9..d9f3573 100644
41050 --- a/drivers/gpu/drm/ttm/ttm_bo_manager.c
41051 +++ b/drivers/gpu/drm/ttm/ttm_bo_manager.c
41052 @@ -146,10 +146,10 @@ static void ttm_bo_man_debug(struct ttm_mem_type_manager *man,
41053 }
41054
41055 const struct ttm_mem_type_manager_func ttm_bo_manager_func = {
41056 - ttm_bo_man_init,
41057 - ttm_bo_man_takedown,
41058 - ttm_bo_man_get_node,
41059 - ttm_bo_man_put_node,
41060 - ttm_bo_man_debug
41061 + .init = ttm_bo_man_init,
41062 + .takedown = ttm_bo_man_takedown,
41063 + .get_node = ttm_bo_man_get_node,
41064 + .put_node = ttm_bo_man_put_node,
41065 + .debug = ttm_bo_man_debug
41066 };
41067 EXPORT_SYMBOL(ttm_bo_manager_func);
41068 diff --git a/drivers/gpu/drm/ttm/ttm_memory.c b/drivers/gpu/drm/ttm/ttm_memory.c
41069 index dbc2def..0a9f710 100644
41070 --- a/drivers/gpu/drm/ttm/ttm_memory.c
41071 +++ b/drivers/gpu/drm/ttm/ttm_memory.c
41072 @@ -264,7 +264,7 @@ static int ttm_mem_init_kernel_zone(struct ttm_mem_global *glob,
41073 zone->glob = glob;
41074 glob->zone_kernel = zone;
41075 ret = kobject_init_and_add(
41076 - &zone->kobj, &ttm_mem_zone_kobj_type, &glob->kobj, zone->name);
41077 + &zone->kobj, &ttm_mem_zone_kobj_type, &glob->kobj, "%s", zone->name);
41078 if (unlikely(ret != 0)) {
41079 kobject_put(&zone->kobj);
41080 return ret;
41081 @@ -347,7 +347,7 @@ static int ttm_mem_init_dma32_zone(struct ttm_mem_global *glob,
41082 zone->glob = glob;
41083 glob->zone_dma32 = zone;
41084 ret = kobject_init_and_add(
41085 - &zone->kobj, &ttm_mem_zone_kobj_type, &glob->kobj, zone->name);
41086 + &zone->kobj, &ttm_mem_zone_kobj_type, &glob->kobj, "%s", zone->name);
41087 if (unlikely(ret != 0)) {
41088 kobject_put(&zone->kobj);
41089 return ret;
41090 diff --git a/drivers/gpu/drm/ttm/ttm_page_alloc.c b/drivers/gpu/drm/ttm/ttm_page_alloc.c
41091 index 863bef9..cba15cf 100644
41092 --- a/drivers/gpu/drm/ttm/ttm_page_alloc.c
41093 +++ b/drivers/gpu/drm/ttm/ttm_page_alloc.c
41094 @@ -391,9 +391,9 @@ out:
41095 static unsigned long
41096 ttm_pool_shrink_scan(struct shrinker *shrink, struct shrink_control *sc)
41097 {
41098 - static atomic_t start_pool = ATOMIC_INIT(0);
41099 + static atomic_unchecked_t start_pool = ATOMIC_INIT(0);
41100 unsigned i;
41101 - unsigned pool_offset = atomic_add_return(1, &start_pool);
41102 + unsigned pool_offset = atomic_add_return_unchecked(1, &start_pool);
41103 struct ttm_page_pool *pool;
41104 int shrink_pages = sc->nr_to_scan;
41105 unsigned long freed = 0;
41106 diff --git a/drivers/gpu/drm/udl/udl_fb.c b/drivers/gpu/drm/udl/udl_fb.c
41107 index 3771763..883f206 100644
41108 --- a/drivers/gpu/drm/udl/udl_fb.c
41109 +++ b/drivers/gpu/drm/udl/udl_fb.c
41110 @@ -367,7 +367,6 @@ static int udl_fb_release(struct fb_info *info, int user)
41111 fb_deferred_io_cleanup(info);
41112 kfree(info->fbdefio);
41113 info->fbdefio = NULL;
41114 - info->fbops->fb_mmap = udl_fb_mmap;
41115 }
41116
41117 pr_warn("released /dev/fb%d user=%d count=%d\n",
41118 diff --git a/drivers/gpu/drm/via/via_drv.h b/drivers/gpu/drm/via/via_drv.h
41119 index ad02732..144f5ed 100644
41120 --- a/drivers/gpu/drm/via/via_drv.h
41121 +++ b/drivers/gpu/drm/via/via_drv.h
41122 @@ -51,7 +51,7 @@ typedef struct drm_via_ring_buffer {
41123 typedef uint32_t maskarray_t[5];
41124
41125 typedef struct drm_via_irq {
41126 - atomic_t irq_received;
41127 + atomic_unchecked_t irq_received;
41128 uint32_t pending_mask;
41129 uint32_t enable_mask;
41130 wait_queue_head_t irq_queue;
41131 @@ -75,7 +75,7 @@ typedef struct drm_via_private {
41132 struct timeval last_vblank;
41133 int last_vblank_valid;
41134 unsigned usec_per_vblank;
41135 - atomic_t vbl_received;
41136 + atomic_unchecked_t vbl_received;
41137 drm_via_state_t hc_state;
41138 char pci_buf[VIA_PCI_BUF_SIZE];
41139 const uint32_t *fire_offsets[VIA_FIRE_BUF_SIZE];
41140 diff --git a/drivers/gpu/drm/via/via_irq.c b/drivers/gpu/drm/via/via_irq.c
41141 index 1319433..a993b0c 100644
41142 --- a/drivers/gpu/drm/via/via_irq.c
41143 +++ b/drivers/gpu/drm/via/via_irq.c
41144 @@ -101,7 +101,7 @@ u32 via_get_vblank_counter(struct drm_device *dev, int crtc)
41145 if (crtc != 0)
41146 return 0;
41147
41148 - return atomic_read(&dev_priv->vbl_received);
41149 + return atomic_read_unchecked(&dev_priv->vbl_received);
41150 }
41151
41152 irqreturn_t via_driver_irq_handler(int irq, void *arg)
41153 @@ -116,8 +116,8 @@ irqreturn_t via_driver_irq_handler(int irq, void *arg)
41154
41155 status = VIA_READ(VIA_REG_INTERRUPT);
41156 if (status & VIA_IRQ_VBLANK_PENDING) {
41157 - atomic_inc(&dev_priv->vbl_received);
41158 - if (!(atomic_read(&dev_priv->vbl_received) & 0x0F)) {
41159 + atomic_inc_unchecked(&dev_priv->vbl_received);
41160 + if (!(atomic_read_unchecked(&dev_priv->vbl_received) & 0x0F)) {
41161 do_gettimeofday(&cur_vblank);
41162 if (dev_priv->last_vblank_valid) {
41163 dev_priv->usec_per_vblank =
41164 @@ -127,7 +127,7 @@ irqreturn_t via_driver_irq_handler(int irq, void *arg)
41165 dev_priv->last_vblank = cur_vblank;
41166 dev_priv->last_vblank_valid = 1;
41167 }
41168 - if (!(atomic_read(&dev_priv->vbl_received) & 0xFF)) {
41169 + if (!(atomic_read_unchecked(&dev_priv->vbl_received) & 0xFF)) {
41170 DRM_DEBUG("US per vblank is: %u\n",
41171 dev_priv->usec_per_vblank);
41172 }
41173 @@ -137,7 +137,7 @@ irqreturn_t via_driver_irq_handler(int irq, void *arg)
41174
41175 for (i = 0; i < dev_priv->num_irqs; ++i) {
41176 if (status & cur_irq->pending_mask) {
41177 - atomic_inc(&cur_irq->irq_received);
41178 + atomic_inc_unchecked(&cur_irq->irq_received);
41179 wake_up(&cur_irq->irq_queue);
41180 handled = 1;
41181 if (dev_priv->irq_map[drm_via_irq_dma0_td] == i)
41182 @@ -242,11 +242,11 @@ via_driver_irq_wait(struct drm_device *dev, unsigned int irq, int force_sequence
41183 DRM_WAIT_ON(ret, cur_irq->irq_queue, 3 * HZ,
41184 ((VIA_READ(masks[irq][2]) & masks[irq][3]) ==
41185 masks[irq][4]));
41186 - cur_irq_sequence = atomic_read(&cur_irq->irq_received);
41187 + cur_irq_sequence = atomic_read_unchecked(&cur_irq->irq_received);
41188 } else {
41189 DRM_WAIT_ON(ret, cur_irq->irq_queue, 3 * HZ,
41190 (((cur_irq_sequence =
41191 - atomic_read(&cur_irq->irq_received)) -
41192 + atomic_read_unchecked(&cur_irq->irq_received)) -
41193 *sequence) <= (1 << 23)));
41194 }
41195 *sequence = cur_irq_sequence;
41196 @@ -284,7 +284,7 @@ void via_driver_irq_preinstall(struct drm_device *dev)
41197 }
41198
41199 for (i = 0; i < dev_priv->num_irqs; ++i) {
41200 - atomic_set(&cur_irq->irq_received, 0);
41201 + atomic_set_unchecked(&cur_irq->irq_received, 0);
41202 cur_irq->enable_mask = dev_priv->irq_masks[i][0];
41203 cur_irq->pending_mask = dev_priv->irq_masks[i][1];
41204 init_waitqueue_head(&cur_irq->irq_queue);
41205 @@ -366,7 +366,7 @@ int via_wait_irq(struct drm_device *dev, void *data, struct drm_file *file_priv)
41206 switch (irqwait->request.type & ~VIA_IRQ_FLAGS_MASK) {
41207 case VIA_IRQ_RELATIVE:
41208 irqwait->request.sequence +=
41209 - atomic_read(&cur_irq->irq_received);
41210 + atomic_read_unchecked(&cur_irq->irq_received);
41211 irqwait->request.type &= ~_DRM_VBLANK_RELATIVE;
41212 case VIA_IRQ_ABSOLUTE:
41213 break;
41214 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
41215 index 6b252a8..5975dfe 100644
41216 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
41217 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
41218 @@ -437,7 +437,7 @@ struct vmw_private {
41219 * Fencing and IRQs.
41220 */
41221
41222 - atomic_t marker_seq;
41223 + atomic_unchecked_t marker_seq;
41224 wait_queue_head_t fence_queue;
41225 wait_queue_head_t fifo_queue;
41226 int fence_queue_waiters; /* Protected by hw_mutex */
41227 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c b/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
41228 index 6ccd993..618d592 100644
41229 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
41230 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
41231 @@ -154,7 +154,7 @@ int vmw_fifo_init(struct vmw_private *dev_priv, struct vmw_fifo_state *fifo)
41232 (unsigned int) min,
41233 (unsigned int) fifo->capabilities);
41234
41235 - atomic_set(&dev_priv->marker_seq, dev_priv->last_read_seqno);
41236 + atomic_set_unchecked(&dev_priv->marker_seq, dev_priv->last_read_seqno);
41237 iowrite32(dev_priv->last_read_seqno, fifo_mem + SVGA_FIFO_FENCE);
41238 vmw_marker_queue_init(&fifo->marker_queue);
41239 return vmw_fifo_send_fence(dev_priv, &dummy);
41240 @@ -372,7 +372,7 @@ void *vmw_fifo_reserve(struct vmw_private *dev_priv, uint32_t bytes)
41241 if (reserveable)
41242 iowrite32(bytes, fifo_mem +
41243 SVGA_FIFO_RESERVED);
41244 - return fifo_mem + (next_cmd >> 2);
41245 + return (__le32 __force_kernel *)fifo_mem + (next_cmd >> 2);
41246 } else {
41247 need_bounce = true;
41248 }
41249 @@ -492,7 +492,7 @@ int vmw_fifo_send_fence(struct vmw_private *dev_priv, uint32_t *seqno)
41250
41251 fm = vmw_fifo_reserve(dev_priv, bytes);
41252 if (unlikely(fm == NULL)) {
41253 - *seqno = atomic_read(&dev_priv->marker_seq);
41254 + *seqno = atomic_read_unchecked(&dev_priv->marker_seq);
41255 ret = -ENOMEM;
41256 (void)vmw_fallback_wait(dev_priv, false, true, *seqno,
41257 false, 3*HZ);
41258 @@ -500,7 +500,7 @@ int vmw_fifo_send_fence(struct vmw_private *dev_priv, uint32_t *seqno)
41259 }
41260
41261 do {
41262 - *seqno = atomic_add_return(1, &dev_priv->marker_seq);
41263 + *seqno = atomic_add_return_unchecked(1, &dev_priv->marker_seq);
41264 } while (*seqno == 0);
41265
41266 if (!(fifo_state->capabilities & SVGA_FIFO_CAP_FENCE)) {
41267 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c b/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c
41268 index b1273e8..9c274fd 100644
41269 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c
41270 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c
41271 @@ -164,9 +164,9 @@ static void vmw_gmrid_man_debug(struct ttm_mem_type_manager *man,
41272 }
41273
41274 const struct ttm_mem_type_manager_func vmw_gmrid_manager_func = {
41275 - vmw_gmrid_man_init,
41276 - vmw_gmrid_man_takedown,
41277 - vmw_gmrid_man_get_node,
41278 - vmw_gmrid_man_put_node,
41279 - vmw_gmrid_man_debug
41280 + .init = vmw_gmrid_man_init,
41281 + .takedown = vmw_gmrid_man_takedown,
41282 + .get_node = vmw_gmrid_man_get_node,
41283 + .put_node = vmw_gmrid_man_put_node,
41284 + .debug = vmw_gmrid_man_debug
41285 };
41286 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c b/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c
41287 index 37881ec..319065d 100644
41288 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c
41289 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c
41290 @@ -235,7 +235,7 @@ int vmw_present_ioctl(struct drm_device *dev, void *data,
41291 int ret;
41292
41293 num_clips = arg->num_clips;
41294 - clips_ptr = (struct drm_vmw_rect *)(unsigned long)arg->clips_ptr;
41295 + clips_ptr = (struct drm_vmw_rect __user *)(unsigned long)arg->clips_ptr;
41296
41297 if (unlikely(num_clips == 0))
41298 return 0;
41299 @@ -318,7 +318,7 @@ int vmw_present_readback_ioctl(struct drm_device *dev, void *data,
41300 int ret;
41301
41302 num_clips = arg->num_clips;
41303 - clips_ptr = (struct drm_vmw_rect *)(unsigned long)arg->clips_ptr;
41304 + clips_ptr = (struct drm_vmw_rect __user *)(unsigned long)arg->clips_ptr;
41305
41306 if (unlikely(num_clips == 0))
41307 return 0;
41308 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c b/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
41309 index 0c42376..6febe77 100644
41310 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
41311 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
41312 @@ -107,7 +107,7 @@ bool vmw_seqno_passed(struct vmw_private *dev_priv,
41313 * emitted. Then the fence is stale and signaled.
41314 */
41315
41316 - ret = ((atomic_read(&dev_priv->marker_seq) - seqno)
41317 + ret = ((atomic_read_unchecked(&dev_priv->marker_seq) - seqno)
41318 > VMW_FENCE_WRAP);
41319
41320 return ret;
41321 @@ -138,7 +138,7 @@ int vmw_fallback_wait(struct vmw_private *dev_priv,
41322
41323 if (fifo_idle)
41324 down_read(&fifo_state->rwsem);
41325 - signal_seq = atomic_read(&dev_priv->marker_seq);
41326 + signal_seq = atomic_read_unchecked(&dev_priv->marker_seq);
41327 ret = 0;
41328
41329 for (;;) {
41330 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c b/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c
41331 index 8a8725c2..afed796 100644
41332 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c
41333 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c
41334 @@ -151,7 +151,7 @@ int vmw_wait_lag(struct vmw_private *dev_priv,
41335 while (!vmw_lag_lt(queue, us)) {
41336 spin_lock(&queue->lock);
41337 if (list_empty(&queue->head))
41338 - seqno = atomic_read(&dev_priv->marker_seq);
41339 + seqno = atomic_read_unchecked(&dev_priv->marker_seq);
41340 else {
41341 marker = list_first_entry(&queue->head,
41342 struct vmw_marker, head);
41343 diff --git a/drivers/gpu/vga/vga_switcheroo.c b/drivers/gpu/vga/vga_switcheroo.c
41344 index ec0ae2d..dc0780b 100644
41345 --- a/drivers/gpu/vga/vga_switcheroo.c
41346 +++ b/drivers/gpu/vga/vga_switcheroo.c
41347 @@ -643,7 +643,7 @@ static int vga_switcheroo_runtime_resume(struct device *dev)
41348
41349 /* this version is for the case where the power switch is separate
41350 to the device being powered down. */
41351 -int vga_switcheroo_init_domain_pm_ops(struct device *dev, struct dev_pm_domain *domain)
41352 +int vga_switcheroo_init_domain_pm_ops(struct device *dev, dev_pm_domain_no_const *domain)
41353 {
41354 /* copy over all the bus versions */
41355 if (dev->bus && dev->bus->pm) {
41356 @@ -688,7 +688,7 @@ static int vga_switcheroo_runtime_resume_hdmi_audio(struct device *dev)
41357 return ret;
41358 }
41359
41360 -int vga_switcheroo_init_domain_pm_optimus_hdmi_audio(struct device *dev, struct dev_pm_domain *domain)
41361 +int vga_switcheroo_init_domain_pm_optimus_hdmi_audio(struct device *dev, dev_pm_domain_no_const *domain)
41362 {
41363 /* copy over all the bus versions */
41364 if (dev->bus && dev->bus->pm) {
41365 diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
41366 index da52279..83ba0e7 100644
41367 --- a/drivers/hid/hid-core.c
41368 +++ b/drivers/hid/hid-core.c
41369 @@ -2466,7 +2466,7 @@ EXPORT_SYMBOL_GPL(hid_ignore);
41370
41371 int hid_add_device(struct hid_device *hdev)
41372 {
41373 - static atomic_t id = ATOMIC_INIT(0);
41374 + static atomic_unchecked_t id = ATOMIC_INIT(0);
41375 int ret;
41376
41377 if (WARN_ON(hdev->status & HID_STAT_ADDED))
41378 @@ -2508,7 +2508,7 @@ int hid_add_device(struct hid_device *hdev)
41379 /* XXX hack, any other cleaner solution after the driver core
41380 * is converted to allow more than 20 bytes as the device name? */
41381 dev_set_name(&hdev->dev, "%04X:%04X:%04X.%04X", hdev->bus,
41382 - hdev->vendor, hdev->product, atomic_inc_return(&id));
41383 + hdev->vendor, hdev->product, atomic_inc_return_unchecked(&id));
41384
41385 hid_debug_register(hdev, dev_name(&hdev->dev));
41386 ret = device_add(&hdev->dev);
41387 diff --git a/drivers/hid/hid-wiimote-debug.c b/drivers/hid/hid-wiimote-debug.c
41388 index c13fb5b..55a3802 100644
41389 --- a/drivers/hid/hid-wiimote-debug.c
41390 +++ b/drivers/hid/hid-wiimote-debug.c
41391 @@ -66,7 +66,7 @@ static ssize_t wiidebug_eeprom_read(struct file *f, char __user *u, size_t s,
41392 else if (size == 0)
41393 return -EIO;
41394
41395 - if (copy_to_user(u, buf, size))
41396 + if (size > sizeof(buf) || copy_to_user(u, buf, size))
41397 return -EFAULT;
41398
41399 *off += size;
41400 diff --git a/drivers/hid/uhid.c b/drivers/hid/uhid.c
41401 index 0d078c3..cd0962c 100644
41402 --- a/drivers/hid/uhid.c
41403 +++ b/drivers/hid/uhid.c
41404 @@ -47,7 +47,7 @@ struct uhid_device {
41405 struct mutex report_lock;
41406 wait_queue_head_t report_wait;
41407 atomic_t report_done;
41408 - atomic_t report_id;
41409 + atomic_unchecked_t report_id;
41410 struct uhid_event report_buf;
41411 };
41412
41413 @@ -163,7 +163,7 @@ static int uhid_hid_get_raw(struct hid_device *hid, unsigned char rnum,
41414
41415 spin_lock_irqsave(&uhid->qlock, flags);
41416 ev->type = UHID_FEATURE;
41417 - ev->u.feature.id = atomic_inc_return(&uhid->report_id);
41418 + ev->u.feature.id = atomic_inc_return_unchecked(&uhid->report_id);
41419 ev->u.feature.rnum = rnum;
41420 ev->u.feature.rtype = report_type;
41421
41422 @@ -539,7 +539,7 @@ static int uhid_dev_feature_answer(struct uhid_device *uhid,
41423 spin_lock_irqsave(&uhid->qlock, flags);
41424
41425 /* id for old report; drop it silently */
41426 - if (atomic_read(&uhid->report_id) != ev->u.feature_answer.id)
41427 + if (atomic_read_unchecked(&uhid->report_id) != ev->u.feature_answer.id)
41428 goto unlock;
41429 if (atomic_read(&uhid->report_done))
41430 goto unlock;
41431 diff --git a/drivers/hv/channel.c b/drivers/hv/channel.c
41432 index 602ca86..10a6573 100644
41433 --- a/drivers/hv/channel.c
41434 +++ b/drivers/hv/channel.c
41435 @@ -365,8 +365,8 @@ int vmbus_establish_gpadl(struct vmbus_channel *channel, void *kbuffer,
41436 int ret = 0;
41437 int t;
41438
41439 - next_gpadl_handle = atomic_read(&vmbus_connection.next_gpadl_handle);
41440 - atomic_inc(&vmbus_connection.next_gpadl_handle);
41441 + next_gpadl_handle = atomic_read_unchecked(&vmbus_connection.next_gpadl_handle);
41442 + atomic_inc_unchecked(&vmbus_connection.next_gpadl_handle);
41443
41444 ret = create_gpadl_header(kbuffer, size, &msginfo, &msgcount);
41445 if (ret)
41446 diff --git a/drivers/hv/hv.c b/drivers/hv/hv.c
41447 index bcb4950..61dba6c 100644
41448 --- a/drivers/hv/hv.c
41449 +++ b/drivers/hv/hv.c
41450 @@ -112,7 +112,7 @@ static u64 do_hypercall(u64 control, void *input, void *output)
41451 u64 output_address = (output) ? virt_to_phys(output) : 0;
41452 u32 output_address_hi = output_address >> 32;
41453 u32 output_address_lo = output_address & 0xFFFFFFFF;
41454 - void *hypercall_page = hv_context.hypercall_page;
41455 + void *hypercall_page = ktva_ktla(hv_context.hypercall_page);
41456
41457 __asm__ __volatile__ ("call *%8" : "=d"(hv_status_hi),
41458 "=a"(hv_status_lo) : "d" (control_hi),
41459 @@ -154,7 +154,7 @@ int hv_init(void)
41460 /* See if the hypercall page is already set */
41461 rdmsrl(HV_X64_MSR_HYPERCALL, hypercall_msr.as_uint64);
41462
41463 - virtaddr = __vmalloc(PAGE_SIZE, GFP_KERNEL, PAGE_KERNEL_EXEC);
41464 + virtaddr = __vmalloc(PAGE_SIZE, GFP_KERNEL, PAGE_KERNEL_RX);
41465
41466 if (!virtaddr)
41467 goto cleanup;
41468 diff --git a/drivers/hv/hv_balloon.c b/drivers/hv/hv_balloon.c
41469 index 7e6d78d..7354bed 100644
41470 --- a/drivers/hv/hv_balloon.c
41471 +++ b/drivers/hv/hv_balloon.c
41472 @@ -464,7 +464,7 @@ MODULE_PARM_DESC(hot_add, "If set attempt memory hot_add");
41473
41474 module_param(pressure_report_delay, uint, (S_IRUGO | S_IWUSR));
41475 MODULE_PARM_DESC(pressure_report_delay, "Delay in secs in reporting pressure");
41476 -static atomic_t trans_id = ATOMIC_INIT(0);
41477 +static atomic_unchecked_t trans_id = ATOMIC_INIT(0);
41478
41479 static int dm_ring_size = (5 * PAGE_SIZE);
41480
41481 @@ -886,7 +886,7 @@ static void hot_add_req(struct work_struct *dummy)
41482 pr_info("Memory hot add failed\n");
41483
41484 dm->state = DM_INITIALIZED;
41485 - resp.hdr.trans_id = atomic_inc_return(&trans_id);
41486 + resp.hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
41487 vmbus_sendpacket(dm->dev->channel, &resp,
41488 sizeof(struct dm_hot_add_response),
41489 (unsigned long)NULL,
41490 @@ -960,7 +960,7 @@ static void post_status(struct hv_dynmem_device *dm)
41491 memset(&status, 0, sizeof(struct dm_status));
41492 status.hdr.type = DM_STATUS_REPORT;
41493 status.hdr.size = sizeof(struct dm_status);
41494 - status.hdr.trans_id = atomic_inc_return(&trans_id);
41495 + status.hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
41496
41497 /*
41498 * The host expects the guest to report free memory.
41499 @@ -980,7 +980,7 @@ static void post_status(struct hv_dynmem_device *dm)
41500 * send the status. This can happen if we were interrupted
41501 * after we picked our transaction ID.
41502 */
41503 - if (status.hdr.trans_id != atomic_read(&trans_id))
41504 + if (status.hdr.trans_id != atomic_read_unchecked(&trans_id))
41505 return;
41506
41507 vmbus_sendpacket(dm->dev->channel, &status,
41508 @@ -1108,7 +1108,7 @@ static void balloon_up(struct work_struct *dummy)
41509 */
41510
41511 do {
41512 - bl_resp->hdr.trans_id = atomic_inc_return(&trans_id);
41513 + bl_resp->hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
41514 ret = vmbus_sendpacket(dm_device.dev->channel,
41515 bl_resp,
41516 bl_resp->hdr.size,
41517 @@ -1152,7 +1152,7 @@ static void balloon_down(struct hv_dynmem_device *dm,
41518
41519 memset(&resp, 0, sizeof(struct dm_unballoon_response));
41520 resp.hdr.type = DM_UNBALLOON_RESPONSE;
41521 - resp.hdr.trans_id = atomic_inc_return(&trans_id);
41522 + resp.hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
41523 resp.hdr.size = sizeof(struct dm_unballoon_response);
41524
41525 vmbus_sendpacket(dm_device.dev->channel, &resp,
41526 @@ -1216,7 +1216,7 @@ static void version_resp(struct hv_dynmem_device *dm,
41527 memset(&version_req, 0, sizeof(struct dm_version_request));
41528 version_req.hdr.type = DM_VERSION_REQUEST;
41529 version_req.hdr.size = sizeof(struct dm_version_request);
41530 - version_req.hdr.trans_id = atomic_inc_return(&trans_id);
41531 + version_req.hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
41532 version_req.version.version = DYNMEM_PROTOCOL_VERSION_WIN7;
41533 version_req.is_last_attempt = 1;
41534
41535 @@ -1386,7 +1386,7 @@ static int balloon_probe(struct hv_device *dev,
41536 memset(&version_req, 0, sizeof(struct dm_version_request));
41537 version_req.hdr.type = DM_VERSION_REQUEST;
41538 version_req.hdr.size = sizeof(struct dm_version_request);
41539 - version_req.hdr.trans_id = atomic_inc_return(&trans_id);
41540 + version_req.hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
41541 version_req.version.version = DYNMEM_PROTOCOL_VERSION_WIN8;
41542 version_req.is_last_attempt = 0;
41543
41544 @@ -1417,7 +1417,7 @@ static int balloon_probe(struct hv_device *dev,
41545 memset(&cap_msg, 0, sizeof(struct dm_capabilities));
41546 cap_msg.hdr.type = DM_CAPABILITIES_REPORT;
41547 cap_msg.hdr.size = sizeof(struct dm_capabilities);
41548 - cap_msg.hdr.trans_id = atomic_inc_return(&trans_id);
41549 + cap_msg.hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
41550
41551 cap_msg.caps.cap_bits.balloon = 1;
41552 cap_msg.caps.cap_bits.hot_add = 1;
41553 diff --git a/drivers/hv/hyperv_vmbus.h b/drivers/hv/hyperv_vmbus.h
41554 index 860134d..ea3a79a 100644
41555 --- a/drivers/hv/hyperv_vmbus.h
41556 +++ b/drivers/hv/hyperv_vmbus.h
41557 @@ -602,7 +602,7 @@ enum vmbus_connect_state {
41558 struct vmbus_connection {
41559 enum vmbus_connect_state conn_state;
41560
41561 - atomic_t next_gpadl_handle;
41562 + atomic_unchecked_t next_gpadl_handle;
41563
41564 /*
41565 * Represents channel interrupts. Each bit position represents a
41566 diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
41567 index 8e53a3c..7a64e44 100644
41568 --- a/drivers/hv/vmbus_drv.c
41569 +++ b/drivers/hv/vmbus_drv.c
41570 @@ -807,10 +807,10 @@ int vmbus_device_register(struct hv_device *child_device_obj)
41571 {
41572 int ret = 0;
41573
41574 - static atomic_t device_num = ATOMIC_INIT(0);
41575 + static atomic_unchecked_t device_num = ATOMIC_INIT(0);
41576
41577 dev_set_name(&child_device_obj->device, "vmbus_0_%d",
41578 - atomic_inc_return(&device_num));
41579 + atomic_inc_return_unchecked(&device_num));
41580
41581 child_device_obj->device.bus = &hv_bus;
41582 child_device_obj->device.parent = &hv_acpi_dev->dev;
41583 diff --git a/drivers/hwmon/acpi_power_meter.c b/drivers/hwmon/acpi_power_meter.c
41584 index 579bdf9..75118b5 100644
41585 --- a/drivers/hwmon/acpi_power_meter.c
41586 +++ b/drivers/hwmon/acpi_power_meter.c
41587 @@ -116,7 +116,7 @@ struct sensor_template {
41588 struct device_attribute *devattr,
41589 const char *buf, size_t count);
41590 int index;
41591 -};
41592 +} __do_const;
41593
41594 /* Averaging interval */
41595 static int update_avg_interval(struct acpi_power_meter_resource *resource)
41596 @@ -631,7 +631,7 @@ static int register_attrs(struct acpi_power_meter_resource *resource,
41597 struct sensor_template *attrs)
41598 {
41599 struct device *dev = &resource->acpi_dev->dev;
41600 - struct sensor_device_attribute *sensors =
41601 + sensor_device_attribute_no_const *sensors =
41602 &resource->sensors[resource->num_sensors];
41603 int res = 0;
41604
41605 diff --git a/drivers/hwmon/applesmc.c b/drivers/hwmon/applesmc.c
41606 index 3288f13..71cfb4e 100644
41607 --- a/drivers/hwmon/applesmc.c
41608 +++ b/drivers/hwmon/applesmc.c
41609 @@ -1106,7 +1106,7 @@ static int applesmc_create_nodes(struct applesmc_node_group *groups, int num)
41610 {
41611 struct applesmc_node_group *grp;
41612 struct applesmc_dev_attr *node;
41613 - struct attribute *attr;
41614 + attribute_no_const *attr;
41615 int ret, i;
41616
41617 for (grp = groups; grp->format; grp++) {
41618 diff --git a/drivers/hwmon/asus_atk0110.c b/drivers/hwmon/asus_atk0110.c
41619 index ae208f6..48b6c5b 100644
41620 --- a/drivers/hwmon/asus_atk0110.c
41621 +++ b/drivers/hwmon/asus_atk0110.c
41622 @@ -147,10 +147,10 @@ MODULE_DEVICE_TABLE(acpi, atk_ids);
41623 struct atk_sensor_data {
41624 struct list_head list;
41625 struct atk_data *data;
41626 - struct device_attribute label_attr;
41627 - struct device_attribute input_attr;
41628 - struct device_attribute limit1_attr;
41629 - struct device_attribute limit2_attr;
41630 + device_attribute_no_const label_attr;
41631 + device_attribute_no_const input_attr;
41632 + device_attribute_no_const limit1_attr;
41633 + device_attribute_no_const limit2_attr;
41634 char label_attr_name[ATTR_NAME_SIZE];
41635 char input_attr_name[ATTR_NAME_SIZE];
41636 char limit1_attr_name[ATTR_NAME_SIZE];
41637 @@ -270,7 +270,7 @@ static ssize_t atk_name_show(struct device *dev,
41638 static struct device_attribute atk_name_attr =
41639 __ATTR(name, 0444, atk_name_show, NULL);
41640
41641 -static void atk_init_attribute(struct device_attribute *attr, char *name,
41642 +static void atk_init_attribute(device_attribute_no_const *attr, char *name,
41643 sysfs_show_func show)
41644 {
41645 sysfs_attr_init(&attr->attr);
41646 diff --git a/drivers/hwmon/coretemp.c b/drivers/hwmon/coretemp.c
41647 index d76f0b7..55ae976 100644
41648 --- a/drivers/hwmon/coretemp.c
41649 +++ b/drivers/hwmon/coretemp.c
41650 @@ -784,7 +784,7 @@ static int coretemp_cpu_callback(struct notifier_block *nfb,
41651 return NOTIFY_OK;
41652 }
41653
41654 -static struct notifier_block coretemp_cpu_notifier __refdata = {
41655 +static struct notifier_block coretemp_cpu_notifier = {
41656 .notifier_call = coretemp_cpu_callback,
41657 };
41658
41659 diff --git a/drivers/hwmon/ibmaem.c b/drivers/hwmon/ibmaem.c
41660 index 632f1dc..57e6a58 100644
41661 --- a/drivers/hwmon/ibmaem.c
41662 +++ b/drivers/hwmon/ibmaem.c
41663 @@ -926,7 +926,7 @@ static int aem_register_sensors(struct aem_data *data,
41664 struct aem_rw_sensor_template *rw)
41665 {
41666 struct device *dev = &data->pdev->dev;
41667 - struct sensor_device_attribute *sensors = data->sensors;
41668 + sensor_device_attribute_no_const *sensors = data->sensors;
41669 int err;
41670
41671 /* Set up read-only sensors */
41672 diff --git a/drivers/hwmon/iio_hwmon.c b/drivers/hwmon/iio_hwmon.c
41673 index 9fbb1b1..efbaa3e 100644
41674 --- a/drivers/hwmon/iio_hwmon.c
41675 +++ b/drivers/hwmon/iio_hwmon.c
41676 @@ -61,7 +61,7 @@ static int iio_hwmon_probe(struct platform_device *pdev)
41677 {
41678 struct device *dev = &pdev->dev;
41679 struct iio_hwmon_state *st;
41680 - struct sensor_device_attribute *a;
41681 + sensor_device_attribute_no_const *a;
41682 int ret, i;
41683 int in_i = 1, temp_i = 1, curr_i = 1;
41684 enum iio_chan_type type;
41685 diff --git a/drivers/hwmon/nct6775.c b/drivers/hwmon/nct6775.c
41686 index 38d5a63..cf2c2ea 100644
41687 --- a/drivers/hwmon/nct6775.c
41688 +++ b/drivers/hwmon/nct6775.c
41689 @@ -944,10 +944,10 @@ static struct attribute_group *
41690 nct6775_create_attr_group(struct device *dev, struct sensor_template_group *tg,
41691 int repeat)
41692 {
41693 - struct attribute_group *group;
41694 + attribute_group_no_const *group;
41695 struct sensor_device_attr_u *su;
41696 - struct sensor_device_attribute *a;
41697 - struct sensor_device_attribute_2 *a2;
41698 + sensor_device_attribute_no_const *a;
41699 + sensor_device_attribute_2_no_const *a2;
41700 struct attribute **attrs;
41701 struct sensor_device_template **t;
41702 int i, count;
41703 diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c
41704 index 291d11f..3f0dbbd 100644
41705 --- a/drivers/hwmon/pmbus/pmbus_core.c
41706 +++ b/drivers/hwmon/pmbus/pmbus_core.c
41707 @@ -783,7 +783,7 @@ static int pmbus_add_attribute(struct pmbus_data *data, struct attribute *attr)
41708 return 0;
41709 }
41710
41711 -static void pmbus_dev_attr_init(struct device_attribute *dev_attr,
41712 +static void pmbus_dev_attr_init(device_attribute_no_const *dev_attr,
41713 const char *name,
41714 umode_t mode,
41715 ssize_t (*show)(struct device *dev,
41716 @@ -800,7 +800,7 @@ static void pmbus_dev_attr_init(struct device_attribute *dev_attr,
41717 dev_attr->store = store;
41718 }
41719
41720 -static void pmbus_attr_init(struct sensor_device_attribute *a,
41721 +static void pmbus_attr_init(sensor_device_attribute_no_const *a,
41722 const char *name,
41723 umode_t mode,
41724 ssize_t (*show)(struct device *dev,
41725 @@ -822,7 +822,7 @@ static int pmbus_add_boolean(struct pmbus_data *data,
41726 u16 reg, u8 mask)
41727 {
41728 struct pmbus_boolean *boolean;
41729 - struct sensor_device_attribute *a;
41730 + sensor_device_attribute_no_const *a;
41731
41732 boolean = devm_kzalloc(data->dev, sizeof(*boolean), GFP_KERNEL);
41733 if (!boolean)
41734 @@ -847,7 +847,7 @@ static struct pmbus_sensor *pmbus_add_sensor(struct pmbus_data *data,
41735 bool update, bool readonly)
41736 {
41737 struct pmbus_sensor *sensor;
41738 - struct device_attribute *a;
41739 + device_attribute_no_const *a;
41740
41741 sensor = devm_kzalloc(data->dev, sizeof(*sensor), GFP_KERNEL);
41742 if (!sensor)
41743 @@ -878,7 +878,7 @@ static int pmbus_add_label(struct pmbus_data *data,
41744 const char *lstring, int index)
41745 {
41746 struct pmbus_label *label;
41747 - struct device_attribute *a;
41748 + device_attribute_no_const *a;
41749
41750 label = devm_kzalloc(data->dev, sizeof(*label), GFP_KERNEL);
41751 if (!label)
41752 diff --git a/drivers/hwmon/sht15.c b/drivers/hwmon/sht15.c
41753 index 97cd45a..ac54d8b 100644
41754 --- a/drivers/hwmon/sht15.c
41755 +++ b/drivers/hwmon/sht15.c
41756 @@ -169,7 +169,7 @@ struct sht15_data {
41757 int supply_uv;
41758 bool supply_uv_valid;
41759 struct work_struct update_supply_work;
41760 - atomic_t interrupt_handled;
41761 + atomic_unchecked_t interrupt_handled;
41762 };
41763
41764 /**
41765 @@ -542,13 +542,13 @@ static int sht15_measurement(struct sht15_data *data,
41766 ret = gpio_direction_input(data->pdata->gpio_data);
41767 if (ret)
41768 return ret;
41769 - atomic_set(&data->interrupt_handled, 0);
41770 + atomic_set_unchecked(&data->interrupt_handled, 0);
41771
41772 enable_irq(gpio_to_irq(data->pdata->gpio_data));
41773 if (gpio_get_value(data->pdata->gpio_data) == 0) {
41774 disable_irq_nosync(gpio_to_irq(data->pdata->gpio_data));
41775 /* Only relevant if the interrupt hasn't occurred. */
41776 - if (!atomic_read(&data->interrupt_handled))
41777 + if (!atomic_read_unchecked(&data->interrupt_handled))
41778 schedule_work(&data->read_work);
41779 }
41780 ret = wait_event_timeout(data->wait_queue,
41781 @@ -820,7 +820,7 @@ static irqreturn_t sht15_interrupt_fired(int irq, void *d)
41782
41783 /* First disable the interrupt */
41784 disable_irq_nosync(irq);
41785 - atomic_inc(&data->interrupt_handled);
41786 + atomic_inc_unchecked(&data->interrupt_handled);
41787 /* Then schedule a reading work struct */
41788 if (data->state != SHT15_READING_NOTHING)
41789 schedule_work(&data->read_work);
41790 @@ -842,11 +842,11 @@ static void sht15_bh_read_data(struct work_struct *work_s)
41791 * If not, then start the interrupt again - care here as could
41792 * have gone low in meantime so verify it hasn't!
41793 */
41794 - atomic_set(&data->interrupt_handled, 0);
41795 + atomic_set_unchecked(&data->interrupt_handled, 0);
41796 enable_irq(gpio_to_irq(data->pdata->gpio_data));
41797 /* If still not occurred or another handler was scheduled */
41798 if (gpio_get_value(data->pdata->gpio_data)
41799 - || atomic_read(&data->interrupt_handled))
41800 + || atomic_read_unchecked(&data->interrupt_handled))
41801 return;
41802 }
41803
41804 diff --git a/drivers/hwmon/via-cputemp.c b/drivers/hwmon/via-cputemp.c
41805 index 8df43c5..b07b91d 100644
41806 --- a/drivers/hwmon/via-cputemp.c
41807 +++ b/drivers/hwmon/via-cputemp.c
41808 @@ -296,7 +296,7 @@ static int via_cputemp_cpu_callback(struct notifier_block *nfb,
41809 return NOTIFY_OK;
41810 }
41811
41812 -static struct notifier_block via_cputemp_cpu_notifier __refdata = {
41813 +static struct notifier_block via_cputemp_cpu_notifier = {
41814 .notifier_call = via_cputemp_cpu_callback,
41815 };
41816
41817 diff --git a/drivers/i2c/busses/i2c-amd756-s4882.c b/drivers/i2c/busses/i2c-amd756-s4882.c
41818 index 41fc683..a39cfea 100644
41819 --- a/drivers/i2c/busses/i2c-amd756-s4882.c
41820 +++ b/drivers/i2c/busses/i2c-amd756-s4882.c
41821 @@ -43,7 +43,7 @@
41822 extern struct i2c_adapter amd756_smbus;
41823
41824 static struct i2c_adapter *s4882_adapter;
41825 -static struct i2c_algorithm *s4882_algo;
41826 +static i2c_algorithm_no_const *s4882_algo;
41827
41828 /* Wrapper access functions for multiplexed SMBus */
41829 static DEFINE_MUTEX(amd756_lock);
41830 diff --git a/drivers/i2c/busses/i2c-diolan-u2c.c b/drivers/i2c/busses/i2c-diolan-u2c.c
41831 index 721f7eb..0fd2a09 100644
41832 --- a/drivers/i2c/busses/i2c-diolan-u2c.c
41833 +++ b/drivers/i2c/busses/i2c-diolan-u2c.c
41834 @@ -98,7 +98,7 @@ MODULE_PARM_DESC(frequency, "I2C clock frequency in hertz");
41835 /* usb layer */
41836
41837 /* Send command to device, and get response. */
41838 -static int diolan_usb_transfer(struct i2c_diolan_u2c *dev)
41839 +static int __intentional_overflow(-1) diolan_usb_transfer(struct i2c_diolan_u2c *dev)
41840 {
41841 int ret = 0;
41842 int actual;
41843 diff --git a/drivers/i2c/busses/i2c-nforce2-s4985.c b/drivers/i2c/busses/i2c-nforce2-s4985.c
41844 index b170bdf..3c76427 100644
41845 --- a/drivers/i2c/busses/i2c-nforce2-s4985.c
41846 +++ b/drivers/i2c/busses/i2c-nforce2-s4985.c
41847 @@ -41,7 +41,7 @@
41848 extern struct i2c_adapter *nforce2_smbus;
41849
41850 static struct i2c_adapter *s4985_adapter;
41851 -static struct i2c_algorithm *s4985_algo;
41852 +static i2c_algorithm_no_const *s4985_algo;
41853
41854 /* Wrapper access functions for multiplexed SMBus */
41855 static DEFINE_MUTEX(nforce2_lock);
41856 diff --git a/drivers/i2c/i2c-dev.c b/drivers/i2c/i2c-dev.c
41857 index 80b47e8..1a6040d9 100644
41858 --- a/drivers/i2c/i2c-dev.c
41859 +++ b/drivers/i2c/i2c-dev.c
41860 @@ -277,7 +277,7 @@ static noinline int i2cdev_ioctl_rdrw(struct i2c_client *client,
41861 break;
41862 }
41863
41864 - data_ptrs[i] = (u8 __user *)rdwr_pa[i].buf;
41865 + data_ptrs[i] = (u8 __force_user *)rdwr_pa[i].buf;
41866 rdwr_pa[i].buf = memdup_user(data_ptrs[i], rdwr_pa[i].len);
41867 if (IS_ERR(rdwr_pa[i].buf)) {
41868 res = PTR_ERR(rdwr_pa[i].buf);
41869 diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
41870 index 0b510ba..4fbb5085 100644
41871 --- a/drivers/ide/ide-cd.c
41872 +++ b/drivers/ide/ide-cd.c
41873 @@ -768,7 +768,7 @@ static void cdrom_do_block_pc(ide_drive_t *drive, struct request *rq)
41874 alignment = queue_dma_alignment(q) | q->dma_pad_mask;
41875 if ((unsigned long)buf & alignment
41876 || blk_rq_bytes(rq) & q->dma_pad_mask
41877 - || object_is_on_stack(buf))
41878 + || object_starts_on_stack(buf))
41879 drive->dma = 0;
41880 }
41881 }
41882 diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c
41883 index ede16aec..e423e8a 100644
41884 --- a/drivers/iio/industrialio-core.c
41885 +++ b/drivers/iio/industrialio-core.c
41886 @@ -527,7 +527,7 @@ static ssize_t iio_write_channel_info(struct device *dev,
41887 }
41888
41889 static
41890 -int __iio_device_attr_init(struct device_attribute *dev_attr,
41891 +int __iio_device_attr_init(device_attribute_no_const *dev_attr,
41892 const char *postfix,
41893 struct iio_chan_spec const *chan,
41894 ssize_t (*readfunc)(struct device *dev,
41895 diff --git a/drivers/infiniband/core/cm.c b/drivers/infiniband/core/cm.c
41896 index c323917..6ddea8b 100644
41897 --- a/drivers/infiniband/core/cm.c
41898 +++ b/drivers/infiniband/core/cm.c
41899 @@ -115,7 +115,7 @@ static char const counter_group_names[CM_COUNTER_GROUPS]
41900
41901 struct cm_counter_group {
41902 struct kobject obj;
41903 - atomic_long_t counter[CM_ATTR_COUNT];
41904 + atomic_long_unchecked_t counter[CM_ATTR_COUNT];
41905 };
41906
41907 struct cm_counter_attribute {
41908 @@ -1398,7 +1398,7 @@ static void cm_dup_req_handler(struct cm_work *work,
41909 struct ib_mad_send_buf *msg = NULL;
41910 int ret;
41911
41912 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
41913 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
41914 counter[CM_REQ_COUNTER]);
41915
41916 /* Quick state check to discard duplicate REQs. */
41917 @@ -1785,7 +1785,7 @@ static void cm_dup_rep_handler(struct cm_work *work)
41918 if (!cm_id_priv)
41919 return;
41920
41921 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
41922 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
41923 counter[CM_REP_COUNTER]);
41924 ret = cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg);
41925 if (ret)
41926 @@ -1952,7 +1952,7 @@ static int cm_rtu_handler(struct cm_work *work)
41927 if (cm_id_priv->id.state != IB_CM_REP_SENT &&
41928 cm_id_priv->id.state != IB_CM_MRA_REP_RCVD) {
41929 spin_unlock_irq(&cm_id_priv->lock);
41930 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
41931 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
41932 counter[CM_RTU_COUNTER]);
41933 goto out;
41934 }
41935 @@ -2135,7 +2135,7 @@ static int cm_dreq_handler(struct cm_work *work)
41936 cm_id_priv = cm_acquire_id(dreq_msg->remote_comm_id,
41937 dreq_msg->local_comm_id);
41938 if (!cm_id_priv) {
41939 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
41940 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
41941 counter[CM_DREQ_COUNTER]);
41942 cm_issue_drep(work->port, work->mad_recv_wc);
41943 return -EINVAL;
41944 @@ -2160,7 +2160,7 @@ static int cm_dreq_handler(struct cm_work *work)
41945 case IB_CM_MRA_REP_RCVD:
41946 break;
41947 case IB_CM_TIMEWAIT:
41948 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
41949 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
41950 counter[CM_DREQ_COUNTER]);
41951 if (cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg))
41952 goto unlock;
41953 @@ -2174,7 +2174,7 @@ static int cm_dreq_handler(struct cm_work *work)
41954 cm_free_msg(msg);
41955 goto deref;
41956 case IB_CM_DREQ_RCVD:
41957 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
41958 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
41959 counter[CM_DREQ_COUNTER]);
41960 goto unlock;
41961 default:
41962 @@ -2541,7 +2541,7 @@ static int cm_mra_handler(struct cm_work *work)
41963 ib_modify_mad(cm_id_priv->av.port->mad_agent,
41964 cm_id_priv->msg, timeout)) {
41965 if (cm_id_priv->id.lap_state == IB_CM_MRA_LAP_RCVD)
41966 - atomic_long_inc(&work->port->
41967 + atomic_long_inc_unchecked(&work->port->
41968 counter_group[CM_RECV_DUPLICATES].
41969 counter[CM_MRA_COUNTER]);
41970 goto out;
41971 @@ -2550,7 +2550,7 @@ static int cm_mra_handler(struct cm_work *work)
41972 break;
41973 case IB_CM_MRA_REQ_RCVD:
41974 case IB_CM_MRA_REP_RCVD:
41975 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
41976 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
41977 counter[CM_MRA_COUNTER]);
41978 /* fall through */
41979 default:
41980 @@ -2712,7 +2712,7 @@ static int cm_lap_handler(struct cm_work *work)
41981 case IB_CM_LAP_IDLE:
41982 break;
41983 case IB_CM_MRA_LAP_SENT:
41984 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
41985 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
41986 counter[CM_LAP_COUNTER]);
41987 if (cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg))
41988 goto unlock;
41989 @@ -2728,7 +2728,7 @@ static int cm_lap_handler(struct cm_work *work)
41990 cm_free_msg(msg);
41991 goto deref;
41992 case IB_CM_LAP_RCVD:
41993 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
41994 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
41995 counter[CM_LAP_COUNTER]);
41996 goto unlock;
41997 default:
41998 @@ -3012,7 +3012,7 @@ static int cm_sidr_req_handler(struct cm_work *work)
41999 cur_cm_id_priv = cm_insert_remote_sidr(cm_id_priv);
42000 if (cur_cm_id_priv) {
42001 spin_unlock_irq(&cm.lock);
42002 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
42003 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
42004 counter[CM_SIDR_REQ_COUNTER]);
42005 goto out; /* Duplicate message. */
42006 }
42007 @@ -3224,10 +3224,10 @@ static void cm_send_handler(struct ib_mad_agent *mad_agent,
42008 if (!msg->context[0] && (attr_index != CM_REJ_COUNTER))
42009 msg->retries = 1;
42010
42011 - atomic_long_add(1 + msg->retries,
42012 + atomic_long_add_unchecked(1 + msg->retries,
42013 &port->counter_group[CM_XMIT].counter[attr_index]);
42014 if (msg->retries)
42015 - atomic_long_add(msg->retries,
42016 + atomic_long_add_unchecked(msg->retries,
42017 &port->counter_group[CM_XMIT_RETRIES].
42018 counter[attr_index]);
42019
42020 @@ -3437,7 +3437,7 @@ static void cm_recv_handler(struct ib_mad_agent *mad_agent,
42021 }
42022
42023 attr_id = be16_to_cpu(mad_recv_wc->recv_buf.mad->mad_hdr.attr_id);
42024 - atomic_long_inc(&port->counter_group[CM_RECV].
42025 + atomic_long_inc_unchecked(&port->counter_group[CM_RECV].
42026 counter[attr_id - CM_ATTR_ID_OFFSET]);
42027
42028 work = kmalloc(sizeof *work + sizeof(struct ib_sa_path_rec) * paths,
42029 @@ -3668,7 +3668,7 @@ static ssize_t cm_show_counter(struct kobject *obj, struct attribute *attr,
42030 cm_attr = container_of(attr, struct cm_counter_attribute, attr);
42031
42032 return sprintf(buf, "%ld\n",
42033 - atomic_long_read(&group->counter[cm_attr->index]));
42034 + atomic_long_read_unchecked(&group->counter[cm_attr->index]));
42035 }
42036
42037 static const struct sysfs_ops cm_counter_ops = {
42038 diff --git a/drivers/infiniband/core/fmr_pool.c b/drivers/infiniband/core/fmr_pool.c
42039 index 9f5ad7c..588cd84 100644
42040 --- a/drivers/infiniband/core/fmr_pool.c
42041 +++ b/drivers/infiniband/core/fmr_pool.c
42042 @@ -98,8 +98,8 @@ struct ib_fmr_pool {
42043
42044 struct task_struct *thread;
42045
42046 - atomic_t req_ser;
42047 - atomic_t flush_ser;
42048 + atomic_unchecked_t req_ser;
42049 + atomic_unchecked_t flush_ser;
42050
42051 wait_queue_head_t force_wait;
42052 };
42053 @@ -179,10 +179,10 @@ static int ib_fmr_cleanup_thread(void *pool_ptr)
42054 struct ib_fmr_pool *pool = pool_ptr;
42055
42056 do {
42057 - if (atomic_read(&pool->flush_ser) - atomic_read(&pool->req_ser) < 0) {
42058 + if (atomic_read_unchecked(&pool->flush_ser) - atomic_read_unchecked(&pool->req_ser) < 0) {
42059 ib_fmr_batch_release(pool);
42060
42061 - atomic_inc(&pool->flush_ser);
42062 + atomic_inc_unchecked(&pool->flush_ser);
42063 wake_up_interruptible(&pool->force_wait);
42064
42065 if (pool->flush_function)
42066 @@ -190,7 +190,7 @@ static int ib_fmr_cleanup_thread(void *pool_ptr)
42067 }
42068
42069 set_current_state(TASK_INTERRUPTIBLE);
42070 - if (atomic_read(&pool->flush_ser) - atomic_read(&pool->req_ser) >= 0 &&
42071 + if (atomic_read_unchecked(&pool->flush_ser) - atomic_read_unchecked(&pool->req_ser) >= 0 &&
42072 !kthread_should_stop())
42073 schedule();
42074 __set_current_state(TASK_RUNNING);
42075 @@ -282,8 +282,8 @@ struct ib_fmr_pool *ib_create_fmr_pool(struct ib_pd *pd,
42076 pool->dirty_watermark = params->dirty_watermark;
42077 pool->dirty_len = 0;
42078 spin_lock_init(&pool->pool_lock);
42079 - atomic_set(&pool->req_ser, 0);
42080 - atomic_set(&pool->flush_ser, 0);
42081 + atomic_set_unchecked(&pool->req_ser, 0);
42082 + atomic_set_unchecked(&pool->flush_ser, 0);
42083 init_waitqueue_head(&pool->force_wait);
42084
42085 pool->thread = kthread_run(ib_fmr_cleanup_thread,
42086 @@ -411,11 +411,11 @@ int ib_flush_fmr_pool(struct ib_fmr_pool *pool)
42087 }
42088 spin_unlock_irq(&pool->pool_lock);
42089
42090 - serial = atomic_inc_return(&pool->req_ser);
42091 + serial = atomic_inc_return_unchecked(&pool->req_ser);
42092 wake_up_process(pool->thread);
42093
42094 if (wait_event_interruptible(pool->force_wait,
42095 - atomic_read(&pool->flush_ser) - serial >= 0))
42096 + atomic_read_unchecked(&pool->flush_ser) - serial >= 0))
42097 return -EINTR;
42098
42099 return 0;
42100 @@ -525,7 +525,7 @@ int ib_fmr_pool_unmap(struct ib_pool_fmr *fmr)
42101 } else {
42102 list_add_tail(&fmr->list, &pool->dirty_list);
42103 if (++pool->dirty_len >= pool->dirty_watermark) {
42104 - atomic_inc(&pool->req_ser);
42105 + atomic_inc_unchecked(&pool->req_ser);
42106 wake_up_process(pool->thread);
42107 }
42108 }
42109 diff --git a/drivers/infiniband/hw/cxgb4/mem.c b/drivers/infiniband/hw/cxgb4/mem.c
42110 index ec7a298..8742e59 100644
42111 --- a/drivers/infiniband/hw/cxgb4/mem.c
42112 +++ b/drivers/infiniband/hw/cxgb4/mem.c
42113 @@ -249,7 +249,7 @@ static int write_tpt_entry(struct c4iw_rdev *rdev, u32 reset_tpt_entry,
42114 int err;
42115 struct fw_ri_tpte tpt;
42116 u32 stag_idx;
42117 - static atomic_t key;
42118 + static atomic_unchecked_t key;
42119
42120 if (c4iw_fatal_error(rdev))
42121 return -EIO;
42122 @@ -270,7 +270,7 @@ static int write_tpt_entry(struct c4iw_rdev *rdev, u32 reset_tpt_entry,
42123 if (rdev->stats.stag.cur > rdev->stats.stag.max)
42124 rdev->stats.stag.max = rdev->stats.stag.cur;
42125 mutex_unlock(&rdev->stats.lock);
42126 - *stag = (stag_idx << 8) | (atomic_inc_return(&key) & 0xff);
42127 + *stag = (stag_idx << 8) | (atomic_inc_return_unchecked(&key) & 0xff);
42128 }
42129 PDBG("%s stag_state 0x%0x type 0x%0x pdid 0x%0x, stag_idx 0x%x\n",
42130 __func__, stag_state, type, pdid, stag_idx);
42131 diff --git a/drivers/infiniband/hw/ipath/ipath_rc.c b/drivers/infiniband/hw/ipath/ipath_rc.c
42132 index 79b3dbc..96e5fcc 100644
42133 --- a/drivers/infiniband/hw/ipath/ipath_rc.c
42134 +++ b/drivers/infiniband/hw/ipath/ipath_rc.c
42135 @@ -1868,7 +1868,7 @@ void ipath_rc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
42136 struct ib_atomic_eth *ateth;
42137 struct ipath_ack_entry *e;
42138 u64 vaddr;
42139 - atomic64_t *maddr;
42140 + atomic64_unchecked_t *maddr;
42141 u64 sdata;
42142 u32 rkey;
42143 u8 next;
42144 @@ -1903,11 +1903,11 @@ void ipath_rc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
42145 IB_ACCESS_REMOTE_ATOMIC)))
42146 goto nack_acc_unlck;
42147 /* Perform atomic OP and save result. */
42148 - maddr = (atomic64_t *) qp->r_sge.sge.vaddr;
42149 + maddr = (atomic64_unchecked_t *) qp->r_sge.sge.vaddr;
42150 sdata = be64_to_cpu(ateth->swap_data);
42151 e = &qp->s_ack_queue[qp->r_head_ack_queue];
42152 e->atomic_data = (opcode == OP(FETCH_ADD)) ?
42153 - (u64) atomic64_add_return(sdata, maddr) - sdata :
42154 + (u64) atomic64_add_return_unchecked(sdata, maddr) - sdata :
42155 (u64) cmpxchg((u64 *) qp->r_sge.sge.vaddr,
42156 be64_to_cpu(ateth->compare_data),
42157 sdata);
42158 diff --git a/drivers/infiniband/hw/ipath/ipath_ruc.c b/drivers/infiniband/hw/ipath/ipath_ruc.c
42159 index 1f95bba..9530f87 100644
42160 --- a/drivers/infiniband/hw/ipath/ipath_ruc.c
42161 +++ b/drivers/infiniband/hw/ipath/ipath_ruc.c
42162 @@ -266,7 +266,7 @@ static void ipath_ruc_loopback(struct ipath_qp *sqp)
42163 unsigned long flags;
42164 struct ib_wc wc;
42165 u64 sdata;
42166 - atomic64_t *maddr;
42167 + atomic64_unchecked_t *maddr;
42168 enum ib_wc_status send_status;
42169
42170 /*
42171 @@ -382,11 +382,11 @@ again:
42172 IB_ACCESS_REMOTE_ATOMIC)))
42173 goto acc_err;
42174 /* Perform atomic OP and save result. */
42175 - maddr = (atomic64_t *) qp->r_sge.sge.vaddr;
42176 + maddr = (atomic64_unchecked_t *) qp->r_sge.sge.vaddr;
42177 sdata = wqe->wr.wr.atomic.compare_add;
42178 *(u64 *) sqp->s_sge.sge.vaddr =
42179 (wqe->wr.opcode == IB_WR_ATOMIC_FETCH_AND_ADD) ?
42180 - (u64) atomic64_add_return(sdata, maddr) - sdata :
42181 + (u64) atomic64_add_return_unchecked(sdata, maddr) - sdata :
42182 (u64) cmpxchg((u64 *) qp->r_sge.sge.vaddr,
42183 sdata, wqe->wr.wr.atomic.swap);
42184 goto send_comp;
42185 diff --git a/drivers/infiniband/hw/mlx4/mad.c b/drivers/infiniband/hw/mlx4/mad.c
42186 index fd36ec6..a6a082f 100644
42187 --- a/drivers/infiniband/hw/mlx4/mad.c
42188 +++ b/drivers/infiniband/hw/mlx4/mad.c
42189 @@ -98,7 +98,7 @@ __be64 mlx4_ib_gen_node_guid(void)
42190
42191 __be64 mlx4_ib_get_new_demux_tid(struct mlx4_ib_demux_ctx *ctx)
42192 {
42193 - return cpu_to_be64(atomic_inc_return(&ctx->tid)) |
42194 + return cpu_to_be64(atomic_inc_return_unchecked(&ctx->tid)) |
42195 cpu_to_be64(0xff00000000000000LL);
42196 }
42197
42198 diff --git a/drivers/infiniband/hw/mlx4/mcg.c b/drivers/infiniband/hw/mlx4/mcg.c
42199 index ed327e6..ca1739e0 100644
42200 --- a/drivers/infiniband/hw/mlx4/mcg.c
42201 +++ b/drivers/infiniband/hw/mlx4/mcg.c
42202 @@ -1041,7 +1041,7 @@ int mlx4_ib_mcg_port_init(struct mlx4_ib_demux_ctx *ctx)
42203 {
42204 char name[20];
42205
42206 - atomic_set(&ctx->tid, 0);
42207 + atomic_set_unchecked(&ctx->tid, 0);
42208 sprintf(name, "mlx4_ib_mcg%d", ctx->port);
42209 ctx->mcg_wq = create_singlethread_workqueue(name);
42210 if (!ctx->mcg_wq)
42211 diff --git a/drivers/infiniband/hw/mlx4/mlx4_ib.h b/drivers/infiniband/hw/mlx4/mlx4_ib.h
42212 index 66b0b7d..f14836a 100644
42213 --- a/drivers/infiniband/hw/mlx4/mlx4_ib.h
42214 +++ b/drivers/infiniband/hw/mlx4/mlx4_ib.h
42215 @@ -425,7 +425,7 @@ struct mlx4_ib_demux_ctx {
42216 struct list_head mcg_mgid0_list;
42217 struct workqueue_struct *mcg_wq;
42218 struct mlx4_ib_demux_pv_ctx **tun;
42219 - atomic_t tid;
42220 + atomic_unchecked_t tid;
42221 int flushing; /* flushing the work queue */
42222 };
42223
42224 diff --git a/drivers/infiniband/hw/mthca/mthca_cmd.c b/drivers/infiniband/hw/mthca/mthca_cmd.c
42225 index 9d3e5c1..6f166df 100644
42226 --- a/drivers/infiniband/hw/mthca/mthca_cmd.c
42227 +++ b/drivers/infiniband/hw/mthca/mthca_cmd.c
42228 @@ -772,7 +772,7 @@ static void mthca_setup_cmd_doorbells(struct mthca_dev *dev, u64 base)
42229 mthca_dbg(dev, "Mapped doorbell page for posting FW commands\n");
42230 }
42231
42232 -int mthca_QUERY_FW(struct mthca_dev *dev)
42233 +int __intentional_overflow(-1) mthca_QUERY_FW(struct mthca_dev *dev)
42234 {
42235 struct mthca_mailbox *mailbox;
42236 u32 *outbox;
42237 @@ -1612,7 +1612,7 @@ int mthca_HW2SW_MPT(struct mthca_dev *dev, struct mthca_mailbox *mailbox,
42238 CMD_TIME_CLASS_B);
42239 }
42240
42241 -int mthca_WRITE_MTT(struct mthca_dev *dev, struct mthca_mailbox *mailbox,
42242 +int __intentional_overflow(-1) mthca_WRITE_MTT(struct mthca_dev *dev, struct mthca_mailbox *mailbox,
42243 int num_mtt)
42244 {
42245 return mthca_cmd(dev, mailbox->dma, num_mtt, 0, CMD_WRITE_MTT,
42246 @@ -1634,7 +1634,7 @@ int mthca_MAP_EQ(struct mthca_dev *dev, u64 event_mask, int unmap,
42247 0, CMD_MAP_EQ, CMD_TIME_CLASS_B);
42248 }
42249
42250 -int mthca_SW2HW_EQ(struct mthca_dev *dev, struct mthca_mailbox *mailbox,
42251 +int __intentional_overflow(-1) mthca_SW2HW_EQ(struct mthca_dev *dev, struct mthca_mailbox *mailbox,
42252 int eq_num)
42253 {
42254 return mthca_cmd(dev, mailbox->dma, eq_num, 0, CMD_SW2HW_EQ,
42255 @@ -1857,7 +1857,7 @@ int mthca_CONF_SPECIAL_QP(struct mthca_dev *dev, int type, u32 qpn)
42256 CMD_TIME_CLASS_B);
42257 }
42258
42259 -int mthca_MAD_IFC(struct mthca_dev *dev, int ignore_mkey, int ignore_bkey,
42260 +int __intentional_overflow(-1) mthca_MAD_IFC(struct mthca_dev *dev, int ignore_mkey, int ignore_bkey,
42261 int port, struct ib_wc *in_wc, struct ib_grh *in_grh,
42262 void *in_mad, void *response_mad)
42263 {
42264 diff --git a/drivers/infiniband/hw/mthca/mthca_main.c b/drivers/infiniband/hw/mthca/mthca_main.c
42265 index ded76c1..0cf0a08 100644
42266 --- a/drivers/infiniband/hw/mthca/mthca_main.c
42267 +++ b/drivers/infiniband/hw/mthca/mthca_main.c
42268 @@ -692,7 +692,7 @@ err_close:
42269 return err;
42270 }
42271
42272 -static int mthca_setup_hca(struct mthca_dev *dev)
42273 +static int __intentional_overflow(-1) mthca_setup_hca(struct mthca_dev *dev)
42274 {
42275 int err;
42276
42277 diff --git a/drivers/infiniband/hw/mthca/mthca_mr.c b/drivers/infiniband/hw/mthca/mthca_mr.c
42278 index ed9a989..6aa5dc2 100644
42279 --- a/drivers/infiniband/hw/mthca/mthca_mr.c
42280 +++ b/drivers/infiniband/hw/mthca/mthca_mr.c
42281 @@ -81,7 +81,7 @@ struct mthca_mpt_entry {
42282 * through the bitmaps)
42283 */
42284
42285 -static u32 mthca_buddy_alloc(struct mthca_buddy *buddy, int order)
42286 +static u32 __intentional_overflow(-1) mthca_buddy_alloc(struct mthca_buddy *buddy, int order)
42287 {
42288 int o;
42289 int m;
42290 @@ -426,7 +426,7 @@ static inline u32 adjust_key(struct mthca_dev *dev, u32 key)
42291 return key;
42292 }
42293
42294 -int mthca_mr_alloc(struct mthca_dev *dev, u32 pd, int buffer_size_shift,
42295 +int __intentional_overflow(-1) mthca_mr_alloc(struct mthca_dev *dev, u32 pd, int buffer_size_shift,
42296 u64 iova, u64 total_size, u32 access, struct mthca_mr *mr)
42297 {
42298 struct mthca_mailbox *mailbox;
42299 @@ -516,7 +516,7 @@ int mthca_mr_alloc_notrans(struct mthca_dev *dev, u32 pd,
42300 return mthca_mr_alloc(dev, pd, 12, 0, ~0ULL, access, mr);
42301 }
42302
42303 -int mthca_mr_alloc_phys(struct mthca_dev *dev, u32 pd,
42304 +int __intentional_overflow(-1) mthca_mr_alloc_phys(struct mthca_dev *dev, u32 pd,
42305 u64 *buffer_list, int buffer_size_shift,
42306 int list_len, u64 iova, u64 total_size,
42307 u32 access, struct mthca_mr *mr)
42308 diff --git a/drivers/infiniband/hw/mthca/mthca_provider.c b/drivers/infiniband/hw/mthca/mthca_provider.c
42309 index 415f8e1..e34214e 100644
42310 --- a/drivers/infiniband/hw/mthca/mthca_provider.c
42311 +++ b/drivers/infiniband/hw/mthca/mthca_provider.c
42312 @@ -764,7 +764,7 @@ unlock:
42313 return 0;
42314 }
42315
42316 -static int mthca_resize_cq(struct ib_cq *ibcq, int entries, struct ib_udata *udata)
42317 +static int __intentional_overflow(-1) mthca_resize_cq(struct ib_cq *ibcq, int entries, struct ib_udata *udata)
42318 {
42319 struct mthca_dev *dev = to_mdev(ibcq->device);
42320 struct mthca_cq *cq = to_mcq(ibcq);
42321 diff --git a/drivers/infiniband/hw/nes/nes.c b/drivers/infiniband/hw/nes/nes.c
42322 index 353c7b0..c6ce921 100644
42323 --- a/drivers/infiniband/hw/nes/nes.c
42324 +++ b/drivers/infiniband/hw/nes/nes.c
42325 @@ -98,7 +98,7 @@ MODULE_PARM_DESC(limit_maxrdreqsz, "Limit max read request size to 256 Bytes");
42326 LIST_HEAD(nes_adapter_list);
42327 static LIST_HEAD(nes_dev_list);
42328
42329 -atomic_t qps_destroyed;
42330 +atomic_unchecked_t qps_destroyed;
42331
42332 static unsigned int ee_flsh_adapter;
42333 static unsigned int sysfs_nonidx_addr;
42334 @@ -269,7 +269,7 @@ static void nes_cqp_rem_ref_callback(struct nes_device *nesdev, struct nes_cqp_r
42335 struct nes_qp *nesqp = cqp_request->cqp_callback_pointer;
42336 struct nes_adapter *nesadapter = nesdev->nesadapter;
42337
42338 - atomic_inc(&qps_destroyed);
42339 + atomic_inc_unchecked(&qps_destroyed);
42340
42341 /* Free the control structures */
42342
42343 diff --git a/drivers/infiniband/hw/nes/nes.h b/drivers/infiniband/hw/nes/nes.h
42344 index 33cc589..3bd6538 100644
42345 --- a/drivers/infiniband/hw/nes/nes.h
42346 +++ b/drivers/infiniband/hw/nes/nes.h
42347 @@ -177,17 +177,17 @@ extern unsigned int nes_debug_level;
42348 extern unsigned int wqm_quanta;
42349 extern struct list_head nes_adapter_list;
42350
42351 -extern atomic_t cm_connects;
42352 -extern atomic_t cm_accepts;
42353 -extern atomic_t cm_disconnects;
42354 -extern atomic_t cm_closes;
42355 -extern atomic_t cm_connecteds;
42356 -extern atomic_t cm_connect_reqs;
42357 -extern atomic_t cm_rejects;
42358 -extern atomic_t mod_qp_timouts;
42359 -extern atomic_t qps_created;
42360 -extern atomic_t qps_destroyed;
42361 -extern atomic_t sw_qps_destroyed;
42362 +extern atomic_unchecked_t cm_connects;
42363 +extern atomic_unchecked_t cm_accepts;
42364 +extern atomic_unchecked_t cm_disconnects;
42365 +extern atomic_unchecked_t cm_closes;
42366 +extern atomic_unchecked_t cm_connecteds;
42367 +extern atomic_unchecked_t cm_connect_reqs;
42368 +extern atomic_unchecked_t cm_rejects;
42369 +extern atomic_unchecked_t mod_qp_timouts;
42370 +extern atomic_unchecked_t qps_created;
42371 +extern atomic_unchecked_t qps_destroyed;
42372 +extern atomic_unchecked_t sw_qps_destroyed;
42373 extern u32 mh_detected;
42374 extern u32 mh_pauses_sent;
42375 extern u32 cm_packets_sent;
42376 @@ -196,16 +196,16 @@ extern u32 cm_packets_created;
42377 extern u32 cm_packets_received;
42378 extern u32 cm_packets_dropped;
42379 extern u32 cm_packets_retrans;
42380 -extern atomic_t cm_listens_created;
42381 -extern atomic_t cm_listens_destroyed;
42382 +extern atomic_unchecked_t cm_listens_created;
42383 +extern atomic_unchecked_t cm_listens_destroyed;
42384 extern u32 cm_backlog_drops;
42385 -extern atomic_t cm_loopbacks;
42386 -extern atomic_t cm_nodes_created;
42387 -extern atomic_t cm_nodes_destroyed;
42388 -extern atomic_t cm_accel_dropped_pkts;
42389 -extern atomic_t cm_resets_recvd;
42390 -extern atomic_t pau_qps_created;
42391 -extern atomic_t pau_qps_destroyed;
42392 +extern atomic_unchecked_t cm_loopbacks;
42393 +extern atomic_unchecked_t cm_nodes_created;
42394 +extern atomic_unchecked_t cm_nodes_destroyed;
42395 +extern atomic_unchecked_t cm_accel_dropped_pkts;
42396 +extern atomic_unchecked_t cm_resets_recvd;
42397 +extern atomic_unchecked_t pau_qps_created;
42398 +extern atomic_unchecked_t pau_qps_destroyed;
42399
42400 extern u32 int_mod_timer_init;
42401 extern u32 int_mod_cq_depth_256;
42402 diff --git a/drivers/infiniband/hw/nes/nes_cm.c b/drivers/infiniband/hw/nes/nes_cm.c
42403 index dfa9df4..6bf7221 100644
42404 --- a/drivers/infiniband/hw/nes/nes_cm.c
42405 +++ b/drivers/infiniband/hw/nes/nes_cm.c
42406 @@ -68,14 +68,14 @@ u32 cm_packets_dropped;
42407 u32 cm_packets_retrans;
42408 u32 cm_packets_created;
42409 u32 cm_packets_received;
42410 -atomic_t cm_listens_created;
42411 -atomic_t cm_listens_destroyed;
42412 +atomic_unchecked_t cm_listens_created;
42413 +atomic_unchecked_t cm_listens_destroyed;
42414 u32 cm_backlog_drops;
42415 -atomic_t cm_loopbacks;
42416 -atomic_t cm_nodes_created;
42417 -atomic_t cm_nodes_destroyed;
42418 -atomic_t cm_accel_dropped_pkts;
42419 -atomic_t cm_resets_recvd;
42420 +atomic_unchecked_t cm_loopbacks;
42421 +atomic_unchecked_t cm_nodes_created;
42422 +atomic_unchecked_t cm_nodes_destroyed;
42423 +atomic_unchecked_t cm_accel_dropped_pkts;
42424 +atomic_unchecked_t cm_resets_recvd;
42425
42426 static inline int mini_cm_accelerated(struct nes_cm_core *, struct nes_cm_node *);
42427 static struct nes_cm_listener *mini_cm_listen(struct nes_cm_core *, struct nes_vnic *, struct nes_cm_info *);
42428 @@ -134,28 +134,28 @@ static void record_ird_ord(struct nes_cm_node *, u16, u16);
42429 /* instance of function pointers for client API */
42430 /* set address of this instance to cm_core->cm_ops at cm_core alloc */
42431 static struct nes_cm_ops nes_cm_api = {
42432 - mini_cm_accelerated,
42433 - mini_cm_listen,
42434 - mini_cm_del_listen,
42435 - mini_cm_connect,
42436 - mini_cm_close,
42437 - mini_cm_accept,
42438 - mini_cm_reject,
42439 - mini_cm_recv_pkt,
42440 - mini_cm_dealloc_core,
42441 - mini_cm_get,
42442 - mini_cm_set
42443 + .accelerated = mini_cm_accelerated,
42444 + .listen = mini_cm_listen,
42445 + .stop_listener = mini_cm_del_listen,
42446 + .connect = mini_cm_connect,
42447 + .close = mini_cm_close,
42448 + .accept = mini_cm_accept,
42449 + .reject = mini_cm_reject,
42450 + .recv_pkt = mini_cm_recv_pkt,
42451 + .destroy_cm_core = mini_cm_dealloc_core,
42452 + .get = mini_cm_get,
42453 + .set = mini_cm_set
42454 };
42455
42456 static struct nes_cm_core *g_cm_core;
42457
42458 -atomic_t cm_connects;
42459 -atomic_t cm_accepts;
42460 -atomic_t cm_disconnects;
42461 -atomic_t cm_closes;
42462 -atomic_t cm_connecteds;
42463 -atomic_t cm_connect_reqs;
42464 -atomic_t cm_rejects;
42465 +atomic_unchecked_t cm_connects;
42466 +atomic_unchecked_t cm_accepts;
42467 +atomic_unchecked_t cm_disconnects;
42468 +atomic_unchecked_t cm_closes;
42469 +atomic_unchecked_t cm_connecteds;
42470 +atomic_unchecked_t cm_connect_reqs;
42471 +atomic_unchecked_t cm_rejects;
42472
42473 int nes_add_ref_cm_node(struct nes_cm_node *cm_node)
42474 {
42475 @@ -1319,7 +1319,7 @@ static int mini_cm_dec_refcnt_listen(struct nes_cm_core *cm_core,
42476 kfree(listener);
42477 listener = NULL;
42478 ret = 0;
42479 - atomic_inc(&cm_listens_destroyed);
42480 + atomic_inc_unchecked(&cm_listens_destroyed);
42481 } else {
42482 spin_unlock_irqrestore(&cm_core->listen_list_lock, flags);
42483 }
42484 @@ -1513,7 +1513,7 @@ static struct nes_cm_node *make_cm_node(struct nes_cm_core *cm_core,
42485 cm_node->rem_mac);
42486
42487 add_hte_node(cm_core, cm_node);
42488 - atomic_inc(&cm_nodes_created);
42489 + atomic_inc_unchecked(&cm_nodes_created);
42490
42491 return cm_node;
42492 }
42493 @@ -1571,7 +1571,7 @@ static int rem_ref_cm_node(struct nes_cm_core *cm_core,
42494 }
42495
42496 atomic_dec(&cm_core->node_cnt);
42497 - atomic_inc(&cm_nodes_destroyed);
42498 + atomic_inc_unchecked(&cm_nodes_destroyed);
42499 nesqp = cm_node->nesqp;
42500 if (nesqp) {
42501 nesqp->cm_node = NULL;
42502 @@ -1635,7 +1635,7 @@ static int process_options(struct nes_cm_node *cm_node, u8 *optionsloc,
42503
42504 static void drop_packet(struct sk_buff *skb)
42505 {
42506 - atomic_inc(&cm_accel_dropped_pkts);
42507 + atomic_inc_unchecked(&cm_accel_dropped_pkts);
42508 dev_kfree_skb_any(skb);
42509 }
42510
42511 @@ -1698,7 +1698,7 @@ static void handle_rst_pkt(struct nes_cm_node *cm_node, struct sk_buff *skb,
42512 {
42513
42514 int reset = 0; /* whether to send reset in case of err.. */
42515 - atomic_inc(&cm_resets_recvd);
42516 + atomic_inc_unchecked(&cm_resets_recvd);
42517 nes_debug(NES_DBG_CM, "Received Reset, cm_node = %p, state = %u."
42518 " refcnt=%d\n", cm_node, cm_node->state,
42519 atomic_read(&cm_node->ref_count));
42520 @@ -2339,7 +2339,7 @@ static struct nes_cm_node *mini_cm_connect(struct nes_cm_core *cm_core,
42521 rem_ref_cm_node(cm_node->cm_core, cm_node);
42522 return NULL;
42523 }
42524 - atomic_inc(&cm_loopbacks);
42525 + atomic_inc_unchecked(&cm_loopbacks);
42526 loopbackremotenode->loopbackpartner = cm_node;
42527 loopbackremotenode->tcp_cntxt.rcv_wscale =
42528 NES_CM_DEFAULT_RCV_WND_SCALE;
42529 @@ -2614,7 +2614,7 @@ static int mini_cm_recv_pkt(struct nes_cm_core *cm_core,
42530 nes_queue_mgt_skbs(skb, nesvnic, cm_node->nesqp);
42531 else {
42532 rem_ref_cm_node(cm_core, cm_node);
42533 - atomic_inc(&cm_accel_dropped_pkts);
42534 + atomic_inc_unchecked(&cm_accel_dropped_pkts);
42535 dev_kfree_skb_any(skb);
42536 }
42537 break;
42538 @@ -2922,7 +2922,7 @@ static int nes_cm_disconn_true(struct nes_qp *nesqp)
42539
42540 if ((cm_id) && (cm_id->event_handler)) {
42541 if (issue_disconn) {
42542 - atomic_inc(&cm_disconnects);
42543 + atomic_inc_unchecked(&cm_disconnects);
42544 cm_event.event = IW_CM_EVENT_DISCONNECT;
42545 cm_event.status = disconn_status;
42546 cm_event.local_addr = cm_id->local_addr;
42547 @@ -2944,7 +2944,7 @@ static int nes_cm_disconn_true(struct nes_qp *nesqp)
42548 }
42549
42550 if (issue_close) {
42551 - atomic_inc(&cm_closes);
42552 + atomic_inc_unchecked(&cm_closes);
42553 nes_disconnect(nesqp, 1);
42554
42555 cm_id->provider_data = nesqp;
42556 @@ -3082,7 +3082,7 @@ int nes_accept(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
42557
42558 nes_debug(NES_DBG_CM, "QP%u, cm_node=%p, jiffies = %lu listener = %p\n",
42559 nesqp->hwqp.qp_id, cm_node, jiffies, cm_node->listener);
42560 - atomic_inc(&cm_accepts);
42561 + atomic_inc_unchecked(&cm_accepts);
42562
42563 nes_debug(NES_DBG_CM, "netdev refcnt = %u.\n",
42564 netdev_refcnt_read(nesvnic->netdev));
42565 @@ -3278,7 +3278,7 @@ int nes_reject(struct iw_cm_id *cm_id, const void *pdata, u8 pdata_len)
42566 struct nes_cm_core *cm_core;
42567 u8 *start_buff;
42568
42569 - atomic_inc(&cm_rejects);
42570 + atomic_inc_unchecked(&cm_rejects);
42571 cm_node = (struct nes_cm_node *)cm_id->provider_data;
42572 loopback = cm_node->loopbackpartner;
42573 cm_core = cm_node->cm_core;
42574 @@ -3340,7 +3340,7 @@ int nes_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
42575 ntohs(raddr->sin_port), ntohl(laddr->sin_addr.s_addr),
42576 ntohs(laddr->sin_port));
42577
42578 - atomic_inc(&cm_connects);
42579 + atomic_inc_unchecked(&cm_connects);
42580 nesqp->active_conn = 1;
42581
42582 /* cache the cm_id in the qp */
42583 @@ -3451,7 +3451,7 @@ int nes_create_listen(struct iw_cm_id *cm_id, int backlog)
42584 g_cm_core->api->stop_listener(g_cm_core, (void *)cm_node);
42585 return err;
42586 }
42587 - atomic_inc(&cm_listens_created);
42588 + atomic_inc_unchecked(&cm_listens_created);
42589 }
42590
42591 cm_id->add_ref(cm_id);
42592 @@ -3558,7 +3558,7 @@ static void cm_event_connected(struct nes_cm_event *event)
42593
42594 if (nesqp->destroyed)
42595 return;
42596 - atomic_inc(&cm_connecteds);
42597 + atomic_inc_unchecked(&cm_connecteds);
42598 nes_debug(NES_DBG_CM, "QP%u attempting to connect to 0x%08X:0x%04X on"
42599 " local port 0x%04X. jiffies = %lu.\n",
42600 nesqp->hwqp.qp_id, ntohl(raddr->sin_addr.s_addr),
42601 @@ -3741,7 +3741,7 @@ static void cm_event_reset(struct nes_cm_event *event)
42602
42603 cm_id->add_ref(cm_id);
42604 ret = cm_id->event_handler(cm_id, &cm_event);
42605 - atomic_inc(&cm_closes);
42606 + atomic_inc_unchecked(&cm_closes);
42607 cm_event.event = IW_CM_EVENT_CLOSE;
42608 cm_event.status = 0;
42609 cm_event.provider_data = cm_id->provider_data;
42610 @@ -3781,7 +3781,7 @@ static void cm_event_mpa_req(struct nes_cm_event *event)
42611 return;
42612 cm_id = cm_node->cm_id;
42613
42614 - atomic_inc(&cm_connect_reqs);
42615 + atomic_inc_unchecked(&cm_connect_reqs);
42616 nes_debug(NES_DBG_CM, "cm_node = %p - cm_id = %p, jiffies = %lu\n",
42617 cm_node, cm_id, jiffies);
42618
42619 @@ -3830,7 +3830,7 @@ static void cm_event_mpa_reject(struct nes_cm_event *event)
42620 return;
42621 cm_id = cm_node->cm_id;
42622
42623 - atomic_inc(&cm_connect_reqs);
42624 + atomic_inc_unchecked(&cm_connect_reqs);
42625 nes_debug(NES_DBG_CM, "cm_node = %p - cm_id = %p, jiffies = %lu\n",
42626 cm_node, cm_id, jiffies);
42627
42628 diff --git a/drivers/infiniband/hw/nes/nes_mgt.c b/drivers/infiniband/hw/nes/nes_mgt.c
42629 index 4166452..fc952c3 100644
42630 --- a/drivers/infiniband/hw/nes/nes_mgt.c
42631 +++ b/drivers/infiniband/hw/nes/nes_mgt.c
42632 @@ -40,8 +40,8 @@
42633 #include "nes.h"
42634 #include "nes_mgt.h"
42635
42636 -atomic_t pau_qps_created;
42637 -atomic_t pau_qps_destroyed;
42638 +atomic_unchecked_t pau_qps_created;
42639 +atomic_unchecked_t pau_qps_destroyed;
42640
42641 static void nes_replenish_mgt_rq(struct nes_vnic_mgt *mgtvnic)
42642 {
42643 @@ -621,7 +621,7 @@ void nes_destroy_pau_qp(struct nes_device *nesdev, struct nes_qp *nesqp)
42644 {
42645 struct sk_buff *skb;
42646 unsigned long flags;
42647 - atomic_inc(&pau_qps_destroyed);
42648 + atomic_inc_unchecked(&pau_qps_destroyed);
42649
42650 /* Free packets that have not yet been forwarded */
42651 /* Lock is acquired by skb_dequeue when removing the skb */
42652 @@ -810,7 +810,7 @@ static void nes_mgt_ce_handler(struct nes_device *nesdev, struct nes_hw_nic_cq *
42653 cq->cq_vbase[head].cqe_words[NES_NIC_CQE_HASH_RCVNXT]);
42654 skb_queue_head_init(&nesqp->pau_list);
42655 spin_lock_init(&nesqp->pau_lock);
42656 - atomic_inc(&pau_qps_created);
42657 + atomic_inc_unchecked(&pau_qps_created);
42658 nes_change_quad_hash(nesdev, mgtvnic->nesvnic, nesqp);
42659 }
42660
42661 diff --git a/drivers/infiniband/hw/nes/nes_nic.c b/drivers/infiniband/hw/nes/nes_nic.c
42662 index 49eb511..a774366 100644
42663 --- a/drivers/infiniband/hw/nes/nes_nic.c
42664 +++ b/drivers/infiniband/hw/nes/nes_nic.c
42665 @@ -1273,39 +1273,39 @@ static void nes_netdev_get_ethtool_stats(struct net_device *netdev,
42666 target_stat_values[++index] = mh_detected;
42667 target_stat_values[++index] = mh_pauses_sent;
42668 target_stat_values[++index] = nesvnic->endnode_ipv4_tcp_retransmits;
42669 - target_stat_values[++index] = atomic_read(&cm_connects);
42670 - target_stat_values[++index] = atomic_read(&cm_accepts);
42671 - target_stat_values[++index] = atomic_read(&cm_disconnects);
42672 - target_stat_values[++index] = atomic_read(&cm_connecteds);
42673 - target_stat_values[++index] = atomic_read(&cm_connect_reqs);
42674 - target_stat_values[++index] = atomic_read(&cm_rejects);
42675 - target_stat_values[++index] = atomic_read(&mod_qp_timouts);
42676 - target_stat_values[++index] = atomic_read(&qps_created);
42677 - target_stat_values[++index] = atomic_read(&sw_qps_destroyed);
42678 - target_stat_values[++index] = atomic_read(&qps_destroyed);
42679 - target_stat_values[++index] = atomic_read(&cm_closes);
42680 + target_stat_values[++index] = atomic_read_unchecked(&cm_connects);
42681 + target_stat_values[++index] = atomic_read_unchecked(&cm_accepts);
42682 + target_stat_values[++index] = atomic_read_unchecked(&cm_disconnects);
42683 + target_stat_values[++index] = atomic_read_unchecked(&cm_connecteds);
42684 + target_stat_values[++index] = atomic_read_unchecked(&cm_connect_reqs);
42685 + target_stat_values[++index] = atomic_read_unchecked(&cm_rejects);
42686 + target_stat_values[++index] = atomic_read_unchecked(&mod_qp_timouts);
42687 + target_stat_values[++index] = atomic_read_unchecked(&qps_created);
42688 + target_stat_values[++index] = atomic_read_unchecked(&sw_qps_destroyed);
42689 + target_stat_values[++index] = atomic_read_unchecked(&qps_destroyed);
42690 + target_stat_values[++index] = atomic_read_unchecked(&cm_closes);
42691 target_stat_values[++index] = cm_packets_sent;
42692 target_stat_values[++index] = cm_packets_bounced;
42693 target_stat_values[++index] = cm_packets_created;
42694 target_stat_values[++index] = cm_packets_received;
42695 target_stat_values[++index] = cm_packets_dropped;
42696 target_stat_values[++index] = cm_packets_retrans;
42697 - target_stat_values[++index] = atomic_read(&cm_listens_created);
42698 - target_stat_values[++index] = atomic_read(&cm_listens_destroyed);
42699 + target_stat_values[++index] = atomic_read_unchecked(&cm_listens_created);
42700 + target_stat_values[++index] = atomic_read_unchecked(&cm_listens_destroyed);
42701 target_stat_values[++index] = cm_backlog_drops;
42702 - target_stat_values[++index] = atomic_read(&cm_loopbacks);
42703 - target_stat_values[++index] = atomic_read(&cm_nodes_created);
42704 - target_stat_values[++index] = atomic_read(&cm_nodes_destroyed);
42705 - target_stat_values[++index] = atomic_read(&cm_accel_dropped_pkts);
42706 - target_stat_values[++index] = atomic_read(&cm_resets_recvd);
42707 + target_stat_values[++index] = atomic_read_unchecked(&cm_loopbacks);
42708 + target_stat_values[++index] = atomic_read_unchecked(&cm_nodes_created);
42709 + target_stat_values[++index] = atomic_read_unchecked(&cm_nodes_destroyed);
42710 + target_stat_values[++index] = atomic_read_unchecked(&cm_accel_dropped_pkts);
42711 + target_stat_values[++index] = atomic_read_unchecked(&cm_resets_recvd);
42712 target_stat_values[++index] = nesadapter->free_4kpbl;
42713 target_stat_values[++index] = nesadapter->free_256pbl;
42714 target_stat_values[++index] = int_mod_timer_init;
42715 target_stat_values[++index] = nesvnic->lro_mgr.stats.aggregated;
42716 target_stat_values[++index] = nesvnic->lro_mgr.stats.flushed;
42717 target_stat_values[++index] = nesvnic->lro_mgr.stats.no_desc;
42718 - target_stat_values[++index] = atomic_read(&pau_qps_created);
42719 - target_stat_values[++index] = atomic_read(&pau_qps_destroyed);
42720 + target_stat_values[++index] = atomic_read_unchecked(&pau_qps_created);
42721 + target_stat_values[++index] = atomic_read_unchecked(&pau_qps_destroyed);
42722 }
42723
42724 /**
42725 diff --git a/drivers/infiniband/hw/nes/nes_verbs.c b/drivers/infiniband/hw/nes/nes_verbs.c
42726 index 218dd35..97ce31d 100644
42727 --- a/drivers/infiniband/hw/nes/nes_verbs.c
42728 +++ b/drivers/infiniband/hw/nes/nes_verbs.c
42729 @@ -46,9 +46,9 @@
42730
42731 #include <rdma/ib_umem.h>
42732
42733 -atomic_t mod_qp_timouts;
42734 -atomic_t qps_created;
42735 -atomic_t sw_qps_destroyed;
42736 +atomic_unchecked_t mod_qp_timouts;
42737 +atomic_unchecked_t qps_created;
42738 +atomic_unchecked_t sw_qps_destroyed;
42739
42740 static void nes_unregister_ofa_device(struct nes_ib_device *nesibdev);
42741
42742 @@ -1134,7 +1134,7 @@ static struct ib_qp *nes_create_qp(struct ib_pd *ibpd,
42743 if (init_attr->create_flags)
42744 return ERR_PTR(-EINVAL);
42745
42746 - atomic_inc(&qps_created);
42747 + atomic_inc_unchecked(&qps_created);
42748 switch (init_attr->qp_type) {
42749 case IB_QPT_RC:
42750 if (nes_drv_opt & NES_DRV_OPT_NO_INLINE_DATA) {
42751 @@ -1468,7 +1468,7 @@ static int nes_destroy_qp(struct ib_qp *ibqp)
42752 struct iw_cm_event cm_event;
42753 int ret = 0;
42754
42755 - atomic_inc(&sw_qps_destroyed);
42756 + atomic_inc_unchecked(&sw_qps_destroyed);
42757 nesqp->destroyed = 1;
42758
42759 /* Blow away the connection if it exists. */
42760 diff --git a/drivers/infiniband/hw/qib/qib.h b/drivers/infiniband/hw/qib/qib.h
42761 index c00ae09..04e91be 100644
42762 --- a/drivers/infiniband/hw/qib/qib.h
42763 +++ b/drivers/infiniband/hw/qib/qib.h
42764 @@ -52,6 +52,7 @@
42765 #include <linux/kref.h>
42766 #include <linux/sched.h>
42767 #include <linux/kthread.h>
42768 +#include <linux/slab.h>
42769
42770 #include "qib_common.h"
42771 #include "qib_verbs.h"
42772 diff --git a/drivers/input/gameport/gameport.c b/drivers/input/gameport/gameport.c
42773 index 24c41ba..102d71f 100644
42774 --- a/drivers/input/gameport/gameport.c
42775 +++ b/drivers/input/gameport/gameport.c
42776 @@ -490,14 +490,14 @@ EXPORT_SYMBOL(gameport_set_phys);
42777 */
42778 static void gameport_init_port(struct gameport *gameport)
42779 {
42780 - static atomic_t gameport_no = ATOMIC_INIT(0);
42781 + static atomic_unchecked_t gameport_no = ATOMIC_INIT(0);
42782
42783 __module_get(THIS_MODULE);
42784
42785 mutex_init(&gameport->drv_mutex);
42786 device_initialize(&gameport->dev);
42787 dev_set_name(&gameport->dev, "gameport%lu",
42788 - (unsigned long)atomic_inc_return(&gameport_no) - 1);
42789 + (unsigned long)atomic_inc_return_unchecked(&gameport_no) - 1);
42790 gameport->dev.bus = &gameport_bus;
42791 gameport->dev.release = gameport_release_port;
42792 if (gameport->parent)
42793 diff --git a/drivers/input/input.c b/drivers/input/input.c
42794 index 1c4c0db..6f7abe3 100644
42795 --- a/drivers/input/input.c
42796 +++ b/drivers/input/input.c
42797 @@ -1772,7 +1772,7 @@ EXPORT_SYMBOL_GPL(input_class);
42798 */
42799 struct input_dev *input_allocate_device(void)
42800 {
42801 - static atomic_t input_no = ATOMIC_INIT(0);
42802 + static atomic_unchecked_t input_no = ATOMIC_INIT(0);
42803 struct input_dev *dev;
42804
42805 dev = kzalloc(sizeof(struct input_dev), GFP_KERNEL);
42806 @@ -1787,7 +1787,7 @@ struct input_dev *input_allocate_device(void)
42807 INIT_LIST_HEAD(&dev->node);
42808
42809 dev_set_name(&dev->dev, "input%ld",
42810 - (unsigned long) atomic_inc_return(&input_no) - 1);
42811 + (unsigned long) atomic_inc_return_unchecked(&input_no) - 1);
42812
42813 __module_get(THIS_MODULE);
42814 }
42815 diff --git a/drivers/input/joystick/sidewinder.c b/drivers/input/joystick/sidewinder.c
42816 index 4a95b22..874c182 100644
42817 --- a/drivers/input/joystick/sidewinder.c
42818 +++ b/drivers/input/joystick/sidewinder.c
42819 @@ -30,6 +30,7 @@
42820 #include <linux/kernel.h>
42821 #include <linux/module.h>
42822 #include <linux/slab.h>
42823 +#include <linux/sched.h>
42824 #include <linux/input.h>
42825 #include <linux/gameport.h>
42826 #include <linux/jiffies.h>
42827 diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
42828 index 603fe0d..f63decc 100644
42829 --- a/drivers/input/joystick/xpad.c
42830 +++ b/drivers/input/joystick/xpad.c
42831 @@ -737,7 +737,7 @@ static void xpad_led_set(struct led_classdev *led_cdev,
42832
42833 static int xpad_led_probe(struct usb_xpad *xpad)
42834 {
42835 - static atomic_t led_seq = ATOMIC_INIT(0);
42836 + static atomic_unchecked_t led_seq = ATOMIC_INIT(0);
42837 long led_no;
42838 struct xpad_led *led;
42839 struct led_classdev *led_cdev;
42840 @@ -750,7 +750,7 @@ static int xpad_led_probe(struct usb_xpad *xpad)
42841 if (!led)
42842 return -ENOMEM;
42843
42844 - led_no = (long)atomic_inc_return(&led_seq) - 1;
42845 + led_no = (long)atomic_inc_return_unchecked(&led_seq) - 1;
42846
42847 snprintf(led->name, sizeof(led->name), "xpad%ld", led_no);
42848 led->xpad = xpad;
42849 diff --git a/drivers/input/misc/ims-pcu.c b/drivers/input/misc/ims-pcu.c
42850 index 5a73639..d586683 100644
42851 --- a/drivers/input/misc/ims-pcu.c
42852 +++ b/drivers/input/misc/ims-pcu.c
42853 @@ -1850,7 +1850,7 @@ static int ims_pcu_identify_type(struct ims_pcu *pcu, u8 *device_id)
42854
42855 static int ims_pcu_init_application_mode(struct ims_pcu *pcu)
42856 {
42857 - static atomic_t device_no = ATOMIC_INIT(0);
42858 + static atomic_unchecked_t device_no = ATOMIC_INIT(0);
42859
42860 const struct ims_pcu_device_info *info;
42861 int error;
42862 @@ -1881,7 +1881,7 @@ static int ims_pcu_init_application_mode(struct ims_pcu *pcu)
42863 }
42864
42865 /* Device appears to be operable, complete initialization */
42866 - pcu->device_no = atomic_inc_return(&device_no) - 1;
42867 + pcu->device_no = atomic_inc_return_unchecked(&device_no) - 1;
42868
42869 /*
42870 * PCU-B devices, both GEN_1 and GEN_2 do not have OFN sensor
42871 diff --git a/drivers/input/mouse/psmouse.h b/drivers/input/mouse/psmouse.h
42872 index 2f0b39d..7370f13 100644
42873 --- a/drivers/input/mouse/psmouse.h
42874 +++ b/drivers/input/mouse/psmouse.h
42875 @@ -116,7 +116,7 @@ struct psmouse_attribute {
42876 ssize_t (*set)(struct psmouse *psmouse, void *data,
42877 const char *buf, size_t count);
42878 bool protect;
42879 -};
42880 +} __do_const;
42881 #define to_psmouse_attr(a) container_of((a), struct psmouse_attribute, dattr)
42882
42883 ssize_t psmouse_attr_show_helper(struct device *dev, struct device_attribute *attr,
42884 diff --git a/drivers/input/mousedev.c b/drivers/input/mousedev.c
42885 index b604564..3f14ae4 100644
42886 --- a/drivers/input/mousedev.c
42887 +++ b/drivers/input/mousedev.c
42888 @@ -744,7 +744,7 @@ static ssize_t mousedev_read(struct file *file, char __user *buffer,
42889
42890 spin_unlock_irq(&client->packet_lock);
42891
42892 - if (copy_to_user(buffer, data, count))
42893 + if (count > sizeof(data) || copy_to_user(buffer, data, count))
42894 return -EFAULT;
42895
42896 return count;
42897 diff --git a/drivers/input/serio/serio.c b/drivers/input/serio/serio.c
42898 index b29134d..394deb0 100644
42899 --- a/drivers/input/serio/serio.c
42900 +++ b/drivers/input/serio/serio.c
42901 @@ -514,7 +514,7 @@ static void serio_release_port(struct device *dev)
42902 */
42903 static void serio_init_port(struct serio *serio)
42904 {
42905 - static atomic_t serio_no = ATOMIC_INIT(0);
42906 + static atomic_unchecked_t serio_no = ATOMIC_INIT(0);
42907
42908 __module_get(THIS_MODULE);
42909
42910 @@ -525,7 +525,7 @@ static void serio_init_port(struct serio *serio)
42911 mutex_init(&serio->drv_mutex);
42912 device_initialize(&serio->dev);
42913 dev_set_name(&serio->dev, "serio%ld",
42914 - (long)atomic_inc_return(&serio_no) - 1);
42915 + (long)atomic_inc_return_unchecked(&serio_no) - 1);
42916 serio->dev.bus = &serio_bus;
42917 serio->dev.release = serio_release_port;
42918 serio->dev.groups = serio_device_attr_groups;
42919 diff --git a/drivers/input/serio/serio_raw.c b/drivers/input/serio/serio_raw.c
42920 index c9a02fe..0debc75 100644
42921 --- a/drivers/input/serio/serio_raw.c
42922 +++ b/drivers/input/serio/serio_raw.c
42923 @@ -292,7 +292,7 @@ static irqreturn_t serio_raw_interrupt(struct serio *serio, unsigned char data,
42924
42925 static int serio_raw_connect(struct serio *serio, struct serio_driver *drv)
42926 {
42927 - static atomic_t serio_raw_no = ATOMIC_INIT(0);
42928 + static atomic_unchecked_t serio_raw_no = ATOMIC_INIT(0);
42929 struct serio_raw *serio_raw;
42930 int err;
42931
42932 @@ -303,7 +303,7 @@ static int serio_raw_connect(struct serio *serio, struct serio_driver *drv)
42933 }
42934
42935 snprintf(serio_raw->name, sizeof(serio_raw->name),
42936 - "serio_raw%ld", (long)atomic_inc_return(&serio_raw_no) - 1);
42937 + "serio_raw%ld", (long)atomic_inc_return_unchecked(&serio_raw_no) - 1);
42938 kref_init(&serio_raw->kref);
42939 INIT_LIST_HEAD(&serio_raw->client_list);
42940 init_waitqueue_head(&serio_raw->wait);
42941 diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
42942 index e5555fc..937986d 100644
42943 --- a/drivers/iommu/iommu.c
42944 +++ b/drivers/iommu/iommu.c
42945 @@ -588,7 +588,7 @@ static struct notifier_block iommu_bus_nb = {
42946 static void iommu_bus_init(struct bus_type *bus, struct iommu_ops *ops)
42947 {
42948 bus_register_notifier(bus, &iommu_bus_nb);
42949 - bus_for_each_dev(bus, NULL, ops, add_iommu_group);
42950 + bus_for_each_dev(bus, NULL, (void *)ops, add_iommu_group);
42951 }
42952
42953 /**
42954 diff --git a/drivers/iommu/irq_remapping.c b/drivers/iommu/irq_remapping.c
42955 index 228632c9..edfe331 100644
42956 --- a/drivers/iommu/irq_remapping.c
42957 +++ b/drivers/iommu/irq_remapping.c
42958 @@ -356,7 +356,7 @@ int setup_hpet_msi_remapped(unsigned int irq, unsigned int id)
42959 void panic_if_irq_remap(const char *msg)
42960 {
42961 if (irq_remapping_enabled)
42962 - panic(msg);
42963 + panic("%s", msg);
42964 }
42965
42966 static void ir_ack_apic_edge(struct irq_data *data)
42967 @@ -377,10 +377,12 @@ static void ir_print_prefix(struct irq_data *data, struct seq_file *p)
42968
42969 void irq_remap_modify_chip_defaults(struct irq_chip *chip)
42970 {
42971 - chip->irq_print_chip = ir_print_prefix;
42972 - chip->irq_ack = ir_ack_apic_edge;
42973 - chip->irq_eoi = ir_ack_apic_level;
42974 - chip->irq_set_affinity = x86_io_apic_ops.set_affinity;
42975 + pax_open_kernel();
42976 + *(void **)&chip->irq_print_chip = ir_print_prefix;
42977 + *(void **)&chip->irq_ack = ir_ack_apic_edge;
42978 + *(void **)&chip->irq_eoi = ir_ack_apic_level;
42979 + *(void **)&chip->irq_set_affinity = x86_io_apic_ops.set_affinity;
42980 + pax_close_kernel();
42981 }
42982
42983 bool setup_remapped_irq(int irq, struct irq_cfg *cfg, struct irq_chip *chip)
42984 diff --git a/drivers/irqchip/irq-gic.c b/drivers/irqchip/irq-gic.c
42985 index 57d165e..611997e 100644
42986 --- a/drivers/irqchip/irq-gic.c
42987 +++ b/drivers/irqchip/irq-gic.c
42988 @@ -84,7 +84,7 @@ static u8 gic_cpu_map[NR_GIC_CPU_IF] __read_mostly;
42989 * Supported arch specific GIC irq extension.
42990 * Default make them NULL.
42991 */
42992 -struct irq_chip gic_arch_extn = {
42993 +irq_chip_no_const gic_arch_extn = {
42994 .irq_eoi = NULL,
42995 .irq_mask = NULL,
42996 .irq_unmask = NULL,
42997 @@ -336,7 +336,7 @@ static void gic_handle_cascade_irq(unsigned int irq, struct irq_desc *desc)
42998 chained_irq_exit(chip, desc);
42999 }
43000
43001 -static struct irq_chip gic_chip = {
43002 +static irq_chip_no_const gic_chip __read_only = {
43003 .name = "GIC",
43004 .irq_mask = gic_mask_irq,
43005 .irq_unmask = gic_unmask_irq,
43006 diff --git a/drivers/irqchip/irq-renesas-irqc.c b/drivers/irqchip/irq-renesas-irqc.c
43007 index 8777065..a4a9967 100644
43008 --- a/drivers/irqchip/irq-renesas-irqc.c
43009 +++ b/drivers/irqchip/irq-renesas-irqc.c
43010 @@ -151,7 +151,7 @@ static int irqc_probe(struct platform_device *pdev)
43011 struct irqc_priv *p;
43012 struct resource *io;
43013 struct resource *irq;
43014 - struct irq_chip *irq_chip;
43015 + irq_chip_no_const *irq_chip;
43016 const char *name = dev_name(&pdev->dev);
43017 int ret;
43018 int k;
43019 diff --git a/drivers/isdn/capi/capi.c b/drivers/isdn/capi/capi.c
43020 index ac6f72b..81150f2 100644
43021 --- a/drivers/isdn/capi/capi.c
43022 +++ b/drivers/isdn/capi/capi.c
43023 @@ -81,8 +81,8 @@ struct capiminor {
43024
43025 struct capi20_appl *ap;
43026 u32 ncci;
43027 - atomic_t datahandle;
43028 - atomic_t msgid;
43029 + atomic_unchecked_t datahandle;
43030 + atomic_unchecked_t msgid;
43031
43032 struct tty_port port;
43033 int ttyinstop;
43034 @@ -391,7 +391,7 @@ gen_data_b3_resp_for(struct capiminor *mp, struct sk_buff *skb)
43035 capimsg_setu16(s, 2, mp->ap->applid);
43036 capimsg_setu8 (s, 4, CAPI_DATA_B3);
43037 capimsg_setu8 (s, 5, CAPI_RESP);
43038 - capimsg_setu16(s, 6, atomic_inc_return(&mp->msgid));
43039 + capimsg_setu16(s, 6, atomic_inc_return_unchecked(&mp->msgid));
43040 capimsg_setu32(s, 8, mp->ncci);
43041 capimsg_setu16(s, 12, datahandle);
43042 }
43043 @@ -512,14 +512,14 @@ static void handle_minor_send(struct capiminor *mp)
43044 mp->outbytes -= len;
43045 spin_unlock_bh(&mp->outlock);
43046
43047 - datahandle = atomic_inc_return(&mp->datahandle);
43048 + datahandle = atomic_inc_return_unchecked(&mp->datahandle);
43049 skb_push(skb, CAPI_DATA_B3_REQ_LEN);
43050 memset(skb->data, 0, CAPI_DATA_B3_REQ_LEN);
43051 capimsg_setu16(skb->data, 0, CAPI_DATA_B3_REQ_LEN);
43052 capimsg_setu16(skb->data, 2, mp->ap->applid);
43053 capimsg_setu8 (skb->data, 4, CAPI_DATA_B3);
43054 capimsg_setu8 (skb->data, 5, CAPI_REQ);
43055 - capimsg_setu16(skb->data, 6, atomic_inc_return(&mp->msgid));
43056 + capimsg_setu16(skb->data, 6, atomic_inc_return_unchecked(&mp->msgid));
43057 capimsg_setu32(skb->data, 8, mp->ncci); /* NCCI */
43058 capimsg_setu32(skb->data, 12, (u32)(long)skb->data);/* Data32 */
43059 capimsg_setu16(skb->data, 16, len); /* Data length */
43060 diff --git a/drivers/isdn/gigaset/bas-gigaset.c b/drivers/isdn/gigaset/bas-gigaset.c
43061 index c44950d..10ac276 100644
43062 --- a/drivers/isdn/gigaset/bas-gigaset.c
43063 +++ b/drivers/isdn/gigaset/bas-gigaset.c
43064 @@ -2564,22 +2564,22 @@ static int gigaset_post_reset(struct usb_interface *intf)
43065
43066
43067 static const struct gigaset_ops gigops = {
43068 - gigaset_write_cmd,
43069 - gigaset_write_room,
43070 - gigaset_chars_in_buffer,
43071 - gigaset_brkchars,
43072 - gigaset_init_bchannel,
43073 - gigaset_close_bchannel,
43074 - gigaset_initbcshw,
43075 - gigaset_freebcshw,
43076 - gigaset_reinitbcshw,
43077 - gigaset_initcshw,
43078 - gigaset_freecshw,
43079 - gigaset_set_modem_ctrl,
43080 - gigaset_baud_rate,
43081 - gigaset_set_line_ctrl,
43082 - gigaset_isoc_send_skb,
43083 - gigaset_isoc_input,
43084 + .write_cmd = gigaset_write_cmd,
43085 + .write_room = gigaset_write_room,
43086 + .chars_in_buffer = gigaset_chars_in_buffer,
43087 + .brkchars = gigaset_brkchars,
43088 + .init_bchannel = gigaset_init_bchannel,
43089 + .close_bchannel = gigaset_close_bchannel,
43090 + .initbcshw = gigaset_initbcshw,
43091 + .freebcshw = gigaset_freebcshw,
43092 + .reinitbcshw = gigaset_reinitbcshw,
43093 + .initcshw = gigaset_initcshw,
43094 + .freecshw = gigaset_freecshw,
43095 + .set_modem_ctrl = gigaset_set_modem_ctrl,
43096 + .baud_rate = gigaset_baud_rate,
43097 + .set_line_ctrl = gigaset_set_line_ctrl,
43098 + .send_skb = gigaset_isoc_send_skb,
43099 + .handle_input = gigaset_isoc_input,
43100 };
43101
43102 /* bas_gigaset_init
43103 diff --git a/drivers/isdn/gigaset/interface.c b/drivers/isdn/gigaset/interface.c
43104 index 600c79b..3752bab 100644
43105 --- a/drivers/isdn/gigaset/interface.c
43106 +++ b/drivers/isdn/gigaset/interface.c
43107 @@ -130,9 +130,9 @@ static int if_open(struct tty_struct *tty, struct file *filp)
43108 }
43109 tty->driver_data = cs;
43110
43111 - ++cs->port.count;
43112 + atomic_inc(&cs->port.count);
43113
43114 - if (cs->port.count == 1) {
43115 + if (atomic_read(&cs->port.count) == 1) {
43116 tty_port_tty_set(&cs->port, tty);
43117 cs->port.low_latency = 1;
43118 }
43119 @@ -156,9 +156,9 @@ static void if_close(struct tty_struct *tty, struct file *filp)
43120
43121 if (!cs->connected)
43122 gig_dbg(DEBUG_IF, "not connected"); /* nothing to do */
43123 - else if (!cs->port.count)
43124 + else if (!atomic_read(&cs->port.count))
43125 dev_warn(cs->dev, "%s: device not opened\n", __func__);
43126 - else if (!--cs->port.count)
43127 + else if (!atomic_dec_return(&cs->port.count))
43128 tty_port_tty_set(&cs->port, NULL);
43129
43130 mutex_unlock(&cs->mutex);
43131 diff --git a/drivers/isdn/gigaset/ser-gigaset.c b/drivers/isdn/gigaset/ser-gigaset.c
43132 index 8c91fd5..14f13ce 100644
43133 --- a/drivers/isdn/gigaset/ser-gigaset.c
43134 +++ b/drivers/isdn/gigaset/ser-gigaset.c
43135 @@ -453,22 +453,22 @@ static int gigaset_set_line_ctrl(struct cardstate *cs, unsigned cflag)
43136 }
43137
43138 static const struct gigaset_ops ops = {
43139 - gigaset_write_cmd,
43140 - gigaset_write_room,
43141 - gigaset_chars_in_buffer,
43142 - gigaset_brkchars,
43143 - gigaset_init_bchannel,
43144 - gigaset_close_bchannel,
43145 - gigaset_initbcshw,
43146 - gigaset_freebcshw,
43147 - gigaset_reinitbcshw,
43148 - gigaset_initcshw,
43149 - gigaset_freecshw,
43150 - gigaset_set_modem_ctrl,
43151 - gigaset_baud_rate,
43152 - gigaset_set_line_ctrl,
43153 - gigaset_m10x_send_skb, /* asyncdata.c */
43154 - gigaset_m10x_input, /* asyncdata.c */
43155 + .write_cmd = gigaset_write_cmd,
43156 + .write_room = gigaset_write_room,
43157 + .chars_in_buffer = gigaset_chars_in_buffer,
43158 + .brkchars = gigaset_brkchars,
43159 + .init_bchannel = gigaset_init_bchannel,
43160 + .close_bchannel = gigaset_close_bchannel,
43161 + .initbcshw = gigaset_initbcshw,
43162 + .freebcshw = gigaset_freebcshw,
43163 + .reinitbcshw = gigaset_reinitbcshw,
43164 + .initcshw = gigaset_initcshw,
43165 + .freecshw = gigaset_freecshw,
43166 + .set_modem_ctrl = gigaset_set_modem_ctrl,
43167 + .baud_rate = gigaset_baud_rate,
43168 + .set_line_ctrl = gigaset_set_line_ctrl,
43169 + .send_skb = gigaset_m10x_send_skb, /* asyncdata.c */
43170 + .handle_input = gigaset_m10x_input, /* asyncdata.c */
43171 };
43172
43173
43174 diff --git a/drivers/isdn/gigaset/usb-gigaset.c b/drivers/isdn/gigaset/usb-gigaset.c
43175 index d0a41cb..b953e50 100644
43176 --- a/drivers/isdn/gigaset/usb-gigaset.c
43177 +++ b/drivers/isdn/gigaset/usb-gigaset.c
43178 @@ -547,7 +547,7 @@ static int gigaset_brkchars(struct cardstate *cs, const unsigned char buf[6])
43179 gigaset_dbg_buffer(DEBUG_USBREQ, "brkchars", 6, buf);
43180 memcpy(cs->hw.usb->bchars, buf, 6);
43181 return usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x19, 0x41,
43182 - 0, 0, &buf, 6, 2000);
43183 + 0, 0, buf, 6, 2000);
43184 }
43185
43186 static void gigaset_freebcshw(struct bc_state *bcs)
43187 @@ -869,22 +869,22 @@ static int gigaset_pre_reset(struct usb_interface *intf)
43188 }
43189
43190 static const struct gigaset_ops ops = {
43191 - gigaset_write_cmd,
43192 - gigaset_write_room,
43193 - gigaset_chars_in_buffer,
43194 - gigaset_brkchars,
43195 - gigaset_init_bchannel,
43196 - gigaset_close_bchannel,
43197 - gigaset_initbcshw,
43198 - gigaset_freebcshw,
43199 - gigaset_reinitbcshw,
43200 - gigaset_initcshw,
43201 - gigaset_freecshw,
43202 - gigaset_set_modem_ctrl,
43203 - gigaset_baud_rate,
43204 - gigaset_set_line_ctrl,
43205 - gigaset_m10x_send_skb,
43206 - gigaset_m10x_input,
43207 + .write_cmd = gigaset_write_cmd,
43208 + .write_room = gigaset_write_room,
43209 + .chars_in_buffer = gigaset_chars_in_buffer,
43210 + .brkchars = gigaset_brkchars,
43211 + .init_bchannel = gigaset_init_bchannel,
43212 + .close_bchannel = gigaset_close_bchannel,
43213 + .initbcshw = gigaset_initbcshw,
43214 + .freebcshw = gigaset_freebcshw,
43215 + .reinitbcshw = gigaset_reinitbcshw,
43216 + .initcshw = gigaset_initcshw,
43217 + .freecshw = gigaset_freecshw,
43218 + .set_modem_ctrl = gigaset_set_modem_ctrl,
43219 + .baud_rate = gigaset_baud_rate,
43220 + .set_line_ctrl = gigaset_set_line_ctrl,
43221 + .send_skb = gigaset_m10x_send_skb,
43222 + .handle_input = gigaset_m10x_input,
43223 };
43224
43225 /*
43226 diff --git a/drivers/isdn/hardware/avm/b1.c b/drivers/isdn/hardware/avm/b1.c
43227 index 4d9b195..455075c 100644
43228 --- a/drivers/isdn/hardware/avm/b1.c
43229 +++ b/drivers/isdn/hardware/avm/b1.c
43230 @@ -176,7 +176,7 @@ int b1_load_t4file(avmcard *card, capiloaddatapart *t4file)
43231 }
43232 if (left) {
43233 if (t4file->user) {
43234 - if (copy_from_user(buf, dp, left))
43235 + if (left > sizeof buf || copy_from_user(buf, dp, left))
43236 return -EFAULT;
43237 } else {
43238 memcpy(buf, dp, left);
43239 @@ -224,7 +224,7 @@ int b1_load_config(avmcard *card, capiloaddatapart *config)
43240 }
43241 if (left) {
43242 if (config->user) {
43243 - if (copy_from_user(buf, dp, left))
43244 + if (left > sizeof buf || copy_from_user(buf, dp, left))
43245 return -EFAULT;
43246 } else {
43247 memcpy(buf, dp, left);
43248 diff --git a/drivers/isdn/i4l/isdn_common.c b/drivers/isdn/i4l/isdn_common.c
43249 index 9b856e1..fa03c92 100644
43250 --- a/drivers/isdn/i4l/isdn_common.c
43251 +++ b/drivers/isdn/i4l/isdn_common.c
43252 @@ -1654,6 +1654,8 @@ isdn_ioctl(struct file *file, uint cmd, ulong arg)
43253 } else
43254 return -EINVAL;
43255 case IIOCDBGVAR:
43256 + if (!capable(CAP_SYS_RAWIO))
43257 + return -EPERM;
43258 if (arg) {
43259 if (copy_to_user(argp, &dev, sizeof(ulong)))
43260 return -EFAULT;
43261 diff --git a/drivers/isdn/i4l/isdn_concap.c b/drivers/isdn/i4l/isdn_concap.c
43262 index 91d5730..336523e 100644
43263 --- a/drivers/isdn/i4l/isdn_concap.c
43264 +++ b/drivers/isdn/i4l/isdn_concap.c
43265 @@ -80,9 +80,9 @@ static int isdn_concap_dl_disconn_req(struct concap_proto *concap)
43266 }
43267
43268 struct concap_device_ops isdn_concap_reliable_dl_dops = {
43269 - &isdn_concap_dl_data_req,
43270 - &isdn_concap_dl_connect_req,
43271 - &isdn_concap_dl_disconn_req
43272 + .data_req = &isdn_concap_dl_data_req,
43273 + .connect_req = &isdn_concap_dl_connect_req,
43274 + .disconn_req = &isdn_concap_dl_disconn_req
43275 };
43276
43277 /* The following should better go into a dedicated source file such that
43278 diff --git a/drivers/isdn/i4l/isdn_tty.c b/drivers/isdn/i4l/isdn_tty.c
43279 index 3c5f249..5fac4d0 100644
43280 --- a/drivers/isdn/i4l/isdn_tty.c
43281 +++ b/drivers/isdn/i4l/isdn_tty.c
43282 @@ -1508,9 +1508,9 @@ isdn_tty_open(struct tty_struct *tty, struct file *filp)
43283
43284 #ifdef ISDN_DEBUG_MODEM_OPEN
43285 printk(KERN_DEBUG "isdn_tty_open %s, count = %d\n", tty->name,
43286 - port->count);
43287 + atomic_read(&port->count));
43288 #endif
43289 - port->count++;
43290 + atomic_inc(&port->count);
43291 port->tty = tty;
43292 /*
43293 * Start up serial port
43294 @@ -1554,7 +1554,7 @@ isdn_tty_close(struct tty_struct *tty, struct file *filp)
43295 #endif
43296 return;
43297 }
43298 - if ((tty->count == 1) && (port->count != 1)) {
43299 + if ((tty->count == 1) && (atomic_read(&port->count) != 1)) {
43300 /*
43301 * Uh, oh. tty->count is 1, which means that the tty
43302 * structure will be freed. Info->count should always
43303 @@ -1563,15 +1563,15 @@ isdn_tty_close(struct tty_struct *tty, struct file *filp)
43304 * serial port won't be shutdown.
43305 */
43306 printk(KERN_ERR "isdn_tty_close: bad port count; tty->count is 1, "
43307 - "info->count is %d\n", port->count);
43308 - port->count = 1;
43309 + "info->count is %d\n", atomic_read(&port->count));
43310 + atomic_set(&port->count, 1);
43311 }
43312 - if (--port->count < 0) {
43313 + if (atomic_dec_return(&port->count) < 0) {
43314 printk(KERN_ERR "isdn_tty_close: bad port count for ttyi%d: %d\n",
43315 - info->line, port->count);
43316 - port->count = 0;
43317 + info->line, atomic_read(&port->count));
43318 + atomic_set(&port->count, 0);
43319 }
43320 - if (port->count) {
43321 + if (atomic_read(&port->count)) {
43322 #ifdef ISDN_DEBUG_MODEM_OPEN
43323 printk(KERN_DEBUG "isdn_tty_close after info->count != 0\n");
43324 #endif
43325 @@ -1625,7 +1625,7 @@ isdn_tty_hangup(struct tty_struct *tty)
43326 if (isdn_tty_paranoia_check(info, tty->name, "isdn_tty_hangup"))
43327 return;
43328 isdn_tty_shutdown(info);
43329 - port->count = 0;
43330 + atomic_set(&port->count, 0);
43331 port->flags &= ~ASYNC_NORMAL_ACTIVE;
43332 port->tty = NULL;
43333 wake_up_interruptible(&port->open_wait);
43334 @@ -1970,7 +1970,7 @@ isdn_tty_find_icall(int di, int ch, setup_parm *setup)
43335 for (i = 0; i < ISDN_MAX_CHANNELS; i++) {
43336 modem_info *info = &dev->mdm.info[i];
43337
43338 - if (info->port.count == 0)
43339 + if (atomic_read(&info->port.count) == 0)
43340 continue;
43341 if ((info->emu.mdmreg[REG_SI1] & si2bit[si1]) && /* SI1 is matching */
43342 (info->emu.mdmreg[REG_SI2] == si2)) { /* SI2 is matching */
43343 diff --git a/drivers/isdn/i4l/isdn_x25iface.c b/drivers/isdn/i4l/isdn_x25iface.c
43344 index e2d4e58..40cd045 100644
43345 --- a/drivers/isdn/i4l/isdn_x25iface.c
43346 +++ b/drivers/isdn/i4l/isdn_x25iface.c
43347 @@ -53,14 +53,14 @@ static int isdn_x25iface_disconn_ind(struct concap_proto *);
43348
43349
43350 static struct concap_proto_ops ix25_pops = {
43351 - &isdn_x25iface_proto_new,
43352 - &isdn_x25iface_proto_del,
43353 - &isdn_x25iface_proto_restart,
43354 - &isdn_x25iface_proto_close,
43355 - &isdn_x25iface_xmit,
43356 - &isdn_x25iface_receive,
43357 - &isdn_x25iface_connect_ind,
43358 - &isdn_x25iface_disconn_ind
43359 + .proto_new = &isdn_x25iface_proto_new,
43360 + .proto_del = &isdn_x25iface_proto_del,
43361 + .restart = &isdn_x25iface_proto_restart,
43362 + .close = &isdn_x25iface_proto_close,
43363 + .encap_and_xmit = &isdn_x25iface_xmit,
43364 + .data_ind = &isdn_x25iface_receive,
43365 + .connect_ind = &isdn_x25iface_connect_ind,
43366 + .disconn_ind = &isdn_x25iface_disconn_ind
43367 };
43368
43369 /* error message helper function */
43370 diff --git a/drivers/isdn/icn/icn.c b/drivers/isdn/icn/icn.c
43371 index 6a7447c..cae33fe 100644
43372 --- a/drivers/isdn/icn/icn.c
43373 +++ b/drivers/isdn/icn/icn.c
43374 @@ -1045,7 +1045,7 @@ icn_writecmd(const u_char *buf, int len, int user, icn_card *card)
43375 if (count > len)
43376 count = len;
43377 if (user) {
43378 - if (copy_from_user(msg, buf, count))
43379 + if (count > sizeof msg || copy_from_user(msg, buf, count))
43380 return -EFAULT;
43381 } else
43382 memcpy(msg, buf, count);
43383 diff --git a/drivers/isdn/mISDN/dsp_cmx.c b/drivers/isdn/mISDN/dsp_cmx.c
43384 index a4f05c5..1433bc5 100644
43385 --- a/drivers/isdn/mISDN/dsp_cmx.c
43386 +++ b/drivers/isdn/mISDN/dsp_cmx.c
43387 @@ -1628,7 +1628,7 @@ unsigned long dsp_spl_jiffies; /* calculate the next time to fire */
43388 static u16 dsp_count; /* last sample count */
43389 static int dsp_count_valid; /* if we have last sample count */
43390
43391 -void
43392 +void __intentional_overflow(-1)
43393 dsp_cmx_send(void *arg)
43394 {
43395 struct dsp_conf *conf;
43396 diff --git a/drivers/leds/leds-clevo-mail.c b/drivers/leds/leds-clevo-mail.c
43397 index f58a354..fbae176 100644
43398 --- a/drivers/leds/leds-clevo-mail.c
43399 +++ b/drivers/leds/leds-clevo-mail.c
43400 @@ -40,7 +40,7 @@ static int __init clevo_mail_led_dmi_callback(const struct dmi_system_id *id)
43401 * detected as working, but in reality it is not) as low as
43402 * possible.
43403 */
43404 -static struct dmi_system_id clevo_mail_led_dmi_table[] __initdata = {
43405 +static struct dmi_system_id clevo_mail_led_dmi_table[] __initconst = {
43406 {
43407 .callback = clevo_mail_led_dmi_callback,
43408 .ident = "Clevo D410J",
43409 diff --git a/drivers/leds/leds-ss4200.c b/drivers/leds/leds-ss4200.c
43410 index 2eb3ef6..295891f 100644
43411 --- a/drivers/leds/leds-ss4200.c
43412 +++ b/drivers/leds/leds-ss4200.c
43413 @@ -91,7 +91,7 @@ MODULE_PARM_DESC(nodetect, "Skip DMI-based hardware detection");
43414 * detected as working, but in reality it is not) as low as
43415 * possible.
43416 */
43417 -static struct dmi_system_id nas_led_whitelist[] __initdata = {
43418 +static struct dmi_system_id nas_led_whitelist[] __initconst = {
43419 {
43420 .callback = ss4200_led_dmi_callback,
43421 .ident = "Intel SS4200-E",
43422 diff --git a/drivers/lguest/core.c b/drivers/lguest/core.c
43423 index 0bf1e4e..b4bf44e 100644
43424 --- a/drivers/lguest/core.c
43425 +++ b/drivers/lguest/core.c
43426 @@ -97,9 +97,17 @@ static __init int map_switcher(void)
43427 * The end address needs +1 because __get_vm_area allocates an
43428 * extra guard page, so we need space for that.
43429 */
43430 +
43431 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
43432 + switcher_vma = __get_vm_area(TOTAL_SWITCHER_PAGES * PAGE_SIZE,
43433 + VM_ALLOC | VM_KERNEXEC, switcher_addr, switcher_addr
43434 + + (TOTAL_SWITCHER_PAGES+1) * PAGE_SIZE);
43435 +#else
43436 switcher_vma = __get_vm_area(TOTAL_SWITCHER_PAGES * PAGE_SIZE,
43437 VM_ALLOC, switcher_addr, switcher_addr
43438 + (TOTAL_SWITCHER_PAGES+1) * PAGE_SIZE);
43439 +#endif
43440 +
43441 if (!switcher_vma) {
43442 err = -ENOMEM;
43443 printk("lguest: could not map switcher pages high\n");
43444 @@ -124,7 +132,7 @@ static __init int map_switcher(void)
43445 * Now the Switcher is mapped at the right address, we can't fail!
43446 * Copy in the compiled-in Switcher code (from x86/switcher_32.S).
43447 */
43448 - memcpy(switcher_vma->addr, start_switcher_text,
43449 + memcpy(switcher_vma->addr, ktla_ktva(start_switcher_text),
43450 end_switcher_text - start_switcher_text);
43451
43452 printk(KERN_INFO "lguest: mapped switcher at %p\n",
43453 diff --git a/drivers/lguest/page_tables.c b/drivers/lguest/page_tables.c
43454 index e8b55c3..3514c37 100644
43455 --- a/drivers/lguest/page_tables.c
43456 +++ b/drivers/lguest/page_tables.c
43457 @@ -559,7 +559,7 @@ void pin_page(struct lg_cpu *cpu, unsigned long vaddr)
43458 /*:*/
43459
43460 #ifdef CONFIG_X86_PAE
43461 -static void release_pmd(pmd_t *spmd)
43462 +static void __intentional_overflow(-1) release_pmd(pmd_t *spmd)
43463 {
43464 /* If the entry's not present, there's nothing to release. */
43465 if (pmd_flags(*spmd) & _PAGE_PRESENT) {
43466 diff --git a/drivers/lguest/x86/core.c b/drivers/lguest/x86/core.c
43467 index 922a1ac..9dd0c2a 100644
43468 --- a/drivers/lguest/x86/core.c
43469 +++ b/drivers/lguest/x86/core.c
43470 @@ -59,7 +59,7 @@ static struct {
43471 /* Offset from where switcher.S was compiled to where we've copied it */
43472 static unsigned long switcher_offset(void)
43473 {
43474 - return switcher_addr - (unsigned long)start_switcher_text;
43475 + return switcher_addr - (unsigned long)ktla_ktva(start_switcher_text);
43476 }
43477
43478 /* This cpu's struct lguest_pages (after the Switcher text page) */
43479 @@ -99,7 +99,13 @@ static void copy_in_guest_info(struct lg_cpu *cpu, struct lguest_pages *pages)
43480 * These copies are pretty cheap, so we do them unconditionally: */
43481 /* Save the current Host top-level page directory.
43482 */
43483 +
43484 +#ifdef CONFIG_PAX_PER_CPU_PGD
43485 + pages->state.host_cr3 = read_cr3();
43486 +#else
43487 pages->state.host_cr3 = __pa(current->mm->pgd);
43488 +#endif
43489 +
43490 /*
43491 * Set up the Guest's page tables to see this CPU's pages (and no
43492 * other CPU's pages).
43493 @@ -477,7 +483,7 @@ void __init lguest_arch_host_init(void)
43494 * compiled-in switcher code and the high-mapped copy we just made.
43495 */
43496 for (i = 0; i < IDT_ENTRIES; i++)
43497 - default_idt_entries[i] += switcher_offset();
43498 + default_idt_entries[i] = ktla_ktva(default_idt_entries[i]) + switcher_offset();
43499
43500 /*
43501 * Set up the Switcher's per-cpu areas.
43502 @@ -560,7 +566,7 @@ void __init lguest_arch_host_init(void)
43503 * it will be undisturbed when we switch. To change %cs and jump we
43504 * need this structure to feed to Intel's "lcall" instruction.
43505 */
43506 - lguest_entry.offset = (long)switch_to_guest + switcher_offset();
43507 + lguest_entry.offset = (long)ktla_ktva(switch_to_guest) + switcher_offset();
43508 lguest_entry.segment = LGUEST_CS;
43509
43510 /*
43511 diff --git a/drivers/lguest/x86/switcher_32.S b/drivers/lguest/x86/switcher_32.S
43512 index 40634b0..4f5855e 100644
43513 --- a/drivers/lguest/x86/switcher_32.S
43514 +++ b/drivers/lguest/x86/switcher_32.S
43515 @@ -87,6 +87,7 @@
43516 #include <asm/page.h>
43517 #include <asm/segment.h>
43518 #include <asm/lguest.h>
43519 +#include <asm/processor-flags.h>
43520
43521 // We mark the start of the code to copy
43522 // It's placed in .text tho it's never run here
43523 @@ -149,6 +150,13 @@ ENTRY(switch_to_guest)
43524 // Changes type when we load it: damn Intel!
43525 // For after we switch over our page tables
43526 // That entry will be read-only: we'd crash.
43527 +
43528 +#ifdef CONFIG_PAX_KERNEXEC
43529 + mov %cr0, %edx
43530 + xor $X86_CR0_WP, %edx
43531 + mov %edx, %cr0
43532 +#endif
43533 +
43534 movl $(GDT_ENTRY_TSS*8), %edx
43535 ltr %dx
43536
43537 @@ -157,9 +165,15 @@ ENTRY(switch_to_guest)
43538 // Let's clear it again for our return.
43539 // The GDT descriptor of the Host
43540 // Points to the table after two "size" bytes
43541 - movl (LGUEST_PAGES_host_gdt_desc+2)(%eax), %edx
43542 + movl (LGUEST_PAGES_host_gdt_desc+2)(%eax), %eax
43543 // Clear "used" from type field (byte 5, bit 2)
43544 - andb $0xFD, (GDT_ENTRY_TSS*8 + 5)(%edx)
43545 + andb $0xFD, (GDT_ENTRY_TSS*8 + 5)(%eax)
43546 +
43547 +#ifdef CONFIG_PAX_KERNEXEC
43548 + mov %cr0, %eax
43549 + xor $X86_CR0_WP, %eax
43550 + mov %eax, %cr0
43551 +#endif
43552
43553 // Once our page table's switched, the Guest is live!
43554 // The Host fades as we run this final step.
43555 @@ -295,13 +309,12 @@ deliver_to_host:
43556 // I consulted gcc, and it gave
43557 // These instructions, which I gladly credit:
43558 leal (%edx,%ebx,8), %eax
43559 - movzwl (%eax),%edx
43560 - movl 4(%eax), %eax
43561 - xorw %ax, %ax
43562 - orl %eax, %edx
43563 + movl 4(%eax), %edx
43564 + movw (%eax), %dx
43565 // Now the address of the handler's in %edx
43566 // We call it now: its "iret" drops us home.
43567 - jmp *%edx
43568 + ljmp $__KERNEL_CS, $1f
43569 +1: jmp *%edx
43570
43571 // Every interrupt can come to us here
43572 // But we must truly tell each apart.
43573 diff --git a/drivers/md/bcache/closure.h b/drivers/md/bcache/closure.h
43574 index 7ef7461..5a09dac 100644
43575 --- a/drivers/md/bcache/closure.h
43576 +++ b/drivers/md/bcache/closure.h
43577 @@ -238,7 +238,7 @@ static inline void closure_set_stopped(struct closure *cl)
43578 static inline void set_closure_fn(struct closure *cl, closure_fn *fn,
43579 struct workqueue_struct *wq)
43580 {
43581 - BUG_ON(object_is_on_stack(cl));
43582 + BUG_ON(object_starts_on_stack(cl));
43583 closure_set_ip(cl);
43584 cl->fn = fn;
43585 cl->wq = wq;
43586 diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c
43587 index 9a8e66a..10cc762 100644
43588 --- a/drivers/md/bitmap.c
43589 +++ b/drivers/md/bitmap.c
43590 @@ -1779,7 +1779,7 @@ void bitmap_status(struct seq_file *seq, struct bitmap *bitmap)
43591 chunk_kb ? "KB" : "B");
43592 if (bitmap->storage.file) {
43593 seq_printf(seq, ", file: ");
43594 - seq_path(seq, &bitmap->storage.file->f_path, " \t\n");
43595 + seq_path(seq, &bitmap->storage.file->f_path, " \t\n\\");
43596 }
43597
43598 seq_printf(seq, "\n");
43599 diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c
43600 index 5152142..623d141 100644
43601 --- a/drivers/md/dm-ioctl.c
43602 +++ b/drivers/md/dm-ioctl.c
43603 @@ -1769,7 +1769,7 @@ static int validate_params(uint cmd, struct dm_ioctl *param)
43604 cmd == DM_LIST_VERSIONS_CMD)
43605 return 0;
43606
43607 - if ((cmd == DM_DEV_CREATE_CMD)) {
43608 + if (cmd == DM_DEV_CREATE_CMD) {
43609 if (!*param->name) {
43610 DMWARN("name not supplied when creating device");
43611 return -EINVAL;
43612 diff --git a/drivers/md/dm-raid1.c b/drivers/md/dm-raid1.c
43613 index 7dfdb5c..4caada6 100644
43614 --- a/drivers/md/dm-raid1.c
43615 +++ b/drivers/md/dm-raid1.c
43616 @@ -40,7 +40,7 @@ enum dm_raid1_error {
43617
43618 struct mirror {
43619 struct mirror_set *ms;
43620 - atomic_t error_count;
43621 + atomic_unchecked_t error_count;
43622 unsigned long error_type;
43623 struct dm_dev *dev;
43624 sector_t offset;
43625 @@ -186,7 +186,7 @@ static struct mirror *get_valid_mirror(struct mirror_set *ms)
43626 struct mirror *m;
43627
43628 for (m = ms->mirror; m < ms->mirror + ms->nr_mirrors; m++)
43629 - if (!atomic_read(&m->error_count))
43630 + if (!atomic_read_unchecked(&m->error_count))
43631 return m;
43632
43633 return NULL;
43634 @@ -218,7 +218,7 @@ static void fail_mirror(struct mirror *m, enum dm_raid1_error error_type)
43635 * simple way to tell if a device has encountered
43636 * errors.
43637 */
43638 - atomic_inc(&m->error_count);
43639 + atomic_inc_unchecked(&m->error_count);
43640
43641 if (test_and_set_bit(error_type, &m->error_type))
43642 return;
43643 @@ -409,7 +409,7 @@ static struct mirror *choose_mirror(struct mirror_set *ms, sector_t sector)
43644 struct mirror *m = get_default_mirror(ms);
43645
43646 do {
43647 - if (likely(!atomic_read(&m->error_count)))
43648 + if (likely(!atomic_read_unchecked(&m->error_count)))
43649 return m;
43650
43651 if (m-- == ms->mirror)
43652 @@ -423,7 +423,7 @@ static int default_ok(struct mirror *m)
43653 {
43654 struct mirror *default_mirror = get_default_mirror(m->ms);
43655
43656 - return !atomic_read(&default_mirror->error_count);
43657 + return !atomic_read_unchecked(&default_mirror->error_count);
43658 }
43659
43660 static int mirror_available(struct mirror_set *ms, struct bio *bio)
43661 @@ -560,7 +560,7 @@ static void do_reads(struct mirror_set *ms, struct bio_list *reads)
43662 */
43663 if (likely(region_in_sync(ms, region, 1)))
43664 m = choose_mirror(ms, bio->bi_iter.bi_sector);
43665 - else if (m && atomic_read(&m->error_count))
43666 + else if (m && atomic_read_unchecked(&m->error_count))
43667 m = NULL;
43668
43669 if (likely(m))
43670 @@ -927,7 +927,7 @@ static int get_mirror(struct mirror_set *ms, struct dm_target *ti,
43671 }
43672
43673 ms->mirror[mirror].ms = ms;
43674 - atomic_set(&(ms->mirror[mirror].error_count), 0);
43675 + atomic_set_unchecked(&(ms->mirror[mirror].error_count), 0);
43676 ms->mirror[mirror].error_type = 0;
43677 ms->mirror[mirror].offset = offset;
43678
43679 @@ -1342,7 +1342,7 @@ static void mirror_resume(struct dm_target *ti)
43680 */
43681 static char device_status_char(struct mirror *m)
43682 {
43683 - if (!atomic_read(&(m->error_count)))
43684 + if (!atomic_read_unchecked(&(m->error_count)))
43685 return 'A';
43686
43687 return (test_bit(DM_RAID1_FLUSH_ERROR, &(m->error_type))) ? 'F' :
43688 diff --git a/drivers/md/dm-stats.c b/drivers/md/dm-stats.c
43689 index 28a9012..9c0f6a5 100644
43690 --- a/drivers/md/dm-stats.c
43691 +++ b/drivers/md/dm-stats.c
43692 @@ -382,7 +382,7 @@ do_sync_free:
43693 synchronize_rcu_expedited();
43694 dm_stat_free(&s->rcu_head);
43695 } else {
43696 - ACCESS_ONCE(dm_stat_need_rcu_barrier) = 1;
43697 + ACCESS_ONCE_RW(dm_stat_need_rcu_barrier) = 1;
43698 call_rcu(&s->rcu_head, dm_stat_free);
43699 }
43700 return 0;
43701 @@ -554,8 +554,8 @@ void dm_stats_account_io(struct dm_stats *stats, unsigned long bi_rw,
43702 ((bi_rw & (REQ_WRITE | REQ_DISCARD)) ==
43703 (ACCESS_ONCE(last->last_rw) & (REQ_WRITE | REQ_DISCARD)))
43704 ));
43705 - ACCESS_ONCE(last->last_sector) = end_sector;
43706 - ACCESS_ONCE(last->last_rw) = bi_rw;
43707 + ACCESS_ONCE_RW(last->last_sector) = end_sector;
43708 + ACCESS_ONCE_RW(last->last_rw) = bi_rw;
43709 }
43710
43711 rcu_read_lock();
43712 diff --git a/drivers/md/dm-stripe.c b/drivers/md/dm-stripe.c
43713 index d1600d2..4c3af3a 100644
43714 --- a/drivers/md/dm-stripe.c
43715 +++ b/drivers/md/dm-stripe.c
43716 @@ -21,7 +21,7 @@ struct stripe {
43717 struct dm_dev *dev;
43718 sector_t physical_start;
43719
43720 - atomic_t error_count;
43721 + atomic_unchecked_t error_count;
43722 };
43723
43724 struct stripe_c {
43725 @@ -186,7 +186,7 @@ static int stripe_ctr(struct dm_target *ti, unsigned int argc, char **argv)
43726 kfree(sc);
43727 return r;
43728 }
43729 - atomic_set(&(sc->stripe[i].error_count), 0);
43730 + atomic_set_unchecked(&(sc->stripe[i].error_count), 0);
43731 }
43732
43733 ti->private = sc;
43734 @@ -330,7 +330,7 @@ static void stripe_status(struct dm_target *ti, status_type_t type,
43735 DMEMIT("%d ", sc->stripes);
43736 for (i = 0; i < sc->stripes; i++) {
43737 DMEMIT("%s ", sc->stripe[i].dev->name);
43738 - buffer[i] = atomic_read(&(sc->stripe[i].error_count)) ?
43739 + buffer[i] = atomic_read_unchecked(&(sc->stripe[i].error_count)) ?
43740 'D' : 'A';
43741 }
43742 buffer[i] = '\0';
43743 @@ -375,8 +375,8 @@ static int stripe_end_io(struct dm_target *ti, struct bio *bio, int error)
43744 */
43745 for (i = 0; i < sc->stripes; i++)
43746 if (!strcmp(sc->stripe[i].dev->name, major_minor)) {
43747 - atomic_inc(&(sc->stripe[i].error_count));
43748 - if (atomic_read(&(sc->stripe[i].error_count)) <
43749 + atomic_inc_unchecked(&(sc->stripe[i].error_count));
43750 + if (atomic_read_unchecked(&(sc->stripe[i].error_count)) <
43751 DM_IO_ERROR_THRESHOLD)
43752 schedule_work(&sc->trigger_event);
43753 }
43754 diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c
43755 index 50601ec..6d3b9dc 100644
43756 --- a/drivers/md/dm-table.c
43757 +++ b/drivers/md/dm-table.c
43758 @@ -274,7 +274,7 @@ static struct dm_dev_internal *find_device(struct list_head *l, dev_t dev)
43759 static int open_dev(struct dm_dev_internal *d, dev_t dev,
43760 struct mapped_device *md)
43761 {
43762 - static char *_claim_ptr = "I belong to device-mapper";
43763 + static char _claim_ptr[] = "I belong to device-mapper";
43764 struct block_device *bdev;
43765
43766 int r;
43767 @@ -342,7 +342,7 @@ static int device_area_is_invalid(struct dm_target *ti, struct dm_dev *dev,
43768 if (!dev_size)
43769 return 0;
43770
43771 - if ((start >= dev_size) || (start + len > dev_size)) {
43772 + if ((start >= dev_size) || (len > dev_size - start)) {
43773 DMWARN("%s: %s too small for target: "
43774 "start=%llu, len=%llu, dev_size=%llu",
43775 dm_device_name(ti->table->md), bdevname(bdev, b),
43776 diff --git a/drivers/md/dm-thin-metadata.c b/drivers/md/dm-thin-metadata.c
43777 index b086a94..74cb67e 100644
43778 --- a/drivers/md/dm-thin-metadata.c
43779 +++ b/drivers/md/dm-thin-metadata.c
43780 @@ -404,7 +404,7 @@ static void __setup_btree_details(struct dm_pool_metadata *pmd)
43781 {
43782 pmd->info.tm = pmd->tm;
43783 pmd->info.levels = 2;
43784 - pmd->info.value_type.context = pmd->data_sm;
43785 + pmd->info.value_type.context = (dm_space_map_no_const *)pmd->data_sm;
43786 pmd->info.value_type.size = sizeof(__le64);
43787 pmd->info.value_type.inc = data_block_inc;
43788 pmd->info.value_type.dec = data_block_dec;
43789 @@ -423,7 +423,7 @@ static void __setup_btree_details(struct dm_pool_metadata *pmd)
43790
43791 pmd->bl_info.tm = pmd->tm;
43792 pmd->bl_info.levels = 1;
43793 - pmd->bl_info.value_type.context = pmd->data_sm;
43794 + pmd->bl_info.value_type.context = (dm_space_map_no_const *)pmd->data_sm;
43795 pmd->bl_info.value_type.size = sizeof(__le64);
43796 pmd->bl_info.value_type.inc = data_block_inc;
43797 pmd->bl_info.value_type.dec = data_block_dec;
43798 diff --git a/drivers/md/dm.c b/drivers/md/dm.c
43799 index 455e649..1f214be 100644
43800 --- a/drivers/md/dm.c
43801 +++ b/drivers/md/dm.c
43802 @@ -178,9 +178,9 @@ struct mapped_device {
43803 /*
43804 * Event handling.
43805 */
43806 - atomic_t event_nr;
43807 + atomic_unchecked_t event_nr;
43808 wait_queue_head_t eventq;
43809 - atomic_t uevent_seq;
43810 + atomic_unchecked_t uevent_seq;
43811 struct list_head uevent_list;
43812 spinlock_t uevent_lock; /* Protect access to uevent_list */
43813
43814 @@ -1884,8 +1884,8 @@ static struct mapped_device *alloc_dev(int minor)
43815 spin_lock_init(&md->deferred_lock);
43816 atomic_set(&md->holders, 1);
43817 atomic_set(&md->open_count, 0);
43818 - atomic_set(&md->event_nr, 0);
43819 - atomic_set(&md->uevent_seq, 0);
43820 + atomic_set_unchecked(&md->event_nr, 0);
43821 + atomic_set_unchecked(&md->uevent_seq, 0);
43822 INIT_LIST_HEAD(&md->uevent_list);
43823 spin_lock_init(&md->uevent_lock);
43824
43825 @@ -2039,7 +2039,7 @@ static void event_callback(void *context)
43826
43827 dm_send_uevents(&uevents, &disk_to_dev(md->disk)->kobj);
43828
43829 - atomic_inc(&md->event_nr);
43830 + atomic_inc_unchecked(&md->event_nr);
43831 wake_up(&md->eventq);
43832 }
43833
43834 @@ -2732,18 +2732,18 @@ int dm_kobject_uevent(struct mapped_device *md, enum kobject_action action,
43835
43836 uint32_t dm_next_uevent_seq(struct mapped_device *md)
43837 {
43838 - return atomic_add_return(1, &md->uevent_seq);
43839 + return atomic_add_return_unchecked(1, &md->uevent_seq);
43840 }
43841
43842 uint32_t dm_get_event_nr(struct mapped_device *md)
43843 {
43844 - return atomic_read(&md->event_nr);
43845 + return atomic_read_unchecked(&md->event_nr);
43846 }
43847
43848 int dm_wait_event(struct mapped_device *md, int event_nr)
43849 {
43850 return wait_event_interruptible(md->eventq,
43851 - (event_nr != atomic_read(&md->event_nr)));
43852 + (event_nr != atomic_read_unchecked(&md->event_nr)));
43853 }
43854
43855 void dm_uevent_add(struct mapped_device *md, struct list_head *elist)
43856 diff --git a/drivers/md/md.c b/drivers/md/md.c
43857 index 2382cfc..0d7e551 100644
43858 --- a/drivers/md/md.c
43859 +++ b/drivers/md/md.c
43860 @@ -194,10 +194,10 @@ EXPORT_SYMBOL_GPL(bio_clone_mddev);
43861 * start build, activate spare
43862 */
43863 static DECLARE_WAIT_QUEUE_HEAD(md_event_waiters);
43864 -static atomic_t md_event_count;
43865 +static atomic_unchecked_t md_event_count;
43866 void md_new_event(struct mddev *mddev)
43867 {
43868 - atomic_inc(&md_event_count);
43869 + atomic_inc_unchecked(&md_event_count);
43870 wake_up(&md_event_waiters);
43871 }
43872 EXPORT_SYMBOL_GPL(md_new_event);
43873 @@ -207,7 +207,7 @@ EXPORT_SYMBOL_GPL(md_new_event);
43874 */
43875 static void md_new_event_inintr(struct mddev *mddev)
43876 {
43877 - atomic_inc(&md_event_count);
43878 + atomic_inc_unchecked(&md_event_count);
43879 wake_up(&md_event_waiters);
43880 }
43881
43882 @@ -1462,7 +1462,7 @@ static int super_1_load(struct md_rdev *rdev, struct md_rdev *refdev, int minor_
43883 if ((le32_to_cpu(sb->feature_map) & MD_FEATURE_RESHAPE_ACTIVE) &&
43884 (le32_to_cpu(sb->feature_map) & MD_FEATURE_NEW_OFFSET))
43885 rdev->new_data_offset += (s32)le32_to_cpu(sb->new_offset);
43886 - atomic_set(&rdev->corrected_errors, le32_to_cpu(sb->cnt_corrected_read));
43887 + atomic_set_unchecked(&rdev->corrected_errors, le32_to_cpu(sb->cnt_corrected_read));
43888
43889 rdev->sb_size = le32_to_cpu(sb->max_dev) * 2 + 256;
43890 bmask = queue_logical_block_size(rdev->bdev->bd_disk->queue)-1;
43891 @@ -1713,7 +1713,7 @@ static void super_1_sync(struct mddev *mddev, struct md_rdev *rdev)
43892 else
43893 sb->resync_offset = cpu_to_le64(0);
43894
43895 - sb->cnt_corrected_read = cpu_to_le32(atomic_read(&rdev->corrected_errors));
43896 + sb->cnt_corrected_read = cpu_to_le32(atomic_read_unchecked(&rdev->corrected_errors));
43897
43898 sb->raid_disks = cpu_to_le32(mddev->raid_disks);
43899 sb->size = cpu_to_le64(mddev->dev_sectors);
43900 @@ -2725,7 +2725,7 @@ __ATTR(state, S_IRUGO|S_IWUSR, state_show, state_store);
43901 static ssize_t
43902 errors_show(struct md_rdev *rdev, char *page)
43903 {
43904 - return sprintf(page, "%d\n", atomic_read(&rdev->corrected_errors));
43905 + return sprintf(page, "%d\n", atomic_read_unchecked(&rdev->corrected_errors));
43906 }
43907
43908 static ssize_t
43909 @@ -2734,7 +2734,7 @@ errors_store(struct md_rdev *rdev, const char *buf, size_t len)
43910 char *e;
43911 unsigned long n = simple_strtoul(buf, &e, 10);
43912 if (*buf && (*e == 0 || *e == '\n')) {
43913 - atomic_set(&rdev->corrected_errors, n);
43914 + atomic_set_unchecked(&rdev->corrected_errors, n);
43915 return len;
43916 }
43917 return -EINVAL;
43918 @@ -3183,8 +3183,8 @@ int md_rdev_init(struct md_rdev *rdev)
43919 rdev->sb_loaded = 0;
43920 rdev->bb_page = NULL;
43921 atomic_set(&rdev->nr_pending, 0);
43922 - atomic_set(&rdev->read_errors, 0);
43923 - atomic_set(&rdev->corrected_errors, 0);
43924 + atomic_set_unchecked(&rdev->read_errors, 0);
43925 + atomic_set_unchecked(&rdev->corrected_errors, 0);
43926
43927 INIT_LIST_HEAD(&rdev->same_set);
43928 init_waitqueue_head(&rdev->blocked_wait);
43929 @@ -7058,7 +7058,7 @@ static int md_seq_show(struct seq_file *seq, void *v)
43930
43931 spin_unlock(&pers_lock);
43932 seq_printf(seq, "\n");
43933 - seq->poll_event = atomic_read(&md_event_count);
43934 + seq->poll_event = atomic_read_unchecked(&md_event_count);
43935 return 0;
43936 }
43937 if (v == (void*)2) {
43938 @@ -7161,7 +7161,7 @@ static int md_seq_open(struct inode *inode, struct file *file)
43939 return error;
43940
43941 seq = file->private_data;
43942 - seq->poll_event = atomic_read(&md_event_count);
43943 + seq->poll_event = atomic_read_unchecked(&md_event_count);
43944 return error;
43945 }
43946
43947 @@ -7178,7 +7178,7 @@ static unsigned int mdstat_poll(struct file *filp, poll_table *wait)
43948 /* always allow read */
43949 mask = POLLIN | POLLRDNORM;
43950
43951 - if (seq->poll_event != atomic_read(&md_event_count))
43952 + if (seq->poll_event != atomic_read_unchecked(&md_event_count))
43953 mask |= POLLERR | POLLPRI;
43954 return mask;
43955 }
43956 @@ -7222,7 +7222,7 @@ static int is_mddev_idle(struct mddev *mddev, int init)
43957 struct gendisk *disk = rdev->bdev->bd_contains->bd_disk;
43958 curr_events = (int)part_stat_read(&disk->part0, sectors[0]) +
43959 (int)part_stat_read(&disk->part0, sectors[1]) -
43960 - atomic_read(&disk->sync_io);
43961 + atomic_read_unchecked(&disk->sync_io);
43962 /* sync IO will cause sync_io to increase before the disk_stats
43963 * as sync_io is counted when a request starts, and
43964 * disk_stats is counted when it completes.
43965 diff --git a/drivers/md/md.h b/drivers/md/md.h
43966 index a49d991..3582bb7 100644
43967 --- a/drivers/md/md.h
43968 +++ b/drivers/md/md.h
43969 @@ -94,13 +94,13 @@ struct md_rdev {
43970 * only maintained for arrays that
43971 * support hot removal
43972 */
43973 - atomic_t read_errors; /* number of consecutive read errors that
43974 + atomic_unchecked_t read_errors; /* number of consecutive read errors that
43975 * we have tried to ignore.
43976 */
43977 struct timespec last_read_error; /* monotonic time since our
43978 * last read error
43979 */
43980 - atomic_t corrected_errors; /* number of corrected read errors,
43981 + atomic_unchecked_t corrected_errors; /* number of corrected read errors,
43982 * for reporting to userspace and storing
43983 * in superblock.
43984 */
43985 @@ -449,7 +449,7 @@ static inline void rdev_dec_pending(struct md_rdev *rdev, struct mddev *mddev)
43986
43987 static inline void md_sync_acct(struct block_device *bdev, unsigned long nr_sectors)
43988 {
43989 - atomic_add(nr_sectors, &bdev->bd_contains->bd_disk->sync_io);
43990 + atomic_add_unchecked(nr_sectors, &bdev->bd_contains->bd_disk->sync_io);
43991 }
43992
43993 struct md_personality
43994 diff --git a/drivers/md/persistent-data/dm-space-map-metadata.c b/drivers/md/persistent-data/dm-space-map-metadata.c
43995 index 786b689..ea8c956 100644
43996 --- a/drivers/md/persistent-data/dm-space-map-metadata.c
43997 +++ b/drivers/md/persistent-data/dm-space-map-metadata.c
43998 @@ -679,7 +679,7 @@ static int sm_metadata_extend(struct dm_space_map *sm, dm_block_t extra_blocks)
43999 * Flick into a mode where all blocks get allocated in the new area.
44000 */
44001 smm->begin = old_len;
44002 - memcpy(sm, &bootstrap_ops, sizeof(*sm));
44003 + memcpy((void *)sm, &bootstrap_ops, sizeof(*sm));
44004
44005 /*
44006 * Extend.
44007 @@ -710,7 +710,7 @@ out:
44008 /*
44009 * Switch back to normal behaviour.
44010 */
44011 - memcpy(sm, &ops, sizeof(*sm));
44012 + memcpy((void *)sm, &ops, sizeof(*sm));
44013 return r;
44014 }
44015
44016 diff --git a/drivers/md/persistent-data/dm-space-map.h b/drivers/md/persistent-data/dm-space-map.h
44017 index 3e6d115..ffecdeb 100644
44018 --- a/drivers/md/persistent-data/dm-space-map.h
44019 +++ b/drivers/md/persistent-data/dm-space-map.h
44020 @@ -71,6 +71,7 @@ struct dm_space_map {
44021 dm_sm_threshold_fn fn,
44022 void *context);
44023 };
44024 +typedef struct dm_space_map __no_const dm_space_map_no_const;
44025
44026 /*----------------------------------------------------------------*/
44027
44028 diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
44029 index 56e24c0..e1c8e1f 100644
44030 --- a/drivers/md/raid1.c
44031 +++ b/drivers/md/raid1.c
44032 @@ -1931,7 +1931,7 @@ static int fix_sync_read_error(struct r1bio *r1_bio)
44033 if (r1_sync_page_io(rdev, sect, s,
44034 bio->bi_io_vec[idx].bv_page,
44035 READ) != 0)
44036 - atomic_add(s, &rdev->corrected_errors);
44037 + atomic_add_unchecked(s, &rdev->corrected_errors);
44038 }
44039 sectors -= s;
44040 sect += s;
44041 @@ -2165,7 +2165,7 @@ static void fix_read_error(struct r1conf *conf, int read_disk,
44042 test_bit(In_sync, &rdev->flags)) {
44043 if (r1_sync_page_io(rdev, sect, s,
44044 conf->tmppage, READ)) {
44045 - atomic_add(s, &rdev->corrected_errors);
44046 + atomic_add_unchecked(s, &rdev->corrected_errors);
44047 printk(KERN_INFO
44048 "md/raid1:%s: read error corrected "
44049 "(%d sectors at %llu on %s)\n",
44050 diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
44051 index cb882aa..9bd076e 100644
44052 --- a/drivers/md/raid10.c
44053 +++ b/drivers/md/raid10.c
44054 @@ -1949,7 +1949,7 @@ static void end_sync_read(struct bio *bio, int error)
44055 /* The write handler will notice the lack of
44056 * R10BIO_Uptodate and record any errors etc
44057 */
44058 - atomic_add(r10_bio->sectors,
44059 + atomic_add_unchecked(r10_bio->sectors,
44060 &conf->mirrors[d].rdev->corrected_errors);
44061
44062 /* for reconstruct, we always reschedule after a read.
44063 @@ -2307,7 +2307,7 @@ static void check_decay_read_errors(struct mddev *mddev, struct md_rdev *rdev)
44064 {
44065 struct timespec cur_time_mon;
44066 unsigned long hours_since_last;
44067 - unsigned int read_errors = atomic_read(&rdev->read_errors);
44068 + unsigned int read_errors = atomic_read_unchecked(&rdev->read_errors);
44069
44070 ktime_get_ts(&cur_time_mon);
44071
44072 @@ -2329,9 +2329,9 @@ static void check_decay_read_errors(struct mddev *mddev, struct md_rdev *rdev)
44073 * overflowing the shift of read_errors by hours_since_last.
44074 */
44075 if (hours_since_last >= 8 * sizeof(read_errors))
44076 - atomic_set(&rdev->read_errors, 0);
44077 + atomic_set_unchecked(&rdev->read_errors, 0);
44078 else
44079 - atomic_set(&rdev->read_errors, read_errors >> hours_since_last);
44080 + atomic_set_unchecked(&rdev->read_errors, read_errors >> hours_since_last);
44081 }
44082
44083 static int r10_sync_page_io(struct md_rdev *rdev, sector_t sector,
44084 @@ -2385,8 +2385,8 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
44085 return;
44086
44087 check_decay_read_errors(mddev, rdev);
44088 - atomic_inc(&rdev->read_errors);
44089 - if (atomic_read(&rdev->read_errors) > max_read_errors) {
44090 + atomic_inc_unchecked(&rdev->read_errors);
44091 + if (atomic_read_unchecked(&rdev->read_errors) > max_read_errors) {
44092 char b[BDEVNAME_SIZE];
44093 bdevname(rdev->bdev, b);
44094
44095 @@ -2394,7 +2394,7 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
44096 "md/raid10:%s: %s: Raid device exceeded "
44097 "read_error threshold [cur %d:max %d]\n",
44098 mdname(mddev), b,
44099 - atomic_read(&rdev->read_errors), max_read_errors);
44100 + atomic_read_unchecked(&rdev->read_errors), max_read_errors);
44101 printk(KERN_NOTICE
44102 "md/raid10:%s: %s: Failing raid device\n",
44103 mdname(mddev), b);
44104 @@ -2549,7 +2549,7 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
44105 sect +
44106 choose_data_offset(r10_bio, rdev)),
44107 bdevname(rdev->bdev, b));
44108 - atomic_add(s, &rdev->corrected_errors);
44109 + atomic_add_unchecked(s, &rdev->corrected_errors);
44110 }
44111
44112 rdev_dec_pending(rdev, mddev);
44113 diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
44114 index ad1b9be..b417412 100644
44115 --- a/drivers/md/raid5.c
44116 +++ b/drivers/md/raid5.c
44117 @@ -1702,6 +1702,10 @@ static int grow_one_stripe(struct r5conf *conf, int hash)
44118 return 1;
44119 }
44120
44121 +#ifdef CONFIG_GRKERNSEC_HIDESYM
44122 +static atomic_unchecked_t raid5_cache_id = ATOMIC_INIT(0);
44123 +#endif
44124 +
44125 static int grow_stripes(struct r5conf *conf, int num)
44126 {
44127 struct kmem_cache *sc;
44128 @@ -1713,7 +1717,11 @@ static int grow_stripes(struct r5conf *conf, int num)
44129 "raid%d-%s", conf->level, mdname(conf->mddev));
44130 else
44131 sprintf(conf->cache_name[0],
44132 +#ifdef CONFIG_GRKERNSEC_HIDESYM
44133 + "raid%d-%08lx", conf->level, atomic_inc_return_unchecked(&raid5_cache_id));
44134 +#else
44135 "raid%d-%p", conf->level, conf->mddev);
44136 +#endif
44137 sprintf(conf->cache_name[1], "%s-alt", conf->cache_name[0]);
44138
44139 conf->active_name = 0;
44140 @@ -1986,21 +1994,21 @@ static void raid5_end_read_request(struct bio * bi, int error)
44141 mdname(conf->mddev), STRIPE_SECTORS,
44142 (unsigned long long)s,
44143 bdevname(rdev->bdev, b));
44144 - atomic_add(STRIPE_SECTORS, &rdev->corrected_errors);
44145 + atomic_add_unchecked(STRIPE_SECTORS, &rdev->corrected_errors);
44146 clear_bit(R5_ReadError, &sh->dev[i].flags);
44147 clear_bit(R5_ReWrite, &sh->dev[i].flags);
44148 } else if (test_bit(R5_ReadNoMerge, &sh->dev[i].flags))
44149 clear_bit(R5_ReadNoMerge, &sh->dev[i].flags);
44150
44151 - if (atomic_read(&rdev->read_errors))
44152 - atomic_set(&rdev->read_errors, 0);
44153 + if (atomic_read_unchecked(&rdev->read_errors))
44154 + atomic_set_unchecked(&rdev->read_errors, 0);
44155 } else {
44156 const char *bdn = bdevname(rdev->bdev, b);
44157 int retry = 0;
44158 int set_bad = 0;
44159
44160 clear_bit(R5_UPTODATE, &sh->dev[i].flags);
44161 - atomic_inc(&rdev->read_errors);
44162 + atomic_inc_unchecked(&rdev->read_errors);
44163 if (test_bit(R5_ReadRepl, &sh->dev[i].flags))
44164 printk_ratelimited(
44165 KERN_WARNING
44166 @@ -2028,7 +2036,7 @@ static void raid5_end_read_request(struct bio * bi, int error)
44167 mdname(conf->mddev),
44168 (unsigned long long)s,
44169 bdn);
44170 - } else if (atomic_read(&rdev->read_errors)
44171 + } else if (atomic_read_unchecked(&rdev->read_errors)
44172 > conf->max_nr_stripes)
44173 printk(KERN_WARNING
44174 "md/raid:%s: Too many read errors, failing device %s.\n",
44175 diff --git a/drivers/media/dvb-core/dvbdev.c b/drivers/media/dvb-core/dvbdev.c
44176 index 983db75..ef9248c 100644
44177 --- a/drivers/media/dvb-core/dvbdev.c
44178 +++ b/drivers/media/dvb-core/dvbdev.c
44179 @@ -185,7 +185,7 @@ int dvb_register_device(struct dvb_adapter *adap, struct dvb_device **pdvbdev,
44180 const struct dvb_device *template, void *priv, int type)
44181 {
44182 struct dvb_device *dvbdev;
44183 - struct file_operations *dvbdevfops;
44184 + file_operations_no_const *dvbdevfops;
44185 struct device *clsdev;
44186 int minor;
44187 int id;
44188 diff --git a/drivers/media/dvb-frontends/af9033.h b/drivers/media/dvb-frontends/af9033.h
44189 index 539f4db..cdd403b 100644
44190 --- a/drivers/media/dvb-frontends/af9033.h
44191 +++ b/drivers/media/dvb-frontends/af9033.h
44192 @@ -82,7 +82,7 @@ struct af9033_ops {
44193 int (*pid_filter_ctrl)(struct dvb_frontend *fe, int onoff);
44194 int (*pid_filter)(struct dvb_frontend *fe, int index, u16 pid,
44195 int onoff);
44196 -};
44197 +} __no_const;
44198
44199
44200 #if IS_ENABLED(CONFIG_DVB_AF9033)
44201 diff --git a/drivers/media/dvb-frontends/dib3000.h b/drivers/media/dvb-frontends/dib3000.h
44202 index 9b6c3bb..baeb5c7 100644
44203 --- a/drivers/media/dvb-frontends/dib3000.h
44204 +++ b/drivers/media/dvb-frontends/dib3000.h
44205 @@ -39,7 +39,7 @@ struct dib_fe_xfer_ops
44206 int (*fifo_ctrl)(struct dvb_frontend *fe, int onoff);
44207 int (*pid_ctrl)(struct dvb_frontend *fe, int index, int pid, int onoff);
44208 int (*tuner_pass_ctrl)(struct dvb_frontend *fe, int onoff, u8 pll_ctrl);
44209 -};
44210 +} __no_const;
44211
44212 #if IS_ENABLED(CONFIG_DVB_DIB3000MB)
44213 extern struct dvb_frontend* dib3000mb_attach(const struct dib3000_config* config,
44214 diff --git a/drivers/media/pci/cx88/cx88-video.c b/drivers/media/pci/cx88/cx88-video.c
44215 index ed8cb90..5ef7f79 100644
44216 --- a/drivers/media/pci/cx88/cx88-video.c
44217 +++ b/drivers/media/pci/cx88/cx88-video.c
44218 @@ -50,9 +50,9 @@ MODULE_VERSION(CX88_VERSION);
44219
44220 /* ------------------------------------------------------------------ */
44221
44222 -static unsigned int video_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
44223 -static unsigned int vbi_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
44224 -static unsigned int radio_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
44225 +static int video_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
44226 +static int vbi_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
44227 +static int radio_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
44228
44229 module_param_array(video_nr, int, NULL, 0444);
44230 module_param_array(vbi_nr, int, NULL, 0444);
44231 diff --git a/drivers/media/pci/ivtv/ivtv-driver.c b/drivers/media/pci/ivtv/ivtv-driver.c
44232 index 802642d..5534900 100644
44233 --- a/drivers/media/pci/ivtv/ivtv-driver.c
44234 +++ b/drivers/media/pci/ivtv/ivtv-driver.c
44235 @@ -83,7 +83,7 @@ static struct pci_device_id ivtv_pci_tbl[] = {
44236 MODULE_DEVICE_TABLE(pci,ivtv_pci_tbl);
44237
44238 /* ivtv instance counter */
44239 -static atomic_t ivtv_instance = ATOMIC_INIT(0);
44240 +static atomic_unchecked_t ivtv_instance = ATOMIC_INIT(0);
44241
44242 /* Parameter declarations */
44243 static int cardtype[IVTV_MAX_CARDS];
44244 diff --git a/drivers/media/platform/omap/omap_vout.c b/drivers/media/platform/omap/omap_vout.c
44245 index 9a726ea..f5e9b52 100644
44246 --- a/drivers/media/platform/omap/omap_vout.c
44247 +++ b/drivers/media/platform/omap/omap_vout.c
44248 @@ -63,7 +63,6 @@ enum omap_vout_channels {
44249 OMAP_VIDEO2,
44250 };
44251
44252 -static struct videobuf_queue_ops video_vbq_ops;
44253 /* Variables configurable through module params*/
44254 static u32 video1_numbuffers = 3;
44255 static u32 video2_numbuffers = 3;
44256 @@ -1015,6 +1014,12 @@ static int omap_vout_open(struct file *file)
44257 {
44258 struct videobuf_queue *q;
44259 struct omap_vout_device *vout = NULL;
44260 + static struct videobuf_queue_ops video_vbq_ops = {
44261 + .buf_setup = omap_vout_buffer_setup,
44262 + .buf_prepare = omap_vout_buffer_prepare,
44263 + .buf_release = omap_vout_buffer_release,
44264 + .buf_queue = omap_vout_buffer_queue,
44265 + };
44266
44267 vout = video_drvdata(file);
44268 v4l2_dbg(1, debug, &vout->vid_dev->v4l2_dev, "Entering %s\n", __func__);
44269 @@ -1032,10 +1037,6 @@ static int omap_vout_open(struct file *file)
44270 vout->type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
44271
44272 q = &vout->vbq;
44273 - video_vbq_ops.buf_setup = omap_vout_buffer_setup;
44274 - video_vbq_ops.buf_prepare = omap_vout_buffer_prepare;
44275 - video_vbq_ops.buf_release = omap_vout_buffer_release;
44276 - video_vbq_ops.buf_queue = omap_vout_buffer_queue;
44277 spin_lock_init(&vout->vbq_lock);
44278
44279 videobuf_queue_dma_contig_init(q, &video_vbq_ops, q->dev,
44280 diff --git a/drivers/media/platform/s5p-tv/mixer.h b/drivers/media/platform/s5p-tv/mixer.h
44281 index fb2acc5..a2fcbdc4 100644
44282 --- a/drivers/media/platform/s5p-tv/mixer.h
44283 +++ b/drivers/media/platform/s5p-tv/mixer.h
44284 @@ -156,7 +156,7 @@ struct mxr_layer {
44285 /** layer index (unique identifier) */
44286 int idx;
44287 /** callbacks for layer methods */
44288 - struct mxr_layer_ops ops;
44289 + struct mxr_layer_ops *ops;
44290 /** format array */
44291 const struct mxr_format **fmt_array;
44292 /** size of format array */
44293 diff --git a/drivers/media/platform/s5p-tv/mixer_grp_layer.c b/drivers/media/platform/s5p-tv/mixer_grp_layer.c
44294 index 74344c7..a39e70e 100644
44295 --- a/drivers/media/platform/s5p-tv/mixer_grp_layer.c
44296 +++ b/drivers/media/platform/s5p-tv/mixer_grp_layer.c
44297 @@ -235,7 +235,7 @@ struct mxr_layer *mxr_graph_layer_create(struct mxr_device *mdev, int idx)
44298 {
44299 struct mxr_layer *layer;
44300 int ret;
44301 - struct mxr_layer_ops ops = {
44302 + static struct mxr_layer_ops ops = {
44303 .release = mxr_graph_layer_release,
44304 .buffer_set = mxr_graph_buffer_set,
44305 .stream_set = mxr_graph_stream_set,
44306 diff --git a/drivers/media/platform/s5p-tv/mixer_reg.c b/drivers/media/platform/s5p-tv/mixer_reg.c
44307 index b713403..53cb5ad 100644
44308 --- a/drivers/media/platform/s5p-tv/mixer_reg.c
44309 +++ b/drivers/media/platform/s5p-tv/mixer_reg.c
44310 @@ -276,7 +276,7 @@ static void mxr_irq_layer_handle(struct mxr_layer *layer)
44311 layer->update_buf = next;
44312 }
44313
44314 - layer->ops.buffer_set(layer, layer->update_buf);
44315 + layer->ops->buffer_set(layer, layer->update_buf);
44316
44317 if (done && done != layer->shadow_buf)
44318 vb2_buffer_done(&done->vb, VB2_BUF_STATE_DONE);
44319 diff --git a/drivers/media/platform/s5p-tv/mixer_video.c b/drivers/media/platform/s5p-tv/mixer_video.c
44320 index a1ce55f..4a3c4d9 100644
44321 --- a/drivers/media/platform/s5p-tv/mixer_video.c
44322 +++ b/drivers/media/platform/s5p-tv/mixer_video.c
44323 @@ -210,7 +210,7 @@ static void mxr_layer_default_geo(struct mxr_layer *layer)
44324 layer->geo.src.height = layer->geo.src.full_height;
44325
44326 mxr_geometry_dump(mdev, &layer->geo);
44327 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
44328 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
44329 mxr_geometry_dump(mdev, &layer->geo);
44330 }
44331
44332 @@ -228,7 +228,7 @@ static void mxr_layer_update_output(struct mxr_layer *layer)
44333 layer->geo.dst.full_width = mbus_fmt.width;
44334 layer->geo.dst.full_height = mbus_fmt.height;
44335 layer->geo.dst.field = mbus_fmt.field;
44336 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
44337 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
44338
44339 mxr_geometry_dump(mdev, &layer->geo);
44340 }
44341 @@ -334,7 +334,7 @@ static int mxr_s_fmt(struct file *file, void *priv,
44342 /* set source size to highest accepted value */
44343 geo->src.full_width = max(geo->dst.full_width, pix->width);
44344 geo->src.full_height = max(geo->dst.full_height, pix->height);
44345 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
44346 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
44347 mxr_geometry_dump(mdev, &layer->geo);
44348 /* set cropping to total visible screen */
44349 geo->src.width = pix->width;
44350 @@ -342,12 +342,12 @@ static int mxr_s_fmt(struct file *file, void *priv,
44351 geo->src.x_offset = 0;
44352 geo->src.y_offset = 0;
44353 /* assure consistency of geometry */
44354 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_CROP, MXR_NO_OFFSET);
44355 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_CROP, MXR_NO_OFFSET);
44356 mxr_geometry_dump(mdev, &layer->geo);
44357 /* set full size to lowest possible value */
44358 geo->src.full_width = 0;
44359 geo->src.full_height = 0;
44360 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
44361 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
44362 mxr_geometry_dump(mdev, &layer->geo);
44363
44364 /* returning results */
44365 @@ -474,7 +474,7 @@ static int mxr_s_selection(struct file *file, void *fh,
44366 target->width = s->r.width;
44367 target->height = s->r.height;
44368
44369 - layer->ops.fix_geometry(layer, stage, s->flags);
44370 + layer->ops->fix_geometry(layer, stage, s->flags);
44371
44372 /* retrieve update selection rectangle */
44373 res.left = target->x_offset;
44374 @@ -950,13 +950,13 @@ static int start_streaming(struct vb2_queue *vq, unsigned int count)
44375 mxr_output_get(mdev);
44376
44377 mxr_layer_update_output(layer);
44378 - layer->ops.format_set(layer);
44379 + layer->ops->format_set(layer);
44380 /* enabling layer in hardware */
44381 spin_lock_irqsave(&layer->enq_slock, flags);
44382 layer->state = MXR_LAYER_STREAMING;
44383 spin_unlock_irqrestore(&layer->enq_slock, flags);
44384
44385 - layer->ops.stream_set(layer, MXR_ENABLE);
44386 + layer->ops->stream_set(layer, MXR_ENABLE);
44387 mxr_streamer_get(mdev);
44388
44389 return 0;
44390 @@ -1026,7 +1026,7 @@ static int stop_streaming(struct vb2_queue *vq)
44391 spin_unlock_irqrestore(&layer->enq_slock, flags);
44392
44393 /* disabling layer in hardware */
44394 - layer->ops.stream_set(layer, MXR_DISABLE);
44395 + layer->ops->stream_set(layer, MXR_DISABLE);
44396 /* remove one streamer */
44397 mxr_streamer_put(mdev);
44398 /* allow changes in output configuration */
44399 @@ -1065,8 +1065,8 @@ void mxr_base_layer_unregister(struct mxr_layer *layer)
44400
44401 void mxr_layer_release(struct mxr_layer *layer)
44402 {
44403 - if (layer->ops.release)
44404 - layer->ops.release(layer);
44405 + if (layer->ops->release)
44406 + layer->ops->release(layer);
44407 }
44408
44409 void mxr_base_layer_release(struct mxr_layer *layer)
44410 @@ -1092,7 +1092,7 @@ struct mxr_layer *mxr_base_layer_create(struct mxr_device *mdev,
44411
44412 layer->mdev = mdev;
44413 layer->idx = idx;
44414 - layer->ops = *ops;
44415 + layer->ops = ops;
44416
44417 spin_lock_init(&layer->enq_slock);
44418 INIT_LIST_HEAD(&layer->enq_list);
44419 diff --git a/drivers/media/platform/s5p-tv/mixer_vp_layer.c b/drivers/media/platform/s5p-tv/mixer_vp_layer.c
44420 index c9388c4..ce71ece 100644
44421 --- a/drivers/media/platform/s5p-tv/mixer_vp_layer.c
44422 +++ b/drivers/media/platform/s5p-tv/mixer_vp_layer.c
44423 @@ -206,7 +206,7 @@ struct mxr_layer *mxr_vp_layer_create(struct mxr_device *mdev, int idx)
44424 {
44425 struct mxr_layer *layer;
44426 int ret;
44427 - struct mxr_layer_ops ops = {
44428 + static struct mxr_layer_ops ops = {
44429 .release = mxr_vp_layer_release,
44430 .buffer_set = mxr_vp_buffer_set,
44431 .stream_set = mxr_vp_stream_set,
44432 diff --git a/drivers/media/platform/vivi.c b/drivers/media/platform/vivi.c
44433 index 3890f4f..b5c7511 100644
44434 --- a/drivers/media/platform/vivi.c
44435 +++ b/drivers/media/platform/vivi.c
44436 @@ -58,8 +58,8 @@ MODULE_AUTHOR("Mauro Carvalho Chehab, Ted Walther and John Sokol");
44437 MODULE_LICENSE("Dual BSD/GPL");
44438 MODULE_VERSION(VIVI_VERSION);
44439
44440 -static unsigned video_nr = -1;
44441 -module_param(video_nr, uint, 0644);
44442 +static int video_nr = -1;
44443 +module_param(video_nr, int, 0644);
44444 MODULE_PARM_DESC(video_nr, "videoX start number, -1 is autodetect");
44445
44446 static unsigned n_devs = 1;
44447 diff --git a/drivers/media/radio/radio-cadet.c b/drivers/media/radio/radio-cadet.c
44448 index d719e59..63f3470 100644
44449 --- a/drivers/media/radio/radio-cadet.c
44450 +++ b/drivers/media/radio/radio-cadet.c
44451 @@ -333,6 +333,8 @@ static ssize_t cadet_read(struct file *file, char __user *data, size_t count, lo
44452 unsigned char readbuf[RDS_BUFFER];
44453 int i = 0;
44454
44455 + if (count > RDS_BUFFER)
44456 + return -EFAULT;
44457 mutex_lock(&dev->lock);
44458 if (dev->rdsstat == 0)
44459 cadet_start_rds(dev);
44460 @@ -349,8 +351,9 @@ static ssize_t cadet_read(struct file *file, char __user *data, size_t count, lo
44461 readbuf[i++] = dev->rdsbuf[dev->rdsout++];
44462 mutex_unlock(&dev->lock);
44463
44464 - if (i && copy_to_user(data, readbuf, i))
44465 - return -EFAULT;
44466 + if (i > sizeof(readbuf) || (i && copy_to_user(data, readbuf, i)))
44467 + i = -EFAULT;
44468 +
44469 return i;
44470 }
44471
44472 diff --git a/drivers/media/radio/radio-maxiradio.c b/drivers/media/radio/radio-maxiradio.c
44473 index 5236035..c622c74 100644
44474 --- a/drivers/media/radio/radio-maxiradio.c
44475 +++ b/drivers/media/radio/radio-maxiradio.c
44476 @@ -61,7 +61,7 @@ MODULE_PARM_DESC(radio_nr, "Radio device number");
44477 /* TEA5757 pin mappings */
44478 static const int clk = 1, data = 2, wren = 4, mo_st = 8, power = 16;
44479
44480 -static atomic_t maxiradio_instance = ATOMIC_INIT(0);
44481 +static atomic_unchecked_t maxiradio_instance = ATOMIC_INIT(0);
44482
44483 #define PCI_VENDOR_ID_GUILLEMOT 0x5046
44484 #define PCI_DEVICE_ID_GUILLEMOT_MAXIRADIO 0x1001
44485 diff --git a/drivers/media/radio/radio-shark.c b/drivers/media/radio/radio-shark.c
44486 index 050b3bb..79f62b9 100644
44487 --- a/drivers/media/radio/radio-shark.c
44488 +++ b/drivers/media/radio/radio-shark.c
44489 @@ -79,7 +79,7 @@ struct shark_device {
44490 u32 last_val;
44491 };
44492
44493 -static atomic_t shark_instance = ATOMIC_INIT(0);
44494 +static atomic_unchecked_t shark_instance = ATOMIC_INIT(0);
44495
44496 static void shark_write_val(struct snd_tea575x *tea, u32 val)
44497 {
44498 diff --git a/drivers/media/radio/radio-shark2.c b/drivers/media/radio/radio-shark2.c
44499 index 8654e0d..0608a64 100644
44500 --- a/drivers/media/radio/radio-shark2.c
44501 +++ b/drivers/media/radio/radio-shark2.c
44502 @@ -74,7 +74,7 @@ struct shark_device {
44503 u8 *transfer_buffer;
44504 };
44505
44506 -static atomic_t shark_instance = ATOMIC_INIT(0);
44507 +static atomic_unchecked_t shark_instance = ATOMIC_INIT(0);
44508
44509 static int shark_write_reg(struct radio_tea5777 *tea, u64 reg)
44510 {
44511 diff --git a/drivers/media/radio/radio-si476x.c b/drivers/media/radio/radio-si476x.c
44512 index 2fd9009..278cc1e 100644
44513 --- a/drivers/media/radio/radio-si476x.c
44514 +++ b/drivers/media/radio/radio-si476x.c
44515 @@ -1445,7 +1445,7 @@ static int si476x_radio_probe(struct platform_device *pdev)
44516 struct si476x_radio *radio;
44517 struct v4l2_ctrl *ctrl;
44518
44519 - static atomic_t instance = ATOMIC_INIT(0);
44520 + static atomic_unchecked_t instance = ATOMIC_INIT(0);
44521
44522 radio = devm_kzalloc(&pdev->dev, sizeof(*radio), GFP_KERNEL);
44523 if (!radio)
44524 diff --git a/drivers/media/usb/dvb-usb/cxusb.c b/drivers/media/usb/dvb-usb/cxusb.c
44525 index a1c641e..3007da9 100644
44526 --- a/drivers/media/usb/dvb-usb/cxusb.c
44527 +++ b/drivers/media/usb/dvb-usb/cxusb.c
44528 @@ -1112,7 +1112,7 @@ static struct dib0070_config dib7070p_dib0070_config = {
44529
44530 struct dib0700_adapter_state {
44531 int (*set_param_save) (struct dvb_frontend *);
44532 -};
44533 +} __no_const;
44534
44535 static int dib7070_set_param_override(struct dvb_frontend *fe)
44536 {
44537 diff --git a/drivers/media/usb/dvb-usb/dw2102.c b/drivers/media/usb/dvb-usb/dw2102.c
44538 index ae0f56a..ec71784 100644
44539 --- a/drivers/media/usb/dvb-usb/dw2102.c
44540 +++ b/drivers/media/usb/dvb-usb/dw2102.c
44541 @@ -118,7 +118,7 @@ struct su3000_state {
44542
44543 struct s6x0_state {
44544 int (*old_set_voltage)(struct dvb_frontend *f, fe_sec_voltage_t v);
44545 -};
44546 +} __no_const;
44547
44548 /* debug */
44549 static int dvb_usb_dw2102_debug;
44550 diff --git a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
44551 index 7e2411c..cef73ca 100644
44552 --- a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
44553 +++ b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
44554 @@ -328,7 +328,7 @@ struct v4l2_buffer32 {
44555 __u32 reserved;
44556 };
44557
44558 -static int get_v4l2_plane32(struct v4l2_plane *up, struct v4l2_plane32 *up32,
44559 +static int get_v4l2_plane32(struct v4l2_plane __user *up, struct v4l2_plane32 __user *up32,
44560 enum v4l2_memory memory)
44561 {
44562 void __user *up_pln;
44563 @@ -357,7 +357,7 @@ static int get_v4l2_plane32(struct v4l2_plane *up, struct v4l2_plane32 *up32,
44564 return 0;
44565 }
44566
44567 -static int put_v4l2_plane32(struct v4l2_plane *up, struct v4l2_plane32 *up32,
44568 +static int put_v4l2_plane32(struct v4l2_plane __user *up, struct v4l2_plane32 __user *up32,
44569 enum v4l2_memory memory)
44570 {
44571 if (copy_in_user(up32, up, 2 * sizeof(__u32)) ||
44572 @@ -427,7 +427,7 @@ static int get_v4l2_buffer32(struct v4l2_buffer *kp, struct v4l2_buffer32 __user
44573 * by passing a very big num_planes value */
44574 uplane = compat_alloc_user_space(num_planes *
44575 sizeof(struct v4l2_plane));
44576 - kp->m.planes = uplane;
44577 + kp->m.planes = (struct v4l2_plane __force_kernel *)uplane;
44578
44579 while (--num_planes >= 0) {
44580 ret = get_v4l2_plane32(uplane, uplane32, kp->memory);
44581 @@ -498,7 +498,7 @@ static int put_v4l2_buffer32(struct v4l2_buffer *kp, struct v4l2_buffer32 __user
44582 if (num_planes == 0)
44583 return 0;
44584
44585 - uplane = kp->m.planes;
44586 + uplane = (struct v4l2_plane __force_user *)kp->m.planes;
44587 if (get_user(p, &up->m.planes))
44588 return -EFAULT;
44589 uplane32 = compat_ptr(p);
44590 @@ -552,7 +552,7 @@ static int get_v4l2_framebuffer32(struct v4l2_framebuffer *kp, struct v4l2_frame
44591 get_user(kp->capability, &up->capability) ||
44592 get_user(kp->flags, &up->flags))
44593 return -EFAULT;
44594 - kp->base = compat_ptr(tmp);
44595 + kp->base = (void __force_kernel *)compat_ptr(tmp);
44596 get_v4l2_pix_format(&kp->fmt, &up->fmt);
44597 return 0;
44598 }
44599 @@ -658,7 +658,7 @@ static int get_v4l2_ext_controls32(struct v4l2_ext_controls *kp, struct v4l2_ext
44600 n * sizeof(struct v4l2_ext_control32)))
44601 return -EFAULT;
44602 kcontrols = compat_alloc_user_space(n * sizeof(struct v4l2_ext_control));
44603 - kp->controls = kcontrols;
44604 + kp->controls = (struct v4l2_ext_control __force_kernel *)kcontrols;
44605 while (--n >= 0) {
44606 if (copy_in_user(kcontrols, ucontrols, sizeof(*ucontrols)))
44607 return -EFAULT;
44608 @@ -680,7 +680,7 @@ static int get_v4l2_ext_controls32(struct v4l2_ext_controls *kp, struct v4l2_ext
44609 static int put_v4l2_ext_controls32(struct v4l2_ext_controls *kp, struct v4l2_ext_controls32 __user *up)
44610 {
44611 struct v4l2_ext_control32 __user *ucontrols;
44612 - struct v4l2_ext_control __user *kcontrols = kp->controls;
44613 + struct v4l2_ext_control __user *kcontrols = (struct v4l2_ext_control __force_user *)kp->controls;
44614 int n = kp->count;
44615 compat_caddr_t p;
44616
44617 @@ -774,7 +774,7 @@ static int put_v4l2_edid32(struct v4l2_edid *kp, struct v4l2_edid32 __user *up)
44618 put_user(kp->start_block, &up->start_block) ||
44619 put_user(kp->blocks, &up->blocks) ||
44620 put_user(tmp, &up->edid) ||
44621 - copy_to_user(kp->reserved, up->reserved, sizeof(kp->reserved)))
44622 + copy_to_user(up->reserved, kp->reserved, sizeof(kp->reserved)))
44623 return -EFAULT;
44624 return 0;
44625 }
44626 diff --git a/drivers/media/v4l2-core/v4l2-ctrls.c b/drivers/media/v4l2-core/v4l2-ctrls.c
44627 index 55c6832..a91c7a6 100644
44628 --- a/drivers/media/v4l2-core/v4l2-ctrls.c
44629 +++ b/drivers/media/v4l2-core/v4l2-ctrls.c
44630 @@ -1431,8 +1431,8 @@ static int validate_new(const struct v4l2_ctrl *ctrl,
44631 return 0;
44632
44633 case V4L2_CTRL_TYPE_STRING:
44634 - len = strlen(c->string);
44635 - if (len < ctrl->minimum)
44636 + len = strlen_user(c->string);
44637 + if (!len || len < ctrl->minimum)
44638 return -ERANGE;
44639 if ((len - ctrl->minimum) % ctrl->step)
44640 return -ERANGE;
44641 diff --git a/drivers/media/v4l2-core/v4l2-device.c b/drivers/media/v4l2-core/v4l2-device.c
44642 index 02d1b63..5fd6b16 100644
44643 --- a/drivers/media/v4l2-core/v4l2-device.c
44644 +++ b/drivers/media/v4l2-core/v4l2-device.c
44645 @@ -75,9 +75,9 @@ int v4l2_device_put(struct v4l2_device *v4l2_dev)
44646 EXPORT_SYMBOL_GPL(v4l2_device_put);
44647
44648 int v4l2_device_set_name(struct v4l2_device *v4l2_dev, const char *basename,
44649 - atomic_t *instance)
44650 + atomic_unchecked_t *instance)
44651 {
44652 - int num = atomic_inc_return(instance) - 1;
44653 + int num = atomic_inc_return_unchecked(instance) - 1;
44654 int len = strlen(basename);
44655
44656 if (basename[len - 1] >= '0' && basename[len - 1] <= '9')
44657 diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c
44658 index d9113cc..7de6ccc 100644
44659 --- a/drivers/media/v4l2-core/v4l2-ioctl.c
44660 +++ b/drivers/media/v4l2-core/v4l2-ioctl.c
44661 @@ -2003,7 +2003,8 @@ struct v4l2_ioctl_info {
44662 struct file *file, void *fh, void *p);
44663 } u;
44664 void (*debug)(const void *arg, bool write_only);
44665 -};
44666 +} __do_const;
44667 +typedef struct v4l2_ioctl_info __no_const v4l2_ioctl_info_no_const;
44668
44669 /* This control needs a priority check */
44670 #define INFO_FL_PRIO (1 << 0)
44671 @@ -2186,7 +2187,7 @@ static long __video_do_ioctl(struct file *file,
44672 struct video_device *vfd = video_devdata(file);
44673 const struct v4l2_ioctl_ops *ops = vfd->ioctl_ops;
44674 bool write_only = false;
44675 - struct v4l2_ioctl_info default_info;
44676 + v4l2_ioctl_info_no_const default_info;
44677 const struct v4l2_ioctl_info *info;
44678 void *fh = file->private_data;
44679 struct v4l2_fh *vfh = NULL;
44680 @@ -2260,7 +2261,7 @@ done:
44681 }
44682
44683 static int check_array_args(unsigned int cmd, void *parg, size_t *array_size,
44684 - void * __user *user_ptr, void ***kernel_ptr)
44685 + void __user **user_ptr, void ***kernel_ptr)
44686 {
44687 int ret = 0;
44688
44689 @@ -2276,7 +2277,7 @@ static int check_array_args(unsigned int cmd, void *parg, size_t *array_size,
44690 ret = -EINVAL;
44691 break;
44692 }
44693 - *user_ptr = (void __user *)buf->m.planes;
44694 + *user_ptr = (void __force_user *)buf->m.planes;
44695 *kernel_ptr = (void *)&buf->m.planes;
44696 *array_size = sizeof(struct v4l2_plane) * buf->length;
44697 ret = 1;
44698 @@ -2311,7 +2312,7 @@ static int check_array_args(unsigned int cmd, void *parg, size_t *array_size,
44699 ret = -EINVAL;
44700 break;
44701 }
44702 - *user_ptr = (void __user *)ctrls->controls;
44703 + *user_ptr = (void __force_user *)ctrls->controls;
44704 *kernel_ptr = (void *)&ctrls->controls;
44705 *array_size = sizeof(struct v4l2_ext_control)
44706 * ctrls->count;
44707 @@ -2412,7 +2413,7 @@ video_usercopy(struct file *file, unsigned int cmd, unsigned long arg,
44708 }
44709
44710 if (has_array_args) {
44711 - *kernel_ptr = user_ptr;
44712 + *kernel_ptr = (void __force_kernel *)user_ptr;
44713 if (copy_to_user(user_ptr, mbuf, array_size))
44714 err = -EFAULT;
44715 goto out_array_args;
44716 diff --git a/drivers/message/fusion/mptbase.c b/drivers/message/fusion/mptbase.c
44717 index 570b18a..f880314 100644
44718 --- a/drivers/message/fusion/mptbase.c
44719 +++ b/drivers/message/fusion/mptbase.c
44720 @@ -6755,8 +6755,13 @@ static int mpt_iocinfo_proc_show(struct seq_file *m, void *v)
44721 seq_printf(m, " MaxChainDepth = 0x%02x frames\n", ioc->facts.MaxChainDepth);
44722 seq_printf(m, " MinBlockSize = 0x%02x bytes\n", 4*ioc->facts.BlockSize);
44723
44724 +#ifdef CONFIG_GRKERNSEC_HIDESYM
44725 + seq_printf(m, " RequestFrames @ 0x%p (Dma @ 0x%p)\n", NULL, NULL);
44726 +#else
44727 seq_printf(m, " RequestFrames @ 0x%p (Dma @ 0x%p)\n",
44728 (void *)ioc->req_frames, (void *)(ulong)ioc->req_frames_dma);
44729 +#endif
44730 +
44731 /*
44732 * Rounding UP to nearest 4-kB boundary here...
44733 */
44734 @@ -6769,7 +6774,11 @@ static int mpt_iocinfo_proc_show(struct seq_file *m, void *v)
44735 ioc->facts.GlobalCredits);
44736
44737 seq_printf(m, " Frames @ 0x%p (Dma @ 0x%p)\n",
44738 +#ifdef CONFIG_GRKERNSEC_HIDESYM
44739 + NULL, NULL);
44740 +#else
44741 (void *)ioc->alloc, (void *)(ulong)ioc->alloc_dma);
44742 +#endif
44743 sz = (ioc->reply_sz * ioc->reply_depth) + 128;
44744 seq_printf(m, " {CurRepSz=%d} x {CurRepDepth=%d} = %d bytes ^= 0x%x\n",
44745 ioc->reply_sz, ioc->reply_depth, ioc->reply_sz*ioc->reply_depth, sz);
44746 diff --git a/drivers/message/fusion/mptsas.c b/drivers/message/fusion/mptsas.c
44747 index 00d339c..2ea899d 100644
44748 --- a/drivers/message/fusion/mptsas.c
44749 +++ b/drivers/message/fusion/mptsas.c
44750 @@ -446,6 +446,23 @@ mptsas_is_end_device(struct mptsas_devinfo * attached)
44751 return 0;
44752 }
44753
44754 +static inline void
44755 +mptsas_set_rphy(MPT_ADAPTER *ioc, struct mptsas_phyinfo *phy_info, struct sas_rphy *rphy)
44756 +{
44757 + if (phy_info->port_details) {
44758 + phy_info->port_details->rphy = rphy;
44759 + dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "sas_rphy_add: rphy=%p\n",
44760 + ioc->name, rphy));
44761 + }
44762 +
44763 + if (rphy) {
44764 + dsaswideprintk(ioc, dev_printk(KERN_DEBUG,
44765 + &rphy->dev, MYIOC_s_FMT "add:", ioc->name));
44766 + dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "rphy=%p release=%p\n",
44767 + ioc->name, rphy, rphy->dev.release));
44768 + }
44769 +}
44770 +
44771 /* no mutex */
44772 static void
44773 mptsas_port_delete(MPT_ADAPTER *ioc, struct mptsas_portinfo_details * port_details)
44774 @@ -484,23 +501,6 @@ mptsas_get_rphy(struct mptsas_phyinfo *phy_info)
44775 return NULL;
44776 }
44777
44778 -static inline void
44779 -mptsas_set_rphy(MPT_ADAPTER *ioc, struct mptsas_phyinfo *phy_info, struct sas_rphy *rphy)
44780 -{
44781 - if (phy_info->port_details) {
44782 - phy_info->port_details->rphy = rphy;
44783 - dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "sas_rphy_add: rphy=%p\n",
44784 - ioc->name, rphy));
44785 - }
44786 -
44787 - if (rphy) {
44788 - dsaswideprintk(ioc, dev_printk(KERN_DEBUG,
44789 - &rphy->dev, MYIOC_s_FMT "add:", ioc->name));
44790 - dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "rphy=%p release=%p\n",
44791 - ioc->name, rphy, rphy->dev.release));
44792 - }
44793 -}
44794 -
44795 static inline struct sas_port *
44796 mptsas_get_port(struct mptsas_phyinfo *phy_info)
44797 {
44798 diff --git a/drivers/message/fusion/mptscsih.c b/drivers/message/fusion/mptscsih.c
44799 index 727819c..ad74694 100644
44800 --- a/drivers/message/fusion/mptscsih.c
44801 +++ b/drivers/message/fusion/mptscsih.c
44802 @@ -1271,15 +1271,16 @@ mptscsih_info(struct Scsi_Host *SChost)
44803
44804 h = shost_priv(SChost);
44805
44806 - if (h) {
44807 - if (h->info_kbuf == NULL)
44808 - if ((h->info_kbuf = kmalloc(0x1000 /* 4Kb */, GFP_KERNEL)) == NULL)
44809 - return h->info_kbuf;
44810 - h->info_kbuf[0] = '\0';
44811 + if (!h)
44812 + return NULL;
44813
44814 - mpt_print_ioc_summary(h->ioc, h->info_kbuf, &size, 0, 0);
44815 - h->info_kbuf[size-1] = '\0';
44816 - }
44817 + if (h->info_kbuf == NULL)
44818 + if ((h->info_kbuf = kmalloc(0x1000 /* 4Kb */, GFP_KERNEL)) == NULL)
44819 + return h->info_kbuf;
44820 + h->info_kbuf[0] = '\0';
44821 +
44822 + mpt_print_ioc_summary(h->ioc, h->info_kbuf, &size, 0, 0);
44823 + h->info_kbuf[size-1] = '\0';
44824
44825 return h->info_kbuf;
44826 }
44827 diff --git a/drivers/message/i2o/i2o_proc.c b/drivers/message/i2o/i2o_proc.c
44828 index b7d87cd..3fb36da 100644
44829 --- a/drivers/message/i2o/i2o_proc.c
44830 +++ b/drivers/message/i2o/i2o_proc.c
44831 @@ -255,12 +255,6 @@ static char *scsi_devices[] = {
44832 "Array Controller Device"
44833 };
44834
44835 -static char *chtostr(char *tmp, u8 *chars, int n)
44836 -{
44837 - tmp[0] = 0;
44838 - return strncat(tmp, (char *)chars, n);
44839 -}
44840 -
44841 static int i2o_report_query_status(struct seq_file *seq, int block_status,
44842 char *group)
44843 {
44844 @@ -707,9 +701,9 @@ static int i2o_seq_show_status(struct seq_file *seq, void *v)
44845 static int i2o_seq_show_hw(struct seq_file *seq, void *v)
44846 {
44847 struct i2o_controller *c = (struct i2o_controller *)seq->private;
44848 - static u32 work32[5];
44849 - static u8 *work8 = (u8 *) work32;
44850 - static u16 *work16 = (u16 *) work32;
44851 + u32 work32[5];
44852 + u8 *work8 = (u8 *) work32;
44853 + u16 *work16 = (u16 *) work32;
44854 int token;
44855 u32 hwcap;
44856
44857 @@ -790,7 +784,6 @@ static int i2o_seq_show_ddm_table(struct seq_file *seq, void *v)
44858 } *result;
44859
44860 i2o_exec_execute_ddm_table ddm_table;
44861 - char tmp[28 + 1];
44862
44863 result = kmalloc(sizeof(*result), GFP_KERNEL);
44864 if (!result)
44865 @@ -825,8 +818,7 @@ static int i2o_seq_show_ddm_table(struct seq_file *seq, void *v)
44866
44867 seq_printf(seq, "%-#7x", ddm_table.i2o_vendor_id);
44868 seq_printf(seq, "%-#8x", ddm_table.module_id);
44869 - seq_printf(seq, "%-29s",
44870 - chtostr(tmp, ddm_table.module_name_version, 28));
44871 + seq_printf(seq, "%-.28s", ddm_table.module_name_version);
44872 seq_printf(seq, "%9d ", ddm_table.data_size);
44873 seq_printf(seq, "%8d", ddm_table.code_size);
44874
44875 @@ -893,7 +885,6 @@ static int i2o_seq_show_drivers_stored(struct seq_file *seq, void *v)
44876
44877 i2o_driver_result_table *result;
44878 i2o_driver_store_table *dst;
44879 - char tmp[28 + 1];
44880
44881 result = kmalloc(sizeof(i2o_driver_result_table), GFP_KERNEL);
44882 if (result == NULL)
44883 @@ -928,9 +919,8 @@ static int i2o_seq_show_drivers_stored(struct seq_file *seq, void *v)
44884
44885 seq_printf(seq, "%-#7x", dst->i2o_vendor_id);
44886 seq_printf(seq, "%-#8x", dst->module_id);
44887 - seq_printf(seq, "%-29s",
44888 - chtostr(tmp, dst->module_name_version, 28));
44889 - seq_printf(seq, "%-9s", chtostr(tmp, dst->date, 8));
44890 + seq_printf(seq, "%-.28s", dst->module_name_version);
44891 + seq_printf(seq, "%-.8s", dst->date);
44892 seq_printf(seq, "%8d ", dst->module_size);
44893 seq_printf(seq, "%8d ", dst->mpb_size);
44894 seq_printf(seq, "0x%04x", dst->module_flags);
44895 @@ -1246,11 +1236,10 @@ static int i2o_seq_show_authorized_users(struct seq_file *seq, void *v)
44896 static int i2o_seq_show_dev_identity(struct seq_file *seq, void *v)
44897 {
44898 struct i2o_device *d = (struct i2o_device *)seq->private;
44899 - static u32 work32[128]; // allow for "stuff" + up to 256 byte (max) serial number
44900 + u32 work32[128]; // allow for "stuff" + up to 256 byte (max) serial number
44901 // == (allow) 512d bytes (max)
44902 - static u16 *work16 = (u16 *) work32;
44903 + u16 *work16 = (u16 *) work32;
44904 int token;
44905 - char tmp[16 + 1];
44906
44907 token = i2o_parm_field_get(d, 0xF100, -1, &work32, sizeof(work32));
44908
44909 @@ -1262,14 +1251,10 @@ static int i2o_seq_show_dev_identity(struct seq_file *seq, void *v)
44910 seq_printf(seq, "Device Class : %s\n", i2o_get_class_name(work16[0]));
44911 seq_printf(seq, "Owner TID : %0#5x\n", work16[2]);
44912 seq_printf(seq, "Parent TID : %0#5x\n", work16[3]);
44913 - seq_printf(seq, "Vendor info : %s\n",
44914 - chtostr(tmp, (u8 *) (work32 + 2), 16));
44915 - seq_printf(seq, "Product info : %s\n",
44916 - chtostr(tmp, (u8 *) (work32 + 6), 16));
44917 - seq_printf(seq, "Description : %s\n",
44918 - chtostr(tmp, (u8 *) (work32 + 10), 16));
44919 - seq_printf(seq, "Product rev. : %s\n",
44920 - chtostr(tmp, (u8 *) (work32 + 14), 8));
44921 + seq_printf(seq, "Vendor info : %.16s\n", (u8 *) (work32 + 2));
44922 + seq_printf(seq, "Product info : %.16s\n", (u8 *) (work32 + 6));
44923 + seq_printf(seq, "Description : %.16s\n", (u8 *) (work32 + 10));
44924 + seq_printf(seq, "Product rev. : %.8s\n", (u8 *) (work32 + 14));
44925
44926 seq_printf(seq, "Serial number : ");
44927 print_serial_number(seq, (u8 *) (work32 + 16),
44928 @@ -1306,8 +1291,6 @@ static int i2o_seq_show_ddm_identity(struct seq_file *seq, void *v)
44929 u8 pad[256]; // allow up to 256 byte (max) serial number
44930 } result;
44931
44932 - char tmp[24 + 1];
44933 -
44934 token = i2o_parm_field_get(d, 0xF101, -1, &result, sizeof(result));
44935
44936 if (token < 0) {
44937 @@ -1316,10 +1299,8 @@ static int i2o_seq_show_ddm_identity(struct seq_file *seq, void *v)
44938 }
44939
44940 seq_printf(seq, "Registering DDM TID : 0x%03x\n", result.ddm_tid);
44941 - seq_printf(seq, "Module name : %s\n",
44942 - chtostr(tmp, result.module_name, 24));
44943 - seq_printf(seq, "Module revision : %s\n",
44944 - chtostr(tmp, result.module_rev, 8));
44945 + seq_printf(seq, "Module name : %.24s\n", result.module_name);
44946 + seq_printf(seq, "Module revision : %.8s\n", result.module_rev);
44947
44948 seq_printf(seq, "Serial number : ");
44949 print_serial_number(seq, result.serial_number, sizeof(result) - 36);
44950 @@ -1343,8 +1324,6 @@ static int i2o_seq_show_uinfo(struct seq_file *seq, void *v)
44951 u8 instance_number[4];
44952 } result;
44953
44954 - char tmp[64 + 1];
44955 -
44956 token = i2o_parm_field_get(d, 0xF102, -1, &result, sizeof(result));
44957
44958 if (token < 0) {
44959 @@ -1352,14 +1331,10 @@ static int i2o_seq_show_uinfo(struct seq_file *seq, void *v)
44960 return 0;
44961 }
44962
44963 - seq_printf(seq, "Device name : %s\n",
44964 - chtostr(tmp, result.device_name, 64));
44965 - seq_printf(seq, "Service name : %s\n",
44966 - chtostr(tmp, result.service_name, 64));
44967 - seq_printf(seq, "Physical name : %s\n",
44968 - chtostr(tmp, result.physical_location, 64));
44969 - seq_printf(seq, "Instance number : %s\n",
44970 - chtostr(tmp, result.instance_number, 4));
44971 + seq_printf(seq, "Device name : %.64s\n", result.device_name);
44972 + seq_printf(seq, "Service name : %.64s\n", result.service_name);
44973 + seq_printf(seq, "Physical name : %.64s\n", result.physical_location);
44974 + seq_printf(seq, "Instance number : %.4s\n", result.instance_number);
44975
44976 return 0;
44977 }
44978 @@ -1368,9 +1343,9 @@ static int i2o_seq_show_uinfo(struct seq_file *seq, void *v)
44979 static int i2o_seq_show_sgl_limits(struct seq_file *seq, void *v)
44980 {
44981 struct i2o_device *d = (struct i2o_device *)seq->private;
44982 - static u32 work32[12];
44983 - static u16 *work16 = (u16 *) work32;
44984 - static u8 *work8 = (u8 *) work32;
44985 + u32 work32[12];
44986 + u16 *work16 = (u16 *) work32;
44987 + u8 *work8 = (u8 *) work32;
44988 int token;
44989
44990 token = i2o_parm_field_get(d, 0xF103, -1, &work32, sizeof(work32));
44991 diff --git a/drivers/message/i2o/iop.c b/drivers/message/i2o/iop.c
44992 index 92752fb..a7494f6 100644
44993 --- a/drivers/message/i2o/iop.c
44994 +++ b/drivers/message/i2o/iop.c
44995 @@ -111,10 +111,10 @@ u32 i2o_cntxt_list_add(struct i2o_controller * c, void *ptr)
44996
44997 spin_lock_irqsave(&c->context_list_lock, flags);
44998
44999 - if (unlikely(atomic_inc_and_test(&c->context_list_counter)))
45000 - atomic_inc(&c->context_list_counter);
45001 + if (unlikely(atomic_inc_and_test_unchecked(&c->context_list_counter)))
45002 + atomic_inc_unchecked(&c->context_list_counter);
45003
45004 - entry->context = atomic_read(&c->context_list_counter);
45005 + entry->context = atomic_read_unchecked(&c->context_list_counter);
45006
45007 list_add(&entry->list, &c->context_list);
45008
45009 @@ -1076,7 +1076,7 @@ struct i2o_controller *i2o_iop_alloc(void)
45010
45011 #if BITS_PER_LONG == 64
45012 spin_lock_init(&c->context_list_lock);
45013 - atomic_set(&c->context_list_counter, 0);
45014 + atomic_set_unchecked(&c->context_list_counter, 0);
45015 INIT_LIST_HEAD(&c->context_list);
45016 #endif
45017
45018 diff --git a/drivers/mfd/ab8500-debugfs.c b/drivers/mfd/ab8500-debugfs.c
45019 index d1a22aa..d0f7bf7 100644
45020 --- a/drivers/mfd/ab8500-debugfs.c
45021 +++ b/drivers/mfd/ab8500-debugfs.c
45022 @@ -100,7 +100,7 @@ static int irq_last;
45023 static u32 *irq_count;
45024 static int num_irqs;
45025
45026 -static struct device_attribute **dev_attr;
45027 +static device_attribute_no_const **dev_attr;
45028 static char **event_name;
45029
45030 static u8 avg_sample = SAMPLE_16;
45031 diff --git a/drivers/mfd/max8925-i2c.c b/drivers/mfd/max8925-i2c.c
45032 index a83eed5..62a58a9 100644
45033 --- a/drivers/mfd/max8925-i2c.c
45034 +++ b/drivers/mfd/max8925-i2c.c
45035 @@ -152,7 +152,7 @@ static int max8925_probe(struct i2c_client *client,
45036 const struct i2c_device_id *id)
45037 {
45038 struct max8925_platform_data *pdata = dev_get_platdata(&client->dev);
45039 - static struct max8925_chip *chip;
45040 + struct max8925_chip *chip;
45041 struct device_node *node = client->dev.of_node;
45042
45043 if (node && !pdata) {
45044 diff --git a/drivers/mfd/tps65910.c b/drivers/mfd/tps65910.c
45045 index 460a014..21d3061 100644
45046 --- a/drivers/mfd/tps65910.c
45047 +++ b/drivers/mfd/tps65910.c
45048 @@ -230,7 +230,7 @@ static int tps65910_irq_init(struct tps65910 *tps65910, int irq,
45049 struct tps65910_platform_data *pdata)
45050 {
45051 int ret = 0;
45052 - static struct regmap_irq_chip *tps6591x_irqs_chip;
45053 + struct regmap_irq_chip *tps6591x_irqs_chip;
45054
45055 if (!irq) {
45056 dev_warn(tps65910->dev, "No interrupt support, no core IRQ\n");
45057 diff --git a/drivers/mfd/twl4030-irq.c b/drivers/mfd/twl4030-irq.c
45058 index 596b1f6..5b6ab74 100644
45059 --- a/drivers/mfd/twl4030-irq.c
45060 +++ b/drivers/mfd/twl4030-irq.c
45061 @@ -34,6 +34,7 @@
45062 #include <linux/of.h>
45063 #include <linux/irqdomain.h>
45064 #include <linux/i2c/twl.h>
45065 +#include <asm/pgtable.h>
45066
45067 #include "twl-core.h"
45068
45069 @@ -725,10 +726,12 @@ int twl4030_init_irq(struct device *dev, int irq_num)
45070 * Install an irq handler for each of the SIH modules;
45071 * clone dummy irq_chip since PIH can't *do* anything
45072 */
45073 - twl4030_irq_chip = dummy_irq_chip;
45074 - twl4030_irq_chip.name = "twl4030";
45075 + pax_open_kernel();
45076 + memcpy((void *)&twl4030_irq_chip, &dummy_irq_chip, sizeof twl4030_irq_chip);
45077 + *(const char **)&twl4030_irq_chip.name = "twl4030";
45078
45079 - twl4030_sih_irq_chip.irq_ack = dummy_irq_chip.irq_ack;
45080 + *(void **)&twl4030_sih_irq_chip.irq_ack = dummy_irq_chip.irq_ack;
45081 + pax_close_kernel();
45082
45083 for (i = irq_base; i < irq_end; i++) {
45084 irq_set_chip_and_handler(i, &twl4030_irq_chip,
45085 diff --git a/drivers/misc/c2port/core.c b/drivers/misc/c2port/core.c
45086 index 464419b..64bae8d 100644
45087 --- a/drivers/misc/c2port/core.c
45088 +++ b/drivers/misc/c2port/core.c
45089 @@ -922,7 +922,9 @@ struct c2port_device *c2port_device_register(char *name,
45090 goto error_idr_alloc;
45091 c2dev->id = ret;
45092
45093 - bin_attr_flash_data.size = ops->blocks_num * ops->block_size;
45094 + pax_open_kernel();
45095 + *(size_t *)&bin_attr_flash_data.size = ops->blocks_num * ops->block_size;
45096 + pax_close_kernel();
45097
45098 c2dev->dev = device_create(c2port_class, NULL, 0, c2dev,
45099 "c2port%d", c2dev->id);
45100 diff --git a/drivers/misc/eeprom/sunxi_sid.c b/drivers/misc/eeprom/sunxi_sid.c
45101 index 3f2b625..945e179 100644
45102 --- a/drivers/misc/eeprom/sunxi_sid.c
45103 +++ b/drivers/misc/eeprom/sunxi_sid.c
45104 @@ -126,7 +126,9 @@ static int sunxi_sid_probe(struct platform_device *pdev)
45105
45106 platform_set_drvdata(pdev, sid_data);
45107
45108 - sid_bin_attr.size = sid_data->keysize;
45109 + pax_open_kernel();
45110 + *(size_t *)&sid_bin_attr.size = sid_data->keysize;
45111 + pax_close_kernel();
45112 if (device_create_bin_file(&pdev->dev, &sid_bin_attr))
45113 return -ENODEV;
45114
45115 diff --git a/drivers/misc/kgdbts.c b/drivers/misc/kgdbts.c
45116 index 36f5d52..32311c3 100644
45117 --- a/drivers/misc/kgdbts.c
45118 +++ b/drivers/misc/kgdbts.c
45119 @@ -834,7 +834,7 @@ static void run_plant_and_detach_test(int is_early)
45120 char before[BREAK_INSTR_SIZE];
45121 char after[BREAK_INSTR_SIZE];
45122
45123 - probe_kernel_read(before, (char *)kgdbts_break_test,
45124 + probe_kernel_read(before, ktla_ktva((char *)kgdbts_break_test),
45125 BREAK_INSTR_SIZE);
45126 init_simple_test();
45127 ts.tst = plant_and_detach_test;
45128 @@ -842,7 +842,7 @@ static void run_plant_and_detach_test(int is_early)
45129 /* Activate test with initial breakpoint */
45130 if (!is_early)
45131 kgdb_breakpoint();
45132 - probe_kernel_read(after, (char *)kgdbts_break_test,
45133 + probe_kernel_read(after, ktla_ktva((char *)kgdbts_break_test),
45134 BREAK_INSTR_SIZE);
45135 if (memcmp(before, after, BREAK_INSTR_SIZE)) {
45136 printk(KERN_CRIT "kgdbts: ERROR kgdb corrupted memory\n");
45137 diff --git a/drivers/misc/lis3lv02d/lis3lv02d.c b/drivers/misc/lis3lv02d/lis3lv02d.c
45138 index 3ef4627..8d00486 100644
45139 --- a/drivers/misc/lis3lv02d/lis3lv02d.c
45140 +++ b/drivers/misc/lis3lv02d/lis3lv02d.c
45141 @@ -497,7 +497,7 @@ static irqreturn_t lis302dl_interrupt(int irq, void *data)
45142 * the lid is closed. This leads to interrupts as soon as a little move
45143 * is done.
45144 */
45145 - atomic_inc(&lis3->count);
45146 + atomic_inc_unchecked(&lis3->count);
45147
45148 wake_up_interruptible(&lis3->misc_wait);
45149 kill_fasync(&lis3->async_queue, SIGIO, POLL_IN);
45150 @@ -583,7 +583,7 @@ static int lis3lv02d_misc_open(struct inode *inode, struct file *file)
45151 if (lis3->pm_dev)
45152 pm_runtime_get_sync(lis3->pm_dev);
45153
45154 - atomic_set(&lis3->count, 0);
45155 + atomic_set_unchecked(&lis3->count, 0);
45156 return 0;
45157 }
45158
45159 @@ -615,7 +615,7 @@ static ssize_t lis3lv02d_misc_read(struct file *file, char __user *buf,
45160 add_wait_queue(&lis3->misc_wait, &wait);
45161 while (true) {
45162 set_current_state(TASK_INTERRUPTIBLE);
45163 - data = atomic_xchg(&lis3->count, 0);
45164 + data = atomic_xchg_unchecked(&lis3->count, 0);
45165 if (data)
45166 break;
45167
45168 @@ -656,7 +656,7 @@ static unsigned int lis3lv02d_misc_poll(struct file *file, poll_table *wait)
45169 struct lis3lv02d, miscdev);
45170
45171 poll_wait(file, &lis3->misc_wait, wait);
45172 - if (atomic_read(&lis3->count))
45173 + if (atomic_read_unchecked(&lis3->count))
45174 return POLLIN | POLLRDNORM;
45175 return 0;
45176 }
45177 diff --git a/drivers/misc/lis3lv02d/lis3lv02d.h b/drivers/misc/lis3lv02d/lis3lv02d.h
45178 index c439c82..1f20f57 100644
45179 --- a/drivers/misc/lis3lv02d/lis3lv02d.h
45180 +++ b/drivers/misc/lis3lv02d/lis3lv02d.h
45181 @@ -297,7 +297,7 @@ struct lis3lv02d {
45182 struct input_polled_dev *idev; /* input device */
45183 struct platform_device *pdev; /* platform device */
45184 struct regulator_bulk_data regulators[2];
45185 - atomic_t count; /* interrupt count after last read */
45186 + atomic_unchecked_t count; /* interrupt count after last read */
45187 union axis_conversion ac; /* hw -> logical axis */
45188 int mapped_btns[3];
45189
45190 diff --git a/drivers/misc/sgi-gru/gruhandles.c b/drivers/misc/sgi-gru/gruhandles.c
45191 index 2f30bad..c4c13d0 100644
45192 --- a/drivers/misc/sgi-gru/gruhandles.c
45193 +++ b/drivers/misc/sgi-gru/gruhandles.c
45194 @@ -44,8 +44,8 @@ static void update_mcs_stats(enum mcs_op op, unsigned long clks)
45195 unsigned long nsec;
45196
45197 nsec = CLKS2NSEC(clks);
45198 - atomic_long_inc(&mcs_op_statistics[op].count);
45199 - atomic_long_add(nsec, &mcs_op_statistics[op].total);
45200 + atomic_long_inc_unchecked(&mcs_op_statistics[op].count);
45201 + atomic_long_add_unchecked(nsec, &mcs_op_statistics[op].total);
45202 if (mcs_op_statistics[op].max < nsec)
45203 mcs_op_statistics[op].max = nsec;
45204 }
45205 diff --git a/drivers/misc/sgi-gru/gruprocfs.c b/drivers/misc/sgi-gru/gruprocfs.c
45206 index 4f76359..cdfcb2e 100644
45207 --- a/drivers/misc/sgi-gru/gruprocfs.c
45208 +++ b/drivers/misc/sgi-gru/gruprocfs.c
45209 @@ -32,9 +32,9 @@
45210
45211 #define printstat(s, f) printstat_val(s, &gru_stats.f, #f)
45212
45213 -static void printstat_val(struct seq_file *s, atomic_long_t *v, char *id)
45214 +static void printstat_val(struct seq_file *s, atomic_long_unchecked_t *v, char *id)
45215 {
45216 - unsigned long val = atomic_long_read(v);
45217 + unsigned long val = atomic_long_read_unchecked(v);
45218
45219 seq_printf(s, "%16lu %s\n", val, id);
45220 }
45221 @@ -134,8 +134,8 @@ static int mcs_statistics_show(struct seq_file *s, void *p)
45222
45223 seq_printf(s, "%-20s%12s%12s%12s\n", "#id", "count", "aver-clks", "max-clks");
45224 for (op = 0; op < mcsop_last; op++) {
45225 - count = atomic_long_read(&mcs_op_statistics[op].count);
45226 - total = atomic_long_read(&mcs_op_statistics[op].total);
45227 + count = atomic_long_read_unchecked(&mcs_op_statistics[op].count);
45228 + total = atomic_long_read_unchecked(&mcs_op_statistics[op].total);
45229 max = mcs_op_statistics[op].max;
45230 seq_printf(s, "%-20s%12ld%12ld%12ld\n", id[op], count,
45231 count ? total / count : 0, max);
45232 diff --git a/drivers/misc/sgi-gru/grutables.h b/drivers/misc/sgi-gru/grutables.h
45233 index 5c3ce24..4915ccb 100644
45234 --- a/drivers/misc/sgi-gru/grutables.h
45235 +++ b/drivers/misc/sgi-gru/grutables.h
45236 @@ -167,82 +167,82 @@ extern unsigned int gru_max_gids;
45237 * GRU statistics.
45238 */
45239 struct gru_stats_s {
45240 - atomic_long_t vdata_alloc;
45241 - atomic_long_t vdata_free;
45242 - atomic_long_t gts_alloc;
45243 - atomic_long_t gts_free;
45244 - atomic_long_t gms_alloc;
45245 - atomic_long_t gms_free;
45246 - atomic_long_t gts_double_allocate;
45247 - atomic_long_t assign_context;
45248 - atomic_long_t assign_context_failed;
45249 - atomic_long_t free_context;
45250 - atomic_long_t load_user_context;
45251 - atomic_long_t load_kernel_context;
45252 - atomic_long_t lock_kernel_context;
45253 - atomic_long_t unlock_kernel_context;
45254 - atomic_long_t steal_user_context;
45255 - atomic_long_t steal_kernel_context;
45256 - atomic_long_t steal_context_failed;
45257 - atomic_long_t nopfn;
45258 - atomic_long_t asid_new;
45259 - atomic_long_t asid_next;
45260 - atomic_long_t asid_wrap;
45261 - atomic_long_t asid_reuse;
45262 - atomic_long_t intr;
45263 - atomic_long_t intr_cbr;
45264 - atomic_long_t intr_tfh;
45265 - atomic_long_t intr_spurious;
45266 - atomic_long_t intr_mm_lock_failed;
45267 - atomic_long_t call_os;
45268 - atomic_long_t call_os_wait_queue;
45269 - atomic_long_t user_flush_tlb;
45270 - atomic_long_t user_unload_context;
45271 - atomic_long_t user_exception;
45272 - atomic_long_t set_context_option;
45273 - atomic_long_t check_context_retarget_intr;
45274 - atomic_long_t check_context_unload;
45275 - atomic_long_t tlb_dropin;
45276 - atomic_long_t tlb_preload_page;
45277 - atomic_long_t tlb_dropin_fail_no_asid;
45278 - atomic_long_t tlb_dropin_fail_upm;
45279 - atomic_long_t tlb_dropin_fail_invalid;
45280 - atomic_long_t tlb_dropin_fail_range_active;
45281 - atomic_long_t tlb_dropin_fail_idle;
45282 - atomic_long_t tlb_dropin_fail_fmm;
45283 - atomic_long_t tlb_dropin_fail_no_exception;
45284 - atomic_long_t tfh_stale_on_fault;
45285 - atomic_long_t mmu_invalidate_range;
45286 - atomic_long_t mmu_invalidate_page;
45287 - atomic_long_t flush_tlb;
45288 - atomic_long_t flush_tlb_gru;
45289 - atomic_long_t flush_tlb_gru_tgh;
45290 - atomic_long_t flush_tlb_gru_zero_asid;
45291 + atomic_long_unchecked_t vdata_alloc;
45292 + atomic_long_unchecked_t vdata_free;
45293 + atomic_long_unchecked_t gts_alloc;
45294 + atomic_long_unchecked_t gts_free;
45295 + atomic_long_unchecked_t gms_alloc;
45296 + atomic_long_unchecked_t gms_free;
45297 + atomic_long_unchecked_t gts_double_allocate;
45298 + atomic_long_unchecked_t assign_context;
45299 + atomic_long_unchecked_t assign_context_failed;
45300 + atomic_long_unchecked_t free_context;
45301 + atomic_long_unchecked_t load_user_context;
45302 + atomic_long_unchecked_t load_kernel_context;
45303 + atomic_long_unchecked_t lock_kernel_context;
45304 + atomic_long_unchecked_t unlock_kernel_context;
45305 + atomic_long_unchecked_t steal_user_context;
45306 + atomic_long_unchecked_t steal_kernel_context;
45307 + atomic_long_unchecked_t steal_context_failed;
45308 + atomic_long_unchecked_t nopfn;
45309 + atomic_long_unchecked_t asid_new;
45310 + atomic_long_unchecked_t asid_next;
45311 + atomic_long_unchecked_t asid_wrap;
45312 + atomic_long_unchecked_t asid_reuse;
45313 + atomic_long_unchecked_t intr;
45314 + atomic_long_unchecked_t intr_cbr;
45315 + atomic_long_unchecked_t intr_tfh;
45316 + atomic_long_unchecked_t intr_spurious;
45317 + atomic_long_unchecked_t intr_mm_lock_failed;
45318 + atomic_long_unchecked_t call_os;
45319 + atomic_long_unchecked_t call_os_wait_queue;
45320 + atomic_long_unchecked_t user_flush_tlb;
45321 + atomic_long_unchecked_t user_unload_context;
45322 + atomic_long_unchecked_t user_exception;
45323 + atomic_long_unchecked_t set_context_option;
45324 + atomic_long_unchecked_t check_context_retarget_intr;
45325 + atomic_long_unchecked_t check_context_unload;
45326 + atomic_long_unchecked_t tlb_dropin;
45327 + atomic_long_unchecked_t tlb_preload_page;
45328 + atomic_long_unchecked_t tlb_dropin_fail_no_asid;
45329 + atomic_long_unchecked_t tlb_dropin_fail_upm;
45330 + atomic_long_unchecked_t tlb_dropin_fail_invalid;
45331 + atomic_long_unchecked_t tlb_dropin_fail_range_active;
45332 + atomic_long_unchecked_t tlb_dropin_fail_idle;
45333 + atomic_long_unchecked_t tlb_dropin_fail_fmm;
45334 + atomic_long_unchecked_t tlb_dropin_fail_no_exception;
45335 + atomic_long_unchecked_t tfh_stale_on_fault;
45336 + atomic_long_unchecked_t mmu_invalidate_range;
45337 + atomic_long_unchecked_t mmu_invalidate_page;
45338 + atomic_long_unchecked_t flush_tlb;
45339 + atomic_long_unchecked_t flush_tlb_gru;
45340 + atomic_long_unchecked_t flush_tlb_gru_tgh;
45341 + atomic_long_unchecked_t flush_tlb_gru_zero_asid;
45342
45343 - atomic_long_t copy_gpa;
45344 - atomic_long_t read_gpa;
45345 + atomic_long_unchecked_t copy_gpa;
45346 + atomic_long_unchecked_t read_gpa;
45347
45348 - atomic_long_t mesq_receive;
45349 - atomic_long_t mesq_receive_none;
45350 - atomic_long_t mesq_send;
45351 - atomic_long_t mesq_send_failed;
45352 - atomic_long_t mesq_noop;
45353 - atomic_long_t mesq_send_unexpected_error;
45354 - atomic_long_t mesq_send_lb_overflow;
45355 - atomic_long_t mesq_send_qlimit_reached;
45356 - atomic_long_t mesq_send_amo_nacked;
45357 - atomic_long_t mesq_send_put_nacked;
45358 - atomic_long_t mesq_page_overflow;
45359 - atomic_long_t mesq_qf_locked;
45360 - atomic_long_t mesq_qf_noop_not_full;
45361 - atomic_long_t mesq_qf_switch_head_failed;
45362 - atomic_long_t mesq_qf_unexpected_error;
45363 - atomic_long_t mesq_noop_unexpected_error;
45364 - atomic_long_t mesq_noop_lb_overflow;
45365 - atomic_long_t mesq_noop_qlimit_reached;
45366 - atomic_long_t mesq_noop_amo_nacked;
45367 - atomic_long_t mesq_noop_put_nacked;
45368 - atomic_long_t mesq_noop_page_overflow;
45369 + atomic_long_unchecked_t mesq_receive;
45370 + atomic_long_unchecked_t mesq_receive_none;
45371 + atomic_long_unchecked_t mesq_send;
45372 + atomic_long_unchecked_t mesq_send_failed;
45373 + atomic_long_unchecked_t mesq_noop;
45374 + atomic_long_unchecked_t mesq_send_unexpected_error;
45375 + atomic_long_unchecked_t mesq_send_lb_overflow;
45376 + atomic_long_unchecked_t mesq_send_qlimit_reached;
45377 + atomic_long_unchecked_t mesq_send_amo_nacked;
45378 + atomic_long_unchecked_t mesq_send_put_nacked;
45379 + atomic_long_unchecked_t mesq_page_overflow;
45380 + atomic_long_unchecked_t mesq_qf_locked;
45381 + atomic_long_unchecked_t mesq_qf_noop_not_full;
45382 + atomic_long_unchecked_t mesq_qf_switch_head_failed;
45383 + atomic_long_unchecked_t mesq_qf_unexpected_error;
45384 + atomic_long_unchecked_t mesq_noop_unexpected_error;
45385 + atomic_long_unchecked_t mesq_noop_lb_overflow;
45386 + atomic_long_unchecked_t mesq_noop_qlimit_reached;
45387 + atomic_long_unchecked_t mesq_noop_amo_nacked;
45388 + atomic_long_unchecked_t mesq_noop_put_nacked;
45389 + atomic_long_unchecked_t mesq_noop_page_overflow;
45390
45391 };
45392
45393 @@ -251,8 +251,8 @@ enum mcs_op {cchop_allocate, cchop_start, cchop_interrupt, cchop_interrupt_sync,
45394 tghop_invalidate, mcsop_last};
45395
45396 struct mcs_op_statistic {
45397 - atomic_long_t count;
45398 - atomic_long_t total;
45399 + atomic_long_unchecked_t count;
45400 + atomic_long_unchecked_t total;
45401 unsigned long max;
45402 };
45403
45404 @@ -275,7 +275,7 @@ extern struct mcs_op_statistic mcs_op_statistics[mcsop_last];
45405
45406 #define STAT(id) do { \
45407 if (gru_options & OPT_STATS) \
45408 - atomic_long_inc(&gru_stats.id); \
45409 + atomic_long_inc_unchecked(&gru_stats.id); \
45410 } while (0)
45411
45412 #ifdef CONFIG_SGI_GRU_DEBUG
45413 diff --git a/drivers/misc/sgi-xp/xp.h b/drivers/misc/sgi-xp/xp.h
45414 index c862cd4..0d176fe 100644
45415 --- a/drivers/misc/sgi-xp/xp.h
45416 +++ b/drivers/misc/sgi-xp/xp.h
45417 @@ -288,7 +288,7 @@ struct xpc_interface {
45418 xpc_notify_func, void *);
45419 void (*received) (short, int, void *);
45420 enum xp_retval (*partid_to_nasids) (short, void *);
45421 -};
45422 +} __no_const;
45423
45424 extern struct xpc_interface xpc_interface;
45425
45426 diff --git a/drivers/misc/sgi-xp/xp_main.c b/drivers/misc/sgi-xp/xp_main.c
45427 index 01be66d..e3a0c7e 100644
45428 --- a/drivers/misc/sgi-xp/xp_main.c
45429 +++ b/drivers/misc/sgi-xp/xp_main.c
45430 @@ -78,13 +78,13 @@ xpc_notloaded(void)
45431 }
45432
45433 struct xpc_interface xpc_interface = {
45434 - (void (*)(int))xpc_notloaded,
45435 - (void (*)(int))xpc_notloaded,
45436 - (enum xp_retval(*)(short, int, u32, void *, u16))xpc_notloaded,
45437 - (enum xp_retval(*)(short, int, u32, void *, u16, xpc_notify_func,
45438 + .connect = (void (*)(int))xpc_notloaded,
45439 + .disconnect = (void (*)(int))xpc_notloaded,
45440 + .send = (enum xp_retval(*)(short, int, u32, void *, u16))xpc_notloaded,
45441 + .send_notify = (enum xp_retval(*)(short, int, u32, void *, u16, xpc_notify_func,
45442 void *))xpc_notloaded,
45443 - (void (*)(short, int, void *))xpc_notloaded,
45444 - (enum xp_retval(*)(short, void *))xpc_notloaded
45445 + .received = (void (*)(short, int, void *))xpc_notloaded,
45446 + .partid_to_nasids = (enum xp_retval(*)(short, void *))xpc_notloaded
45447 };
45448 EXPORT_SYMBOL_GPL(xpc_interface);
45449
45450 diff --git a/drivers/misc/sgi-xp/xpc.h b/drivers/misc/sgi-xp/xpc.h
45451 index b94d5f7..7f494c5 100644
45452 --- a/drivers/misc/sgi-xp/xpc.h
45453 +++ b/drivers/misc/sgi-xp/xpc.h
45454 @@ -835,6 +835,7 @@ struct xpc_arch_operations {
45455 void (*received_payload) (struct xpc_channel *, void *);
45456 void (*notify_senders_of_disconnect) (struct xpc_channel *);
45457 };
45458 +typedef struct xpc_arch_operations __no_const xpc_arch_operations_no_const;
45459
45460 /* struct xpc_partition act_state values (for XPC HB) */
45461
45462 @@ -876,7 +877,7 @@ extern struct xpc_registration xpc_registrations[];
45463 /* found in xpc_main.c */
45464 extern struct device *xpc_part;
45465 extern struct device *xpc_chan;
45466 -extern struct xpc_arch_operations xpc_arch_ops;
45467 +extern xpc_arch_operations_no_const xpc_arch_ops;
45468 extern int xpc_disengage_timelimit;
45469 extern int xpc_disengage_timedout;
45470 extern int xpc_activate_IRQ_rcvd;
45471 diff --git a/drivers/misc/sgi-xp/xpc_main.c b/drivers/misc/sgi-xp/xpc_main.c
45472 index 82dc574..8539ab2 100644
45473 --- a/drivers/misc/sgi-xp/xpc_main.c
45474 +++ b/drivers/misc/sgi-xp/xpc_main.c
45475 @@ -166,7 +166,7 @@ static struct notifier_block xpc_die_notifier = {
45476 .notifier_call = xpc_system_die,
45477 };
45478
45479 -struct xpc_arch_operations xpc_arch_ops;
45480 +xpc_arch_operations_no_const xpc_arch_ops;
45481
45482 /*
45483 * Timer function to enforce the timelimit on the partition disengage.
45484 @@ -1210,7 +1210,7 @@ xpc_system_die(struct notifier_block *nb, unsigned long event, void *_die_args)
45485
45486 if (((die_args->trapnr == X86_TRAP_MF) ||
45487 (die_args->trapnr == X86_TRAP_XF)) &&
45488 - !user_mode_vm(die_args->regs))
45489 + !user_mode(die_args->regs))
45490 xpc_die_deactivate();
45491
45492 break;
45493 diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c
45494 index 452782b..0c10e40 100644
45495 --- a/drivers/mmc/card/block.c
45496 +++ b/drivers/mmc/card/block.c
45497 @@ -574,7 +574,7 @@ static int mmc_blk_ioctl_cmd(struct block_device *bdev,
45498 if (idata->ic.postsleep_min_us)
45499 usleep_range(idata->ic.postsleep_min_us, idata->ic.postsleep_max_us);
45500
45501 - if (copy_to_user(&(ic_ptr->response), cmd.resp, sizeof(cmd.resp))) {
45502 + if (copy_to_user(ic_ptr->response, cmd.resp, sizeof(cmd.resp))) {
45503 err = -EFAULT;
45504 goto cmd_rel_host;
45505 }
45506 diff --git a/drivers/mmc/core/mmc_ops.c b/drivers/mmc/core/mmc_ops.c
45507 index f51b5ba..86614a7 100644
45508 --- a/drivers/mmc/core/mmc_ops.c
45509 +++ b/drivers/mmc/core/mmc_ops.c
45510 @@ -247,7 +247,7 @@ mmc_send_cxd_data(struct mmc_card *card, struct mmc_host *host,
45511 void *data_buf;
45512 int is_on_stack;
45513
45514 - is_on_stack = object_is_on_stack(buf);
45515 + is_on_stack = object_starts_on_stack(buf);
45516 if (is_on_stack) {
45517 /*
45518 * dma onto stack is unsafe/nonportable, but callers to this
45519 diff --git a/drivers/mmc/host/dw_mmc.h b/drivers/mmc/host/dw_mmc.h
45520 index 6834977..824ee1b 100644
45521 --- a/drivers/mmc/host/dw_mmc.h
45522 +++ b/drivers/mmc/host/dw_mmc.h
45523 @@ -259,5 +259,5 @@ struct dw_mci_drv_data {
45524 int (*parse_dt)(struct dw_mci *host);
45525 int (*execute_tuning)(struct dw_mci_slot *slot, u32 opcode,
45526 struct dw_mci_tuning_data *tuning_data);
45527 -};
45528 +} __do_const;
45529 #endif /* _DW_MMC_H_ */
45530 diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c
45531 index 771c60a..12cb615 100644
45532 --- a/drivers/mmc/host/mmci.c
45533 +++ b/drivers/mmc/host/mmci.c
45534 @@ -1570,7 +1570,9 @@ static int mmci_probe(struct amba_device *dev,
45535 mmc->caps2 = plat->capabilities2;
45536
45537 if (variant->busy_detect) {
45538 - mmci_ops.card_busy = mmci_card_busy;
45539 + pax_open_kernel();
45540 + *(void **)&mmci_ops.card_busy = mmci_card_busy;
45541 + pax_close_kernel();
45542 mmci_write_datactrlreg(host, MCI_ST_DPSM_BUSYMODE);
45543 mmc->caps |= MMC_CAP_WAIT_WHILE_BUSY;
45544 mmc->max_busy_timeout = 0;
45545 diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c b/drivers/mmc/host/sdhci-esdhc-imx.c
45546 index b841bb7..d82712f5 100644
45547 --- a/drivers/mmc/host/sdhci-esdhc-imx.c
45548 +++ b/drivers/mmc/host/sdhci-esdhc-imx.c
45549 @@ -1031,9 +1031,12 @@ static int sdhci_esdhc_imx_probe(struct platform_device *pdev)
45550 host->mmc->caps |= MMC_CAP_1_8V_DDR;
45551 }
45552
45553 - if (imx_data->socdata->flags & ESDHC_FLAG_MAN_TUNING)
45554 - sdhci_esdhc_ops.platform_execute_tuning =
45555 + if (imx_data->socdata->flags & ESDHC_FLAG_MAN_TUNING) {
45556 + pax_open_kernel();
45557 + *(void **)&sdhci_esdhc_ops.platform_execute_tuning =
45558 esdhc_executing_tuning;
45559 + pax_close_kernel();
45560 + }
45561
45562 if (imx_data->socdata->flags & ESDHC_FLAG_STD_TUNING)
45563 writel(readl(host->ioaddr + ESDHC_TUNING_CTRL) |
45564 diff --git a/drivers/mmc/host/sdhci-s3c.c b/drivers/mmc/host/sdhci-s3c.c
45565 index d61eb5a..88c0f5d 100644
45566 --- a/drivers/mmc/host/sdhci-s3c.c
45567 +++ b/drivers/mmc/host/sdhci-s3c.c
45568 @@ -657,9 +657,11 @@ static int sdhci_s3c_probe(struct platform_device *pdev)
45569 * we can use overriding functions instead of default.
45570 */
45571 if (host->quirks & SDHCI_QUIRK_NONSTANDARD_CLOCK) {
45572 - sdhci_s3c_ops.set_clock = sdhci_cmu_set_clock;
45573 - sdhci_s3c_ops.get_min_clock = sdhci_cmu_get_min_clock;
45574 - sdhci_s3c_ops.get_max_clock = sdhci_cmu_get_max_clock;
45575 + pax_open_kernel();
45576 + *(void **)&sdhci_s3c_ops.set_clock = sdhci_cmu_set_clock;
45577 + *(void **)&sdhci_s3c_ops.get_min_clock = sdhci_cmu_get_min_clock;
45578 + *(void **)&sdhci_s3c_ops.get_max_clock = sdhci_cmu_get_max_clock;
45579 + pax_close_kernel();
45580 }
45581
45582 /* It supports additional host capabilities if needed */
45583 diff --git a/drivers/mtd/chips/cfi_cmdset_0020.c b/drivers/mtd/chips/cfi_cmdset_0020.c
45584 index 6293855..3415551 100644
45585 --- a/drivers/mtd/chips/cfi_cmdset_0020.c
45586 +++ b/drivers/mtd/chips/cfi_cmdset_0020.c
45587 @@ -666,7 +666,7 @@ cfi_staa_writev(struct mtd_info *mtd, const struct kvec *vecs,
45588 size_t totlen = 0, thislen;
45589 int ret = 0;
45590 size_t buflen = 0;
45591 - static char *buffer;
45592 + char *buffer;
45593
45594 if (!ECCBUF_SIZE) {
45595 /* We should fall back to a general writev implementation.
45596 diff --git a/drivers/mtd/nand/denali.c b/drivers/mtd/nand/denali.c
45597 index c07cd57..61c4fbd 100644
45598 --- a/drivers/mtd/nand/denali.c
45599 +++ b/drivers/mtd/nand/denali.c
45600 @@ -24,6 +24,7 @@
45601 #include <linux/slab.h>
45602 #include <linux/mtd/mtd.h>
45603 #include <linux/module.h>
45604 +#include <linux/slab.h>
45605
45606 #include "denali.h"
45607
45608 diff --git a/drivers/mtd/nand/gpmi-nand/gpmi-nand.c b/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
45609 index bb77f75..47539b1 100644
45610 --- a/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
45611 +++ b/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
45612 @@ -370,7 +370,7 @@ void prepare_data_dma(struct gpmi_nand_data *this, enum dma_data_direction dr)
45613
45614 /* first try to map the upper buffer directly */
45615 if (virt_addr_valid(this->upper_buf) &&
45616 - !object_is_on_stack(this->upper_buf)) {
45617 + !object_starts_on_stack(this->upper_buf)) {
45618 sg_init_one(sgl, this->upper_buf, this->upper_len);
45619 ret = dma_map_sg(this->dev, sgl, 1, dr);
45620 if (ret == 0)
45621 diff --git a/drivers/mtd/nftlmount.c b/drivers/mtd/nftlmount.c
45622 index 51b9d6a..52af9a7 100644
45623 --- a/drivers/mtd/nftlmount.c
45624 +++ b/drivers/mtd/nftlmount.c
45625 @@ -24,6 +24,7 @@
45626 #include <asm/errno.h>
45627 #include <linux/delay.h>
45628 #include <linux/slab.h>
45629 +#include <linux/sched.h>
45630 #include <linux/mtd/mtd.h>
45631 #include <linux/mtd/nand.h>
45632 #include <linux/mtd/nftl.h>
45633 diff --git a/drivers/mtd/sm_ftl.c b/drivers/mtd/sm_ftl.c
45634 index cf49c22..971b133 100644
45635 --- a/drivers/mtd/sm_ftl.c
45636 +++ b/drivers/mtd/sm_ftl.c
45637 @@ -56,7 +56,7 @@ static ssize_t sm_attr_show(struct device *dev, struct device_attribute *attr,
45638 #define SM_CIS_VENDOR_OFFSET 0x59
45639 static struct attribute_group *sm_create_sysfs_attributes(struct sm_ftl *ftl)
45640 {
45641 - struct attribute_group *attr_group;
45642 + attribute_group_no_const *attr_group;
45643 struct attribute **attributes;
45644 struct sm_sysfs_attribute *vendor_attribute;
45645 char *vendor;
45646 diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
45647 index d3a6789..198ec21 100644
45648 --- a/drivers/net/bonding/bond_main.c
45649 +++ b/drivers/net/bonding/bond_main.c
45650 @@ -4504,6 +4504,7 @@ static void __exit bonding_exit(void)
45651
45652 bond_netlink_fini();
45653 unregister_pernet_subsys(&bond_net_ops);
45654 + rtnl_link_unregister(&bond_link_ops);
45655
45656 #ifdef CONFIG_NET_POLL_CONTROLLER
45657 /*
45658 diff --git a/drivers/net/bonding/bond_netlink.c b/drivers/net/bonding/bond_netlink.c
45659 index f847e16..fc8dbe9 100644
45660 --- a/drivers/net/bonding/bond_netlink.c
45661 +++ b/drivers/net/bonding/bond_netlink.c
45662 @@ -542,7 +542,7 @@ nla_put_failure:
45663 return -EMSGSIZE;
45664 }
45665
45666 -struct rtnl_link_ops bond_link_ops __read_mostly = {
45667 +struct rtnl_link_ops bond_link_ops = {
45668 .kind = "bond",
45669 .priv_size = sizeof(struct bonding),
45670 .setup = bond_setup,
45671 diff --git a/drivers/net/can/Kconfig b/drivers/net/can/Kconfig
45672 index 9e7d95d..d447b88 100644
45673 --- a/drivers/net/can/Kconfig
45674 +++ b/drivers/net/can/Kconfig
45675 @@ -104,7 +104,7 @@ config CAN_JANZ_ICAN3
45676
45677 config CAN_FLEXCAN
45678 tristate "Support for Freescale FLEXCAN based chips"
45679 - depends on ARM || PPC
45680 + depends on (ARM && CPU_LITTLE_ENDIAN) || PPC
45681 ---help---
45682 Say Y here if you want to support for Freescale FlexCAN.
45683
45684 diff --git a/drivers/net/ethernet/8390/ax88796.c b/drivers/net/ethernet/8390/ax88796.c
45685 index 455d4c3..3353ee7 100644
45686 --- a/drivers/net/ethernet/8390/ax88796.c
45687 +++ b/drivers/net/ethernet/8390/ax88796.c
45688 @@ -889,9 +889,11 @@ static int ax_probe(struct platform_device *pdev)
45689 if (ax->plat->reg_offsets)
45690 ei_local->reg_offset = ax->plat->reg_offsets;
45691 else {
45692 + resource_size_t _mem_size = mem_size;
45693 + do_div(_mem_size, 0x18);
45694 ei_local->reg_offset = ax->reg_offsets;
45695 for (ret = 0; ret < 0x18; ret++)
45696 - ax->reg_offsets[ret] = (mem_size / 0x18) * ret;
45697 + ax->reg_offsets[ret] = _mem_size * ret;
45698 }
45699
45700 if (!request_mem_region(mem->start, mem_size, pdev->name)) {
45701 diff --git a/drivers/net/ethernet/altera/altera_tse_main.c b/drivers/net/ethernet/altera/altera_tse_main.c
45702 index 7330681..7e9e463 100644
45703 --- a/drivers/net/ethernet/altera/altera_tse_main.c
45704 +++ b/drivers/net/ethernet/altera/altera_tse_main.c
45705 @@ -1182,7 +1182,7 @@ static int tse_shutdown(struct net_device *dev)
45706 return 0;
45707 }
45708
45709 -static struct net_device_ops altera_tse_netdev_ops = {
45710 +static net_device_ops_no_const altera_tse_netdev_ops __read_only = {
45711 .ndo_open = tse_open,
45712 .ndo_stop = tse_shutdown,
45713 .ndo_start_xmit = tse_start_xmit,
45714 @@ -1439,11 +1439,13 @@ static int altera_tse_probe(struct platform_device *pdev)
45715 ndev->netdev_ops = &altera_tse_netdev_ops;
45716 altera_tse_set_ethtool_ops(ndev);
45717
45718 + pax_open_kernel();
45719 altera_tse_netdev_ops.ndo_set_rx_mode = tse_set_rx_mode;
45720
45721 if (priv->hash_filter)
45722 altera_tse_netdev_ops.ndo_set_rx_mode =
45723 tse_set_rx_mode_hashfilter;
45724 + pax_close_kernel();
45725
45726 /* Scatter/gather IO is not supported,
45727 * so it is turned off
45728 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
45729 index 3448cc0..67b2dc4 100644
45730 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
45731 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
45732 @@ -1058,7 +1058,7 @@ static inline u8 bnx2x_get_path_func_num(struct bnx2x *bp)
45733 static inline void bnx2x_init_bp_objs(struct bnx2x *bp)
45734 {
45735 /* RX_MODE controlling object */
45736 - bnx2x_init_rx_mode_obj(bp, &bp->rx_mode_obj);
45737 + bnx2x_init_rx_mode_obj(bp);
45738
45739 /* multicast configuration controlling object */
45740 bnx2x_init_mcast_obj(bp, &bp->mcast_obj, bp->fp->cl_id, bp->fp->cid,
45741 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
45742 index 31297266..944cf6e 100644
45743 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
45744 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
45745 @@ -2329,15 +2329,14 @@ int bnx2x_config_rx_mode(struct bnx2x *bp,
45746 return rc;
45747 }
45748
45749 -void bnx2x_init_rx_mode_obj(struct bnx2x *bp,
45750 - struct bnx2x_rx_mode_obj *o)
45751 +void bnx2x_init_rx_mode_obj(struct bnx2x *bp)
45752 {
45753 if (CHIP_IS_E1x(bp)) {
45754 - o->wait_comp = bnx2x_empty_rx_mode_wait;
45755 - o->config_rx_mode = bnx2x_set_rx_mode_e1x;
45756 + bp->rx_mode_obj.wait_comp = bnx2x_empty_rx_mode_wait;
45757 + bp->rx_mode_obj.config_rx_mode = bnx2x_set_rx_mode_e1x;
45758 } else {
45759 - o->wait_comp = bnx2x_wait_rx_mode_comp_e2;
45760 - o->config_rx_mode = bnx2x_set_rx_mode_e2;
45761 + bp->rx_mode_obj.wait_comp = bnx2x_wait_rx_mode_comp_e2;
45762 + bp->rx_mode_obj.config_rx_mode = bnx2x_set_rx_mode_e2;
45763 }
45764 }
45765
45766 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
45767 index 80f6c79..fb7d12d 100644
45768 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
45769 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
45770 @@ -1340,8 +1340,7 @@ int bnx2x_vlan_mac_move(struct bnx2x *bp,
45771
45772 /********************* RX MODE ****************/
45773
45774 -void bnx2x_init_rx_mode_obj(struct bnx2x *bp,
45775 - struct bnx2x_rx_mode_obj *o);
45776 +void bnx2x_init_rx_mode_obj(struct bnx2x *bp);
45777
45778 /**
45779 * bnx2x_config_rx_mode - Send and RX_MODE ramrod according to the provided parameters.
45780 diff --git a/drivers/net/ethernet/broadcom/tg3.h b/drivers/net/ethernet/broadcom/tg3.h
45781 index 04321e5..b51cdc4 100644
45782 --- a/drivers/net/ethernet/broadcom/tg3.h
45783 +++ b/drivers/net/ethernet/broadcom/tg3.h
45784 @@ -150,6 +150,7 @@
45785 #define CHIPREV_ID_5750_A0 0x4000
45786 #define CHIPREV_ID_5750_A1 0x4001
45787 #define CHIPREV_ID_5750_A3 0x4003
45788 +#define CHIPREV_ID_5750_C1 0x4201
45789 #define CHIPREV_ID_5750_C2 0x4202
45790 #define CHIPREV_ID_5752_A0_HW 0x5000
45791 #define CHIPREV_ID_5752_A0 0x6000
45792 diff --git a/drivers/net/ethernet/brocade/bna/bna_enet.c b/drivers/net/ethernet/brocade/bna/bna_enet.c
45793 index 13f9636..228040f 100644
45794 --- a/drivers/net/ethernet/brocade/bna/bna_enet.c
45795 +++ b/drivers/net/ethernet/brocade/bna/bna_enet.c
45796 @@ -1690,10 +1690,10 @@ bna_cb_ioceth_reset(void *arg)
45797 }
45798
45799 static struct bfa_ioc_cbfn bna_ioceth_cbfn = {
45800 - bna_cb_ioceth_enable,
45801 - bna_cb_ioceth_disable,
45802 - bna_cb_ioceth_hbfail,
45803 - bna_cb_ioceth_reset
45804 + .enable_cbfn = bna_cb_ioceth_enable,
45805 + .disable_cbfn = bna_cb_ioceth_disable,
45806 + .hbfail_cbfn = bna_cb_ioceth_hbfail,
45807 + .reset_cbfn = bna_cb_ioceth_reset
45808 };
45809
45810 static void bna_attr_init(struct bna_ioceth *ioceth)
45811 diff --git a/drivers/net/ethernet/chelsio/cxgb3/l2t.h b/drivers/net/ethernet/chelsio/cxgb3/l2t.h
45812 index 8cffcdf..aadf043 100644
45813 --- a/drivers/net/ethernet/chelsio/cxgb3/l2t.h
45814 +++ b/drivers/net/ethernet/chelsio/cxgb3/l2t.h
45815 @@ -87,7 +87,7 @@ typedef void (*arp_failure_handler_func)(struct t3cdev * dev,
45816 */
45817 struct l2t_skb_cb {
45818 arp_failure_handler_func arp_failure_handler;
45819 -};
45820 +} __no_const;
45821
45822 #define L2T_SKB_CB(skb) ((struct l2t_skb_cb *)(skb)->cb)
45823
45824 diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
45825 index 24e16e3..bfe6ef2 100644
45826 --- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
45827 +++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
45828 @@ -2139,7 +2139,7 @@ static void get_regs(struct net_device *dev, struct ethtool_regs *regs,
45829
45830 int i;
45831 struct adapter *ap = netdev2adap(dev);
45832 - static const unsigned int *reg_ranges;
45833 + const unsigned int *reg_ranges;
45834 int arr_size = 0, buf_size = 0;
45835
45836 if (is_t4(ap->params.chip)) {
45837 diff --git a/drivers/net/ethernet/dec/tulip/de4x5.c b/drivers/net/ethernet/dec/tulip/de4x5.c
45838 index c05b66d..ed69872 100644
45839 --- a/drivers/net/ethernet/dec/tulip/de4x5.c
45840 +++ b/drivers/net/ethernet/dec/tulip/de4x5.c
45841 @@ -5388,7 +5388,7 @@ de4x5_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
45842 for (i=0; i<ETH_ALEN; i++) {
45843 tmp.addr[i] = dev->dev_addr[i];
45844 }
45845 - if (copy_to_user(ioc->data, tmp.addr, ioc->len)) return -EFAULT;
45846 + if (ioc->len > sizeof tmp.addr || copy_to_user(ioc->data, tmp.addr, ioc->len)) return -EFAULT;
45847 break;
45848
45849 case DE4X5_SET_HWADDR: /* Set the hardware address */
45850 @@ -5428,7 +5428,7 @@ de4x5_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
45851 spin_lock_irqsave(&lp->lock, flags);
45852 memcpy(&statbuf, &lp->pktStats, ioc->len);
45853 spin_unlock_irqrestore(&lp->lock, flags);
45854 - if (copy_to_user(ioc->data, &statbuf, ioc->len))
45855 + if (ioc->len > sizeof statbuf || copy_to_user(ioc->data, &statbuf, ioc->len))
45856 return -EFAULT;
45857 break;
45858 }
45859 diff --git a/drivers/net/ethernet/emulex/benet/be_main.c b/drivers/net/ethernet/emulex/benet/be_main.c
45860 index dc19bc5..f2d4548 100644
45861 --- a/drivers/net/ethernet/emulex/benet/be_main.c
45862 +++ b/drivers/net/ethernet/emulex/benet/be_main.c
45863 @@ -535,7 +535,7 @@ static void accumulate_16bit_val(u32 *acc, u16 val)
45864
45865 if (wrapped)
45866 newacc += 65536;
45867 - ACCESS_ONCE(*acc) = newacc;
45868 + ACCESS_ONCE_RW(*acc) = newacc;
45869 }
45870
45871 static void populate_erx_stats(struct be_adapter *adapter,
45872 diff --git a/drivers/net/ethernet/faraday/ftgmac100.c b/drivers/net/ethernet/faraday/ftgmac100.c
45873 index 68069ea..c4484f6 100644
45874 --- a/drivers/net/ethernet/faraday/ftgmac100.c
45875 +++ b/drivers/net/ethernet/faraday/ftgmac100.c
45876 @@ -30,6 +30,8 @@
45877 #include <linux/netdevice.h>
45878 #include <linux/phy.h>
45879 #include <linux/platform_device.h>
45880 +#include <linux/interrupt.h>
45881 +#include <linux/irqreturn.h>
45882 #include <net/ip.h>
45883
45884 #include "ftgmac100.h"
45885 diff --git a/drivers/net/ethernet/faraday/ftmac100.c b/drivers/net/ethernet/faraday/ftmac100.c
45886 index 8be5b40..081bc1b 100644
45887 --- a/drivers/net/ethernet/faraday/ftmac100.c
45888 +++ b/drivers/net/ethernet/faraday/ftmac100.c
45889 @@ -31,6 +31,8 @@
45890 #include <linux/module.h>
45891 #include <linux/netdevice.h>
45892 #include <linux/platform_device.h>
45893 +#include <linux/interrupt.h>
45894 +#include <linux/irqreturn.h>
45895
45896 #include "ftmac100.h"
45897
45898 diff --git a/drivers/net/ethernet/intel/i40e/i40e_ptp.c b/drivers/net/ethernet/intel/i40e/i40e_ptp.c
45899 index e61e637..9117795 100644
45900 --- a/drivers/net/ethernet/intel/i40e/i40e_ptp.c
45901 +++ b/drivers/net/ethernet/intel/i40e/i40e_ptp.c
45902 @@ -436,7 +436,7 @@ void i40e_ptp_set_increment(struct i40e_pf *pf)
45903 wr32(hw, I40E_PRTTSYN_INC_H, incval >> 32);
45904
45905 /* Update the base adjustement value. */
45906 - ACCESS_ONCE(pf->ptp_base_adj) = incval;
45907 + ACCESS_ONCE_RW(pf->ptp_base_adj) = incval;
45908 smp_mb(); /* Force the above update. */
45909 }
45910
45911 diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
45912 index 8902ae6..e7bcdce 100644
45913 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
45914 +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
45915 @@ -771,7 +771,7 @@ void ixgbe_ptp_start_cyclecounter(struct ixgbe_adapter *adapter)
45916 }
45917
45918 /* update the base incval used to calculate frequency adjustment */
45919 - ACCESS_ONCE(adapter->base_incval) = incval;
45920 + ACCESS_ONCE_RW(adapter->base_incval) = incval;
45921 smp_mb();
45922
45923 /* need lock to prevent incorrect read while modifying cyclecounter */
45924 diff --git a/drivers/net/ethernet/neterion/vxge/vxge-config.c b/drivers/net/ethernet/neterion/vxge/vxge-config.c
45925 index 089b713..28d87ae 100644
45926 --- a/drivers/net/ethernet/neterion/vxge/vxge-config.c
45927 +++ b/drivers/net/ethernet/neterion/vxge/vxge-config.c
45928 @@ -3461,7 +3461,10 @@ __vxge_hw_fifo_create(struct __vxge_hw_vpath_handle *vp,
45929 struct __vxge_hw_fifo *fifo;
45930 struct vxge_hw_fifo_config *config;
45931 u32 txdl_size, txdl_per_memblock;
45932 - struct vxge_hw_mempool_cbs fifo_mp_callback;
45933 + static struct vxge_hw_mempool_cbs fifo_mp_callback = {
45934 + .item_func_alloc = __vxge_hw_fifo_mempool_item_alloc,
45935 + };
45936 +
45937 struct __vxge_hw_virtualpath *vpath;
45938
45939 if ((vp == NULL) || (attr == NULL)) {
45940 @@ -3544,8 +3547,6 @@ __vxge_hw_fifo_create(struct __vxge_hw_vpath_handle *vp,
45941 goto exit;
45942 }
45943
45944 - fifo_mp_callback.item_func_alloc = __vxge_hw_fifo_mempool_item_alloc;
45945 -
45946 fifo->mempool =
45947 __vxge_hw_mempool_create(vpath->hldev,
45948 fifo->config->memblock_size,
45949 diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c
45950 index ba20c72..f30c0fe 100644
45951 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c
45952 +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c
45953 @@ -2176,7 +2176,9 @@ int qlcnic_83xx_configure_opmode(struct qlcnic_adapter *adapter)
45954 max_tx_rings = QLCNIC_MAX_VNIC_TX_RINGS;
45955 } else if (ret == QLC_83XX_DEFAULT_OPMODE) {
45956 ahw->nic_mode = QLCNIC_DEFAULT_MODE;
45957 - adapter->nic_ops->init_driver = qlcnic_83xx_init_default_driver;
45958 + pax_open_kernel();
45959 + *(void **)&adapter->nic_ops->init_driver = qlcnic_83xx_init_default_driver;
45960 + pax_close_kernel();
45961 ahw->idc.state_entry = qlcnic_83xx_idc_ready_state_entry;
45962 max_sds_rings = QLCNIC_MAX_SDS_RINGS;
45963 max_tx_rings = QLCNIC_MAX_TX_RINGS;
45964 diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c
45965 index be7d7a6..a8983f8 100644
45966 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c
45967 +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c
45968 @@ -207,17 +207,23 @@ int qlcnic_83xx_config_vnic_opmode(struct qlcnic_adapter *adapter)
45969 case QLCNIC_NON_PRIV_FUNC:
45970 ahw->op_mode = QLCNIC_NON_PRIV_FUNC;
45971 ahw->idc.state_entry = qlcnic_83xx_idc_ready_state_entry;
45972 - nic_ops->init_driver = qlcnic_83xx_init_non_privileged_vnic;
45973 + pax_open_kernel();
45974 + *(void **)&nic_ops->init_driver = qlcnic_83xx_init_non_privileged_vnic;
45975 + pax_close_kernel();
45976 break;
45977 case QLCNIC_PRIV_FUNC:
45978 ahw->op_mode = QLCNIC_PRIV_FUNC;
45979 ahw->idc.state_entry = qlcnic_83xx_idc_vnic_pf_entry;
45980 - nic_ops->init_driver = qlcnic_83xx_init_privileged_vnic;
45981 + pax_open_kernel();
45982 + *(void **)&nic_ops->init_driver = qlcnic_83xx_init_privileged_vnic;
45983 + pax_close_kernel();
45984 break;
45985 case QLCNIC_MGMT_FUNC:
45986 ahw->op_mode = QLCNIC_MGMT_FUNC;
45987 ahw->idc.state_entry = qlcnic_83xx_idc_ready_state_entry;
45988 - nic_ops->init_driver = qlcnic_83xx_init_mgmt_vnic;
45989 + pax_open_kernel();
45990 + *(void **)&nic_ops->init_driver = qlcnic_83xx_init_mgmt_vnic;
45991 + pax_close_kernel();
45992 break;
45993 default:
45994 dev_err(&adapter->pdev->dev, "Invalid Virtual NIC opmode\n");
45995 diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_minidump.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_minidump.c
45996 index 37b979b..50f5b95 100644
45997 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_minidump.c
45998 +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_minidump.c
45999 @@ -1217,7 +1217,7 @@ flash_temp:
46000 int qlcnic_dump_fw(struct qlcnic_adapter *adapter)
46001 {
46002 struct qlcnic_fw_dump *fw_dump = &adapter->ahw->fw_dump;
46003 - static const struct qlcnic_dump_operations *fw_dump_ops;
46004 + const struct qlcnic_dump_operations *fw_dump_ops;
46005 struct qlcnic_83xx_dump_template_hdr *hdr_83xx;
46006 u32 entry_offset, dump, no_entries, buf_offset = 0;
46007 int i, k, ops_cnt, ops_index, dump_size = 0;
46008 diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c
46009 index aa1c079..2b1a3e8 100644
46010 --- a/drivers/net/ethernet/realtek/r8169.c
46011 +++ b/drivers/net/ethernet/realtek/r8169.c
46012 @@ -758,22 +758,22 @@ struct rtl8169_private {
46013 struct mdio_ops {
46014 void (*write)(struct rtl8169_private *, int, int);
46015 int (*read)(struct rtl8169_private *, int);
46016 - } mdio_ops;
46017 + } __no_const mdio_ops;
46018
46019 struct pll_power_ops {
46020 void (*down)(struct rtl8169_private *);
46021 void (*up)(struct rtl8169_private *);
46022 - } pll_power_ops;
46023 + } __no_const pll_power_ops;
46024
46025 struct jumbo_ops {
46026 void (*enable)(struct rtl8169_private *);
46027 void (*disable)(struct rtl8169_private *);
46028 - } jumbo_ops;
46029 + } __no_const jumbo_ops;
46030
46031 struct csi_ops {
46032 void (*write)(struct rtl8169_private *, int, int);
46033 u32 (*read)(struct rtl8169_private *, int);
46034 - } csi_ops;
46035 + } __no_const csi_ops;
46036
46037 int (*set_speed)(struct net_device *, u8 aneg, u16 sp, u8 dpx, u32 adv);
46038 int (*get_settings)(struct net_device *, struct ethtool_cmd *);
46039 diff --git a/drivers/net/ethernet/sfc/ptp.c b/drivers/net/ethernet/sfc/ptp.c
46040 index 6b861e3..204ac86 100644
46041 --- a/drivers/net/ethernet/sfc/ptp.c
46042 +++ b/drivers/net/ethernet/sfc/ptp.c
46043 @@ -822,7 +822,7 @@ static int efx_ptp_synchronize(struct efx_nic *efx, unsigned int num_readings)
46044 ptp->start.dma_addr);
46045
46046 /* Clear flag that signals MC ready */
46047 - ACCESS_ONCE(*start) = 0;
46048 + ACCESS_ONCE_RW(*start) = 0;
46049 rc = efx_mcdi_rpc_start(efx, MC_CMD_PTP, synch_buf,
46050 MC_CMD_PTP_IN_SYNCHRONIZE_LEN);
46051 EFX_BUG_ON_PARANOID(rc);
46052 diff --git a/drivers/net/ethernet/stmicro/stmmac/mmc_core.c b/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
46053 index 50617c5..b13724c 100644
46054 --- a/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
46055 +++ b/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
46056 @@ -140,8 +140,8 @@ void dwmac_mmc_ctrl(void __iomem *ioaddr, unsigned int mode)
46057
46058 writel(value, ioaddr + MMC_CNTRL);
46059
46060 - pr_debug("stmmac: MMC ctrl register (offset 0x%x): 0x%08x\n",
46061 - MMC_CNTRL, value);
46062 +// pr_debug("stmmac: MMC ctrl register (offset 0x%x): 0x%08x\n",
46063 +// MMC_CNTRL, value);
46064 }
46065
46066 /* To mask all all interrupts.*/
46067 diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h
46068 index d18f711d..5755800 100644
46069 --- a/drivers/net/hyperv/hyperv_net.h
46070 +++ b/drivers/net/hyperv/hyperv_net.h
46071 @@ -101,7 +101,7 @@ struct rndis_device {
46072
46073 enum rndis_device_state state;
46074 bool link_state;
46075 - atomic_t new_req_id;
46076 + atomic_unchecked_t new_req_id;
46077
46078 spinlock_t request_lock;
46079 struct list_head req_list;
46080 diff --git a/drivers/net/hyperv/rndis_filter.c b/drivers/net/hyperv/rndis_filter.c
46081 index 143a98c..d54fbaa 100644
46082 --- a/drivers/net/hyperv/rndis_filter.c
46083 +++ b/drivers/net/hyperv/rndis_filter.c
46084 @@ -100,7 +100,7 @@ static struct rndis_request *get_rndis_request(struct rndis_device *dev,
46085 * template
46086 */
46087 set = &rndis_msg->msg.set_req;
46088 - set->req_id = atomic_inc_return(&dev->new_req_id);
46089 + set->req_id = atomic_inc_return_unchecked(&dev->new_req_id);
46090
46091 /* Add to the request list */
46092 spin_lock_irqsave(&dev->request_lock, flags);
46093 @@ -834,7 +834,7 @@ static void rndis_filter_halt_device(struct rndis_device *dev)
46094
46095 /* Setup the rndis set */
46096 halt = &request->request_msg.msg.halt_req;
46097 - halt->req_id = atomic_inc_return(&dev->new_req_id);
46098 + halt->req_id = atomic_inc_return_unchecked(&dev->new_req_id);
46099
46100 /* Ignore return since this msg is optional. */
46101 rndis_filter_send_request(dev, request);
46102 diff --git a/drivers/net/ieee802154/fakehard.c b/drivers/net/ieee802154/fakehard.c
46103 index 78f18be..1d19c62 100644
46104 --- a/drivers/net/ieee802154/fakehard.c
46105 +++ b/drivers/net/ieee802154/fakehard.c
46106 @@ -364,7 +364,7 @@ static int ieee802154fake_probe(struct platform_device *pdev)
46107 phy->transmit_power = 0xbf;
46108
46109 dev->netdev_ops = &fake_ops;
46110 - dev->ml_priv = &fake_mlme;
46111 + dev->ml_priv = (void *)&fake_mlme;
46112
46113 priv = netdev_priv(dev);
46114 priv->phy = phy;
46115 diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c
46116 index d53e299..e99c458 100644
46117 --- a/drivers/net/macvlan.c
46118 +++ b/drivers/net/macvlan.c
46119 @@ -984,13 +984,15 @@ static const struct nla_policy macvlan_policy[IFLA_MACVLAN_MAX + 1] = {
46120 int macvlan_link_register(struct rtnl_link_ops *ops)
46121 {
46122 /* common fields */
46123 - ops->priv_size = sizeof(struct macvlan_dev);
46124 - ops->validate = macvlan_validate;
46125 - ops->maxtype = IFLA_MACVLAN_MAX;
46126 - ops->policy = macvlan_policy;
46127 - ops->changelink = macvlan_changelink;
46128 - ops->get_size = macvlan_get_size;
46129 - ops->fill_info = macvlan_fill_info;
46130 + pax_open_kernel();
46131 + *(size_t *)&ops->priv_size = sizeof(struct macvlan_dev);
46132 + *(void **)&ops->validate = macvlan_validate;
46133 + *(int *)&ops->maxtype = IFLA_MACVLAN_MAX;
46134 + *(const void **)&ops->policy = macvlan_policy;
46135 + *(void **)&ops->changelink = macvlan_changelink;
46136 + *(void **)&ops->get_size = macvlan_get_size;
46137 + *(void **)&ops->fill_info = macvlan_fill_info;
46138 + pax_close_kernel();
46139
46140 return rtnl_link_register(ops);
46141 };
46142 @@ -1045,7 +1047,7 @@ static int macvlan_device_event(struct notifier_block *unused,
46143 return NOTIFY_DONE;
46144 }
46145
46146 -static struct notifier_block macvlan_notifier_block __read_mostly = {
46147 +static struct notifier_block macvlan_notifier_block = {
46148 .notifier_call = macvlan_device_event,
46149 };
46150
46151 diff --git a/drivers/net/macvtap.c b/drivers/net/macvtap.c
46152 index 3381c4f..dea5fd5 100644
46153 --- a/drivers/net/macvtap.c
46154 +++ b/drivers/net/macvtap.c
46155 @@ -1020,7 +1020,7 @@ static long macvtap_ioctl(struct file *file, unsigned int cmd,
46156 }
46157
46158 ret = 0;
46159 - if (copy_to_user(&ifr->ifr_name, vlan->dev->name, IFNAMSIZ) ||
46160 + if (copy_to_user(ifr->ifr_name, vlan->dev->name, IFNAMSIZ) ||
46161 put_user(q->flags, &ifr->ifr_flags))
46162 ret = -EFAULT;
46163 macvtap_put_vlan(vlan);
46164 @@ -1190,7 +1190,7 @@ static int macvtap_device_event(struct notifier_block *unused,
46165 return NOTIFY_DONE;
46166 }
46167
46168 -static struct notifier_block macvtap_notifier_block __read_mostly = {
46169 +static struct notifier_block macvtap_notifier_block = {
46170 .notifier_call = macvtap_device_event,
46171 };
46172
46173 diff --git a/drivers/net/phy/mdio-bitbang.c b/drivers/net/phy/mdio-bitbang.c
46174 index daec9b0..6428fcb 100644
46175 --- a/drivers/net/phy/mdio-bitbang.c
46176 +++ b/drivers/net/phy/mdio-bitbang.c
46177 @@ -234,6 +234,7 @@ void free_mdio_bitbang(struct mii_bus *bus)
46178 struct mdiobb_ctrl *ctrl = bus->priv;
46179
46180 module_put(ctrl->ops->owner);
46181 + mdiobus_unregister(bus);
46182 mdiobus_free(bus);
46183 }
46184 EXPORT_SYMBOL(free_mdio_bitbang);
46185 diff --git a/drivers/net/ppp/ppp_generic.c b/drivers/net/ppp/ppp_generic.c
46186 index e3923eb..2a0373b 100644
46187 --- a/drivers/net/ppp/ppp_generic.c
46188 +++ b/drivers/net/ppp/ppp_generic.c
46189 @@ -1012,7 +1012,6 @@ ppp_net_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
46190 void __user *addr = (void __user *) ifr->ifr_ifru.ifru_data;
46191 struct ppp_stats stats;
46192 struct ppp_comp_stats cstats;
46193 - char *vers;
46194
46195 switch (cmd) {
46196 case SIOCGPPPSTATS:
46197 @@ -1034,8 +1033,7 @@ ppp_net_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
46198 break;
46199
46200 case SIOCGPPPVER:
46201 - vers = PPP_VERSION;
46202 - if (copy_to_user(addr, vers, strlen(vers) + 1))
46203 + if (copy_to_user(addr, PPP_VERSION, sizeof(PPP_VERSION)))
46204 break;
46205 err = 0;
46206 break;
46207 diff --git a/drivers/net/slip/slhc.c b/drivers/net/slip/slhc.c
46208 index 1252d9c..80e660b 100644
46209 --- a/drivers/net/slip/slhc.c
46210 +++ b/drivers/net/slip/slhc.c
46211 @@ -488,7 +488,7 @@ slhc_uncompress(struct slcompress *comp, unsigned char *icp, int isize)
46212 register struct tcphdr *thp;
46213 register struct iphdr *ip;
46214 register struct cstate *cs;
46215 - int len, hdrlen;
46216 + long len, hdrlen;
46217 unsigned char *cp = icp;
46218
46219 /* We've got a compressed packet; read the change byte */
46220 diff --git a/drivers/net/team/team.c b/drivers/net/team/team.c
46221 index ce4989b..b40b328 100644
46222 --- a/drivers/net/team/team.c
46223 +++ b/drivers/net/team/team.c
46224 @@ -2868,7 +2868,7 @@ static int team_device_event(struct notifier_block *unused,
46225 return NOTIFY_DONE;
46226 }
46227
46228 -static struct notifier_block team_notifier_block __read_mostly = {
46229 +static struct notifier_block team_notifier_block = {
46230 .notifier_call = team_device_event,
46231 };
46232
46233 diff --git a/drivers/net/tun.c b/drivers/net/tun.c
46234 index ee328ba..c4a0041 100644
46235 --- a/drivers/net/tun.c
46236 +++ b/drivers/net/tun.c
46237 @@ -1876,7 +1876,7 @@ unlock:
46238 }
46239
46240 static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
46241 - unsigned long arg, int ifreq_len)
46242 + unsigned long arg, size_t ifreq_len)
46243 {
46244 struct tun_file *tfile = file->private_data;
46245 struct tun_struct *tun;
46246 @@ -1889,6 +1889,9 @@ static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
46247 unsigned int ifindex;
46248 int ret;
46249
46250 + if (ifreq_len > sizeof ifr)
46251 + return -EFAULT;
46252 +
46253 if (cmd == TUNSETIFF || cmd == TUNSETQUEUE || _IOC_TYPE(cmd) == 0x89) {
46254 if (copy_from_user(&ifr, argp, ifreq_len))
46255 return -EFAULT;
46256 diff --git a/drivers/net/usb/hso.c b/drivers/net/usb/hso.c
46257 index 660bd5e..ac59452 100644
46258 --- a/drivers/net/usb/hso.c
46259 +++ b/drivers/net/usb/hso.c
46260 @@ -71,7 +71,7 @@
46261 #include <asm/byteorder.h>
46262 #include <linux/serial_core.h>
46263 #include <linux/serial.h>
46264 -
46265 +#include <asm/local.h>
46266
46267 #define MOD_AUTHOR "Option Wireless"
46268 #define MOD_DESCRIPTION "USB High Speed Option driver"
46269 @@ -1179,7 +1179,7 @@ static void put_rxbuf_data_and_resubmit_ctrl_urb(struct hso_serial *serial)
46270 struct urb *urb;
46271
46272 urb = serial->rx_urb[0];
46273 - if (serial->port.count > 0) {
46274 + if (atomic_read(&serial->port.count) > 0) {
46275 count = put_rxbuf_data(urb, serial);
46276 if (count == -1)
46277 return;
46278 @@ -1217,7 +1217,7 @@ static void hso_std_serial_read_bulk_callback(struct urb *urb)
46279 DUMP1(urb->transfer_buffer, urb->actual_length);
46280
46281 /* Anyone listening? */
46282 - if (serial->port.count == 0)
46283 + if (atomic_read(&serial->port.count) == 0)
46284 return;
46285
46286 if (serial->parent->port_spec & HSO_INFO_CRC_BUG)
46287 @@ -1287,8 +1287,7 @@ static int hso_serial_open(struct tty_struct *tty, struct file *filp)
46288 tty_port_tty_set(&serial->port, tty);
46289
46290 /* check for port already opened, if not set the termios */
46291 - serial->port.count++;
46292 - if (serial->port.count == 1) {
46293 + if (atomic_inc_return(&serial->port.count) == 1) {
46294 serial->rx_state = RX_IDLE;
46295 /* Force default termio settings */
46296 _hso_serial_set_termios(tty, NULL);
46297 @@ -1300,7 +1299,7 @@ static int hso_serial_open(struct tty_struct *tty, struct file *filp)
46298 result = hso_start_serial_device(serial->parent, GFP_KERNEL);
46299 if (result) {
46300 hso_stop_serial_device(serial->parent);
46301 - serial->port.count--;
46302 + atomic_dec(&serial->port.count);
46303 kref_put(&serial->parent->ref, hso_serial_ref_free);
46304 }
46305 } else {
46306 @@ -1337,10 +1336,10 @@ static void hso_serial_close(struct tty_struct *tty, struct file *filp)
46307
46308 /* reset the rts and dtr */
46309 /* do the actual close */
46310 - serial->port.count--;
46311 + atomic_dec(&serial->port.count);
46312
46313 - if (serial->port.count <= 0) {
46314 - serial->port.count = 0;
46315 + if (atomic_read(&serial->port.count) <= 0) {
46316 + atomic_set(&serial->port.count, 0);
46317 tty_port_tty_set(&serial->port, NULL);
46318 if (!usb_gone)
46319 hso_stop_serial_device(serial->parent);
46320 @@ -1416,7 +1415,7 @@ static void hso_serial_set_termios(struct tty_struct *tty, struct ktermios *old)
46321
46322 /* the actual setup */
46323 spin_lock_irqsave(&serial->serial_lock, flags);
46324 - if (serial->port.count)
46325 + if (atomic_read(&serial->port.count))
46326 _hso_serial_set_termios(tty, old);
46327 else
46328 tty->termios = *old;
46329 @@ -1885,7 +1884,7 @@ static void intr_callback(struct urb *urb)
46330 D1("Pending read interrupt on port %d\n", i);
46331 spin_lock(&serial->serial_lock);
46332 if (serial->rx_state == RX_IDLE &&
46333 - serial->port.count > 0) {
46334 + atomic_read(&serial->port.count) > 0) {
46335 /* Setup and send a ctrl req read on
46336 * port i */
46337 if (!serial->rx_urb_filled[0]) {
46338 @@ -3061,7 +3060,7 @@ static int hso_resume(struct usb_interface *iface)
46339 /* Start all serial ports */
46340 for (i = 0; i < HSO_SERIAL_TTY_MINORS; i++) {
46341 if (serial_table[i] && (serial_table[i]->interface == iface)) {
46342 - if (dev2ser(serial_table[i])->port.count) {
46343 + if (atomic_read(&dev2ser(serial_table[i])->port.count)) {
46344 result =
46345 hso_start_serial_device(serial_table[i], GFP_NOIO);
46346 hso_kick_transmit(dev2ser(serial_table[i]));
46347 diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c
46348 index 3fbfb08..2c16265 100644
46349 --- a/drivers/net/usb/r8152.c
46350 +++ b/drivers/net/usb/r8152.c
46351 @@ -567,7 +567,7 @@ struct r8152 {
46352 void (*up)(struct r8152 *);
46353 void (*down)(struct r8152 *);
46354 void (*unload)(struct r8152 *);
46355 - } rtl_ops;
46356 + } __no_const rtl_ops;
46357
46358 int intr_interval;
46359 u32 saved_wolopts;
46360 diff --git a/drivers/net/usb/sierra_net.c b/drivers/net/usb/sierra_net.c
46361 index a2515887..6d13233 100644
46362 --- a/drivers/net/usb/sierra_net.c
46363 +++ b/drivers/net/usb/sierra_net.c
46364 @@ -51,7 +51,7 @@ static const char driver_name[] = "sierra_net";
46365 /* atomic counter partially included in MAC address to make sure 2 devices
46366 * do not end up with the same MAC - concept breaks in case of > 255 ifaces
46367 */
46368 -static atomic_t iface_counter = ATOMIC_INIT(0);
46369 +static atomic_unchecked_t iface_counter = ATOMIC_INIT(0);
46370
46371 /*
46372 * SYNC Timer Delay definition used to set the expiry time
46373 @@ -697,7 +697,7 @@ static int sierra_net_bind(struct usbnet *dev, struct usb_interface *intf)
46374 dev->net->netdev_ops = &sierra_net_device_ops;
46375
46376 /* change MAC addr to include, ifacenum, and to be unique */
46377 - dev->net->dev_addr[ETH_ALEN-2] = atomic_inc_return(&iface_counter);
46378 + dev->net->dev_addr[ETH_ALEN-2] = atomic_inc_return_unchecked(&iface_counter);
46379 dev->net->dev_addr[ETH_ALEN-1] = ifacenum;
46380
46381 /* we will have to manufacture ethernet headers, prepare template */
46382 diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
46383 index 4dbb2ed..5410db0 100644
46384 --- a/drivers/net/vxlan.c
46385 +++ b/drivers/net/vxlan.c
46386 @@ -2840,7 +2840,7 @@ nla_put_failure:
46387 return -EMSGSIZE;
46388 }
46389
46390 -static struct rtnl_link_ops vxlan_link_ops __read_mostly = {
46391 +static struct rtnl_link_ops vxlan_link_ops = {
46392 .kind = "vxlan",
46393 .maxtype = IFLA_VXLAN_MAX,
46394 .policy = vxlan_policy,
46395 @@ -2887,7 +2887,7 @@ static int vxlan_lowerdev_event(struct notifier_block *unused,
46396 return NOTIFY_DONE;
46397 }
46398
46399 -static struct notifier_block vxlan_notifier_block __read_mostly = {
46400 +static struct notifier_block vxlan_notifier_block = {
46401 .notifier_call = vxlan_lowerdev_event,
46402 };
46403
46404 diff --git a/drivers/net/wan/lmc/lmc_media.c b/drivers/net/wan/lmc/lmc_media.c
46405 index 5920c99..ff2e4a5 100644
46406 --- a/drivers/net/wan/lmc/lmc_media.c
46407 +++ b/drivers/net/wan/lmc/lmc_media.c
46408 @@ -95,62 +95,63 @@ static inline void write_av9110_bit (lmc_softc_t *, int);
46409 static void write_av9110(lmc_softc_t *, u32, u32, u32, u32, u32);
46410
46411 lmc_media_t lmc_ds3_media = {
46412 - lmc_ds3_init, /* special media init stuff */
46413 - lmc_ds3_default, /* reset to default state */
46414 - lmc_ds3_set_status, /* reset status to state provided */
46415 - lmc_dummy_set_1, /* set clock source */
46416 - lmc_dummy_set2_1, /* set line speed */
46417 - lmc_ds3_set_100ft, /* set cable length */
46418 - lmc_ds3_set_scram, /* set scrambler */
46419 - lmc_ds3_get_link_status, /* get link status */
46420 - lmc_dummy_set_1, /* set link status */
46421 - lmc_ds3_set_crc_length, /* set CRC length */
46422 - lmc_dummy_set_1, /* set T1 or E1 circuit type */
46423 - lmc_ds3_watchdog
46424 + .init = lmc_ds3_init, /* special media init stuff */
46425 + .defaults = lmc_ds3_default, /* reset to default state */
46426 + .set_status = lmc_ds3_set_status, /* reset status to state provided */
46427 + .set_clock_source = lmc_dummy_set_1, /* set clock source */
46428 + .set_speed = lmc_dummy_set2_1, /* set line speed */
46429 + .set_cable_length = lmc_ds3_set_100ft, /* set cable length */
46430 + .set_scrambler = lmc_ds3_set_scram, /* set scrambler */
46431 + .get_link_status = lmc_ds3_get_link_status, /* get link status */
46432 + .set_link_status = lmc_dummy_set_1, /* set link status */
46433 + .set_crc_length = lmc_ds3_set_crc_length, /* set CRC length */
46434 + .set_circuit_type = lmc_dummy_set_1, /* set T1 or E1 circuit type */
46435 + .watchdog = lmc_ds3_watchdog
46436 };
46437
46438 lmc_media_t lmc_hssi_media = {
46439 - lmc_hssi_init, /* special media init stuff */
46440 - lmc_hssi_default, /* reset to default state */
46441 - lmc_hssi_set_status, /* reset status to state provided */
46442 - lmc_hssi_set_clock, /* set clock source */
46443 - lmc_dummy_set2_1, /* set line speed */
46444 - lmc_dummy_set_1, /* set cable length */
46445 - lmc_dummy_set_1, /* set scrambler */
46446 - lmc_hssi_get_link_status, /* get link status */
46447 - lmc_hssi_set_link_status, /* set link status */
46448 - lmc_hssi_set_crc_length, /* set CRC length */
46449 - lmc_dummy_set_1, /* set T1 or E1 circuit type */
46450 - lmc_hssi_watchdog
46451 + .init = lmc_hssi_init, /* special media init stuff */
46452 + .defaults = lmc_hssi_default, /* reset to default state */
46453 + .set_status = lmc_hssi_set_status, /* reset status to state provided */
46454 + .set_clock_source = lmc_hssi_set_clock, /* set clock source */
46455 + .set_speed = lmc_dummy_set2_1, /* set line speed */
46456 + .set_cable_length = lmc_dummy_set_1, /* set cable length */
46457 + .set_scrambler = lmc_dummy_set_1, /* set scrambler */
46458 + .get_link_status = lmc_hssi_get_link_status, /* get link status */
46459 + .set_link_status = lmc_hssi_set_link_status, /* set link status */
46460 + .set_crc_length = lmc_hssi_set_crc_length, /* set CRC length */
46461 + .set_circuit_type = lmc_dummy_set_1, /* set T1 or E1 circuit type */
46462 + .watchdog = lmc_hssi_watchdog
46463 };
46464
46465 -lmc_media_t lmc_ssi_media = { lmc_ssi_init, /* special media init stuff */
46466 - lmc_ssi_default, /* reset to default state */
46467 - lmc_ssi_set_status, /* reset status to state provided */
46468 - lmc_ssi_set_clock, /* set clock source */
46469 - lmc_ssi_set_speed, /* set line speed */
46470 - lmc_dummy_set_1, /* set cable length */
46471 - lmc_dummy_set_1, /* set scrambler */
46472 - lmc_ssi_get_link_status, /* get link status */
46473 - lmc_ssi_set_link_status, /* set link status */
46474 - lmc_ssi_set_crc_length, /* set CRC length */
46475 - lmc_dummy_set_1, /* set T1 or E1 circuit type */
46476 - lmc_ssi_watchdog
46477 +lmc_media_t lmc_ssi_media = {
46478 + .init = lmc_ssi_init, /* special media init stuff */
46479 + .defaults = lmc_ssi_default, /* reset to default state */
46480 + .set_status = lmc_ssi_set_status, /* reset status to state provided */
46481 + .set_clock_source = lmc_ssi_set_clock, /* set clock source */
46482 + .set_speed = lmc_ssi_set_speed, /* set line speed */
46483 + .set_cable_length = lmc_dummy_set_1, /* set cable length */
46484 + .set_scrambler = lmc_dummy_set_1, /* set scrambler */
46485 + .get_link_status = lmc_ssi_get_link_status, /* get link status */
46486 + .set_link_status = lmc_ssi_set_link_status, /* set link status */
46487 + .set_crc_length = lmc_ssi_set_crc_length, /* set CRC length */
46488 + .set_circuit_type = lmc_dummy_set_1, /* set T1 or E1 circuit type */
46489 + .watchdog = lmc_ssi_watchdog
46490 };
46491
46492 lmc_media_t lmc_t1_media = {
46493 - lmc_t1_init, /* special media init stuff */
46494 - lmc_t1_default, /* reset to default state */
46495 - lmc_t1_set_status, /* reset status to state provided */
46496 - lmc_t1_set_clock, /* set clock source */
46497 - lmc_dummy_set2_1, /* set line speed */
46498 - lmc_dummy_set_1, /* set cable length */
46499 - lmc_dummy_set_1, /* set scrambler */
46500 - lmc_t1_get_link_status, /* get link status */
46501 - lmc_dummy_set_1, /* set link status */
46502 - lmc_t1_set_crc_length, /* set CRC length */
46503 - lmc_t1_set_circuit_type, /* set T1 or E1 circuit type */
46504 - lmc_t1_watchdog
46505 + .init = lmc_t1_init, /* special media init stuff */
46506 + .defaults = lmc_t1_default, /* reset to default state */
46507 + .set_status = lmc_t1_set_status, /* reset status to state provided */
46508 + .set_clock_source = lmc_t1_set_clock, /* set clock source */
46509 + .set_speed = lmc_dummy_set2_1, /* set line speed */
46510 + .set_cable_length = lmc_dummy_set_1, /* set cable length */
46511 + .set_scrambler = lmc_dummy_set_1, /* set scrambler */
46512 + .get_link_status = lmc_t1_get_link_status, /* get link status */
46513 + .set_link_status = lmc_dummy_set_1, /* set link status */
46514 + .set_crc_length = lmc_t1_set_crc_length, /* set CRC length */
46515 + .set_circuit_type = lmc_t1_set_circuit_type, /* set T1 or E1 circuit type */
46516 + .watchdog = lmc_t1_watchdog
46517 };
46518
46519 static void
46520 diff --git a/drivers/net/wan/z85230.c b/drivers/net/wan/z85230.c
46521 index feacc3b..5bac0de 100644
46522 --- a/drivers/net/wan/z85230.c
46523 +++ b/drivers/net/wan/z85230.c
46524 @@ -485,9 +485,9 @@ static void z8530_status(struct z8530_channel *chan)
46525
46526 struct z8530_irqhandler z8530_sync =
46527 {
46528 - z8530_rx,
46529 - z8530_tx,
46530 - z8530_status
46531 + .rx = z8530_rx,
46532 + .tx = z8530_tx,
46533 + .status = z8530_status
46534 };
46535
46536 EXPORT_SYMBOL(z8530_sync);
46537 @@ -605,15 +605,15 @@ static void z8530_dma_status(struct z8530_channel *chan)
46538 }
46539
46540 static struct z8530_irqhandler z8530_dma_sync = {
46541 - z8530_dma_rx,
46542 - z8530_dma_tx,
46543 - z8530_dma_status
46544 + .rx = z8530_dma_rx,
46545 + .tx = z8530_dma_tx,
46546 + .status = z8530_dma_status
46547 };
46548
46549 static struct z8530_irqhandler z8530_txdma_sync = {
46550 - z8530_rx,
46551 - z8530_dma_tx,
46552 - z8530_dma_status
46553 + .rx = z8530_rx,
46554 + .tx = z8530_dma_tx,
46555 + .status = z8530_dma_status
46556 };
46557
46558 /**
46559 @@ -680,9 +680,9 @@ static void z8530_status_clear(struct z8530_channel *chan)
46560
46561 struct z8530_irqhandler z8530_nop=
46562 {
46563 - z8530_rx_clear,
46564 - z8530_tx_clear,
46565 - z8530_status_clear
46566 + .rx = z8530_rx_clear,
46567 + .tx = z8530_tx_clear,
46568 + .status = z8530_status_clear
46569 };
46570
46571
46572 diff --git a/drivers/net/wimax/i2400m/rx.c b/drivers/net/wimax/i2400m/rx.c
46573 index 0b60295..b8bfa5b 100644
46574 --- a/drivers/net/wimax/i2400m/rx.c
46575 +++ b/drivers/net/wimax/i2400m/rx.c
46576 @@ -1359,7 +1359,7 @@ int i2400m_rx_setup(struct i2400m *i2400m)
46577 if (i2400m->rx_roq == NULL)
46578 goto error_roq_alloc;
46579
46580 - rd = kcalloc(I2400M_RO_CIN + 1, sizeof(*i2400m->rx_roq[0].log),
46581 + rd = kcalloc(sizeof(*i2400m->rx_roq[0].log), I2400M_RO_CIN + 1,
46582 GFP_KERNEL);
46583 if (rd == NULL) {
46584 result = -ENOMEM;
46585 diff --git a/drivers/net/wireless/airo.c b/drivers/net/wireless/airo.c
46586 index 64747d4..17c4cf3 100644
46587 --- a/drivers/net/wireless/airo.c
46588 +++ b/drivers/net/wireless/airo.c
46589 @@ -7846,7 +7846,7 @@ static int writerids(struct net_device *dev, aironet_ioctl *comp) {
46590 struct airo_info *ai = dev->ml_priv;
46591 int ridcode;
46592 int enabled;
46593 - static int (* writer)(struct airo_info *, u16 rid, const void *, int, int);
46594 + int (* writer)(struct airo_info *, u16 rid, const void *, int, int);
46595 unsigned char *iobuf;
46596
46597 /* Only super-user can write RIDs */
46598 diff --git a/drivers/net/wireless/at76c50x-usb.c b/drivers/net/wireless/at76c50x-usb.c
46599 index 99b3bfa..9559372 100644
46600 --- a/drivers/net/wireless/at76c50x-usb.c
46601 +++ b/drivers/net/wireless/at76c50x-usb.c
46602 @@ -353,7 +353,7 @@ static int at76_dfu_get_state(struct usb_device *udev, u8 *state)
46603 }
46604
46605 /* Convert timeout from the DFU status to jiffies */
46606 -static inline unsigned long at76_get_timeout(struct dfu_status *s)
46607 +static inline unsigned long __intentional_overflow(-1) at76_get_timeout(struct dfu_status *s)
46608 {
46609 return msecs_to_jiffies((s->poll_timeout[2] << 16)
46610 | (s->poll_timeout[1] << 8)
46611 diff --git a/drivers/net/wireless/ath/ath10k/htc.c b/drivers/net/wireless/ath/ath10k/htc.c
46612 index 7f1bccd..ca2ffca 100644
46613 --- a/drivers/net/wireless/ath/ath10k/htc.c
46614 +++ b/drivers/net/wireless/ath/ath10k/htc.c
46615 @@ -840,7 +840,10 @@ void ath10k_htc_stop(struct ath10k_htc *htc)
46616 /* registered target arrival callback from the HIF layer */
46617 int ath10k_htc_init(struct ath10k *ar)
46618 {
46619 - struct ath10k_hif_cb htc_callbacks;
46620 + static struct ath10k_hif_cb htc_callbacks = {
46621 + .rx_completion = ath10k_htc_rx_completion_handler,
46622 + .tx_completion = ath10k_htc_tx_completion_handler,
46623 + };
46624 struct ath10k_htc_ep *ep = NULL;
46625 struct ath10k_htc *htc = &ar->htc;
46626
46627 @@ -850,8 +853,6 @@ int ath10k_htc_init(struct ath10k *ar)
46628 ath10k_htc_reset_endpoint_states(htc);
46629
46630 /* setup HIF layer callbacks */
46631 - htc_callbacks.rx_completion = ath10k_htc_rx_completion_handler;
46632 - htc_callbacks.tx_completion = ath10k_htc_tx_completion_handler;
46633 htc->ar = ar;
46634
46635 /* Get HIF default pipe for HTC message exchange */
46636 diff --git a/drivers/net/wireless/ath/ath10k/htc.h b/drivers/net/wireless/ath/ath10k/htc.h
46637 index 4716d33..a688310 100644
46638 --- a/drivers/net/wireless/ath/ath10k/htc.h
46639 +++ b/drivers/net/wireless/ath/ath10k/htc.h
46640 @@ -271,13 +271,13 @@ enum ath10k_htc_ep_id {
46641
46642 struct ath10k_htc_ops {
46643 void (*target_send_suspend_complete)(struct ath10k *ar);
46644 -};
46645 +} __no_const;
46646
46647 struct ath10k_htc_ep_ops {
46648 void (*ep_tx_complete)(struct ath10k *, struct sk_buff *);
46649 void (*ep_rx_complete)(struct ath10k *, struct sk_buff *);
46650 void (*ep_tx_credits)(struct ath10k *);
46651 -};
46652 +} __no_const;
46653
46654 /* service connection information */
46655 struct ath10k_htc_svc_conn_req {
46656 diff --git a/drivers/net/wireless/ath/ath9k/ar9002_mac.c b/drivers/net/wireless/ath/ath9k/ar9002_mac.c
46657 index 741b38d..b7ae41b 100644
46658 --- a/drivers/net/wireless/ath/ath9k/ar9002_mac.c
46659 +++ b/drivers/net/wireless/ath/ath9k/ar9002_mac.c
46660 @@ -220,8 +220,8 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
46661 ads->ds_txstatus6 = ads->ds_txstatus7 = 0;
46662 ads->ds_txstatus8 = ads->ds_txstatus9 = 0;
46663
46664 - ACCESS_ONCE(ads->ds_link) = i->link;
46665 - ACCESS_ONCE(ads->ds_data) = i->buf_addr[0];
46666 + ACCESS_ONCE_RW(ads->ds_link) = i->link;
46667 + ACCESS_ONCE_RW(ads->ds_data) = i->buf_addr[0];
46668
46669 ctl1 = i->buf_len[0] | (i->is_last ? 0 : AR_TxMore);
46670 ctl6 = SM(i->keytype, AR_EncrType);
46671 @@ -235,26 +235,26 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
46672
46673 if ((i->is_first || i->is_last) &&
46674 i->aggr != AGGR_BUF_MIDDLE && i->aggr != AGGR_BUF_LAST) {
46675 - ACCESS_ONCE(ads->ds_ctl2) = set11nTries(i->rates, 0)
46676 + ACCESS_ONCE_RW(ads->ds_ctl2) = set11nTries(i->rates, 0)
46677 | set11nTries(i->rates, 1)
46678 | set11nTries(i->rates, 2)
46679 | set11nTries(i->rates, 3)
46680 | (i->dur_update ? AR_DurUpdateEna : 0)
46681 | SM(0, AR_BurstDur);
46682
46683 - ACCESS_ONCE(ads->ds_ctl3) = set11nRate(i->rates, 0)
46684 + ACCESS_ONCE_RW(ads->ds_ctl3) = set11nRate(i->rates, 0)
46685 | set11nRate(i->rates, 1)
46686 | set11nRate(i->rates, 2)
46687 | set11nRate(i->rates, 3);
46688 } else {
46689 - ACCESS_ONCE(ads->ds_ctl2) = 0;
46690 - ACCESS_ONCE(ads->ds_ctl3) = 0;
46691 + ACCESS_ONCE_RW(ads->ds_ctl2) = 0;
46692 + ACCESS_ONCE_RW(ads->ds_ctl3) = 0;
46693 }
46694
46695 if (!i->is_first) {
46696 - ACCESS_ONCE(ads->ds_ctl0) = 0;
46697 - ACCESS_ONCE(ads->ds_ctl1) = ctl1;
46698 - ACCESS_ONCE(ads->ds_ctl6) = ctl6;
46699 + ACCESS_ONCE_RW(ads->ds_ctl0) = 0;
46700 + ACCESS_ONCE_RW(ads->ds_ctl1) = ctl1;
46701 + ACCESS_ONCE_RW(ads->ds_ctl6) = ctl6;
46702 return;
46703 }
46704
46705 @@ -279,7 +279,7 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
46706 break;
46707 }
46708
46709 - ACCESS_ONCE(ads->ds_ctl0) = (i->pkt_len & AR_FrameLen)
46710 + ACCESS_ONCE_RW(ads->ds_ctl0) = (i->pkt_len & AR_FrameLen)
46711 | (i->flags & ATH9K_TXDESC_VMF ? AR_VirtMoreFrag : 0)
46712 | SM(i->txpower, AR_XmitPower)
46713 | (i->flags & ATH9K_TXDESC_VEOL ? AR_VEOL : 0)
46714 @@ -289,19 +289,19 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
46715 | (i->flags & ATH9K_TXDESC_RTSENA ? AR_RTSEnable :
46716 (i->flags & ATH9K_TXDESC_CTSENA ? AR_CTSEnable : 0));
46717
46718 - ACCESS_ONCE(ads->ds_ctl1) = ctl1;
46719 - ACCESS_ONCE(ads->ds_ctl6) = ctl6;
46720 + ACCESS_ONCE_RW(ads->ds_ctl1) = ctl1;
46721 + ACCESS_ONCE_RW(ads->ds_ctl6) = ctl6;
46722
46723 if (i->aggr == AGGR_BUF_MIDDLE || i->aggr == AGGR_BUF_LAST)
46724 return;
46725
46726 - ACCESS_ONCE(ads->ds_ctl4) = set11nPktDurRTSCTS(i->rates, 0)
46727 + ACCESS_ONCE_RW(ads->ds_ctl4) = set11nPktDurRTSCTS(i->rates, 0)
46728 | set11nPktDurRTSCTS(i->rates, 1);
46729
46730 - ACCESS_ONCE(ads->ds_ctl5) = set11nPktDurRTSCTS(i->rates, 2)
46731 + ACCESS_ONCE_RW(ads->ds_ctl5) = set11nPktDurRTSCTS(i->rates, 2)
46732 | set11nPktDurRTSCTS(i->rates, 3);
46733
46734 - ACCESS_ONCE(ads->ds_ctl7) = set11nRateFlags(i->rates, 0)
46735 + ACCESS_ONCE_RW(ads->ds_ctl7) = set11nRateFlags(i->rates, 0)
46736 | set11nRateFlags(i->rates, 1)
46737 | set11nRateFlags(i->rates, 2)
46738 | set11nRateFlags(i->rates, 3)
46739 diff --git a/drivers/net/wireless/ath/ath9k/ar9003_mac.c b/drivers/net/wireless/ath/ath9k/ar9003_mac.c
46740 index 729ffbf..49f50e3 100644
46741 --- a/drivers/net/wireless/ath/ath9k/ar9003_mac.c
46742 +++ b/drivers/net/wireless/ath/ath9k/ar9003_mac.c
46743 @@ -39,47 +39,47 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
46744 (i->qcu << AR_TxQcuNum_S) | desc_len;
46745
46746 checksum += val;
46747 - ACCESS_ONCE(ads->info) = val;
46748 + ACCESS_ONCE_RW(ads->info) = val;
46749
46750 checksum += i->link;
46751 - ACCESS_ONCE(ads->link) = i->link;
46752 + ACCESS_ONCE_RW(ads->link) = i->link;
46753
46754 checksum += i->buf_addr[0];
46755 - ACCESS_ONCE(ads->data0) = i->buf_addr[0];
46756 + ACCESS_ONCE_RW(ads->data0) = i->buf_addr[0];
46757 checksum += i->buf_addr[1];
46758 - ACCESS_ONCE(ads->data1) = i->buf_addr[1];
46759 + ACCESS_ONCE_RW(ads->data1) = i->buf_addr[1];
46760 checksum += i->buf_addr[2];
46761 - ACCESS_ONCE(ads->data2) = i->buf_addr[2];
46762 + ACCESS_ONCE_RW(ads->data2) = i->buf_addr[2];
46763 checksum += i->buf_addr[3];
46764 - ACCESS_ONCE(ads->data3) = i->buf_addr[3];
46765 + ACCESS_ONCE_RW(ads->data3) = i->buf_addr[3];
46766
46767 checksum += (val = (i->buf_len[0] << AR_BufLen_S) & AR_BufLen);
46768 - ACCESS_ONCE(ads->ctl3) = val;
46769 + ACCESS_ONCE_RW(ads->ctl3) = val;
46770 checksum += (val = (i->buf_len[1] << AR_BufLen_S) & AR_BufLen);
46771 - ACCESS_ONCE(ads->ctl5) = val;
46772 + ACCESS_ONCE_RW(ads->ctl5) = val;
46773 checksum += (val = (i->buf_len[2] << AR_BufLen_S) & AR_BufLen);
46774 - ACCESS_ONCE(ads->ctl7) = val;
46775 + ACCESS_ONCE_RW(ads->ctl7) = val;
46776 checksum += (val = (i->buf_len[3] << AR_BufLen_S) & AR_BufLen);
46777 - ACCESS_ONCE(ads->ctl9) = val;
46778 + ACCESS_ONCE_RW(ads->ctl9) = val;
46779
46780 checksum = (u16) (((checksum & 0xffff) + (checksum >> 16)) & 0xffff);
46781 - ACCESS_ONCE(ads->ctl10) = checksum;
46782 + ACCESS_ONCE_RW(ads->ctl10) = checksum;
46783
46784 if (i->is_first || i->is_last) {
46785 - ACCESS_ONCE(ads->ctl13) = set11nTries(i->rates, 0)
46786 + ACCESS_ONCE_RW(ads->ctl13) = set11nTries(i->rates, 0)
46787 | set11nTries(i->rates, 1)
46788 | set11nTries(i->rates, 2)
46789 | set11nTries(i->rates, 3)
46790 | (i->dur_update ? AR_DurUpdateEna : 0)
46791 | SM(0, AR_BurstDur);
46792
46793 - ACCESS_ONCE(ads->ctl14) = set11nRate(i->rates, 0)
46794 + ACCESS_ONCE_RW(ads->ctl14) = set11nRate(i->rates, 0)
46795 | set11nRate(i->rates, 1)
46796 | set11nRate(i->rates, 2)
46797 | set11nRate(i->rates, 3);
46798 } else {
46799 - ACCESS_ONCE(ads->ctl13) = 0;
46800 - ACCESS_ONCE(ads->ctl14) = 0;
46801 + ACCESS_ONCE_RW(ads->ctl13) = 0;
46802 + ACCESS_ONCE_RW(ads->ctl14) = 0;
46803 }
46804
46805 ads->ctl20 = 0;
46806 @@ -89,17 +89,17 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
46807
46808 ctl17 = SM(i->keytype, AR_EncrType);
46809 if (!i->is_first) {
46810 - ACCESS_ONCE(ads->ctl11) = 0;
46811 - ACCESS_ONCE(ads->ctl12) = i->is_last ? 0 : AR_TxMore;
46812 - ACCESS_ONCE(ads->ctl15) = 0;
46813 - ACCESS_ONCE(ads->ctl16) = 0;
46814 - ACCESS_ONCE(ads->ctl17) = ctl17;
46815 - ACCESS_ONCE(ads->ctl18) = 0;
46816 - ACCESS_ONCE(ads->ctl19) = 0;
46817 + ACCESS_ONCE_RW(ads->ctl11) = 0;
46818 + ACCESS_ONCE_RW(ads->ctl12) = i->is_last ? 0 : AR_TxMore;
46819 + ACCESS_ONCE_RW(ads->ctl15) = 0;
46820 + ACCESS_ONCE_RW(ads->ctl16) = 0;
46821 + ACCESS_ONCE_RW(ads->ctl17) = ctl17;
46822 + ACCESS_ONCE_RW(ads->ctl18) = 0;
46823 + ACCESS_ONCE_RW(ads->ctl19) = 0;
46824 return;
46825 }
46826
46827 - ACCESS_ONCE(ads->ctl11) = (i->pkt_len & AR_FrameLen)
46828 + ACCESS_ONCE_RW(ads->ctl11) = (i->pkt_len & AR_FrameLen)
46829 | (i->flags & ATH9K_TXDESC_VMF ? AR_VirtMoreFrag : 0)
46830 | SM(i->txpower, AR_XmitPower)
46831 | (i->flags & ATH9K_TXDESC_VEOL ? AR_VEOL : 0)
46832 @@ -135,22 +135,22 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
46833 val = (i->flags & ATH9K_TXDESC_PAPRD) >> ATH9K_TXDESC_PAPRD_S;
46834 ctl12 |= SM(val, AR_PAPRDChainMask);
46835
46836 - ACCESS_ONCE(ads->ctl12) = ctl12;
46837 - ACCESS_ONCE(ads->ctl17) = ctl17;
46838 + ACCESS_ONCE_RW(ads->ctl12) = ctl12;
46839 + ACCESS_ONCE_RW(ads->ctl17) = ctl17;
46840
46841 - ACCESS_ONCE(ads->ctl15) = set11nPktDurRTSCTS(i->rates, 0)
46842 + ACCESS_ONCE_RW(ads->ctl15) = set11nPktDurRTSCTS(i->rates, 0)
46843 | set11nPktDurRTSCTS(i->rates, 1);
46844
46845 - ACCESS_ONCE(ads->ctl16) = set11nPktDurRTSCTS(i->rates, 2)
46846 + ACCESS_ONCE_RW(ads->ctl16) = set11nPktDurRTSCTS(i->rates, 2)
46847 | set11nPktDurRTSCTS(i->rates, 3);
46848
46849 - ACCESS_ONCE(ads->ctl18) = set11nRateFlags(i->rates, 0)
46850 + ACCESS_ONCE_RW(ads->ctl18) = set11nRateFlags(i->rates, 0)
46851 | set11nRateFlags(i->rates, 1)
46852 | set11nRateFlags(i->rates, 2)
46853 | set11nRateFlags(i->rates, 3)
46854 | SM(i->rtscts_rate, AR_RTSCTSRate);
46855
46856 - ACCESS_ONCE(ads->ctl19) = AR_Not_Sounding;
46857 + ACCESS_ONCE_RW(ads->ctl19) = AR_Not_Sounding;
46858 }
46859
46860 static u16 ar9003_calc_ptr_chksum(struct ar9003_txc *ads)
46861 diff --git a/drivers/net/wireless/ath/ath9k/hw.h b/drivers/net/wireless/ath/ath9k/hw.h
46862 index 0acd4b5..0591c91 100644
46863 --- a/drivers/net/wireless/ath/ath9k/hw.h
46864 +++ b/drivers/net/wireless/ath/ath9k/hw.h
46865 @@ -629,7 +629,7 @@ struct ath_hw_private_ops {
46866
46867 /* ANI */
46868 void (*ani_cache_ini_regs)(struct ath_hw *ah);
46869 -};
46870 +} __no_const;
46871
46872 /**
46873 * struct ath_spec_scan - parameters for Atheros spectral scan
46874 @@ -706,7 +706,7 @@ struct ath_hw_ops {
46875 #ifdef CONFIG_ATH9K_BTCOEX_SUPPORT
46876 void (*set_bt_ant_diversity)(struct ath_hw *hw, bool enable);
46877 #endif
46878 -};
46879 +} __no_const;
46880
46881 struct ath_nf_limits {
46882 s16 max;
46883 diff --git a/drivers/net/wireless/b43/phy_lp.c b/drivers/net/wireless/b43/phy_lp.c
46884 index 92190da..f3a4c4c 100644
46885 --- a/drivers/net/wireless/b43/phy_lp.c
46886 +++ b/drivers/net/wireless/b43/phy_lp.c
46887 @@ -2514,7 +2514,7 @@ static int lpphy_b2063_tune(struct b43_wldev *dev,
46888 {
46889 struct ssb_bus *bus = dev->dev->sdev->bus;
46890
46891 - static const struct b206x_channel *chandata = NULL;
46892 + const struct b206x_channel *chandata = NULL;
46893 u32 crystal_freq = bus->chipco.pmu.crystalfreq * 1000;
46894 u32 freqref, vco_freq, val1, val2, val3, timeout, timeoutref, count;
46895 u16 old_comm15, scale;
46896 diff --git a/drivers/net/wireless/iwlegacy/3945-mac.c b/drivers/net/wireless/iwlegacy/3945-mac.c
46897 index dc1d20c..f7a4f06 100644
46898 --- a/drivers/net/wireless/iwlegacy/3945-mac.c
46899 +++ b/drivers/net/wireless/iwlegacy/3945-mac.c
46900 @@ -3633,7 +3633,9 @@ il3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
46901 */
46902 if (il3945_mod_params.disable_hw_scan) {
46903 D_INFO("Disabling hw_scan\n");
46904 - il3945_mac_ops.hw_scan = NULL;
46905 + pax_open_kernel();
46906 + *(void **)&il3945_mac_ops.hw_scan = NULL;
46907 + pax_close_kernel();
46908 }
46909
46910 D_INFO("*** LOAD DRIVER ***\n");
46911 diff --git a/drivers/net/wireless/iwlwifi/dvm/debugfs.c b/drivers/net/wireless/iwlwifi/dvm/debugfs.c
46912 index d2fe259..0c4c682 100644
46913 --- a/drivers/net/wireless/iwlwifi/dvm/debugfs.c
46914 +++ b/drivers/net/wireless/iwlwifi/dvm/debugfs.c
46915 @@ -188,7 +188,7 @@ static ssize_t iwl_dbgfs_sram_write(struct file *file,
46916 {
46917 struct iwl_priv *priv = file->private_data;
46918 char buf[64];
46919 - int buf_size;
46920 + size_t buf_size;
46921 u32 offset, len;
46922
46923 memset(buf, 0, sizeof(buf));
46924 @@ -458,7 +458,7 @@ static ssize_t iwl_dbgfs_rx_handlers_write(struct file *file,
46925 struct iwl_priv *priv = file->private_data;
46926
46927 char buf[8];
46928 - int buf_size;
46929 + size_t buf_size;
46930 u32 reset_flag;
46931
46932 memset(buf, 0, sizeof(buf));
46933 @@ -539,7 +539,7 @@ static ssize_t iwl_dbgfs_disable_ht40_write(struct file *file,
46934 {
46935 struct iwl_priv *priv = file->private_data;
46936 char buf[8];
46937 - int buf_size;
46938 + size_t buf_size;
46939 int ht40;
46940
46941 memset(buf, 0, sizeof(buf));
46942 @@ -591,7 +591,7 @@ static ssize_t iwl_dbgfs_sleep_level_override_write(struct file *file,
46943 {
46944 struct iwl_priv *priv = file->private_data;
46945 char buf[8];
46946 - int buf_size;
46947 + size_t buf_size;
46948 int value;
46949
46950 memset(buf, 0, sizeof(buf));
46951 @@ -683,10 +683,10 @@ DEBUGFS_READ_FILE_OPS(temperature);
46952 DEBUGFS_READ_WRITE_FILE_OPS(sleep_level_override);
46953 DEBUGFS_READ_FILE_OPS(current_sleep_command);
46954
46955 -static const char *fmt_value = " %-30s %10u\n";
46956 -static const char *fmt_hex = " %-30s 0x%02X\n";
46957 -static const char *fmt_table = " %-30s %10u %10u %10u %10u\n";
46958 -static const char *fmt_header =
46959 +static const char fmt_value[] = " %-30s %10u\n";
46960 +static const char fmt_hex[] = " %-30s 0x%02X\n";
46961 +static const char fmt_table[] = " %-30s %10u %10u %10u %10u\n";
46962 +static const char fmt_header[] =
46963 "%-32s current cumulative delta max\n";
46964
46965 static int iwl_statistics_flag(struct iwl_priv *priv, char *buf, int bufsz)
46966 @@ -1856,7 +1856,7 @@ static ssize_t iwl_dbgfs_clear_ucode_statistics_write(struct file *file,
46967 {
46968 struct iwl_priv *priv = file->private_data;
46969 char buf[8];
46970 - int buf_size;
46971 + size_t buf_size;
46972 int clear;
46973
46974 memset(buf, 0, sizeof(buf));
46975 @@ -1901,7 +1901,7 @@ static ssize_t iwl_dbgfs_ucode_tracing_write(struct file *file,
46976 {
46977 struct iwl_priv *priv = file->private_data;
46978 char buf[8];
46979 - int buf_size;
46980 + size_t buf_size;
46981 int trace;
46982
46983 memset(buf, 0, sizeof(buf));
46984 @@ -1972,7 +1972,7 @@ static ssize_t iwl_dbgfs_missed_beacon_write(struct file *file,
46985 {
46986 struct iwl_priv *priv = file->private_data;
46987 char buf[8];
46988 - int buf_size;
46989 + size_t buf_size;
46990 int missed;
46991
46992 memset(buf, 0, sizeof(buf));
46993 @@ -2013,7 +2013,7 @@ static ssize_t iwl_dbgfs_plcp_delta_write(struct file *file,
46994
46995 struct iwl_priv *priv = file->private_data;
46996 char buf[8];
46997 - int buf_size;
46998 + size_t buf_size;
46999 int plcp;
47000
47001 memset(buf, 0, sizeof(buf));
47002 @@ -2073,7 +2073,7 @@ static ssize_t iwl_dbgfs_txfifo_flush_write(struct file *file,
47003
47004 struct iwl_priv *priv = file->private_data;
47005 char buf[8];
47006 - int buf_size;
47007 + size_t buf_size;
47008 int flush;
47009
47010 memset(buf, 0, sizeof(buf));
47011 @@ -2163,7 +2163,7 @@ static ssize_t iwl_dbgfs_protection_mode_write(struct file *file,
47012
47013 struct iwl_priv *priv = file->private_data;
47014 char buf[8];
47015 - int buf_size;
47016 + size_t buf_size;
47017 int rts;
47018
47019 if (!priv->cfg->ht_params)
47020 @@ -2205,7 +2205,7 @@ static ssize_t iwl_dbgfs_echo_test_write(struct file *file,
47021 {
47022 struct iwl_priv *priv = file->private_data;
47023 char buf[8];
47024 - int buf_size;
47025 + size_t buf_size;
47026
47027 memset(buf, 0, sizeof(buf));
47028 buf_size = min(count, sizeof(buf) - 1);
47029 @@ -2239,7 +2239,7 @@ static ssize_t iwl_dbgfs_log_event_write(struct file *file,
47030 struct iwl_priv *priv = file->private_data;
47031 u32 event_log_flag;
47032 char buf[8];
47033 - int buf_size;
47034 + size_t buf_size;
47035
47036 /* check that the interface is up */
47037 if (!iwl_is_ready(priv))
47038 @@ -2293,7 +2293,7 @@ static ssize_t iwl_dbgfs_calib_disabled_write(struct file *file,
47039 struct iwl_priv *priv = file->private_data;
47040 char buf[8];
47041 u32 calib_disabled;
47042 - int buf_size;
47043 + size_t buf_size;
47044
47045 memset(buf, 0, sizeof(buf));
47046 buf_size = min(count, sizeof(buf) - 1);
47047 diff --git a/drivers/net/wireless/iwlwifi/dvm/main.c b/drivers/net/wireless/iwlwifi/dvm/main.c
47048 index 6a6df71..eb5c93a 100644
47049 --- a/drivers/net/wireless/iwlwifi/dvm/main.c
47050 +++ b/drivers/net/wireless/iwlwifi/dvm/main.c
47051 @@ -1127,7 +1127,7 @@ static void iwl_option_config(struct iwl_priv *priv)
47052 static int iwl_eeprom_init_hw_params(struct iwl_priv *priv)
47053 {
47054 struct iwl_nvm_data *data = priv->nvm_data;
47055 - char *debug_msg;
47056 + static const char debug_msg[] = "Device SKU: 24GHz %s %s, 52GHz %s %s, 11.n %s %s\n";
47057
47058 if (data->sku_cap_11n_enable &&
47059 !priv->cfg->ht_params) {
47060 @@ -1141,7 +1141,6 @@ static int iwl_eeprom_init_hw_params(struct iwl_priv *priv)
47061 return -EINVAL;
47062 }
47063
47064 - debug_msg = "Device SKU: 24GHz %s %s, 52GHz %s %s, 11.n %s %s\n";
47065 IWL_DEBUG_INFO(priv, debug_msg,
47066 data->sku_cap_band_24GHz_enable ? "" : "NOT", "enabled",
47067 data->sku_cap_band_52GHz_enable ? "" : "NOT", "enabled",
47068 diff --git a/drivers/net/wireless/iwlwifi/pcie/trans.c b/drivers/net/wireless/iwlwifi/pcie/trans.c
47069 index 2365553..97126d8 100644
47070 --- a/drivers/net/wireless/iwlwifi/pcie/trans.c
47071 +++ b/drivers/net/wireless/iwlwifi/pcie/trans.c
47072 @@ -1552,7 +1552,7 @@ static ssize_t iwl_dbgfs_interrupt_write(struct file *file,
47073 struct isr_statistics *isr_stats = &trans_pcie->isr_stats;
47074
47075 char buf[8];
47076 - int buf_size;
47077 + size_t buf_size;
47078 u32 reset_flag;
47079
47080 memset(buf, 0, sizeof(buf));
47081 @@ -1573,7 +1573,7 @@ static ssize_t iwl_dbgfs_csr_write(struct file *file,
47082 {
47083 struct iwl_trans *trans = file->private_data;
47084 char buf[8];
47085 - int buf_size;
47086 + size_t buf_size;
47087 int csr;
47088
47089 memset(buf, 0, sizeof(buf));
47090 diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c
47091 index 9d7a52f..2729a99 100644
47092 --- a/drivers/net/wireless/mac80211_hwsim.c
47093 +++ b/drivers/net/wireless/mac80211_hwsim.c
47094 @@ -2570,20 +2570,20 @@ static int __init init_mac80211_hwsim(void)
47095 if (channels < 1)
47096 return -EINVAL;
47097
47098 - mac80211_hwsim_mchan_ops = mac80211_hwsim_ops;
47099 - mac80211_hwsim_mchan_ops.hw_scan = mac80211_hwsim_hw_scan;
47100 - mac80211_hwsim_mchan_ops.cancel_hw_scan = mac80211_hwsim_cancel_hw_scan;
47101 - mac80211_hwsim_mchan_ops.sw_scan_start = NULL;
47102 - mac80211_hwsim_mchan_ops.sw_scan_complete = NULL;
47103 - mac80211_hwsim_mchan_ops.remain_on_channel = mac80211_hwsim_roc;
47104 - mac80211_hwsim_mchan_ops.cancel_remain_on_channel = mac80211_hwsim_croc;
47105 - mac80211_hwsim_mchan_ops.add_chanctx = mac80211_hwsim_add_chanctx;
47106 - mac80211_hwsim_mchan_ops.remove_chanctx = mac80211_hwsim_remove_chanctx;
47107 - mac80211_hwsim_mchan_ops.change_chanctx = mac80211_hwsim_change_chanctx;
47108 - mac80211_hwsim_mchan_ops.assign_vif_chanctx =
47109 - mac80211_hwsim_assign_vif_chanctx;
47110 - mac80211_hwsim_mchan_ops.unassign_vif_chanctx =
47111 - mac80211_hwsim_unassign_vif_chanctx;
47112 + pax_open_kernel();
47113 + memcpy((void *)&mac80211_hwsim_mchan_ops, &mac80211_hwsim_ops, sizeof mac80211_hwsim_mchan_ops);
47114 + *(void **)&mac80211_hwsim_mchan_ops.hw_scan = mac80211_hwsim_hw_scan;
47115 + *(void **)&mac80211_hwsim_mchan_ops.cancel_hw_scan = mac80211_hwsim_cancel_hw_scan;
47116 + *(void **)&mac80211_hwsim_mchan_ops.sw_scan_start = NULL;
47117 + *(void **)&mac80211_hwsim_mchan_ops.sw_scan_complete = NULL;
47118 + *(void **)&mac80211_hwsim_mchan_ops.remain_on_channel = mac80211_hwsim_roc;
47119 + *(void **)&mac80211_hwsim_mchan_ops.cancel_remain_on_channel = mac80211_hwsim_croc;
47120 + *(void **)&mac80211_hwsim_mchan_ops.add_chanctx = mac80211_hwsim_add_chanctx;
47121 + *(void **)&mac80211_hwsim_mchan_ops.remove_chanctx = mac80211_hwsim_remove_chanctx;
47122 + *(void **)&mac80211_hwsim_mchan_ops.change_chanctx = mac80211_hwsim_change_chanctx;
47123 + *(void **)&mac80211_hwsim_mchan_ops.assign_vif_chanctx = mac80211_hwsim_assign_vif_chanctx;
47124 + *(void **)&mac80211_hwsim_mchan_ops.unassign_vif_chanctx = mac80211_hwsim_unassign_vif_chanctx;
47125 + pax_close_kernel();
47126
47127 spin_lock_init(&hwsim_radio_lock);
47128 INIT_LIST_HEAD(&hwsim_radios);
47129 diff --git a/drivers/net/wireless/rndis_wlan.c b/drivers/net/wireless/rndis_wlan.c
47130 index 39d22a1..4ec8612 100644
47131 --- a/drivers/net/wireless/rndis_wlan.c
47132 +++ b/drivers/net/wireless/rndis_wlan.c
47133 @@ -1236,7 +1236,7 @@ static int set_rts_threshold(struct usbnet *usbdev, u32 rts_threshold)
47134
47135 netdev_dbg(usbdev->net, "%s(): %i\n", __func__, rts_threshold);
47136
47137 - if (rts_threshold < 0 || rts_threshold > 2347)
47138 + if (rts_threshold > 2347)
47139 rts_threshold = 2347;
47140
47141 tmp = cpu_to_le32(rts_threshold);
47142 diff --git a/drivers/net/wireless/rt2x00/rt2x00.h b/drivers/net/wireless/rt2x00/rt2x00.h
47143 index e3b885d..7a7de2f 100644
47144 --- a/drivers/net/wireless/rt2x00/rt2x00.h
47145 +++ b/drivers/net/wireless/rt2x00/rt2x00.h
47146 @@ -375,7 +375,7 @@ struct rt2x00_intf {
47147 * for hardware which doesn't support hardware
47148 * sequence counting.
47149 */
47150 - atomic_t seqno;
47151 + atomic_unchecked_t seqno;
47152 };
47153
47154 static inline struct rt2x00_intf* vif_to_intf(struct ieee80211_vif *vif)
47155 diff --git a/drivers/net/wireless/rt2x00/rt2x00queue.c b/drivers/net/wireless/rt2x00/rt2x00queue.c
47156 index 5642ccc..01f03eb 100644
47157 --- a/drivers/net/wireless/rt2x00/rt2x00queue.c
47158 +++ b/drivers/net/wireless/rt2x00/rt2x00queue.c
47159 @@ -250,9 +250,9 @@ static void rt2x00queue_create_tx_descriptor_seq(struct rt2x00_dev *rt2x00dev,
47160 * sequence counter given by mac80211.
47161 */
47162 if (test_bit(ENTRY_TXD_FIRST_FRAGMENT, &txdesc->flags))
47163 - seqno = atomic_add_return(0x10, &intf->seqno);
47164 + seqno = atomic_add_return_unchecked(0x10, &intf->seqno);
47165 else
47166 - seqno = atomic_read(&intf->seqno);
47167 + seqno = atomic_read_unchecked(&intf->seqno);
47168
47169 hdr->seq_ctrl &= cpu_to_le16(IEEE80211_SCTL_FRAG);
47170 hdr->seq_ctrl |= cpu_to_le16(seqno);
47171 diff --git a/drivers/net/wireless/ti/wl1251/sdio.c b/drivers/net/wireless/ti/wl1251/sdio.c
47172 index b661f896..ddf7d2b 100644
47173 --- a/drivers/net/wireless/ti/wl1251/sdio.c
47174 +++ b/drivers/net/wireless/ti/wl1251/sdio.c
47175 @@ -282,13 +282,17 @@ static int wl1251_sdio_probe(struct sdio_func *func,
47176
47177 irq_set_irq_type(wl->irq, IRQ_TYPE_EDGE_RISING);
47178
47179 - wl1251_sdio_ops.enable_irq = wl1251_enable_line_irq;
47180 - wl1251_sdio_ops.disable_irq = wl1251_disable_line_irq;
47181 + pax_open_kernel();
47182 + *(void **)&wl1251_sdio_ops.enable_irq = wl1251_enable_line_irq;
47183 + *(void **)&wl1251_sdio_ops.disable_irq = wl1251_disable_line_irq;
47184 + pax_close_kernel();
47185
47186 wl1251_info("using dedicated interrupt line");
47187 } else {
47188 - wl1251_sdio_ops.enable_irq = wl1251_sdio_enable_irq;
47189 - wl1251_sdio_ops.disable_irq = wl1251_sdio_disable_irq;
47190 + pax_open_kernel();
47191 + *(void **)&wl1251_sdio_ops.enable_irq = wl1251_sdio_enable_irq;
47192 + *(void **)&wl1251_sdio_ops.disable_irq = wl1251_sdio_disable_irq;
47193 + pax_close_kernel();
47194
47195 wl1251_info("using SDIO interrupt");
47196 }
47197 diff --git a/drivers/net/wireless/ti/wl12xx/main.c b/drivers/net/wireless/ti/wl12xx/main.c
47198 index d50dfac..0a6f5be3 100644
47199 --- a/drivers/net/wireless/ti/wl12xx/main.c
47200 +++ b/drivers/net/wireless/ti/wl12xx/main.c
47201 @@ -656,7 +656,9 @@ static int wl12xx_identify_chip(struct wl1271 *wl)
47202 sizeof(wl->conf.mem));
47203
47204 /* read data preparation is only needed by wl127x */
47205 - wl->ops->prepare_read = wl127x_prepare_read;
47206 + pax_open_kernel();
47207 + *(void **)&wl->ops->prepare_read = wl127x_prepare_read;
47208 + pax_close_kernel();
47209
47210 wlcore_set_min_fw_ver(wl, WL127X_CHIP_VER,
47211 WL127X_IFTYPE_SR_VER, WL127X_MAJOR_SR_VER,
47212 @@ -681,7 +683,9 @@ static int wl12xx_identify_chip(struct wl1271 *wl)
47213 sizeof(wl->conf.mem));
47214
47215 /* read data preparation is only needed by wl127x */
47216 - wl->ops->prepare_read = wl127x_prepare_read;
47217 + pax_open_kernel();
47218 + *(void **)&wl->ops->prepare_read = wl127x_prepare_read;
47219 + pax_close_kernel();
47220
47221 wlcore_set_min_fw_ver(wl, WL127X_CHIP_VER,
47222 WL127X_IFTYPE_SR_VER, WL127X_MAJOR_SR_VER,
47223 diff --git a/drivers/net/wireless/ti/wl18xx/main.c b/drivers/net/wireless/ti/wl18xx/main.c
47224 index de5b4fa..7996ec6 100644
47225 --- a/drivers/net/wireless/ti/wl18xx/main.c
47226 +++ b/drivers/net/wireless/ti/wl18xx/main.c
47227 @@ -1900,8 +1900,10 @@ static int wl18xx_setup(struct wl1271 *wl)
47228 }
47229
47230 if (!checksum_param) {
47231 - wl18xx_ops.set_rx_csum = NULL;
47232 - wl18xx_ops.init_vif = NULL;
47233 + pax_open_kernel();
47234 + *(void **)&wl18xx_ops.set_rx_csum = NULL;
47235 + *(void **)&wl18xx_ops.init_vif = NULL;
47236 + pax_close_kernel();
47237 }
47238
47239 /* Enable 11a Band only if we have 5G antennas */
47240 diff --git a/drivers/net/wireless/zd1211rw/zd_usb.c b/drivers/net/wireless/zd1211rw/zd_usb.c
47241 index a912dc0..a8225ba 100644
47242 --- a/drivers/net/wireless/zd1211rw/zd_usb.c
47243 +++ b/drivers/net/wireless/zd1211rw/zd_usb.c
47244 @@ -385,7 +385,7 @@ static inline void handle_regs_int(struct urb *urb)
47245 {
47246 struct zd_usb *usb = urb->context;
47247 struct zd_usb_interrupt *intr = &usb->intr;
47248 - int len;
47249 + unsigned int len;
47250 u16 int_num;
47251
47252 ZD_ASSERT(in_interrupt());
47253 diff --git a/drivers/nfc/nfcwilink.c b/drivers/nfc/nfcwilink.c
47254 index 683671a..4519fc2 100644
47255 --- a/drivers/nfc/nfcwilink.c
47256 +++ b/drivers/nfc/nfcwilink.c
47257 @@ -497,7 +497,7 @@ static struct nci_ops nfcwilink_ops = {
47258
47259 static int nfcwilink_probe(struct platform_device *pdev)
47260 {
47261 - static struct nfcwilink *drv;
47262 + struct nfcwilink *drv;
47263 int rc;
47264 __u32 protocols;
47265
47266 diff --git a/drivers/oprofile/buffer_sync.c b/drivers/oprofile/buffer_sync.c
47267 index d93b2b6..ae50401 100644
47268 --- a/drivers/oprofile/buffer_sync.c
47269 +++ b/drivers/oprofile/buffer_sync.c
47270 @@ -332,7 +332,7 @@ static void add_data(struct op_entry *entry, struct mm_struct *mm)
47271 if (cookie == NO_COOKIE)
47272 offset = pc;
47273 if (cookie == INVALID_COOKIE) {
47274 - atomic_inc(&oprofile_stats.sample_lost_no_mapping);
47275 + atomic_inc_unchecked(&oprofile_stats.sample_lost_no_mapping);
47276 offset = pc;
47277 }
47278 if (cookie != last_cookie) {
47279 @@ -376,14 +376,14 @@ add_sample(struct mm_struct *mm, struct op_sample *s, int in_kernel)
47280 /* add userspace sample */
47281
47282 if (!mm) {
47283 - atomic_inc(&oprofile_stats.sample_lost_no_mm);
47284 + atomic_inc_unchecked(&oprofile_stats.sample_lost_no_mm);
47285 return 0;
47286 }
47287
47288 cookie = lookup_dcookie(mm, s->eip, &offset);
47289
47290 if (cookie == INVALID_COOKIE) {
47291 - atomic_inc(&oprofile_stats.sample_lost_no_mapping);
47292 + atomic_inc_unchecked(&oprofile_stats.sample_lost_no_mapping);
47293 return 0;
47294 }
47295
47296 @@ -552,7 +552,7 @@ void sync_buffer(int cpu)
47297 /* ignore backtraces if failed to add a sample */
47298 if (state == sb_bt_start) {
47299 state = sb_bt_ignore;
47300 - atomic_inc(&oprofile_stats.bt_lost_no_mapping);
47301 + atomic_inc_unchecked(&oprofile_stats.bt_lost_no_mapping);
47302 }
47303 }
47304 release_mm(mm);
47305 diff --git a/drivers/oprofile/event_buffer.c b/drivers/oprofile/event_buffer.c
47306 index c0cc4e7..44d4e54 100644
47307 --- a/drivers/oprofile/event_buffer.c
47308 +++ b/drivers/oprofile/event_buffer.c
47309 @@ -53,7 +53,7 @@ void add_event_entry(unsigned long value)
47310 }
47311
47312 if (buffer_pos == buffer_size) {
47313 - atomic_inc(&oprofile_stats.event_lost_overflow);
47314 + atomic_inc_unchecked(&oprofile_stats.event_lost_overflow);
47315 return;
47316 }
47317
47318 diff --git a/drivers/oprofile/oprof.c b/drivers/oprofile/oprof.c
47319 index ed2c3ec..deda85a 100644
47320 --- a/drivers/oprofile/oprof.c
47321 +++ b/drivers/oprofile/oprof.c
47322 @@ -110,7 +110,7 @@ static void switch_worker(struct work_struct *work)
47323 if (oprofile_ops.switch_events())
47324 return;
47325
47326 - atomic_inc(&oprofile_stats.multiplex_counter);
47327 + atomic_inc_unchecked(&oprofile_stats.multiplex_counter);
47328 start_switch_worker();
47329 }
47330
47331 diff --git a/drivers/oprofile/oprofile_files.c b/drivers/oprofile/oprofile_files.c
47332 index ee2cfce..7f8f699 100644
47333 --- a/drivers/oprofile/oprofile_files.c
47334 +++ b/drivers/oprofile/oprofile_files.c
47335 @@ -27,7 +27,7 @@ unsigned long oprofile_time_slice;
47336
47337 #ifdef CONFIG_OPROFILE_EVENT_MULTIPLEX
47338
47339 -static ssize_t timeout_read(struct file *file, char __user *buf,
47340 +static ssize_t __intentional_overflow(-1) timeout_read(struct file *file, char __user *buf,
47341 size_t count, loff_t *offset)
47342 {
47343 return oprofilefs_ulong_to_user(jiffies_to_msecs(oprofile_time_slice),
47344 diff --git a/drivers/oprofile/oprofile_stats.c b/drivers/oprofile/oprofile_stats.c
47345 index 59659ce..6c860a0 100644
47346 --- a/drivers/oprofile/oprofile_stats.c
47347 +++ b/drivers/oprofile/oprofile_stats.c
47348 @@ -30,11 +30,11 @@ void oprofile_reset_stats(void)
47349 cpu_buf->sample_invalid_eip = 0;
47350 }
47351
47352 - atomic_set(&oprofile_stats.sample_lost_no_mm, 0);
47353 - atomic_set(&oprofile_stats.sample_lost_no_mapping, 0);
47354 - atomic_set(&oprofile_stats.event_lost_overflow, 0);
47355 - atomic_set(&oprofile_stats.bt_lost_no_mapping, 0);
47356 - atomic_set(&oprofile_stats.multiplex_counter, 0);
47357 + atomic_set_unchecked(&oprofile_stats.sample_lost_no_mm, 0);
47358 + atomic_set_unchecked(&oprofile_stats.sample_lost_no_mapping, 0);
47359 + atomic_set_unchecked(&oprofile_stats.event_lost_overflow, 0);
47360 + atomic_set_unchecked(&oprofile_stats.bt_lost_no_mapping, 0);
47361 + atomic_set_unchecked(&oprofile_stats.multiplex_counter, 0);
47362 }
47363
47364
47365 diff --git a/drivers/oprofile/oprofile_stats.h b/drivers/oprofile/oprofile_stats.h
47366 index 1fc622b..8c48fc3 100644
47367 --- a/drivers/oprofile/oprofile_stats.h
47368 +++ b/drivers/oprofile/oprofile_stats.h
47369 @@ -13,11 +13,11 @@
47370 #include <linux/atomic.h>
47371
47372 struct oprofile_stat_struct {
47373 - atomic_t sample_lost_no_mm;
47374 - atomic_t sample_lost_no_mapping;
47375 - atomic_t bt_lost_no_mapping;
47376 - atomic_t event_lost_overflow;
47377 - atomic_t multiplex_counter;
47378 + atomic_unchecked_t sample_lost_no_mm;
47379 + atomic_unchecked_t sample_lost_no_mapping;
47380 + atomic_unchecked_t bt_lost_no_mapping;
47381 + atomic_unchecked_t event_lost_overflow;
47382 + atomic_unchecked_t multiplex_counter;
47383 };
47384
47385 extern struct oprofile_stat_struct oprofile_stats;
47386 diff --git a/drivers/oprofile/oprofilefs.c b/drivers/oprofile/oprofilefs.c
47387 index 3f49345..c750d0b 100644
47388 --- a/drivers/oprofile/oprofilefs.c
47389 +++ b/drivers/oprofile/oprofilefs.c
47390 @@ -176,8 +176,8 @@ int oprofilefs_create_ro_ulong(struct dentry *root,
47391
47392 static ssize_t atomic_read_file(struct file *file, char __user *buf, size_t count, loff_t *offset)
47393 {
47394 - atomic_t *val = file->private_data;
47395 - return oprofilefs_ulong_to_user(atomic_read(val), buf, count, offset);
47396 + atomic_unchecked_t *val = file->private_data;
47397 + return oprofilefs_ulong_to_user(atomic_read_unchecked(val), buf, count, offset);
47398 }
47399
47400
47401 @@ -189,7 +189,7 @@ static const struct file_operations atomic_ro_fops = {
47402
47403
47404 int oprofilefs_create_ro_atomic(struct dentry *root,
47405 - char const *name, atomic_t *val)
47406 + char const *name, atomic_unchecked_t *val)
47407 {
47408 return __oprofilefs_create_file(root, name,
47409 &atomic_ro_fops, 0444, val);
47410 diff --git a/drivers/oprofile/timer_int.c b/drivers/oprofile/timer_int.c
47411 index 61be1d9..dec05d7 100644
47412 --- a/drivers/oprofile/timer_int.c
47413 +++ b/drivers/oprofile/timer_int.c
47414 @@ -93,7 +93,7 @@ static int oprofile_cpu_notify(struct notifier_block *self,
47415 return NOTIFY_OK;
47416 }
47417
47418 -static struct notifier_block __refdata oprofile_cpu_notifier = {
47419 +static struct notifier_block oprofile_cpu_notifier = {
47420 .notifier_call = oprofile_cpu_notify,
47421 };
47422
47423 diff --git a/drivers/parport/procfs.c b/drivers/parport/procfs.c
47424 index 92ed045..62d39bd7 100644
47425 --- a/drivers/parport/procfs.c
47426 +++ b/drivers/parport/procfs.c
47427 @@ -64,7 +64,7 @@ static int do_active_device(ctl_table *table, int write,
47428
47429 *ppos += len;
47430
47431 - return copy_to_user(result, buffer, len) ? -EFAULT : 0;
47432 + return (len > sizeof buffer || copy_to_user(result, buffer, len)) ? -EFAULT : 0;
47433 }
47434
47435 #ifdef CONFIG_PARPORT_1284
47436 @@ -106,7 +106,7 @@ static int do_autoprobe(ctl_table *table, int write,
47437
47438 *ppos += len;
47439
47440 - return copy_to_user (result, buffer, len) ? -EFAULT : 0;
47441 + return (len > sizeof buffer || copy_to_user (result, buffer, len)) ? -EFAULT : 0;
47442 }
47443 #endif /* IEEE1284.3 support. */
47444
47445 diff --git a/drivers/pci/hotplug/acpiphp_ibm.c b/drivers/pci/hotplug/acpiphp_ibm.c
47446 index 8dcccff..35d701d 100644
47447 --- a/drivers/pci/hotplug/acpiphp_ibm.c
47448 +++ b/drivers/pci/hotplug/acpiphp_ibm.c
47449 @@ -452,7 +452,9 @@ static int __init ibm_acpiphp_init(void)
47450 goto init_cleanup;
47451 }
47452
47453 - ibm_apci_table_attr.size = ibm_get_table_from_acpi(NULL);
47454 + pax_open_kernel();
47455 + *(size_t *)&ibm_apci_table_attr.size = ibm_get_table_from_acpi(NULL);
47456 + pax_close_kernel();
47457 retval = sysfs_create_bin_file(sysdir, &ibm_apci_table_attr);
47458
47459 return retval;
47460 diff --git a/drivers/pci/hotplug/cpcihp_generic.c b/drivers/pci/hotplug/cpcihp_generic.c
47461 index 7536eef..52dc8fa 100644
47462 --- a/drivers/pci/hotplug/cpcihp_generic.c
47463 +++ b/drivers/pci/hotplug/cpcihp_generic.c
47464 @@ -73,7 +73,6 @@ static u16 port;
47465 static unsigned int enum_bit;
47466 static u8 enum_mask;
47467
47468 -static struct cpci_hp_controller_ops generic_hpc_ops;
47469 static struct cpci_hp_controller generic_hpc;
47470
47471 static int __init validate_parameters(void)
47472 @@ -139,6 +138,10 @@ static int query_enum(void)
47473 return ((value & enum_mask) == enum_mask);
47474 }
47475
47476 +static struct cpci_hp_controller_ops generic_hpc_ops = {
47477 + .query_enum = query_enum,
47478 +};
47479 +
47480 static int __init cpcihp_generic_init(void)
47481 {
47482 int status;
47483 @@ -165,7 +168,6 @@ static int __init cpcihp_generic_init(void)
47484 pci_dev_put(dev);
47485
47486 memset(&generic_hpc, 0, sizeof (struct cpci_hp_controller));
47487 - generic_hpc_ops.query_enum = query_enum;
47488 generic_hpc.ops = &generic_hpc_ops;
47489
47490 status = cpci_hp_register_controller(&generic_hpc);
47491 diff --git a/drivers/pci/hotplug/cpcihp_zt5550.c b/drivers/pci/hotplug/cpcihp_zt5550.c
47492 index e8c4a7c..7046f5c 100644
47493 --- a/drivers/pci/hotplug/cpcihp_zt5550.c
47494 +++ b/drivers/pci/hotplug/cpcihp_zt5550.c
47495 @@ -59,7 +59,6 @@
47496 /* local variables */
47497 static bool debug;
47498 static bool poll;
47499 -static struct cpci_hp_controller_ops zt5550_hpc_ops;
47500 static struct cpci_hp_controller zt5550_hpc;
47501
47502 /* Primary cPCI bus bridge device */
47503 @@ -205,6 +204,10 @@ static int zt5550_hc_disable_irq(void)
47504 return 0;
47505 }
47506
47507 +static struct cpci_hp_controller_ops zt5550_hpc_ops = {
47508 + .query_enum = zt5550_hc_query_enum,
47509 +};
47510 +
47511 static int zt5550_hc_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
47512 {
47513 int status;
47514 @@ -216,16 +219,17 @@ static int zt5550_hc_init_one (struct pci_dev *pdev, const struct pci_device_id
47515 dbg("returned from zt5550_hc_config");
47516
47517 memset(&zt5550_hpc, 0, sizeof (struct cpci_hp_controller));
47518 - zt5550_hpc_ops.query_enum = zt5550_hc_query_enum;
47519 zt5550_hpc.ops = &zt5550_hpc_ops;
47520 if(!poll) {
47521 zt5550_hpc.irq = hc_dev->irq;
47522 zt5550_hpc.irq_flags = IRQF_SHARED;
47523 zt5550_hpc.dev_id = hc_dev;
47524
47525 - zt5550_hpc_ops.enable_irq = zt5550_hc_enable_irq;
47526 - zt5550_hpc_ops.disable_irq = zt5550_hc_disable_irq;
47527 - zt5550_hpc_ops.check_irq = zt5550_hc_check_irq;
47528 + pax_open_kernel();
47529 + *(void **)&zt5550_hpc_ops.enable_irq = zt5550_hc_enable_irq;
47530 + *(void **)&zt5550_hpc_ops.disable_irq = zt5550_hc_disable_irq;
47531 + *(void **)&zt5550_hpc_ops.check_irq = zt5550_hc_check_irq;
47532 + pax_open_kernel();
47533 } else {
47534 info("using ENUM# polling mode");
47535 }
47536 diff --git a/drivers/pci/hotplug/cpqphp_nvram.c b/drivers/pci/hotplug/cpqphp_nvram.c
47537 index 76ba8a1..20ca857 100644
47538 --- a/drivers/pci/hotplug/cpqphp_nvram.c
47539 +++ b/drivers/pci/hotplug/cpqphp_nvram.c
47540 @@ -428,9 +428,13 @@ static u32 store_HRT (void __iomem *rom_start)
47541
47542 void compaq_nvram_init (void __iomem *rom_start)
47543 {
47544 +
47545 +#ifndef CONFIG_PAX_KERNEXEC
47546 if (rom_start) {
47547 compaq_int15_entry_point = (rom_start + ROM_INT15_PHY_ADDR - ROM_PHY_ADDR);
47548 }
47549 +#endif
47550 +
47551 dbg("int15 entry = %p\n", compaq_int15_entry_point);
47552
47553 /* initialize our int15 lock */
47554 diff --git a/drivers/pci/hotplug/pci_hotplug_core.c b/drivers/pci/hotplug/pci_hotplug_core.c
47555 index cfa92a9..29539c5 100644
47556 --- a/drivers/pci/hotplug/pci_hotplug_core.c
47557 +++ b/drivers/pci/hotplug/pci_hotplug_core.c
47558 @@ -441,8 +441,10 @@ int __pci_hp_register(struct hotplug_slot *slot, struct pci_bus *bus,
47559 return -EINVAL;
47560 }
47561
47562 - slot->ops->owner = owner;
47563 - slot->ops->mod_name = mod_name;
47564 + pax_open_kernel();
47565 + *(struct module **)&slot->ops->owner = owner;
47566 + *(const char **)&slot->ops->mod_name = mod_name;
47567 + pax_close_kernel();
47568
47569 mutex_lock(&pci_hp_mutex);
47570 /*
47571 diff --git a/drivers/pci/hotplug/pciehp_core.c b/drivers/pci/hotplug/pciehp_core.c
47572 index 0e0a2ff..29dff57 100644
47573 --- a/drivers/pci/hotplug/pciehp_core.c
47574 +++ b/drivers/pci/hotplug/pciehp_core.c
47575 @@ -92,7 +92,7 @@ static int init_slot(struct controller *ctrl)
47576 struct slot *slot = ctrl->slot;
47577 struct hotplug_slot *hotplug = NULL;
47578 struct hotplug_slot_info *info = NULL;
47579 - struct hotplug_slot_ops *ops = NULL;
47580 + hotplug_slot_ops_no_const *ops = NULL;
47581 char name[SLOT_NAME_SIZE];
47582 int retval = -ENOMEM;
47583
47584 diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c
47585 index fb02fc2..83dc2c3 100644
47586 --- a/drivers/pci/msi.c
47587 +++ b/drivers/pci/msi.c
47588 @@ -524,8 +524,8 @@ static int populate_msi_sysfs(struct pci_dev *pdev)
47589 {
47590 struct attribute **msi_attrs;
47591 struct attribute *msi_attr;
47592 - struct device_attribute *msi_dev_attr;
47593 - struct attribute_group *msi_irq_group;
47594 + device_attribute_no_const *msi_dev_attr;
47595 + attribute_group_no_const *msi_irq_group;
47596 const struct attribute_group **msi_irq_groups;
47597 struct msi_desc *entry;
47598 int ret = -ENOMEM;
47599 @@ -589,7 +589,7 @@ error_attrs:
47600 count = 0;
47601 msi_attr = msi_attrs[count];
47602 while (msi_attr) {
47603 - msi_dev_attr = container_of(msi_attr, struct device_attribute, attr);
47604 + msi_dev_attr = container_of(msi_attr, device_attribute_no_const, attr);
47605 kfree(msi_attr->name);
47606 kfree(msi_dev_attr);
47607 ++count;
47608 diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
47609 index 4e0acef..bd98e31 100644
47610 --- a/drivers/pci/pci-sysfs.c
47611 +++ b/drivers/pci/pci-sysfs.c
47612 @@ -1101,7 +1101,7 @@ static int pci_create_attr(struct pci_dev *pdev, int num, int write_combine)
47613 {
47614 /* allocate attribute structure, piggyback attribute name */
47615 int name_len = write_combine ? 13 : 10;
47616 - struct bin_attribute *res_attr;
47617 + bin_attribute_no_const *res_attr;
47618 int retval;
47619
47620 res_attr = kzalloc(sizeof(*res_attr) + name_len, GFP_ATOMIC);
47621 @@ -1286,7 +1286,7 @@ static struct device_attribute reset_attr = __ATTR(reset, 0200, NULL, reset_stor
47622 static int pci_create_capabilities_sysfs(struct pci_dev *dev)
47623 {
47624 int retval;
47625 - struct bin_attribute *attr;
47626 + bin_attribute_no_const *attr;
47627
47628 /* If the device has VPD, try to expose it in sysfs. */
47629 if (dev->vpd) {
47630 @@ -1333,7 +1333,7 @@ int __must_check pci_create_sysfs_dev_files (struct pci_dev *pdev)
47631 {
47632 int retval;
47633 int rom_size = 0;
47634 - struct bin_attribute *attr;
47635 + bin_attribute_no_const *attr;
47636
47637 if (!sysfs_initialized)
47638 return -EACCES;
47639 diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
47640 index 6bd0822..35bc2b3 100644
47641 --- a/drivers/pci/pci.h
47642 +++ b/drivers/pci/pci.h
47643 @@ -91,7 +91,7 @@ struct pci_vpd_ops {
47644 struct pci_vpd {
47645 unsigned int len;
47646 const struct pci_vpd_ops *ops;
47647 - struct bin_attribute *attr; /* descriptor for sysfs VPD entry */
47648 + bin_attribute_no_const *attr; /* descriptor for sysfs VPD entry */
47649 };
47650
47651 int pci_vpd_pci22_init(struct pci_dev *dev);
47652 diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c
47653 index e1e7026..d28dd33 100644
47654 --- a/drivers/pci/pcie/aspm.c
47655 +++ b/drivers/pci/pcie/aspm.c
47656 @@ -27,9 +27,9 @@
47657 #define MODULE_PARAM_PREFIX "pcie_aspm."
47658
47659 /* Note: those are not register definitions */
47660 -#define ASPM_STATE_L0S_UP (1) /* Upstream direction L0s state */
47661 -#define ASPM_STATE_L0S_DW (2) /* Downstream direction L0s state */
47662 -#define ASPM_STATE_L1 (4) /* L1 state */
47663 +#define ASPM_STATE_L0S_UP (1U) /* Upstream direction L0s state */
47664 +#define ASPM_STATE_L0S_DW (2U) /* Downstream direction L0s state */
47665 +#define ASPM_STATE_L1 (4U) /* L1 state */
47666 #define ASPM_STATE_L0S (ASPM_STATE_L0S_UP | ASPM_STATE_L0S_DW)
47667 #define ASPM_STATE_ALL (ASPM_STATE_L0S | ASPM_STATE_L1)
47668
47669 diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
47670 index ef09f5f..49ac62f 100644
47671 --- a/drivers/pci/probe.c
47672 +++ b/drivers/pci/probe.c
47673 @@ -175,7 +175,7 @@ int __pci_read_base(struct pci_dev *dev, enum pci_bar_type type,
47674 struct pci_bus_region region, inverted_region;
47675 bool bar_too_big = false, bar_disabled = false;
47676
47677 - mask = type ? PCI_ROM_ADDRESS_MASK : ~0;
47678 + mask = type ? (u32)PCI_ROM_ADDRESS_MASK : ~0;
47679
47680 /* No printks while decoding is disabled! */
47681 if (!dev->mmio_always_on) {
47682 diff --git a/drivers/pci/proc.c b/drivers/pci/proc.c
47683 index 46d1378..30e452b 100644
47684 --- a/drivers/pci/proc.c
47685 +++ b/drivers/pci/proc.c
47686 @@ -434,7 +434,16 @@ static const struct file_operations proc_bus_pci_dev_operations = {
47687 static int __init pci_proc_init(void)
47688 {
47689 struct pci_dev *dev = NULL;
47690 +
47691 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
47692 +#ifdef CONFIG_GRKERNSEC_PROC_USER
47693 + proc_bus_pci_dir = proc_mkdir_mode("bus/pci", S_IRUSR | S_IXUSR, NULL);
47694 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
47695 + proc_bus_pci_dir = proc_mkdir_mode("bus/pci", S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP, NULL);
47696 +#endif
47697 +#else
47698 proc_bus_pci_dir = proc_mkdir("bus/pci", NULL);
47699 +#endif
47700 proc_create("devices", 0, proc_bus_pci_dir,
47701 &proc_bus_pci_dev_operations);
47702 proc_initialized = 1;
47703 diff --git a/drivers/platform/chrome/chromeos_laptop.c b/drivers/platform/chrome/chromeos_laptop.c
47704 index 7f3aad0..7d604bb 100644
47705 --- a/drivers/platform/chrome/chromeos_laptop.c
47706 +++ b/drivers/platform/chrome/chromeos_laptop.c
47707 @@ -406,7 +406,7 @@ static struct chromeos_laptop cr48 = {
47708 .callback = chromeos_laptop_dmi_matched, \
47709 .driver_data = (void *)&board_
47710
47711 -static struct dmi_system_id chromeos_laptop_dmi_table[] __initdata = {
47712 +static struct dmi_system_id chromeos_laptop_dmi_table[] __initconst = {
47713 {
47714 .ident = "Samsung Series 5 550",
47715 .matches = {
47716 diff --git a/drivers/platform/x86/alienware-wmi.c b/drivers/platform/x86/alienware-wmi.c
47717 index 541f951..4dfd598 100644
47718 --- a/drivers/platform/x86/alienware-wmi.c
47719 +++ b/drivers/platform/x86/alienware-wmi.c
47720 @@ -132,7 +132,7 @@ struct wmax_led_args {
47721 } __packed;
47722
47723 static struct platform_device *platform_device;
47724 -static struct device_attribute *zone_dev_attrs;
47725 +static device_attribute_no_const *zone_dev_attrs;
47726 static struct attribute **zone_attrs;
47727 static struct platform_zone *zone_data;
47728
47729 @@ -143,7 +143,7 @@ static struct platform_driver platform_driver = {
47730 }
47731 };
47732
47733 -static struct attribute_group zone_attribute_group = {
47734 +static attribute_group_no_const zone_attribute_group = {
47735 .name = "rgb_zones",
47736 };
47737
47738 diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c
47739 index c5e082f..d6307a0 100644
47740 --- a/drivers/platform/x86/asus-wmi.c
47741 +++ b/drivers/platform/x86/asus-wmi.c
47742 @@ -1595,6 +1595,10 @@ static int show_dsts(struct seq_file *m, void *data)
47743 int err;
47744 u32 retval = -1;
47745
47746 +#ifdef CONFIG_GRKERNSEC_KMEM
47747 + return -EPERM;
47748 +#endif
47749 +
47750 err = asus_wmi_get_devstate(asus, asus->debug.dev_id, &retval);
47751
47752 if (err < 0)
47753 @@ -1611,6 +1615,10 @@ static int show_devs(struct seq_file *m, void *data)
47754 int err;
47755 u32 retval = -1;
47756
47757 +#ifdef CONFIG_GRKERNSEC_KMEM
47758 + return -EPERM;
47759 +#endif
47760 +
47761 err = asus_wmi_set_devstate(asus->debug.dev_id, asus->debug.ctrl_param,
47762 &retval);
47763
47764 @@ -1635,6 +1643,10 @@ static int show_call(struct seq_file *m, void *data)
47765 union acpi_object *obj;
47766 acpi_status status;
47767
47768 +#ifdef CONFIG_GRKERNSEC_KMEM
47769 + return -EPERM;
47770 +#endif
47771 +
47772 status = wmi_evaluate_method(ASUS_WMI_MGMT_GUID,
47773 1, asus->debug.method_id,
47774 &input, &output);
47775 diff --git a/drivers/platform/x86/msi-laptop.c b/drivers/platform/x86/msi-laptop.c
47776 index 62f8030..c7f2a45 100644
47777 --- a/drivers/platform/x86/msi-laptop.c
47778 +++ b/drivers/platform/x86/msi-laptop.c
47779 @@ -1000,12 +1000,14 @@ static int __init load_scm_model_init(struct platform_device *sdev)
47780
47781 if (!quirks->ec_read_only) {
47782 /* allow userland write sysfs file */
47783 - dev_attr_bluetooth.store = store_bluetooth;
47784 - dev_attr_wlan.store = store_wlan;
47785 - dev_attr_threeg.store = store_threeg;
47786 - dev_attr_bluetooth.attr.mode |= S_IWUSR;
47787 - dev_attr_wlan.attr.mode |= S_IWUSR;
47788 - dev_attr_threeg.attr.mode |= S_IWUSR;
47789 + pax_open_kernel();
47790 + *(void **)&dev_attr_bluetooth.store = store_bluetooth;
47791 + *(void **)&dev_attr_wlan.store = store_wlan;
47792 + *(void **)&dev_attr_threeg.store = store_threeg;
47793 + *(umode_t *)&dev_attr_bluetooth.attr.mode |= S_IWUSR;
47794 + *(umode_t *)&dev_attr_wlan.attr.mode |= S_IWUSR;
47795 + *(umode_t *)&dev_attr_threeg.attr.mode |= S_IWUSR;
47796 + pax_close_kernel();
47797 }
47798
47799 /* disable hardware control by fn key */
47800 diff --git a/drivers/platform/x86/msi-wmi.c b/drivers/platform/x86/msi-wmi.c
47801 index 70222f2..8c8ce66 100644
47802 --- a/drivers/platform/x86/msi-wmi.c
47803 +++ b/drivers/platform/x86/msi-wmi.c
47804 @@ -183,7 +183,7 @@ static const struct backlight_ops msi_backlight_ops = {
47805 static void msi_wmi_notify(u32 value, void *context)
47806 {
47807 struct acpi_buffer response = { ACPI_ALLOCATE_BUFFER, NULL };
47808 - static struct key_entry *key;
47809 + struct key_entry *key;
47810 union acpi_object *obj;
47811 acpi_status status;
47812
47813 diff --git a/drivers/platform/x86/sony-laptop.c b/drivers/platform/x86/sony-laptop.c
47814 index 9c5a074..06c976a 100644
47815 --- a/drivers/platform/x86/sony-laptop.c
47816 +++ b/drivers/platform/x86/sony-laptop.c
47817 @@ -2527,7 +2527,7 @@ static void sony_nc_gfx_switch_cleanup(struct platform_device *pd)
47818 }
47819
47820 /* High speed charging function */
47821 -static struct device_attribute *hsc_handle;
47822 +static device_attribute_no_const *hsc_handle;
47823
47824 static ssize_t sony_nc_highspeed_charging_store(struct device *dev,
47825 struct device_attribute *attr,
47826 @@ -2601,7 +2601,7 @@ static void sony_nc_highspeed_charging_cleanup(struct platform_device *pd)
47827 }
47828
47829 /* low battery function */
47830 -static struct device_attribute *lowbatt_handle;
47831 +static device_attribute_no_const *lowbatt_handle;
47832
47833 static ssize_t sony_nc_lowbatt_store(struct device *dev,
47834 struct device_attribute *attr,
47835 @@ -2667,7 +2667,7 @@ static void sony_nc_lowbatt_cleanup(struct platform_device *pd)
47836 }
47837
47838 /* fan speed function */
47839 -static struct device_attribute *fan_handle, *hsf_handle;
47840 +static device_attribute_no_const *fan_handle, *hsf_handle;
47841
47842 static ssize_t sony_nc_hsfan_store(struct device *dev,
47843 struct device_attribute *attr,
47844 @@ -2774,7 +2774,7 @@ static void sony_nc_fanspeed_cleanup(struct platform_device *pd)
47845 }
47846
47847 /* USB charge function */
47848 -static struct device_attribute *uc_handle;
47849 +static device_attribute_no_const *uc_handle;
47850
47851 static ssize_t sony_nc_usb_charge_store(struct device *dev,
47852 struct device_attribute *attr,
47853 @@ -2848,7 +2848,7 @@ static void sony_nc_usb_charge_cleanup(struct platform_device *pd)
47854 }
47855
47856 /* Panel ID function */
47857 -static struct device_attribute *panel_handle;
47858 +static device_attribute_no_const *panel_handle;
47859
47860 static ssize_t sony_nc_panelid_show(struct device *dev,
47861 struct device_attribute *attr, char *buffer)
47862 @@ -2895,7 +2895,7 @@ static void sony_nc_panelid_cleanup(struct platform_device *pd)
47863 }
47864
47865 /* smart connect function */
47866 -static struct device_attribute *sc_handle;
47867 +static device_attribute_no_const *sc_handle;
47868
47869 static ssize_t sony_nc_smart_conn_store(struct device *dev,
47870 struct device_attribute *attr,
47871 diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
47872 index 15e61c1..40a39c7 100644
47873 --- a/drivers/platform/x86/thinkpad_acpi.c
47874 +++ b/drivers/platform/x86/thinkpad_acpi.c
47875 @@ -2094,7 +2094,7 @@ static int hotkey_mask_get(void)
47876 return 0;
47877 }
47878
47879 -void static hotkey_mask_warn_incomplete_mask(void)
47880 +static void hotkey_mask_warn_incomplete_mask(void)
47881 {
47882 /* log only what the user can fix... */
47883 const u32 wantedmask = hotkey_driver_mask &
47884 @@ -2438,10 +2438,10 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
47885 && !tp_features.bright_unkfw)
47886 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
47887 }
47888 +}
47889
47890 #undef TPACPI_COMPARE_KEY
47891 #undef TPACPI_MAY_SEND_KEY
47892 -}
47893
47894 /*
47895 * Polling driver
47896 diff --git a/drivers/pnp/pnpbios/bioscalls.c b/drivers/pnp/pnpbios/bioscalls.c
47897 index 438d4c7..ca8a2fb 100644
47898 --- a/drivers/pnp/pnpbios/bioscalls.c
47899 +++ b/drivers/pnp/pnpbios/bioscalls.c
47900 @@ -59,7 +59,7 @@ do { \
47901 set_desc_limit(&gdt[(selname) >> 3], (size) - 1); \
47902 } while(0)
47903
47904 -static struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4092,
47905 +static const struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4093,
47906 (unsigned long)__va(0x400UL), PAGE_SIZE - 0x400 - 1);
47907
47908 /*
47909 @@ -96,7 +96,10 @@ static inline u16 call_pnp_bios(u16 func, u16 arg1, u16 arg2, u16 arg3,
47910
47911 cpu = get_cpu();
47912 save_desc_40 = get_cpu_gdt_table(cpu)[0x40 / 8];
47913 +
47914 + pax_open_kernel();
47915 get_cpu_gdt_table(cpu)[0x40 / 8] = bad_bios_desc;
47916 + pax_close_kernel();
47917
47918 /* On some boxes IRQ's during PnP BIOS calls are deadly. */
47919 spin_lock_irqsave(&pnp_bios_lock, flags);
47920 @@ -134,7 +137,10 @@ static inline u16 call_pnp_bios(u16 func, u16 arg1, u16 arg2, u16 arg3,
47921 :"memory");
47922 spin_unlock_irqrestore(&pnp_bios_lock, flags);
47923
47924 + pax_open_kernel();
47925 get_cpu_gdt_table(cpu)[0x40 / 8] = save_desc_40;
47926 + pax_close_kernel();
47927 +
47928 put_cpu();
47929
47930 /* If we get here and this is set then the PnP BIOS faulted on us. */
47931 @@ -468,7 +474,7 @@ int pnp_bios_read_escd(char *data, u32 nvram_base)
47932 return status;
47933 }
47934
47935 -void pnpbios_calls_init(union pnp_bios_install_struct *header)
47936 +void __init pnpbios_calls_init(union pnp_bios_install_struct *header)
47937 {
47938 int i;
47939
47940 @@ -476,6 +482,8 @@ void pnpbios_calls_init(union pnp_bios_install_struct *header)
47941 pnp_bios_callpoint.offset = header->fields.pm16offset;
47942 pnp_bios_callpoint.segment = PNP_CS16;
47943
47944 + pax_open_kernel();
47945 +
47946 for_each_possible_cpu(i) {
47947 struct desc_struct *gdt = get_cpu_gdt_table(i);
47948 if (!gdt)
47949 @@ -487,4 +495,6 @@ void pnpbios_calls_init(union pnp_bios_install_struct *header)
47950 set_desc_base(&gdt[GDT_ENTRY_PNPBIOS_DS],
47951 (unsigned long)__va(header->fields.pm16dseg));
47952 }
47953 +
47954 + pax_close_kernel();
47955 }
47956 diff --git a/drivers/pnp/resource.c b/drivers/pnp/resource.c
47957 index 01712cb..782e822 100644
47958 --- a/drivers/pnp/resource.c
47959 +++ b/drivers/pnp/resource.c
47960 @@ -360,7 +360,7 @@ int pnp_check_irq(struct pnp_dev *dev, struct resource *res)
47961 return 1;
47962
47963 /* check if the resource is valid */
47964 - if (*irq < 0 || *irq > 15)
47965 + if (*irq > 15)
47966 return 0;
47967
47968 /* check if the resource is reserved */
47969 @@ -424,7 +424,7 @@ int pnp_check_dma(struct pnp_dev *dev, struct resource *res)
47970 return 1;
47971
47972 /* check if the resource is valid */
47973 - if (*dma < 0 || *dma == 4 || *dma > 7)
47974 + if (*dma == 4 || *dma > 7)
47975 return 0;
47976
47977 /* check if the resource is reserved */
47978 diff --git a/drivers/power/pda_power.c b/drivers/power/pda_power.c
47979 index 0c52e2a..3421ab7 100644
47980 --- a/drivers/power/pda_power.c
47981 +++ b/drivers/power/pda_power.c
47982 @@ -37,7 +37,11 @@ static int polling;
47983
47984 #if IS_ENABLED(CONFIG_USB_PHY)
47985 static struct usb_phy *transceiver;
47986 -static struct notifier_block otg_nb;
47987 +static int otg_handle_notification(struct notifier_block *nb,
47988 + unsigned long event, void *unused);
47989 +static struct notifier_block otg_nb = {
47990 + .notifier_call = otg_handle_notification
47991 +};
47992 #endif
47993
47994 static struct regulator *ac_draw;
47995 @@ -369,7 +373,6 @@ static int pda_power_probe(struct platform_device *pdev)
47996
47997 #if IS_ENABLED(CONFIG_USB_PHY)
47998 if (!IS_ERR_OR_NULL(transceiver) && pdata->use_otg_notifier) {
47999 - otg_nb.notifier_call = otg_handle_notification;
48000 ret = usb_register_notifier(transceiver, &otg_nb);
48001 if (ret) {
48002 dev_err(dev, "failure to register otg notifier\n");
48003 diff --git a/drivers/power/power_supply.h b/drivers/power/power_supply.h
48004 index cc439fd..8fa30df 100644
48005 --- a/drivers/power/power_supply.h
48006 +++ b/drivers/power/power_supply.h
48007 @@ -16,12 +16,12 @@ struct power_supply;
48008
48009 #ifdef CONFIG_SYSFS
48010
48011 -extern void power_supply_init_attrs(struct device_type *dev_type);
48012 +extern void power_supply_init_attrs(void);
48013 extern int power_supply_uevent(struct device *dev, struct kobj_uevent_env *env);
48014
48015 #else
48016
48017 -static inline void power_supply_init_attrs(struct device_type *dev_type) {}
48018 +static inline void power_supply_init_attrs(void) {}
48019 #define power_supply_uevent NULL
48020
48021 #endif /* CONFIG_SYSFS */
48022 diff --git a/drivers/power/power_supply_core.c b/drivers/power/power_supply_core.c
48023 index 2660664..75fcb04 100644
48024 --- a/drivers/power/power_supply_core.c
48025 +++ b/drivers/power/power_supply_core.c
48026 @@ -28,7 +28,10 @@ EXPORT_SYMBOL_GPL(power_supply_class);
48027 ATOMIC_NOTIFIER_HEAD(power_supply_notifier);
48028 EXPORT_SYMBOL_GPL(power_supply_notifier);
48029
48030 -static struct device_type power_supply_dev_type;
48031 +extern const struct attribute_group *power_supply_attr_groups[];
48032 +static struct device_type power_supply_dev_type = {
48033 + .groups = power_supply_attr_groups,
48034 +};
48035
48036 static bool __power_supply_is_supplied_by(struct power_supply *supplier,
48037 struct power_supply *supply)
48038 @@ -628,7 +631,7 @@ static int __init power_supply_class_init(void)
48039 return PTR_ERR(power_supply_class);
48040
48041 power_supply_class->dev_uevent = power_supply_uevent;
48042 - power_supply_init_attrs(&power_supply_dev_type);
48043 + power_supply_init_attrs();
48044
48045 return 0;
48046 }
48047 diff --git a/drivers/power/power_supply_sysfs.c b/drivers/power/power_supply_sysfs.c
48048 index 44420d1..967126e 100644
48049 --- a/drivers/power/power_supply_sysfs.c
48050 +++ b/drivers/power/power_supply_sysfs.c
48051 @@ -230,17 +230,15 @@ static struct attribute_group power_supply_attr_group = {
48052 .is_visible = power_supply_attr_is_visible,
48053 };
48054
48055 -static const struct attribute_group *power_supply_attr_groups[] = {
48056 +const struct attribute_group *power_supply_attr_groups[] = {
48057 &power_supply_attr_group,
48058 NULL,
48059 };
48060
48061 -void power_supply_init_attrs(struct device_type *dev_type)
48062 +void power_supply_init_attrs(void)
48063 {
48064 int i;
48065
48066 - dev_type->groups = power_supply_attr_groups;
48067 -
48068 for (i = 0; i < ARRAY_SIZE(power_supply_attrs); i++)
48069 __power_supply_attrs[i] = &power_supply_attrs[i].attr;
48070 }
48071 diff --git a/drivers/powercap/powercap_sys.c b/drivers/powercap/powercap_sys.c
48072 index 84419af..268ede8 100644
48073 --- a/drivers/powercap/powercap_sys.c
48074 +++ b/drivers/powercap/powercap_sys.c
48075 @@ -154,8 +154,77 @@ struct powercap_constraint_attr {
48076 struct device_attribute name_attr;
48077 };
48078
48079 +static ssize_t show_constraint_name(struct device *dev,
48080 + struct device_attribute *dev_attr,
48081 + char *buf);
48082 +
48083 static struct powercap_constraint_attr
48084 - constraint_attrs[MAX_CONSTRAINTS_PER_ZONE];
48085 + constraint_attrs[MAX_CONSTRAINTS_PER_ZONE] = {
48086 + [0 ... MAX_CONSTRAINTS_PER_ZONE - 1] = {
48087 + .power_limit_attr = {
48088 + .attr = {
48089 + .name = NULL,
48090 + .mode = S_IWUSR | S_IRUGO
48091 + },
48092 + .show = show_constraint_power_limit_uw,
48093 + .store = store_constraint_power_limit_uw
48094 + },
48095 +
48096 + .time_window_attr = {
48097 + .attr = {
48098 + .name = NULL,
48099 + .mode = S_IWUSR | S_IRUGO
48100 + },
48101 + .show = show_constraint_time_window_us,
48102 + .store = store_constraint_time_window_us
48103 + },
48104 +
48105 + .max_power_attr = {
48106 + .attr = {
48107 + .name = NULL,
48108 + .mode = S_IRUGO
48109 + },
48110 + .show = show_constraint_max_power_uw,
48111 + .store = NULL
48112 + },
48113 +
48114 + .min_power_attr = {
48115 + .attr = {
48116 + .name = NULL,
48117 + .mode = S_IRUGO
48118 + },
48119 + .show = show_constraint_min_power_uw,
48120 + .store = NULL
48121 + },
48122 +
48123 + .max_time_window_attr = {
48124 + .attr = {
48125 + .name = NULL,
48126 + .mode = S_IRUGO
48127 + },
48128 + .show = show_constraint_max_time_window_us,
48129 + .store = NULL
48130 + },
48131 +
48132 + .min_time_window_attr = {
48133 + .attr = {
48134 + .name = NULL,
48135 + .mode = S_IRUGO
48136 + },
48137 + .show = show_constraint_min_time_window_us,
48138 + .store = NULL
48139 + },
48140 +
48141 + .name_attr = {
48142 + .attr = {
48143 + .name = NULL,
48144 + .mode = S_IRUGO
48145 + },
48146 + .show = show_constraint_name,
48147 + .store = NULL
48148 + }
48149 + }
48150 +};
48151
48152 /* A list of powercap control_types */
48153 static LIST_HEAD(powercap_cntrl_list);
48154 @@ -193,23 +262,16 @@ static ssize_t show_constraint_name(struct device *dev,
48155 }
48156
48157 static int create_constraint_attribute(int id, const char *name,
48158 - int mode,
48159 - struct device_attribute *dev_attr,
48160 - ssize_t (*show)(struct device *,
48161 - struct device_attribute *, char *),
48162 - ssize_t (*store)(struct device *,
48163 - struct device_attribute *,
48164 - const char *, size_t)
48165 - )
48166 + struct device_attribute *dev_attr)
48167 {
48168 + name = kasprintf(GFP_KERNEL, "constraint_%d_%s", id, name);
48169
48170 - dev_attr->attr.name = kasprintf(GFP_KERNEL, "constraint_%d_%s",
48171 - id, name);
48172 - if (!dev_attr->attr.name)
48173 + if (!name)
48174 return -ENOMEM;
48175 - dev_attr->attr.mode = mode;
48176 - dev_attr->show = show;
48177 - dev_attr->store = store;
48178 +
48179 + pax_open_kernel();
48180 + *(const char **)&dev_attr->attr.name = name;
48181 + pax_close_kernel();
48182
48183 return 0;
48184 }
48185 @@ -236,49 +298,31 @@ static int seed_constraint_attributes(void)
48186
48187 for (i = 0; i < MAX_CONSTRAINTS_PER_ZONE; ++i) {
48188 ret = create_constraint_attribute(i, "power_limit_uw",
48189 - S_IWUSR | S_IRUGO,
48190 - &constraint_attrs[i].power_limit_attr,
48191 - show_constraint_power_limit_uw,
48192 - store_constraint_power_limit_uw);
48193 + &constraint_attrs[i].power_limit_attr);
48194 if (ret)
48195 goto err_alloc;
48196 ret = create_constraint_attribute(i, "time_window_us",
48197 - S_IWUSR | S_IRUGO,
48198 - &constraint_attrs[i].time_window_attr,
48199 - show_constraint_time_window_us,
48200 - store_constraint_time_window_us);
48201 + &constraint_attrs[i].time_window_attr);
48202 if (ret)
48203 goto err_alloc;
48204 - ret = create_constraint_attribute(i, "name", S_IRUGO,
48205 - &constraint_attrs[i].name_attr,
48206 - show_constraint_name,
48207 - NULL);
48208 + ret = create_constraint_attribute(i, "name",
48209 + &constraint_attrs[i].name_attr);
48210 if (ret)
48211 goto err_alloc;
48212 - ret = create_constraint_attribute(i, "max_power_uw", S_IRUGO,
48213 - &constraint_attrs[i].max_power_attr,
48214 - show_constraint_max_power_uw,
48215 - NULL);
48216 + ret = create_constraint_attribute(i, "max_power_uw",
48217 + &constraint_attrs[i].max_power_attr);
48218 if (ret)
48219 goto err_alloc;
48220 - ret = create_constraint_attribute(i, "min_power_uw", S_IRUGO,
48221 - &constraint_attrs[i].min_power_attr,
48222 - show_constraint_min_power_uw,
48223 - NULL);
48224 + ret = create_constraint_attribute(i, "min_power_uw",
48225 + &constraint_attrs[i].min_power_attr);
48226 if (ret)
48227 goto err_alloc;
48228 ret = create_constraint_attribute(i, "max_time_window_us",
48229 - S_IRUGO,
48230 - &constraint_attrs[i].max_time_window_attr,
48231 - show_constraint_max_time_window_us,
48232 - NULL);
48233 + &constraint_attrs[i].max_time_window_attr);
48234 if (ret)
48235 goto err_alloc;
48236 ret = create_constraint_attribute(i, "min_time_window_us",
48237 - S_IRUGO,
48238 - &constraint_attrs[i].min_time_window_attr,
48239 - show_constraint_min_time_window_us,
48240 - NULL);
48241 + &constraint_attrs[i].min_time_window_attr);
48242 if (ret)
48243 goto err_alloc;
48244
48245 @@ -378,10 +422,12 @@ static void create_power_zone_common_attributes(
48246 power_zone->zone_dev_attrs[count++] =
48247 &dev_attr_max_energy_range_uj.attr;
48248 if (power_zone->ops->get_energy_uj) {
48249 + pax_open_kernel();
48250 if (power_zone->ops->reset_energy_uj)
48251 - dev_attr_energy_uj.attr.mode = S_IWUSR | S_IRUGO;
48252 + *(umode_t *)&dev_attr_energy_uj.attr.mode = S_IWUSR | S_IRUGO;
48253 else
48254 - dev_attr_energy_uj.attr.mode = S_IRUGO;
48255 + *(umode_t *)&dev_attr_energy_uj.attr.mode = S_IRUGO;
48256 + pax_close_kernel();
48257 power_zone->zone_dev_attrs[count++] =
48258 &dev_attr_energy_uj.attr;
48259 }
48260 diff --git a/drivers/ptp/ptp_private.h b/drivers/ptp/ptp_private.h
48261 index 9c5d414..c7900ce 100644
48262 --- a/drivers/ptp/ptp_private.h
48263 +++ b/drivers/ptp/ptp_private.h
48264 @@ -51,7 +51,7 @@ struct ptp_clock {
48265 struct mutex pincfg_mux; /* protect concurrent info->pin_config access */
48266 wait_queue_head_t tsev_wq;
48267 int defunct; /* tells readers to go away when clock is being removed */
48268 - struct device_attribute *pin_dev_attr;
48269 + device_attribute_no_const *pin_dev_attr;
48270 struct attribute **pin_attr;
48271 struct attribute_group pin_attr_group;
48272 };
48273 diff --git a/drivers/ptp/ptp_sysfs.c b/drivers/ptp/ptp_sysfs.c
48274 index 302e626..12579af 100644
48275 --- a/drivers/ptp/ptp_sysfs.c
48276 +++ b/drivers/ptp/ptp_sysfs.c
48277 @@ -280,7 +280,7 @@ static int ptp_populate_pins(struct ptp_clock *ptp)
48278 goto no_pin_attr;
48279
48280 for (i = 0; i < n_pins; i++) {
48281 - struct device_attribute *da = &ptp->pin_dev_attr[i];
48282 + device_attribute_no_const *da = &ptp->pin_dev_attr[i];
48283 sysfs_attr_init(&da->attr);
48284 da->attr.name = info->pin_config[i].name;
48285 da->attr.mode = 0644;
48286 diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
48287 index 9a09f3c..450b523 100644
48288 --- a/drivers/regulator/core.c
48289 +++ b/drivers/regulator/core.c
48290 @@ -3380,7 +3380,7 @@ regulator_register(const struct regulator_desc *regulator_desc,
48291 {
48292 const struct regulation_constraints *constraints = NULL;
48293 const struct regulator_init_data *init_data;
48294 - static atomic_t regulator_no = ATOMIC_INIT(0);
48295 + static atomic_unchecked_t regulator_no = ATOMIC_INIT(0);
48296 struct regulator_dev *rdev;
48297 struct device *dev;
48298 int ret, i;
48299 @@ -3450,7 +3450,7 @@ regulator_register(const struct regulator_desc *regulator_desc,
48300 rdev->dev.of_node = config->of_node;
48301 rdev->dev.parent = dev;
48302 dev_set_name(&rdev->dev, "regulator.%d",
48303 - atomic_inc_return(&regulator_no) - 1);
48304 + atomic_inc_return_unchecked(&regulator_no) - 1);
48305 ret = device_register(&rdev->dev);
48306 if (ret != 0) {
48307 put_device(&rdev->dev);
48308 diff --git a/drivers/regulator/max8660.c b/drivers/regulator/max8660.c
48309 index 2fc4111..6aa88ca 100644
48310 --- a/drivers/regulator/max8660.c
48311 +++ b/drivers/regulator/max8660.c
48312 @@ -424,8 +424,10 @@ static int max8660_probe(struct i2c_client *client,
48313 max8660->shadow_regs[MAX8660_OVER1] = 5;
48314 } else {
48315 /* Otherwise devices can be toggled via software */
48316 - max8660_dcdc_ops.enable = max8660_dcdc_enable;
48317 - max8660_dcdc_ops.disable = max8660_dcdc_disable;
48318 + pax_open_kernel();
48319 + *(void **)&max8660_dcdc_ops.enable = max8660_dcdc_enable;
48320 + *(void **)&max8660_dcdc_ops.disable = max8660_dcdc_disable;
48321 + pax_close_kernel();
48322 }
48323
48324 /*
48325 diff --git a/drivers/regulator/max8973-regulator.c b/drivers/regulator/max8973-regulator.c
48326 index dbedf17..18ff6b7 100644
48327 --- a/drivers/regulator/max8973-regulator.c
48328 +++ b/drivers/regulator/max8973-regulator.c
48329 @@ -403,9 +403,11 @@ static int max8973_probe(struct i2c_client *client,
48330 if (!pdata || !pdata->enable_ext_control) {
48331 max->desc.enable_reg = MAX8973_VOUT;
48332 max->desc.enable_mask = MAX8973_VOUT_ENABLE;
48333 - max->ops.enable = regulator_enable_regmap;
48334 - max->ops.disable = regulator_disable_regmap;
48335 - max->ops.is_enabled = regulator_is_enabled_regmap;
48336 + pax_open_kernel();
48337 + *(void **)&max->ops.enable = regulator_enable_regmap;
48338 + *(void **)&max->ops.disable = regulator_disable_regmap;
48339 + *(void **)&max->ops.is_enabled = regulator_is_enabled_regmap;
48340 + pax_close_kernel();
48341 }
48342
48343 if (pdata) {
48344 diff --git a/drivers/regulator/mc13892-regulator.c b/drivers/regulator/mc13892-regulator.c
48345 index f374fa5..26f0683 100644
48346 --- a/drivers/regulator/mc13892-regulator.c
48347 +++ b/drivers/regulator/mc13892-regulator.c
48348 @@ -582,10 +582,12 @@ static int mc13892_regulator_probe(struct platform_device *pdev)
48349 }
48350 mc13xxx_unlock(mc13892);
48351
48352 - mc13892_regulators[MC13892_VCAM].desc.ops->set_mode
48353 + pax_open_kernel();
48354 + *(void **)&mc13892_regulators[MC13892_VCAM].desc.ops->set_mode
48355 = mc13892_vcam_set_mode;
48356 - mc13892_regulators[MC13892_VCAM].desc.ops->get_mode
48357 + *(void **)&mc13892_regulators[MC13892_VCAM].desc.ops->get_mode
48358 = mc13892_vcam_get_mode;
48359 + pax_close_kernel();
48360
48361 mc13xxx_data = mc13xxx_parse_regulators_dt(pdev, mc13892_regulators,
48362 ARRAY_SIZE(mc13892_regulators));
48363 diff --git a/drivers/rtc/rtc-cmos.c b/drivers/rtc/rtc-cmos.c
48364 index 0963c93..ea29cce 100644
48365 --- a/drivers/rtc/rtc-cmos.c
48366 +++ b/drivers/rtc/rtc-cmos.c
48367 @@ -777,7 +777,9 @@ cmos_do_probe(struct device *dev, struct resource *ports, int rtc_irq)
48368 hpet_rtc_timer_init();
48369
48370 /* export at least the first block of NVRAM */
48371 - nvram.size = address_space - NVRAM_OFFSET;
48372 + pax_open_kernel();
48373 + *(size_t *)&nvram.size = address_space - NVRAM_OFFSET;
48374 + pax_close_kernel();
48375 retval = sysfs_create_bin_file(&dev->kobj, &nvram);
48376 if (retval < 0) {
48377 dev_dbg(dev, "can't create nvram file? %d\n", retval);
48378 diff --git a/drivers/rtc/rtc-dev.c b/drivers/rtc/rtc-dev.c
48379 index d049393..bb20be0 100644
48380 --- a/drivers/rtc/rtc-dev.c
48381 +++ b/drivers/rtc/rtc-dev.c
48382 @@ -16,6 +16,7 @@
48383 #include <linux/module.h>
48384 #include <linux/rtc.h>
48385 #include <linux/sched.h>
48386 +#include <linux/grsecurity.h>
48387 #include "rtc-core.h"
48388
48389 static dev_t rtc_devt;
48390 @@ -347,6 +348,8 @@ static long rtc_dev_ioctl(struct file *file,
48391 if (copy_from_user(&tm, uarg, sizeof(tm)))
48392 return -EFAULT;
48393
48394 + gr_log_timechange();
48395 +
48396 return rtc_set_time(rtc, &tm);
48397
48398 case RTC_PIE_ON:
48399 diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c
48400 index f03d5ba..8325bf6 100644
48401 --- a/drivers/rtc/rtc-ds1307.c
48402 +++ b/drivers/rtc/rtc-ds1307.c
48403 @@ -107,7 +107,7 @@ struct ds1307 {
48404 u8 offset; /* register's offset */
48405 u8 regs[11];
48406 u16 nvram_offset;
48407 - struct bin_attribute *nvram;
48408 + bin_attribute_no_const *nvram;
48409 enum ds_type type;
48410 unsigned long flags;
48411 #define HAS_NVRAM 0 /* bit 0 == sysfs file active */
48412 diff --git a/drivers/rtc/rtc-m48t59.c b/drivers/rtc/rtc-m48t59.c
48413 index 11880c1..b823aa4 100644
48414 --- a/drivers/rtc/rtc-m48t59.c
48415 +++ b/drivers/rtc/rtc-m48t59.c
48416 @@ -483,7 +483,9 @@ static int m48t59_rtc_probe(struct platform_device *pdev)
48417 if (IS_ERR(m48t59->rtc))
48418 return PTR_ERR(m48t59->rtc);
48419
48420 - m48t59_nvram_attr.size = pdata->offset;
48421 + pax_open_kernel();
48422 + *(size_t *)&m48t59_nvram_attr.size = pdata->offset;
48423 + pax_close_kernel();
48424
48425 ret = sysfs_create_bin_file(&pdev->dev.kobj, &m48t59_nvram_attr);
48426 if (ret)
48427 diff --git a/drivers/scsi/aic7xxx/aic79xx_pci.c b/drivers/scsi/aic7xxx/aic79xx_pci.c
48428 index 14b5f8d..cc9bd26 100644
48429 --- a/drivers/scsi/aic7xxx/aic79xx_pci.c
48430 +++ b/drivers/scsi/aic7xxx/aic79xx_pci.c
48431 @@ -827,7 +827,7 @@ ahd_pci_intr(struct ahd_softc *ahd)
48432 for (bit = 0; bit < 8; bit++) {
48433
48434 if ((pci_status[i] & (0x1 << bit)) != 0) {
48435 - static const char *s;
48436 + const char *s;
48437
48438 s = pci_status_strings[bit];
48439 if (i == 7/*TARG*/ && bit == 3)
48440 @@ -887,23 +887,15 @@ ahd_pci_split_intr(struct ahd_softc *ahd, u_int intstat)
48441
48442 for (bit = 0; bit < 8; bit++) {
48443
48444 - if ((split_status[i] & (0x1 << bit)) != 0) {
48445 - static const char *s;
48446 -
48447 - s = split_status_strings[bit];
48448 - printk(s, ahd_name(ahd),
48449 + if ((split_status[i] & (0x1 << bit)) != 0)
48450 + printk(split_status_strings[bit], ahd_name(ahd),
48451 split_status_source[i]);
48452 - }
48453
48454 if (i > 1)
48455 continue;
48456
48457 - if ((sg_split_status[i] & (0x1 << bit)) != 0) {
48458 - static const char *s;
48459 -
48460 - s = split_status_strings[bit];
48461 - printk(s, ahd_name(ahd), "SG");
48462 - }
48463 + if ((sg_split_status[i] & (0x1 << bit)) != 0)
48464 + printk(split_status_strings[bit], ahd_name(ahd), "SG");
48465 }
48466 }
48467 /*
48468 diff --git a/drivers/scsi/bfa/bfa_fcpim.h b/drivers/scsi/bfa/bfa_fcpim.h
48469 index e693af6..2e525b6 100644
48470 --- a/drivers/scsi/bfa/bfa_fcpim.h
48471 +++ b/drivers/scsi/bfa/bfa_fcpim.h
48472 @@ -36,7 +36,7 @@ struct bfa_iotag_s {
48473
48474 struct bfa_itn_s {
48475 bfa_isr_func_t isr;
48476 -};
48477 +} __no_const;
48478
48479 void bfa_itn_create(struct bfa_s *bfa, struct bfa_rport_s *rport,
48480 void (*isr)(struct bfa_s *bfa, struct bfi_msg_s *m));
48481 diff --git a/drivers/scsi/bfa/bfa_fcs.c b/drivers/scsi/bfa/bfa_fcs.c
48482 index a3ab5cc..8143622 100644
48483 --- a/drivers/scsi/bfa/bfa_fcs.c
48484 +++ b/drivers/scsi/bfa/bfa_fcs.c
48485 @@ -38,10 +38,21 @@ struct bfa_fcs_mod_s {
48486 #define BFA_FCS_MODULE(_mod) { _mod ## _modinit, _mod ## _modexit }
48487
48488 static struct bfa_fcs_mod_s fcs_modules[] = {
48489 - { bfa_fcs_port_attach, NULL, NULL },
48490 - { bfa_fcs_uf_attach, NULL, NULL },
48491 - { bfa_fcs_fabric_attach, bfa_fcs_fabric_modinit,
48492 - bfa_fcs_fabric_modexit },
48493 + {
48494 + .attach = bfa_fcs_port_attach,
48495 + .modinit = NULL,
48496 + .modexit = NULL
48497 + },
48498 + {
48499 + .attach = bfa_fcs_uf_attach,
48500 + .modinit = NULL,
48501 + .modexit = NULL
48502 + },
48503 + {
48504 + .attach = bfa_fcs_fabric_attach,
48505 + .modinit = bfa_fcs_fabric_modinit,
48506 + .modexit = bfa_fcs_fabric_modexit
48507 + },
48508 };
48509
48510 /*
48511 diff --git a/drivers/scsi/bfa/bfa_fcs_lport.c b/drivers/scsi/bfa/bfa_fcs_lport.c
48512 index ff75ef8..2dfe00a 100644
48513 --- a/drivers/scsi/bfa/bfa_fcs_lport.c
48514 +++ b/drivers/scsi/bfa/bfa_fcs_lport.c
48515 @@ -89,15 +89,26 @@ static struct {
48516 void (*offline) (struct bfa_fcs_lport_s *port);
48517 } __port_action[] = {
48518 {
48519 - bfa_fcs_lport_unknown_init, bfa_fcs_lport_unknown_online,
48520 - bfa_fcs_lport_unknown_offline}, {
48521 - bfa_fcs_lport_fab_init, bfa_fcs_lport_fab_online,
48522 - bfa_fcs_lport_fab_offline}, {
48523 - bfa_fcs_lport_n2n_init, bfa_fcs_lport_n2n_online,
48524 - bfa_fcs_lport_n2n_offline}, {
48525 - bfa_fcs_lport_loop_init, bfa_fcs_lport_loop_online,
48526 - bfa_fcs_lport_loop_offline},
48527 - };
48528 + .init = bfa_fcs_lport_unknown_init,
48529 + .online = bfa_fcs_lport_unknown_online,
48530 + .offline = bfa_fcs_lport_unknown_offline
48531 + },
48532 + {
48533 + .init = bfa_fcs_lport_fab_init,
48534 + .online = bfa_fcs_lport_fab_online,
48535 + .offline = bfa_fcs_lport_fab_offline
48536 + },
48537 + {
48538 + .init = bfa_fcs_lport_n2n_init,
48539 + .online = bfa_fcs_lport_n2n_online,
48540 + .offline = bfa_fcs_lport_n2n_offline
48541 + },
48542 + {
48543 + .init = bfa_fcs_lport_loop_init,
48544 + .online = bfa_fcs_lport_loop_online,
48545 + .offline = bfa_fcs_lport_loop_offline
48546 + },
48547 +};
48548
48549 /*
48550 * fcs_port_sm FCS logical port state machine
48551 diff --git a/drivers/scsi/bfa/bfa_ioc.h b/drivers/scsi/bfa/bfa_ioc.h
48552 index 2e28392..9d865b6 100644
48553 --- a/drivers/scsi/bfa/bfa_ioc.h
48554 +++ b/drivers/scsi/bfa/bfa_ioc.h
48555 @@ -258,7 +258,7 @@ struct bfa_ioc_cbfn_s {
48556 bfa_ioc_disable_cbfn_t disable_cbfn;
48557 bfa_ioc_hbfail_cbfn_t hbfail_cbfn;
48558 bfa_ioc_reset_cbfn_t reset_cbfn;
48559 -};
48560 +} __no_const;
48561
48562 /*
48563 * IOC event notification mechanism.
48564 @@ -352,7 +352,7 @@ struct bfa_ioc_hwif_s {
48565 void (*ioc_set_alt_fwstate) (struct bfa_ioc_s *ioc,
48566 enum bfi_ioc_state fwstate);
48567 enum bfi_ioc_state (*ioc_get_alt_fwstate) (struct bfa_ioc_s *ioc);
48568 -};
48569 +} __no_const;
48570
48571 /*
48572 * Queue element to wait for room in request queue. FIFO order is
48573 diff --git a/drivers/scsi/bfa/bfa_modules.h b/drivers/scsi/bfa/bfa_modules.h
48574 index a14c784..6de6790 100644
48575 --- a/drivers/scsi/bfa/bfa_modules.h
48576 +++ b/drivers/scsi/bfa/bfa_modules.h
48577 @@ -78,12 +78,12 @@ enum {
48578 \
48579 extern struct bfa_module_s hal_mod_ ## __mod; \
48580 struct bfa_module_s hal_mod_ ## __mod = { \
48581 - bfa_ ## __mod ## _meminfo, \
48582 - bfa_ ## __mod ## _attach, \
48583 - bfa_ ## __mod ## _detach, \
48584 - bfa_ ## __mod ## _start, \
48585 - bfa_ ## __mod ## _stop, \
48586 - bfa_ ## __mod ## _iocdisable, \
48587 + .meminfo = bfa_ ## __mod ## _meminfo, \
48588 + .attach = bfa_ ## __mod ## _attach, \
48589 + .detach = bfa_ ## __mod ## _detach, \
48590 + .start = bfa_ ## __mod ## _start, \
48591 + .stop = bfa_ ## __mod ## _stop, \
48592 + .iocdisable = bfa_ ## __mod ## _iocdisable, \
48593 }
48594
48595 #define BFA_CACHELINE_SZ (256)
48596 diff --git a/drivers/scsi/fcoe/fcoe_sysfs.c b/drivers/scsi/fcoe/fcoe_sysfs.c
48597 index 045c4e1..13de803 100644
48598 --- a/drivers/scsi/fcoe/fcoe_sysfs.c
48599 +++ b/drivers/scsi/fcoe/fcoe_sysfs.c
48600 @@ -33,8 +33,8 @@
48601 */
48602 #include "libfcoe.h"
48603
48604 -static atomic_t ctlr_num;
48605 -static atomic_t fcf_num;
48606 +static atomic_unchecked_t ctlr_num;
48607 +static atomic_unchecked_t fcf_num;
48608
48609 /*
48610 * fcoe_fcf_dev_loss_tmo: the default number of seconds that fcoe sysfs
48611 @@ -685,7 +685,7 @@ struct fcoe_ctlr_device *fcoe_ctlr_device_add(struct device *parent,
48612 if (!ctlr)
48613 goto out;
48614
48615 - ctlr->id = atomic_inc_return(&ctlr_num) - 1;
48616 + ctlr->id = atomic_inc_return_unchecked(&ctlr_num) - 1;
48617 ctlr->f = f;
48618 ctlr->mode = FIP_CONN_TYPE_FABRIC;
48619 INIT_LIST_HEAD(&ctlr->fcfs);
48620 @@ -902,7 +902,7 @@ struct fcoe_fcf_device *fcoe_fcf_device_add(struct fcoe_ctlr_device *ctlr,
48621 fcf->dev.parent = &ctlr->dev;
48622 fcf->dev.bus = &fcoe_bus_type;
48623 fcf->dev.type = &fcoe_fcf_device_type;
48624 - fcf->id = atomic_inc_return(&fcf_num) - 1;
48625 + fcf->id = atomic_inc_return_unchecked(&fcf_num) - 1;
48626 fcf->state = FCOE_FCF_STATE_UNKNOWN;
48627
48628 fcf->dev_loss_tmo = ctlr->fcf_dev_loss_tmo;
48629 @@ -938,8 +938,8 @@ int __init fcoe_sysfs_setup(void)
48630 {
48631 int error;
48632
48633 - atomic_set(&ctlr_num, 0);
48634 - atomic_set(&fcf_num, 0);
48635 + atomic_set_unchecked(&ctlr_num, 0);
48636 + atomic_set_unchecked(&fcf_num, 0);
48637
48638 error = bus_register(&fcoe_bus_type);
48639 if (error)
48640 diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c
48641 index 3cbb57a..95e47a3 100644
48642 --- a/drivers/scsi/hosts.c
48643 +++ b/drivers/scsi/hosts.c
48644 @@ -42,7 +42,7 @@
48645 #include "scsi_logging.h"
48646
48647
48648 -static atomic_t scsi_host_next_hn = ATOMIC_INIT(0); /* host_no for next new host */
48649 +static atomic_unchecked_t scsi_host_next_hn = ATOMIC_INIT(0); /* host_no for next new host */
48650
48651
48652 static void scsi_host_cls_release(struct device *dev)
48653 @@ -369,7 +369,7 @@ struct Scsi_Host *scsi_host_alloc(struct scsi_host_template *sht, int privsize)
48654 * subtract one because we increment first then return, but we need to
48655 * know what the next host number was before increment
48656 */
48657 - shost->host_no = atomic_inc_return(&scsi_host_next_hn) - 1;
48658 + shost->host_no = atomic_inc_return_unchecked(&scsi_host_next_hn) - 1;
48659 shost->dma_channel = 0xff;
48660
48661 /* These three are default values which can be overridden */
48662 diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
48663 index 9a6e4a2..27843b6 100644
48664 --- a/drivers/scsi/hpsa.c
48665 +++ b/drivers/scsi/hpsa.c
48666 @@ -687,10 +687,10 @@ static inline u32 next_command(struct ctlr_info *h, u8 q)
48667 unsigned long flags;
48668
48669 if (h->transMethod & CFGTBL_Trans_io_accel1)
48670 - return h->access.command_completed(h, q);
48671 + return h->access->command_completed(h, q);
48672
48673 if (unlikely(!(h->transMethod & CFGTBL_Trans_Performant)))
48674 - return h->access.command_completed(h, q);
48675 + return h->access->command_completed(h, q);
48676
48677 if ((rq->head[rq->current_entry] & 1) == rq->wraparound) {
48678 a = rq->head[rq->current_entry];
48679 @@ -5448,7 +5448,7 @@ static void start_io(struct ctlr_info *h)
48680 while (!list_empty(&h->reqQ)) {
48681 c = list_entry(h->reqQ.next, struct CommandList, list);
48682 /* can't do anything if fifo is full */
48683 - if ((h->access.fifo_full(h))) {
48684 + if ((h->access->fifo_full(h))) {
48685 h->fifo_recently_full = 1;
48686 dev_warn(&h->pdev->dev, "fifo full\n");
48687 break;
48688 @@ -5472,7 +5472,7 @@ static void start_io(struct ctlr_info *h)
48689
48690 /* Tell the controller execute command */
48691 spin_unlock_irqrestore(&h->lock, flags);
48692 - h->access.submit_command(h, c);
48693 + h->access->submit_command(h, c);
48694 spin_lock_irqsave(&h->lock, flags);
48695 }
48696 spin_unlock_irqrestore(&h->lock, flags);
48697 @@ -5480,17 +5480,17 @@ static void start_io(struct ctlr_info *h)
48698
48699 static inline unsigned long get_next_completion(struct ctlr_info *h, u8 q)
48700 {
48701 - return h->access.command_completed(h, q);
48702 + return h->access->command_completed(h, q);
48703 }
48704
48705 static inline bool interrupt_pending(struct ctlr_info *h)
48706 {
48707 - return h->access.intr_pending(h);
48708 + return h->access->intr_pending(h);
48709 }
48710
48711 static inline long interrupt_not_for_us(struct ctlr_info *h)
48712 {
48713 - return (h->access.intr_pending(h) == 0) ||
48714 + return (h->access->intr_pending(h) == 0) ||
48715 (h->interrupts_enabled == 0);
48716 }
48717
48718 @@ -6444,7 +6444,7 @@ static int hpsa_pci_init(struct ctlr_info *h)
48719 if (prod_index < 0)
48720 return -ENODEV;
48721 h->product_name = products[prod_index].product_name;
48722 - h->access = *(products[prod_index].access);
48723 + h->access = products[prod_index].access;
48724
48725 pci_disable_link_state(h->pdev, PCIE_LINK_STATE_L0S |
48726 PCIE_LINK_STATE_L1 | PCIE_LINK_STATE_CLKPM);
48727 @@ -6723,7 +6723,7 @@ static void controller_lockup_detected(struct ctlr_info *h)
48728 {
48729 unsigned long flags;
48730
48731 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
48732 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
48733 spin_lock_irqsave(&h->lock, flags);
48734 h->lockup_detected = readl(h->vaddr + SA5_SCRATCHPAD_OFFSET);
48735 spin_unlock_irqrestore(&h->lock, flags);
48736 @@ -6951,7 +6951,7 @@ reinit_after_soft_reset:
48737 }
48738
48739 /* make sure the board interrupts are off */
48740 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
48741 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
48742
48743 if (hpsa_request_irq(h, do_hpsa_intr_msi, do_hpsa_intr_intx))
48744 goto clean2;
48745 @@ -6986,7 +6986,7 @@ reinit_after_soft_reset:
48746 * fake ones to scoop up any residual completions.
48747 */
48748 spin_lock_irqsave(&h->lock, flags);
48749 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
48750 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
48751 spin_unlock_irqrestore(&h->lock, flags);
48752 free_irqs(h);
48753 rc = hpsa_request_irq(h, hpsa_msix_discard_completions,
48754 @@ -7005,9 +7005,9 @@ reinit_after_soft_reset:
48755 dev_info(&h->pdev->dev, "Board READY.\n");
48756 dev_info(&h->pdev->dev,
48757 "Waiting for stale completions to drain.\n");
48758 - h->access.set_intr_mask(h, HPSA_INTR_ON);
48759 + h->access->set_intr_mask(h, HPSA_INTR_ON);
48760 msleep(10000);
48761 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
48762 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
48763
48764 rc = controller_reset_failed(h->cfgtable);
48765 if (rc)
48766 @@ -7033,7 +7033,7 @@ reinit_after_soft_reset:
48767 h->drv_req_rescan = 0;
48768
48769 /* Turn the interrupts on so we can service requests */
48770 - h->access.set_intr_mask(h, HPSA_INTR_ON);
48771 + h->access->set_intr_mask(h, HPSA_INTR_ON);
48772
48773 hpsa_hba_inquiry(h);
48774 hpsa_register_scsi(h); /* hook ourselves into SCSI subsystem */
48775 @@ -7102,7 +7102,7 @@ static void hpsa_shutdown(struct pci_dev *pdev)
48776 * To write all data in the battery backed cache to disks
48777 */
48778 hpsa_flush_cache(h);
48779 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
48780 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
48781 hpsa_free_irqs_and_disable_msix(h);
48782 }
48783
48784 @@ -7220,7 +7220,7 @@ static void hpsa_enter_performant_mode(struct ctlr_info *h, u32 trans_support)
48785 CFGTBL_Trans_enable_directed_msix |
48786 (trans_support & (CFGTBL_Trans_io_accel1 |
48787 CFGTBL_Trans_io_accel2));
48788 - struct access_method access = SA5_performant_access;
48789 + struct access_method *access = &SA5_performant_access;
48790
48791 /* This is a bit complicated. There are 8 registers on
48792 * the controller which we write to to tell it 8 different
48793 @@ -7285,12 +7285,12 @@ static void hpsa_enter_performant_mode(struct ctlr_info *h, u32 trans_support)
48794 * enable outbound interrupt coalescing in accelerator mode;
48795 */
48796 if (trans_support & CFGTBL_Trans_io_accel1) {
48797 - access = SA5_ioaccel_mode1_access;
48798 + access = &SA5_ioaccel_mode1_access;
48799 writel(10, &h->cfgtable->HostWrite.CoalIntDelay);
48800 writel(4, &h->cfgtable->HostWrite.CoalIntCount);
48801 } else {
48802 if (trans_support & CFGTBL_Trans_io_accel2) {
48803 - access = SA5_ioaccel_mode2_access;
48804 + access = &SA5_ioaccel_mode2_access;
48805 writel(10, &h->cfgtable->HostWrite.CoalIntDelay);
48806 writel(4, &h->cfgtable->HostWrite.CoalIntCount);
48807 }
48808 diff --git a/drivers/scsi/hpsa.h b/drivers/scsi/hpsa.h
48809 index 44235a2..962e91b 100644
48810 --- a/drivers/scsi/hpsa.h
48811 +++ b/drivers/scsi/hpsa.h
48812 @@ -128,7 +128,7 @@ struct ctlr_info {
48813 unsigned int msix_vector;
48814 unsigned int msi_vector;
48815 int intr_mode; /* either PERF_MODE_INT or SIMPLE_MODE_INT */
48816 - struct access_method access;
48817 + struct access_method *access;
48818 char hba_mode_enabled;
48819
48820 /* queue and queue Info */
48821 @@ -541,35 +541,35 @@ static unsigned long SA5_ioaccel_mode1_completed(struct ctlr_info *h, u8 q)
48822 }
48823
48824 static struct access_method SA5_access = {
48825 - SA5_submit_command,
48826 - SA5_intr_mask,
48827 - SA5_fifo_full,
48828 - SA5_intr_pending,
48829 - SA5_completed,
48830 + .submit_command = SA5_submit_command,
48831 + .set_intr_mask = SA5_intr_mask,
48832 + .fifo_full = SA5_fifo_full,
48833 + .intr_pending = SA5_intr_pending,
48834 + .command_completed = SA5_completed,
48835 };
48836
48837 static struct access_method SA5_ioaccel_mode1_access = {
48838 - SA5_submit_command,
48839 - SA5_performant_intr_mask,
48840 - SA5_fifo_full,
48841 - SA5_ioaccel_mode1_intr_pending,
48842 - SA5_ioaccel_mode1_completed,
48843 + .submit_command = SA5_submit_command,
48844 + .set_intr_mask = SA5_performant_intr_mask,
48845 + .fifo_full = SA5_fifo_full,
48846 + .intr_pending = SA5_ioaccel_mode1_intr_pending,
48847 + .command_completed = SA5_ioaccel_mode1_completed,
48848 };
48849
48850 static struct access_method SA5_ioaccel_mode2_access = {
48851 - SA5_submit_command_ioaccel2,
48852 - SA5_performant_intr_mask,
48853 - SA5_fifo_full,
48854 - SA5_performant_intr_pending,
48855 - SA5_performant_completed,
48856 + .submit_command = SA5_submit_command_ioaccel2,
48857 + .set_intr_mask = SA5_performant_intr_mask,
48858 + .fifo_full = SA5_fifo_full,
48859 + .intr_pending = SA5_performant_intr_pending,
48860 + .command_completed = SA5_performant_completed,
48861 };
48862
48863 static struct access_method SA5_performant_access = {
48864 - SA5_submit_command,
48865 - SA5_performant_intr_mask,
48866 - SA5_fifo_full,
48867 - SA5_performant_intr_pending,
48868 - SA5_performant_completed,
48869 + .submit_command = SA5_submit_command,
48870 + .set_intr_mask = SA5_performant_intr_mask,
48871 + .fifo_full = SA5_fifo_full,
48872 + .intr_pending = SA5_performant_intr_pending,
48873 + .command_completed = SA5_performant_completed,
48874 };
48875
48876 struct board_type {
48877 diff --git a/drivers/scsi/libfc/fc_exch.c b/drivers/scsi/libfc/fc_exch.c
48878 index 1b3a094..068e683 100644
48879 --- a/drivers/scsi/libfc/fc_exch.c
48880 +++ b/drivers/scsi/libfc/fc_exch.c
48881 @@ -101,12 +101,12 @@ struct fc_exch_mgr {
48882 u16 pool_max_index;
48883
48884 struct {
48885 - atomic_t no_free_exch;
48886 - atomic_t no_free_exch_xid;
48887 - atomic_t xid_not_found;
48888 - atomic_t xid_busy;
48889 - atomic_t seq_not_found;
48890 - atomic_t non_bls_resp;
48891 + atomic_unchecked_t no_free_exch;
48892 + atomic_unchecked_t no_free_exch_xid;
48893 + atomic_unchecked_t xid_not_found;
48894 + atomic_unchecked_t xid_busy;
48895 + atomic_unchecked_t seq_not_found;
48896 + atomic_unchecked_t non_bls_resp;
48897 } stats;
48898 };
48899
48900 @@ -811,7 +811,7 @@ static struct fc_exch *fc_exch_em_alloc(struct fc_lport *lport,
48901 /* allocate memory for exchange */
48902 ep = mempool_alloc(mp->ep_pool, GFP_ATOMIC);
48903 if (!ep) {
48904 - atomic_inc(&mp->stats.no_free_exch);
48905 + atomic_inc_unchecked(&mp->stats.no_free_exch);
48906 goto out;
48907 }
48908 memset(ep, 0, sizeof(*ep));
48909 @@ -874,7 +874,7 @@ out:
48910 return ep;
48911 err:
48912 spin_unlock_bh(&pool->lock);
48913 - atomic_inc(&mp->stats.no_free_exch_xid);
48914 + atomic_inc_unchecked(&mp->stats.no_free_exch_xid);
48915 mempool_free(ep, mp->ep_pool);
48916 return NULL;
48917 }
48918 @@ -1023,7 +1023,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
48919 xid = ntohs(fh->fh_ox_id); /* we originated exch */
48920 ep = fc_exch_find(mp, xid);
48921 if (!ep) {
48922 - atomic_inc(&mp->stats.xid_not_found);
48923 + atomic_inc_unchecked(&mp->stats.xid_not_found);
48924 reject = FC_RJT_OX_ID;
48925 goto out;
48926 }
48927 @@ -1053,7 +1053,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
48928 ep = fc_exch_find(mp, xid);
48929 if ((f_ctl & FC_FC_FIRST_SEQ) && fc_sof_is_init(fr_sof(fp))) {
48930 if (ep) {
48931 - atomic_inc(&mp->stats.xid_busy);
48932 + atomic_inc_unchecked(&mp->stats.xid_busy);
48933 reject = FC_RJT_RX_ID;
48934 goto rel;
48935 }
48936 @@ -1064,7 +1064,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
48937 }
48938 xid = ep->xid; /* get our XID */
48939 } else if (!ep) {
48940 - atomic_inc(&mp->stats.xid_not_found);
48941 + atomic_inc_unchecked(&mp->stats.xid_not_found);
48942 reject = FC_RJT_RX_ID; /* XID not found */
48943 goto out;
48944 }
48945 @@ -1082,7 +1082,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
48946 } else {
48947 sp = &ep->seq;
48948 if (sp->id != fh->fh_seq_id) {
48949 - atomic_inc(&mp->stats.seq_not_found);
48950 + atomic_inc_unchecked(&mp->stats.seq_not_found);
48951 if (f_ctl & FC_FC_END_SEQ) {
48952 /*
48953 * Update sequence_id based on incoming last
48954 @@ -1533,22 +1533,22 @@ static void fc_exch_recv_seq_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
48955
48956 ep = fc_exch_find(mp, ntohs(fh->fh_ox_id));
48957 if (!ep) {
48958 - atomic_inc(&mp->stats.xid_not_found);
48959 + atomic_inc_unchecked(&mp->stats.xid_not_found);
48960 goto out;
48961 }
48962 if (ep->esb_stat & ESB_ST_COMPLETE) {
48963 - atomic_inc(&mp->stats.xid_not_found);
48964 + atomic_inc_unchecked(&mp->stats.xid_not_found);
48965 goto rel;
48966 }
48967 if (ep->rxid == FC_XID_UNKNOWN)
48968 ep->rxid = ntohs(fh->fh_rx_id);
48969 if (ep->sid != 0 && ep->sid != ntoh24(fh->fh_d_id)) {
48970 - atomic_inc(&mp->stats.xid_not_found);
48971 + atomic_inc_unchecked(&mp->stats.xid_not_found);
48972 goto rel;
48973 }
48974 if (ep->did != ntoh24(fh->fh_s_id) &&
48975 ep->did != FC_FID_FLOGI) {
48976 - atomic_inc(&mp->stats.xid_not_found);
48977 + atomic_inc_unchecked(&mp->stats.xid_not_found);
48978 goto rel;
48979 }
48980 sof = fr_sof(fp);
48981 @@ -1557,7 +1557,7 @@ static void fc_exch_recv_seq_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
48982 sp->ssb_stat |= SSB_ST_RESP;
48983 sp->id = fh->fh_seq_id;
48984 } else if (sp->id != fh->fh_seq_id) {
48985 - atomic_inc(&mp->stats.seq_not_found);
48986 + atomic_inc_unchecked(&mp->stats.seq_not_found);
48987 goto rel;
48988 }
48989
48990 @@ -1619,9 +1619,9 @@ static void fc_exch_recv_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
48991 sp = fc_seq_lookup_orig(mp, fp); /* doesn't hold sequence */
48992
48993 if (!sp)
48994 - atomic_inc(&mp->stats.xid_not_found);
48995 + atomic_inc_unchecked(&mp->stats.xid_not_found);
48996 else
48997 - atomic_inc(&mp->stats.non_bls_resp);
48998 + atomic_inc_unchecked(&mp->stats.non_bls_resp);
48999
49000 fc_frame_free(fp);
49001 }
49002 @@ -2261,13 +2261,13 @@ void fc_exch_update_stats(struct fc_lport *lport)
49003
49004 list_for_each_entry(ema, &lport->ema_list, ema_list) {
49005 mp = ema->mp;
49006 - st->fc_no_free_exch += atomic_read(&mp->stats.no_free_exch);
49007 + st->fc_no_free_exch += atomic_read_unchecked(&mp->stats.no_free_exch);
49008 st->fc_no_free_exch_xid +=
49009 - atomic_read(&mp->stats.no_free_exch_xid);
49010 - st->fc_xid_not_found += atomic_read(&mp->stats.xid_not_found);
49011 - st->fc_xid_busy += atomic_read(&mp->stats.xid_busy);
49012 - st->fc_seq_not_found += atomic_read(&mp->stats.seq_not_found);
49013 - st->fc_non_bls_resp += atomic_read(&mp->stats.non_bls_resp);
49014 + atomic_read_unchecked(&mp->stats.no_free_exch_xid);
49015 + st->fc_xid_not_found += atomic_read_unchecked(&mp->stats.xid_not_found);
49016 + st->fc_xid_busy += atomic_read_unchecked(&mp->stats.xid_busy);
49017 + st->fc_seq_not_found += atomic_read_unchecked(&mp->stats.seq_not_found);
49018 + st->fc_non_bls_resp += atomic_read_unchecked(&mp->stats.non_bls_resp);
49019 }
49020 }
49021 EXPORT_SYMBOL(fc_exch_update_stats);
49022 diff --git a/drivers/scsi/libsas/sas_ata.c b/drivers/scsi/libsas/sas_ata.c
49023 index 766098a..1c6c971 100644
49024 --- a/drivers/scsi/libsas/sas_ata.c
49025 +++ b/drivers/scsi/libsas/sas_ata.c
49026 @@ -554,7 +554,7 @@ static struct ata_port_operations sas_sata_ops = {
49027 .postreset = ata_std_postreset,
49028 .error_handler = ata_std_error_handler,
49029 .post_internal_cmd = sas_ata_post_internal,
49030 - .qc_defer = ata_std_qc_defer,
49031 + .qc_defer = ata_std_qc_defer,
49032 .qc_prep = ata_noop_qc_prep,
49033 .qc_issue = sas_ata_qc_issue,
49034 .qc_fill_rtf = sas_ata_qc_fill_rtf,
49035 diff --git a/drivers/scsi/lpfc/lpfc.h b/drivers/scsi/lpfc/lpfc.h
49036 index 94a3caf..a118dec 100644
49037 --- a/drivers/scsi/lpfc/lpfc.h
49038 +++ b/drivers/scsi/lpfc/lpfc.h
49039 @@ -430,7 +430,7 @@ struct lpfc_vport {
49040 struct dentry *debug_nodelist;
49041 struct dentry *vport_debugfs_root;
49042 struct lpfc_debugfs_trc *disc_trc;
49043 - atomic_t disc_trc_cnt;
49044 + atomic_unchecked_t disc_trc_cnt;
49045 #endif
49046 uint8_t stat_data_enabled;
49047 uint8_t stat_data_blocked;
49048 @@ -879,8 +879,8 @@ struct lpfc_hba {
49049 struct timer_list fabric_block_timer;
49050 unsigned long bit_flags;
49051 #define FABRIC_COMANDS_BLOCKED 0
49052 - atomic_t num_rsrc_err;
49053 - atomic_t num_cmd_success;
49054 + atomic_unchecked_t num_rsrc_err;
49055 + atomic_unchecked_t num_cmd_success;
49056 unsigned long last_rsrc_error_time;
49057 unsigned long last_ramp_down_time;
49058 #ifdef CONFIG_SCSI_LPFC_DEBUG_FS
49059 @@ -915,7 +915,7 @@ struct lpfc_hba {
49060
49061 struct dentry *debug_slow_ring_trc;
49062 struct lpfc_debugfs_trc *slow_ring_trc;
49063 - atomic_t slow_ring_trc_cnt;
49064 + atomic_unchecked_t slow_ring_trc_cnt;
49065 /* iDiag debugfs sub-directory */
49066 struct dentry *idiag_root;
49067 struct dentry *idiag_pci_cfg;
49068 diff --git a/drivers/scsi/lpfc/lpfc_debugfs.c b/drivers/scsi/lpfc/lpfc_debugfs.c
49069 index 828c08e..e3378e0 100644
49070 --- a/drivers/scsi/lpfc/lpfc_debugfs.c
49071 +++ b/drivers/scsi/lpfc/lpfc_debugfs.c
49072 @@ -106,7 +106,7 @@ MODULE_PARM_DESC(lpfc_debugfs_mask_disc_trc,
49073
49074 #include <linux/debugfs.h>
49075
49076 -static atomic_t lpfc_debugfs_seq_trc_cnt = ATOMIC_INIT(0);
49077 +static atomic_unchecked_t lpfc_debugfs_seq_trc_cnt = ATOMIC_INIT(0);
49078 static unsigned long lpfc_debugfs_start_time = 0L;
49079
49080 /* iDiag */
49081 @@ -147,7 +147,7 @@ lpfc_debugfs_disc_trc_data(struct lpfc_vport *vport, char *buf, int size)
49082 lpfc_debugfs_enable = 0;
49083
49084 len = 0;
49085 - index = (atomic_read(&vport->disc_trc_cnt) + 1) &
49086 + index = (atomic_read_unchecked(&vport->disc_trc_cnt) + 1) &
49087 (lpfc_debugfs_max_disc_trc - 1);
49088 for (i = index; i < lpfc_debugfs_max_disc_trc; i++) {
49089 dtp = vport->disc_trc + i;
49090 @@ -213,7 +213,7 @@ lpfc_debugfs_slow_ring_trc_data(struct lpfc_hba *phba, char *buf, int size)
49091 lpfc_debugfs_enable = 0;
49092
49093 len = 0;
49094 - index = (atomic_read(&phba->slow_ring_trc_cnt) + 1) &
49095 + index = (atomic_read_unchecked(&phba->slow_ring_trc_cnt) + 1) &
49096 (lpfc_debugfs_max_slow_ring_trc - 1);
49097 for (i = index; i < lpfc_debugfs_max_slow_ring_trc; i++) {
49098 dtp = phba->slow_ring_trc + i;
49099 @@ -646,14 +646,14 @@ lpfc_debugfs_disc_trc(struct lpfc_vport *vport, int mask, char *fmt,
49100 !vport || !vport->disc_trc)
49101 return;
49102
49103 - index = atomic_inc_return(&vport->disc_trc_cnt) &
49104 + index = atomic_inc_return_unchecked(&vport->disc_trc_cnt) &
49105 (lpfc_debugfs_max_disc_trc - 1);
49106 dtp = vport->disc_trc + index;
49107 dtp->fmt = fmt;
49108 dtp->data1 = data1;
49109 dtp->data2 = data2;
49110 dtp->data3 = data3;
49111 - dtp->seq_cnt = atomic_inc_return(&lpfc_debugfs_seq_trc_cnt);
49112 + dtp->seq_cnt = atomic_inc_return_unchecked(&lpfc_debugfs_seq_trc_cnt);
49113 dtp->jif = jiffies;
49114 #endif
49115 return;
49116 @@ -684,14 +684,14 @@ lpfc_debugfs_slow_ring_trc(struct lpfc_hba *phba, char *fmt,
49117 !phba || !phba->slow_ring_trc)
49118 return;
49119
49120 - index = atomic_inc_return(&phba->slow_ring_trc_cnt) &
49121 + index = atomic_inc_return_unchecked(&phba->slow_ring_trc_cnt) &
49122 (lpfc_debugfs_max_slow_ring_trc - 1);
49123 dtp = phba->slow_ring_trc + index;
49124 dtp->fmt = fmt;
49125 dtp->data1 = data1;
49126 dtp->data2 = data2;
49127 dtp->data3 = data3;
49128 - dtp->seq_cnt = atomic_inc_return(&lpfc_debugfs_seq_trc_cnt);
49129 + dtp->seq_cnt = atomic_inc_return_unchecked(&lpfc_debugfs_seq_trc_cnt);
49130 dtp->jif = jiffies;
49131 #endif
49132 return;
49133 @@ -4268,7 +4268,7 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
49134 "slow_ring buffer\n");
49135 goto debug_failed;
49136 }
49137 - atomic_set(&phba->slow_ring_trc_cnt, 0);
49138 + atomic_set_unchecked(&phba->slow_ring_trc_cnt, 0);
49139 memset(phba->slow_ring_trc, 0,
49140 (sizeof(struct lpfc_debugfs_trc) *
49141 lpfc_debugfs_max_slow_ring_trc));
49142 @@ -4314,7 +4314,7 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
49143 "buffer\n");
49144 goto debug_failed;
49145 }
49146 - atomic_set(&vport->disc_trc_cnt, 0);
49147 + atomic_set_unchecked(&vport->disc_trc_cnt, 0);
49148
49149 snprintf(name, sizeof(name), "discovery_trace");
49150 vport->debug_disc_trc =
49151 diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c
49152 index 635eeb3..038aef6 100644
49153 --- a/drivers/scsi/lpfc/lpfc_init.c
49154 +++ b/drivers/scsi/lpfc/lpfc_init.c
49155 @@ -11194,8 +11194,10 @@ lpfc_init(void)
49156 "misc_register returned with status %d", error);
49157
49158 if (lpfc_enable_npiv) {
49159 - lpfc_transport_functions.vport_create = lpfc_vport_create;
49160 - lpfc_transport_functions.vport_delete = lpfc_vport_delete;
49161 + pax_open_kernel();
49162 + *(void **)&lpfc_transport_functions.vport_create = lpfc_vport_create;
49163 + *(void **)&lpfc_transport_functions.vport_delete = lpfc_vport_delete;
49164 + pax_close_kernel();
49165 }
49166 lpfc_transport_template =
49167 fc_attach_transport(&lpfc_transport_functions);
49168 diff --git a/drivers/scsi/lpfc/lpfc_scsi.c b/drivers/scsi/lpfc/lpfc_scsi.c
49169 index 462453e..c0023a6 100644
49170 --- a/drivers/scsi/lpfc/lpfc_scsi.c
49171 +++ b/drivers/scsi/lpfc/lpfc_scsi.c
49172 @@ -382,7 +382,7 @@ lpfc_rampdown_queue_depth(struct lpfc_hba *phba)
49173 uint32_t evt_posted;
49174
49175 spin_lock_irqsave(&phba->hbalock, flags);
49176 - atomic_inc(&phba->num_rsrc_err);
49177 + atomic_inc_unchecked(&phba->num_rsrc_err);
49178 phba->last_rsrc_error_time = jiffies;
49179
49180 if ((phba->last_ramp_down_time + QUEUE_RAMP_DOWN_INTERVAL) > jiffies) {
49181 @@ -423,8 +423,8 @@ lpfc_ramp_down_queue_handler(struct lpfc_hba *phba)
49182 unsigned long num_rsrc_err, num_cmd_success;
49183 int i;
49184
49185 - num_rsrc_err = atomic_read(&phba->num_rsrc_err);
49186 - num_cmd_success = atomic_read(&phba->num_cmd_success);
49187 + num_rsrc_err = atomic_read_unchecked(&phba->num_rsrc_err);
49188 + num_cmd_success = atomic_read_unchecked(&phba->num_cmd_success);
49189
49190 /*
49191 * The error and success command counters are global per
49192 @@ -452,8 +452,8 @@ lpfc_ramp_down_queue_handler(struct lpfc_hba *phba)
49193 }
49194 }
49195 lpfc_destroy_vport_work_array(phba, vports);
49196 - atomic_set(&phba->num_rsrc_err, 0);
49197 - atomic_set(&phba->num_cmd_success, 0);
49198 + atomic_set_unchecked(&phba->num_rsrc_err, 0);
49199 + atomic_set_unchecked(&phba->num_cmd_success, 0);
49200 }
49201
49202 /**
49203 diff --git a/drivers/scsi/mpt2sas/mpt2sas_scsih.c b/drivers/scsi/mpt2sas/mpt2sas_scsih.c
49204 index 6fd7d40..b444223 100644
49205 --- a/drivers/scsi/mpt2sas/mpt2sas_scsih.c
49206 +++ b/drivers/scsi/mpt2sas/mpt2sas_scsih.c
49207 @@ -1557,7 +1557,7 @@ _scsih_get_resync(struct device *dev)
49208 {
49209 struct scsi_device *sdev = to_scsi_device(dev);
49210 struct MPT2SAS_ADAPTER *ioc = shost_priv(sdev->host);
49211 - static struct _raid_device *raid_device;
49212 + struct _raid_device *raid_device;
49213 unsigned long flags;
49214 Mpi2RaidVolPage0_t vol_pg0;
49215 Mpi2ConfigReply_t mpi_reply;
49216 @@ -1609,7 +1609,7 @@ _scsih_get_state(struct device *dev)
49217 {
49218 struct scsi_device *sdev = to_scsi_device(dev);
49219 struct MPT2SAS_ADAPTER *ioc = shost_priv(sdev->host);
49220 - static struct _raid_device *raid_device;
49221 + struct _raid_device *raid_device;
49222 unsigned long flags;
49223 Mpi2RaidVolPage0_t vol_pg0;
49224 Mpi2ConfigReply_t mpi_reply;
49225 @@ -6637,7 +6637,7 @@ _scsih_sas_ir_operation_status_event(struct MPT2SAS_ADAPTER *ioc,
49226 struct fw_event_work *fw_event)
49227 {
49228 Mpi2EventDataIrOperationStatus_t *event_data = fw_event->event_data;
49229 - static struct _raid_device *raid_device;
49230 + struct _raid_device *raid_device;
49231 unsigned long flags;
49232 u16 handle;
49233
49234 @@ -7108,7 +7108,7 @@ _scsih_scan_for_devices_after_reset(struct MPT2SAS_ADAPTER *ioc)
49235 u64 sas_address;
49236 struct _sas_device *sas_device;
49237 struct _sas_node *expander_device;
49238 - static struct _raid_device *raid_device;
49239 + struct _raid_device *raid_device;
49240 u8 retry_count;
49241 unsigned long flags;
49242
49243 diff --git a/drivers/scsi/pmcraid.c b/drivers/scsi/pmcraid.c
49244 index be8ce54..94ed33a 100644
49245 --- a/drivers/scsi/pmcraid.c
49246 +++ b/drivers/scsi/pmcraid.c
49247 @@ -200,8 +200,8 @@ static int pmcraid_slave_alloc(struct scsi_device *scsi_dev)
49248 res->scsi_dev = scsi_dev;
49249 scsi_dev->hostdata = res;
49250 res->change_detected = 0;
49251 - atomic_set(&res->read_failures, 0);
49252 - atomic_set(&res->write_failures, 0);
49253 + atomic_set_unchecked(&res->read_failures, 0);
49254 + atomic_set_unchecked(&res->write_failures, 0);
49255 rc = 0;
49256 }
49257 spin_unlock_irqrestore(&pinstance->resource_lock, lock_flags);
49258 @@ -2687,9 +2687,9 @@ static int pmcraid_error_handler(struct pmcraid_cmd *cmd)
49259
49260 /* If this was a SCSI read/write command keep count of errors */
49261 if (SCSI_CMD_TYPE(scsi_cmd->cmnd[0]) == SCSI_READ_CMD)
49262 - atomic_inc(&res->read_failures);
49263 + atomic_inc_unchecked(&res->read_failures);
49264 else if (SCSI_CMD_TYPE(scsi_cmd->cmnd[0]) == SCSI_WRITE_CMD)
49265 - atomic_inc(&res->write_failures);
49266 + atomic_inc_unchecked(&res->write_failures);
49267
49268 if (!RES_IS_GSCSI(res->cfg_entry) &&
49269 masked_ioasc != PMCRAID_IOASC_HW_DEVICE_BUS_STATUS_ERROR) {
49270 @@ -3545,7 +3545,7 @@ static int pmcraid_queuecommand_lck(
49271 * block of scsi_cmd which is re-used (e.g. cancel/abort), which uses
49272 * hrrq_id assigned here in queuecommand
49273 */
49274 - ioarcb->hrrq_id = atomic_add_return(1, &(pinstance->last_message_id)) %
49275 + ioarcb->hrrq_id = atomic_add_return_unchecked(1, &(pinstance->last_message_id)) %
49276 pinstance->num_hrrq;
49277 cmd->cmd_done = pmcraid_io_done;
49278
49279 @@ -3857,7 +3857,7 @@ static long pmcraid_ioctl_passthrough(
49280 * block of scsi_cmd which is re-used (e.g. cancel/abort), which uses
49281 * hrrq_id assigned here in queuecommand
49282 */
49283 - ioarcb->hrrq_id = atomic_add_return(1, &(pinstance->last_message_id)) %
49284 + ioarcb->hrrq_id = atomic_add_return_unchecked(1, &(pinstance->last_message_id)) %
49285 pinstance->num_hrrq;
49286
49287 if (request_size) {
49288 @@ -4495,7 +4495,7 @@ static void pmcraid_worker_function(struct work_struct *workp)
49289
49290 pinstance = container_of(workp, struct pmcraid_instance, worker_q);
49291 /* add resources only after host is added into system */
49292 - if (!atomic_read(&pinstance->expose_resources))
49293 + if (!atomic_read_unchecked(&pinstance->expose_resources))
49294 return;
49295
49296 fw_version = be16_to_cpu(pinstance->inq_data->fw_version);
49297 @@ -5322,8 +5322,8 @@ static int pmcraid_init_instance(struct pci_dev *pdev, struct Scsi_Host *host,
49298 init_waitqueue_head(&pinstance->reset_wait_q);
49299
49300 atomic_set(&pinstance->outstanding_cmds, 0);
49301 - atomic_set(&pinstance->last_message_id, 0);
49302 - atomic_set(&pinstance->expose_resources, 0);
49303 + atomic_set_unchecked(&pinstance->last_message_id, 0);
49304 + atomic_set_unchecked(&pinstance->expose_resources, 0);
49305
49306 INIT_LIST_HEAD(&pinstance->free_res_q);
49307 INIT_LIST_HEAD(&pinstance->used_res_q);
49308 @@ -6036,7 +6036,7 @@ static int pmcraid_probe(struct pci_dev *pdev,
49309 /* Schedule worker thread to handle CCN and take care of adding and
49310 * removing devices to OS
49311 */
49312 - atomic_set(&pinstance->expose_resources, 1);
49313 + atomic_set_unchecked(&pinstance->expose_resources, 1);
49314 schedule_work(&pinstance->worker_q);
49315 return rc;
49316
49317 diff --git a/drivers/scsi/pmcraid.h b/drivers/scsi/pmcraid.h
49318 index e1d150f..6c6df44 100644
49319 --- a/drivers/scsi/pmcraid.h
49320 +++ b/drivers/scsi/pmcraid.h
49321 @@ -748,7 +748,7 @@ struct pmcraid_instance {
49322 struct pmcraid_isr_param hrrq_vector[PMCRAID_NUM_MSIX_VECTORS];
49323
49324 /* Message id as filled in last fired IOARCB, used to identify HRRQ */
49325 - atomic_t last_message_id;
49326 + atomic_unchecked_t last_message_id;
49327
49328 /* configuration table */
49329 struct pmcraid_config_table *cfg_table;
49330 @@ -777,7 +777,7 @@ struct pmcraid_instance {
49331 atomic_t outstanding_cmds;
49332
49333 /* should add/delete resources to mid-layer now ?*/
49334 - atomic_t expose_resources;
49335 + atomic_unchecked_t expose_resources;
49336
49337
49338
49339 @@ -813,8 +813,8 @@ struct pmcraid_resource_entry {
49340 struct pmcraid_config_table_entry_ext cfg_entry_ext;
49341 };
49342 struct scsi_device *scsi_dev; /* Link scsi_device structure */
49343 - atomic_t read_failures; /* count of failed READ commands */
49344 - atomic_t write_failures; /* count of failed WRITE commands */
49345 + atomic_unchecked_t read_failures; /* count of failed READ commands */
49346 + atomic_unchecked_t write_failures; /* count of failed WRITE commands */
49347
49348 /* To indicate add/delete/modify during CCN */
49349 u8 change_detected;
49350 diff --git a/drivers/scsi/qla2xxx/qla_attr.c b/drivers/scsi/qla2xxx/qla_attr.c
49351 index 07befcf..c0bff13 100644
49352 --- a/drivers/scsi/qla2xxx/qla_attr.c
49353 +++ b/drivers/scsi/qla2xxx/qla_attr.c
49354 @@ -2188,7 +2188,7 @@ qla24xx_vport_disable(struct fc_vport *fc_vport, bool disable)
49355 return 0;
49356 }
49357
49358 -struct fc_function_template qla2xxx_transport_functions = {
49359 +fc_function_template_no_const qla2xxx_transport_functions = {
49360
49361 .show_host_node_name = 1,
49362 .show_host_port_name = 1,
49363 @@ -2236,7 +2236,7 @@ struct fc_function_template qla2xxx_transport_functions = {
49364 .bsg_timeout = qla24xx_bsg_timeout,
49365 };
49366
49367 -struct fc_function_template qla2xxx_transport_vport_functions = {
49368 +fc_function_template_no_const qla2xxx_transport_vport_functions = {
49369
49370 .show_host_node_name = 1,
49371 .show_host_port_name = 1,
49372 diff --git a/drivers/scsi/qla2xxx/qla_gbl.h b/drivers/scsi/qla2xxx/qla_gbl.h
49373 index e665e81..16e84e6 100644
49374 --- a/drivers/scsi/qla2xxx/qla_gbl.h
49375 +++ b/drivers/scsi/qla2xxx/qla_gbl.h
49376 @@ -557,8 +557,8 @@ extern void qla2x00_get_sym_node_name(scsi_qla_host_t *, uint8_t *);
49377 struct device_attribute;
49378 extern struct device_attribute *qla2x00_host_attrs[];
49379 struct fc_function_template;
49380 -extern struct fc_function_template qla2xxx_transport_functions;
49381 -extern struct fc_function_template qla2xxx_transport_vport_functions;
49382 +extern fc_function_template_no_const qla2xxx_transport_functions;
49383 +extern fc_function_template_no_const qla2xxx_transport_vport_functions;
49384 extern void qla2x00_alloc_sysfs_attr(scsi_qla_host_t *);
49385 extern void qla2x00_free_sysfs_attr(scsi_qla_host_t *, bool);
49386 extern void qla2x00_init_host_attr(scsi_qla_host_t *);
49387 diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
49388 index 19e99cc..b3c0b7b 100644
49389 --- a/drivers/scsi/qla2xxx/qla_os.c
49390 +++ b/drivers/scsi/qla2xxx/qla_os.c
49391 @@ -1493,8 +1493,10 @@ qla2x00_config_dma_addressing(struct qla_hw_data *ha)
49392 !pci_set_consistent_dma_mask(ha->pdev, DMA_BIT_MASK(64))) {
49393 /* Ok, a 64bit DMA mask is applicable. */
49394 ha->flags.enable_64bit_addressing = 1;
49395 - ha->isp_ops->calc_req_entries = qla2x00_calc_iocbs_64;
49396 - ha->isp_ops->build_iocbs = qla2x00_build_scsi_iocbs_64;
49397 + pax_open_kernel();
49398 + *(void **)&ha->isp_ops->calc_req_entries = qla2x00_calc_iocbs_64;
49399 + *(void **)&ha->isp_ops->build_iocbs = qla2x00_build_scsi_iocbs_64;
49400 + pax_close_kernel();
49401 return;
49402 }
49403 }
49404 diff --git a/drivers/scsi/qla4xxx/ql4_def.h b/drivers/scsi/qla4xxx/ql4_def.h
49405 index 73a5022..4e0797c 100644
49406 --- a/drivers/scsi/qla4xxx/ql4_def.h
49407 +++ b/drivers/scsi/qla4xxx/ql4_def.h
49408 @@ -305,7 +305,7 @@ struct ddb_entry {
49409 * (4000 only) */
49410 atomic_t relogin_timer; /* Max Time to wait for
49411 * relogin to complete */
49412 - atomic_t relogin_retry_count; /* Num of times relogin has been
49413 + atomic_unchecked_t relogin_retry_count; /* Num of times relogin has been
49414 * retried */
49415 uint32_t default_time2wait; /* Default Min time between
49416 * relogins (+aens) */
49417 diff --git a/drivers/scsi/qla4xxx/ql4_os.c b/drivers/scsi/qla4xxx/ql4_os.c
49418 index 459b9f7..2930a68 100644
49419 --- a/drivers/scsi/qla4xxx/ql4_os.c
49420 +++ b/drivers/scsi/qla4xxx/ql4_os.c
49421 @@ -4499,12 +4499,12 @@ static void qla4xxx_check_relogin_flash_ddb(struct iscsi_cls_session *cls_sess)
49422 */
49423 if (!iscsi_is_session_online(cls_sess)) {
49424 /* Reset retry relogin timer */
49425 - atomic_inc(&ddb_entry->relogin_retry_count);
49426 + atomic_inc_unchecked(&ddb_entry->relogin_retry_count);
49427 DEBUG2(ql4_printk(KERN_INFO, ha,
49428 "%s: index[%d] relogin timed out-retrying"
49429 " relogin (%d), retry (%d)\n", __func__,
49430 ddb_entry->fw_ddb_index,
49431 - atomic_read(&ddb_entry->relogin_retry_count),
49432 + atomic_read_unchecked(&ddb_entry->relogin_retry_count),
49433 ddb_entry->default_time2wait + 4));
49434 set_bit(DPC_RELOGIN_DEVICE, &ha->dpc_flags);
49435 atomic_set(&ddb_entry->retry_relogin_timer,
49436 @@ -6609,7 +6609,7 @@ static void qla4xxx_setup_flash_ddb_entry(struct scsi_qla_host *ha,
49437
49438 atomic_set(&ddb_entry->retry_relogin_timer, INVALID_ENTRY);
49439 atomic_set(&ddb_entry->relogin_timer, 0);
49440 - atomic_set(&ddb_entry->relogin_retry_count, 0);
49441 + atomic_set_unchecked(&ddb_entry->relogin_retry_count, 0);
49442 def_timeout = le16_to_cpu(ddb_entry->fw_ddb_entry.def_timeout);
49443 ddb_entry->default_relogin_timeout =
49444 (def_timeout > LOGIN_TOV) && (def_timeout < LOGIN_TOV * 10) ?
49445 diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
49446 index 88d46fe..7351be5 100644
49447 --- a/drivers/scsi/scsi.c
49448 +++ b/drivers/scsi/scsi.c
49449 @@ -640,7 +640,7 @@ int scsi_dispatch_cmd(struct scsi_cmnd *cmd)
49450 struct Scsi_Host *host = cmd->device->host;
49451 int rtn = 0;
49452
49453 - atomic_inc(&cmd->device->iorequest_cnt);
49454 + atomic_inc_unchecked(&cmd->device->iorequest_cnt);
49455
49456 /* check if the device is still usable */
49457 if (unlikely(cmd->device->sdev_state == SDEV_DEL)) {
49458 diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
49459 index 9db097a..ca5c291 100644
49460 --- a/drivers/scsi/scsi_lib.c
49461 +++ b/drivers/scsi/scsi_lib.c
49462 @@ -1464,7 +1464,7 @@ static void scsi_kill_request(struct request *req, struct request_queue *q)
49463 shost = sdev->host;
49464 scsi_init_cmd_errh(cmd);
49465 cmd->result = DID_NO_CONNECT << 16;
49466 - atomic_inc(&cmd->device->iorequest_cnt);
49467 + atomic_inc_unchecked(&cmd->device->iorequest_cnt);
49468
49469 /*
49470 * SCSI request completion path will do scsi_device_unbusy(),
49471 @@ -1490,9 +1490,9 @@ static void scsi_softirq_done(struct request *rq)
49472
49473 INIT_LIST_HEAD(&cmd->eh_entry);
49474
49475 - atomic_inc(&cmd->device->iodone_cnt);
49476 + atomic_inc_unchecked(&cmd->device->iodone_cnt);
49477 if (cmd->result)
49478 - atomic_inc(&cmd->device->ioerr_cnt);
49479 + atomic_inc_unchecked(&cmd->device->ioerr_cnt);
49480
49481 disposition = scsi_decide_disposition(cmd);
49482 if (disposition != SUCCESS &&
49483 diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
49484 index 074e8cc..f612e5c 100644
49485 --- a/drivers/scsi/scsi_sysfs.c
49486 +++ b/drivers/scsi/scsi_sysfs.c
49487 @@ -780,7 +780,7 @@ show_iostat_##field(struct device *dev, struct device_attribute *attr, \
49488 char *buf) \
49489 { \
49490 struct scsi_device *sdev = to_scsi_device(dev); \
49491 - unsigned long long count = atomic_read(&sdev->field); \
49492 + unsigned long long count = atomic_read_unchecked(&sdev->field); \
49493 return snprintf(buf, 20, "0x%llx\n", count); \
49494 } \
49495 static DEVICE_ATTR(field, S_IRUGO, show_iostat_##field, NULL)
49496 diff --git a/drivers/scsi/scsi_tgt_lib.c b/drivers/scsi/scsi_tgt_lib.c
49497 index e51add0..1e06a96 100644
49498 --- a/drivers/scsi/scsi_tgt_lib.c
49499 +++ b/drivers/scsi/scsi_tgt_lib.c
49500 @@ -363,7 +363,7 @@ static int scsi_map_user_pages(struct scsi_tgt_cmd *tcmd, struct scsi_cmnd *cmd,
49501 int err;
49502
49503 dprintk("%lx %u\n", uaddr, len);
49504 - err = blk_rq_map_user(q, rq, NULL, (void *)uaddr, len, GFP_KERNEL);
49505 + err = blk_rq_map_user(q, rq, NULL, (void __user *)uaddr, len, GFP_KERNEL);
49506 if (err) {
49507 /*
49508 * TODO: need to fixup sg_tablesize, max_segment_size,
49509 diff --git a/drivers/scsi/scsi_transport_fc.c b/drivers/scsi/scsi_transport_fc.c
49510 index f80908f..22aba76 100644
49511 --- a/drivers/scsi/scsi_transport_fc.c
49512 +++ b/drivers/scsi/scsi_transport_fc.c
49513 @@ -498,7 +498,7 @@ static DECLARE_TRANSPORT_CLASS(fc_vport_class,
49514 * Netlink Infrastructure
49515 */
49516
49517 -static atomic_t fc_event_seq;
49518 +static atomic_unchecked_t fc_event_seq;
49519
49520 /**
49521 * fc_get_event_number - Obtain the next sequential FC event number
49522 @@ -511,7 +511,7 @@ static atomic_t fc_event_seq;
49523 u32
49524 fc_get_event_number(void)
49525 {
49526 - return atomic_add_return(1, &fc_event_seq);
49527 + return atomic_add_return_unchecked(1, &fc_event_seq);
49528 }
49529 EXPORT_SYMBOL(fc_get_event_number);
49530
49531 @@ -655,7 +655,7 @@ static __init int fc_transport_init(void)
49532 {
49533 int error;
49534
49535 - atomic_set(&fc_event_seq, 0);
49536 + atomic_set_unchecked(&fc_event_seq, 0);
49537
49538 error = transport_class_register(&fc_host_class);
49539 if (error)
49540 @@ -845,7 +845,7 @@ static int fc_str_to_dev_loss(const char *buf, unsigned long *val)
49541 char *cp;
49542
49543 *val = simple_strtoul(buf, &cp, 0);
49544 - if ((*cp && (*cp != '\n')) || (*val < 0))
49545 + if (*cp && (*cp != '\n'))
49546 return -EINVAL;
49547 /*
49548 * Check for overflow; dev_loss_tmo is u32
49549 diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c
49550 index 0102a2d..cc3f8e9 100644
49551 --- a/drivers/scsi/scsi_transport_iscsi.c
49552 +++ b/drivers/scsi/scsi_transport_iscsi.c
49553 @@ -79,7 +79,7 @@ struct iscsi_internal {
49554 struct transport_container session_cont;
49555 };
49556
49557 -static atomic_t iscsi_session_nr; /* sysfs session id for next new session */
49558 +static atomic_unchecked_t iscsi_session_nr; /* sysfs session id for next new session */
49559 static struct workqueue_struct *iscsi_eh_timer_workq;
49560
49561 static DEFINE_IDA(iscsi_sess_ida);
49562 @@ -2071,7 +2071,7 @@ int iscsi_add_session(struct iscsi_cls_session *session, unsigned int target_id)
49563 int err;
49564
49565 ihost = shost->shost_data;
49566 - session->sid = atomic_add_return(1, &iscsi_session_nr);
49567 + session->sid = atomic_add_return_unchecked(1, &iscsi_session_nr);
49568
49569 if (target_id == ISCSI_MAX_TARGET) {
49570 id = ida_simple_get(&iscsi_sess_ida, 0, 0, GFP_KERNEL);
49571 @@ -4511,7 +4511,7 @@ static __init int iscsi_transport_init(void)
49572 printk(KERN_INFO "Loading iSCSI transport class v%s.\n",
49573 ISCSI_TRANSPORT_VERSION);
49574
49575 - atomic_set(&iscsi_session_nr, 0);
49576 + atomic_set_unchecked(&iscsi_session_nr, 0);
49577
49578 err = class_register(&iscsi_transport_class);
49579 if (err)
49580 diff --git a/drivers/scsi/scsi_transport_srp.c b/drivers/scsi/scsi_transport_srp.c
49581 index 13e8983..d306a68 100644
49582 --- a/drivers/scsi/scsi_transport_srp.c
49583 +++ b/drivers/scsi/scsi_transport_srp.c
49584 @@ -36,7 +36,7 @@
49585 #include "scsi_transport_srp_internal.h"
49586
49587 struct srp_host_attrs {
49588 - atomic_t next_port_id;
49589 + atomic_unchecked_t next_port_id;
49590 };
49591 #define to_srp_host_attrs(host) ((struct srp_host_attrs *)(host)->shost_data)
49592
49593 @@ -101,7 +101,7 @@ static int srp_host_setup(struct transport_container *tc, struct device *dev,
49594 struct Scsi_Host *shost = dev_to_shost(dev);
49595 struct srp_host_attrs *srp_host = to_srp_host_attrs(shost);
49596
49597 - atomic_set(&srp_host->next_port_id, 0);
49598 + atomic_set_unchecked(&srp_host->next_port_id, 0);
49599 return 0;
49600 }
49601
49602 @@ -734,7 +734,7 @@ struct srp_rport *srp_rport_add(struct Scsi_Host *shost,
49603 rport_fast_io_fail_timedout);
49604 INIT_DELAYED_WORK(&rport->dev_loss_work, rport_dev_loss_timedout);
49605
49606 - id = atomic_inc_return(&to_srp_host_attrs(shost)->next_port_id);
49607 + id = atomic_inc_return_unchecked(&to_srp_host_attrs(shost)->next_port_id);
49608 dev_set_name(&rport->dev, "port-%d:%d", shost->host_no, id);
49609
49610 transport_setup_device(&rport->dev);
49611 diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
49612 index efcbcd1..aeaf26e 100644
49613 --- a/drivers/scsi/sd.c
49614 +++ b/drivers/scsi/sd.c
49615 @@ -2968,7 +2968,7 @@ static int sd_probe(struct device *dev)
49616 sdkp->disk = gd;
49617 sdkp->index = index;
49618 atomic_set(&sdkp->openers, 0);
49619 - atomic_set(&sdkp->device->ioerr_cnt, 0);
49620 + atomic_set_unchecked(&sdkp->device->ioerr_cnt, 0);
49621
49622 if (!sdp->request_queue->rq_timeout) {
49623 if (sdp->type != TYPE_MOD)
49624 diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
49625 index df5e961..df6b97f 100644
49626 --- a/drivers/scsi/sg.c
49627 +++ b/drivers/scsi/sg.c
49628 @@ -1102,7 +1102,7 @@ sg_ioctl(struct file *filp, unsigned int cmd_in, unsigned long arg)
49629 sdp->disk->disk_name,
49630 MKDEV(SCSI_GENERIC_MAJOR, sdp->index),
49631 NULL,
49632 - (char *)arg);
49633 + (char __user *)arg);
49634 case BLKTRACESTART:
49635 return blk_trace_startstop(sdp->device->request_queue, 1);
49636 case BLKTRACESTOP:
49637 diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
49638 index 939edf4..3f50423 100644
49639 --- a/drivers/spi/spi.c
49640 +++ b/drivers/spi/spi.c
49641 @@ -2204,7 +2204,7 @@ int spi_bus_unlock(struct spi_master *master)
49642 EXPORT_SYMBOL_GPL(spi_bus_unlock);
49643
49644 /* portable code must never pass more than 32 bytes */
49645 -#define SPI_BUFSIZ max(32, SMP_CACHE_BYTES)
49646 +#define SPI_BUFSIZ max(32UL, SMP_CACHE_BYTES)
49647
49648 static u8 *buf;
49649
49650 diff --git a/drivers/staging/android/timed_output.c b/drivers/staging/android/timed_output.c
49651 index 2c61783..4d49e4e 100644
49652 --- a/drivers/staging/android/timed_output.c
49653 +++ b/drivers/staging/android/timed_output.c
49654 @@ -25,7 +25,7 @@
49655 #include "timed_output.h"
49656
49657 static struct class *timed_output_class;
49658 -static atomic_t device_count;
49659 +static atomic_unchecked_t device_count;
49660
49661 static ssize_t enable_show(struct device *dev, struct device_attribute *attr,
49662 char *buf)
49663 @@ -63,7 +63,7 @@ static int create_timed_output_class(void)
49664 timed_output_class = class_create(THIS_MODULE, "timed_output");
49665 if (IS_ERR(timed_output_class))
49666 return PTR_ERR(timed_output_class);
49667 - atomic_set(&device_count, 0);
49668 + atomic_set_unchecked(&device_count, 0);
49669 timed_output_class->dev_groups = timed_output_groups;
49670 }
49671
49672 @@ -81,7 +81,7 @@ int timed_output_dev_register(struct timed_output_dev *tdev)
49673 if (ret < 0)
49674 return ret;
49675
49676 - tdev->index = atomic_inc_return(&device_count);
49677 + tdev->index = atomic_inc_return_unchecked(&device_count);
49678 tdev->dev = device_create(timed_output_class, NULL,
49679 MKDEV(0, tdev->index), NULL, "%s", tdev->name);
49680 if (IS_ERR(tdev->dev))
49681 diff --git a/drivers/staging/gdm724x/gdm_tty.c b/drivers/staging/gdm724x/gdm_tty.c
49682 index fe47cd3..19a1bd1 100644
49683 --- a/drivers/staging/gdm724x/gdm_tty.c
49684 +++ b/drivers/staging/gdm724x/gdm_tty.c
49685 @@ -44,7 +44,7 @@
49686 #define gdm_tty_send_control(n, r, v, d, l) (\
49687 n->tty_dev->send_control(n->tty_dev->priv_dev, r, v, d, l))
49688
49689 -#define GDM_TTY_READY(gdm) (gdm && gdm->tty_dev && gdm->port.count)
49690 +#define GDM_TTY_READY(gdm) (gdm && gdm->tty_dev && atomic_read(&gdm->port.count))
49691
49692 static struct tty_driver *gdm_driver[TTY_MAX_COUNT];
49693 static struct gdm *gdm_table[TTY_MAX_COUNT][GDM_TTY_MINOR];
49694 diff --git a/drivers/staging/imx-drm/imx-drm-core.c b/drivers/staging/imx-drm/imx-drm-core.c
49695 index c270c9a..94ddf82 100644
49696 --- a/drivers/staging/imx-drm/imx-drm-core.c
49697 +++ b/drivers/staging/imx-drm/imx-drm-core.c
49698 @@ -362,7 +362,7 @@ int imx_drm_add_crtc(struct drm_device *drm, struct drm_crtc *crtc,
49699 if (imxdrm->pipes >= MAX_CRTC)
49700 return -EINVAL;
49701
49702 - if (imxdrm->drm->open_count)
49703 + if (local_read(&imxdrm->drm->open_count))
49704 return -EBUSY;
49705
49706 imx_drm_crtc = kzalloc(sizeof(*imx_drm_crtc), GFP_KERNEL);
49707 diff --git a/drivers/staging/lustre/lnet/selftest/brw_test.c b/drivers/staging/lustre/lnet/selftest/brw_test.c
49708 index 3f8020c..649fded 100644
49709 --- a/drivers/staging/lustre/lnet/selftest/brw_test.c
49710 +++ b/drivers/staging/lustre/lnet/selftest/brw_test.c
49711 @@ -488,13 +488,11 @@ brw_server_handle(struct srpc_server_rpc *rpc)
49712 return 0;
49713 }
49714
49715 -sfw_test_client_ops_t brw_test_client;
49716 -void brw_init_test_client(void)
49717 -{
49718 - brw_test_client.tso_init = brw_client_init;
49719 - brw_test_client.tso_fini = brw_client_fini;
49720 - brw_test_client.tso_prep_rpc = brw_client_prep_rpc;
49721 - brw_test_client.tso_done_rpc = brw_client_done_rpc;
49722 +sfw_test_client_ops_t brw_test_client = {
49723 + .tso_init = brw_client_init,
49724 + .tso_fini = brw_client_fini,
49725 + .tso_prep_rpc = brw_client_prep_rpc,
49726 + .tso_done_rpc = brw_client_done_rpc,
49727 };
49728
49729 srpc_service_t brw_test_service;
49730 diff --git a/drivers/staging/lustre/lnet/selftest/framework.c b/drivers/staging/lustre/lnet/selftest/framework.c
49731 index 050723a..fa6fdf1 100644
49732 --- a/drivers/staging/lustre/lnet/selftest/framework.c
49733 +++ b/drivers/staging/lustre/lnet/selftest/framework.c
49734 @@ -1635,12 +1635,10 @@ static srpc_service_t sfw_services[] =
49735
49736 extern sfw_test_client_ops_t ping_test_client;
49737 extern srpc_service_t ping_test_service;
49738 -extern void ping_init_test_client(void);
49739 extern void ping_init_test_service(void);
49740
49741 extern sfw_test_client_ops_t brw_test_client;
49742 extern srpc_service_t brw_test_service;
49743 -extern void brw_init_test_client(void);
49744 extern void brw_init_test_service(void);
49745
49746
49747 @@ -1684,12 +1682,10 @@ sfw_startup (void)
49748 INIT_LIST_HEAD(&sfw_data.fw_zombie_rpcs);
49749 INIT_LIST_HEAD(&sfw_data.fw_zombie_sessions);
49750
49751 - brw_init_test_client();
49752 brw_init_test_service();
49753 rc = sfw_register_test(&brw_test_service, &brw_test_client);
49754 LASSERT (rc == 0);
49755
49756 - ping_init_test_client();
49757 ping_init_test_service();
49758 rc = sfw_register_test(&ping_test_service, &ping_test_client);
49759 LASSERT (rc == 0);
49760 diff --git a/drivers/staging/lustre/lnet/selftest/ping_test.c b/drivers/staging/lustre/lnet/selftest/ping_test.c
49761 index 750cac4..e4d751f 100644
49762 --- a/drivers/staging/lustre/lnet/selftest/ping_test.c
49763 +++ b/drivers/staging/lustre/lnet/selftest/ping_test.c
49764 @@ -211,14 +211,12 @@ ping_server_handle(struct srpc_server_rpc *rpc)
49765 return 0;
49766 }
49767
49768 -sfw_test_client_ops_t ping_test_client;
49769 -void ping_init_test_client(void)
49770 -{
49771 - ping_test_client.tso_init = ping_client_init;
49772 - ping_test_client.tso_fini = ping_client_fini;
49773 - ping_test_client.tso_prep_rpc = ping_client_prep_rpc;
49774 - ping_test_client.tso_done_rpc = ping_client_done_rpc;
49775 -}
49776 +sfw_test_client_ops_t ping_test_client = {
49777 + .tso_init = ping_client_init,
49778 + .tso_fini = ping_client_fini,
49779 + .tso_prep_rpc = ping_client_prep_rpc,
49780 + .tso_done_rpc = ping_client_done_rpc,
49781 +};
49782
49783 srpc_service_t ping_test_service;
49784 void ping_init_test_service(void)
49785 diff --git a/drivers/staging/lustre/lustre/include/lustre_dlm.h b/drivers/staging/lustre/lustre/include/lustre_dlm.h
49786 index 3e25f00..0d59cf5 100644
49787 --- a/drivers/staging/lustre/lustre/include/lustre_dlm.h
49788 +++ b/drivers/staging/lustre/lustre/include/lustre_dlm.h
49789 @@ -1141,7 +1141,7 @@ struct ldlm_callback_suite {
49790 ldlm_completion_callback lcs_completion;
49791 ldlm_blocking_callback lcs_blocking;
49792 ldlm_glimpse_callback lcs_glimpse;
49793 -};
49794 +} __no_const;
49795
49796 /* ldlm_lockd.c */
49797 int ldlm_del_waiting_lock(struct ldlm_lock *lock);
49798 diff --git a/drivers/staging/lustre/lustre/include/obd.h b/drivers/staging/lustre/lustre/include/obd.h
49799 index 72cf3fe..4beac19 100644
49800 --- a/drivers/staging/lustre/lustre/include/obd.h
49801 +++ b/drivers/staging/lustre/lustre/include/obd.h
49802 @@ -1427,7 +1427,7 @@ struct md_ops {
49803 * lprocfs_alloc_md_stats() in obdclass/lprocfs_status.c. Also, add a
49804 * wrapper function in include/linux/obd_class.h.
49805 */
49806 -};
49807 +} __no_const;
49808
49809 struct lsm_operations {
49810 void (*lsm_free)(struct lov_stripe_md *);
49811 diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c b/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c
49812 index 986bf38..eab2558f 100644
49813 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c
49814 +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c
49815 @@ -259,7 +259,7 @@ ldlm_process_flock_lock(struct ldlm_lock *req, __u64 *flags, int first_enq,
49816 int added = (mode == LCK_NL);
49817 int overlaps = 0;
49818 int splitted = 0;
49819 - const struct ldlm_callback_suite null_cbs = { NULL };
49820 + const struct ldlm_callback_suite null_cbs = { };
49821
49822 CDEBUG(D_DLMTRACE, "flags %#llx owner "LPU64" pid %u mode %u start "
49823 LPU64" end "LPU64"\n", *flags,
49824 diff --git a/drivers/staging/lustre/lustre/libcfs/linux/linux-proc.c b/drivers/staging/lustre/lustre/libcfs/linux/linux-proc.c
49825 index e947b91..f408990 100644
49826 --- a/drivers/staging/lustre/lustre/libcfs/linux/linux-proc.c
49827 +++ b/drivers/staging/lustre/lustre/libcfs/linux/linux-proc.c
49828 @@ -217,7 +217,7 @@ DECLARE_PROC_HANDLER(proc_debug_mb)
49829 int LL_PROC_PROTO(proc_console_max_delay_cs)
49830 {
49831 int rc, max_delay_cs;
49832 - ctl_table_t dummy = *table;
49833 + ctl_table_no_const dummy = *table;
49834 cfs_duration_t d;
49835
49836 dummy.data = &max_delay_cs;
49837 @@ -248,7 +248,7 @@ int LL_PROC_PROTO(proc_console_max_delay_cs)
49838 int LL_PROC_PROTO(proc_console_min_delay_cs)
49839 {
49840 int rc, min_delay_cs;
49841 - ctl_table_t dummy = *table;
49842 + ctl_table_no_const dummy = *table;
49843 cfs_duration_t d;
49844
49845 dummy.data = &min_delay_cs;
49846 @@ -279,7 +279,7 @@ int LL_PROC_PROTO(proc_console_min_delay_cs)
49847 int LL_PROC_PROTO(proc_console_backoff)
49848 {
49849 int rc, backoff;
49850 - ctl_table_t dummy = *table;
49851 + ctl_table_no_const dummy = *table;
49852
49853 dummy.data = &backoff;
49854 dummy.proc_handler = &proc_dointvec;
49855 diff --git a/drivers/staging/lustre/lustre/libcfs/module.c b/drivers/staging/lustre/lustre/libcfs/module.c
49856 index 24ae26d..9d09cab 100644
49857 --- a/drivers/staging/lustre/lustre/libcfs/module.c
49858 +++ b/drivers/staging/lustre/lustre/libcfs/module.c
49859 @@ -313,11 +313,11 @@ out:
49860
49861
49862 struct cfs_psdev_ops libcfs_psdev_ops = {
49863 - libcfs_psdev_open,
49864 - libcfs_psdev_release,
49865 - NULL,
49866 - NULL,
49867 - libcfs_ioctl
49868 + .p_open = libcfs_psdev_open,
49869 + .p_close = libcfs_psdev_release,
49870 + .p_read = NULL,
49871 + .p_write = NULL,
49872 + .p_ioctl = libcfs_ioctl
49873 };
49874
49875 extern int insert_proc(void);
49876 diff --git a/drivers/staging/lustre/lustre/llite/dir.c b/drivers/staging/lustre/lustre/llite/dir.c
49877 index 7fbc18e..f982071 100644
49878 --- a/drivers/staging/lustre/lustre/llite/dir.c
49879 +++ b/drivers/staging/lustre/lustre/llite/dir.c
49880 @@ -660,7 +660,7 @@ int ll_dir_setdirstripe(struct inode *dir, struct lmv_user_md *lump,
49881 int mode;
49882 int err;
49883
49884 - mode = (0755 & (S_IRWXUGO|S_ISVTX) & ~current->fs->umask) | S_IFDIR;
49885 + mode = (0755 & (S_IRWXUGO|S_ISVTX) & ~current_umask()) | S_IFDIR;
49886 op_data = ll_prep_md_op_data(NULL, dir, NULL, filename,
49887 strlen(filename), mode, LUSTRE_OPC_MKDIR,
49888 lump);
49889 diff --git a/drivers/staging/media/solo6x10/solo6x10-core.c b/drivers/staging/media/solo6x10/solo6x10-core.c
49890 index f670469..03b7438 100644
49891 --- a/drivers/staging/media/solo6x10/solo6x10-core.c
49892 +++ b/drivers/staging/media/solo6x10/solo6x10-core.c
49893 @@ -434,7 +434,7 @@ static void solo_device_release(struct device *dev)
49894
49895 static int solo_sysfs_init(struct solo_dev *solo_dev)
49896 {
49897 - struct bin_attribute *sdram_attr = &solo_dev->sdram_attr;
49898 + bin_attribute_no_const *sdram_attr = &solo_dev->sdram_attr;
49899 struct device *dev = &solo_dev->dev;
49900 const char *driver;
49901 int i;
49902 diff --git a/drivers/staging/media/solo6x10/solo6x10-g723.c b/drivers/staging/media/solo6x10/solo6x10-g723.c
49903 index 74f037b..5b5bb76 100644
49904 --- a/drivers/staging/media/solo6x10/solo6x10-g723.c
49905 +++ b/drivers/staging/media/solo6x10/solo6x10-g723.c
49906 @@ -355,7 +355,7 @@ static int solo_snd_pcm_init(struct solo_dev *solo_dev)
49907
49908 int solo_g723_init(struct solo_dev *solo_dev)
49909 {
49910 - static struct snd_device_ops ops = { NULL };
49911 + static struct snd_device_ops ops = { };
49912 struct snd_card *card;
49913 struct snd_kcontrol_new kctl;
49914 char name[32];
49915 diff --git a/drivers/staging/media/solo6x10/solo6x10-p2m.c b/drivers/staging/media/solo6x10/solo6x10-p2m.c
49916 index 7f2f247..d999137 100644
49917 --- a/drivers/staging/media/solo6x10/solo6x10-p2m.c
49918 +++ b/drivers/staging/media/solo6x10/solo6x10-p2m.c
49919 @@ -77,7 +77,7 @@ int solo_p2m_dma_desc(struct solo_dev *solo_dev,
49920
49921 /* Get next ID. According to Softlogic, 6110 has problems on !=0 P2M */
49922 if (solo_dev->type != SOLO_DEV_6110 && multi_p2m) {
49923 - p2m_id = atomic_inc_return(&solo_dev->p2m_count) % SOLO_NR_P2M;
49924 + p2m_id = atomic_inc_return_unchecked(&solo_dev->p2m_count) % SOLO_NR_P2M;
49925 if (p2m_id < 0)
49926 p2m_id = -p2m_id;
49927 }
49928 diff --git a/drivers/staging/media/solo6x10/solo6x10.h b/drivers/staging/media/solo6x10/solo6x10.h
49929 index 8964f8b..36eb087 100644
49930 --- a/drivers/staging/media/solo6x10/solo6x10.h
49931 +++ b/drivers/staging/media/solo6x10/solo6x10.h
49932 @@ -237,7 +237,7 @@ struct solo_dev {
49933
49934 /* P2M DMA Engine */
49935 struct solo_p2m_dev p2m_dev[SOLO_NR_P2M];
49936 - atomic_t p2m_count;
49937 + atomic_unchecked_t p2m_count;
49938 int p2m_jiffies;
49939 unsigned int p2m_timeouts;
49940
49941 diff --git a/drivers/staging/octeon/ethernet-rx.c b/drivers/staging/octeon/ethernet-rx.c
49942 index a0f4868..139f1fb 100644
49943 --- a/drivers/staging/octeon/ethernet-rx.c
49944 +++ b/drivers/staging/octeon/ethernet-rx.c
49945 @@ -417,11 +417,11 @@ static int cvm_oct_napi_poll(struct napi_struct *napi, int budget)
49946 /* Increment RX stats for virtual ports */
49947 if (work->ipprt >= CVMX_PIP_NUM_INPUT_PORTS) {
49948 #ifdef CONFIG_64BIT
49949 - atomic64_add(1, (atomic64_t *)&priv->stats.rx_packets);
49950 - atomic64_add(skb->len, (atomic64_t *)&priv->stats.rx_bytes);
49951 + atomic64_add_unchecked(1, (atomic64_unchecked_t *)&priv->stats.rx_packets);
49952 + atomic64_add_unchecked(skb->len, (atomic64_unchecked_t *)&priv->stats.rx_bytes);
49953 #else
49954 - atomic_add(1, (atomic_t *)&priv->stats.rx_packets);
49955 - atomic_add(skb->len, (atomic_t *)&priv->stats.rx_bytes);
49956 + atomic_add_unchecked(1, (atomic_unchecked_t *)&priv->stats.rx_packets);
49957 + atomic_add_unchecked(skb->len, (atomic_unchecked_t *)&priv->stats.rx_bytes);
49958 #endif
49959 }
49960 netif_receive_skb(skb);
49961 @@ -432,9 +432,9 @@ static int cvm_oct_napi_poll(struct napi_struct *napi, int budget)
49962 dev->name);
49963 */
49964 #ifdef CONFIG_64BIT
49965 - atomic64_add(1, (atomic64_t *)&priv->stats.rx_dropped);
49966 + atomic64_add_unchecked(1, (atomic64_unchecked_t *)&priv->stats.rx_dropped);
49967 #else
49968 - atomic_add(1, (atomic_t *)&priv->stats.rx_dropped);
49969 + atomic_add_unchecked(1, (atomic_unchecked_t *)&priv->stats.rx_dropped);
49970 #endif
49971 dev_kfree_skb_irq(skb);
49972 }
49973 diff --git a/drivers/staging/octeon/ethernet.c b/drivers/staging/octeon/ethernet.c
49974 index ff7214a..6dd90f0 100644
49975 --- a/drivers/staging/octeon/ethernet.c
49976 +++ b/drivers/staging/octeon/ethernet.c
49977 @@ -247,11 +247,11 @@ static struct net_device_stats *cvm_oct_common_get_stats(struct net_device *dev)
49978 * since the RX tasklet also increments it.
49979 */
49980 #ifdef CONFIG_64BIT
49981 - atomic64_add(rx_status.dropped_packets,
49982 - (atomic64_t *)&priv->stats.rx_dropped);
49983 + atomic64_add_unchecked(rx_status.dropped_packets,
49984 + (atomic64_unchecked_t *)&priv->stats.rx_dropped);
49985 #else
49986 - atomic_add(rx_status.dropped_packets,
49987 - (atomic_t *)&priv->stats.rx_dropped);
49988 + atomic_add_unchecked(rx_status.dropped_packets,
49989 + (atomic_unchecked_t *)&priv->stats.rx_dropped);
49990 #endif
49991 }
49992
49993 diff --git a/drivers/staging/rtl8188eu/include/hal_intf.h b/drivers/staging/rtl8188eu/include/hal_intf.h
49994 index c274b34..f84de76 100644
49995 --- a/drivers/staging/rtl8188eu/include/hal_intf.h
49996 +++ b/drivers/staging/rtl8188eu/include/hal_intf.h
49997 @@ -271,7 +271,7 @@ struct hal_ops {
49998 s32 (*c2h_handler)(struct adapter *padapter,
49999 struct c2h_evt_hdr *c2h_evt);
50000 c2h_id_filter c2h_id_filter_ccx;
50001 -};
50002 +} __no_const;
50003
50004 enum rt_eeprom_type {
50005 EEPROM_93C46,
50006 diff --git a/drivers/staging/rtl8188eu/include/rtw_io.h b/drivers/staging/rtl8188eu/include/rtw_io.h
50007 index e8790f8..b4a5980 100644
50008 --- a/drivers/staging/rtl8188eu/include/rtw_io.h
50009 +++ b/drivers/staging/rtl8188eu/include/rtw_io.h
50010 @@ -124,7 +124,7 @@ struct _io_ops {
50011 u32 (*_write_scsi)(struct intf_hdl *pintfhdl, u32 cnt, u8 *pmem);
50012 void (*_read_port_cancel)(struct intf_hdl *pintfhdl);
50013 void (*_write_port_cancel)(struct intf_hdl *pintfhdl);
50014 -};
50015 +} __no_const;
50016
50017 struct io_req {
50018 struct list_head list;
50019 diff --git a/drivers/staging/rtl8712/rtl871x_io.h b/drivers/staging/rtl8712/rtl871x_io.h
50020 index dc23395..cf7e9b1 100644
50021 --- a/drivers/staging/rtl8712/rtl871x_io.h
50022 +++ b/drivers/staging/rtl8712/rtl871x_io.h
50023 @@ -108,7 +108,7 @@ struct _io_ops {
50024 u8 *pmem);
50025 u32 (*_write_port)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt,
50026 u8 *pmem);
50027 -};
50028 +} __no_const;
50029
50030 struct io_req {
50031 struct list_head list;
50032 diff --git a/drivers/staging/rtl8723au/include/hal_intf.h b/drivers/staging/rtl8723au/include/hal_intf.h
50033 index d183f4b..3f4903d 100644
50034 --- a/drivers/staging/rtl8723au/include/hal_intf.h
50035 +++ b/drivers/staging/rtl8723au/include/hal_intf.h
50036 @@ -251,7 +251,7 @@ struct hal_ops {
50037 void (*hal_reset_security_engine)(struct rtw_adapter *adapter);
50038 s32 (*c2h_handler)(struct rtw_adapter *padapter, struct c2h_evt_hdr *c2h_evt);
50039 c2h_id_filter c2h_id_filter_ccx;
50040 -};
50041 +} __no_const;
50042
50043 enum rt_eeprom_type {
50044 EEPROM_93C46,
50045 diff --git a/drivers/staging/rtl8723au/include/rtw_io.h b/drivers/staging/rtl8723au/include/rtw_io.h
50046 index 8d39d800..3f21c0c 100644
50047 --- a/drivers/staging/rtl8723au/include/rtw_io.h
50048 +++ b/drivers/staging/rtl8723au/include/rtw_io.h
50049 @@ -130,7 +130,7 @@ struct _io_ops
50050 void (*_read_port_cancel)(struct intf_hdl *pintfhdl);
50051 void (*_write_port_cancel)(struct intf_hdl *pintfhdl);
50052
50053 -};
50054 +} __no_const;
50055
50056 struct io_req {
50057 struct list_head list;
50058 diff --git a/drivers/staging/sbe-2t3e3/netdev.c b/drivers/staging/sbe-2t3e3/netdev.c
50059 index fe6c951..72935ba 100644
50060 --- a/drivers/staging/sbe-2t3e3/netdev.c
50061 +++ b/drivers/staging/sbe-2t3e3/netdev.c
50062 @@ -51,7 +51,7 @@ static int t3e3_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
50063 t3e3_if_config(sc, cmd_2t3e3, (char *)&param, &resp, &rlen);
50064
50065 if (rlen)
50066 - if (copy_to_user(data, &resp, rlen))
50067 + if (rlen > sizeof resp || copy_to_user(data, &resp, rlen))
50068 return -EFAULT;
50069
50070 return 0;
50071 diff --git a/drivers/staging/usbip/vhci.h b/drivers/staging/usbip/vhci.h
50072 index a863a98..d272795 100644
50073 --- a/drivers/staging/usbip/vhci.h
50074 +++ b/drivers/staging/usbip/vhci.h
50075 @@ -83,7 +83,7 @@ struct vhci_hcd {
50076 unsigned resuming:1;
50077 unsigned long re_timeout;
50078
50079 - atomic_t seqnum;
50080 + atomic_unchecked_t seqnum;
50081
50082 /*
50083 * NOTE:
50084 diff --git a/drivers/staging/usbip/vhci_hcd.c b/drivers/staging/usbip/vhci_hcd.c
50085 index 70e1755..de41855 100644
50086 --- a/drivers/staging/usbip/vhci_hcd.c
50087 +++ b/drivers/staging/usbip/vhci_hcd.c
50088 @@ -439,7 +439,7 @@ static void vhci_tx_urb(struct urb *urb)
50089
50090 spin_lock(&vdev->priv_lock);
50091
50092 - priv->seqnum = atomic_inc_return(&the_controller->seqnum);
50093 + priv->seqnum = atomic_inc_return_unchecked(&the_controller->seqnum);
50094 if (priv->seqnum == 0xffff)
50095 dev_info(&urb->dev->dev, "seqnum max\n");
50096
50097 @@ -685,7 +685,7 @@ static int vhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)
50098 return -ENOMEM;
50099 }
50100
50101 - unlink->seqnum = atomic_inc_return(&the_controller->seqnum);
50102 + unlink->seqnum = atomic_inc_return_unchecked(&the_controller->seqnum);
50103 if (unlink->seqnum == 0xffff)
50104 pr_info("seqnum max\n");
50105
50106 @@ -889,7 +889,7 @@ static int vhci_start(struct usb_hcd *hcd)
50107 vdev->rhport = rhport;
50108 }
50109
50110 - atomic_set(&vhci->seqnum, 0);
50111 + atomic_set_unchecked(&vhci->seqnum, 0);
50112 spin_lock_init(&vhci->lock);
50113
50114 hcd->power_budget = 0; /* no limit */
50115 diff --git a/drivers/staging/usbip/vhci_rx.c b/drivers/staging/usbip/vhci_rx.c
50116 index d07fcb5..358e1e1 100644
50117 --- a/drivers/staging/usbip/vhci_rx.c
50118 +++ b/drivers/staging/usbip/vhci_rx.c
50119 @@ -80,7 +80,7 @@ static void vhci_recv_ret_submit(struct vhci_device *vdev,
50120 if (!urb) {
50121 pr_err("cannot find a urb of seqnum %u\n", pdu->base.seqnum);
50122 pr_info("max seqnum %d\n",
50123 - atomic_read(&the_controller->seqnum));
50124 + atomic_read_unchecked(&the_controller->seqnum));
50125 usbip_event_add(ud, VDEV_EVENT_ERROR_TCP);
50126 return;
50127 }
50128 diff --git a/drivers/staging/vt6655/hostap.c b/drivers/staging/vt6655/hostap.c
50129 index 6eecd53..29317c6 100644
50130 --- a/drivers/staging/vt6655/hostap.c
50131 +++ b/drivers/staging/vt6655/hostap.c
50132 @@ -69,14 +69,13 @@ static int msglevel = MSG_LEVEL_INFO;
50133 *
50134 */
50135
50136 +static net_device_ops_no_const apdev_netdev_ops;
50137 +
50138 static int hostap_enable_hostapd(PSDevice pDevice, int rtnl_locked)
50139 {
50140 PSDevice apdev_priv;
50141 struct net_device *dev = pDevice->dev;
50142 int ret;
50143 - const struct net_device_ops apdev_netdev_ops = {
50144 - .ndo_start_xmit = pDevice->tx_80211,
50145 - };
50146
50147 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%s: Enabling hostapd mode\n", dev->name);
50148
50149 @@ -88,6 +87,8 @@ static int hostap_enable_hostapd(PSDevice pDevice, int rtnl_locked)
50150 *apdev_priv = *pDevice;
50151 eth_hw_addr_inherit(pDevice->apdev, dev);
50152
50153 + /* only half broken now */
50154 + apdev_netdev_ops.ndo_start_xmit = pDevice->tx_80211;
50155 pDevice->apdev->netdev_ops = &apdev_netdev_ops;
50156
50157 pDevice->apdev->type = ARPHRD_IEEE80211;
50158 diff --git a/drivers/staging/vt6656/hostap.c b/drivers/staging/vt6656/hostap.c
50159 index 67ba48b..24e602f 100644
50160 --- a/drivers/staging/vt6656/hostap.c
50161 +++ b/drivers/staging/vt6656/hostap.c
50162 @@ -60,14 +60,13 @@ static int msglevel =MSG_LEVEL_INFO;
50163 *
50164 */
50165
50166 +static net_device_ops_no_const apdev_netdev_ops;
50167 +
50168 static int hostap_enable_hostapd(struct vnt_private *pDevice, int rtnl_locked)
50169 {
50170 struct vnt_private *apdev_priv;
50171 struct net_device *dev = pDevice->dev;
50172 int ret;
50173 - const struct net_device_ops apdev_netdev_ops = {
50174 - .ndo_start_xmit = pDevice->tx_80211,
50175 - };
50176
50177 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%s: Enabling hostapd mode\n", dev->name);
50178
50179 @@ -79,6 +78,8 @@ static int hostap_enable_hostapd(struct vnt_private *pDevice, int rtnl_locked)
50180 *apdev_priv = *pDevice;
50181 memcpy(pDevice->apdev->dev_addr, dev->dev_addr, ETH_ALEN);
50182
50183 + /* only half broken now */
50184 + apdev_netdev_ops.ndo_start_xmit = pDevice->tx_80211;
50185 pDevice->apdev->netdev_ops = &apdev_netdev_ops;
50186
50187 pDevice->apdev->type = ARPHRD_IEEE80211;
50188 diff --git a/drivers/target/sbp/sbp_target.c b/drivers/target/sbp/sbp_target.c
50189 index e7e9372..161f530 100644
50190 --- a/drivers/target/sbp/sbp_target.c
50191 +++ b/drivers/target/sbp/sbp_target.c
50192 @@ -62,7 +62,7 @@ static const u32 sbp_unit_directory_template[] = {
50193
50194 #define SESSION_MAINTENANCE_INTERVAL HZ
50195
50196 -static atomic_t login_id = ATOMIC_INIT(0);
50197 +static atomic_unchecked_t login_id = ATOMIC_INIT(0);
50198
50199 static void session_maintenance_work(struct work_struct *);
50200 static int sbp_run_transaction(struct fw_card *, int, int, int, int,
50201 @@ -444,7 +444,7 @@ static void sbp_management_request_login(
50202 login->lun = se_lun;
50203 login->status_fifo_addr = sbp2_pointer_to_addr(&req->orb.status_fifo);
50204 login->exclusive = LOGIN_ORB_EXCLUSIVE(be32_to_cpu(req->orb.misc));
50205 - login->login_id = atomic_inc_return(&login_id);
50206 + login->login_id = atomic_inc_return_unchecked(&login_id);
50207
50208 login->tgt_agt = sbp_target_agent_register(login);
50209 if (IS_ERR(login->tgt_agt)) {
50210 diff --git a/drivers/target/target_core_device.c b/drivers/target/target_core_device.c
50211 index 26416c1..e796a3d 100644
50212 --- a/drivers/target/target_core_device.c
50213 +++ b/drivers/target/target_core_device.c
50214 @@ -1524,7 +1524,7 @@ struct se_device *target_alloc_device(struct se_hba *hba, const char *name)
50215 spin_lock_init(&dev->se_tmr_lock);
50216 spin_lock_init(&dev->qf_cmd_lock);
50217 sema_init(&dev->caw_sem, 1);
50218 - atomic_set(&dev->dev_ordered_id, 0);
50219 + atomic_set_unchecked(&dev->dev_ordered_id, 0);
50220 INIT_LIST_HEAD(&dev->t10_wwn.t10_vpd_list);
50221 spin_lock_init(&dev->t10_wwn.t10_vpd_lock);
50222 INIT_LIST_HEAD(&dev->t10_pr.registration_list);
50223 diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c
50224 index 789aa9e..084b425 100644
50225 --- a/drivers/target/target_core_transport.c
50226 +++ b/drivers/target/target_core_transport.c
50227 @@ -1148,7 +1148,7 @@ transport_check_alloc_task_attr(struct se_cmd *cmd)
50228 * Used to determine when ORDERED commands should go from
50229 * Dormant to Active status.
50230 */
50231 - cmd->se_ordered_id = atomic_inc_return(&dev->dev_ordered_id);
50232 + cmd->se_ordered_id = atomic_inc_return_unchecked(&dev->dev_ordered_id);
50233 smp_mb__after_atomic_inc();
50234 pr_debug("Allocated se_ordered_id: %u for Task Attr: 0x%02x on %s\n",
50235 cmd->se_ordered_id, cmd->sam_task_attr,
50236 diff --git a/drivers/thermal/of-thermal.c b/drivers/thermal/of-thermal.c
50237 index 04b1be7..5eff86d 100644
50238 --- a/drivers/thermal/of-thermal.c
50239 +++ b/drivers/thermal/of-thermal.c
50240 @@ -30,6 +30,7 @@
50241 #include <linux/err.h>
50242 #include <linux/export.h>
50243 #include <linux/string.h>
50244 +#include <linux/mm.h>
50245
50246 #include "thermal_core.h"
50247
50248 @@ -341,8 +342,10 @@ thermal_zone_of_add_sensor(struct device_node *zone,
50249 tz->get_trend = get_trend;
50250 tz->sensor_data = data;
50251
50252 - tzd->ops->get_temp = of_thermal_get_temp;
50253 - tzd->ops->get_trend = of_thermal_get_trend;
50254 + pax_open_kernel();
50255 + *(void **)&tzd->ops->get_temp = of_thermal_get_temp;
50256 + *(void **)&tzd->ops->get_trend = of_thermal_get_trend;
50257 + pax_close_kernel();
50258 mutex_unlock(&tzd->lock);
50259
50260 return tzd;
50261 @@ -461,8 +464,10 @@ void thermal_zone_of_sensor_unregister(struct device *dev,
50262 return;
50263
50264 mutex_lock(&tzd->lock);
50265 - tzd->ops->get_temp = NULL;
50266 - tzd->ops->get_trend = NULL;
50267 + pax_open_kernel();
50268 + *(void **)&tzd->ops->get_temp = NULL;
50269 + *(void **)&tzd->ops->get_trend = NULL;
50270 + pax_close_kernel();
50271
50272 tz->get_temp = NULL;
50273 tz->get_trend = NULL;
50274 diff --git a/drivers/tty/cyclades.c b/drivers/tty/cyclades.c
50275 index a57bb5a..1f727d33 100644
50276 --- a/drivers/tty/cyclades.c
50277 +++ b/drivers/tty/cyclades.c
50278 @@ -1570,10 +1570,10 @@ static int cy_open(struct tty_struct *tty, struct file *filp)
50279 printk(KERN_DEBUG "cyc:cy_open ttyC%d, count = %d\n", info->line,
50280 info->port.count);
50281 #endif
50282 - info->port.count++;
50283 + atomic_inc(&info->port.count);
50284 #ifdef CY_DEBUG_COUNT
50285 printk(KERN_DEBUG "cyc:cy_open (%d): incrementing count to %d\n",
50286 - current->pid, info->port.count);
50287 + current->pid, atomic_read(&info->port.count));
50288 #endif
50289
50290 /*
50291 @@ -3974,7 +3974,7 @@ static int cyclades_proc_show(struct seq_file *m, void *v)
50292 for (j = 0; j < cy_card[i].nports; j++) {
50293 info = &cy_card[i].ports[j];
50294
50295 - if (info->port.count) {
50296 + if (atomic_read(&info->port.count)) {
50297 /* XXX is the ldisc num worth this? */
50298 struct tty_struct *tty;
50299 struct tty_ldisc *ld;
50300 diff --git a/drivers/tty/hvc/hvc_console.c b/drivers/tty/hvc/hvc_console.c
50301 index 0ff7fda..dbc7d52 100644
50302 --- a/drivers/tty/hvc/hvc_console.c
50303 +++ b/drivers/tty/hvc/hvc_console.c
50304 @@ -342,7 +342,7 @@ static int hvc_open(struct tty_struct *tty, struct file * filp)
50305
50306 spin_lock_irqsave(&hp->port.lock, flags);
50307 /* Check and then increment for fast path open. */
50308 - if (hp->port.count++ > 0) {
50309 + if (atomic_inc_return(&hp->port.count) > 1) {
50310 spin_unlock_irqrestore(&hp->port.lock, flags);
50311 hvc_kick();
50312 return 0;
50313 @@ -397,7 +397,7 @@ static void hvc_close(struct tty_struct *tty, struct file * filp)
50314
50315 spin_lock_irqsave(&hp->port.lock, flags);
50316
50317 - if (--hp->port.count == 0) {
50318 + if (atomic_dec_return(&hp->port.count) == 0) {
50319 spin_unlock_irqrestore(&hp->port.lock, flags);
50320 /* We are done with the tty pointer now. */
50321 tty_port_tty_set(&hp->port, NULL);
50322 @@ -419,9 +419,9 @@ static void hvc_close(struct tty_struct *tty, struct file * filp)
50323 */
50324 tty_wait_until_sent_from_close(tty, HVC_CLOSE_WAIT);
50325 } else {
50326 - if (hp->port.count < 0)
50327 + if (atomic_read(&hp->port.count) < 0)
50328 printk(KERN_ERR "hvc_close %X: oops, count is %d\n",
50329 - hp->vtermno, hp->port.count);
50330 + hp->vtermno, atomic_read(&hp->port.count));
50331 spin_unlock_irqrestore(&hp->port.lock, flags);
50332 }
50333 }
50334 @@ -451,12 +451,12 @@ static void hvc_hangup(struct tty_struct *tty)
50335 * open->hangup case this can be called after the final close so prevent
50336 * that from happening for now.
50337 */
50338 - if (hp->port.count <= 0) {
50339 + if (atomic_read(&hp->port.count) <= 0) {
50340 spin_unlock_irqrestore(&hp->port.lock, flags);
50341 return;
50342 }
50343
50344 - hp->port.count = 0;
50345 + atomic_set(&hp->port.count, 0);
50346 spin_unlock_irqrestore(&hp->port.lock, flags);
50347 tty_port_tty_set(&hp->port, NULL);
50348
50349 @@ -504,7 +504,7 @@ static int hvc_write(struct tty_struct *tty, const unsigned char *buf, int count
50350 return -EPIPE;
50351
50352 /* FIXME what's this (unprotected) check for? */
50353 - if (hp->port.count <= 0)
50354 + if (atomic_read(&hp->port.count) <= 0)
50355 return -EIO;
50356
50357 spin_lock_irqsave(&hp->lock, flags);
50358 diff --git a/drivers/tty/hvc/hvcs.c b/drivers/tty/hvc/hvcs.c
50359 index 81e939e..95ead10 100644
50360 --- a/drivers/tty/hvc/hvcs.c
50361 +++ b/drivers/tty/hvc/hvcs.c
50362 @@ -83,6 +83,7 @@
50363 #include <asm/hvcserver.h>
50364 #include <asm/uaccess.h>
50365 #include <asm/vio.h>
50366 +#include <asm/local.h>
50367
50368 /*
50369 * 1.3.0 -> 1.3.1 In hvcs_open memset(..,0x00,..) instead of memset(..,0x3F,00).
50370 @@ -416,7 +417,7 @@ static ssize_t hvcs_vterm_state_store(struct device *dev, struct device_attribut
50371
50372 spin_lock_irqsave(&hvcsd->lock, flags);
50373
50374 - if (hvcsd->port.count > 0) {
50375 + if (atomic_read(&hvcsd->port.count) > 0) {
50376 spin_unlock_irqrestore(&hvcsd->lock, flags);
50377 printk(KERN_INFO "HVCS: vterm state unchanged. "
50378 "The hvcs device node is still in use.\n");
50379 @@ -1127,7 +1128,7 @@ static int hvcs_install(struct tty_driver *driver, struct tty_struct *tty)
50380 }
50381 }
50382
50383 - hvcsd->port.count = 0;
50384 + atomic_set(&hvcsd->port.count, 0);
50385 hvcsd->port.tty = tty;
50386 tty->driver_data = hvcsd;
50387
50388 @@ -1180,7 +1181,7 @@ static int hvcs_open(struct tty_struct *tty, struct file *filp)
50389 unsigned long flags;
50390
50391 spin_lock_irqsave(&hvcsd->lock, flags);
50392 - hvcsd->port.count++;
50393 + atomic_inc(&hvcsd->port.count);
50394 hvcsd->todo_mask |= HVCS_SCHED_READ;
50395 spin_unlock_irqrestore(&hvcsd->lock, flags);
50396
50397 @@ -1216,7 +1217,7 @@ static void hvcs_close(struct tty_struct *tty, struct file *filp)
50398 hvcsd = tty->driver_data;
50399
50400 spin_lock_irqsave(&hvcsd->lock, flags);
50401 - if (--hvcsd->port.count == 0) {
50402 + if (atomic_dec_and_test(&hvcsd->port.count)) {
50403
50404 vio_disable_interrupts(hvcsd->vdev);
50405
50406 @@ -1241,10 +1242,10 @@ static void hvcs_close(struct tty_struct *tty, struct file *filp)
50407
50408 free_irq(irq, hvcsd);
50409 return;
50410 - } else if (hvcsd->port.count < 0) {
50411 + } else if (atomic_read(&hvcsd->port.count) < 0) {
50412 printk(KERN_ERR "HVCS: vty-server@%X open_count: %d"
50413 " is missmanaged.\n",
50414 - hvcsd->vdev->unit_address, hvcsd->port.count);
50415 + hvcsd->vdev->unit_address, atomic_read(&hvcsd->port.count));
50416 }
50417
50418 spin_unlock_irqrestore(&hvcsd->lock, flags);
50419 @@ -1266,7 +1267,7 @@ static void hvcs_hangup(struct tty_struct * tty)
50420
50421 spin_lock_irqsave(&hvcsd->lock, flags);
50422 /* Preserve this so that we know how many kref refs to put */
50423 - temp_open_count = hvcsd->port.count;
50424 + temp_open_count = atomic_read(&hvcsd->port.count);
50425
50426 /*
50427 * Don't kref put inside the spinlock because the destruction
50428 @@ -1281,7 +1282,7 @@ static void hvcs_hangup(struct tty_struct * tty)
50429 tty->driver_data = NULL;
50430 hvcsd->port.tty = NULL;
50431
50432 - hvcsd->port.count = 0;
50433 + atomic_set(&hvcsd->port.count, 0);
50434
50435 /* This will drop any buffered data on the floor which is OK in a hangup
50436 * scenario. */
50437 @@ -1352,7 +1353,7 @@ static int hvcs_write(struct tty_struct *tty,
50438 * the middle of a write operation? This is a crummy place to do this
50439 * but we want to keep it all in the spinlock.
50440 */
50441 - if (hvcsd->port.count <= 0) {
50442 + if (atomic_read(&hvcsd->port.count) <= 0) {
50443 spin_unlock_irqrestore(&hvcsd->lock, flags);
50444 return -ENODEV;
50445 }
50446 @@ -1426,7 +1427,7 @@ static int hvcs_write_room(struct tty_struct *tty)
50447 {
50448 struct hvcs_struct *hvcsd = tty->driver_data;
50449
50450 - if (!hvcsd || hvcsd->port.count <= 0)
50451 + if (!hvcsd || atomic_read(&hvcsd->port.count) <= 0)
50452 return 0;
50453
50454 return HVCS_BUFF_LEN - hvcsd->chars_in_buffer;
50455 diff --git a/drivers/tty/hvc/hvsi.c b/drivers/tty/hvc/hvsi.c
50456 index 4190199..06d5bfa 100644
50457 --- a/drivers/tty/hvc/hvsi.c
50458 +++ b/drivers/tty/hvc/hvsi.c
50459 @@ -85,7 +85,7 @@ struct hvsi_struct {
50460 int n_outbuf;
50461 uint32_t vtermno;
50462 uint32_t virq;
50463 - atomic_t seqno; /* HVSI packet sequence number */
50464 + atomic_unchecked_t seqno; /* HVSI packet sequence number */
50465 uint16_t mctrl;
50466 uint8_t state; /* HVSI protocol state */
50467 uint8_t flags;
50468 @@ -295,7 +295,7 @@ static int hvsi_version_respond(struct hvsi_struct *hp, uint16_t query_seqno)
50469
50470 packet.hdr.type = VS_QUERY_RESPONSE_PACKET_HEADER;
50471 packet.hdr.len = sizeof(struct hvsi_query_response);
50472 - packet.hdr.seqno = atomic_inc_return(&hp->seqno);
50473 + packet.hdr.seqno = atomic_inc_return_unchecked(&hp->seqno);
50474 packet.verb = VSV_SEND_VERSION_NUMBER;
50475 packet.u.version = HVSI_VERSION;
50476 packet.query_seqno = query_seqno+1;
50477 @@ -555,7 +555,7 @@ static int hvsi_query(struct hvsi_struct *hp, uint16_t verb)
50478
50479 packet.hdr.type = VS_QUERY_PACKET_HEADER;
50480 packet.hdr.len = sizeof(struct hvsi_query);
50481 - packet.hdr.seqno = atomic_inc_return(&hp->seqno);
50482 + packet.hdr.seqno = atomic_inc_return_unchecked(&hp->seqno);
50483 packet.verb = verb;
50484
50485 pr_debug("%s: sending %i bytes\n", __func__, packet.hdr.len);
50486 @@ -597,7 +597,7 @@ static int hvsi_set_mctrl(struct hvsi_struct *hp, uint16_t mctrl)
50487 int wrote;
50488
50489 packet.hdr.type = VS_CONTROL_PACKET_HEADER,
50490 - packet.hdr.seqno = atomic_inc_return(&hp->seqno);
50491 + packet.hdr.seqno = atomic_inc_return_unchecked(&hp->seqno);
50492 packet.hdr.len = sizeof(struct hvsi_control);
50493 packet.verb = VSV_SET_MODEM_CTL;
50494 packet.mask = HVSI_TSDTR;
50495 @@ -680,7 +680,7 @@ static int hvsi_put_chars(struct hvsi_struct *hp, const char *buf, int count)
50496 BUG_ON(count > HVSI_MAX_OUTGOING_DATA);
50497
50498 packet.hdr.type = VS_DATA_PACKET_HEADER;
50499 - packet.hdr.seqno = atomic_inc_return(&hp->seqno);
50500 + packet.hdr.seqno = atomic_inc_return_unchecked(&hp->seqno);
50501 packet.hdr.len = count + sizeof(struct hvsi_header);
50502 memcpy(&packet.data, buf, count);
50503
50504 @@ -697,7 +697,7 @@ static void hvsi_close_protocol(struct hvsi_struct *hp)
50505 struct hvsi_control packet __ALIGNED__;
50506
50507 packet.hdr.type = VS_CONTROL_PACKET_HEADER;
50508 - packet.hdr.seqno = atomic_inc_return(&hp->seqno);
50509 + packet.hdr.seqno = atomic_inc_return_unchecked(&hp->seqno);
50510 packet.hdr.len = 6;
50511 packet.verb = VSV_CLOSE_PROTOCOL;
50512
50513 @@ -725,7 +725,7 @@ static int hvsi_open(struct tty_struct *tty, struct file *filp)
50514
50515 tty_port_tty_set(&hp->port, tty);
50516 spin_lock_irqsave(&hp->lock, flags);
50517 - hp->port.count++;
50518 + atomic_inc(&hp->port.count);
50519 atomic_set(&hp->seqno, 0);
50520 h_vio_signal(hp->vtermno, VIO_IRQ_ENABLE);
50521 spin_unlock_irqrestore(&hp->lock, flags);
50522 @@ -782,7 +782,7 @@ static void hvsi_close(struct tty_struct *tty, struct file *filp)
50523
50524 spin_lock_irqsave(&hp->lock, flags);
50525
50526 - if (--hp->port.count == 0) {
50527 + if (atomic_dec_return(&hp->port.count) == 0) {
50528 tty_port_tty_set(&hp->port, NULL);
50529 hp->inbuf_end = hp->inbuf; /* discard remaining partial packets */
50530
50531 @@ -815,9 +815,9 @@ static void hvsi_close(struct tty_struct *tty, struct file *filp)
50532
50533 spin_lock_irqsave(&hp->lock, flags);
50534 }
50535 - } else if (hp->port.count < 0)
50536 + } else if (atomic_read(&hp->port.count) < 0)
50537 printk(KERN_ERR "hvsi_close %lu: oops, count is %d\n",
50538 - hp - hvsi_ports, hp->port.count);
50539 + hp - hvsi_ports, atomic_read(&hp->port.count));
50540
50541 spin_unlock_irqrestore(&hp->lock, flags);
50542 }
50543 @@ -832,7 +832,7 @@ static void hvsi_hangup(struct tty_struct *tty)
50544 tty_port_tty_set(&hp->port, NULL);
50545
50546 spin_lock_irqsave(&hp->lock, flags);
50547 - hp->port.count = 0;
50548 + atomic_set(&hp->port.count, 0);
50549 hp->n_outbuf = 0;
50550 spin_unlock_irqrestore(&hp->lock, flags);
50551 }
50552 diff --git a/drivers/tty/hvc/hvsi_lib.c b/drivers/tty/hvc/hvsi_lib.c
50553 index 7ae6c29..05c6dba 100644
50554 --- a/drivers/tty/hvc/hvsi_lib.c
50555 +++ b/drivers/tty/hvc/hvsi_lib.c
50556 @@ -8,7 +8,7 @@
50557
50558 static int hvsi_send_packet(struct hvsi_priv *pv, struct hvsi_header *packet)
50559 {
50560 - packet->seqno = cpu_to_be16(atomic_inc_return(&pv->seqno));
50561 + packet->seqno = cpu_to_be16(atomic_inc_return_unchecked(&pv->seqno));
50562
50563 /* Assumes that always succeeds, works in practice */
50564 return pv->put_chars(pv->termno, (char *)packet, packet->len);
50565 @@ -20,7 +20,7 @@ static void hvsi_start_handshake(struct hvsi_priv *pv)
50566
50567 /* Reset state */
50568 pv->established = 0;
50569 - atomic_set(&pv->seqno, 0);
50570 + atomic_set_unchecked(&pv->seqno, 0);
50571
50572 pr_devel("HVSI@%x: Handshaking started\n", pv->termno);
50573
50574 diff --git a/drivers/tty/ipwireless/tty.c b/drivers/tty/ipwireless/tty.c
50575 index 17ee3bf..8d2520d 100644
50576 --- a/drivers/tty/ipwireless/tty.c
50577 +++ b/drivers/tty/ipwireless/tty.c
50578 @@ -28,6 +28,7 @@
50579 #include <linux/tty_driver.h>
50580 #include <linux/tty_flip.h>
50581 #include <linux/uaccess.h>
50582 +#include <asm/local.h>
50583
50584 #include "tty.h"
50585 #include "network.h"
50586 @@ -98,10 +99,10 @@ static int ipw_open(struct tty_struct *linux_tty, struct file *filp)
50587 mutex_unlock(&tty->ipw_tty_mutex);
50588 return -ENODEV;
50589 }
50590 - if (tty->port.count == 0)
50591 + if (atomic_read(&tty->port.count) == 0)
50592 tty->tx_bytes_queued = 0;
50593
50594 - tty->port.count++;
50595 + atomic_inc(&tty->port.count);
50596
50597 tty->port.tty = linux_tty;
50598 linux_tty->driver_data = tty;
50599 @@ -117,9 +118,7 @@ static int ipw_open(struct tty_struct *linux_tty, struct file *filp)
50600
50601 static void do_ipw_close(struct ipw_tty *tty)
50602 {
50603 - tty->port.count--;
50604 -
50605 - if (tty->port.count == 0) {
50606 + if (atomic_dec_return(&tty->port.count) == 0) {
50607 struct tty_struct *linux_tty = tty->port.tty;
50608
50609 if (linux_tty != NULL) {
50610 @@ -140,7 +139,7 @@ static void ipw_hangup(struct tty_struct *linux_tty)
50611 return;
50612
50613 mutex_lock(&tty->ipw_tty_mutex);
50614 - if (tty->port.count == 0) {
50615 + if (atomic_read(&tty->port.count) == 0) {
50616 mutex_unlock(&tty->ipw_tty_mutex);
50617 return;
50618 }
50619 @@ -163,7 +162,7 @@ void ipwireless_tty_received(struct ipw_tty *tty, unsigned char *data,
50620
50621 mutex_lock(&tty->ipw_tty_mutex);
50622
50623 - if (!tty->port.count) {
50624 + if (!atomic_read(&tty->port.count)) {
50625 mutex_unlock(&tty->ipw_tty_mutex);
50626 return;
50627 }
50628 @@ -202,7 +201,7 @@ static int ipw_write(struct tty_struct *linux_tty,
50629 return -ENODEV;
50630
50631 mutex_lock(&tty->ipw_tty_mutex);
50632 - if (!tty->port.count) {
50633 + if (!atomic_read(&tty->port.count)) {
50634 mutex_unlock(&tty->ipw_tty_mutex);
50635 return -EINVAL;
50636 }
50637 @@ -242,7 +241,7 @@ static int ipw_write_room(struct tty_struct *linux_tty)
50638 if (!tty)
50639 return -ENODEV;
50640
50641 - if (!tty->port.count)
50642 + if (!atomic_read(&tty->port.count))
50643 return -EINVAL;
50644
50645 room = IPWIRELESS_TX_QUEUE_SIZE - tty->tx_bytes_queued;
50646 @@ -284,7 +283,7 @@ static int ipw_chars_in_buffer(struct tty_struct *linux_tty)
50647 if (!tty)
50648 return 0;
50649
50650 - if (!tty->port.count)
50651 + if (!atomic_read(&tty->port.count))
50652 return 0;
50653
50654 return tty->tx_bytes_queued;
50655 @@ -365,7 +364,7 @@ static int ipw_tiocmget(struct tty_struct *linux_tty)
50656 if (!tty)
50657 return -ENODEV;
50658
50659 - if (!tty->port.count)
50660 + if (!atomic_read(&tty->port.count))
50661 return -EINVAL;
50662
50663 return get_control_lines(tty);
50664 @@ -381,7 +380,7 @@ ipw_tiocmset(struct tty_struct *linux_tty,
50665 if (!tty)
50666 return -ENODEV;
50667
50668 - if (!tty->port.count)
50669 + if (!atomic_read(&tty->port.count))
50670 return -EINVAL;
50671
50672 return set_control_lines(tty, set, clear);
50673 @@ -395,7 +394,7 @@ static int ipw_ioctl(struct tty_struct *linux_tty,
50674 if (!tty)
50675 return -ENODEV;
50676
50677 - if (!tty->port.count)
50678 + if (!atomic_read(&tty->port.count))
50679 return -EINVAL;
50680
50681 /* FIXME: Exactly how is the tty object locked here .. */
50682 @@ -551,7 +550,7 @@ void ipwireless_tty_free(struct ipw_tty *tty)
50683 * are gone */
50684 mutex_lock(&ttyj->ipw_tty_mutex);
50685 }
50686 - while (ttyj->port.count)
50687 + while (atomic_read(&ttyj->port.count))
50688 do_ipw_close(ttyj);
50689 ipwireless_disassociate_network_ttys(network,
50690 ttyj->channel_idx);
50691 diff --git a/drivers/tty/moxa.c b/drivers/tty/moxa.c
50692 index 1deaca4..c8582d4 100644
50693 --- a/drivers/tty/moxa.c
50694 +++ b/drivers/tty/moxa.c
50695 @@ -1189,7 +1189,7 @@ static int moxa_open(struct tty_struct *tty, struct file *filp)
50696 }
50697
50698 ch = &brd->ports[port % MAX_PORTS_PER_BOARD];
50699 - ch->port.count++;
50700 + atomic_inc(&ch->port.count);
50701 tty->driver_data = ch;
50702 tty_port_tty_set(&ch->port, tty);
50703 mutex_lock(&ch->port.mutex);
50704 diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c
50705 index 2ebe47b..3205833 100644
50706 --- a/drivers/tty/n_gsm.c
50707 +++ b/drivers/tty/n_gsm.c
50708 @@ -1644,7 +1644,7 @@ static struct gsm_dlci *gsm_dlci_alloc(struct gsm_mux *gsm, int addr)
50709 spin_lock_init(&dlci->lock);
50710 mutex_init(&dlci->mutex);
50711 dlci->fifo = &dlci->_fifo;
50712 - if (kfifo_alloc(&dlci->_fifo, 4096, GFP_KERNEL) < 0) {
50713 + if (kfifo_alloc(&dlci->_fifo, 4096, GFP_KERNEL)) {
50714 kfree(dlci);
50715 return NULL;
50716 }
50717 @@ -2954,7 +2954,7 @@ static int gsmtty_open(struct tty_struct *tty, struct file *filp)
50718 struct gsm_dlci *dlci = tty->driver_data;
50719 struct tty_port *port = &dlci->port;
50720
50721 - port->count++;
50722 + atomic_inc(&port->count);
50723 tty_port_tty_set(port, tty);
50724
50725 dlci->modem_rx = 0;
50726 diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c
50727 index fe9d129..477300f 100644
50728 --- a/drivers/tty/n_tty.c
50729 +++ b/drivers/tty/n_tty.c
50730 @@ -115,7 +115,7 @@ struct n_tty_data {
50731 int minimum_to_wake;
50732
50733 /* consumer-published */
50734 - size_t read_tail;
50735 + size_t read_tail __intentional_overflow(-1);
50736 size_t line_start;
50737
50738 /* protected by output lock */
50739 @@ -2516,6 +2516,7 @@ void n_tty_inherit_ops(struct tty_ldisc_ops *ops)
50740 {
50741 *ops = tty_ldisc_N_TTY;
50742 ops->owner = NULL;
50743 - ops->refcount = ops->flags = 0;
50744 + atomic_set(&ops->refcount, 0);
50745 + ops->flags = 0;
50746 }
50747 EXPORT_SYMBOL_GPL(n_tty_inherit_ops);
50748 diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c
50749 index 25c9bc7..24077b7 100644
50750 --- a/drivers/tty/pty.c
50751 +++ b/drivers/tty/pty.c
50752 @@ -790,8 +790,10 @@ static void __init unix98_pty_init(void)
50753 panic("Couldn't register Unix98 pts driver");
50754
50755 /* Now create the /dev/ptmx special device */
50756 + pax_open_kernel();
50757 tty_default_fops(&ptmx_fops);
50758 - ptmx_fops.open = ptmx_open;
50759 + *(void **)&ptmx_fops.open = ptmx_open;
50760 + pax_close_kernel();
50761
50762 cdev_init(&ptmx_cdev, &ptmx_fops);
50763 if (cdev_add(&ptmx_cdev, MKDEV(TTYAUX_MAJOR, 2), 1) ||
50764 diff --git a/drivers/tty/rocket.c b/drivers/tty/rocket.c
50765 index 383c4c7..d408e21 100644
50766 --- a/drivers/tty/rocket.c
50767 +++ b/drivers/tty/rocket.c
50768 @@ -914,7 +914,7 @@ static int rp_open(struct tty_struct *tty, struct file *filp)
50769 tty->driver_data = info;
50770 tty_port_tty_set(port, tty);
50771
50772 - if (port->count++ == 0) {
50773 + if (atomic_inc_return(&port->count) == 1) {
50774 atomic_inc(&rp_num_ports_open);
50775
50776 #ifdef ROCKET_DEBUG_OPEN
50777 @@ -923,7 +923,7 @@ static int rp_open(struct tty_struct *tty, struct file *filp)
50778 #endif
50779 }
50780 #ifdef ROCKET_DEBUG_OPEN
50781 - printk(KERN_INFO "rp_open ttyR%d, count=%d\n", info->line, info->port.count);
50782 + printk(KERN_INFO "rp_open ttyR%d, count=%d\n", info->line, atomic-read(&info->port.count));
50783 #endif
50784
50785 /*
50786 @@ -1515,7 +1515,7 @@ static void rp_hangup(struct tty_struct *tty)
50787 spin_unlock_irqrestore(&info->port.lock, flags);
50788 return;
50789 }
50790 - if (info->port.count)
50791 + if (atomic_read(&info->port.count))
50792 atomic_dec(&rp_num_ports_open);
50793 clear_bit((info->aiop * 8) + info->chan, (void *) &xmit_flags[info->board]);
50794 spin_unlock_irqrestore(&info->port.lock, flags);
50795 diff --git a/drivers/tty/serial/ioc4_serial.c b/drivers/tty/serial/ioc4_serial.c
50796 index 1274499..f541382 100644
50797 --- a/drivers/tty/serial/ioc4_serial.c
50798 +++ b/drivers/tty/serial/ioc4_serial.c
50799 @@ -437,7 +437,7 @@ struct ioc4_soft {
50800 } is_intr_info[MAX_IOC4_INTR_ENTS];
50801
50802 /* Number of entries active in the above array */
50803 - atomic_t is_num_intrs;
50804 + atomic_unchecked_t is_num_intrs;
50805 } is_intr_type[IOC4_NUM_INTR_TYPES];
50806
50807 /* is_ir_lock must be held while
50808 @@ -974,7 +974,7 @@ intr_connect(struct ioc4_soft *soft, int type,
50809 BUG_ON(!((type == IOC4_SIO_INTR_TYPE)
50810 || (type == IOC4_OTHER_INTR_TYPE)));
50811
50812 - i = atomic_inc_return(&soft-> is_intr_type[type].is_num_intrs) - 1;
50813 + i = atomic_inc_return_unchecked(&soft-> is_intr_type[type].is_num_intrs) - 1;
50814 BUG_ON(!(i < MAX_IOC4_INTR_ENTS || (printk("i %d\n", i), 0)));
50815
50816 /* Save off the lower level interrupt handler */
50817 @@ -1001,7 +1001,7 @@ static irqreturn_t ioc4_intr(int irq, void *arg)
50818
50819 soft = arg;
50820 for (intr_type = 0; intr_type < IOC4_NUM_INTR_TYPES; intr_type++) {
50821 - num_intrs = (int)atomic_read(
50822 + num_intrs = (int)atomic_read_unchecked(
50823 &soft->is_intr_type[intr_type].is_num_intrs);
50824
50825 this_mir = this_ir = pending_intrs(soft, intr_type);
50826 diff --git a/drivers/tty/serial/kgdboc.c b/drivers/tty/serial/kgdboc.c
50827 index a260cde..6b2b5ce 100644
50828 --- a/drivers/tty/serial/kgdboc.c
50829 +++ b/drivers/tty/serial/kgdboc.c
50830 @@ -24,8 +24,9 @@
50831 #define MAX_CONFIG_LEN 40
50832
50833 static struct kgdb_io kgdboc_io_ops;
50834 +static struct kgdb_io kgdboc_io_ops_console;
50835
50836 -/* -1 = init not run yet, 0 = unconfigured, 1 = configured. */
50837 +/* -1 = init not run yet, 0 = unconfigured, 1/2 = configured. */
50838 static int configured = -1;
50839
50840 static char config[MAX_CONFIG_LEN];
50841 @@ -151,6 +152,8 @@ static void cleanup_kgdboc(void)
50842 kgdboc_unregister_kbd();
50843 if (configured == 1)
50844 kgdb_unregister_io_module(&kgdboc_io_ops);
50845 + else if (configured == 2)
50846 + kgdb_unregister_io_module(&kgdboc_io_ops_console);
50847 }
50848
50849 static int configure_kgdboc(void)
50850 @@ -160,13 +163,13 @@ static int configure_kgdboc(void)
50851 int err;
50852 char *cptr = config;
50853 struct console *cons;
50854 + int is_console = 0;
50855
50856 err = kgdboc_option_setup(config);
50857 if (err || !strlen(config) || isspace(config[0]))
50858 goto noconfig;
50859
50860 err = -ENODEV;
50861 - kgdboc_io_ops.is_console = 0;
50862 kgdb_tty_driver = NULL;
50863
50864 kgdboc_use_kms = 0;
50865 @@ -187,7 +190,7 @@ static int configure_kgdboc(void)
50866 int idx;
50867 if (cons->device && cons->device(cons, &idx) == p &&
50868 idx == tty_line) {
50869 - kgdboc_io_ops.is_console = 1;
50870 + is_console = 1;
50871 break;
50872 }
50873 cons = cons->next;
50874 @@ -197,7 +200,13 @@ static int configure_kgdboc(void)
50875 kgdb_tty_line = tty_line;
50876
50877 do_register:
50878 - err = kgdb_register_io_module(&kgdboc_io_ops);
50879 + if (is_console) {
50880 + err = kgdb_register_io_module(&kgdboc_io_ops_console);
50881 + configured = 2;
50882 + } else {
50883 + err = kgdb_register_io_module(&kgdboc_io_ops);
50884 + configured = 1;
50885 + }
50886 if (err)
50887 goto noconfig;
50888
50889 @@ -205,8 +214,6 @@ do_register:
50890 if (err)
50891 goto nmi_con_failed;
50892
50893 - configured = 1;
50894 -
50895 return 0;
50896
50897 nmi_con_failed:
50898 @@ -223,7 +230,7 @@ noconfig:
50899 static int __init init_kgdboc(void)
50900 {
50901 /* Already configured? */
50902 - if (configured == 1)
50903 + if (configured >= 1)
50904 return 0;
50905
50906 return configure_kgdboc();
50907 @@ -272,7 +279,7 @@ static int param_set_kgdboc_var(const char *kmessage, struct kernel_param *kp)
50908 if (config[len - 1] == '\n')
50909 config[len - 1] = '\0';
50910
50911 - if (configured == 1)
50912 + if (configured >= 1)
50913 cleanup_kgdboc();
50914
50915 /* Go and configure with the new params. */
50916 @@ -312,6 +319,15 @@ static struct kgdb_io kgdboc_io_ops = {
50917 .post_exception = kgdboc_post_exp_handler,
50918 };
50919
50920 +static struct kgdb_io kgdboc_io_ops_console = {
50921 + .name = "kgdboc",
50922 + .read_char = kgdboc_get_char,
50923 + .write_char = kgdboc_put_char,
50924 + .pre_exception = kgdboc_pre_exp_handler,
50925 + .post_exception = kgdboc_post_exp_handler,
50926 + .is_console = 1
50927 +};
50928 +
50929 #ifdef CONFIG_KGDB_SERIAL_CONSOLE
50930 /* This is only available if kgdboc is a built in for early debugging */
50931 static int __init kgdboc_early_init(char *opt)
50932 diff --git a/drivers/tty/serial/msm_serial.c b/drivers/tty/serial/msm_serial.c
50933 index 053b98e..86742e5 100644
50934 --- a/drivers/tty/serial/msm_serial.c
50935 +++ b/drivers/tty/serial/msm_serial.c
50936 @@ -1026,7 +1026,7 @@ static struct uart_driver msm_uart_driver = {
50937 .cons = MSM_CONSOLE,
50938 };
50939
50940 -static atomic_t msm_uart_next_id = ATOMIC_INIT(0);
50941 +static atomic_unchecked_t msm_uart_next_id = ATOMIC_INIT(0);
50942
50943 static const struct of_device_id msm_uartdm_table[] = {
50944 { .compatible = "qcom,msm-uartdm-v1.1", .data = (void *)UARTDM_1P1 },
50945 @@ -1045,7 +1045,7 @@ static int __init msm_serial_probe(struct platform_device *pdev)
50946 int irq;
50947
50948 if (pdev->id == -1)
50949 - pdev->id = atomic_inc_return(&msm_uart_next_id) - 1;
50950 + pdev->id = atomic_inc_return_unchecked(&msm_uart_next_id) - 1;
50951
50952 if (unlikely(pdev->id < 0 || pdev->id >= UART_NR))
50953 return -ENXIO;
50954 diff --git a/drivers/tty/serial/samsung.c b/drivers/tty/serial/samsung.c
50955 index 1f5505e..a1a767d 100644
50956 --- a/drivers/tty/serial/samsung.c
50957 +++ b/drivers/tty/serial/samsung.c
50958 @@ -463,11 +463,16 @@ static void s3c24xx_serial_shutdown(struct uart_port *port)
50959 }
50960 }
50961
50962 +static int s3c64xx_serial_startup(struct uart_port *port);
50963 static int s3c24xx_serial_startup(struct uart_port *port)
50964 {
50965 struct s3c24xx_uart_port *ourport = to_ourport(port);
50966 int ret;
50967
50968 + /* Startup sequence is different for s3c64xx and higher SoC's */
50969 + if (s3c24xx_serial_has_interrupt_mask(port))
50970 + return s3c64xx_serial_startup(port);
50971 +
50972 dbg("s3c24xx_serial_startup: port=%p (%08lx,%p)\n",
50973 port->mapbase, port->membase);
50974
50975 @@ -1141,10 +1146,6 @@ static int s3c24xx_serial_init_port(struct s3c24xx_uart_port *ourport,
50976 /* setup info for port */
50977 port->dev = &platdev->dev;
50978
50979 - /* Startup sequence is different for s3c64xx and higher SoC's */
50980 - if (s3c24xx_serial_has_interrupt_mask(port))
50981 - s3c24xx_serial_ops.startup = s3c64xx_serial_startup;
50982 -
50983 port->uartclk = 1;
50984
50985 if (cfg->uart_flags & UPF_CONS_FLOW) {
50986 diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
50987 index b68550d..a62d7f8 100644
50988 --- a/drivers/tty/serial/serial_core.c
50989 +++ b/drivers/tty/serial/serial_core.c
50990 @@ -1329,7 +1329,7 @@ static void uart_close(struct tty_struct *tty, struct file *filp)
50991
50992 pr_debug("uart_close(%d) called\n", uport ? uport->line : -1);
50993
50994 - if (!port->count || tty_port_close_start(port, tty, filp) == 0)
50995 + if (!atomic_read(&port->count) || tty_port_close_start(port, tty, filp) == 0)
50996 return;
50997
50998 /*
50999 @@ -1456,7 +1456,7 @@ static void uart_hangup(struct tty_struct *tty)
51000 uart_flush_buffer(tty);
51001 uart_shutdown(tty, state);
51002 spin_lock_irqsave(&port->lock, flags);
51003 - port->count = 0;
51004 + atomic_set(&port->count, 0);
51005 clear_bit(ASYNCB_NORMAL_ACTIVE, &port->flags);
51006 spin_unlock_irqrestore(&port->lock, flags);
51007 tty_port_tty_set(port, NULL);
51008 @@ -1554,7 +1554,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp)
51009 goto end;
51010 }
51011
51012 - port->count++;
51013 + atomic_inc(&port->count);
51014 if (!state->uart_port || state->uart_port->flags & UPF_DEAD) {
51015 retval = -ENXIO;
51016 goto err_dec_count;
51017 @@ -1594,7 +1594,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp)
51018 end:
51019 return retval;
51020 err_dec_count:
51021 - port->count--;
51022 + atomic_inc(&port->count);
51023 mutex_unlock(&port->mutex);
51024 goto end;
51025 }
51026 diff --git a/drivers/tty/synclink.c b/drivers/tty/synclink.c
51027 index d48e040..0f52764 100644
51028 --- a/drivers/tty/synclink.c
51029 +++ b/drivers/tty/synclink.c
51030 @@ -3090,7 +3090,7 @@ static void mgsl_close(struct tty_struct *tty, struct file * filp)
51031
51032 if (debug_level >= DEBUG_LEVEL_INFO)
51033 printk("%s(%d):mgsl_close(%s) entry, count=%d\n",
51034 - __FILE__,__LINE__, info->device_name, info->port.count);
51035 + __FILE__,__LINE__, info->device_name, atomic_read(&info->port.count));
51036
51037 if (tty_port_close_start(&info->port, tty, filp) == 0)
51038 goto cleanup;
51039 @@ -3108,7 +3108,7 @@ static void mgsl_close(struct tty_struct *tty, struct file * filp)
51040 cleanup:
51041 if (debug_level >= DEBUG_LEVEL_INFO)
51042 printk("%s(%d):mgsl_close(%s) exit, count=%d\n", __FILE__,__LINE__,
51043 - tty->driver->name, info->port.count);
51044 + tty->driver->name, atomic_read(&info->port.count));
51045
51046 } /* end of mgsl_close() */
51047
51048 @@ -3207,8 +3207,8 @@ static void mgsl_hangup(struct tty_struct *tty)
51049
51050 mgsl_flush_buffer(tty);
51051 shutdown(info);
51052 -
51053 - info->port.count = 0;
51054 +
51055 + atomic_set(&info->port.count, 0);
51056 info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
51057 info->port.tty = NULL;
51058
51059 @@ -3297,12 +3297,12 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
51060
51061 if (debug_level >= DEBUG_LEVEL_INFO)
51062 printk("%s(%d):block_til_ready before block on %s count=%d\n",
51063 - __FILE__,__LINE__, tty->driver->name, port->count );
51064 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
51065
51066 spin_lock_irqsave(&info->irq_spinlock, flags);
51067 if (!tty_hung_up_p(filp)) {
51068 extra_count = true;
51069 - port->count--;
51070 + atomic_dec(&port->count);
51071 }
51072 spin_unlock_irqrestore(&info->irq_spinlock, flags);
51073 port->blocked_open++;
51074 @@ -3331,7 +3331,7 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
51075
51076 if (debug_level >= DEBUG_LEVEL_INFO)
51077 printk("%s(%d):block_til_ready blocking on %s count=%d\n",
51078 - __FILE__,__LINE__, tty->driver->name, port->count );
51079 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
51080
51081 tty_unlock(tty);
51082 schedule();
51083 @@ -3343,12 +3343,12 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
51084
51085 /* FIXME: Racy on hangup during close wait */
51086 if (extra_count)
51087 - port->count++;
51088 + atomic_inc(&port->count);
51089 port->blocked_open--;
51090
51091 if (debug_level >= DEBUG_LEVEL_INFO)
51092 printk("%s(%d):block_til_ready after blocking on %s count=%d\n",
51093 - __FILE__,__LINE__, tty->driver->name, port->count );
51094 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
51095
51096 if (!retval)
51097 port->flags |= ASYNC_NORMAL_ACTIVE;
51098 @@ -3400,7 +3400,7 @@ static int mgsl_open(struct tty_struct *tty, struct file * filp)
51099
51100 if (debug_level >= DEBUG_LEVEL_INFO)
51101 printk("%s(%d):mgsl_open(%s), old ref count = %d\n",
51102 - __FILE__,__LINE__,tty->driver->name, info->port.count);
51103 + __FILE__,__LINE__,tty->driver->name, atomic_read(&info->port.count));
51104
51105 /* If port is closing, signal caller to try again */
51106 if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){
51107 @@ -3419,10 +3419,10 @@ static int mgsl_open(struct tty_struct *tty, struct file * filp)
51108 spin_unlock_irqrestore(&info->netlock, flags);
51109 goto cleanup;
51110 }
51111 - info->port.count++;
51112 + atomic_inc(&info->port.count);
51113 spin_unlock_irqrestore(&info->netlock, flags);
51114
51115 - if (info->port.count == 1) {
51116 + if (atomic_read(&info->port.count) == 1) {
51117 /* 1st open on this device, init hardware */
51118 retval = startup(info);
51119 if (retval < 0)
51120 @@ -3446,8 +3446,8 @@ cleanup:
51121 if (retval) {
51122 if (tty->count == 1)
51123 info->port.tty = NULL; /* tty layer will release tty struct */
51124 - if(info->port.count)
51125 - info->port.count--;
51126 + if (atomic_read(&info->port.count))
51127 + atomic_dec(&info->port.count);
51128 }
51129
51130 return retval;
51131 @@ -7665,7 +7665,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
51132 unsigned short new_crctype;
51133
51134 /* return error if TTY interface open */
51135 - if (info->port.count)
51136 + if (atomic_read(&info->port.count))
51137 return -EBUSY;
51138
51139 switch (encoding)
51140 @@ -7760,7 +7760,7 @@ static int hdlcdev_open(struct net_device *dev)
51141
51142 /* arbitrate between network and tty opens */
51143 spin_lock_irqsave(&info->netlock, flags);
51144 - if (info->port.count != 0 || info->netcount != 0) {
51145 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
51146 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name);
51147 spin_unlock_irqrestore(&info->netlock, flags);
51148 return -EBUSY;
51149 @@ -7846,7 +7846,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
51150 printk("%s:hdlcdev_ioctl(%s)\n",__FILE__,dev->name);
51151
51152 /* return error if TTY interface open */
51153 - if (info->port.count)
51154 + if (atomic_read(&info->port.count))
51155 return -EBUSY;
51156
51157 if (cmd != SIOCWANDEV)
51158 diff --git a/drivers/tty/synclink_gt.c b/drivers/tty/synclink_gt.c
51159 index c359a91..959fc26 100644
51160 --- a/drivers/tty/synclink_gt.c
51161 +++ b/drivers/tty/synclink_gt.c
51162 @@ -670,7 +670,7 @@ static int open(struct tty_struct *tty, struct file *filp)
51163 tty->driver_data = info;
51164 info->port.tty = tty;
51165
51166 - DBGINFO(("%s open, old ref count = %d\n", info->device_name, info->port.count));
51167 + DBGINFO(("%s open, old ref count = %d\n", info->device_name, atomic_read(&info->port.count)));
51168
51169 /* If port is closing, signal caller to try again */
51170 if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){
51171 @@ -691,10 +691,10 @@ static int open(struct tty_struct *tty, struct file *filp)
51172 mutex_unlock(&info->port.mutex);
51173 goto cleanup;
51174 }
51175 - info->port.count++;
51176 + atomic_inc(&info->port.count);
51177 spin_unlock_irqrestore(&info->netlock, flags);
51178
51179 - if (info->port.count == 1) {
51180 + if (atomic_read(&info->port.count) == 1) {
51181 /* 1st open on this device, init hardware */
51182 retval = startup(info);
51183 if (retval < 0) {
51184 @@ -715,8 +715,8 @@ cleanup:
51185 if (retval) {
51186 if (tty->count == 1)
51187 info->port.tty = NULL; /* tty layer will release tty struct */
51188 - if(info->port.count)
51189 - info->port.count--;
51190 + if(atomic_read(&info->port.count))
51191 + atomic_dec(&info->port.count);
51192 }
51193
51194 DBGINFO(("%s open rc=%d\n", info->device_name, retval));
51195 @@ -729,7 +729,7 @@ static void close(struct tty_struct *tty, struct file *filp)
51196
51197 if (sanity_check(info, tty->name, "close"))
51198 return;
51199 - DBGINFO(("%s close entry, count=%d\n", info->device_name, info->port.count));
51200 + DBGINFO(("%s close entry, count=%d\n", info->device_name, atomic_read(&info->port.count)));
51201
51202 if (tty_port_close_start(&info->port, tty, filp) == 0)
51203 goto cleanup;
51204 @@ -746,7 +746,7 @@ static void close(struct tty_struct *tty, struct file *filp)
51205 tty_port_close_end(&info->port, tty);
51206 info->port.tty = NULL;
51207 cleanup:
51208 - DBGINFO(("%s close exit, count=%d\n", tty->driver->name, info->port.count));
51209 + DBGINFO(("%s close exit, count=%d\n", tty->driver->name, atomic_read(&info->port.count)));
51210 }
51211
51212 static void hangup(struct tty_struct *tty)
51213 @@ -764,7 +764,7 @@ static void hangup(struct tty_struct *tty)
51214 shutdown(info);
51215
51216 spin_lock_irqsave(&info->port.lock, flags);
51217 - info->port.count = 0;
51218 + atomic_set(&info->port.count, 0);
51219 info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
51220 info->port.tty = NULL;
51221 spin_unlock_irqrestore(&info->port.lock, flags);
51222 @@ -1449,7 +1449,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
51223 unsigned short new_crctype;
51224
51225 /* return error if TTY interface open */
51226 - if (info->port.count)
51227 + if (atomic_read(&info->port.count))
51228 return -EBUSY;
51229
51230 DBGINFO(("%s hdlcdev_attach\n", info->device_name));
51231 @@ -1544,7 +1544,7 @@ static int hdlcdev_open(struct net_device *dev)
51232
51233 /* arbitrate between network and tty opens */
51234 spin_lock_irqsave(&info->netlock, flags);
51235 - if (info->port.count != 0 || info->netcount != 0) {
51236 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
51237 DBGINFO(("%s hdlc_open busy\n", dev->name));
51238 spin_unlock_irqrestore(&info->netlock, flags);
51239 return -EBUSY;
51240 @@ -1629,7 +1629,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
51241 DBGINFO(("%s hdlcdev_ioctl\n", dev->name));
51242
51243 /* return error if TTY interface open */
51244 - if (info->port.count)
51245 + if (atomic_read(&info->port.count))
51246 return -EBUSY;
51247
51248 if (cmd != SIOCWANDEV)
51249 @@ -2413,7 +2413,7 @@ static irqreturn_t slgt_interrupt(int dummy, void *dev_id)
51250 if (port == NULL)
51251 continue;
51252 spin_lock(&port->lock);
51253 - if ((port->port.count || port->netcount) &&
51254 + if ((atomic_read(&port->port.count) || port->netcount) &&
51255 port->pending_bh && !port->bh_running &&
51256 !port->bh_requested) {
51257 DBGISR(("%s bh queued\n", port->device_name));
51258 @@ -3302,7 +3302,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
51259 spin_lock_irqsave(&info->lock, flags);
51260 if (!tty_hung_up_p(filp)) {
51261 extra_count = true;
51262 - port->count--;
51263 + atomic_dec(&port->count);
51264 }
51265 spin_unlock_irqrestore(&info->lock, flags);
51266 port->blocked_open++;
51267 @@ -3339,7 +3339,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
51268 remove_wait_queue(&port->open_wait, &wait);
51269
51270 if (extra_count)
51271 - port->count++;
51272 + atomic_inc(&port->count);
51273 port->blocked_open--;
51274
51275 if (!retval)
51276 diff --git a/drivers/tty/synclinkmp.c b/drivers/tty/synclinkmp.c
51277 index 53ba853..3c30f6d 100644
51278 --- a/drivers/tty/synclinkmp.c
51279 +++ b/drivers/tty/synclinkmp.c
51280 @@ -750,7 +750,7 @@ static int open(struct tty_struct *tty, struct file *filp)
51281
51282 if (debug_level >= DEBUG_LEVEL_INFO)
51283 printk("%s(%d):%s open(), old ref count = %d\n",
51284 - __FILE__,__LINE__,tty->driver->name, info->port.count);
51285 + __FILE__,__LINE__,tty->driver->name, atomic_read(&info->port.count));
51286
51287 /* If port is closing, signal caller to try again */
51288 if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){
51289 @@ -769,10 +769,10 @@ static int open(struct tty_struct *tty, struct file *filp)
51290 spin_unlock_irqrestore(&info->netlock, flags);
51291 goto cleanup;
51292 }
51293 - info->port.count++;
51294 + atomic_inc(&info->port.count);
51295 spin_unlock_irqrestore(&info->netlock, flags);
51296
51297 - if (info->port.count == 1) {
51298 + if (atomic_read(&info->port.count) == 1) {
51299 /* 1st open on this device, init hardware */
51300 retval = startup(info);
51301 if (retval < 0)
51302 @@ -796,8 +796,8 @@ cleanup:
51303 if (retval) {
51304 if (tty->count == 1)
51305 info->port.tty = NULL; /* tty layer will release tty struct */
51306 - if(info->port.count)
51307 - info->port.count--;
51308 + if(atomic_read(&info->port.count))
51309 + atomic_dec(&info->port.count);
51310 }
51311
51312 return retval;
51313 @@ -815,7 +815,7 @@ static void close(struct tty_struct *tty, struct file *filp)
51314
51315 if (debug_level >= DEBUG_LEVEL_INFO)
51316 printk("%s(%d):%s close() entry, count=%d\n",
51317 - __FILE__,__LINE__, info->device_name, info->port.count);
51318 + __FILE__,__LINE__, info->device_name, atomic_read(&info->port.count));
51319
51320 if (tty_port_close_start(&info->port, tty, filp) == 0)
51321 goto cleanup;
51322 @@ -834,7 +834,7 @@ static void close(struct tty_struct *tty, struct file *filp)
51323 cleanup:
51324 if (debug_level >= DEBUG_LEVEL_INFO)
51325 printk("%s(%d):%s close() exit, count=%d\n", __FILE__,__LINE__,
51326 - tty->driver->name, info->port.count);
51327 + tty->driver->name, atomic_read(&info->port.count));
51328 }
51329
51330 /* Called by tty_hangup() when a hangup is signaled.
51331 @@ -857,7 +857,7 @@ static void hangup(struct tty_struct *tty)
51332 shutdown(info);
51333
51334 spin_lock_irqsave(&info->port.lock, flags);
51335 - info->port.count = 0;
51336 + atomic_set(&info->port.count, 0);
51337 info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
51338 info->port.tty = NULL;
51339 spin_unlock_irqrestore(&info->port.lock, flags);
51340 @@ -1565,7 +1565,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
51341 unsigned short new_crctype;
51342
51343 /* return error if TTY interface open */
51344 - if (info->port.count)
51345 + if (atomic_read(&info->port.count))
51346 return -EBUSY;
51347
51348 switch (encoding)
51349 @@ -1660,7 +1660,7 @@ static int hdlcdev_open(struct net_device *dev)
51350
51351 /* arbitrate between network and tty opens */
51352 spin_lock_irqsave(&info->netlock, flags);
51353 - if (info->port.count != 0 || info->netcount != 0) {
51354 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
51355 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name);
51356 spin_unlock_irqrestore(&info->netlock, flags);
51357 return -EBUSY;
51358 @@ -1746,7 +1746,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
51359 printk("%s:hdlcdev_ioctl(%s)\n",__FILE__,dev->name);
51360
51361 /* return error if TTY interface open */
51362 - if (info->port.count)
51363 + if (atomic_read(&info->port.count))
51364 return -EBUSY;
51365
51366 if (cmd != SIOCWANDEV)
51367 @@ -2621,7 +2621,7 @@ static irqreturn_t synclinkmp_interrupt(int dummy, void *dev_id)
51368 * do not request bottom half processing if the
51369 * device is not open in a normal mode.
51370 */
51371 - if ( port && (port->port.count || port->netcount) &&
51372 + if ( port && (atomic_read(&port->port.count) || port->netcount) &&
51373 port->pending_bh && !port->bh_running &&
51374 !port->bh_requested ) {
51375 if ( debug_level >= DEBUG_LEVEL_ISR )
51376 @@ -3319,12 +3319,12 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
51377
51378 if (debug_level >= DEBUG_LEVEL_INFO)
51379 printk("%s(%d):%s block_til_ready() before block, count=%d\n",
51380 - __FILE__,__LINE__, tty->driver->name, port->count );
51381 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
51382
51383 spin_lock_irqsave(&info->lock, flags);
51384 if (!tty_hung_up_p(filp)) {
51385 extra_count = true;
51386 - port->count--;
51387 + atomic_dec(&port->count);
51388 }
51389 spin_unlock_irqrestore(&info->lock, flags);
51390 port->blocked_open++;
51391 @@ -3353,7 +3353,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
51392
51393 if (debug_level >= DEBUG_LEVEL_INFO)
51394 printk("%s(%d):%s block_til_ready() count=%d\n",
51395 - __FILE__,__LINE__, tty->driver->name, port->count );
51396 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
51397
51398 tty_unlock(tty);
51399 schedule();
51400 @@ -3364,12 +3364,12 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
51401 remove_wait_queue(&port->open_wait, &wait);
51402
51403 if (extra_count)
51404 - port->count++;
51405 + atomic_inc(&port->count);
51406 port->blocked_open--;
51407
51408 if (debug_level >= DEBUG_LEVEL_INFO)
51409 printk("%s(%d):%s block_til_ready() after, count=%d\n",
51410 - __FILE__,__LINE__, tty->driver->name, port->count );
51411 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
51412
51413 if (!retval)
51414 port->flags |= ASYNC_NORMAL_ACTIVE;
51415 diff --git a/drivers/tty/sysrq.c b/drivers/tty/sysrq.c
51416 index ce396ec..04a37be 100644
51417 --- a/drivers/tty/sysrq.c
51418 +++ b/drivers/tty/sysrq.c
51419 @@ -1075,7 +1075,7 @@ EXPORT_SYMBOL(unregister_sysrq_key);
51420 static ssize_t write_sysrq_trigger(struct file *file, const char __user *buf,
51421 size_t count, loff_t *ppos)
51422 {
51423 - if (count) {
51424 + if (count && capable(CAP_SYS_ADMIN)) {
51425 char c;
51426
51427 if (get_user(c, buf))
51428 diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
51429 index 3411071..86f2cf2 100644
51430 --- a/drivers/tty/tty_io.c
51431 +++ b/drivers/tty/tty_io.c
51432 @@ -3475,7 +3475,7 @@ EXPORT_SYMBOL_GPL(get_current_tty);
51433
51434 void tty_default_fops(struct file_operations *fops)
51435 {
51436 - *fops = tty_fops;
51437 + memcpy((void *)fops, &tty_fops, sizeof(tty_fops));
51438 }
51439
51440 /*
51441 diff --git a/drivers/tty/tty_ldisc.c b/drivers/tty/tty_ldisc.c
51442 index 2d822aa..a566234 100644
51443 --- a/drivers/tty/tty_ldisc.c
51444 +++ b/drivers/tty/tty_ldisc.c
51445 @@ -71,7 +71,7 @@ int tty_register_ldisc(int disc, struct tty_ldisc_ops *new_ldisc)
51446 raw_spin_lock_irqsave(&tty_ldiscs_lock, flags);
51447 tty_ldiscs[disc] = new_ldisc;
51448 new_ldisc->num = disc;
51449 - new_ldisc->refcount = 0;
51450 + atomic_set(&new_ldisc->refcount, 0);
51451 raw_spin_unlock_irqrestore(&tty_ldiscs_lock, flags);
51452
51453 return ret;
51454 @@ -99,7 +99,7 @@ int tty_unregister_ldisc(int disc)
51455 return -EINVAL;
51456
51457 raw_spin_lock_irqsave(&tty_ldiscs_lock, flags);
51458 - if (tty_ldiscs[disc]->refcount)
51459 + if (atomic_read(&tty_ldiscs[disc]->refcount))
51460 ret = -EBUSY;
51461 else
51462 tty_ldiscs[disc] = NULL;
51463 @@ -120,7 +120,7 @@ static struct tty_ldisc_ops *get_ldops(int disc)
51464 if (ldops) {
51465 ret = ERR_PTR(-EAGAIN);
51466 if (try_module_get(ldops->owner)) {
51467 - ldops->refcount++;
51468 + atomic_inc(&ldops->refcount);
51469 ret = ldops;
51470 }
51471 }
51472 @@ -133,7 +133,7 @@ static void put_ldops(struct tty_ldisc_ops *ldops)
51473 unsigned long flags;
51474
51475 raw_spin_lock_irqsave(&tty_ldiscs_lock, flags);
51476 - ldops->refcount--;
51477 + atomic_dec(&ldops->refcount);
51478 module_put(ldops->owner);
51479 raw_spin_unlock_irqrestore(&tty_ldiscs_lock, flags);
51480 }
51481 diff --git a/drivers/tty/tty_port.c b/drivers/tty/tty_port.c
51482 index 3f746c8..2f2fcaa 100644
51483 --- a/drivers/tty/tty_port.c
51484 +++ b/drivers/tty/tty_port.c
51485 @@ -235,7 +235,7 @@ void tty_port_hangup(struct tty_port *port)
51486 unsigned long flags;
51487
51488 spin_lock_irqsave(&port->lock, flags);
51489 - port->count = 0;
51490 + atomic_set(&port->count, 0);
51491 port->flags &= ~ASYNC_NORMAL_ACTIVE;
51492 tty = port->tty;
51493 if (tty)
51494 @@ -393,7 +393,7 @@ int tty_port_block_til_ready(struct tty_port *port,
51495 /* The port lock protects the port counts */
51496 spin_lock_irqsave(&port->lock, flags);
51497 if (!tty_hung_up_p(filp))
51498 - port->count--;
51499 + atomic_dec(&port->count);
51500 port->blocked_open++;
51501 spin_unlock_irqrestore(&port->lock, flags);
51502
51503 @@ -435,7 +435,7 @@ int tty_port_block_til_ready(struct tty_port *port,
51504 we must not mess that up further */
51505 spin_lock_irqsave(&port->lock, flags);
51506 if (!tty_hung_up_p(filp))
51507 - port->count++;
51508 + atomic_inc(&port->count);
51509 port->blocked_open--;
51510 if (retval == 0)
51511 port->flags |= ASYNC_NORMAL_ACTIVE;
51512 @@ -469,19 +469,19 @@ int tty_port_close_start(struct tty_port *port,
51513 return 0;
51514 }
51515
51516 - if (tty->count == 1 && port->count != 1) {
51517 + if (tty->count == 1 && atomic_read(&port->count) != 1) {
51518 printk(KERN_WARNING
51519 "tty_port_close_start: tty->count = 1 port count = %d.\n",
51520 - port->count);
51521 - port->count = 1;
51522 + atomic_read(&port->count));
51523 + atomic_set(&port->count, 1);
51524 }
51525 - if (--port->count < 0) {
51526 + if (atomic_dec_return(&port->count) < 0) {
51527 printk(KERN_WARNING "tty_port_close_start: count = %d\n",
51528 - port->count);
51529 - port->count = 0;
51530 + atomic_read(&port->count));
51531 + atomic_set(&port->count, 0);
51532 }
51533
51534 - if (port->count) {
51535 + if (atomic_read(&port->count)) {
51536 spin_unlock_irqrestore(&port->lock, flags);
51537 return 0;
51538 }
51539 @@ -563,7 +563,7 @@ int tty_port_open(struct tty_port *port, struct tty_struct *tty,
51540 {
51541 spin_lock_irq(&port->lock);
51542 if (!tty_hung_up_p(filp))
51543 - ++port->count;
51544 + atomic_inc(&port->count);
51545 spin_unlock_irq(&port->lock);
51546 tty_port_tty_set(port, tty);
51547
51548 diff --git a/drivers/tty/vt/keyboard.c b/drivers/tty/vt/keyboard.c
51549 index d0e3a44..5f8b754 100644
51550 --- a/drivers/tty/vt/keyboard.c
51551 +++ b/drivers/tty/vt/keyboard.c
51552 @@ -641,6 +641,16 @@ static void k_spec(struct vc_data *vc, unsigned char value, char up_flag)
51553 kbd->kbdmode == VC_OFF) &&
51554 value != KVAL(K_SAK))
51555 return; /* SAK is allowed even in raw mode */
51556 +
51557 +#if defined(CONFIG_GRKERNSEC_PROC) || defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
51558 + {
51559 + void *func = fn_handler[value];
51560 + if (func == fn_show_state || func == fn_show_ptregs ||
51561 + func == fn_show_mem)
51562 + return;
51563 + }
51564 +#endif
51565 +
51566 fn_handler[value](vc);
51567 }
51568
51569 @@ -1776,9 +1786,6 @@ int vt_do_kdsk_ioctl(int cmd, struct kbentry __user *user_kbe, int perm,
51570 if (copy_from_user(&tmp, user_kbe, sizeof(struct kbentry)))
51571 return -EFAULT;
51572
51573 - if (!capable(CAP_SYS_TTY_CONFIG))
51574 - perm = 0;
51575 -
51576 switch (cmd) {
51577 case KDGKBENT:
51578 /* Ensure another thread doesn't free it under us */
51579 @@ -1793,6 +1800,9 @@ int vt_do_kdsk_ioctl(int cmd, struct kbentry __user *user_kbe, int perm,
51580 spin_unlock_irqrestore(&kbd_event_lock, flags);
51581 return put_user(val, &user_kbe->kb_value);
51582 case KDSKBENT:
51583 + if (!capable(CAP_SYS_TTY_CONFIG))
51584 + perm = 0;
51585 +
51586 if (!perm)
51587 return -EPERM;
51588 if (!i && v == K_NOSUCHMAP) {
51589 @@ -1883,9 +1893,6 @@ int vt_do_kdgkb_ioctl(int cmd, struct kbsentry __user *user_kdgkb, int perm)
51590 int i, j, k;
51591 int ret;
51592
51593 - if (!capable(CAP_SYS_TTY_CONFIG))
51594 - perm = 0;
51595 -
51596 kbs = kmalloc(sizeof(*kbs), GFP_KERNEL);
51597 if (!kbs) {
51598 ret = -ENOMEM;
51599 @@ -1919,6 +1926,9 @@ int vt_do_kdgkb_ioctl(int cmd, struct kbsentry __user *user_kdgkb, int perm)
51600 kfree(kbs);
51601 return ((p && *p) ? -EOVERFLOW : 0);
51602 case KDSKBSENT:
51603 + if (!capable(CAP_SYS_TTY_CONFIG))
51604 + perm = 0;
51605 +
51606 if (!perm) {
51607 ret = -EPERM;
51608 goto reterr;
51609 diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c
51610 index a673e5b..36e5d32 100644
51611 --- a/drivers/uio/uio.c
51612 +++ b/drivers/uio/uio.c
51613 @@ -25,6 +25,7 @@
51614 #include <linux/kobject.h>
51615 #include <linux/cdev.h>
51616 #include <linux/uio_driver.h>
51617 +#include <asm/local.h>
51618
51619 #define UIO_MAX_DEVICES (1U << MINORBITS)
51620
51621 @@ -32,7 +33,7 @@ struct uio_device {
51622 struct module *owner;
51623 struct device *dev;
51624 int minor;
51625 - atomic_t event;
51626 + atomic_unchecked_t event;
51627 struct fasync_struct *async_queue;
51628 wait_queue_head_t wait;
51629 struct uio_info *info;
51630 @@ -243,7 +244,7 @@ static ssize_t event_show(struct device *dev,
51631 struct device_attribute *attr, char *buf)
51632 {
51633 struct uio_device *idev = dev_get_drvdata(dev);
51634 - return sprintf(buf, "%u\n", (unsigned int)atomic_read(&idev->event));
51635 + return sprintf(buf, "%u\n", (unsigned int)atomic_read_unchecked(&idev->event));
51636 }
51637 static DEVICE_ATTR_RO(event);
51638
51639 @@ -405,7 +406,7 @@ void uio_event_notify(struct uio_info *info)
51640 {
51641 struct uio_device *idev = info->uio_dev;
51642
51643 - atomic_inc(&idev->event);
51644 + atomic_inc_unchecked(&idev->event);
51645 wake_up_interruptible(&idev->wait);
51646 kill_fasync(&idev->async_queue, SIGIO, POLL_IN);
51647 }
51648 @@ -458,7 +459,7 @@ static int uio_open(struct inode *inode, struct file *filep)
51649 }
51650
51651 listener->dev = idev;
51652 - listener->event_count = atomic_read(&idev->event);
51653 + listener->event_count = atomic_read_unchecked(&idev->event);
51654 filep->private_data = listener;
51655
51656 if (idev->info->open) {
51657 @@ -509,7 +510,7 @@ static unsigned int uio_poll(struct file *filep, poll_table *wait)
51658 return -EIO;
51659
51660 poll_wait(filep, &idev->wait, wait);
51661 - if (listener->event_count != atomic_read(&idev->event))
51662 + if (listener->event_count != atomic_read_unchecked(&idev->event))
51663 return POLLIN | POLLRDNORM;
51664 return 0;
51665 }
51666 @@ -534,7 +535,7 @@ static ssize_t uio_read(struct file *filep, char __user *buf,
51667 do {
51668 set_current_state(TASK_INTERRUPTIBLE);
51669
51670 - event_count = atomic_read(&idev->event);
51671 + event_count = atomic_read_unchecked(&idev->event);
51672 if (event_count != listener->event_count) {
51673 if (copy_to_user(buf, &event_count, count))
51674 retval = -EFAULT;
51675 @@ -591,9 +592,13 @@ static ssize_t uio_write(struct file *filep, const char __user *buf,
51676 static int uio_find_mem_index(struct vm_area_struct *vma)
51677 {
51678 struct uio_device *idev = vma->vm_private_data;
51679 + unsigned long size;
51680
51681 if (vma->vm_pgoff < MAX_UIO_MAPS) {
51682 - if (idev->info->mem[vma->vm_pgoff].size == 0)
51683 + size = idev->info->mem[vma->vm_pgoff].size;
51684 + if (size == 0)
51685 + return -1;
51686 + if (vma->vm_end - vma->vm_start > size)
51687 return -1;
51688 return (int)vma->vm_pgoff;
51689 }
51690 @@ -825,7 +830,7 @@ int __uio_register_device(struct module *owner,
51691 idev->owner = owner;
51692 idev->info = info;
51693 init_waitqueue_head(&idev->wait);
51694 - atomic_set(&idev->event, 0);
51695 + atomic_set_unchecked(&idev->event, 0);
51696
51697 ret = uio_get_minor(idev);
51698 if (ret)
51699 diff --git a/drivers/usb/atm/cxacru.c b/drivers/usb/atm/cxacru.c
51700 index 813d4d3..a71934f 100644
51701 --- a/drivers/usb/atm/cxacru.c
51702 +++ b/drivers/usb/atm/cxacru.c
51703 @@ -472,7 +472,7 @@ static ssize_t cxacru_sysfs_store_adsl_config(struct device *dev,
51704 ret = sscanf(buf + pos, "%x=%x%n", &index, &value, &tmp);
51705 if (ret < 2)
51706 return -EINVAL;
51707 - if (index < 0 || index > 0x7f)
51708 + if (index > 0x7f)
51709 return -EINVAL;
51710 pos += tmp;
51711
51712 diff --git a/drivers/usb/atm/usbatm.c b/drivers/usb/atm/usbatm.c
51713 index dada014..1d0d517 100644
51714 --- a/drivers/usb/atm/usbatm.c
51715 +++ b/drivers/usb/atm/usbatm.c
51716 @@ -331,7 +331,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
51717 if (printk_ratelimit())
51718 atm_warn(instance, "%s: OAM not supported (vpi %d, vci %d)!\n",
51719 __func__, vpi, vci);
51720 - atomic_inc(&vcc->stats->rx_err);
51721 + atomic_inc_unchecked(&vcc->stats->rx_err);
51722 return;
51723 }
51724
51725 @@ -358,7 +358,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
51726 if (length > ATM_MAX_AAL5_PDU) {
51727 atm_rldbg(instance, "%s: bogus length %u (vcc: 0x%p)!\n",
51728 __func__, length, vcc);
51729 - atomic_inc(&vcc->stats->rx_err);
51730 + atomic_inc_unchecked(&vcc->stats->rx_err);
51731 goto out;
51732 }
51733
51734 @@ -367,14 +367,14 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
51735 if (sarb->len < pdu_length) {
51736 atm_rldbg(instance, "%s: bogus pdu_length %u (sarb->len: %u, vcc: 0x%p)!\n",
51737 __func__, pdu_length, sarb->len, vcc);
51738 - atomic_inc(&vcc->stats->rx_err);
51739 + atomic_inc_unchecked(&vcc->stats->rx_err);
51740 goto out;
51741 }
51742
51743 if (crc32_be(~0, skb_tail_pointer(sarb) - pdu_length, pdu_length) != 0xc704dd7b) {
51744 atm_rldbg(instance, "%s: packet failed crc check (vcc: 0x%p)!\n",
51745 __func__, vcc);
51746 - atomic_inc(&vcc->stats->rx_err);
51747 + atomic_inc_unchecked(&vcc->stats->rx_err);
51748 goto out;
51749 }
51750
51751 @@ -386,7 +386,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
51752 if (printk_ratelimit())
51753 atm_err(instance, "%s: no memory for skb (length: %u)!\n",
51754 __func__, length);
51755 - atomic_inc(&vcc->stats->rx_drop);
51756 + atomic_inc_unchecked(&vcc->stats->rx_drop);
51757 goto out;
51758 }
51759
51760 @@ -414,7 +414,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
51761
51762 vcc->push(vcc, skb);
51763
51764 - atomic_inc(&vcc->stats->rx);
51765 + atomic_inc_unchecked(&vcc->stats->rx);
51766 out:
51767 skb_trim(sarb, 0);
51768 }
51769 @@ -612,7 +612,7 @@ static void usbatm_tx_process(unsigned long data)
51770 struct atm_vcc *vcc = UDSL_SKB(skb)->atm.vcc;
51771
51772 usbatm_pop(vcc, skb);
51773 - atomic_inc(&vcc->stats->tx);
51774 + atomic_inc_unchecked(&vcc->stats->tx);
51775
51776 skb = skb_dequeue(&instance->sndqueue);
51777 }
51778 @@ -756,11 +756,11 @@ static int usbatm_atm_proc_read(struct atm_dev *atm_dev, loff_t *pos, char *page
51779 if (!left--)
51780 return sprintf(page,
51781 "AAL5: tx %d ( %d err ), rx %d ( %d err, %d drop )\n",
51782 - atomic_read(&atm_dev->stats.aal5.tx),
51783 - atomic_read(&atm_dev->stats.aal5.tx_err),
51784 - atomic_read(&atm_dev->stats.aal5.rx),
51785 - atomic_read(&atm_dev->stats.aal5.rx_err),
51786 - atomic_read(&atm_dev->stats.aal5.rx_drop));
51787 + atomic_read_unchecked(&atm_dev->stats.aal5.tx),
51788 + atomic_read_unchecked(&atm_dev->stats.aal5.tx_err),
51789 + atomic_read_unchecked(&atm_dev->stats.aal5.rx),
51790 + atomic_read_unchecked(&atm_dev->stats.aal5.rx_err),
51791 + atomic_read_unchecked(&atm_dev->stats.aal5.rx_drop));
51792
51793 if (!left--) {
51794 if (instance->disconnected)
51795 diff --git a/drivers/usb/core/devices.c b/drivers/usb/core/devices.c
51796 index 2a3bbdf..91d72cf 100644
51797 --- a/drivers/usb/core/devices.c
51798 +++ b/drivers/usb/core/devices.c
51799 @@ -126,7 +126,7 @@ static const char format_endpt[] =
51800 * time it gets called.
51801 */
51802 static struct device_connect_event {
51803 - atomic_t count;
51804 + atomic_unchecked_t count;
51805 wait_queue_head_t wait;
51806 } device_event = {
51807 .count = ATOMIC_INIT(1),
51808 @@ -164,7 +164,7 @@ static const struct class_info clas_info[] = {
51809
51810 void usbfs_conn_disc_event(void)
51811 {
51812 - atomic_add(2, &device_event.count);
51813 + atomic_add_unchecked(2, &device_event.count);
51814 wake_up(&device_event.wait);
51815 }
51816
51817 @@ -652,7 +652,7 @@ static unsigned int usb_device_poll(struct file *file,
51818
51819 poll_wait(file, &device_event.wait, wait);
51820
51821 - event_count = atomic_read(&device_event.count);
51822 + event_count = atomic_read_unchecked(&device_event.count);
51823 if (file->f_version != event_count) {
51824 file->f_version = event_count;
51825 return POLLIN | POLLRDNORM;
51826 diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c
51827 index 257876e..4304364 100644
51828 --- a/drivers/usb/core/devio.c
51829 +++ b/drivers/usb/core/devio.c
51830 @@ -187,7 +187,7 @@ static ssize_t usbdev_read(struct file *file, char __user *buf, size_t nbytes,
51831 struct usb_dev_state *ps = file->private_data;
51832 struct usb_device *dev = ps->dev;
51833 ssize_t ret = 0;
51834 - unsigned len;
51835 + size_t len;
51836 loff_t pos;
51837 int i;
51838
51839 @@ -229,22 +229,22 @@ static ssize_t usbdev_read(struct file *file, char __user *buf, size_t nbytes,
51840 for (i = 0; nbytes && i < dev->descriptor.bNumConfigurations; i++) {
51841 struct usb_config_descriptor *config =
51842 (struct usb_config_descriptor *)dev->rawdescriptors[i];
51843 - unsigned int length = le16_to_cpu(config->wTotalLength);
51844 + size_t length = le16_to_cpu(config->wTotalLength);
51845
51846 if (*ppos < pos + length) {
51847
51848 /* The descriptor may claim to be longer than it
51849 * really is. Here is the actual allocated length. */
51850 - unsigned alloclen =
51851 + size_t alloclen =
51852 le16_to_cpu(dev->config[i].desc.wTotalLength);
51853
51854 - len = length - (*ppos - pos);
51855 + len = length + pos - *ppos;
51856 if (len > nbytes)
51857 len = nbytes;
51858
51859 /* Simply don't write (skip over) unallocated parts */
51860 if (alloclen > (*ppos - pos)) {
51861 - alloclen -= (*ppos - pos);
51862 + alloclen = alloclen + pos - *ppos;
51863 if (copy_to_user(buf,
51864 dev->rawdescriptors[i] + (*ppos - pos),
51865 min(len, alloclen))) {
51866 diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
51867 index 9c4e292..b89877f 100644
51868 --- a/drivers/usb/core/hcd.c
51869 +++ b/drivers/usb/core/hcd.c
51870 @@ -1550,7 +1550,7 @@ int usb_hcd_submit_urb (struct urb *urb, gfp_t mem_flags)
51871 */
51872 usb_get_urb(urb);
51873 atomic_inc(&urb->use_count);
51874 - atomic_inc(&urb->dev->urbnum);
51875 + atomic_inc_unchecked(&urb->dev->urbnum);
51876 usbmon_urb_submit(&hcd->self, urb);
51877
51878 /* NOTE requirements on root-hub callers (usbfs and the hub
51879 @@ -1577,7 +1577,7 @@ int usb_hcd_submit_urb (struct urb *urb, gfp_t mem_flags)
51880 urb->hcpriv = NULL;
51881 INIT_LIST_HEAD(&urb->urb_list);
51882 atomic_dec(&urb->use_count);
51883 - atomic_dec(&urb->dev->urbnum);
51884 + atomic_dec_unchecked(&urb->dev->urbnum);
51885 if (atomic_read(&urb->reject))
51886 wake_up(&usb_kill_urb_queue);
51887 usb_put_urb(urb);
51888 diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
51889 index 229a73f..ef86f98 100644
51890 --- a/drivers/usb/core/hub.c
51891 +++ b/drivers/usb/core/hub.c
51892 @@ -27,6 +27,7 @@
51893 #include <linux/freezer.h>
51894 #include <linux/random.h>
51895 #include <linux/pm_qos.h>
51896 +#include <linux/grsecurity.h>
51897
51898 #include <asm/uaccess.h>
51899 #include <asm/byteorder.h>
51900 @@ -4512,6 +4513,10 @@ static void hub_port_connect_change(struct usb_hub *hub, int port1,
51901 goto done;
51902 return;
51903 }
51904 +
51905 + if (gr_handle_new_usb())
51906 + goto done;
51907 +
51908 if (hub_is_superspeed(hub->hdev))
51909 unit_load = 150;
51910 else
51911 diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
51912 index 0c8a7fc..c45b40a 100644
51913 --- a/drivers/usb/core/message.c
51914 +++ b/drivers/usb/core/message.c
51915 @@ -128,7 +128,7 @@ static int usb_internal_control_msg(struct usb_device *usb_dev,
51916 * Return: If successful, the number of bytes transferred. Otherwise, a negative
51917 * error number.
51918 */
51919 -int usb_control_msg(struct usb_device *dev, unsigned int pipe, __u8 request,
51920 +int __intentional_overflow(-1) usb_control_msg(struct usb_device *dev, unsigned int pipe, __u8 request,
51921 __u8 requesttype, __u16 value, __u16 index, void *data,
51922 __u16 size, int timeout)
51923 {
51924 @@ -180,7 +180,7 @@ EXPORT_SYMBOL_GPL(usb_control_msg);
51925 * If successful, 0. Otherwise a negative error number. The number of actual
51926 * bytes transferred will be stored in the @actual_length parameter.
51927 */
51928 -int usb_interrupt_msg(struct usb_device *usb_dev, unsigned int pipe,
51929 +int __intentional_overflow(-1) usb_interrupt_msg(struct usb_device *usb_dev, unsigned int pipe,
51930 void *data, int len, int *actual_length, int timeout)
51931 {
51932 return usb_bulk_msg(usb_dev, pipe, data, len, actual_length, timeout);
51933 @@ -220,7 +220,7 @@ EXPORT_SYMBOL_GPL(usb_interrupt_msg);
51934 * bytes transferred will be stored in the @actual_length parameter.
51935 *
51936 */
51937 -int usb_bulk_msg(struct usb_device *usb_dev, unsigned int pipe,
51938 +int __intentional_overflow(-1) usb_bulk_msg(struct usb_device *usb_dev, unsigned int pipe,
51939 void *data, int len, int *actual_length, int timeout)
51940 {
51941 struct urb *urb;
51942 diff --git a/drivers/usb/core/sysfs.c b/drivers/usb/core/sysfs.c
51943 index 1236c60..d47a51c 100644
51944 --- a/drivers/usb/core/sysfs.c
51945 +++ b/drivers/usb/core/sysfs.c
51946 @@ -244,7 +244,7 @@ static ssize_t urbnum_show(struct device *dev, struct device_attribute *attr,
51947 struct usb_device *udev;
51948
51949 udev = to_usb_device(dev);
51950 - return sprintf(buf, "%d\n", atomic_read(&udev->urbnum));
51951 + return sprintf(buf, "%d\n", atomic_read_unchecked(&udev->urbnum));
51952 }
51953 static DEVICE_ATTR_RO(urbnum);
51954
51955 diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
51956 index 4d11449..f4ccabf 100644
51957 --- a/drivers/usb/core/usb.c
51958 +++ b/drivers/usb/core/usb.c
51959 @@ -433,7 +433,7 @@ struct usb_device *usb_alloc_dev(struct usb_device *parent,
51960 set_dev_node(&dev->dev, dev_to_node(bus->controller));
51961 dev->state = USB_STATE_ATTACHED;
51962 dev->lpm_disable_count = 1;
51963 - atomic_set(&dev->urbnum, 0);
51964 + atomic_set_unchecked(&dev->urbnum, 0);
51965
51966 INIT_LIST_HEAD(&dev->ep0.urb_list);
51967 dev->ep0.desc.bLength = USB_DT_ENDPOINT_SIZE;
51968 diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
51969 index 70715ee..07a175c 100644
51970 --- a/drivers/usb/dwc3/gadget.c
51971 +++ b/drivers/usb/dwc3/gadget.c
51972 @@ -550,8 +550,6 @@ static int __dwc3_gadget_ep_enable(struct dwc3_ep *dep,
51973 if (!usb_endpoint_xfer_isoc(desc))
51974 return 0;
51975
51976 - memset(&trb_link, 0, sizeof(trb_link));
51977 -
51978 /* Link TRB for ISOC. The HWO bit is never reset */
51979 trb_st_hw = &dep->trb_pool[0];
51980
51981 diff --git a/drivers/usb/early/ehci-dbgp.c b/drivers/usb/early/ehci-dbgp.c
51982 index 8cfc319..4868255 100644
51983 --- a/drivers/usb/early/ehci-dbgp.c
51984 +++ b/drivers/usb/early/ehci-dbgp.c
51985 @@ -98,7 +98,8 @@ static inline u32 dbgp_len_update(u32 x, u32 len)
51986
51987 #ifdef CONFIG_KGDB
51988 static struct kgdb_io kgdbdbgp_io_ops;
51989 -#define dbgp_kgdb_mode (dbg_io_ops == &kgdbdbgp_io_ops)
51990 +static struct kgdb_io kgdbdbgp_io_ops_console;
51991 +#define dbgp_kgdb_mode (dbg_io_ops == &kgdbdbgp_io_ops || dbg_io_ops == &kgdbdbgp_io_ops_console)
51992 #else
51993 #define dbgp_kgdb_mode (0)
51994 #endif
51995 @@ -1043,6 +1044,13 @@ static struct kgdb_io kgdbdbgp_io_ops = {
51996 .write_char = kgdbdbgp_write_char,
51997 };
51998
51999 +static struct kgdb_io kgdbdbgp_io_ops_console = {
52000 + .name = "kgdbdbgp",
52001 + .read_char = kgdbdbgp_read_char,
52002 + .write_char = kgdbdbgp_write_char,
52003 + .is_console = 1
52004 +};
52005 +
52006 static int kgdbdbgp_wait_time;
52007
52008 static int __init kgdbdbgp_parse_config(char *str)
52009 @@ -1058,8 +1066,10 @@ static int __init kgdbdbgp_parse_config(char *str)
52010 ptr++;
52011 kgdbdbgp_wait_time = simple_strtoul(ptr, &ptr, 10);
52012 }
52013 - kgdb_register_io_module(&kgdbdbgp_io_ops);
52014 - kgdbdbgp_io_ops.is_console = early_dbgp_console.index != -1;
52015 + if (early_dbgp_console.index != -1)
52016 + kgdb_register_io_module(&kgdbdbgp_io_ops_console);
52017 + else
52018 + kgdb_register_io_module(&kgdbdbgp_io_ops);
52019
52020 return 0;
52021 }
52022 diff --git a/drivers/usb/gadget/f_uac1.c b/drivers/usb/gadget/f_uac1.c
52023 index 2b4c82d..06a8ee6 100644
52024 --- a/drivers/usb/gadget/f_uac1.c
52025 +++ b/drivers/usb/gadget/f_uac1.c
52026 @@ -13,6 +13,7 @@
52027 #include <linux/kernel.h>
52028 #include <linux/device.h>
52029 #include <linux/atomic.h>
52030 +#include <linux/module.h>
52031
52032 #include "u_uac1.h"
52033
52034 diff --git a/drivers/usb/gadget/u_serial.c b/drivers/usb/gadget/u_serial.c
52035 index ad0aca8..8ff84865 100644
52036 --- a/drivers/usb/gadget/u_serial.c
52037 +++ b/drivers/usb/gadget/u_serial.c
52038 @@ -733,9 +733,9 @@ static int gs_open(struct tty_struct *tty, struct file *file)
52039 spin_lock_irq(&port->port_lock);
52040
52041 /* already open? Great. */
52042 - if (port->port.count) {
52043 + if (atomic_read(&port->port.count)) {
52044 status = 0;
52045 - port->port.count++;
52046 + atomic_inc(&port->port.count);
52047
52048 /* currently opening/closing? wait ... */
52049 } else if (port->openclose) {
52050 @@ -794,7 +794,7 @@ static int gs_open(struct tty_struct *tty, struct file *file)
52051 tty->driver_data = port;
52052 port->port.tty = tty;
52053
52054 - port->port.count = 1;
52055 + atomic_set(&port->port.count, 1);
52056 port->openclose = false;
52057
52058 /* if connected, start the I/O stream */
52059 @@ -836,11 +836,11 @@ static void gs_close(struct tty_struct *tty, struct file *file)
52060
52061 spin_lock_irq(&port->port_lock);
52062
52063 - if (port->port.count != 1) {
52064 - if (port->port.count == 0)
52065 + if (atomic_read(&port->port.count) != 1) {
52066 + if (atomic_read(&port->port.count) == 0)
52067 WARN_ON(1);
52068 else
52069 - --port->port.count;
52070 + atomic_dec(&port->port.count);
52071 goto exit;
52072 }
52073
52074 @@ -850,7 +850,7 @@ static void gs_close(struct tty_struct *tty, struct file *file)
52075 * and sleep if necessary
52076 */
52077 port->openclose = true;
52078 - port->port.count = 0;
52079 + atomic_set(&port->port.count, 0);
52080
52081 gser = port->port_usb;
52082 if (gser && gser->disconnect)
52083 @@ -1066,7 +1066,7 @@ static int gs_closed(struct gs_port *port)
52084 int cond;
52085
52086 spin_lock_irq(&port->port_lock);
52087 - cond = (port->port.count == 0) && !port->openclose;
52088 + cond = (atomic_read(&port->port.count) == 0) && !port->openclose;
52089 spin_unlock_irq(&port->port_lock);
52090 return cond;
52091 }
52092 @@ -1209,7 +1209,7 @@ int gserial_connect(struct gserial *gser, u8 port_num)
52093 /* if it's already open, start I/O ... and notify the serial
52094 * protocol about open/close status (connect/disconnect).
52095 */
52096 - if (port->port.count) {
52097 + if (atomic_read(&port->port.count)) {
52098 pr_debug("gserial_connect: start ttyGS%d\n", port->port_num);
52099 gs_start_io(port);
52100 if (gser->connect)
52101 @@ -1256,7 +1256,7 @@ void gserial_disconnect(struct gserial *gser)
52102
52103 port->port_usb = NULL;
52104 gser->ioport = NULL;
52105 - if (port->port.count > 0 || port->openclose) {
52106 + if (atomic_read(&port->port.count) > 0 || port->openclose) {
52107 wake_up_interruptible(&port->drain_wait);
52108 if (port->port.tty)
52109 tty_hangup(port->port.tty);
52110 @@ -1272,7 +1272,7 @@ void gserial_disconnect(struct gserial *gser)
52111
52112 /* finally, free any unused/unusable I/O buffers */
52113 spin_lock_irqsave(&port->port_lock, flags);
52114 - if (port->port.count == 0 && !port->openclose)
52115 + if (atomic_read(&port->port.count) == 0 && !port->openclose)
52116 gs_buf_free(&port->port_write_buf);
52117 gs_free_requests(gser->out, &port->read_pool, NULL);
52118 gs_free_requests(gser->out, &port->read_queue, NULL);
52119 diff --git a/drivers/usb/gadget/u_uac1.c b/drivers/usb/gadget/u_uac1.c
52120 index 7a55fea..cc0ed4f 100644
52121 --- a/drivers/usb/gadget/u_uac1.c
52122 +++ b/drivers/usb/gadget/u_uac1.c
52123 @@ -16,6 +16,7 @@
52124 #include <linux/ctype.h>
52125 #include <linux/random.h>
52126 #include <linux/syscalls.h>
52127 +#include <linux/module.h>
52128
52129 #include "u_uac1.h"
52130
52131 diff --git a/drivers/usb/host/ehci-hub.c b/drivers/usb/host/ehci-hub.c
52132 index 7ae0c4d..35521b7 100644
52133 --- a/drivers/usb/host/ehci-hub.c
52134 +++ b/drivers/usb/host/ehci-hub.c
52135 @@ -780,7 +780,7 @@ static struct urb *request_single_step_set_feature_urb(
52136 urb->transfer_flags = URB_DIR_IN;
52137 usb_get_urb(urb);
52138 atomic_inc(&urb->use_count);
52139 - atomic_inc(&urb->dev->urbnum);
52140 + atomic_inc_unchecked(&urb->dev->urbnum);
52141 urb->setup_dma = dma_map_single(
52142 hcd->self.controller,
52143 urb->setup_packet,
52144 @@ -847,7 +847,7 @@ static int ehset_single_step_set_feature(struct usb_hcd *hcd, int port)
52145 urb->status = -EINPROGRESS;
52146 usb_get_urb(urb);
52147 atomic_inc(&urb->use_count);
52148 - atomic_inc(&urb->dev->urbnum);
52149 + atomic_inc_unchecked(&urb->dev->urbnum);
52150 retval = submit_single_step_set_feature(hcd, urb, 0);
52151 if (!retval && !wait_for_completion_timeout(&done,
52152 msecs_to_jiffies(2000))) {
52153 diff --git a/drivers/usb/misc/appledisplay.c b/drivers/usb/misc/appledisplay.c
52154 index ba6a5d6..f88f7f3 100644
52155 --- a/drivers/usb/misc/appledisplay.c
52156 +++ b/drivers/usb/misc/appledisplay.c
52157 @@ -83,7 +83,7 @@ struct appledisplay {
52158 spinlock_t lock;
52159 };
52160
52161 -static atomic_t count_displays = ATOMIC_INIT(0);
52162 +static atomic_unchecked_t count_displays = ATOMIC_INIT(0);
52163 static struct workqueue_struct *wq;
52164
52165 static void appledisplay_complete(struct urb *urb)
52166 @@ -281,7 +281,7 @@ static int appledisplay_probe(struct usb_interface *iface,
52167
52168 /* Register backlight device */
52169 snprintf(bl_name, sizeof(bl_name), "appledisplay%d",
52170 - atomic_inc_return(&count_displays) - 1);
52171 + atomic_inc_return_unchecked(&count_displays) - 1);
52172 memset(&props, 0, sizeof(struct backlight_properties));
52173 props.type = BACKLIGHT_RAW;
52174 props.max_brightness = 0xff;
52175 diff --git a/drivers/usb/serial/console.c b/drivers/usb/serial/console.c
52176 index 8d7fc48..01c4986 100644
52177 --- a/drivers/usb/serial/console.c
52178 +++ b/drivers/usb/serial/console.c
52179 @@ -123,7 +123,7 @@ static int usb_console_setup(struct console *co, char *options)
52180
52181 info->port = port;
52182
52183 - ++port->port.count;
52184 + atomic_inc(&port->port.count);
52185 if (!test_bit(ASYNCB_INITIALIZED, &port->port.flags)) {
52186 if (serial->type->set_termios) {
52187 /*
52188 @@ -167,7 +167,7 @@ static int usb_console_setup(struct console *co, char *options)
52189 }
52190 /* Now that any required fake tty operations are completed restore
52191 * the tty port count */
52192 - --port->port.count;
52193 + atomic_dec(&port->port.count);
52194 /* The console is special in terms of closing the device so
52195 * indicate this port is now acting as a system console. */
52196 port->port.console = 1;
52197 @@ -180,7 +180,7 @@ static int usb_console_setup(struct console *co, char *options)
52198 free_tty:
52199 kfree(tty);
52200 reset_open_count:
52201 - port->port.count = 0;
52202 + atomic_set(&port->port.count, 0);
52203 usb_autopm_put_interface(serial->interface);
52204 error_get_interface:
52205 usb_serial_put(serial);
52206 @@ -191,7 +191,7 @@ static int usb_console_setup(struct console *co, char *options)
52207 static void usb_console_write(struct console *co,
52208 const char *buf, unsigned count)
52209 {
52210 - static struct usbcons_info *info = &usbcons_info;
52211 + struct usbcons_info *info = &usbcons_info;
52212 struct usb_serial_port *port = info->port;
52213 struct usb_serial *serial;
52214 int retval = -ENODEV;
52215 diff --git a/drivers/usb/storage/usb.h b/drivers/usb/storage/usb.h
52216 index 307e339..6aa97cb 100644
52217 --- a/drivers/usb/storage/usb.h
52218 +++ b/drivers/usb/storage/usb.h
52219 @@ -63,7 +63,7 @@ struct us_unusual_dev {
52220 __u8 useProtocol;
52221 __u8 useTransport;
52222 int (*initFunction)(struct us_data *);
52223 -};
52224 +} __do_const;
52225
52226
52227 /* Dynamic bitflag definitions (us->dflags): used in set_bit() etc. */
52228 diff --git a/drivers/usb/wusbcore/wa-hc.h b/drivers/usb/wusbcore/wa-hc.h
52229 index f2a8d29..7bc3fe7 100644
52230 --- a/drivers/usb/wusbcore/wa-hc.h
52231 +++ b/drivers/usb/wusbcore/wa-hc.h
52232 @@ -240,7 +240,7 @@ struct wahc {
52233 spinlock_t xfer_list_lock;
52234 struct work_struct xfer_enqueue_work;
52235 struct work_struct xfer_error_work;
52236 - atomic_t xfer_id_count;
52237 + atomic_unchecked_t xfer_id_count;
52238
52239 kernel_ulong_t quirks;
52240 };
52241 @@ -305,7 +305,7 @@ static inline void wa_init(struct wahc *wa)
52242 INIT_WORK(&wa->xfer_enqueue_work, wa_urb_enqueue_run);
52243 INIT_WORK(&wa->xfer_error_work, wa_process_errored_transfers_run);
52244 wa->dto_in_use = 0;
52245 - atomic_set(&wa->xfer_id_count, 1);
52246 + atomic_set_unchecked(&wa->xfer_id_count, 1);
52247 /* init the buf in URBs */
52248 for (index = 0; index < WA_MAX_BUF_IN_URBS; ++index)
52249 usb_init_urb(&(wa->buf_in_urbs[index]));
52250 diff --git a/drivers/usb/wusbcore/wa-xfer.c b/drivers/usb/wusbcore/wa-xfer.c
52251 index 3e2e4ed..060c9b8 100644
52252 --- a/drivers/usb/wusbcore/wa-xfer.c
52253 +++ b/drivers/usb/wusbcore/wa-xfer.c
52254 @@ -314,7 +314,7 @@ static void wa_xfer_completion(struct wa_xfer *xfer)
52255 */
52256 static void wa_xfer_id_init(struct wa_xfer *xfer)
52257 {
52258 - xfer->id = atomic_add_return(1, &xfer->wa->xfer_id_count);
52259 + xfer->id = atomic_add_return_unchecked(1, &xfer->wa->xfer_id_count);
52260 }
52261
52262 /* Return the xfer's ID. */
52263 diff --git a/drivers/vfio/vfio.c b/drivers/vfio/vfio.c
52264 index 512f479..7e041d0 100644
52265 --- a/drivers/vfio/vfio.c
52266 +++ b/drivers/vfio/vfio.c
52267 @@ -487,7 +487,7 @@ static int vfio_group_nb_add_dev(struct vfio_group *group, struct device *dev)
52268 return 0;
52269
52270 /* TODO Prevent device auto probing */
52271 - WARN("Device %s added to live group %d!\n", dev_name(dev),
52272 + WARN(1, "Device %s added to live group %d!\n", dev_name(dev),
52273 iommu_group_id(group->iommu_group));
52274
52275 return 0;
52276 diff --git a/drivers/vhost/vringh.c b/drivers/vhost/vringh.c
52277 index 5174eba..451e6bc 100644
52278 --- a/drivers/vhost/vringh.c
52279 +++ b/drivers/vhost/vringh.c
52280 @@ -530,17 +530,17 @@ static inline void __vringh_notify_disable(struct vringh *vrh,
52281 /* Userspace access helpers: in this case, addresses are really userspace. */
52282 static inline int getu16_user(u16 *val, const u16 *p)
52283 {
52284 - return get_user(*val, (__force u16 __user *)p);
52285 + return get_user(*val, (u16 __force_user *)p);
52286 }
52287
52288 static inline int putu16_user(u16 *p, u16 val)
52289 {
52290 - return put_user(val, (__force u16 __user *)p);
52291 + return put_user(val, (u16 __force_user *)p);
52292 }
52293
52294 static inline int copydesc_user(void *dst, const void *src, size_t len)
52295 {
52296 - return copy_from_user(dst, (__force void __user *)src, len) ?
52297 + return copy_from_user(dst, (void __force_user *)src, len) ?
52298 -EFAULT : 0;
52299 }
52300
52301 @@ -548,19 +548,19 @@ static inline int putused_user(struct vring_used_elem *dst,
52302 const struct vring_used_elem *src,
52303 unsigned int num)
52304 {
52305 - return copy_to_user((__force void __user *)dst, src,
52306 + return copy_to_user((void __force_user *)dst, src,
52307 sizeof(*dst) * num) ? -EFAULT : 0;
52308 }
52309
52310 static inline int xfer_from_user(void *src, void *dst, size_t len)
52311 {
52312 - return copy_from_user(dst, (__force void __user *)src, len) ?
52313 + return copy_from_user(dst, (void __force_user *)src, len) ?
52314 -EFAULT : 0;
52315 }
52316
52317 static inline int xfer_to_user(void *dst, void *src, size_t len)
52318 {
52319 - return copy_to_user((__force void __user *)dst, src, len) ?
52320 + return copy_to_user((void __force_user *)dst, src, len) ?
52321 -EFAULT : 0;
52322 }
52323
52324 @@ -596,9 +596,9 @@ int vringh_init_user(struct vringh *vrh, u32 features,
52325 vrh->last_used_idx = 0;
52326 vrh->vring.num = num;
52327 /* vring expects kernel addresses, but only used via accessors. */
52328 - vrh->vring.desc = (__force struct vring_desc *)desc;
52329 - vrh->vring.avail = (__force struct vring_avail *)avail;
52330 - vrh->vring.used = (__force struct vring_used *)used;
52331 + vrh->vring.desc = (__force_kernel struct vring_desc *)desc;
52332 + vrh->vring.avail = (__force_kernel struct vring_avail *)avail;
52333 + vrh->vring.used = (__force_kernel struct vring_used *)used;
52334 return 0;
52335 }
52336 EXPORT_SYMBOL(vringh_init_user);
52337 @@ -800,7 +800,7 @@ static inline int getu16_kern(u16 *val, const u16 *p)
52338
52339 static inline int putu16_kern(u16 *p, u16 val)
52340 {
52341 - ACCESS_ONCE(*p) = val;
52342 + ACCESS_ONCE_RW(*p) = val;
52343 return 0;
52344 }
52345
52346 diff --git a/drivers/video/backlight/kb3886_bl.c b/drivers/video/backlight/kb3886_bl.c
52347 index 84a110a..96312c3 100644
52348 --- a/drivers/video/backlight/kb3886_bl.c
52349 +++ b/drivers/video/backlight/kb3886_bl.c
52350 @@ -78,7 +78,7 @@ static struct kb3886bl_machinfo *bl_machinfo;
52351 static unsigned long kb3886bl_flags;
52352 #define KB3886BL_SUSPENDED 0x01
52353
52354 -static struct dmi_system_id kb3886bl_device_table[] __initdata = {
52355 +static const struct dmi_system_id kb3886bl_device_table[] __initconst = {
52356 {
52357 .ident = "Sahara Touch-iT",
52358 .matches = {
52359 diff --git a/drivers/video/fbdev/arcfb.c b/drivers/video/fbdev/arcfb.c
52360 index 1b0b233..6f34c2c 100644
52361 --- a/drivers/video/fbdev/arcfb.c
52362 +++ b/drivers/video/fbdev/arcfb.c
52363 @@ -458,7 +458,7 @@ static ssize_t arcfb_write(struct fb_info *info, const char __user *buf,
52364 return -ENOSPC;
52365
52366 err = 0;
52367 - if ((count + p) > fbmemlength) {
52368 + if (count > (fbmemlength - p)) {
52369 count = fbmemlength - p;
52370 err = -ENOSPC;
52371 }
52372 diff --git a/drivers/video/fbdev/aty/aty128fb.c b/drivers/video/fbdev/aty/aty128fb.c
52373 index 52108be..c7c110d 100644
52374 --- a/drivers/video/fbdev/aty/aty128fb.c
52375 +++ b/drivers/video/fbdev/aty/aty128fb.c
52376 @@ -149,7 +149,7 @@ enum {
52377 };
52378
52379 /* Must match above enum */
52380 -static char * const r128_family[] = {
52381 +static const char * const r128_family[] = {
52382 "AGP",
52383 "PCI",
52384 "PRO AGP",
52385 diff --git a/drivers/video/fbdev/aty/atyfb_base.c b/drivers/video/fbdev/aty/atyfb_base.c
52386 index c3d0074..0b9077e 100644
52387 --- a/drivers/video/fbdev/aty/atyfb_base.c
52388 +++ b/drivers/video/fbdev/aty/atyfb_base.c
52389 @@ -1326,10 +1326,14 @@ static int atyfb_set_par(struct fb_info *info)
52390 par->accel_flags = var->accel_flags; /* hack */
52391
52392 if (var->accel_flags) {
52393 - info->fbops->fb_sync = atyfb_sync;
52394 + pax_open_kernel();
52395 + *(void **)&info->fbops->fb_sync = atyfb_sync;
52396 + pax_close_kernel();
52397 info->flags &= ~FBINFO_HWACCEL_DISABLED;
52398 } else {
52399 - info->fbops->fb_sync = NULL;
52400 + pax_open_kernel();
52401 + *(void **)&info->fbops->fb_sync = NULL;
52402 + pax_close_kernel();
52403 info->flags |= FBINFO_HWACCEL_DISABLED;
52404 }
52405
52406 diff --git a/drivers/video/fbdev/aty/mach64_cursor.c b/drivers/video/fbdev/aty/mach64_cursor.c
52407 index 2fa0317..4983f2a 100644
52408 --- a/drivers/video/fbdev/aty/mach64_cursor.c
52409 +++ b/drivers/video/fbdev/aty/mach64_cursor.c
52410 @@ -8,6 +8,7 @@
52411 #include "../core/fb_draw.h"
52412
52413 #include <asm/io.h>
52414 +#include <asm/pgtable.h>
52415
52416 #ifdef __sparc__
52417 #include <asm/fbio.h>
52418 @@ -218,7 +219,9 @@ int aty_init_cursor(struct fb_info *info)
52419 info->sprite.buf_align = 16; /* and 64 lines tall. */
52420 info->sprite.flags = FB_PIXMAP_IO;
52421
52422 - info->fbops->fb_cursor = atyfb_cursor;
52423 + pax_open_kernel();
52424 + *(void **)&info->fbops->fb_cursor = atyfb_cursor;
52425 + pax_close_kernel();
52426
52427 return 0;
52428 }
52429 diff --git a/drivers/video/fbdev/core/fb_defio.c b/drivers/video/fbdev/core/fb_defio.c
52430 index 900aa4e..6d49418 100644
52431 --- a/drivers/video/fbdev/core/fb_defio.c
52432 +++ b/drivers/video/fbdev/core/fb_defio.c
52433 @@ -206,7 +206,9 @@ void fb_deferred_io_init(struct fb_info *info)
52434
52435 BUG_ON(!fbdefio);
52436 mutex_init(&fbdefio->lock);
52437 - info->fbops->fb_mmap = fb_deferred_io_mmap;
52438 + pax_open_kernel();
52439 + *(void **)&info->fbops->fb_mmap = fb_deferred_io_mmap;
52440 + pax_close_kernel();
52441 INIT_DELAYED_WORK(&info->deferred_work, fb_deferred_io_work);
52442 INIT_LIST_HEAD(&fbdefio->pagelist);
52443 if (fbdefio->delay == 0) /* set a default of 1 s */
52444 @@ -237,7 +239,7 @@ void fb_deferred_io_cleanup(struct fb_info *info)
52445 page->mapping = NULL;
52446 }
52447
52448 - info->fbops->fb_mmap = NULL;
52449 + *(void **)&info->fbops->fb_mmap = NULL;
52450 mutex_destroy(&fbdefio->lock);
52451 }
52452 EXPORT_SYMBOL_GPL(fb_deferred_io_cleanup);
52453 diff --git a/drivers/video/fbdev/core/fbmem.c b/drivers/video/fbdev/core/fbmem.c
52454 index b6d5008..5bca7bf 100644
52455 --- a/drivers/video/fbdev/core/fbmem.c
52456 +++ b/drivers/video/fbdev/core/fbmem.c
52457 @@ -433,7 +433,7 @@ static void fb_do_show_logo(struct fb_info *info, struct fb_image *image,
52458 image->dx += image->width + 8;
52459 }
52460 } else if (rotate == FB_ROTATE_UD) {
52461 - for (x = 0; x < num && image->dx >= 0; x++) {
52462 + for (x = 0; x < num && (__s32)image->dx >= 0; x++) {
52463 info->fbops->fb_imageblit(info, image);
52464 image->dx -= image->width + 8;
52465 }
52466 @@ -445,7 +445,7 @@ static void fb_do_show_logo(struct fb_info *info, struct fb_image *image,
52467 image->dy += image->height + 8;
52468 }
52469 } else if (rotate == FB_ROTATE_CCW) {
52470 - for (x = 0; x < num && image->dy >= 0; x++) {
52471 + for (x = 0; x < num && (__s32)image->dy >= 0; x++) {
52472 info->fbops->fb_imageblit(info, image);
52473 image->dy -= image->height + 8;
52474 }
52475 @@ -1179,7 +1179,7 @@ static long do_fb_ioctl(struct fb_info *info, unsigned int cmd,
52476 return -EFAULT;
52477 if (con2fb.console < 1 || con2fb.console > MAX_NR_CONSOLES)
52478 return -EINVAL;
52479 - if (con2fb.framebuffer < 0 || con2fb.framebuffer >= FB_MAX)
52480 + if (con2fb.framebuffer >= FB_MAX)
52481 return -EINVAL;
52482 if (!registered_fb[con2fb.framebuffer])
52483 request_module("fb%d", con2fb.framebuffer);
52484 @@ -1300,7 +1300,7 @@ static int do_fscreeninfo_to_user(struct fb_fix_screeninfo *fix,
52485 __u32 data;
52486 int err;
52487
52488 - err = copy_to_user(&fix32->id, &fix->id, sizeof(fix32->id));
52489 + err = copy_to_user(fix32->id, &fix->id, sizeof(fix32->id));
52490
52491 data = (__u32) (unsigned long) fix->smem_start;
52492 err |= put_user(data, &fix32->smem_start);
52493 diff --git a/drivers/video/fbdev/hyperv_fb.c b/drivers/video/fbdev/hyperv_fb.c
52494 index e23392e..8a77540 100644
52495 --- a/drivers/video/fbdev/hyperv_fb.c
52496 +++ b/drivers/video/fbdev/hyperv_fb.c
52497 @@ -235,7 +235,7 @@ static uint screen_fb_size;
52498 static inline int synthvid_send(struct hv_device *hdev,
52499 struct synthvid_msg *msg)
52500 {
52501 - static atomic64_t request_id = ATOMIC64_INIT(0);
52502 + static atomic64_unchecked_t request_id = ATOMIC64_INIT(0);
52503 int ret;
52504
52505 msg->pipe_hdr.type = PIPE_MSG_DATA;
52506 @@ -243,7 +243,7 @@ static inline int synthvid_send(struct hv_device *hdev,
52507
52508 ret = vmbus_sendpacket(hdev->channel, msg,
52509 msg->vid_hdr.size + sizeof(struct pipe_msg_hdr),
52510 - atomic64_inc_return(&request_id),
52511 + atomic64_inc_return_unchecked(&request_id),
52512 VM_PKT_DATA_INBAND, 0);
52513
52514 if (ret)
52515 diff --git a/drivers/video/fbdev/i810/i810_accel.c b/drivers/video/fbdev/i810/i810_accel.c
52516 index 7672d2e..b56437f 100644
52517 --- a/drivers/video/fbdev/i810/i810_accel.c
52518 +++ b/drivers/video/fbdev/i810/i810_accel.c
52519 @@ -73,6 +73,7 @@ static inline int wait_for_space(struct fb_info *info, u32 space)
52520 }
52521 }
52522 printk("ringbuffer lockup!!!\n");
52523 + printk("head:%u tail:%u iring.size:%u space:%u\n", head, tail, par->iring.size, space);
52524 i810_report_error(mmio);
52525 par->dev_flags |= LOCKUP;
52526 info->pixmap.scan_align = 1;
52527 diff --git a/drivers/video/fbdev/matrox/matroxfb_DAC1064.c b/drivers/video/fbdev/matrox/matroxfb_DAC1064.c
52528 index a01147f..5d896f8 100644
52529 --- a/drivers/video/fbdev/matrox/matroxfb_DAC1064.c
52530 +++ b/drivers/video/fbdev/matrox/matroxfb_DAC1064.c
52531 @@ -1088,14 +1088,20 @@ static void MGAG100_restore(struct matrox_fb_info *minfo)
52532
52533 #ifdef CONFIG_FB_MATROX_MYSTIQUE
52534 struct matrox_switch matrox_mystique = {
52535 - MGA1064_preinit, MGA1064_reset, MGA1064_init, MGA1064_restore,
52536 + .preinit = MGA1064_preinit,
52537 + .reset = MGA1064_reset,
52538 + .init = MGA1064_init,
52539 + .restore = MGA1064_restore,
52540 };
52541 EXPORT_SYMBOL(matrox_mystique);
52542 #endif
52543
52544 #ifdef CONFIG_FB_MATROX_G
52545 struct matrox_switch matrox_G100 = {
52546 - MGAG100_preinit, MGAG100_reset, MGAG100_init, MGAG100_restore,
52547 + .preinit = MGAG100_preinit,
52548 + .reset = MGAG100_reset,
52549 + .init = MGAG100_init,
52550 + .restore = MGAG100_restore,
52551 };
52552 EXPORT_SYMBOL(matrox_G100);
52553 #endif
52554 diff --git a/drivers/video/fbdev/matrox/matroxfb_Ti3026.c b/drivers/video/fbdev/matrox/matroxfb_Ti3026.c
52555 index 195ad7c..09743fc 100644
52556 --- a/drivers/video/fbdev/matrox/matroxfb_Ti3026.c
52557 +++ b/drivers/video/fbdev/matrox/matroxfb_Ti3026.c
52558 @@ -738,7 +738,10 @@ static int Ti3026_preinit(struct matrox_fb_info *minfo)
52559 }
52560
52561 struct matrox_switch matrox_millennium = {
52562 - Ti3026_preinit, Ti3026_reset, Ti3026_init, Ti3026_restore
52563 + .preinit = Ti3026_preinit,
52564 + .reset = Ti3026_reset,
52565 + .init = Ti3026_init,
52566 + .restore = Ti3026_restore
52567 };
52568 EXPORT_SYMBOL(matrox_millennium);
52569 #endif
52570 diff --git a/drivers/video/fbdev/mb862xx/mb862xxfb_accel.c b/drivers/video/fbdev/mb862xx/mb862xxfb_accel.c
52571 index fe92eed..106e085 100644
52572 --- a/drivers/video/fbdev/mb862xx/mb862xxfb_accel.c
52573 +++ b/drivers/video/fbdev/mb862xx/mb862xxfb_accel.c
52574 @@ -312,14 +312,18 @@ void mb862xxfb_init_accel(struct fb_info *info, int xres)
52575 struct mb862xxfb_par *par = info->par;
52576
52577 if (info->var.bits_per_pixel == 32) {
52578 - info->fbops->fb_fillrect = cfb_fillrect;
52579 - info->fbops->fb_copyarea = cfb_copyarea;
52580 - info->fbops->fb_imageblit = cfb_imageblit;
52581 + pax_open_kernel();
52582 + *(void **)&info->fbops->fb_fillrect = cfb_fillrect;
52583 + *(void **)&info->fbops->fb_copyarea = cfb_copyarea;
52584 + *(void **)&info->fbops->fb_imageblit = cfb_imageblit;
52585 + pax_close_kernel();
52586 } else {
52587 outreg(disp, GC_L0EM, 3);
52588 - info->fbops->fb_fillrect = mb86290fb_fillrect;
52589 - info->fbops->fb_copyarea = mb86290fb_copyarea;
52590 - info->fbops->fb_imageblit = mb86290fb_imageblit;
52591 + pax_open_kernel();
52592 + *(void **)&info->fbops->fb_fillrect = mb86290fb_fillrect;
52593 + *(void **)&info->fbops->fb_copyarea = mb86290fb_copyarea;
52594 + *(void **)&info->fbops->fb_imageblit = mb86290fb_imageblit;
52595 + pax_close_kernel();
52596 }
52597 outreg(draw, GDC_REG_DRAW_BASE, 0);
52598 outreg(draw, GDC_REG_MODE_MISC, 0x8000);
52599 diff --git a/drivers/video/fbdev/nvidia/nvidia.c b/drivers/video/fbdev/nvidia/nvidia.c
52600 index def0412..fed6529 100644
52601 --- a/drivers/video/fbdev/nvidia/nvidia.c
52602 +++ b/drivers/video/fbdev/nvidia/nvidia.c
52603 @@ -669,19 +669,23 @@ static int nvidiafb_set_par(struct fb_info *info)
52604 info->fix.line_length = (info->var.xres_virtual *
52605 info->var.bits_per_pixel) >> 3;
52606 if (info->var.accel_flags) {
52607 - info->fbops->fb_imageblit = nvidiafb_imageblit;
52608 - info->fbops->fb_fillrect = nvidiafb_fillrect;
52609 - info->fbops->fb_copyarea = nvidiafb_copyarea;
52610 - info->fbops->fb_sync = nvidiafb_sync;
52611 + pax_open_kernel();
52612 + *(void **)&info->fbops->fb_imageblit = nvidiafb_imageblit;
52613 + *(void **)&info->fbops->fb_fillrect = nvidiafb_fillrect;
52614 + *(void **)&info->fbops->fb_copyarea = nvidiafb_copyarea;
52615 + *(void **)&info->fbops->fb_sync = nvidiafb_sync;
52616 + pax_close_kernel();
52617 info->pixmap.scan_align = 4;
52618 info->flags &= ~FBINFO_HWACCEL_DISABLED;
52619 info->flags |= FBINFO_READS_FAST;
52620 NVResetGraphics(info);
52621 } else {
52622 - info->fbops->fb_imageblit = cfb_imageblit;
52623 - info->fbops->fb_fillrect = cfb_fillrect;
52624 - info->fbops->fb_copyarea = cfb_copyarea;
52625 - info->fbops->fb_sync = NULL;
52626 + pax_open_kernel();
52627 + *(void **)&info->fbops->fb_imageblit = cfb_imageblit;
52628 + *(void **)&info->fbops->fb_fillrect = cfb_fillrect;
52629 + *(void **)&info->fbops->fb_copyarea = cfb_copyarea;
52630 + *(void **)&info->fbops->fb_sync = NULL;
52631 + pax_close_kernel();
52632 info->pixmap.scan_align = 1;
52633 info->flags |= FBINFO_HWACCEL_DISABLED;
52634 info->flags &= ~FBINFO_READS_FAST;
52635 @@ -1173,8 +1177,11 @@ static int nvidia_set_fbinfo(struct fb_info *info)
52636 info->pixmap.size = 8 * 1024;
52637 info->pixmap.flags = FB_PIXMAP_SYSTEM;
52638
52639 - if (!hwcur)
52640 - info->fbops->fb_cursor = NULL;
52641 + if (!hwcur) {
52642 + pax_open_kernel();
52643 + *(void **)&info->fbops->fb_cursor = NULL;
52644 + pax_close_kernel();
52645 + }
52646
52647 info->var.accel_flags = (!noaccel);
52648
52649 diff --git a/drivers/video/fbdev/omap2/dss/display.c b/drivers/video/fbdev/omap2/dss/display.c
52650 index 2412a0d..294215b 100644
52651 --- a/drivers/video/fbdev/omap2/dss/display.c
52652 +++ b/drivers/video/fbdev/omap2/dss/display.c
52653 @@ -161,12 +161,14 @@ int omapdss_register_display(struct omap_dss_device *dssdev)
52654 if (dssdev->name == NULL)
52655 dssdev->name = dssdev->alias;
52656
52657 + pax_open_kernel();
52658 if (drv && drv->get_resolution == NULL)
52659 - drv->get_resolution = omapdss_default_get_resolution;
52660 + *(void **)&drv->get_resolution = omapdss_default_get_resolution;
52661 if (drv && drv->get_recommended_bpp == NULL)
52662 - drv->get_recommended_bpp = omapdss_default_get_recommended_bpp;
52663 + *(void **)&drv->get_recommended_bpp = omapdss_default_get_recommended_bpp;
52664 if (drv && drv->get_timings == NULL)
52665 - drv->get_timings = omapdss_default_get_timings;
52666 + *(void **)&drv->get_timings = omapdss_default_get_timings;
52667 + pax_close_kernel();
52668
52669 mutex_lock(&panel_list_mutex);
52670 list_add_tail(&dssdev->panel_list, &panel_list);
52671 diff --git a/drivers/video/fbdev/s1d13xxxfb.c b/drivers/video/fbdev/s1d13xxxfb.c
52672 index 83433cb..71e9b98 100644
52673 --- a/drivers/video/fbdev/s1d13xxxfb.c
52674 +++ b/drivers/video/fbdev/s1d13xxxfb.c
52675 @@ -881,8 +881,10 @@ static int s1d13xxxfb_probe(struct platform_device *pdev)
52676
52677 switch(prod_id) {
52678 case S1D13506_PROD_ID: /* activate acceleration */
52679 - s1d13xxxfb_fbops.fb_fillrect = s1d13xxxfb_bitblt_solidfill;
52680 - s1d13xxxfb_fbops.fb_copyarea = s1d13xxxfb_bitblt_copyarea;
52681 + pax_open_kernel();
52682 + *(void **)&s1d13xxxfb_fbops.fb_fillrect = s1d13xxxfb_bitblt_solidfill;
52683 + *(void **)&s1d13xxxfb_fbops.fb_copyarea = s1d13xxxfb_bitblt_copyarea;
52684 + pax_close_kernel();
52685 info->flags = FBINFO_DEFAULT | FBINFO_HWACCEL_YPAN |
52686 FBINFO_HWACCEL_FILLRECT | FBINFO_HWACCEL_COPYAREA;
52687 break;
52688 diff --git a/drivers/video/fbdev/sh_mobile_lcdcfb.c b/drivers/video/fbdev/sh_mobile_lcdcfb.c
52689 index 2bcc84a..29dd1ea 100644
52690 --- a/drivers/video/fbdev/sh_mobile_lcdcfb.c
52691 +++ b/drivers/video/fbdev/sh_mobile_lcdcfb.c
52692 @@ -439,9 +439,9 @@ static unsigned long lcdc_sys_read_data(void *handle)
52693 }
52694
52695 static struct sh_mobile_lcdc_sys_bus_ops sh_mobile_lcdc_sys_bus_ops = {
52696 - lcdc_sys_write_index,
52697 - lcdc_sys_write_data,
52698 - lcdc_sys_read_data,
52699 + .write_index = lcdc_sys_write_index,
52700 + .write_data = lcdc_sys_write_data,
52701 + .read_data = lcdc_sys_read_data,
52702 };
52703
52704 static int sh_mobile_lcdc_sginit(struct fb_info *info,
52705 diff --git a/drivers/video/fbdev/smscufx.c b/drivers/video/fbdev/smscufx.c
52706 index d513ed6..90b0de9 100644
52707 --- a/drivers/video/fbdev/smscufx.c
52708 +++ b/drivers/video/fbdev/smscufx.c
52709 @@ -1175,7 +1175,9 @@ static int ufx_ops_release(struct fb_info *info, int user)
52710 fb_deferred_io_cleanup(info);
52711 kfree(info->fbdefio);
52712 info->fbdefio = NULL;
52713 - info->fbops->fb_mmap = ufx_ops_mmap;
52714 + pax_open_kernel();
52715 + *(void **)&info->fbops->fb_mmap = ufx_ops_mmap;
52716 + pax_close_kernel();
52717 }
52718
52719 pr_debug("released /dev/fb%d user=%d count=%d",
52720 diff --git a/drivers/video/fbdev/udlfb.c b/drivers/video/fbdev/udlfb.c
52721 index 77b890e..458e666 100644
52722 --- a/drivers/video/fbdev/udlfb.c
52723 +++ b/drivers/video/fbdev/udlfb.c
52724 @@ -623,11 +623,11 @@ static int dlfb_handle_damage(struct dlfb_data *dev, int x, int y,
52725 dlfb_urb_completion(urb);
52726
52727 error:
52728 - atomic_add(bytes_sent, &dev->bytes_sent);
52729 - atomic_add(bytes_identical, &dev->bytes_identical);
52730 - atomic_add(width*height*2, &dev->bytes_rendered);
52731 + atomic_add_unchecked(bytes_sent, &dev->bytes_sent);
52732 + atomic_add_unchecked(bytes_identical, &dev->bytes_identical);
52733 + atomic_add_unchecked(width*height*2, &dev->bytes_rendered);
52734 end_cycles = get_cycles();
52735 - atomic_add(((unsigned int) ((end_cycles - start_cycles)
52736 + atomic_add_unchecked(((unsigned int) ((end_cycles - start_cycles)
52737 >> 10)), /* Kcycles */
52738 &dev->cpu_kcycles_used);
52739
52740 @@ -748,11 +748,11 @@ static void dlfb_dpy_deferred_io(struct fb_info *info,
52741 dlfb_urb_completion(urb);
52742
52743 error:
52744 - atomic_add(bytes_sent, &dev->bytes_sent);
52745 - atomic_add(bytes_identical, &dev->bytes_identical);
52746 - atomic_add(bytes_rendered, &dev->bytes_rendered);
52747 + atomic_add_unchecked(bytes_sent, &dev->bytes_sent);
52748 + atomic_add_unchecked(bytes_identical, &dev->bytes_identical);
52749 + atomic_add_unchecked(bytes_rendered, &dev->bytes_rendered);
52750 end_cycles = get_cycles();
52751 - atomic_add(((unsigned int) ((end_cycles - start_cycles)
52752 + atomic_add_unchecked(((unsigned int) ((end_cycles - start_cycles)
52753 >> 10)), /* Kcycles */
52754 &dev->cpu_kcycles_used);
52755 }
52756 @@ -993,7 +993,9 @@ static int dlfb_ops_release(struct fb_info *info, int user)
52757 fb_deferred_io_cleanup(info);
52758 kfree(info->fbdefio);
52759 info->fbdefio = NULL;
52760 - info->fbops->fb_mmap = dlfb_ops_mmap;
52761 + pax_open_kernel();
52762 + *(void **)&info->fbops->fb_mmap = dlfb_ops_mmap;
52763 + pax_close_kernel();
52764 }
52765
52766 pr_warn("released /dev/fb%d user=%d count=%d\n",
52767 @@ -1376,7 +1378,7 @@ static ssize_t metrics_bytes_rendered_show(struct device *fbdev,
52768 struct fb_info *fb_info = dev_get_drvdata(fbdev);
52769 struct dlfb_data *dev = fb_info->par;
52770 return snprintf(buf, PAGE_SIZE, "%u\n",
52771 - atomic_read(&dev->bytes_rendered));
52772 + atomic_read_unchecked(&dev->bytes_rendered));
52773 }
52774
52775 static ssize_t metrics_bytes_identical_show(struct device *fbdev,
52776 @@ -1384,7 +1386,7 @@ static ssize_t metrics_bytes_identical_show(struct device *fbdev,
52777 struct fb_info *fb_info = dev_get_drvdata(fbdev);
52778 struct dlfb_data *dev = fb_info->par;
52779 return snprintf(buf, PAGE_SIZE, "%u\n",
52780 - atomic_read(&dev->bytes_identical));
52781 + atomic_read_unchecked(&dev->bytes_identical));
52782 }
52783
52784 static ssize_t metrics_bytes_sent_show(struct device *fbdev,
52785 @@ -1392,7 +1394,7 @@ static ssize_t metrics_bytes_sent_show(struct device *fbdev,
52786 struct fb_info *fb_info = dev_get_drvdata(fbdev);
52787 struct dlfb_data *dev = fb_info->par;
52788 return snprintf(buf, PAGE_SIZE, "%u\n",
52789 - atomic_read(&dev->bytes_sent));
52790 + atomic_read_unchecked(&dev->bytes_sent));
52791 }
52792
52793 static ssize_t metrics_cpu_kcycles_used_show(struct device *fbdev,
52794 @@ -1400,7 +1402,7 @@ static ssize_t metrics_cpu_kcycles_used_show(struct device *fbdev,
52795 struct fb_info *fb_info = dev_get_drvdata(fbdev);
52796 struct dlfb_data *dev = fb_info->par;
52797 return snprintf(buf, PAGE_SIZE, "%u\n",
52798 - atomic_read(&dev->cpu_kcycles_used));
52799 + atomic_read_unchecked(&dev->cpu_kcycles_used));
52800 }
52801
52802 static ssize_t edid_show(
52803 @@ -1460,10 +1462,10 @@ static ssize_t metrics_reset_store(struct device *fbdev,
52804 struct fb_info *fb_info = dev_get_drvdata(fbdev);
52805 struct dlfb_data *dev = fb_info->par;
52806
52807 - atomic_set(&dev->bytes_rendered, 0);
52808 - atomic_set(&dev->bytes_identical, 0);
52809 - atomic_set(&dev->bytes_sent, 0);
52810 - atomic_set(&dev->cpu_kcycles_used, 0);
52811 + atomic_set_unchecked(&dev->bytes_rendered, 0);
52812 + atomic_set_unchecked(&dev->bytes_identical, 0);
52813 + atomic_set_unchecked(&dev->bytes_sent, 0);
52814 + atomic_set_unchecked(&dev->cpu_kcycles_used, 0);
52815
52816 return count;
52817 }
52818 diff --git a/drivers/video/fbdev/uvesafb.c b/drivers/video/fbdev/uvesafb.c
52819 index 509d452..7c9d2de 100644
52820 --- a/drivers/video/fbdev/uvesafb.c
52821 +++ b/drivers/video/fbdev/uvesafb.c
52822 @@ -19,6 +19,7 @@
52823 #include <linux/io.h>
52824 #include <linux/mutex.h>
52825 #include <linux/slab.h>
52826 +#include <linux/moduleloader.h>
52827 #include <video/edid.h>
52828 #include <video/uvesafb.h>
52829 #ifdef CONFIG_X86
52830 @@ -565,10 +566,32 @@ static int uvesafb_vbe_getpmi(struct uvesafb_ktask *task,
52831 if ((task->t.regs.eax & 0xffff) != 0x4f || task->t.regs.es < 0xc000) {
52832 par->pmi_setpal = par->ypan = 0;
52833 } else {
52834 +
52835 +#ifdef CONFIG_PAX_KERNEXEC
52836 +#ifdef CONFIG_MODULES
52837 + par->pmi_code = module_alloc_exec((u16)task->t.regs.ecx);
52838 +#endif
52839 + if (!par->pmi_code) {
52840 + par->pmi_setpal = par->ypan = 0;
52841 + return 0;
52842 + }
52843 +#endif
52844 +
52845 par->pmi_base = (u16 *)phys_to_virt(((u32)task->t.regs.es << 4)
52846 + task->t.regs.edi);
52847 +
52848 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
52849 + pax_open_kernel();
52850 + memcpy(par->pmi_code, par->pmi_base, (u16)task->t.regs.ecx);
52851 + pax_close_kernel();
52852 +
52853 + par->pmi_start = ktva_ktla(par->pmi_code + par->pmi_base[1]);
52854 + par->pmi_pal = ktva_ktla(par->pmi_code + par->pmi_base[2]);
52855 +#else
52856 par->pmi_start = (u8 *)par->pmi_base + par->pmi_base[1];
52857 par->pmi_pal = (u8 *)par->pmi_base + par->pmi_base[2];
52858 +#endif
52859 +
52860 printk(KERN_INFO "uvesafb: protected mode interface info at "
52861 "%04x:%04x\n",
52862 (u16)task->t.regs.es, (u16)task->t.regs.edi);
52863 @@ -813,13 +836,14 @@ static int uvesafb_vbe_init(struct fb_info *info)
52864 par->ypan = ypan;
52865
52866 if (par->pmi_setpal || par->ypan) {
52867 +#if !defined(CONFIG_MODULES) || !defined(CONFIG_PAX_KERNEXEC)
52868 if (__supported_pte_mask & _PAGE_NX) {
52869 par->pmi_setpal = par->ypan = 0;
52870 printk(KERN_WARNING "uvesafb: NX protection is active, "
52871 "better not use the PMI.\n");
52872 - } else {
52873 + } else
52874 +#endif
52875 uvesafb_vbe_getpmi(task, par);
52876 - }
52877 }
52878 #else
52879 /* The protected mode interface is not available on non-x86. */
52880 @@ -1453,8 +1477,11 @@ static void uvesafb_init_info(struct fb_info *info, struct vbe_mode_ib *mode)
52881 info->fix.ywrapstep = (par->ypan > 1) ? 1 : 0;
52882
52883 /* Disable blanking if the user requested so. */
52884 - if (!blank)
52885 - info->fbops->fb_blank = NULL;
52886 + if (!blank) {
52887 + pax_open_kernel();
52888 + *(void **)&info->fbops->fb_blank = NULL;
52889 + pax_close_kernel();
52890 + }
52891
52892 /*
52893 * Find out how much IO memory is required for the mode with
52894 @@ -1525,8 +1552,11 @@ static void uvesafb_init_info(struct fb_info *info, struct vbe_mode_ib *mode)
52895 info->flags = FBINFO_FLAG_DEFAULT |
52896 (par->ypan ? FBINFO_HWACCEL_YPAN : 0);
52897
52898 - if (!par->ypan)
52899 - info->fbops->fb_pan_display = NULL;
52900 + if (!par->ypan) {
52901 + pax_open_kernel();
52902 + *(void **)&info->fbops->fb_pan_display = NULL;
52903 + pax_close_kernel();
52904 + }
52905 }
52906
52907 static void uvesafb_init_mtrr(struct fb_info *info)
52908 @@ -1787,6 +1817,11 @@ out_mode:
52909 out:
52910 kfree(par->vbe_modes);
52911
52912 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
52913 + if (par->pmi_code)
52914 + module_free_exec(NULL, par->pmi_code);
52915 +#endif
52916 +
52917 framebuffer_release(info);
52918 return err;
52919 }
52920 @@ -1811,6 +1846,11 @@ static int uvesafb_remove(struct platform_device *dev)
52921 kfree(par->vbe_state_orig);
52922 kfree(par->vbe_state_saved);
52923
52924 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
52925 + if (par->pmi_code)
52926 + module_free_exec(NULL, par->pmi_code);
52927 +#endif
52928 +
52929 framebuffer_release(info);
52930 }
52931 return 0;
52932 diff --git a/drivers/video/fbdev/vesafb.c b/drivers/video/fbdev/vesafb.c
52933 index 6170e7f..dd63031 100644
52934 --- a/drivers/video/fbdev/vesafb.c
52935 +++ b/drivers/video/fbdev/vesafb.c
52936 @@ -9,6 +9,7 @@
52937 */
52938
52939 #include <linux/module.h>
52940 +#include <linux/moduleloader.h>
52941 #include <linux/kernel.h>
52942 #include <linux/errno.h>
52943 #include <linux/string.h>
52944 @@ -52,8 +53,8 @@ static int vram_remap; /* Set amount of memory to be used */
52945 static int vram_total; /* Set total amount of memory */
52946 static int pmi_setpal __read_mostly = 1; /* pmi for palette changes ??? */
52947 static int ypan __read_mostly; /* 0..nothing, 1..ypan, 2..ywrap */
52948 -static void (*pmi_start)(void) __read_mostly;
52949 -static void (*pmi_pal) (void) __read_mostly;
52950 +static void (*pmi_start)(void) __read_only;
52951 +static void (*pmi_pal) (void) __read_only;
52952 static int depth __read_mostly;
52953 static int vga_compat __read_mostly;
52954 /* --------------------------------------------------------------------- */
52955 @@ -233,6 +234,7 @@ static int vesafb_probe(struct platform_device *dev)
52956 unsigned int size_remap;
52957 unsigned int size_total;
52958 char *option = NULL;
52959 + void *pmi_code = NULL;
52960
52961 /* ignore error return of fb_get_options */
52962 fb_get_options("vesafb", &option);
52963 @@ -279,10 +281,6 @@ static int vesafb_probe(struct platform_device *dev)
52964 size_remap = size_total;
52965 vesafb_fix.smem_len = size_remap;
52966
52967 -#ifndef __i386__
52968 - screen_info.vesapm_seg = 0;
52969 -#endif
52970 -
52971 if (!request_mem_region(vesafb_fix.smem_start, size_total, "vesafb")) {
52972 printk(KERN_WARNING
52973 "vesafb: cannot reserve video memory at 0x%lx\n",
52974 @@ -312,9 +310,21 @@ static int vesafb_probe(struct platform_device *dev)
52975 printk(KERN_INFO "vesafb: mode is %dx%dx%d, linelength=%d, pages=%d\n",
52976 vesafb_defined.xres, vesafb_defined.yres, vesafb_defined.bits_per_pixel, vesafb_fix.line_length, screen_info.pages);
52977
52978 +#ifdef __i386__
52979 +
52980 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
52981 + pmi_code = module_alloc_exec(screen_info.vesapm_size);
52982 + if (!pmi_code)
52983 +#elif !defined(CONFIG_PAX_KERNEXEC)
52984 + if (0)
52985 +#endif
52986 +
52987 +#endif
52988 + screen_info.vesapm_seg = 0;
52989 +
52990 if (screen_info.vesapm_seg) {
52991 - printk(KERN_INFO "vesafb: protected mode interface info at %04x:%04x\n",
52992 - screen_info.vesapm_seg,screen_info.vesapm_off);
52993 + printk(KERN_INFO "vesafb: protected mode interface info at %04x:%04x %04x bytes\n",
52994 + screen_info.vesapm_seg,screen_info.vesapm_off,screen_info.vesapm_size);
52995 }
52996
52997 if (screen_info.vesapm_seg < 0xc000)
52998 @@ -322,9 +332,25 @@ static int vesafb_probe(struct platform_device *dev)
52999
53000 if (ypan || pmi_setpal) {
53001 unsigned short *pmi_base;
53002 +
53003 pmi_base = (unsigned short*)phys_to_virt(((unsigned long)screen_info.vesapm_seg << 4) + screen_info.vesapm_off);
53004 - pmi_start = (void*)((char*)pmi_base + pmi_base[1]);
53005 - pmi_pal = (void*)((char*)pmi_base + pmi_base[2]);
53006 +
53007 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
53008 + pax_open_kernel();
53009 + memcpy(pmi_code, pmi_base, screen_info.vesapm_size);
53010 +#else
53011 + pmi_code = pmi_base;
53012 +#endif
53013 +
53014 + pmi_start = (void*)((char*)pmi_code + pmi_base[1]);
53015 + pmi_pal = (void*)((char*)pmi_code + pmi_base[2]);
53016 +
53017 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
53018 + pmi_start = ktva_ktla(pmi_start);
53019 + pmi_pal = ktva_ktla(pmi_pal);
53020 + pax_close_kernel();
53021 +#endif
53022 +
53023 printk(KERN_INFO "vesafb: pmi: set display start = %p, set palette = %p\n",pmi_start,pmi_pal);
53024 if (pmi_base[3]) {
53025 printk(KERN_INFO "vesafb: pmi: ports = ");
53026 @@ -477,8 +503,11 @@ static int vesafb_probe(struct platform_device *dev)
53027 info->flags = FBINFO_FLAG_DEFAULT | FBINFO_MISC_FIRMWARE |
53028 (ypan ? FBINFO_HWACCEL_YPAN : 0);
53029
53030 - if (!ypan)
53031 - info->fbops->fb_pan_display = NULL;
53032 + if (!ypan) {
53033 + pax_open_kernel();
53034 + *(void **)&info->fbops->fb_pan_display = NULL;
53035 + pax_close_kernel();
53036 + }
53037
53038 if (fb_alloc_cmap(&info->cmap, 256, 0) < 0) {
53039 err = -ENOMEM;
53040 @@ -492,6 +521,11 @@ static int vesafb_probe(struct platform_device *dev)
53041 fb_info(info, "%s frame buffer device\n", info->fix.id);
53042 return 0;
53043 err:
53044 +
53045 +#if defined(__i386__) && defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
53046 + module_free_exec(NULL, pmi_code);
53047 +#endif
53048 +
53049 if (info->screen_base)
53050 iounmap(info->screen_base);
53051 framebuffer_release(info);
53052 diff --git a/drivers/video/fbdev/via/via_clock.h b/drivers/video/fbdev/via/via_clock.h
53053 index 88714ae..16c2e11 100644
53054 --- a/drivers/video/fbdev/via/via_clock.h
53055 +++ b/drivers/video/fbdev/via/via_clock.h
53056 @@ -56,7 +56,7 @@ struct via_clock {
53057
53058 void (*set_engine_pll_state)(u8 state);
53059 void (*set_engine_pll)(struct via_pll_config config);
53060 -};
53061 +} __no_const;
53062
53063
53064 static inline u32 get_pll_internal_frequency(u32 ref_freq,
53065 diff --git a/drivers/video/logo/logo_linux_clut224.ppm b/drivers/video/logo/logo_linux_clut224.ppm
53066 index 3c14e43..2630570 100644
53067 --- a/drivers/video/logo/logo_linux_clut224.ppm
53068 +++ b/drivers/video/logo/logo_linux_clut224.ppm
53069 @@ -2,1603 +2,1123 @@ P3
53070 # Standard 224-color Linux logo
53071 80 80
53072 255
53073 - 0 0 0 0 0 0 0 0 0 0 0 0
53074 - 0 0 0 0 0 0 0 0 0 0 0 0
53075 - 0 0 0 0 0 0 0 0 0 0 0 0
53076 - 0 0 0 0 0 0 0 0 0 0 0 0
53077 - 0 0 0 0 0 0 0 0 0 0 0 0
53078 - 0 0 0 0 0 0 0 0 0 0 0 0
53079 - 0 0 0 0 0 0 0 0 0 0 0 0
53080 - 0 0 0 0 0 0 0 0 0 0 0 0
53081 - 0 0 0 0 0 0 0 0 0 0 0 0
53082 - 6 6 6 6 6 6 10 10 10 10 10 10
53083 - 10 10 10 6 6 6 6 6 6 6 6 6
53084 - 0 0 0 0 0 0 0 0 0 0 0 0
53085 - 0 0 0 0 0 0 0 0 0 0 0 0
53086 - 0 0 0 0 0 0 0 0 0 0 0 0
53087 - 0 0 0 0 0 0 0 0 0 0 0 0
53088 - 0 0 0 0 0 0 0 0 0 0 0 0
53089 - 0 0 0 0 0 0 0 0 0 0 0 0
53090 - 0 0 0 0 0 0 0 0 0 0 0 0
53091 - 0 0 0 0 0 0 0 0 0 0 0 0
53092 - 0 0 0 0 0 0 0 0 0 0 0 0
53093 - 0 0 0 0 0 0 0 0 0 0 0 0
53094 - 0 0 0 0 0 0 0 0 0 0 0 0
53095 - 0 0 0 0 0 0 0 0 0 0 0 0
53096 - 0 0 0 0 0 0 0 0 0 0 0 0
53097 - 0 0 0 0 0 0 0 0 0 0 0 0
53098 - 0 0 0 0 0 0 0 0 0 0 0 0
53099 - 0 0 0 0 0 0 0 0 0 0 0 0
53100 - 0 0 0 0 0 0 0 0 0 0 0 0
53101 - 0 0 0 6 6 6 10 10 10 14 14 14
53102 - 22 22 22 26 26 26 30 30 30 34 34 34
53103 - 30 30 30 30 30 30 26 26 26 18 18 18
53104 - 14 14 14 10 10 10 6 6 6 0 0 0
53105 - 0 0 0 0 0 0 0 0 0 0 0 0
53106 - 0 0 0 0 0 0 0 0 0 0 0 0
53107 - 0 0 0 0 0 0 0 0 0 0 0 0
53108 - 0 0 0 0 0 0 0 0 0 0 0 0
53109 - 0 0 0 0 0 0 0 0 0 0 0 0
53110 - 0 0 0 0 0 0 0 0 0 0 0 0
53111 - 0 0 0 0 0 0 0 0 0 0 0 0
53112 - 0 0 0 0 0 0 0 0 0 0 0 0
53113 - 0 0 0 0 0 0 0 0 0 0 0 0
53114 - 0 0 0 0 0 1 0 0 1 0 0 0
53115 - 0 0 0 0 0 0 0 0 0 0 0 0
53116 - 0 0 0 0 0 0 0 0 0 0 0 0
53117 - 0 0 0 0 0 0 0 0 0 0 0 0
53118 - 0 0 0 0 0 0 0 0 0 0 0 0
53119 - 0 0 0 0 0 0 0 0 0 0 0 0
53120 - 0 0 0 0 0 0 0 0 0 0 0 0
53121 - 6 6 6 14 14 14 26 26 26 42 42 42
53122 - 54 54 54 66 66 66 78 78 78 78 78 78
53123 - 78 78 78 74 74 74 66 66 66 54 54 54
53124 - 42 42 42 26 26 26 18 18 18 10 10 10
53125 - 6 6 6 0 0 0 0 0 0 0 0 0
53126 - 0 0 0 0 0 0 0 0 0 0 0 0
53127 - 0 0 0 0 0 0 0 0 0 0 0 0
53128 - 0 0 0 0 0 0 0 0 0 0 0 0
53129 - 0 0 0 0 0 0 0 0 0 0 0 0
53130 - 0 0 0 0 0 0 0 0 0 0 0 0
53131 - 0 0 0 0 0 0 0 0 0 0 0 0
53132 - 0 0 0 0 0 0 0 0 0 0 0 0
53133 - 0 0 0 0 0 0 0 0 0 0 0 0
53134 - 0 0 1 0 0 0 0 0 0 0 0 0
53135 - 0 0 0 0 0 0 0 0 0 0 0 0
53136 - 0 0 0 0 0 0 0 0 0 0 0 0
53137 - 0 0 0 0 0 0 0 0 0 0 0 0
53138 - 0 0 0 0 0 0 0 0 0 0 0 0
53139 - 0 0 0 0 0 0 0 0 0 0 0 0
53140 - 0 0 0 0 0 0 0 0 0 10 10 10
53141 - 22 22 22 42 42 42 66 66 66 86 86 86
53142 - 66 66 66 38 38 38 38 38 38 22 22 22
53143 - 26 26 26 34 34 34 54 54 54 66 66 66
53144 - 86 86 86 70 70 70 46 46 46 26 26 26
53145 - 14 14 14 6 6 6 0 0 0 0 0 0
53146 - 0 0 0 0 0 0 0 0 0 0 0 0
53147 - 0 0 0 0 0 0 0 0 0 0 0 0
53148 - 0 0 0 0 0 0 0 0 0 0 0 0
53149 - 0 0 0 0 0 0 0 0 0 0 0 0
53150 - 0 0 0 0 0 0 0 0 0 0 0 0
53151 - 0 0 0 0 0 0 0 0 0 0 0 0
53152 - 0 0 0 0 0 0 0 0 0 0 0 0
53153 - 0 0 0 0 0 0 0 0 0 0 0 0
53154 - 0 0 1 0 0 1 0 0 1 0 0 0
53155 - 0 0 0 0 0 0 0 0 0 0 0 0
53156 - 0 0 0 0 0 0 0 0 0 0 0 0
53157 - 0 0 0 0 0 0 0 0 0 0 0 0
53158 - 0 0 0 0 0 0 0 0 0 0 0 0
53159 - 0 0 0 0 0 0 0 0 0 0 0 0
53160 - 0 0 0 0 0 0 10 10 10 26 26 26
53161 - 50 50 50 82 82 82 58 58 58 6 6 6
53162 - 2 2 6 2 2 6 2 2 6 2 2 6
53163 - 2 2 6 2 2 6 2 2 6 2 2 6
53164 - 6 6 6 54 54 54 86 86 86 66 66 66
53165 - 38 38 38 18 18 18 6 6 6 0 0 0
53166 - 0 0 0 0 0 0 0 0 0 0 0 0
53167 - 0 0 0 0 0 0 0 0 0 0 0 0
53168 - 0 0 0 0 0 0 0 0 0 0 0 0
53169 - 0 0 0 0 0 0 0 0 0 0 0 0
53170 - 0 0 0 0 0 0 0 0 0 0 0 0
53171 - 0 0 0 0 0 0 0 0 0 0 0 0
53172 - 0 0 0 0 0 0 0 0 0 0 0 0
53173 - 0 0 0 0 0 0 0 0 0 0 0 0
53174 - 0 0 0 0 0 0 0 0 0 0 0 0
53175 - 0 0 0 0 0 0 0 0 0 0 0 0
53176 - 0 0 0 0 0 0 0 0 0 0 0 0
53177 - 0 0 0 0 0 0 0 0 0 0 0 0
53178 - 0 0 0 0 0 0 0 0 0 0 0 0
53179 - 0 0 0 0 0 0 0 0 0 0 0 0
53180 - 0 0 0 6 6 6 22 22 22 50 50 50
53181 - 78 78 78 34 34 34 2 2 6 2 2 6
53182 - 2 2 6 2 2 6 2 2 6 2 2 6
53183 - 2 2 6 2 2 6 2 2 6 2 2 6
53184 - 2 2 6 2 2 6 6 6 6 70 70 70
53185 - 78 78 78 46 46 46 22 22 22 6 6 6
53186 - 0 0 0 0 0 0 0 0 0 0 0 0
53187 - 0 0 0 0 0 0 0 0 0 0 0 0
53188 - 0 0 0 0 0 0 0 0 0 0 0 0
53189 - 0 0 0 0 0 0 0 0 0 0 0 0
53190 - 0 0 0 0 0 0 0 0 0 0 0 0
53191 - 0 0 0 0 0 0 0 0 0 0 0 0
53192 - 0 0 0 0 0 0 0 0 0 0 0 0
53193 - 0 0 0 0 0 0 0 0 0 0 0 0
53194 - 0 0 1 0 0 1 0 0 1 0 0 0
53195 - 0 0 0 0 0 0 0 0 0 0 0 0
53196 - 0 0 0 0 0 0 0 0 0 0 0 0
53197 - 0 0 0 0 0 0 0 0 0 0 0 0
53198 - 0 0 0 0 0 0 0 0 0 0 0 0
53199 - 0 0 0 0 0 0 0 0 0 0 0 0
53200 - 6 6 6 18 18 18 42 42 42 82 82 82
53201 - 26 26 26 2 2 6 2 2 6 2 2 6
53202 - 2 2 6 2 2 6 2 2 6 2 2 6
53203 - 2 2 6 2 2 6 2 2 6 14 14 14
53204 - 46 46 46 34 34 34 6 6 6 2 2 6
53205 - 42 42 42 78 78 78 42 42 42 18 18 18
53206 - 6 6 6 0 0 0 0 0 0 0 0 0
53207 - 0 0 0 0 0 0 0 0 0 0 0 0
53208 - 0 0 0 0 0 0 0 0 0 0 0 0
53209 - 0 0 0 0 0 0 0 0 0 0 0 0
53210 - 0 0 0 0 0 0 0 0 0 0 0 0
53211 - 0 0 0 0 0 0 0 0 0 0 0 0
53212 - 0 0 0 0 0 0 0 0 0 0 0 0
53213 - 0 0 0 0 0 0 0 0 0 0 0 0
53214 - 0 0 1 0 0 0 0 0 1 0 0 0
53215 - 0 0 0 0 0 0 0 0 0 0 0 0
53216 - 0 0 0 0 0 0 0 0 0 0 0 0
53217 - 0 0 0 0 0 0 0 0 0 0 0 0
53218 - 0 0 0 0 0 0 0 0 0 0 0 0
53219 - 0 0 0 0 0 0 0 0 0 0 0 0
53220 - 10 10 10 30 30 30 66 66 66 58 58 58
53221 - 2 2 6 2 2 6 2 2 6 2 2 6
53222 - 2 2 6 2 2 6 2 2 6 2 2 6
53223 - 2 2 6 2 2 6 2 2 6 26 26 26
53224 - 86 86 86 101 101 101 46 46 46 10 10 10
53225 - 2 2 6 58 58 58 70 70 70 34 34 34
53226 - 10 10 10 0 0 0 0 0 0 0 0 0
53227 - 0 0 0 0 0 0 0 0 0 0 0 0
53228 - 0 0 0 0 0 0 0 0 0 0 0 0
53229 - 0 0 0 0 0 0 0 0 0 0 0 0
53230 - 0 0 0 0 0 0 0 0 0 0 0 0
53231 - 0 0 0 0 0 0 0 0 0 0 0 0
53232 - 0 0 0 0 0 0 0 0 0 0 0 0
53233 - 0 0 0 0 0 0 0 0 0 0 0 0
53234 - 0 0 1 0 0 1 0 0 1 0 0 0
53235 - 0 0 0 0 0 0 0 0 0 0 0 0
53236 - 0 0 0 0 0 0 0 0 0 0 0 0
53237 - 0 0 0 0 0 0 0 0 0 0 0 0
53238 - 0 0 0 0 0 0 0 0 0 0 0 0
53239 - 0 0 0 0 0 0 0 0 0 0 0 0
53240 - 14 14 14 42 42 42 86 86 86 10 10 10
53241 - 2 2 6 2 2 6 2 2 6 2 2 6
53242 - 2 2 6 2 2 6 2 2 6 2 2 6
53243 - 2 2 6 2 2 6 2 2 6 30 30 30
53244 - 94 94 94 94 94 94 58 58 58 26 26 26
53245 - 2 2 6 6 6 6 78 78 78 54 54 54
53246 - 22 22 22 6 6 6 0 0 0 0 0 0
53247 - 0 0 0 0 0 0 0 0 0 0 0 0
53248 - 0 0 0 0 0 0 0 0 0 0 0 0
53249 - 0 0 0 0 0 0 0 0 0 0 0 0
53250 - 0 0 0 0 0 0 0 0 0 0 0 0
53251 - 0 0 0 0 0 0 0 0 0 0 0 0
53252 - 0 0 0 0 0 0 0 0 0 0 0 0
53253 - 0 0 0 0 0 0 0 0 0 0 0 0
53254 - 0 0 0 0 0 0 0 0 0 0 0 0
53255 - 0 0 0 0 0 0 0 0 0 0 0 0
53256 - 0 0 0 0 0 0 0 0 0 0 0 0
53257 - 0 0 0 0 0 0 0 0 0 0 0 0
53258 - 0 0 0 0 0 0 0 0 0 0 0 0
53259 - 0 0 0 0 0 0 0 0 0 6 6 6
53260 - 22 22 22 62 62 62 62 62 62 2 2 6
53261 - 2 2 6 2 2 6 2 2 6 2 2 6
53262 - 2 2 6 2 2 6 2 2 6 2 2 6
53263 - 2 2 6 2 2 6 2 2 6 26 26 26
53264 - 54 54 54 38 38 38 18 18 18 10 10 10
53265 - 2 2 6 2 2 6 34 34 34 82 82 82
53266 - 38 38 38 14 14 14 0 0 0 0 0 0
53267 - 0 0 0 0 0 0 0 0 0 0 0 0
53268 - 0 0 0 0 0 0 0 0 0 0 0 0
53269 - 0 0 0 0 0 0 0 0 0 0 0 0
53270 - 0 0 0 0 0 0 0 0 0 0 0 0
53271 - 0 0 0 0 0 0 0 0 0 0 0 0
53272 - 0 0 0 0 0 0 0 0 0 0 0 0
53273 - 0 0 0 0 0 0 0 0 0 0 0 0
53274 - 0 0 0 0 0 1 0 0 1 0 0 0
53275 - 0 0 0 0 0 0 0 0 0 0 0 0
53276 - 0 0 0 0 0 0 0 0 0 0 0 0
53277 - 0 0 0 0 0 0 0 0 0 0 0 0
53278 - 0 0 0 0 0 0 0 0 0 0 0 0
53279 - 0 0 0 0 0 0 0 0 0 6 6 6
53280 - 30 30 30 78 78 78 30 30 30 2 2 6
53281 - 2 2 6 2 2 6 2 2 6 2 2 6
53282 - 2 2 6 2 2 6 2 2 6 2 2 6
53283 - 2 2 6 2 2 6 2 2 6 10 10 10
53284 - 10 10 10 2 2 6 2 2 6 2 2 6
53285 - 2 2 6 2 2 6 2 2 6 78 78 78
53286 - 50 50 50 18 18 18 6 6 6 0 0 0
53287 - 0 0 0 0 0 0 0 0 0 0 0 0
53288 - 0 0 0 0 0 0 0 0 0 0 0 0
53289 - 0 0 0 0 0 0 0 0 0 0 0 0
53290 - 0 0 0 0 0 0 0 0 0 0 0 0
53291 - 0 0 0 0 0 0 0 0 0 0 0 0
53292 - 0 0 0 0 0 0 0 0 0 0 0 0
53293 - 0 0 0 0 0 0 0 0 0 0 0 0
53294 - 0 0 1 0 0 0 0 0 0 0 0 0
53295 - 0 0 0 0 0 0 0 0 0 0 0 0
53296 - 0 0 0 0 0 0 0 0 0 0 0 0
53297 - 0 0 0 0 0 0 0 0 0 0 0 0
53298 - 0 0 0 0 0 0 0 0 0 0 0 0
53299 - 0 0 0 0 0 0 0 0 0 10 10 10
53300 - 38 38 38 86 86 86 14 14 14 2 2 6
53301 - 2 2 6 2 2 6 2 2 6 2 2 6
53302 - 2 2 6 2 2 6 2 2 6 2 2 6
53303 - 2 2 6 2 2 6 2 2 6 2 2 6
53304 - 2 2 6 2 2 6 2 2 6 2 2 6
53305 - 2 2 6 2 2 6 2 2 6 54 54 54
53306 - 66 66 66 26 26 26 6 6 6 0 0 0
53307 - 0 0 0 0 0 0 0 0 0 0 0 0
53308 - 0 0 0 0 0 0 0 0 0 0 0 0
53309 - 0 0 0 0 0 0 0 0 0 0 0 0
53310 - 0 0 0 0 0 0 0 0 0 0 0 0
53311 - 0 0 0 0 0 0 0 0 0 0 0 0
53312 - 0 0 0 0 0 0 0 0 0 0 0 0
53313 - 0 0 0 0 0 0 0 0 0 0 0 0
53314 - 0 0 0 0 0 1 0 0 1 0 0 0
53315 - 0 0 0 0 0 0 0 0 0 0 0 0
53316 - 0 0 0 0 0 0 0 0 0 0 0 0
53317 - 0 0 0 0 0 0 0 0 0 0 0 0
53318 - 0 0 0 0 0 0 0 0 0 0 0 0
53319 - 0 0 0 0 0 0 0 0 0 14 14 14
53320 - 42 42 42 82 82 82 2 2 6 2 2 6
53321 - 2 2 6 6 6 6 10 10 10 2 2 6
53322 - 2 2 6 2 2 6 2 2 6 2 2 6
53323 - 2 2 6 2 2 6 2 2 6 6 6 6
53324 - 14 14 14 10 10 10 2 2 6 2 2 6
53325 - 2 2 6 2 2 6 2 2 6 18 18 18
53326 - 82 82 82 34 34 34 10 10 10 0 0 0
53327 - 0 0 0 0 0 0 0 0 0 0 0 0
53328 - 0 0 0 0 0 0 0 0 0 0 0 0
53329 - 0 0 0 0 0 0 0 0 0 0 0 0
53330 - 0 0 0 0 0 0 0 0 0 0 0 0
53331 - 0 0 0 0 0 0 0 0 0 0 0 0
53332 - 0 0 0 0 0 0 0 0 0 0 0 0
53333 - 0 0 0 0 0 0 0 0 0 0 0 0
53334 - 0 0 1 0 0 0 0 0 0 0 0 0
53335 - 0 0 0 0 0 0 0 0 0 0 0 0
53336 - 0 0 0 0 0 0 0 0 0 0 0 0
53337 - 0 0 0 0 0 0 0 0 0 0 0 0
53338 - 0 0 0 0 0 0 0 0 0 0 0 0
53339 - 0 0 0 0 0 0 0 0 0 14 14 14
53340 - 46 46 46 86 86 86 2 2 6 2 2 6
53341 - 6 6 6 6 6 6 22 22 22 34 34 34
53342 - 6 6 6 2 2 6 2 2 6 2 2 6
53343 - 2 2 6 2 2 6 18 18 18 34 34 34
53344 - 10 10 10 50 50 50 22 22 22 2 2 6
53345 - 2 2 6 2 2 6 2 2 6 10 10 10
53346 - 86 86 86 42 42 42 14 14 14 0 0 0
53347 - 0 0 0 0 0 0 0 0 0 0 0 0
53348 - 0 0 0 0 0 0 0 0 0 0 0 0
53349 - 0 0 0 0 0 0 0 0 0 0 0 0
53350 - 0 0 0 0 0 0 0 0 0 0 0 0
53351 - 0 0 0 0 0 0 0 0 0 0 0 0
53352 - 0 0 0 0 0 0 0 0 0 0 0 0
53353 - 0 0 0 0 0 0 0 0 0 0 0 0
53354 - 0 0 1 0 0 1 0 0 1 0 0 0
53355 - 0 0 0 0 0 0 0 0 0 0 0 0
53356 - 0 0 0 0 0 0 0 0 0 0 0 0
53357 - 0 0 0 0 0 0 0 0 0 0 0 0
53358 - 0 0 0 0 0 0 0 0 0 0 0 0
53359 - 0 0 0 0 0 0 0 0 0 14 14 14
53360 - 46 46 46 86 86 86 2 2 6 2 2 6
53361 - 38 38 38 116 116 116 94 94 94 22 22 22
53362 - 22 22 22 2 2 6 2 2 6 2 2 6
53363 - 14 14 14 86 86 86 138 138 138 162 162 162
53364 -154 154 154 38 38 38 26 26 26 6 6 6
53365 - 2 2 6 2 2 6 2 2 6 2 2 6
53366 - 86 86 86 46 46 46 14 14 14 0 0 0
53367 - 0 0 0 0 0 0 0 0 0 0 0 0
53368 - 0 0 0 0 0 0 0 0 0 0 0 0
53369 - 0 0 0 0 0 0 0 0 0 0 0 0
53370 - 0 0 0 0 0 0 0 0 0 0 0 0
53371 - 0 0 0 0 0 0 0 0 0 0 0 0
53372 - 0 0 0 0 0 0 0 0 0 0 0 0
53373 - 0 0 0 0 0 0 0 0 0 0 0 0
53374 - 0 0 0 0 0 0 0 0 0 0 0 0
53375 - 0 0 0 0 0 0 0 0 0 0 0 0
53376 - 0 0 0 0 0 0 0 0 0 0 0 0
53377 - 0 0 0 0 0 0 0 0 0 0 0 0
53378 - 0 0 0 0 0 0 0 0 0 0 0 0
53379 - 0 0 0 0 0 0 0 0 0 14 14 14
53380 - 46 46 46 86 86 86 2 2 6 14 14 14
53381 -134 134 134 198 198 198 195 195 195 116 116 116
53382 - 10 10 10 2 2 6 2 2 6 6 6 6
53383 -101 98 89 187 187 187 210 210 210 218 218 218
53384 -214 214 214 134 134 134 14 14 14 6 6 6
53385 - 2 2 6 2 2 6 2 2 6 2 2 6
53386 - 86 86 86 50 50 50 18 18 18 6 6 6
53387 - 0 0 0 0 0 0 0 0 0 0 0 0
53388 - 0 0 0 0 0 0 0 0 0 0 0 0
53389 - 0 0 0 0 0 0 0 0 0 0 0 0
53390 - 0 0 0 0 0 0 0 0 0 0 0 0
53391 - 0 0 0 0 0 0 0 0 0 0 0 0
53392 - 0 0 0 0 0 0 0 0 0 0 0 0
53393 - 0 0 0 0 0 0 0 0 1 0 0 0
53394 - 0 0 1 0 0 1 0 0 1 0 0 0
53395 - 0 0 0 0 0 0 0 0 0 0 0 0
53396 - 0 0 0 0 0 0 0 0 0 0 0 0
53397 - 0 0 0 0 0 0 0 0 0 0 0 0
53398 - 0 0 0 0 0 0 0 0 0 0 0 0
53399 - 0 0 0 0 0 0 0 0 0 14 14 14
53400 - 46 46 46 86 86 86 2 2 6 54 54 54
53401 -218 218 218 195 195 195 226 226 226 246 246 246
53402 - 58 58 58 2 2 6 2 2 6 30 30 30
53403 -210 210 210 253 253 253 174 174 174 123 123 123
53404 -221 221 221 234 234 234 74 74 74 2 2 6
53405 - 2 2 6 2 2 6 2 2 6 2 2 6
53406 - 70 70 70 58 58 58 22 22 22 6 6 6
53407 - 0 0 0 0 0 0 0 0 0 0 0 0
53408 - 0 0 0 0 0 0 0 0 0 0 0 0
53409 - 0 0 0 0 0 0 0 0 0 0 0 0
53410 - 0 0 0 0 0 0 0 0 0 0 0 0
53411 - 0 0 0 0 0 0 0 0 0 0 0 0
53412 - 0 0 0 0 0 0 0 0 0 0 0 0
53413 - 0 0 0 0 0 0 0 0 0 0 0 0
53414 - 0 0 0 0 0 0 0 0 0 0 0 0
53415 - 0 0 0 0 0 0 0 0 0 0 0 0
53416 - 0 0 0 0 0 0 0 0 0 0 0 0
53417 - 0 0 0 0 0 0 0 0 0 0 0 0
53418 - 0 0 0 0 0 0 0 0 0 0 0 0
53419 - 0 0 0 0 0 0 0 0 0 14 14 14
53420 - 46 46 46 82 82 82 2 2 6 106 106 106
53421 -170 170 170 26 26 26 86 86 86 226 226 226
53422 -123 123 123 10 10 10 14 14 14 46 46 46
53423 -231 231 231 190 190 190 6 6 6 70 70 70
53424 - 90 90 90 238 238 238 158 158 158 2 2 6
53425 - 2 2 6 2 2 6 2 2 6 2 2 6
53426 - 70 70 70 58 58 58 22 22 22 6 6 6
53427 - 0 0 0 0 0 0 0 0 0 0 0 0
53428 - 0 0 0 0 0 0 0 0 0 0 0 0
53429 - 0 0 0 0 0 0 0 0 0 0 0 0
53430 - 0 0 0 0 0 0 0 0 0 0 0 0
53431 - 0 0 0 0 0 0 0 0 0 0 0 0
53432 - 0 0 0 0 0 0 0 0 0 0 0 0
53433 - 0 0 0 0 0 0 0 0 1 0 0 0
53434 - 0 0 1 0 0 1 0 0 1 0 0 0
53435 - 0 0 0 0 0 0 0 0 0 0 0 0
53436 - 0 0 0 0 0 0 0 0 0 0 0 0
53437 - 0 0 0 0 0 0 0 0 0 0 0 0
53438 - 0 0 0 0 0 0 0 0 0 0 0 0
53439 - 0 0 0 0 0 0 0 0 0 14 14 14
53440 - 42 42 42 86 86 86 6 6 6 116 116 116
53441 -106 106 106 6 6 6 70 70 70 149 149 149
53442 -128 128 128 18 18 18 38 38 38 54 54 54
53443 -221 221 221 106 106 106 2 2 6 14 14 14
53444 - 46 46 46 190 190 190 198 198 198 2 2 6
53445 - 2 2 6 2 2 6 2 2 6 2 2 6
53446 - 74 74 74 62 62 62 22 22 22 6 6 6
53447 - 0 0 0 0 0 0 0 0 0 0 0 0
53448 - 0 0 0 0 0 0 0 0 0 0 0 0
53449 - 0 0 0 0 0 0 0 0 0 0 0 0
53450 - 0 0 0 0 0 0 0 0 0 0 0 0
53451 - 0 0 0 0 0 0 0 0 0 0 0 0
53452 - 0 0 0 0 0 0 0 0 0 0 0 0
53453 - 0 0 0 0 0 0 0 0 1 0 0 0
53454 - 0 0 1 0 0 0 0 0 1 0 0 0
53455 - 0 0 0 0 0 0 0 0 0 0 0 0
53456 - 0 0 0 0 0 0 0 0 0 0 0 0
53457 - 0 0 0 0 0 0 0 0 0 0 0 0
53458 - 0 0 0 0 0 0 0 0 0 0 0 0
53459 - 0 0 0 0 0 0 0 0 0 14 14 14
53460 - 42 42 42 94 94 94 14 14 14 101 101 101
53461 -128 128 128 2 2 6 18 18 18 116 116 116
53462 -118 98 46 121 92 8 121 92 8 98 78 10
53463 -162 162 162 106 106 106 2 2 6 2 2 6
53464 - 2 2 6 195 195 195 195 195 195 6 6 6
53465 - 2 2 6 2 2 6 2 2 6 2 2 6
53466 - 74 74 74 62 62 62 22 22 22 6 6 6
53467 - 0 0 0 0 0 0 0 0 0 0 0 0
53468 - 0 0 0 0 0 0 0 0 0 0 0 0
53469 - 0 0 0 0 0 0 0 0 0 0 0 0
53470 - 0 0 0 0 0 0 0 0 0 0 0 0
53471 - 0 0 0 0 0 0 0 0 0 0 0 0
53472 - 0 0 0 0 0 0 0 0 0 0 0 0
53473 - 0 0 0 0 0 0 0 0 1 0 0 1
53474 - 0 0 1 0 0 0 0 0 1 0 0 0
53475 - 0 0 0 0 0 0 0 0 0 0 0 0
53476 - 0 0 0 0 0 0 0 0 0 0 0 0
53477 - 0 0 0 0 0 0 0 0 0 0 0 0
53478 - 0 0 0 0 0 0 0 0 0 0 0 0
53479 - 0 0 0 0 0 0 0 0 0 10 10 10
53480 - 38 38 38 90 90 90 14 14 14 58 58 58
53481 -210 210 210 26 26 26 54 38 6 154 114 10
53482 -226 170 11 236 186 11 225 175 15 184 144 12
53483 -215 174 15 175 146 61 37 26 9 2 2 6
53484 - 70 70 70 246 246 246 138 138 138 2 2 6
53485 - 2 2 6 2 2 6 2 2 6 2 2 6
53486 - 70 70 70 66 66 66 26 26 26 6 6 6
53487 - 0 0 0 0 0 0 0 0 0 0 0 0
53488 - 0 0 0 0 0 0 0 0 0 0 0 0
53489 - 0 0 0 0 0 0 0 0 0 0 0 0
53490 - 0 0 0 0 0 0 0 0 0 0 0 0
53491 - 0 0 0 0 0 0 0 0 0 0 0 0
53492 - 0 0 0 0 0 0 0 0 0 0 0 0
53493 - 0 0 0 0 0 0 0 0 0 0 0 0
53494 - 0 0 0 0 0 0 0 0 0 0 0 0
53495 - 0 0 0 0 0 0 0 0 0 0 0 0
53496 - 0 0 0 0 0 0 0 0 0 0 0 0
53497 - 0 0 0 0 0 0 0 0 0 0 0 0
53498 - 0 0 0 0 0 0 0 0 0 0 0 0
53499 - 0 0 0 0 0 0 0 0 0 10 10 10
53500 - 38 38 38 86 86 86 14 14 14 10 10 10
53501 -195 195 195 188 164 115 192 133 9 225 175 15
53502 -239 182 13 234 190 10 232 195 16 232 200 30
53503 -245 207 45 241 208 19 232 195 16 184 144 12
53504 -218 194 134 211 206 186 42 42 42 2 2 6
53505 - 2 2 6 2 2 6 2 2 6 2 2 6
53506 - 50 50 50 74 74 74 30 30 30 6 6 6
53507 - 0 0 0 0 0 0 0 0 0 0 0 0
53508 - 0 0 0 0 0 0 0 0 0 0 0 0
53509 - 0 0 0 0 0 0 0 0 0 0 0 0
53510 - 0 0 0 0 0 0 0 0 0 0 0 0
53511 - 0 0 0 0 0 0 0 0 0 0 0 0
53512 - 0 0 0 0 0 0 0 0 0 0 0 0
53513 - 0 0 0 0 0 0 0 0 0 0 0 0
53514 - 0 0 0 0 0 0 0 0 0 0 0 0
53515 - 0 0 0 0 0 0 0 0 0 0 0 0
53516 - 0 0 0 0 0 0 0 0 0 0 0 0
53517 - 0 0 0 0 0 0 0 0 0 0 0 0
53518 - 0 0 0 0 0 0 0 0 0 0 0 0
53519 - 0 0 0 0 0 0 0 0 0 10 10 10
53520 - 34 34 34 86 86 86 14 14 14 2 2 6
53521 -121 87 25 192 133 9 219 162 10 239 182 13
53522 -236 186 11 232 195 16 241 208 19 244 214 54
53523 -246 218 60 246 218 38 246 215 20 241 208 19
53524 -241 208 19 226 184 13 121 87 25 2 2 6
53525 - 2 2 6 2 2 6 2 2 6 2 2 6
53526 - 50 50 50 82 82 82 34 34 34 10 10 10
53527 - 0 0 0 0 0 0 0 0 0 0 0 0
53528 - 0 0 0 0 0 0 0 0 0 0 0 0
53529 - 0 0 0 0 0 0 0 0 0 0 0 0
53530 - 0 0 0 0 0 0 0 0 0 0 0 0
53531 - 0 0 0 0 0 0 0 0 0 0 0 0
53532 - 0 0 0 0 0 0 0 0 0 0 0 0
53533 - 0 0 0 0 0 0 0 0 0 0 0 0
53534 - 0 0 0 0 0 0 0 0 0 0 0 0
53535 - 0 0 0 0 0 0 0 0 0 0 0 0
53536 - 0 0 0 0 0 0 0 0 0 0 0 0
53537 - 0 0 0 0 0 0 0 0 0 0 0 0
53538 - 0 0 0 0 0 0 0 0 0 0 0 0
53539 - 0 0 0 0 0 0 0 0 0 10 10 10
53540 - 34 34 34 82 82 82 30 30 30 61 42 6
53541 -180 123 7 206 145 10 230 174 11 239 182 13
53542 -234 190 10 238 202 15 241 208 19 246 218 74
53543 -246 218 38 246 215 20 246 215 20 246 215 20
53544 -226 184 13 215 174 15 184 144 12 6 6 6
53545 - 2 2 6 2 2 6 2 2 6 2 2 6
53546 - 26 26 26 94 94 94 42 42 42 14 14 14
53547 - 0 0 0 0 0 0 0 0 0 0 0 0
53548 - 0 0 0 0 0 0 0 0 0 0 0 0
53549 - 0 0 0 0 0 0 0 0 0 0 0 0
53550 - 0 0 0 0 0 0 0 0 0 0 0 0
53551 - 0 0 0 0 0 0 0 0 0 0 0 0
53552 - 0 0 0 0 0 0 0 0 0 0 0 0
53553 - 0 0 0 0 0 0 0 0 0 0 0 0
53554 - 0 0 0 0 0 0 0 0 0 0 0 0
53555 - 0 0 0 0 0 0 0 0 0 0 0 0
53556 - 0 0 0 0 0 0 0 0 0 0 0 0
53557 - 0 0 0 0 0 0 0 0 0 0 0 0
53558 - 0 0 0 0 0 0 0 0 0 0 0 0
53559 - 0 0 0 0 0 0 0 0 0 10 10 10
53560 - 30 30 30 78 78 78 50 50 50 104 69 6
53561 -192 133 9 216 158 10 236 178 12 236 186 11
53562 -232 195 16 241 208 19 244 214 54 245 215 43
53563 -246 215 20 246 215 20 241 208 19 198 155 10
53564 -200 144 11 216 158 10 156 118 10 2 2 6
53565 - 2 2 6 2 2 6 2 2 6 2 2 6
53566 - 6 6 6 90 90 90 54 54 54 18 18 18
53567 - 6 6 6 0 0 0 0 0 0 0 0 0
53568 - 0 0 0 0 0 0 0 0 0 0 0 0
53569 - 0 0 0 0 0 0 0 0 0 0 0 0
53570 - 0 0 0 0 0 0 0 0 0 0 0 0
53571 - 0 0 0 0 0 0 0 0 0 0 0 0
53572 - 0 0 0 0 0 0 0 0 0 0 0 0
53573 - 0 0 0 0 0 0 0 0 0 0 0 0
53574 - 0 0 0 0 0 0 0 0 0 0 0 0
53575 - 0 0 0 0 0 0 0 0 0 0 0 0
53576 - 0 0 0 0 0 0 0 0 0 0 0 0
53577 - 0 0 0 0 0 0 0 0 0 0 0 0
53578 - 0 0 0 0 0 0 0 0 0 0 0 0
53579 - 0 0 0 0 0 0 0 0 0 10 10 10
53580 - 30 30 30 78 78 78 46 46 46 22 22 22
53581 -137 92 6 210 162 10 239 182 13 238 190 10
53582 -238 202 15 241 208 19 246 215 20 246 215 20
53583 -241 208 19 203 166 17 185 133 11 210 150 10
53584 -216 158 10 210 150 10 102 78 10 2 2 6
53585 - 6 6 6 54 54 54 14 14 14 2 2 6
53586 - 2 2 6 62 62 62 74 74 74 30 30 30
53587 - 10 10 10 0 0 0 0 0 0 0 0 0
53588 - 0 0 0 0 0 0 0 0 0 0 0 0
53589 - 0 0 0 0 0 0 0 0 0 0 0 0
53590 - 0 0 0 0 0 0 0 0 0 0 0 0
53591 - 0 0 0 0 0 0 0 0 0 0 0 0
53592 - 0 0 0 0 0 0 0 0 0 0 0 0
53593 - 0 0 0 0 0 0 0 0 0 0 0 0
53594 - 0 0 0 0 0 0 0 0 0 0 0 0
53595 - 0 0 0 0 0 0 0 0 0 0 0 0
53596 - 0 0 0 0 0 0 0 0 0 0 0 0
53597 - 0 0 0 0 0 0 0 0 0 0 0 0
53598 - 0 0 0 0 0 0 0 0 0 0 0 0
53599 - 0 0 0 0 0 0 0 0 0 10 10 10
53600 - 34 34 34 78 78 78 50 50 50 6 6 6
53601 - 94 70 30 139 102 15 190 146 13 226 184 13
53602 -232 200 30 232 195 16 215 174 15 190 146 13
53603 -168 122 10 192 133 9 210 150 10 213 154 11
53604 -202 150 34 182 157 106 101 98 89 2 2 6
53605 - 2 2 6 78 78 78 116 116 116 58 58 58
53606 - 2 2 6 22 22 22 90 90 90 46 46 46
53607 - 18 18 18 6 6 6 0 0 0 0 0 0
53608 - 0 0 0 0 0 0 0 0 0 0 0 0
53609 - 0 0 0 0 0 0 0 0 0 0 0 0
53610 - 0 0 0 0 0 0 0 0 0 0 0 0
53611 - 0 0 0 0 0 0 0 0 0 0 0 0
53612 - 0 0 0 0 0 0 0 0 0 0 0 0
53613 - 0 0 0 0 0 0 0 0 0 0 0 0
53614 - 0 0 0 0 0 0 0 0 0 0 0 0
53615 - 0 0 0 0 0 0 0 0 0 0 0 0
53616 - 0 0 0 0 0 0 0 0 0 0 0 0
53617 - 0 0 0 0 0 0 0 0 0 0 0 0
53618 - 0 0 0 0 0 0 0 0 0 0 0 0
53619 - 0 0 0 0 0 0 0 0 0 10 10 10
53620 - 38 38 38 86 86 86 50 50 50 6 6 6
53621 -128 128 128 174 154 114 156 107 11 168 122 10
53622 -198 155 10 184 144 12 197 138 11 200 144 11
53623 -206 145 10 206 145 10 197 138 11 188 164 115
53624 -195 195 195 198 198 198 174 174 174 14 14 14
53625 - 2 2 6 22 22 22 116 116 116 116 116 116
53626 - 22 22 22 2 2 6 74 74 74 70 70 70
53627 - 30 30 30 10 10 10 0 0 0 0 0 0
53628 - 0 0 0 0 0 0 0 0 0 0 0 0
53629 - 0 0 0 0 0 0 0 0 0 0 0 0
53630 - 0 0 0 0 0 0 0 0 0 0 0 0
53631 - 0 0 0 0 0 0 0 0 0 0 0 0
53632 - 0 0 0 0 0 0 0 0 0 0 0 0
53633 - 0 0 0 0 0 0 0 0 0 0 0 0
53634 - 0 0 0 0 0 0 0 0 0 0 0 0
53635 - 0 0 0 0 0 0 0 0 0 0 0 0
53636 - 0 0 0 0 0 0 0 0 0 0 0 0
53637 - 0 0 0 0 0 0 0 0 0 0 0 0
53638 - 0 0 0 0 0 0 0 0 0 0 0 0
53639 - 0 0 0 0 0 0 6 6 6 18 18 18
53640 - 50 50 50 101 101 101 26 26 26 10 10 10
53641 -138 138 138 190 190 190 174 154 114 156 107 11
53642 -197 138 11 200 144 11 197 138 11 192 133 9
53643 -180 123 7 190 142 34 190 178 144 187 187 187
53644 -202 202 202 221 221 221 214 214 214 66 66 66
53645 - 2 2 6 2 2 6 50 50 50 62 62 62
53646 - 6 6 6 2 2 6 10 10 10 90 90 90
53647 - 50 50 50 18 18 18 6 6 6 0 0 0
53648 - 0 0 0 0 0 0 0 0 0 0 0 0
53649 - 0 0 0 0 0 0 0 0 0 0 0 0
53650 - 0 0 0 0 0 0 0 0 0 0 0 0
53651 - 0 0 0 0 0 0 0 0 0 0 0 0
53652 - 0 0 0 0 0 0 0 0 0 0 0 0
53653 - 0 0 0 0 0 0 0 0 0 0 0 0
53654 - 0 0 0 0 0 0 0 0 0 0 0 0
53655 - 0 0 0 0 0 0 0 0 0 0 0 0
53656 - 0 0 0 0 0 0 0 0 0 0 0 0
53657 - 0 0 0 0 0 0 0 0 0 0 0 0
53658 - 0 0 0 0 0 0 0 0 0 0 0 0
53659 - 0 0 0 0 0 0 10 10 10 34 34 34
53660 - 74 74 74 74 74 74 2 2 6 6 6 6
53661 -144 144 144 198 198 198 190 190 190 178 166 146
53662 -154 121 60 156 107 11 156 107 11 168 124 44
53663 -174 154 114 187 187 187 190 190 190 210 210 210
53664 -246 246 246 253 253 253 253 253 253 182 182 182
53665 - 6 6 6 2 2 6 2 2 6 2 2 6
53666 - 2 2 6 2 2 6 2 2 6 62 62 62
53667 - 74 74 74 34 34 34 14 14 14 0 0 0
53668 - 0 0 0 0 0 0 0 0 0 0 0 0
53669 - 0 0 0 0 0 0 0 0 0 0 0 0
53670 - 0 0 0 0 0 0 0 0 0 0 0 0
53671 - 0 0 0 0 0 0 0 0 0 0 0 0
53672 - 0 0 0 0 0 0 0 0 0 0 0 0
53673 - 0 0 0 0 0 0 0 0 0 0 0 0
53674 - 0 0 0 0 0 0 0 0 0 0 0 0
53675 - 0 0 0 0 0 0 0 0 0 0 0 0
53676 - 0 0 0 0 0 0 0 0 0 0 0 0
53677 - 0 0 0 0 0 0 0 0 0 0 0 0
53678 - 0 0 0 0 0 0 0 0 0 0 0 0
53679 - 0 0 0 10 10 10 22 22 22 54 54 54
53680 - 94 94 94 18 18 18 2 2 6 46 46 46
53681 -234 234 234 221 221 221 190 190 190 190 190 190
53682 -190 190 190 187 187 187 187 187 187 190 190 190
53683 -190 190 190 195 195 195 214 214 214 242 242 242
53684 -253 253 253 253 253 253 253 253 253 253 253 253
53685 - 82 82 82 2 2 6 2 2 6 2 2 6
53686 - 2 2 6 2 2 6 2 2 6 14 14 14
53687 - 86 86 86 54 54 54 22 22 22 6 6 6
53688 - 0 0 0 0 0 0 0 0 0 0 0 0
53689 - 0 0 0 0 0 0 0 0 0 0 0 0
53690 - 0 0 0 0 0 0 0 0 0 0 0 0
53691 - 0 0 0 0 0 0 0 0 0 0 0 0
53692 - 0 0 0 0 0 0 0 0 0 0 0 0
53693 - 0 0 0 0 0 0 0 0 0 0 0 0
53694 - 0 0 0 0 0 0 0 0 0 0 0 0
53695 - 0 0 0 0 0 0 0 0 0 0 0 0
53696 - 0 0 0 0 0 0 0 0 0 0 0 0
53697 - 0 0 0 0 0 0 0 0 0 0 0 0
53698 - 0 0 0 0 0 0 0 0 0 0 0 0
53699 - 6 6 6 18 18 18 46 46 46 90 90 90
53700 - 46 46 46 18 18 18 6 6 6 182 182 182
53701 -253 253 253 246 246 246 206 206 206 190 190 190
53702 -190 190 190 190 190 190 190 190 190 190 190 190
53703 -206 206 206 231 231 231 250 250 250 253 253 253
53704 -253 253 253 253 253 253 253 253 253 253 253 253
53705 -202 202 202 14 14 14 2 2 6 2 2 6
53706 - 2 2 6 2 2 6 2 2 6 2 2 6
53707 - 42 42 42 86 86 86 42 42 42 18 18 18
53708 - 6 6 6 0 0 0 0 0 0 0 0 0
53709 - 0 0 0 0 0 0 0 0 0 0 0 0
53710 - 0 0 0 0 0 0 0 0 0 0 0 0
53711 - 0 0 0 0 0 0 0 0 0 0 0 0
53712 - 0 0 0 0 0 0 0 0 0 0 0 0
53713 - 0 0 0 0 0 0 0 0 0 0 0 0
53714 - 0 0 0 0 0 0 0 0 0 0 0 0
53715 - 0 0 0 0 0 0 0 0 0 0 0 0
53716 - 0 0 0 0 0 0 0 0 0 0 0 0
53717 - 0 0 0 0 0 0 0 0 0 0 0 0
53718 - 0 0 0 0 0 0 0 0 0 6 6 6
53719 - 14 14 14 38 38 38 74 74 74 66 66 66
53720 - 2 2 6 6 6 6 90 90 90 250 250 250
53721 -253 253 253 253 253 253 238 238 238 198 198 198
53722 -190 190 190 190 190 190 195 195 195 221 221 221
53723 -246 246 246 253 253 253 253 253 253 253 253 253
53724 -253 253 253 253 253 253 253 253 253 253 253 253
53725 -253 253 253 82 82 82 2 2 6 2 2 6
53726 - 2 2 6 2 2 6 2 2 6 2 2 6
53727 - 2 2 6 78 78 78 70 70 70 34 34 34
53728 - 14 14 14 6 6 6 0 0 0 0 0 0
53729 - 0 0 0 0 0 0 0 0 0 0 0 0
53730 - 0 0 0 0 0 0 0 0 0 0 0 0
53731 - 0 0 0 0 0 0 0 0 0 0 0 0
53732 - 0 0 0 0 0 0 0 0 0 0 0 0
53733 - 0 0 0 0 0 0 0 0 0 0 0 0
53734 - 0 0 0 0 0 0 0 0 0 0 0 0
53735 - 0 0 0 0 0 0 0 0 0 0 0 0
53736 - 0 0 0 0 0 0 0 0 0 0 0 0
53737 - 0 0 0 0 0 0 0 0 0 0 0 0
53738 - 0 0 0 0 0 0 0 0 0 14 14 14
53739 - 34 34 34 66 66 66 78 78 78 6 6 6
53740 - 2 2 6 18 18 18 218 218 218 253 253 253
53741 -253 253 253 253 253 253 253 253 253 246 246 246
53742 -226 226 226 231 231 231 246 246 246 253 253 253
53743 -253 253 253 253 253 253 253 253 253 253 253 253
53744 -253 253 253 253 253 253 253 253 253 253 253 253
53745 -253 253 253 178 178 178 2 2 6 2 2 6
53746 - 2 2 6 2 2 6 2 2 6 2 2 6
53747 - 2 2 6 18 18 18 90 90 90 62 62 62
53748 - 30 30 30 10 10 10 0 0 0 0 0 0
53749 - 0 0 0 0 0 0 0 0 0 0 0 0
53750 - 0 0 0 0 0 0 0 0 0 0 0 0
53751 - 0 0 0 0 0 0 0 0 0 0 0 0
53752 - 0 0 0 0 0 0 0 0 0 0 0 0
53753 - 0 0 0 0 0 0 0 0 0 0 0 0
53754 - 0 0 0 0 0 0 0 0 0 0 0 0
53755 - 0 0 0 0 0 0 0 0 0 0 0 0
53756 - 0 0 0 0 0 0 0 0 0 0 0 0
53757 - 0 0 0 0 0 0 0 0 0 0 0 0
53758 - 0 0 0 0 0 0 10 10 10 26 26 26
53759 - 58 58 58 90 90 90 18 18 18 2 2 6
53760 - 2 2 6 110 110 110 253 253 253 253 253 253
53761 -253 253 253 253 253 253 253 253 253 253 253 253
53762 -250 250 250 253 253 253 253 253 253 253 253 253
53763 -253 253 253 253 253 253 253 253 253 253 253 253
53764 -253 253 253 253 253 253 253 253 253 253 253 253
53765 -253 253 253 231 231 231 18 18 18 2 2 6
53766 - 2 2 6 2 2 6 2 2 6 2 2 6
53767 - 2 2 6 2 2 6 18 18 18 94 94 94
53768 - 54 54 54 26 26 26 10 10 10 0 0 0
53769 - 0 0 0 0 0 0 0 0 0 0 0 0
53770 - 0 0 0 0 0 0 0 0 0 0 0 0
53771 - 0 0 0 0 0 0 0 0 0 0 0 0
53772 - 0 0 0 0 0 0 0 0 0 0 0 0
53773 - 0 0 0 0 0 0 0 0 0 0 0 0
53774 - 0 0 0 0 0 0 0 0 0 0 0 0
53775 - 0 0 0 0 0 0 0 0 0 0 0 0
53776 - 0 0 0 0 0 0 0 0 0 0 0 0
53777 - 0 0 0 0 0 0 0 0 0 0 0 0
53778 - 0 0 0 6 6 6 22 22 22 50 50 50
53779 - 90 90 90 26 26 26 2 2 6 2 2 6
53780 - 14 14 14 195 195 195 250 250 250 253 253 253
53781 -253 253 253 253 253 253 253 253 253 253 253 253
53782 -253 253 253 253 253 253 253 253 253 253 253 253
53783 -253 253 253 253 253 253 253 253 253 253 253 253
53784 -253 253 253 253 253 253 253 253 253 253 253 253
53785 -250 250 250 242 242 242 54 54 54 2 2 6
53786 - 2 2 6 2 2 6 2 2 6 2 2 6
53787 - 2 2 6 2 2 6 2 2 6 38 38 38
53788 - 86 86 86 50 50 50 22 22 22 6 6 6
53789 - 0 0 0 0 0 0 0 0 0 0 0 0
53790 - 0 0 0 0 0 0 0 0 0 0 0 0
53791 - 0 0 0 0 0 0 0 0 0 0 0 0
53792 - 0 0 0 0 0 0 0 0 0 0 0 0
53793 - 0 0 0 0 0 0 0 0 0 0 0 0
53794 - 0 0 0 0 0 0 0 0 0 0 0 0
53795 - 0 0 0 0 0 0 0 0 0 0 0 0
53796 - 0 0 0 0 0 0 0 0 0 0 0 0
53797 - 0 0 0 0 0 0 0 0 0 0 0 0
53798 - 6 6 6 14 14 14 38 38 38 82 82 82
53799 - 34 34 34 2 2 6 2 2 6 2 2 6
53800 - 42 42 42 195 195 195 246 246 246 253 253 253
53801 -253 253 253 253 253 253 253 253 253 250 250 250
53802 -242 242 242 242 242 242 250 250 250 253 253 253
53803 -253 253 253 253 253 253 253 253 253 253 253 253
53804 -253 253 253 250 250 250 246 246 246 238 238 238
53805 -226 226 226 231 231 231 101 101 101 6 6 6
53806 - 2 2 6 2 2 6 2 2 6 2 2 6
53807 - 2 2 6 2 2 6 2 2 6 2 2 6
53808 - 38 38 38 82 82 82 42 42 42 14 14 14
53809 - 6 6 6 0 0 0 0 0 0 0 0 0
53810 - 0 0 0 0 0 0 0 0 0 0 0 0
53811 - 0 0 0 0 0 0 0 0 0 0 0 0
53812 - 0 0 0 0 0 0 0 0 0 0 0 0
53813 - 0 0 0 0 0 0 0 0 0 0 0 0
53814 - 0 0 0 0 0 0 0 0 0 0 0 0
53815 - 0 0 0 0 0 0 0 0 0 0 0 0
53816 - 0 0 0 0 0 0 0 0 0 0 0 0
53817 - 0 0 0 0 0 0 0 0 0 0 0 0
53818 - 10 10 10 26 26 26 62 62 62 66 66 66
53819 - 2 2 6 2 2 6 2 2 6 6 6 6
53820 - 70 70 70 170 170 170 206 206 206 234 234 234
53821 -246 246 246 250 250 250 250 250 250 238 238 238
53822 -226 226 226 231 231 231 238 238 238 250 250 250
53823 -250 250 250 250 250 250 246 246 246 231 231 231
53824 -214 214 214 206 206 206 202 202 202 202 202 202
53825 -198 198 198 202 202 202 182 182 182 18 18 18
53826 - 2 2 6 2 2 6 2 2 6 2 2 6
53827 - 2 2 6 2 2 6 2 2 6 2 2 6
53828 - 2 2 6 62 62 62 66 66 66 30 30 30
53829 - 10 10 10 0 0 0 0 0 0 0 0 0
53830 - 0 0 0 0 0 0 0 0 0 0 0 0
53831 - 0 0 0 0 0 0 0 0 0 0 0 0
53832 - 0 0 0 0 0 0 0 0 0 0 0 0
53833 - 0 0 0 0 0 0 0 0 0 0 0 0
53834 - 0 0 0 0 0 0 0 0 0 0 0 0
53835 - 0 0 0 0 0 0 0 0 0 0 0 0
53836 - 0 0 0 0 0 0 0 0 0 0 0 0
53837 - 0 0 0 0 0 0 0 0 0 0 0 0
53838 - 14 14 14 42 42 42 82 82 82 18 18 18
53839 - 2 2 6 2 2 6 2 2 6 10 10 10
53840 - 94 94 94 182 182 182 218 218 218 242 242 242
53841 -250 250 250 253 253 253 253 253 253 250 250 250
53842 -234 234 234 253 253 253 253 253 253 253 253 253
53843 -253 253 253 253 253 253 253 253 253 246 246 246
53844 -238 238 238 226 226 226 210 210 210 202 202 202
53845 -195 195 195 195 195 195 210 210 210 158 158 158
53846 - 6 6 6 14 14 14 50 50 50 14 14 14
53847 - 2 2 6 2 2 6 2 2 6 2 2 6
53848 - 2 2 6 6 6 6 86 86 86 46 46 46
53849 - 18 18 18 6 6 6 0 0 0 0 0 0
53850 - 0 0 0 0 0 0 0 0 0 0 0 0
53851 - 0 0 0 0 0 0 0 0 0 0 0 0
53852 - 0 0 0 0 0 0 0 0 0 0 0 0
53853 - 0 0 0 0 0 0 0 0 0 0 0 0
53854 - 0 0 0 0 0 0 0 0 0 0 0 0
53855 - 0 0 0 0 0 0 0 0 0 0 0 0
53856 - 0 0 0 0 0 0 0 0 0 0 0 0
53857 - 0 0 0 0 0 0 0 0 0 6 6 6
53858 - 22 22 22 54 54 54 70 70 70 2 2 6
53859 - 2 2 6 10 10 10 2 2 6 22 22 22
53860 -166 166 166 231 231 231 250 250 250 253 253 253
53861 -253 253 253 253 253 253 253 253 253 250 250 250
53862 -242 242 242 253 253 253 253 253 253 253 253 253
53863 -253 253 253 253 253 253 253 253 253 253 253 253
53864 -253 253 253 253 253 253 253 253 253 246 246 246
53865 -231 231 231 206 206 206 198 198 198 226 226 226
53866 - 94 94 94 2 2 6 6 6 6 38 38 38
53867 - 30 30 30 2 2 6 2 2 6 2 2 6
53868 - 2 2 6 2 2 6 62 62 62 66 66 66
53869 - 26 26 26 10 10 10 0 0 0 0 0 0
53870 - 0 0 0 0 0 0 0 0 0 0 0 0
53871 - 0 0 0 0 0 0 0 0 0 0 0 0
53872 - 0 0 0 0 0 0 0 0 0 0 0 0
53873 - 0 0 0 0 0 0 0 0 0 0 0 0
53874 - 0 0 0 0 0 0 0 0 0 0 0 0
53875 - 0 0 0 0 0 0 0 0 0 0 0 0
53876 - 0 0 0 0 0 0 0 0 0 0 0 0
53877 - 0 0 0 0 0 0 0 0 0 10 10 10
53878 - 30 30 30 74 74 74 50 50 50 2 2 6
53879 - 26 26 26 26 26 26 2 2 6 106 106 106
53880 -238 238 238 253 253 253 253 253 253 253 253 253
53881 -253 253 253 253 253 253 253 253 253 253 253 253
53882 -253 253 253 253 253 253 253 253 253 253 253 253
53883 -253 253 253 253 253 253 253 253 253 253 253 253
53884 -253 253 253 253 253 253 253 253 253 253 253 253
53885 -253 253 253 246 246 246 218 218 218 202 202 202
53886 -210 210 210 14 14 14 2 2 6 2 2 6
53887 - 30 30 30 22 22 22 2 2 6 2 2 6
53888 - 2 2 6 2 2 6 18 18 18 86 86 86
53889 - 42 42 42 14 14 14 0 0 0 0 0 0
53890 - 0 0 0 0 0 0 0 0 0 0 0 0
53891 - 0 0 0 0 0 0 0 0 0 0 0 0
53892 - 0 0 0 0 0 0 0 0 0 0 0 0
53893 - 0 0 0 0 0 0 0 0 0 0 0 0
53894 - 0 0 0 0 0 0 0 0 0 0 0 0
53895 - 0 0 0 0 0 0 0 0 0 0 0 0
53896 - 0 0 0 0 0 0 0 0 0 0 0 0
53897 - 0 0 0 0 0 0 0 0 0 14 14 14
53898 - 42 42 42 90 90 90 22 22 22 2 2 6
53899 - 42 42 42 2 2 6 18 18 18 218 218 218
53900 -253 253 253 253 253 253 253 253 253 253 253 253
53901 -253 253 253 253 253 253 253 253 253 253 253 253
53902 -253 253 253 253 253 253 253 253 253 253 253 253
53903 -253 253 253 253 253 253 253 253 253 253 253 253
53904 -253 253 253 253 253 253 253 253 253 253 253 253
53905 -253 253 253 253 253 253 250 250 250 221 221 221
53906 -218 218 218 101 101 101 2 2 6 14 14 14
53907 - 18 18 18 38 38 38 10 10 10 2 2 6
53908 - 2 2 6 2 2 6 2 2 6 78 78 78
53909 - 58 58 58 22 22 22 6 6 6 0 0 0
53910 - 0 0 0 0 0 0 0 0 0 0 0 0
53911 - 0 0 0 0 0 0 0 0 0 0 0 0
53912 - 0 0 0 0 0 0 0 0 0 0 0 0
53913 - 0 0 0 0 0 0 0 0 0 0 0 0
53914 - 0 0 0 0 0 0 0 0 0 0 0 0
53915 - 0 0 0 0 0 0 0 0 0 0 0 0
53916 - 0 0 0 0 0 0 0 0 0 0 0 0
53917 - 0 0 0 0 0 0 6 6 6 18 18 18
53918 - 54 54 54 82 82 82 2 2 6 26 26 26
53919 - 22 22 22 2 2 6 123 123 123 253 253 253
53920 -253 253 253 253 253 253 253 253 253 253 253 253
53921 -253 253 253 253 253 253 253 253 253 253 253 253
53922 -253 253 253 253 253 253 253 253 253 253 253 253
53923 -253 253 253 253 253 253 253 253 253 253 253 253
53924 -253 253 253 253 253 253 253 253 253 253 253 253
53925 -253 253 253 253 253 253 253 253 253 250 250 250
53926 -238 238 238 198 198 198 6 6 6 38 38 38
53927 - 58 58 58 26 26 26 38 38 38 2 2 6
53928 - 2 2 6 2 2 6 2 2 6 46 46 46
53929 - 78 78 78 30 30 30 10 10 10 0 0 0
53930 - 0 0 0 0 0 0 0 0 0 0 0 0
53931 - 0 0 0 0 0 0 0 0 0 0 0 0
53932 - 0 0 0 0 0 0 0 0 0 0 0 0
53933 - 0 0 0 0 0 0 0 0 0 0 0 0
53934 - 0 0 0 0 0 0 0 0 0 0 0 0
53935 - 0 0 0 0 0 0 0 0 0 0 0 0
53936 - 0 0 0 0 0 0 0 0 0 0 0 0
53937 - 0 0 0 0 0 0 10 10 10 30 30 30
53938 - 74 74 74 58 58 58 2 2 6 42 42 42
53939 - 2 2 6 22 22 22 231 231 231 253 253 253
53940 -253 253 253 253 253 253 253 253 253 253 253 253
53941 -253 253 253 253 253 253 253 253 253 250 250 250
53942 -253 253 253 253 253 253 253 253 253 253 253 253
53943 -253 253 253 253 253 253 253 253 253 253 253 253
53944 -253 253 253 253 253 253 253 253 253 253 253 253
53945 -253 253 253 253 253 253 253 253 253 253 253 253
53946 -253 253 253 246 246 246 46 46 46 38 38 38
53947 - 42 42 42 14 14 14 38 38 38 14 14 14
53948 - 2 2 6 2 2 6 2 2 6 6 6 6
53949 - 86 86 86 46 46 46 14 14 14 0 0 0
53950 - 0 0 0 0 0 0 0 0 0 0 0 0
53951 - 0 0 0 0 0 0 0 0 0 0 0 0
53952 - 0 0 0 0 0 0 0 0 0 0 0 0
53953 - 0 0 0 0 0 0 0 0 0 0 0 0
53954 - 0 0 0 0 0 0 0 0 0 0 0 0
53955 - 0 0 0 0 0 0 0 0 0 0 0 0
53956 - 0 0 0 0 0 0 0 0 0 0 0 0
53957 - 0 0 0 6 6 6 14 14 14 42 42 42
53958 - 90 90 90 18 18 18 18 18 18 26 26 26
53959 - 2 2 6 116 116 116 253 253 253 253 253 253
53960 -253 253 253 253 253 253 253 253 253 253 253 253
53961 -253 253 253 253 253 253 250 250 250 238 238 238
53962 -253 253 253 253 253 253 253 253 253 253 253 253
53963 -253 253 253 253 253 253 253 253 253 253 253 253
53964 -253 253 253 253 253 253 253 253 253 253 253 253
53965 -253 253 253 253 253 253 253 253 253 253 253 253
53966 -253 253 253 253 253 253 94 94 94 6 6 6
53967 - 2 2 6 2 2 6 10 10 10 34 34 34
53968 - 2 2 6 2 2 6 2 2 6 2 2 6
53969 - 74 74 74 58 58 58 22 22 22 6 6 6
53970 - 0 0 0 0 0 0 0 0 0 0 0 0
53971 - 0 0 0 0 0 0 0 0 0 0 0 0
53972 - 0 0 0 0 0 0 0 0 0 0 0 0
53973 - 0 0 0 0 0 0 0 0 0 0 0 0
53974 - 0 0 0 0 0 0 0 0 0 0 0 0
53975 - 0 0 0 0 0 0 0 0 0 0 0 0
53976 - 0 0 0 0 0 0 0 0 0 0 0 0
53977 - 0 0 0 10 10 10 26 26 26 66 66 66
53978 - 82 82 82 2 2 6 38 38 38 6 6 6
53979 - 14 14 14 210 210 210 253 253 253 253 253 253
53980 -253 253 253 253 253 253 253 253 253 253 253 253
53981 -253 253 253 253 253 253 246 246 246 242 242 242
53982 -253 253 253 253 253 253 253 253 253 253 253 253
53983 -253 253 253 253 253 253 253 253 253 253 253 253
53984 -253 253 253 253 253 253 253 253 253 253 253 253
53985 -253 253 253 253 253 253 253 253 253 253 253 253
53986 -253 253 253 253 253 253 144 144 144 2 2 6
53987 - 2 2 6 2 2 6 2 2 6 46 46 46
53988 - 2 2 6 2 2 6 2 2 6 2 2 6
53989 - 42 42 42 74 74 74 30 30 30 10 10 10
53990 - 0 0 0 0 0 0 0 0 0 0 0 0
53991 - 0 0 0 0 0 0 0 0 0 0 0 0
53992 - 0 0 0 0 0 0 0 0 0 0 0 0
53993 - 0 0 0 0 0 0 0 0 0 0 0 0
53994 - 0 0 0 0 0 0 0 0 0 0 0 0
53995 - 0 0 0 0 0 0 0 0 0 0 0 0
53996 - 0 0 0 0 0 0 0 0 0 0 0 0
53997 - 6 6 6 14 14 14 42 42 42 90 90 90
53998 - 26 26 26 6 6 6 42 42 42 2 2 6
53999 - 74 74 74 250 250 250 253 253 253 253 253 253
54000 -253 253 253 253 253 253 253 253 253 253 253 253
54001 -253 253 253 253 253 253 242 242 242 242 242 242
54002 -253 253 253 253 253 253 253 253 253 253 253 253
54003 -253 253 253 253 253 253 253 253 253 253 253 253
54004 -253 253 253 253 253 253 253 253 253 253 253 253
54005 -253 253 253 253 253 253 253 253 253 253 253 253
54006 -253 253 253 253 253 253 182 182 182 2 2 6
54007 - 2 2 6 2 2 6 2 2 6 46 46 46
54008 - 2 2 6 2 2 6 2 2 6 2 2 6
54009 - 10 10 10 86 86 86 38 38 38 10 10 10
54010 - 0 0 0 0 0 0 0 0 0 0 0 0
54011 - 0 0 0 0 0 0 0 0 0 0 0 0
54012 - 0 0 0 0 0 0 0 0 0 0 0 0
54013 - 0 0 0 0 0 0 0 0 0 0 0 0
54014 - 0 0 0 0 0 0 0 0 0 0 0 0
54015 - 0 0 0 0 0 0 0 0 0 0 0 0
54016 - 0 0 0 0 0 0 0 0 0 0 0 0
54017 - 10 10 10 26 26 26 66 66 66 82 82 82
54018 - 2 2 6 22 22 22 18 18 18 2 2 6
54019 -149 149 149 253 253 253 253 253 253 253 253 253
54020 -253 253 253 253 253 253 253 253 253 253 253 253
54021 -253 253 253 253 253 253 234 234 234 242 242 242
54022 -253 253 253 253 253 253 253 253 253 253 253 253
54023 -253 253 253 253 253 253 253 253 253 253 253 253
54024 -253 253 253 253 253 253 253 253 253 253 253 253
54025 -253 253 253 253 253 253 253 253 253 253 253 253
54026 -253 253 253 253 253 253 206 206 206 2 2 6
54027 - 2 2 6 2 2 6 2 2 6 38 38 38
54028 - 2 2 6 2 2 6 2 2 6 2 2 6
54029 - 6 6 6 86 86 86 46 46 46 14 14 14
54030 - 0 0 0 0 0 0 0 0 0 0 0 0
54031 - 0 0 0 0 0 0 0 0 0 0 0 0
54032 - 0 0 0 0 0 0 0 0 0 0 0 0
54033 - 0 0 0 0 0 0 0 0 0 0 0 0
54034 - 0 0 0 0 0 0 0 0 0 0 0 0
54035 - 0 0 0 0 0 0 0 0 0 0 0 0
54036 - 0 0 0 0 0 0 0 0 0 6 6 6
54037 - 18 18 18 46 46 46 86 86 86 18 18 18
54038 - 2 2 6 34 34 34 10 10 10 6 6 6
54039 -210 210 210 253 253 253 253 253 253 253 253 253
54040 -253 253 253 253 253 253 253 253 253 253 253 253
54041 -253 253 253 253 253 253 234 234 234 242 242 242
54042 -253 253 253 253 253 253 253 253 253 253 253 253
54043 -253 253 253 253 253 253 253 253 253 253 253 253
54044 -253 253 253 253 253 253 253 253 253 253 253 253
54045 -253 253 253 253 253 253 253 253 253 253 253 253
54046 -253 253 253 253 253 253 221 221 221 6 6 6
54047 - 2 2 6 2 2 6 6 6 6 30 30 30
54048 - 2 2 6 2 2 6 2 2 6 2 2 6
54049 - 2 2 6 82 82 82 54 54 54 18 18 18
54050 - 6 6 6 0 0 0 0 0 0 0 0 0
54051 - 0 0 0 0 0 0 0 0 0 0 0 0
54052 - 0 0 0 0 0 0 0 0 0 0 0 0
54053 - 0 0 0 0 0 0 0 0 0 0 0 0
54054 - 0 0 0 0 0 0 0 0 0 0 0 0
54055 - 0 0 0 0 0 0 0 0 0 0 0 0
54056 - 0 0 0 0 0 0 0 0 0 10 10 10
54057 - 26 26 26 66 66 66 62 62 62 2 2 6
54058 - 2 2 6 38 38 38 10 10 10 26 26 26
54059 -238 238 238 253 253 253 253 253 253 253 253 253
54060 -253 253 253 253 253 253 253 253 253 253 253 253
54061 -253 253 253 253 253 253 231 231 231 238 238 238
54062 -253 253 253 253 253 253 253 253 253 253 253 253
54063 -253 253 253 253 253 253 253 253 253 253 253 253
54064 -253 253 253 253 253 253 253 253 253 253 253 253
54065 -253 253 253 253 253 253 253 253 253 253 253 253
54066 -253 253 253 253 253 253 231 231 231 6 6 6
54067 - 2 2 6 2 2 6 10 10 10 30 30 30
54068 - 2 2 6 2 2 6 2 2 6 2 2 6
54069 - 2 2 6 66 66 66 58 58 58 22 22 22
54070 - 6 6 6 0 0 0 0 0 0 0 0 0
54071 - 0 0 0 0 0 0 0 0 0 0 0 0
54072 - 0 0 0 0 0 0 0 0 0 0 0 0
54073 - 0 0 0 0 0 0 0 0 0 0 0 0
54074 - 0 0 0 0 0 0 0 0 0 0 0 0
54075 - 0 0 0 0 0 0 0 0 0 0 0 0
54076 - 0 0 0 0 0 0 0 0 0 10 10 10
54077 - 38 38 38 78 78 78 6 6 6 2 2 6
54078 - 2 2 6 46 46 46 14 14 14 42 42 42
54079 -246 246 246 253 253 253 253 253 253 253 253 253
54080 -253 253 253 253 253 253 253 253 253 253 253 253
54081 -253 253 253 253 253 253 231 231 231 242 242 242
54082 -253 253 253 253 253 253 253 253 253 253 253 253
54083 -253 253 253 253 253 253 253 253 253 253 253 253
54084 -253 253 253 253 253 253 253 253 253 253 253 253
54085 -253 253 253 253 253 253 253 253 253 253 253 253
54086 -253 253 253 253 253 253 234 234 234 10 10 10
54087 - 2 2 6 2 2 6 22 22 22 14 14 14
54088 - 2 2 6 2 2 6 2 2 6 2 2 6
54089 - 2 2 6 66 66 66 62 62 62 22 22 22
54090 - 6 6 6 0 0 0 0 0 0 0 0 0
54091 - 0 0 0 0 0 0 0 0 0 0 0 0
54092 - 0 0 0 0 0 0 0 0 0 0 0 0
54093 - 0 0 0 0 0 0 0 0 0 0 0 0
54094 - 0 0 0 0 0 0 0 0 0 0 0 0
54095 - 0 0 0 0 0 0 0 0 0 0 0 0
54096 - 0 0 0 0 0 0 6 6 6 18 18 18
54097 - 50 50 50 74 74 74 2 2 6 2 2 6
54098 - 14 14 14 70 70 70 34 34 34 62 62 62
54099 -250 250 250 253 253 253 253 253 253 253 253 253
54100 -253 253 253 253 253 253 253 253 253 253 253 253
54101 -253 253 253 253 253 253 231 231 231 246 246 246
54102 -253 253 253 253 253 253 253 253 253 253 253 253
54103 -253 253 253 253 253 253 253 253 253 253 253 253
54104 -253 253 253 253 253 253 253 253 253 253 253 253
54105 -253 253 253 253 253 253 253 253 253 253 253 253
54106 -253 253 253 253 253 253 234 234 234 14 14 14
54107 - 2 2 6 2 2 6 30 30 30 2 2 6
54108 - 2 2 6 2 2 6 2 2 6 2 2 6
54109 - 2 2 6 66 66 66 62 62 62 22 22 22
54110 - 6 6 6 0 0 0 0 0 0 0 0 0
54111 - 0 0 0 0 0 0 0 0 0 0 0 0
54112 - 0 0 0 0 0 0 0 0 0 0 0 0
54113 - 0 0 0 0 0 0 0 0 0 0 0 0
54114 - 0 0 0 0 0 0 0 0 0 0 0 0
54115 - 0 0 0 0 0 0 0 0 0 0 0 0
54116 - 0 0 0 0 0 0 6 6 6 18 18 18
54117 - 54 54 54 62 62 62 2 2 6 2 2 6
54118 - 2 2 6 30 30 30 46 46 46 70 70 70
54119 -250 250 250 253 253 253 253 253 253 253 253 253
54120 -253 253 253 253 253 253 253 253 253 253 253 253
54121 -253 253 253 253 253 253 231 231 231 246 246 246
54122 -253 253 253 253 253 253 253 253 253 253 253 253
54123 -253 253 253 253 253 253 253 253 253 253 253 253
54124 -253 253 253 253 253 253 253 253 253 253 253 253
54125 -253 253 253 253 253 253 253 253 253 253 253 253
54126 -253 253 253 253 253 253 226 226 226 10 10 10
54127 - 2 2 6 6 6 6 30 30 30 2 2 6
54128 - 2 2 6 2 2 6 2 2 6 2 2 6
54129 - 2 2 6 66 66 66 58 58 58 22 22 22
54130 - 6 6 6 0 0 0 0 0 0 0 0 0
54131 - 0 0 0 0 0 0 0 0 0 0 0 0
54132 - 0 0 0 0 0 0 0 0 0 0 0 0
54133 - 0 0 0 0 0 0 0 0 0 0 0 0
54134 - 0 0 0 0 0 0 0 0 0 0 0 0
54135 - 0 0 0 0 0 0 0 0 0 0 0 0
54136 - 0 0 0 0 0 0 6 6 6 22 22 22
54137 - 58 58 58 62 62 62 2 2 6 2 2 6
54138 - 2 2 6 2 2 6 30 30 30 78 78 78
54139 -250 250 250 253 253 253 253 253 253 253 253 253
54140 -253 253 253 253 253 253 253 253 253 253 253 253
54141 -253 253 253 253 253 253 231 231 231 246 246 246
54142 -253 253 253 253 253 253 253 253 253 253 253 253
54143 -253 253 253 253 253 253 253 253 253 253 253 253
54144 -253 253 253 253 253 253 253 253 253 253 253 253
54145 -253 253 253 253 253 253 253 253 253 253 253 253
54146 -253 253 253 253 253 253 206 206 206 2 2 6
54147 - 22 22 22 34 34 34 18 14 6 22 22 22
54148 - 26 26 26 18 18 18 6 6 6 2 2 6
54149 - 2 2 6 82 82 82 54 54 54 18 18 18
54150 - 6 6 6 0 0 0 0 0 0 0 0 0
54151 - 0 0 0 0 0 0 0 0 0 0 0 0
54152 - 0 0 0 0 0 0 0 0 0 0 0 0
54153 - 0 0 0 0 0 0 0 0 0 0 0 0
54154 - 0 0 0 0 0 0 0 0 0 0 0 0
54155 - 0 0 0 0 0 0 0 0 0 0 0 0
54156 - 0 0 0 0 0 0 6 6 6 26 26 26
54157 - 62 62 62 106 106 106 74 54 14 185 133 11
54158 -210 162 10 121 92 8 6 6 6 62 62 62
54159 -238 238 238 253 253 253 253 253 253 253 253 253
54160 -253 253 253 253 253 253 253 253 253 253 253 253
54161 -253 253 253 253 253 253 231 231 231 246 246 246
54162 -253 253 253 253 253 253 253 253 253 253 253 253
54163 -253 253 253 253 253 253 253 253 253 253 253 253
54164 -253 253 253 253 253 253 253 253 253 253 253 253
54165 -253 253 253 253 253 253 253 253 253 253 253 253
54166 -253 253 253 253 253 253 158 158 158 18 18 18
54167 - 14 14 14 2 2 6 2 2 6 2 2 6
54168 - 6 6 6 18 18 18 66 66 66 38 38 38
54169 - 6 6 6 94 94 94 50 50 50 18 18 18
54170 - 6 6 6 0 0 0 0 0 0 0 0 0
54171 - 0 0 0 0 0 0 0 0 0 0 0 0
54172 - 0 0 0 0 0 0 0 0 0 0 0 0
54173 - 0 0 0 0 0 0 0 0 0 0 0 0
54174 - 0 0 0 0 0 0 0 0 0 0 0 0
54175 - 0 0 0 0 0 0 0 0 0 6 6 6
54176 - 10 10 10 10 10 10 18 18 18 38 38 38
54177 - 78 78 78 142 134 106 216 158 10 242 186 14
54178 -246 190 14 246 190 14 156 118 10 10 10 10
54179 - 90 90 90 238 238 238 253 253 253 253 253 253
54180 -253 253 253 253 253 253 253 253 253 253 253 253
54181 -253 253 253 253 253 253 231 231 231 250 250 250
54182 -253 253 253 253 253 253 253 253 253 253 253 253
54183 -253 253 253 253 253 253 253 253 253 253 253 253
54184 -253 253 253 253 253 253 253 253 253 253 253 253
54185 -253 253 253 253 253 253 253 253 253 246 230 190
54186 -238 204 91 238 204 91 181 142 44 37 26 9
54187 - 2 2 6 2 2 6 2 2 6 2 2 6
54188 - 2 2 6 2 2 6 38 38 38 46 46 46
54189 - 26 26 26 106 106 106 54 54 54 18 18 18
54190 - 6 6 6 0 0 0 0 0 0 0 0 0
54191 - 0 0 0 0 0 0 0 0 0 0 0 0
54192 - 0 0 0 0 0 0 0 0 0 0 0 0
54193 - 0 0 0 0 0 0 0 0 0 0 0 0
54194 - 0 0 0 0 0 0 0 0 0 0 0 0
54195 - 0 0 0 6 6 6 14 14 14 22 22 22
54196 - 30 30 30 38 38 38 50 50 50 70 70 70
54197 -106 106 106 190 142 34 226 170 11 242 186 14
54198 -246 190 14 246 190 14 246 190 14 154 114 10
54199 - 6 6 6 74 74 74 226 226 226 253 253 253
54200 -253 253 253 253 253 253 253 253 253 253 253 253
54201 -253 253 253 253 253 253 231 231 231 250 250 250
54202 -253 253 253 253 253 253 253 253 253 253 253 253
54203 -253 253 253 253 253 253 253 253 253 253 253 253
54204 -253 253 253 253 253 253 253 253 253 253 253 253
54205 -253 253 253 253 253 253 253 253 253 228 184 62
54206 -241 196 14 241 208 19 232 195 16 38 30 10
54207 - 2 2 6 2 2 6 2 2 6 2 2 6
54208 - 2 2 6 6 6 6 30 30 30 26 26 26
54209 -203 166 17 154 142 90 66 66 66 26 26 26
54210 - 6 6 6 0 0 0 0 0 0 0 0 0
54211 - 0 0 0 0 0 0 0 0 0 0 0 0
54212 - 0 0 0 0 0 0 0 0 0 0 0 0
54213 - 0 0 0 0 0 0 0 0 0 0 0 0
54214 - 0 0 0 0 0 0 0 0 0 0 0 0
54215 - 6 6 6 18 18 18 38 38 38 58 58 58
54216 - 78 78 78 86 86 86 101 101 101 123 123 123
54217 -175 146 61 210 150 10 234 174 13 246 186 14
54218 -246 190 14 246 190 14 246 190 14 238 190 10
54219 -102 78 10 2 2 6 46 46 46 198 198 198
54220 -253 253 253 253 253 253 253 253 253 253 253 253
54221 -253 253 253 253 253 253 234 234 234 242 242 242
54222 -253 253 253 253 253 253 253 253 253 253 253 253
54223 -253 253 253 253 253 253 253 253 253 253 253 253
54224 -253 253 253 253 253 253 253 253 253 253 253 253
54225 -253 253 253 253 253 253 253 253 253 224 178 62
54226 -242 186 14 241 196 14 210 166 10 22 18 6
54227 - 2 2 6 2 2 6 2 2 6 2 2 6
54228 - 2 2 6 2 2 6 6 6 6 121 92 8
54229 -238 202 15 232 195 16 82 82 82 34 34 34
54230 - 10 10 10 0 0 0 0 0 0 0 0 0
54231 - 0 0 0 0 0 0 0 0 0 0 0 0
54232 - 0 0 0 0 0 0 0 0 0 0 0 0
54233 - 0 0 0 0 0 0 0 0 0 0 0 0
54234 - 0 0 0 0 0 0 0 0 0 0 0 0
54235 - 14 14 14 38 38 38 70 70 70 154 122 46
54236 -190 142 34 200 144 11 197 138 11 197 138 11
54237 -213 154 11 226 170 11 242 186 14 246 190 14
54238 -246 190 14 246 190 14 246 190 14 246 190 14
54239 -225 175 15 46 32 6 2 2 6 22 22 22
54240 -158 158 158 250 250 250 253 253 253 253 253 253
54241 -253 253 253 253 253 253 253 253 253 253 253 253
54242 -253 253 253 253 253 253 253 253 253 253 253 253
54243 -253 253 253 253 253 253 253 253 253 253 253 253
54244 -253 253 253 253 253 253 253 253 253 253 253 253
54245 -253 253 253 250 250 250 242 242 242 224 178 62
54246 -239 182 13 236 186 11 213 154 11 46 32 6
54247 - 2 2 6 2 2 6 2 2 6 2 2 6
54248 - 2 2 6 2 2 6 61 42 6 225 175 15
54249 -238 190 10 236 186 11 112 100 78 42 42 42
54250 - 14 14 14 0 0 0 0 0 0 0 0 0
54251 - 0 0 0 0 0 0 0 0 0 0 0 0
54252 - 0 0 0 0 0 0 0 0 0 0 0 0
54253 - 0 0 0 0 0 0 0 0 0 0 0 0
54254 - 0 0 0 0 0 0 0 0 0 6 6 6
54255 - 22 22 22 54 54 54 154 122 46 213 154 11
54256 -226 170 11 230 174 11 226 170 11 226 170 11
54257 -236 178 12 242 186 14 246 190 14 246 190 14
54258 -246 190 14 246 190 14 246 190 14 246 190 14
54259 -241 196 14 184 144 12 10 10 10 2 2 6
54260 - 6 6 6 116 116 116 242 242 242 253 253 253
54261 -253 253 253 253 253 253 253 253 253 253 253 253
54262 -253 253 253 253 253 253 253 253 253 253 253 253
54263 -253 253 253 253 253 253 253 253 253 253 253 253
54264 -253 253 253 253 253 253 253 253 253 253 253 253
54265 -253 253 253 231 231 231 198 198 198 214 170 54
54266 -236 178 12 236 178 12 210 150 10 137 92 6
54267 - 18 14 6 2 2 6 2 2 6 2 2 6
54268 - 6 6 6 70 47 6 200 144 11 236 178 12
54269 -239 182 13 239 182 13 124 112 88 58 58 58
54270 - 22 22 22 6 6 6 0 0 0 0 0 0
54271 - 0 0 0 0 0 0 0 0 0 0 0 0
54272 - 0 0 0 0 0 0 0 0 0 0 0 0
54273 - 0 0 0 0 0 0 0 0 0 0 0 0
54274 - 0 0 0 0 0 0 0 0 0 10 10 10
54275 - 30 30 30 70 70 70 180 133 36 226 170 11
54276 -239 182 13 242 186 14 242 186 14 246 186 14
54277 -246 190 14 246 190 14 246 190 14 246 190 14
54278 -246 190 14 246 190 14 246 190 14 246 190 14
54279 -246 190 14 232 195 16 98 70 6 2 2 6
54280 - 2 2 6 2 2 6 66 66 66 221 221 221
54281 -253 253 253 253 253 253 253 253 253 253 253 253
54282 -253 253 253 253 253 253 253 253 253 253 253 253
54283 -253 253 253 253 253 253 253 253 253 253 253 253
54284 -253 253 253 253 253 253 253 253 253 253 253 253
54285 -253 253 253 206 206 206 198 198 198 214 166 58
54286 -230 174 11 230 174 11 216 158 10 192 133 9
54287 -163 110 8 116 81 8 102 78 10 116 81 8
54288 -167 114 7 197 138 11 226 170 11 239 182 13
54289 -242 186 14 242 186 14 162 146 94 78 78 78
54290 - 34 34 34 14 14 14 6 6 6 0 0 0
54291 - 0 0 0 0 0 0 0 0 0 0 0 0
54292 - 0 0 0 0 0 0 0 0 0 0 0 0
54293 - 0 0 0 0 0 0 0 0 0 0 0 0
54294 - 0 0 0 0 0 0 0 0 0 6 6 6
54295 - 30 30 30 78 78 78 190 142 34 226 170 11
54296 -239 182 13 246 190 14 246 190 14 246 190 14
54297 -246 190 14 246 190 14 246 190 14 246 190 14
54298 -246 190 14 246 190 14 246 190 14 246 190 14
54299 -246 190 14 241 196 14 203 166 17 22 18 6
54300 - 2 2 6 2 2 6 2 2 6 38 38 38
54301 -218 218 218 253 253 253 253 253 253 253 253 253
54302 -253 253 253 253 253 253 253 253 253 253 253 253
54303 -253 253 253 253 253 253 253 253 253 253 253 253
54304 -253 253 253 253 253 253 253 253 253 253 253 253
54305 -250 250 250 206 206 206 198 198 198 202 162 69
54306 -226 170 11 236 178 12 224 166 10 210 150 10
54307 -200 144 11 197 138 11 192 133 9 197 138 11
54308 -210 150 10 226 170 11 242 186 14 246 190 14
54309 -246 190 14 246 186 14 225 175 15 124 112 88
54310 - 62 62 62 30 30 30 14 14 14 6 6 6
54311 - 0 0 0 0 0 0 0 0 0 0 0 0
54312 - 0 0 0 0 0 0 0 0 0 0 0 0
54313 - 0 0 0 0 0 0 0 0 0 0 0 0
54314 - 0 0 0 0 0 0 0 0 0 10 10 10
54315 - 30 30 30 78 78 78 174 135 50 224 166 10
54316 -239 182 13 246 190 14 246 190 14 246 190 14
54317 -246 190 14 246 190 14 246 190 14 246 190 14
54318 -246 190 14 246 190 14 246 190 14 246 190 14
54319 -246 190 14 246 190 14 241 196 14 139 102 15
54320 - 2 2 6 2 2 6 2 2 6 2 2 6
54321 - 78 78 78 250 250 250 253 253 253 253 253 253
54322 -253 253 253 253 253 253 253 253 253 253 253 253
54323 -253 253 253 253 253 253 253 253 253 253 253 253
54324 -253 253 253 253 253 253 253 253 253 253 253 253
54325 -250 250 250 214 214 214 198 198 198 190 150 46
54326 -219 162 10 236 178 12 234 174 13 224 166 10
54327 -216 158 10 213 154 11 213 154 11 216 158 10
54328 -226 170 11 239 182 13 246 190 14 246 190 14
54329 -246 190 14 246 190 14 242 186 14 206 162 42
54330 -101 101 101 58 58 58 30 30 30 14 14 14
54331 - 6 6 6 0 0 0 0 0 0 0 0 0
54332 - 0 0 0 0 0 0 0 0 0 0 0 0
54333 - 0 0 0 0 0 0 0 0 0 0 0 0
54334 - 0 0 0 0 0 0 0 0 0 10 10 10
54335 - 30 30 30 74 74 74 174 135 50 216 158 10
54336 -236 178 12 246 190 14 246 190 14 246 190 14
54337 -246 190 14 246 190 14 246 190 14 246 190 14
54338 -246 190 14 246 190 14 246 190 14 246 190 14
54339 -246 190 14 246 190 14 241 196 14 226 184 13
54340 - 61 42 6 2 2 6 2 2 6 2 2 6
54341 - 22 22 22 238 238 238 253 253 253 253 253 253
54342 -253 253 253 253 253 253 253 253 253 253 253 253
54343 -253 253 253 253 253 253 253 253 253 253 253 253
54344 -253 253 253 253 253 253 253 253 253 253 253 253
54345 -253 253 253 226 226 226 187 187 187 180 133 36
54346 -216 158 10 236 178 12 239 182 13 236 178 12
54347 -230 174 11 226 170 11 226 170 11 230 174 11
54348 -236 178 12 242 186 14 246 190 14 246 190 14
54349 -246 190 14 246 190 14 246 186 14 239 182 13
54350 -206 162 42 106 106 106 66 66 66 34 34 34
54351 - 14 14 14 6 6 6 0 0 0 0 0 0
54352 - 0 0 0 0 0 0 0 0 0 0 0 0
54353 - 0 0 0 0 0 0 0 0 0 0 0 0
54354 - 0 0 0 0 0 0 0 0 0 6 6 6
54355 - 26 26 26 70 70 70 163 133 67 213 154 11
54356 -236 178 12 246 190 14 246 190 14 246 190 14
54357 -246 190 14 246 190 14 246 190 14 246 190 14
54358 -246 190 14 246 190 14 246 190 14 246 190 14
54359 -246 190 14 246 190 14 246 190 14 241 196 14
54360 -190 146 13 18 14 6 2 2 6 2 2 6
54361 - 46 46 46 246 246 246 253 253 253 253 253 253
54362 -253 253 253 253 253 253 253 253 253 253 253 253
54363 -253 253 253 253 253 253 253 253 253 253 253 253
54364 -253 253 253 253 253 253 253 253 253 253 253 253
54365 -253 253 253 221 221 221 86 86 86 156 107 11
54366 -216 158 10 236 178 12 242 186 14 246 186 14
54367 -242 186 14 239 182 13 239 182 13 242 186 14
54368 -242 186 14 246 186 14 246 190 14 246 190 14
54369 -246 190 14 246 190 14 246 190 14 246 190 14
54370 -242 186 14 225 175 15 142 122 72 66 66 66
54371 - 30 30 30 10 10 10 0 0 0 0 0 0
54372 - 0 0 0 0 0 0 0 0 0 0 0 0
54373 - 0 0 0 0 0 0 0 0 0 0 0 0
54374 - 0 0 0 0 0 0 0 0 0 6 6 6
54375 - 26 26 26 70 70 70 163 133 67 210 150 10
54376 -236 178 12 246 190 14 246 190 14 246 190 14
54377 -246 190 14 246 190 14 246 190 14 246 190 14
54378 -246 190 14 246 190 14 246 190 14 246 190 14
54379 -246 190 14 246 190 14 246 190 14 246 190 14
54380 -232 195 16 121 92 8 34 34 34 106 106 106
54381 -221 221 221 253 253 253 253 253 253 253 253 253
54382 -253 253 253 253 253 253 253 253 253 253 253 253
54383 -253 253 253 253 253 253 253 253 253 253 253 253
54384 -253 253 253 253 253 253 253 253 253 253 253 253
54385 -242 242 242 82 82 82 18 14 6 163 110 8
54386 -216 158 10 236 178 12 242 186 14 246 190 14
54387 -246 190 14 246 190 14 246 190 14 246 190 14
54388 -246 190 14 246 190 14 246 190 14 246 190 14
54389 -246 190 14 246 190 14 246 190 14 246 190 14
54390 -246 190 14 246 190 14 242 186 14 163 133 67
54391 - 46 46 46 18 18 18 6 6 6 0 0 0
54392 - 0 0 0 0 0 0 0 0 0 0 0 0
54393 - 0 0 0 0 0 0 0 0 0 0 0 0
54394 - 0 0 0 0 0 0 0 0 0 10 10 10
54395 - 30 30 30 78 78 78 163 133 67 210 150 10
54396 -236 178 12 246 186 14 246 190 14 246 190 14
54397 -246 190 14 246 190 14 246 190 14 246 190 14
54398 -246 190 14 246 190 14 246 190 14 246 190 14
54399 -246 190 14 246 190 14 246 190 14 246 190 14
54400 -241 196 14 215 174 15 190 178 144 253 253 253
54401 -253 253 253 253 253 253 253 253 253 253 253 253
54402 -253 253 253 253 253 253 253 253 253 253 253 253
54403 -253 253 253 253 253 253 253 253 253 253 253 253
54404 -253 253 253 253 253 253 253 253 253 218 218 218
54405 - 58 58 58 2 2 6 22 18 6 167 114 7
54406 -216 158 10 236 178 12 246 186 14 246 190 14
54407 -246 190 14 246 190 14 246 190 14 246 190 14
54408 -246 190 14 246 190 14 246 190 14 246 190 14
54409 -246 190 14 246 190 14 246 190 14 246 190 14
54410 -246 190 14 246 186 14 242 186 14 190 150 46
54411 - 54 54 54 22 22 22 6 6 6 0 0 0
54412 - 0 0 0 0 0 0 0 0 0 0 0 0
54413 - 0 0 0 0 0 0 0 0 0 0 0 0
54414 - 0 0 0 0 0 0 0 0 0 14 14 14
54415 - 38 38 38 86 86 86 180 133 36 213 154 11
54416 -236 178 12 246 186 14 246 190 14 246 190 14
54417 -246 190 14 246 190 14 246 190 14 246 190 14
54418 -246 190 14 246 190 14 246 190 14 246 190 14
54419 -246 190 14 246 190 14 246 190 14 246 190 14
54420 -246 190 14 232 195 16 190 146 13 214 214 214
54421 -253 253 253 253 253 253 253 253 253 253 253 253
54422 -253 253 253 253 253 253 253 253 253 253 253 253
54423 -253 253 253 253 253 253 253 253 253 253 253 253
54424 -253 253 253 250 250 250 170 170 170 26 26 26
54425 - 2 2 6 2 2 6 37 26 9 163 110 8
54426 -219 162 10 239 182 13 246 186 14 246 190 14
54427 -246 190 14 246 190 14 246 190 14 246 190 14
54428 -246 190 14 246 190 14 246 190 14 246 190 14
54429 -246 190 14 246 190 14 246 190 14 246 190 14
54430 -246 186 14 236 178 12 224 166 10 142 122 72
54431 - 46 46 46 18 18 18 6 6 6 0 0 0
54432 - 0 0 0 0 0 0 0 0 0 0 0 0
54433 - 0 0 0 0 0 0 0 0 0 0 0 0
54434 - 0 0 0 0 0 0 6 6 6 18 18 18
54435 - 50 50 50 109 106 95 192 133 9 224 166 10
54436 -242 186 14 246 190 14 246 190 14 246 190 14
54437 -246 190 14 246 190 14 246 190 14 246 190 14
54438 -246 190 14 246 190 14 246 190 14 246 190 14
54439 -246 190 14 246 190 14 246 190 14 246 190 14
54440 -242 186 14 226 184 13 210 162 10 142 110 46
54441 -226 226 226 253 253 253 253 253 253 253 253 253
54442 -253 253 253 253 253 253 253 253 253 253 253 253
54443 -253 253 253 253 253 253 253 253 253 253 253 253
54444 -198 198 198 66 66 66 2 2 6 2 2 6
54445 - 2 2 6 2 2 6 50 34 6 156 107 11
54446 -219 162 10 239 182 13 246 186 14 246 190 14
54447 -246 190 14 246 190 14 246 190 14 246 190 14
54448 -246 190 14 246 190 14 246 190 14 246 190 14
54449 -246 190 14 246 190 14 246 190 14 242 186 14
54450 -234 174 13 213 154 11 154 122 46 66 66 66
54451 - 30 30 30 10 10 10 0 0 0 0 0 0
54452 - 0 0 0 0 0 0 0 0 0 0 0 0
54453 - 0 0 0 0 0 0 0 0 0 0 0 0
54454 - 0 0 0 0 0 0 6 6 6 22 22 22
54455 - 58 58 58 154 121 60 206 145 10 234 174 13
54456 -242 186 14 246 186 14 246 190 14 246 190 14
54457 -246 190 14 246 190 14 246 190 14 246 190 14
54458 -246 190 14 246 190 14 246 190 14 246 190 14
54459 -246 190 14 246 190 14 246 190 14 246 190 14
54460 -246 186 14 236 178 12 210 162 10 163 110 8
54461 - 61 42 6 138 138 138 218 218 218 250 250 250
54462 -253 253 253 253 253 253 253 253 253 250 250 250
54463 -242 242 242 210 210 210 144 144 144 66 66 66
54464 - 6 6 6 2 2 6 2 2 6 2 2 6
54465 - 2 2 6 2 2 6 61 42 6 163 110 8
54466 -216 158 10 236 178 12 246 190 14 246 190 14
54467 -246 190 14 246 190 14 246 190 14 246 190 14
54468 -246 190 14 246 190 14 246 190 14 246 190 14
54469 -246 190 14 239 182 13 230 174 11 216 158 10
54470 -190 142 34 124 112 88 70 70 70 38 38 38
54471 - 18 18 18 6 6 6 0 0 0 0 0 0
54472 - 0 0 0 0 0 0 0 0 0 0 0 0
54473 - 0 0 0 0 0 0 0 0 0 0 0 0
54474 - 0 0 0 0 0 0 6 6 6 22 22 22
54475 - 62 62 62 168 124 44 206 145 10 224 166 10
54476 -236 178 12 239 182 13 242 186 14 242 186 14
54477 -246 186 14 246 190 14 246 190 14 246 190 14
54478 -246 190 14 246 190 14 246 190 14 246 190 14
54479 -246 190 14 246 190 14 246 190 14 246 190 14
54480 -246 190 14 236 178 12 216 158 10 175 118 6
54481 - 80 54 7 2 2 6 6 6 6 30 30 30
54482 - 54 54 54 62 62 62 50 50 50 38 38 38
54483 - 14 14 14 2 2 6 2 2 6 2 2 6
54484 - 2 2 6 2 2 6 2 2 6 2 2 6
54485 - 2 2 6 6 6 6 80 54 7 167 114 7
54486 -213 154 11 236 178 12 246 190 14 246 190 14
54487 -246 190 14 246 190 14 246 190 14 246 190 14
54488 -246 190 14 242 186 14 239 182 13 239 182 13
54489 -230 174 11 210 150 10 174 135 50 124 112 88
54490 - 82 82 82 54 54 54 34 34 34 18 18 18
54491 - 6 6 6 0 0 0 0 0 0 0 0 0
54492 - 0 0 0 0 0 0 0 0 0 0 0 0
54493 - 0 0 0 0 0 0 0 0 0 0 0 0
54494 - 0 0 0 0 0 0 6 6 6 18 18 18
54495 - 50 50 50 158 118 36 192 133 9 200 144 11
54496 -216 158 10 219 162 10 224 166 10 226 170 11
54497 -230 174 11 236 178 12 239 182 13 239 182 13
54498 -242 186 14 246 186 14 246 190 14 246 190 14
54499 -246 190 14 246 190 14 246 190 14 246 190 14
54500 -246 186 14 230 174 11 210 150 10 163 110 8
54501 -104 69 6 10 10 10 2 2 6 2 2 6
54502 - 2 2 6 2 2 6 2 2 6 2 2 6
54503 - 2 2 6 2 2 6 2 2 6 2 2 6
54504 - 2 2 6 2 2 6 2 2 6 2 2 6
54505 - 2 2 6 6 6 6 91 60 6 167 114 7
54506 -206 145 10 230 174 11 242 186 14 246 190 14
54507 -246 190 14 246 190 14 246 186 14 242 186 14
54508 -239 182 13 230 174 11 224 166 10 213 154 11
54509 -180 133 36 124 112 88 86 86 86 58 58 58
54510 - 38 38 38 22 22 22 10 10 10 6 6 6
54511 - 0 0 0 0 0 0 0 0 0 0 0 0
54512 - 0 0 0 0 0 0 0 0 0 0 0 0
54513 - 0 0 0 0 0 0 0 0 0 0 0 0
54514 - 0 0 0 0 0 0 0 0 0 14 14 14
54515 - 34 34 34 70 70 70 138 110 50 158 118 36
54516 -167 114 7 180 123 7 192 133 9 197 138 11
54517 -200 144 11 206 145 10 213 154 11 219 162 10
54518 -224 166 10 230 174 11 239 182 13 242 186 14
54519 -246 186 14 246 186 14 246 186 14 246 186 14
54520 -239 182 13 216 158 10 185 133 11 152 99 6
54521 -104 69 6 18 14 6 2 2 6 2 2 6
54522 - 2 2 6 2 2 6 2 2 6 2 2 6
54523 - 2 2 6 2 2 6 2 2 6 2 2 6
54524 - 2 2 6 2 2 6 2 2 6 2 2 6
54525 - 2 2 6 6 6 6 80 54 7 152 99 6
54526 -192 133 9 219 162 10 236 178 12 239 182 13
54527 -246 186 14 242 186 14 239 182 13 236 178 12
54528 -224 166 10 206 145 10 192 133 9 154 121 60
54529 - 94 94 94 62 62 62 42 42 42 22 22 22
54530 - 14 14 14 6 6 6 0 0 0 0 0 0
54531 - 0 0 0 0 0 0 0 0 0 0 0 0
54532 - 0 0 0 0 0 0 0 0 0 0 0 0
54533 - 0 0 0 0 0 0 0 0 0 0 0 0
54534 - 0 0 0 0 0 0 0 0 0 6 6 6
54535 - 18 18 18 34 34 34 58 58 58 78 78 78
54536 -101 98 89 124 112 88 142 110 46 156 107 11
54537 -163 110 8 167 114 7 175 118 6 180 123 7
54538 -185 133 11 197 138 11 210 150 10 219 162 10
54539 -226 170 11 236 178 12 236 178 12 234 174 13
54540 -219 162 10 197 138 11 163 110 8 130 83 6
54541 - 91 60 6 10 10 10 2 2 6 2 2 6
54542 - 18 18 18 38 38 38 38 38 38 38 38 38
54543 - 38 38 38 38 38 38 38 38 38 38 38 38
54544 - 38 38 38 38 38 38 26 26 26 2 2 6
54545 - 2 2 6 6 6 6 70 47 6 137 92 6
54546 -175 118 6 200 144 11 219 162 10 230 174 11
54547 -234 174 13 230 174 11 219 162 10 210 150 10
54548 -192 133 9 163 110 8 124 112 88 82 82 82
54549 - 50 50 50 30 30 30 14 14 14 6 6 6
54550 - 0 0 0 0 0 0 0 0 0 0 0 0
54551 - 0 0 0 0 0 0 0 0 0 0 0 0
54552 - 0 0 0 0 0 0 0 0 0 0 0 0
54553 - 0 0 0 0 0 0 0 0 0 0 0 0
54554 - 0 0 0 0 0 0 0 0 0 0 0 0
54555 - 6 6 6 14 14 14 22 22 22 34 34 34
54556 - 42 42 42 58 58 58 74 74 74 86 86 86
54557 -101 98 89 122 102 70 130 98 46 121 87 25
54558 -137 92 6 152 99 6 163 110 8 180 123 7
54559 -185 133 11 197 138 11 206 145 10 200 144 11
54560 -180 123 7 156 107 11 130 83 6 104 69 6
54561 - 50 34 6 54 54 54 110 110 110 101 98 89
54562 - 86 86 86 82 82 82 78 78 78 78 78 78
54563 - 78 78 78 78 78 78 78 78 78 78 78 78
54564 - 78 78 78 82 82 82 86 86 86 94 94 94
54565 -106 106 106 101 101 101 86 66 34 124 80 6
54566 -156 107 11 180 123 7 192 133 9 200 144 11
54567 -206 145 10 200 144 11 192 133 9 175 118 6
54568 -139 102 15 109 106 95 70 70 70 42 42 42
54569 - 22 22 22 10 10 10 0 0 0 0 0 0
54570 - 0 0 0 0 0 0 0 0 0 0 0 0
54571 - 0 0 0 0 0 0 0 0 0 0 0 0
54572 - 0 0 0 0 0 0 0 0 0 0 0 0
54573 - 0 0 0 0 0 0 0 0 0 0 0 0
54574 - 0 0 0 0 0 0 0 0 0 0 0 0
54575 - 0 0 0 0 0 0 6 6 6 10 10 10
54576 - 14 14 14 22 22 22 30 30 30 38 38 38
54577 - 50 50 50 62 62 62 74 74 74 90 90 90
54578 -101 98 89 112 100 78 121 87 25 124 80 6
54579 -137 92 6 152 99 6 152 99 6 152 99 6
54580 -138 86 6 124 80 6 98 70 6 86 66 30
54581 -101 98 89 82 82 82 58 58 58 46 46 46
54582 - 38 38 38 34 34 34 34 34 34 34 34 34
54583 - 34 34 34 34 34 34 34 34 34 34 34 34
54584 - 34 34 34 34 34 34 38 38 38 42 42 42
54585 - 54 54 54 82 82 82 94 86 76 91 60 6
54586 -134 86 6 156 107 11 167 114 7 175 118 6
54587 -175 118 6 167 114 7 152 99 6 121 87 25
54588 -101 98 89 62 62 62 34 34 34 18 18 18
54589 - 6 6 6 0 0 0 0 0 0 0 0 0
54590 - 0 0 0 0 0 0 0 0 0 0 0 0
54591 - 0 0 0 0 0 0 0 0 0 0 0 0
54592 - 0 0 0 0 0 0 0 0 0 0 0 0
54593 - 0 0 0 0 0 0 0 0 0 0 0 0
54594 - 0 0 0 0 0 0 0 0 0 0 0 0
54595 - 0 0 0 0 0 0 0 0 0 0 0 0
54596 - 0 0 0 6 6 6 6 6 6 10 10 10
54597 - 18 18 18 22 22 22 30 30 30 42 42 42
54598 - 50 50 50 66 66 66 86 86 86 101 98 89
54599 -106 86 58 98 70 6 104 69 6 104 69 6
54600 -104 69 6 91 60 6 82 62 34 90 90 90
54601 - 62 62 62 38 38 38 22 22 22 14 14 14
54602 - 10 10 10 10 10 10 10 10 10 10 10 10
54603 - 10 10 10 10 10 10 6 6 6 10 10 10
54604 - 10 10 10 10 10 10 10 10 10 14 14 14
54605 - 22 22 22 42 42 42 70 70 70 89 81 66
54606 - 80 54 7 104 69 6 124 80 6 137 92 6
54607 -134 86 6 116 81 8 100 82 52 86 86 86
54608 - 58 58 58 30 30 30 14 14 14 6 6 6
54609 - 0 0 0 0 0 0 0 0 0 0 0 0
54610 - 0 0 0 0 0 0 0 0 0 0 0 0
54611 - 0 0 0 0 0 0 0 0 0 0 0 0
54612 - 0 0 0 0 0 0 0 0 0 0 0 0
54613 - 0 0 0 0 0 0 0 0 0 0 0 0
54614 - 0 0 0 0 0 0 0 0 0 0 0 0
54615 - 0 0 0 0 0 0 0 0 0 0 0 0
54616 - 0 0 0 0 0 0 0 0 0 0 0 0
54617 - 0 0 0 6 6 6 10 10 10 14 14 14
54618 - 18 18 18 26 26 26 38 38 38 54 54 54
54619 - 70 70 70 86 86 86 94 86 76 89 81 66
54620 - 89 81 66 86 86 86 74 74 74 50 50 50
54621 - 30 30 30 14 14 14 6 6 6 0 0 0
54622 - 0 0 0 0 0 0 0 0 0 0 0 0
54623 - 0 0 0 0 0 0 0 0 0 0 0 0
54624 - 0 0 0 0 0 0 0 0 0 0 0 0
54625 - 6 6 6 18 18 18 34 34 34 58 58 58
54626 - 82 82 82 89 81 66 89 81 66 89 81 66
54627 - 94 86 66 94 86 76 74 74 74 50 50 50
54628 - 26 26 26 14 14 14 6 6 6 0 0 0
54629 - 0 0 0 0 0 0 0 0 0 0 0 0
54630 - 0 0 0 0 0 0 0 0 0 0 0 0
54631 - 0 0 0 0 0 0 0 0 0 0 0 0
54632 - 0 0 0 0 0 0 0 0 0 0 0 0
54633 - 0 0 0 0 0 0 0 0 0 0 0 0
54634 - 0 0 0 0 0 0 0 0 0 0 0 0
54635 - 0 0 0 0 0 0 0 0 0 0 0 0
54636 - 0 0 0 0 0 0 0 0 0 0 0 0
54637 - 0 0 0 0 0 0 0 0 0 0 0 0
54638 - 6 6 6 6 6 6 14 14 14 18 18 18
54639 - 30 30 30 38 38 38 46 46 46 54 54 54
54640 - 50 50 50 42 42 42 30 30 30 18 18 18
54641 - 10 10 10 0 0 0 0 0 0 0 0 0
54642 - 0 0 0 0 0 0 0 0 0 0 0 0
54643 - 0 0 0 0 0 0 0 0 0 0 0 0
54644 - 0 0 0 0 0 0 0 0 0 0 0 0
54645 - 0 0 0 6 6 6 14 14 14 26 26 26
54646 - 38 38 38 50 50 50 58 58 58 58 58 58
54647 - 54 54 54 42 42 42 30 30 30 18 18 18
54648 - 10 10 10 0 0 0 0 0 0 0 0 0
54649 - 0 0 0 0 0 0 0 0 0 0 0 0
54650 - 0 0 0 0 0 0 0 0 0 0 0 0
54651 - 0 0 0 0 0 0 0 0 0 0 0 0
54652 - 0 0 0 0 0 0 0 0 0 0 0 0
54653 - 0 0 0 0 0 0 0 0 0 0 0 0
54654 - 0 0 0 0 0 0 0 0 0 0 0 0
54655 - 0 0 0 0 0 0 0 0 0 0 0 0
54656 - 0 0 0 0 0 0 0 0 0 0 0 0
54657 - 0 0 0 0 0 0 0 0 0 0 0 0
54658 - 0 0 0 0 0 0 0 0 0 6 6 6
54659 - 6 6 6 10 10 10 14 14 14 18 18 18
54660 - 18 18 18 14 14 14 10 10 10 6 6 6
54661 - 0 0 0 0 0 0 0 0 0 0 0 0
54662 - 0 0 0 0 0 0 0 0 0 0 0 0
54663 - 0 0 0 0 0 0 0 0 0 0 0 0
54664 - 0 0 0 0 0 0 0 0 0 0 0 0
54665 - 0 0 0 0 0 0 0 0 0 6 6 6
54666 - 14 14 14 18 18 18 22 22 22 22 22 22
54667 - 18 18 18 14 14 14 10 10 10 6 6 6
54668 - 0 0 0 0 0 0 0 0 0 0 0 0
54669 - 0 0 0 0 0 0 0 0 0 0 0 0
54670 - 0 0 0 0 0 0 0 0 0 0 0 0
54671 - 0 0 0 0 0 0 0 0 0 0 0 0
54672 - 0 0 0 0 0 0 0 0 0 0 0 0
54673 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
54674 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
54675 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
54676 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
54677 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
54678 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
54679 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
54680 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
54681 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
54682 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
54683 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
54684 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
54685 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
54686 +4 4 4 4 4 4
54687 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
54688 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
54689 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
54690 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
54691 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
54692 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
54693 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
54694 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
54695 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
54696 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
54697 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
54698 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
54699 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
54700 +4 4 4 4 4 4
54701 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
54702 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
54703 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
54704 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
54705 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
54706 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
54707 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
54708 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
54709 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
54710 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
54711 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
54712 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
54713 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
54714 +4 4 4 4 4 4
54715 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
54716 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
54717 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
54718 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
54719 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
54720 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
54721 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
54722 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
54723 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
54724 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
54725 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
54726 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
54727 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
54728 +4 4 4 4 4 4
54729 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
54730 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
54731 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
54732 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
54733 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
54734 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
54735 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
54736 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
54737 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
54738 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
54739 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
54740 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
54741 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
54742 +4 4 4 4 4 4
54743 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
54744 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
54745 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
54746 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
54747 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
54748 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
54749 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
54750 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
54751 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
54752 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
54753 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
54754 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
54755 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
54756 +4 4 4 4 4 4
54757 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
54758 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
54759 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
54760 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
54761 +4 4 4 4 4 4 4 4 4 3 3 3 0 0 0 0 0 0
54762 +0 0 0 0 0 0 0 0 0 0 0 0 3 3 3 4 4 4
54763 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
54764 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
54765 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
54766 +4 4 4 4 4 4 4 4 4 4 4 4 1 1 1 0 0 0
54767 +0 0 0 3 3 3 4 4 4 4 4 4 4 4 4 4 4 4
54768 +4 4 4 4 4 4 4 4 4 2 1 0 2 1 0 3 2 2
54769 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
54770 +4 4 4 4 4 4
54771 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
54772 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
54773 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
54774 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
54775 +4 4 4 4 4 4 2 2 2 0 0 0 3 4 3 26 28 28
54776 +37 38 37 37 38 37 14 17 19 2 2 2 0 0 0 2 2 2
54777 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
54778 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
54779 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
54780 +4 4 4 4 4 4 3 3 3 0 0 0 1 1 1 6 6 6
54781 +2 2 2 0 0 0 3 3 3 4 4 4 4 4 4 4 4 4
54782 +4 4 5 3 3 3 1 0 0 0 0 0 1 0 0 0 0 0
54783 +1 1 1 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
54784 +4 4 4 4 4 4
54785 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
54786 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
54787 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
54788 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
54789 +2 2 2 0 0 0 0 0 0 14 17 19 60 74 84 137 136 137
54790 +153 152 153 137 136 137 125 124 125 60 73 81 6 6 6 3 1 0
54791 +0 0 0 3 3 3 4 4 4 4 4 4 4 4 4 4 4 4
54792 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
54793 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
54794 +4 4 4 4 4 4 0 0 0 4 4 4 41 54 63 125 124 125
54795 +60 73 81 6 6 6 4 0 0 3 3 3 4 4 4 4 4 4
54796 +4 4 4 0 0 0 6 9 11 41 54 63 41 65 82 22 30 35
54797 +2 2 2 2 1 0 4 4 4 4 4 4 4 4 4 4 4 4
54798 +4 4 4 4 4 4
54799 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
54800 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
54801 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
54802 +4 4 4 4 4 4 5 5 5 5 5 5 2 2 2 0 0 0
54803 +4 0 0 6 6 6 41 54 63 137 136 137 174 174 174 167 166 167
54804 +165 164 165 165 164 165 163 162 163 163 162 163 125 124 125 41 54 63
54805 +1 1 1 0 0 0 0 0 0 3 3 3 5 5 5 4 4 4
54806 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
54807 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5
54808 +3 3 3 2 0 0 4 0 0 60 73 81 156 155 156 167 166 167
54809 +163 162 163 85 115 134 5 7 8 0 0 0 4 4 4 5 5 5
54810 +0 0 0 2 5 5 55 98 126 90 154 193 90 154 193 72 125 159
54811 +37 51 59 2 0 0 1 1 1 4 5 5 4 4 4 4 4 4
54812 +4 4 4 4 4 4
54813 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
54814 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
54815 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
54816 +4 4 4 5 5 5 4 4 4 1 1 1 0 0 0 3 3 3
54817 +37 38 37 125 124 125 163 162 163 174 174 174 158 157 158 158 157 158
54818 +156 155 156 156 155 156 158 157 158 165 164 165 174 174 174 166 165 166
54819 +125 124 125 16 19 21 1 0 0 0 0 0 0 0 0 4 4 4
54820 +5 5 5 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
54821 +4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 1 1 1
54822 +0 0 0 0 0 0 37 38 37 153 152 153 174 174 174 158 157 158
54823 +174 174 174 163 162 163 37 38 37 4 3 3 4 0 0 1 1 1
54824 +0 0 0 22 40 52 101 161 196 101 161 196 90 154 193 101 161 196
54825 +64 123 161 14 17 19 0 0 0 4 4 4 4 4 4 4 4 4
54826 +4 4 4 4 4 4
54827 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
54828 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
54829 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
54830 +5 5 5 2 2 2 0 0 0 4 0 0 24 26 27 85 115 134
54831 +156 155 156 174 174 174 167 166 167 156 155 156 154 153 154 157 156 157
54832 +156 155 156 156 155 156 155 154 155 153 152 153 158 157 158 167 166 167
54833 +174 174 174 156 155 156 60 74 84 16 19 21 0 0 0 0 0 0
54834 +1 1 1 5 5 5 5 5 5 4 4 4 4 4 4 4 4 4
54835 +4 4 4 5 5 5 6 6 6 3 3 3 0 0 0 4 0 0
54836 +13 16 17 60 73 81 137 136 137 165 164 165 156 155 156 153 152 153
54837 +174 174 174 177 184 187 60 73 81 3 1 0 0 0 0 1 1 2
54838 +22 30 35 64 123 161 136 185 209 90 154 193 90 154 193 90 154 193
54839 +90 154 193 21 29 34 0 0 0 3 2 2 4 4 5 4 4 4
54840 +4 4 4 4 4 4
54841 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
54842 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
54843 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 3 3 3
54844 +0 0 0 0 0 0 10 13 16 60 74 84 157 156 157 174 174 174
54845 +174 174 174 158 157 158 153 152 153 154 153 154 156 155 156 155 154 155
54846 +156 155 156 155 154 155 154 153 154 157 156 157 154 153 154 153 152 153
54847 +163 162 163 174 174 174 177 184 187 137 136 137 60 73 81 13 16 17
54848 +4 0 0 0 0 0 3 3 3 5 5 5 4 4 4 4 4 4
54849 +5 5 5 4 4 4 1 1 1 0 0 0 3 3 3 41 54 63
54850 +131 129 131 174 174 174 174 174 174 174 174 174 167 166 167 174 174 174
54851 +190 197 201 137 136 137 24 26 27 4 0 0 16 21 25 50 82 103
54852 +90 154 193 136 185 209 90 154 193 101 161 196 101 161 196 101 161 196
54853 +31 91 132 3 6 7 0 0 0 4 4 4 4 4 4 4 4 4
54854 +4 4 4 4 4 4
54855 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
54856 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
54857 +4 4 4 4 4 4 4 4 4 2 2 2 0 0 0 4 0 0
54858 +4 0 0 43 57 68 137 136 137 177 184 187 174 174 174 163 162 163
54859 +155 154 155 155 154 155 156 155 156 155 154 155 158 157 158 165 164 165
54860 +167 166 167 166 165 166 163 162 163 157 156 157 155 154 155 155 154 155
54861 +153 152 153 156 155 156 167 166 167 174 174 174 174 174 174 131 129 131
54862 +41 54 63 5 5 5 0 0 0 0 0 0 3 3 3 4 4 4
54863 +1 1 1 0 0 0 1 0 0 26 28 28 125 124 125 174 174 174
54864 +177 184 187 174 174 174 174 174 174 156 155 156 131 129 131 137 136 137
54865 +125 124 125 24 26 27 4 0 0 41 65 82 90 154 193 136 185 209
54866 +136 185 209 101 161 196 53 118 160 37 112 160 90 154 193 34 86 122
54867 +7 12 15 0 0 0 4 4 4 4 4 4 4 4 4 4 4 4
54868 +4 4 4 4 4 4
54869 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
54870 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
54871 +4 4 4 3 3 3 0 0 0 0 0 0 5 5 5 37 38 37
54872 +125 124 125 167 166 167 174 174 174 167 166 167 158 157 158 155 154 155
54873 +156 155 156 156 155 156 156 155 156 163 162 163 167 166 167 155 154 155
54874 +137 136 137 153 152 153 156 155 156 165 164 165 163 162 163 156 155 156
54875 +156 155 156 156 155 156 155 154 155 158 157 158 166 165 166 174 174 174
54876 +167 166 167 125 124 125 37 38 37 1 0 0 0 0 0 0 0 0
54877 +0 0 0 24 26 27 60 74 84 158 157 158 174 174 174 174 174 174
54878 +166 165 166 158 157 158 125 124 125 41 54 63 13 16 17 6 6 6
54879 +6 6 6 37 38 37 80 127 157 136 185 209 101 161 196 101 161 196
54880 +90 154 193 28 67 93 6 10 14 13 20 25 13 20 25 6 10 14
54881 +1 1 2 4 3 3 4 4 4 4 4 4 4 4 4 4 4 4
54882 +4 4 4 4 4 4
54883 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
54884 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
54885 +1 1 1 1 0 0 4 3 3 37 38 37 60 74 84 153 152 153
54886 +167 166 167 167 166 167 158 157 158 154 153 154 155 154 155 156 155 156
54887 +157 156 157 158 157 158 167 166 167 167 166 167 131 129 131 43 57 68
54888 +26 28 28 37 38 37 60 73 81 131 129 131 165 164 165 166 165 166
54889 +158 157 158 155 154 155 156 155 156 156 155 156 156 155 156 158 157 158
54890 +165 164 165 174 174 174 163 162 163 60 74 84 16 19 21 13 16 17
54891 +60 73 81 131 129 131 174 174 174 174 174 174 167 166 167 165 164 165
54892 +137 136 137 60 73 81 24 26 27 4 0 0 4 0 0 16 19 21
54893 +52 104 138 101 161 196 136 185 209 136 185 209 90 154 193 27 99 146
54894 +13 20 25 4 5 7 2 5 5 4 5 7 1 1 2 0 0 0
54895 +4 4 4 4 4 4 3 3 3 2 2 2 2 2 2 4 4 4
54896 +4 4 4 4 4 4
54897 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
54898 +4 4 4 4 4 4 4 4 4 4 4 4 3 3 3 0 0 0
54899 +0 0 0 13 16 17 60 73 81 137 136 137 174 174 174 166 165 166
54900 +158 157 158 156 155 156 157 156 157 156 155 156 155 154 155 158 157 158
54901 +167 166 167 174 174 174 153 152 153 60 73 81 16 19 21 4 0 0
54902 +4 0 0 4 0 0 6 6 6 26 28 28 60 74 84 158 157 158
54903 +174 174 174 166 165 166 157 156 157 155 154 155 156 155 156 156 155 156
54904 +155 154 155 158 157 158 167 166 167 167 166 167 131 129 131 125 124 125
54905 +137 136 137 167 166 167 167 166 167 174 174 174 158 157 158 125 124 125
54906 +16 19 21 4 0 0 4 0 0 10 13 16 49 76 92 107 159 188
54907 +136 185 209 136 185 209 90 154 193 26 108 161 22 40 52 6 10 14
54908 +2 3 3 1 1 2 1 1 2 4 4 5 4 4 5 4 4 5
54909 +4 4 5 2 2 1 0 0 0 0 0 0 0 0 0 2 2 2
54910 +4 4 4 4 4 4
54911 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
54912 +4 4 4 5 5 5 3 3 3 0 0 0 1 0 0 4 0 0
54913 +37 51 59 131 129 131 167 166 167 167 166 167 163 162 163 157 156 157
54914 +157 156 157 155 154 155 153 152 153 157 156 157 167 166 167 174 174 174
54915 +153 152 153 125 124 125 37 38 37 4 0 0 4 0 0 4 0 0
54916 +4 3 3 4 3 3 4 0 0 6 6 6 4 0 0 37 38 37
54917 +125 124 125 174 174 174 174 174 174 165 164 165 156 155 156 154 153 154
54918 +156 155 156 156 155 156 155 154 155 163 162 163 158 157 158 163 162 163
54919 +174 174 174 174 174 174 174 174 174 125 124 125 37 38 37 0 0 0
54920 +4 0 0 6 9 11 41 54 63 90 154 193 136 185 209 146 190 211
54921 +136 185 209 37 112 160 22 40 52 6 10 14 3 6 7 1 1 2
54922 +1 1 2 3 3 3 1 1 2 3 3 3 4 4 4 4 4 4
54923 +2 2 2 2 0 0 16 19 21 37 38 37 24 26 27 0 0 0
54924 +0 0 0 4 4 4
54925 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5
54926 +4 4 4 0 0 0 0 0 0 0 0 0 26 28 28 120 125 127
54927 +158 157 158 174 174 174 165 164 165 157 156 157 155 154 155 156 155 156
54928 +153 152 153 153 152 153 167 166 167 174 174 174 174 174 174 125 124 125
54929 +37 38 37 4 0 0 0 0 0 4 0 0 4 3 3 4 4 4
54930 +4 4 4 4 4 4 5 5 5 4 0 0 4 0 0 4 0 0
54931 +4 3 3 43 57 68 137 136 137 174 174 174 174 174 174 165 164 165
54932 +154 153 154 153 152 153 153 152 153 153 152 153 163 162 163 174 174 174
54933 +174 174 174 153 152 153 60 73 81 6 6 6 4 0 0 4 3 3
54934 +32 43 50 80 127 157 136 185 209 146 190 211 146 190 211 90 154 193
54935 +28 67 93 28 67 93 40 71 93 3 6 7 1 1 2 2 5 5
54936 +50 82 103 79 117 143 26 37 45 0 0 0 3 3 3 1 1 1
54937 +0 0 0 41 54 63 137 136 137 174 174 174 153 152 153 60 73 81
54938 +2 0 0 0 0 0
54939 +4 4 4 4 4 4 4 4 4 4 4 4 6 6 6 2 2 2
54940 +0 0 0 2 0 0 24 26 27 60 74 84 153 152 153 174 174 174
54941 +174 174 174 157 156 157 154 153 154 156 155 156 154 153 154 153 152 153
54942 +165 164 165 174 174 174 177 184 187 137 136 137 43 57 68 6 6 6
54943 +4 0 0 2 0 0 3 3 3 5 5 5 5 5 5 4 4 4
54944 +4 4 4 4 4 4 4 4 4 5 5 5 6 6 6 4 3 3
54945 +4 0 0 4 0 0 24 26 27 60 73 81 153 152 153 174 174 174
54946 +174 174 174 158 157 158 158 157 158 174 174 174 174 174 174 158 157 158
54947 +60 74 84 24 26 27 4 0 0 4 0 0 17 23 27 59 113 148
54948 +136 185 209 191 222 234 146 190 211 136 185 209 31 91 132 7 11 13
54949 +22 40 52 101 161 196 90 154 193 6 9 11 3 4 4 43 95 132
54950 +136 185 209 172 205 220 55 98 126 0 0 0 0 0 0 2 0 0
54951 +26 28 28 153 152 153 177 184 187 167 166 167 177 184 187 165 164 165
54952 +37 38 37 0 0 0
54953 +4 4 4 4 4 4 5 5 5 5 5 5 1 1 1 0 0 0
54954 +13 16 17 60 73 81 137 136 137 174 174 174 174 174 174 165 164 165
54955 +153 152 153 153 152 153 155 154 155 154 153 154 158 157 158 174 174 174
54956 +177 184 187 163 162 163 60 73 81 16 19 21 4 0 0 4 0 0
54957 +4 3 3 4 4 4 5 5 5 5 5 5 4 4 4 5 5 5
54958 +5 5 5 5 5 5 5 5 5 4 4 4 4 4 4 5 5 5
54959 +6 6 6 4 0 0 4 0 0 4 0 0 24 26 27 60 74 84
54960 +166 165 166 174 174 174 177 184 187 165 164 165 125 124 125 24 26 27
54961 +4 0 0 4 0 0 5 5 5 50 82 103 136 185 209 172 205 220
54962 +146 190 211 136 185 209 26 108 161 22 40 52 7 12 15 44 81 103
54963 +71 116 144 28 67 93 37 51 59 41 65 82 100 139 164 101 161 196
54964 +90 154 193 90 154 193 28 67 93 0 0 0 0 0 0 26 28 28
54965 +125 124 125 167 166 167 163 162 163 153 152 153 163 162 163 174 174 174
54966 +85 115 134 4 0 0
54967 +4 4 4 5 5 5 4 4 4 1 0 0 4 0 0 34 47 55
54968 +125 124 125 174 174 174 174 174 174 167 166 167 157 156 157 153 152 153
54969 +155 154 155 155 154 155 158 157 158 166 165 166 167 166 167 154 153 154
54970 +125 124 125 26 28 28 4 0 0 4 0 0 4 0 0 5 5 5
54971 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 1 1 1
54972 +0 0 0 0 0 0 1 1 1 4 4 4 4 4 4 4 4 4
54973 +5 5 5 5 5 5 4 3 3 4 0 0 4 0 0 6 6 6
54974 +37 38 37 131 129 131 137 136 137 37 38 37 0 0 0 4 0 0
54975 +4 5 5 43 61 72 90 154 193 172 205 220 146 190 211 136 185 209
54976 +90 154 193 28 67 93 13 20 25 43 61 72 71 116 144 44 81 103
54977 +2 5 5 7 11 13 59 113 148 101 161 196 90 154 193 28 67 93
54978 +13 20 25 6 10 14 0 0 0 13 16 17 60 73 81 137 136 137
54979 +166 165 166 158 157 158 156 155 156 154 153 154 167 166 167 174 174 174
54980 +60 73 81 4 0 0
54981 +4 4 4 4 4 4 0 0 0 3 3 3 60 74 84 174 174 174
54982 +174 174 174 167 166 167 163 162 163 155 154 155 157 156 157 155 154 155
54983 +156 155 156 163 162 163 167 166 167 158 157 158 125 124 125 37 38 37
54984 +4 3 3 4 0 0 4 0 0 6 6 6 6 6 6 5 5 5
54985 +4 4 4 4 4 4 4 4 4 1 1 1 0 0 0 2 3 3
54986 +10 13 16 7 11 13 1 0 0 0 0 0 2 2 1 4 4 4
54987 +4 4 4 4 4 4 4 4 4 5 5 5 4 3 3 4 0 0
54988 +4 0 0 7 11 13 13 16 17 4 0 0 3 3 3 34 47 55
54989 +80 127 157 146 190 211 172 205 220 136 185 209 136 185 209 136 185 209
54990 +28 67 93 22 40 52 55 98 126 55 98 126 21 29 34 7 11 13
54991 +50 82 103 101 161 196 101 161 196 35 83 115 13 20 25 2 2 1
54992 +1 1 2 1 1 2 37 51 59 131 129 131 174 174 174 174 174 174
54993 +167 166 167 163 162 163 163 162 163 167 166 167 174 174 174 125 124 125
54994 +16 19 21 4 0 0
54995 +4 4 4 4 0 0 4 0 0 60 74 84 174 174 174 174 174 174
54996 +158 157 158 155 154 155 155 154 155 156 155 156 155 154 155 158 157 158
54997 +167 166 167 165 164 165 131 129 131 60 73 81 13 16 17 4 0 0
54998 +4 0 0 4 3 3 6 6 6 4 3 3 5 5 5 4 4 4
54999 +4 4 4 3 2 2 0 0 0 0 0 0 7 11 13 45 69 86
55000 +80 127 157 71 116 144 43 61 72 7 11 13 0 0 0 1 1 1
55001 +4 3 3 4 4 4 4 4 4 4 4 4 6 6 6 5 5 5
55002 +3 2 2 4 0 0 1 0 0 21 29 34 59 113 148 136 185 209
55003 +146 190 211 136 185 209 136 185 209 136 185 209 136 185 209 136 185 209
55004 +68 124 159 44 81 103 22 40 52 13 16 17 43 61 72 90 154 193
55005 +136 185 209 59 113 148 21 29 34 3 4 3 1 1 1 0 0 0
55006 +24 26 27 125 124 125 163 162 163 174 174 174 166 165 166 165 164 165
55007 +163 162 163 125 124 125 125 124 125 125 124 125 125 124 125 26 28 28
55008 +4 0 0 4 3 3
55009 +3 3 3 0 0 0 24 26 27 153 152 153 177 184 187 158 157 158
55010 +156 155 156 156 155 156 155 154 155 155 154 155 165 164 165 174 174 174
55011 +155 154 155 60 74 84 26 28 28 4 0 0 4 0 0 3 1 0
55012 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 3 3
55013 +2 0 0 0 0 0 0 0 0 32 43 50 72 125 159 101 161 196
55014 +136 185 209 101 161 196 101 161 196 79 117 143 32 43 50 0 0 0
55015 +0 0 0 2 2 2 4 4 4 4 4 4 3 3 3 1 0 0
55016 +0 0 0 4 5 5 49 76 92 101 161 196 146 190 211 146 190 211
55017 +136 185 209 136 185 209 136 185 209 136 185 209 136 185 209 90 154 193
55018 +28 67 93 13 16 17 37 51 59 80 127 157 136 185 209 90 154 193
55019 +22 40 52 6 9 11 3 4 3 2 2 1 16 19 21 60 73 81
55020 +137 136 137 163 162 163 158 157 158 166 165 166 167 166 167 153 152 153
55021 +60 74 84 37 38 37 6 6 6 13 16 17 4 0 0 1 0 0
55022 +3 2 2 4 4 4
55023 +3 2 2 4 0 0 37 38 37 137 136 137 167 166 167 158 157 158
55024 +157 156 157 154 153 154 157 156 157 167 166 167 174 174 174 125 124 125
55025 +37 38 37 4 0 0 4 0 0 4 0 0 4 3 3 4 4 4
55026 +4 4 4 4 4 4 5 5 5 5 5 5 1 1 1 0 0 0
55027 +0 0 0 16 21 25 55 98 126 90 154 193 136 185 209 101 161 196
55028 +101 161 196 101 161 196 136 185 209 136 185 209 101 161 196 55 98 126
55029 +14 17 19 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
55030 +22 40 52 90 154 193 146 190 211 146 190 211 136 185 209 136 185 209
55031 +136 185 209 136 185 209 136 185 209 101 161 196 35 83 115 7 11 13
55032 +17 23 27 59 113 148 136 185 209 101 161 196 34 86 122 7 12 15
55033 +2 5 5 3 4 3 6 6 6 60 73 81 131 129 131 163 162 163
55034 +166 165 166 174 174 174 174 174 174 163 162 163 125 124 125 41 54 63
55035 +13 16 17 4 0 0 4 0 0 4 0 0 1 0 0 2 2 2
55036 +4 4 4 4 4 4
55037 +1 1 1 2 1 0 43 57 68 137 136 137 153 152 153 153 152 153
55038 +163 162 163 156 155 156 165 164 165 167 166 167 60 74 84 6 6 6
55039 +4 0 0 4 0 0 5 5 5 4 4 4 4 4 4 4 4 4
55040 +4 5 5 6 6 6 4 3 3 0 0 0 0 0 0 11 15 18
55041 +40 71 93 100 139 164 101 161 196 101 161 196 101 161 196 101 161 196
55042 +101 161 196 101 161 196 101 161 196 101 161 196 136 185 209 136 185 209
55043 +101 161 196 45 69 86 6 6 6 0 0 0 17 23 27 55 98 126
55044 +136 185 209 146 190 211 136 185 209 136 185 209 136 185 209 136 185 209
55045 +136 185 209 136 185 209 90 154 193 22 40 52 7 11 13 50 82 103
55046 +136 185 209 136 185 209 53 118 160 22 40 52 7 11 13 2 5 5
55047 +3 4 3 37 38 37 125 124 125 157 156 157 166 165 166 167 166 167
55048 +174 174 174 174 174 174 137 136 137 60 73 81 4 0 0 4 0 0
55049 +4 0 0 4 0 0 5 5 5 3 3 3 3 3 3 4 4 4
55050 +4 4 4 4 4 4
55051 +4 0 0 4 0 0 41 54 63 137 136 137 125 124 125 131 129 131
55052 +155 154 155 167 166 167 174 174 174 60 74 84 6 6 6 4 0 0
55053 +4 3 3 6 6 6 4 4 4 4 4 4 4 4 4 5 5 5
55054 +4 4 4 1 1 1 0 0 0 3 6 7 41 65 82 72 125 159
55055 +101 161 196 101 161 196 101 161 196 90 154 193 90 154 193 101 161 196
55056 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 136 185 209
55057 +136 185 209 136 185 209 80 127 157 55 98 126 101 161 196 146 190 211
55058 +136 185 209 136 185 209 136 185 209 101 161 196 136 185 209 101 161 196
55059 +136 185 209 101 161 196 35 83 115 22 30 35 101 161 196 172 205 220
55060 +90 154 193 28 67 93 7 11 13 2 5 5 3 4 3 13 16 17
55061 +85 115 134 167 166 167 174 174 174 174 174 174 174 174 174 174 174 174
55062 +167 166 167 60 74 84 13 16 17 4 0 0 4 0 0 4 3 3
55063 +6 6 6 5 5 5 4 4 4 5 5 5 4 4 4 5 5 5
55064 +5 5 5 5 5 5
55065 +1 1 1 4 0 0 41 54 63 137 136 137 137 136 137 125 124 125
55066 +131 129 131 167 166 167 157 156 157 37 38 37 6 6 6 4 0 0
55067 +6 6 6 5 5 5 4 4 4 4 4 4 4 5 5 2 2 1
55068 +0 0 0 0 0 0 26 37 45 58 111 146 101 161 196 101 161 196
55069 +101 161 196 90 154 193 90 154 193 90 154 193 101 161 196 101 161 196
55070 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
55071 +101 161 196 136 185 209 136 185 209 136 185 209 146 190 211 136 185 209
55072 +136 185 209 101 161 196 136 185 209 136 185 209 101 161 196 136 185 209
55073 +101 161 196 136 185 209 136 185 209 136 185 209 136 185 209 16 89 141
55074 +7 11 13 2 5 5 2 5 5 13 16 17 60 73 81 154 154 154
55075 +174 174 174 174 174 174 174 174 174 174 174 174 163 162 163 125 124 125
55076 +24 26 27 4 0 0 4 0 0 4 0 0 5 5 5 5 5 5
55077 +4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 5
55078 +5 5 5 4 4 4
55079 +4 0 0 6 6 6 37 38 37 137 136 137 137 136 137 131 129 131
55080 +131 129 131 153 152 153 131 129 131 26 28 28 4 0 0 4 3 3
55081 +6 6 6 4 4 4 4 4 4 4 4 4 0 0 0 0 0 0
55082 +13 20 25 51 88 114 90 154 193 101 161 196 101 161 196 90 154 193
55083 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 101 161 196
55084 +101 161 196 101 161 196 101 161 196 101 161 196 136 185 209 101 161 196
55085 +101 161 196 136 185 209 101 161 196 136 185 209 136 185 209 101 161 196
55086 +136 185 209 101 161 196 136 185 209 101 161 196 101 161 196 101 161 196
55087 +136 185 209 136 185 209 136 185 209 37 112 160 21 29 34 5 7 8
55088 +2 5 5 13 16 17 43 57 68 131 129 131 174 174 174 174 174 174
55089 +174 174 174 167 166 167 157 156 157 125 124 125 37 38 37 4 0 0
55090 +4 0 0 4 0 0 5 5 5 5 5 5 4 4 4 4 4 4
55091 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55092 +4 4 4 4 4 4
55093 +1 1 1 4 0 0 41 54 63 153 152 153 137 136 137 137 136 137
55094 +137 136 137 153 152 153 125 124 125 24 26 27 4 0 0 3 2 2
55095 +4 4 4 4 4 4 4 3 3 4 0 0 3 6 7 43 61 72
55096 +64 123 161 101 161 196 90 154 193 90 154 193 90 154 193 90 154 193
55097 +90 154 193 90 154 193 90 154 193 90 154 193 101 161 196 90 154 193
55098 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
55099 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
55100 +136 185 209 101 161 196 101 161 196 136 185 209 136 185 209 101 161 196
55101 +101 161 196 90 154 193 28 67 93 13 16 17 7 11 13 3 6 7
55102 +37 51 59 125 124 125 163 162 163 174 174 174 167 166 167 166 165 166
55103 +167 166 167 131 129 131 60 73 81 4 0 0 4 0 0 4 0 0
55104 +3 3 3 5 5 5 6 6 6 4 4 4 4 4 4 4 4 4
55105 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55106 +4 4 4 4 4 4
55107 +4 0 0 4 0 0 41 54 63 137 136 137 153 152 153 137 136 137
55108 +153 152 153 157 156 157 125 124 125 24 26 27 0 0 0 2 2 2
55109 +4 4 4 4 4 4 2 0 0 0 0 0 28 67 93 90 154 193
55110 +90 154 193 90 154 193 90 154 193 90 154 193 64 123 161 90 154 193
55111 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 101 161 196
55112 +90 154 193 101 161 196 101 161 196 101 161 196 90 154 193 136 185 209
55113 +101 161 196 101 161 196 136 185 209 101 161 196 136 185 209 101 161 196
55114 +101 161 196 101 161 196 136 185 209 101 161 196 101 161 196 90 154 193
55115 +35 83 115 13 16 17 3 6 7 2 5 5 13 16 17 60 74 84
55116 +154 154 154 166 165 166 165 164 165 158 157 158 163 162 163 157 156 157
55117 +60 74 84 13 16 17 4 0 0 4 0 0 3 2 2 4 4 4
55118 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55119 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55120 +4 4 4 4 4 4
55121 +1 1 1 4 0 0 41 54 63 157 156 157 155 154 155 137 136 137
55122 +153 152 153 158 157 158 137 136 137 26 28 28 2 0 0 2 2 2
55123 +4 4 4 4 4 4 1 0 0 6 10 14 34 86 122 90 154 193
55124 +64 123 161 90 154 193 64 123 161 90 154 193 90 154 193 90 154 193
55125 +64 123 161 90 154 193 90 154 193 90 154 193 90 154 193 90 154 193
55126 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
55127 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
55128 +136 185 209 101 161 196 136 185 209 90 154 193 26 108 161 22 40 52
55129 +13 16 17 5 7 8 2 5 5 2 5 5 37 38 37 165 164 165
55130 +174 174 174 163 162 163 154 154 154 165 164 165 167 166 167 60 73 81
55131 +6 6 6 4 0 0 4 0 0 4 4 4 4 4 4 4 4 4
55132 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55133 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55134 +4 4 4 4 4 4
55135 +4 0 0 6 6 6 41 54 63 156 155 156 158 157 158 153 152 153
55136 +156 155 156 165 164 165 137 136 137 26 28 28 0 0 0 2 2 2
55137 +4 4 5 4 4 4 2 0 0 7 12 15 31 96 139 64 123 161
55138 +90 154 193 64 123 161 90 154 193 90 154 193 64 123 161 90 154 193
55139 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 90 154 193
55140 +90 154 193 90 154 193 90 154 193 101 161 196 101 161 196 101 161 196
55141 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 136 185 209
55142 +101 161 196 136 185 209 26 108 161 22 40 52 7 11 13 5 7 8
55143 +2 5 5 2 5 5 2 5 5 2 2 1 37 38 37 158 157 158
55144 +174 174 174 154 154 154 156 155 156 167 166 167 165 164 165 37 38 37
55145 +4 0 0 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
55146 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55147 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55148 +4 4 4 4 4 4
55149 +3 1 0 4 0 0 60 73 81 157 156 157 163 162 163 153 152 153
55150 +158 157 158 167 166 167 137 136 137 26 28 28 2 0 0 2 2 2
55151 +4 5 5 4 4 4 4 0 0 7 12 15 24 86 132 26 108 161
55152 +37 112 160 64 123 161 90 154 193 64 123 161 90 154 193 90 154 193
55153 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 90 154 193
55154 +90 154 193 101 161 196 90 154 193 101 161 196 101 161 196 101 161 196
55155 +101 161 196 101 161 196 101 161 196 136 185 209 101 161 196 136 185 209
55156 +90 154 193 35 83 115 13 16 17 13 16 17 7 11 13 3 6 7
55157 +5 7 8 6 6 6 3 4 3 2 2 1 30 32 34 154 154 154
55158 +167 166 167 154 154 154 154 154 154 174 174 174 165 164 165 37 38 37
55159 +6 6 6 4 0 0 6 6 6 4 4 4 4 4 4 4 4 4
55160 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55161 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55162 +4 4 4 4 4 4
55163 +4 0 0 4 0 0 41 54 63 163 162 163 166 165 166 154 154 154
55164 +163 162 163 174 174 174 137 136 137 26 28 28 0 0 0 2 2 2
55165 +4 5 5 4 4 5 1 1 2 6 10 14 28 67 93 18 97 151
55166 +18 97 151 18 97 151 26 108 161 37 112 160 37 112 160 90 154 193
55167 +64 123 161 90 154 193 90 154 193 90 154 193 90 154 193 101 161 196
55168 +90 154 193 101 161 196 101 161 196 90 154 193 101 161 196 101 161 196
55169 +101 161 196 101 161 196 101 161 196 136 185 209 90 154 193 16 89 141
55170 +13 20 25 7 11 13 5 7 8 5 7 8 2 5 5 4 5 5
55171 +3 4 3 4 5 5 3 4 3 0 0 0 37 38 37 158 157 158
55172 +174 174 174 158 157 158 158 157 158 167 166 167 174 174 174 41 54 63
55173 +4 0 0 3 2 2 5 5 5 4 4 4 4 4 4 4 4 4
55174 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55175 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55176 +4 4 4 4 4 4
55177 +1 1 1 4 0 0 60 73 81 165 164 165 174 174 174 158 157 158
55178 +167 166 167 174 174 174 153 152 153 26 28 28 2 0 0 2 2 2
55179 +4 5 5 4 4 4 4 0 0 7 12 15 10 87 144 10 87 144
55180 +18 97 151 18 97 151 18 97 151 26 108 161 26 108 161 26 108 161
55181 +26 108 161 37 112 160 53 118 160 90 154 193 90 154 193 90 154 193
55182 +90 154 193 90 154 193 101 161 196 101 161 196 101 161 196 101 161 196
55183 +101 161 196 136 185 209 90 154 193 26 108 161 22 40 52 13 16 17
55184 +7 11 13 3 6 7 5 7 8 5 7 8 2 5 5 4 5 5
55185 +4 5 5 6 6 6 3 4 3 0 0 0 30 32 34 158 157 158
55186 +174 174 174 156 155 156 155 154 155 165 164 165 154 153 154 37 38 37
55187 +4 0 0 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
55188 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55189 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55190 +4 4 4 4 4 4
55191 +4 0 0 4 0 0 60 73 81 167 166 167 174 174 174 163 162 163
55192 +174 174 174 174 174 174 153 152 153 26 28 28 0 0 0 3 3 3
55193 +5 5 5 4 4 4 1 1 2 7 12 15 28 67 93 18 97 151
55194 +18 97 151 18 97 151 18 97 151 18 97 151 18 97 151 26 108 161
55195 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
55196 +90 154 193 26 108 161 90 154 193 90 154 193 90 154 193 101 161 196
55197 +101 161 196 26 108 161 22 40 52 13 16 17 7 11 13 2 5 5
55198 +2 5 5 6 6 6 2 5 5 4 5 5 4 5 5 4 5 5
55199 +3 4 3 5 5 5 3 4 3 2 0 0 30 32 34 137 136 137
55200 +153 152 153 137 136 137 131 129 131 137 136 137 131 129 131 37 38 37
55201 +4 0 0 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
55202 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55203 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55204 +4 4 4 4 4 4
55205 +1 1 1 4 0 0 60 73 81 167 166 167 174 174 174 166 165 166
55206 +174 174 174 177 184 187 153 152 153 30 32 34 1 0 0 3 3 3
55207 +5 5 5 4 3 3 4 0 0 7 12 15 10 87 144 10 87 144
55208 +18 97 151 18 97 151 18 97 151 26 108 161 26 108 161 26 108 161
55209 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
55210 +26 108 161 26 108 161 26 108 161 90 154 193 90 154 193 26 108 161
55211 +35 83 115 13 16 17 7 11 13 5 7 8 3 6 7 5 7 8
55212 +2 5 5 6 6 6 4 5 5 4 5 5 3 4 3 4 5 5
55213 +3 4 3 6 6 6 3 4 3 0 0 0 26 28 28 125 124 125
55214 +131 129 131 125 124 125 125 124 125 131 129 131 131 129 131 37 38 37
55215 +4 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
55216 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55217 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55218 +4 4 4 4 4 4
55219 +3 1 0 4 0 0 60 73 81 174 174 174 177 184 187 167 166 167
55220 +174 174 174 177 184 187 153 152 153 30 32 34 0 0 0 3 3 3
55221 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 18 97 151
55222 +18 97 151 18 97 151 18 97 151 18 97 151 18 97 151 26 108 161
55223 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
55224 +26 108 161 90 154 193 26 108 161 26 108 161 24 86 132 13 20 25
55225 +7 11 13 13 20 25 22 40 52 5 7 8 3 4 3 3 4 3
55226 +4 5 5 3 4 3 4 5 5 3 4 3 4 5 5 3 4 3
55227 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 125 124 125
55228 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
55229 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
55230 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55231 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55232 +4 4 4 4 4 4
55233 +1 1 1 4 0 0 60 73 81 174 174 174 177 184 187 174 174 174
55234 +174 174 174 190 197 201 157 156 157 30 32 34 1 0 0 3 3 3
55235 +5 5 5 4 3 3 4 0 0 7 12 15 10 87 144 10 87 144
55236 +18 97 151 19 95 150 19 95 150 18 97 151 18 97 151 26 108 161
55237 +18 97 151 26 108 161 26 108 161 26 108 161 26 108 161 90 154 193
55238 +26 108 161 26 108 161 26 108 161 22 40 52 2 5 5 3 4 3
55239 +28 67 93 37 112 160 34 86 122 2 5 5 3 4 3 3 4 3
55240 +3 4 3 3 4 3 3 4 3 2 2 1 3 4 3 4 4 4
55241 +4 5 5 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
55242 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
55243 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
55244 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55245 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55246 +4 4 4 4 4 4
55247 +4 0 0 4 0 0 60 73 81 174 174 174 177 184 187 174 174 174
55248 +174 174 174 190 197 201 158 157 158 30 32 34 0 0 0 2 2 2
55249 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 18 97 151
55250 +10 87 144 19 95 150 19 95 150 18 97 151 18 97 151 18 97 151
55251 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
55252 +18 97 151 22 40 52 2 5 5 2 2 1 22 40 52 26 108 161
55253 +90 154 193 37 112 160 22 40 52 3 4 3 13 20 25 22 30 35
55254 +3 6 7 1 1 1 2 2 2 6 9 11 5 5 5 4 3 3
55255 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 131 129 131
55256 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
55257 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
55258 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55259 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55260 +4 4 4 4 4 4
55261 +1 1 1 4 0 0 60 73 81 177 184 187 193 200 203 174 174 174
55262 +177 184 187 193 200 203 163 162 163 30 32 34 4 0 0 2 2 2
55263 +5 5 5 4 3 3 4 0 0 6 10 14 24 86 132 10 87 144
55264 +10 87 144 10 87 144 19 95 150 19 95 150 19 95 150 18 97 151
55265 +26 108 161 26 108 161 26 108 161 90 154 193 26 108 161 28 67 93
55266 +6 10 14 2 5 5 13 20 25 24 86 132 37 112 160 90 154 193
55267 +10 87 144 7 12 15 2 5 5 28 67 93 37 112 160 28 67 93
55268 +2 2 1 7 12 15 35 83 115 28 67 93 3 6 7 1 0 0
55269 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
55270 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
55271 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
55272 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55273 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55274 +4 4 4 4 4 4
55275 +4 0 0 4 0 0 60 73 81 174 174 174 190 197 201 174 174 174
55276 +177 184 187 193 200 203 163 162 163 30 32 34 0 0 0 2 2 2
55277 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 10 87 144
55278 +10 87 144 16 89 141 19 95 150 10 87 144 26 108 161 26 108 161
55279 +26 108 161 26 108 161 26 108 161 28 67 93 6 10 14 1 1 2
55280 +7 12 15 28 67 93 26 108 161 16 89 141 24 86 132 21 29 34
55281 +3 4 3 21 29 34 37 112 160 37 112 160 27 99 146 21 29 34
55282 +21 29 34 26 108 161 90 154 193 35 83 115 1 1 2 2 0 0
55283 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 125 124 125
55284 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
55285 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
55286 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55287 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55288 +4 4 4 4 4 4
55289 +3 1 0 4 0 0 60 73 81 193 200 203 193 200 203 174 174 174
55290 +190 197 201 193 200 203 165 164 165 37 38 37 4 0 0 2 2 2
55291 +5 5 5 4 3 3 4 0 0 6 10 14 24 86 132 10 87 144
55292 +10 87 144 10 87 144 16 89 141 18 97 151 18 97 151 10 87 144
55293 +24 86 132 24 86 132 13 20 25 4 5 7 4 5 7 22 40 52
55294 +18 97 151 37 112 160 26 108 161 7 12 15 1 1 1 0 0 0
55295 +28 67 93 37 112 160 26 108 161 28 67 93 22 40 52 28 67 93
55296 +26 108 161 90 154 193 26 108 161 10 87 144 0 0 0 2 0 0
55297 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
55298 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
55299 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
55300 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55301 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55302 +4 4 4 4 4 4
55303 +4 0 0 6 6 6 60 73 81 174 174 174 193 200 203 174 174 174
55304 +190 197 201 193 200 203 165 164 165 30 32 34 0 0 0 2 2 2
55305 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 10 87 144
55306 +10 87 144 10 87 144 10 87 144 18 97 151 28 67 93 6 10 14
55307 +0 0 0 1 1 2 4 5 7 13 20 25 16 89 141 26 108 161
55308 +26 108 161 26 108 161 24 86 132 6 9 11 2 3 3 22 40 52
55309 +37 112 160 16 89 141 22 40 52 28 67 93 26 108 161 26 108 161
55310 +90 154 193 26 108 161 26 108 161 28 67 93 1 1 1 4 0 0
55311 +4 4 4 5 5 5 3 3 3 4 0 0 26 28 28 124 126 130
55312 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
55313 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
55314 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55315 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55316 +4 4 4 4 4 4
55317 +4 0 0 4 0 0 60 73 81 193 200 203 193 200 203 174 174 174
55318 +193 200 203 193 200 203 167 166 167 37 38 37 4 0 0 2 2 2
55319 +5 5 5 4 4 4 4 0 0 6 10 14 28 67 93 10 87 144
55320 +10 87 144 10 87 144 18 97 151 10 87 144 13 20 25 4 5 7
55321 +1 1 2 1 1 1 22 40 52 26 108 161 26 108 161 26 108 161
55322 +26 108 161 26 108 161 26 108 161 24 86 132 22 40 52 22 40 52
55323 +22 40 52 22 40 52 10 87 144 26 108 161 26 108 161 26 108 161
55324 +26 108 161 26 108 161 90 154 193 10 87 144 0 0 0 4 0 0
55325 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
55326 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
55327 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
55328 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55329 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55330 +4 4 4 4 4 4
55331 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
55332 +190 197 201 205 212 215 167 166 167 30 32 34 0 0 0 2 2 2
55333 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 10 87 144
55334 +10 87 144 10 87 144 10 87 144 10 87 144 22 40 52 1 1 2
55335 +2 0 0 1 1 2 24 86 132 26 108 161 26 108 161 26 108 161
55336 +26 108 161 19 95 150 16 89 141 10 87 144 22 40 52 22 40 52
55337 +10 87 144 26 108 161 37 112 160 26 108 161 26 108 161 26 108 161
55338 +26 108 161 26 108 161 26 108 161 28 67 93 2 0 0 3 1 0
55339 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 131 129 131
55340 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
55341 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
55342 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55343 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55344 +4 4 4 4 4 4
55345 +4 0 0 4 0 0 60 73 81 220 221 221 190 197 201 174 174 174
55346 +193 200 203 193 200 203 174 174 174 37 38 37 4 0 0 2 2 2
55347 +5 5 5 4 4 4 3 2 2 1 1 2 13 20 25 10 87 144
55348 +10 87 144 10 87 144 10 87 144 10 87 144 10 87 144 13 20 25
55349 +13 20 25 22 40 52 10 87 144 18 97 151 18 97 151 26 108 161
55350 +10 87 144 13 20 25 6 10 14 21 29 34 24 86 132 18 97 151
55351 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
55352 +26 108 161 90 154 193 18 97 151 13 20 25 0 0 0 4 3 3
55353 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
55354 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
55355 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
55356 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55357 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55358 +4 4 4 4 4 4
55359 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
55360 +190 197 201 220 221 221 167 166 167 30 32 34 1 0 0 2 2 2
55361 +5 5 5 4 4 4 4 4 5 2 5 5 4 5 7 13 20 25
55362 +28 67 93 10 87 144 10 87 144 10 87 144 10 87 144 10 87 144
55363 +10 87 144 10 87 144 18 97 151 10 87 144 18 97 151 18 97 151
55364 +28 67 93 2 3 3 0 0 0 28 67 93 26 108 161 26 108 161
55365 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
55366 +26 108 161 10 87 144 13 20 25 1 1 2 3 2 2 4 4 4
55367 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 131 129 131
55368 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
55369 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
55370 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55371 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55372 +4 4 4 4 4 4
55373 +4 0 0 4 0 0 60 73 81 220 221 221 190 197 201 174 174 174
55374 +193 200 203 193 200 203 174 174 174 26 28 28 4 0 0 4 3 3
55375 +5 5 5 4 4 4 4 4 4 4 4 5 1 1 2 2 5 5
55376 +4 5 7 22 40 52 10 87 144 10 87 144 18 97 151 10 87 144
55377 +10 87 144 10 87 144 10 87 144 10 87 144 10 87 144 18 97 151
55378 +10 87 144 28 67 93 22 40 52 10 87 144 26 108 161 18 97 151
55379 +18 97 151 18 97 151 26 108 161 26 108 161 26 108 161 26 108 161
55380 +22 40 52 1 1 2 0 0 0 2 3 3 4 4 4 4 4 4
55381 +4 4 4 5 5 5 4 4 4 0 0 0 26 28 28 131 129 131
55382 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
55383 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
55384 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55385 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55386 +4 4 4 4 4 4
55387 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
55388 +190 197 201 220 221 221 190 197 201 41 54 63 4 0 0 2 2 2
55389 +6 6 6 4 4 4 4 4 4 4 4 5 4 4 5 3 3 3
55390 +1 1 2 1 1 2 6 10 14 22 40 52 10 87 144 18 97 151
55391 +18 97 151 10 87 144 10 87 144 10 87 144 18 97 151 10 87 144
55392 +10 87 144 18 97 151 26 108 161 18 97 151 18 97 151 10 87 144
55393 +26 108 161 26 108 161 26 108 161 10 87 144 28 67 93 6 10 14
55394 +1 1 2 1 1 2 4 3 3 4 4 5 4 4 4 4 4 4
55395 +5 5 5 5 5 5 1 1 1 4 0 0 37 51 59 137 136 137
55396 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
55397 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
55398 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55399 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55400 +4 4 4 4 4 4
55401 +4 0 0 4 0 0 60 73 81 220 221 221 193 200 203 174 174 174
55402 +193 200 203 193 200 203 220 221 221 137 136 137 13 16 17 4 0 0
55403 +2 2 2 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5
55404 +4 4 5 4 3 3 1 1 2 4 5 7 13 20 25 28 67 93
55405 +10 87 144 10 87 144 10 87 144 10 87 144 10 87 144 10 87 144
55406 +10 87 144 18 97 151 18 97 151 10 87 144 18 97 151 26 108 161
55407 +26 108 161 18 97 151 28 67 93 6 10 14 0 0 0 0 0 0
55408 +2 3 3 4 5 5 4 4 5 4 4 4 4 4 4 5 5 5
55409 +3 3 3 1 1 1 0 0 0 16 19 21 125 124 125 137 136 137
55410 +131 129 131 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
55411 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
55412 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55413 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55414 +4 4 4 4 4 4
55415 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
55416 +193 200 203 190 197 201 220 221 221 220 221 221 153 152 153 30 32 34
55417 +0 0 0 0 0 0 2 2 2 4 4 4 4 4 4 4 4 4
55418 +4 4 4 4 5 5 4 5 7 1 1 2 1 1 2 4 5 7
55419 +13 20 25 28 67 93 10 87 144 18 97 151 10 87 144 10 87 144
55420 +10 87 144 10 87 144 10 87 144 18 97 151 26 108 161 18 97 151
55421 +28 67 93 7 12 15 0 0 0 0 0 0 2 2 1 4 4 4
55422 +4 5 5 4 5 5 4 4 4 4 4 4 3 3 3 0 0 0
55423 +0 0 0 0 0 0 37 38 37 125 124 125 158 157 158 131 129 131
55424 +125 124 125 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
55425 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
55426 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55427 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55428 +4 4 4 4 4 4
55429 +4 3 3 4 0 0 41 54 63 193 200 203 220 221 221 174 174 174
55430 +193 200 203 193 200 203 193 200 203 220 221 221 244 246 246 193 200 203
55431 +120 125 127 5 5 5 1 0 0 0 0 0 1 1 1 4 4 4
55432 +4 4 4 4 4 4 4 5 5 4 5 5 4 4 5 1 1 2
55433 +4 5 7 4 5 7 22 40 52 10 87 144 10 87 144 10 87 144
55434 +10 87 144 10 87 144 18 97 151 10 87 144 10 87 144 13 20 25
55435 +4 5 7 2 3 3 1 1 2 4 4 4 4 5 5 4 4 4
55436 +4 4 4 4 4 4 4 4 4 1 1 1 0 0 0 1 1 2
55437 +24 26 27 60 74 84 153 152 153 163 162 163 137 136 137 125 124 125
55438 +125 124 125 125 124 125 125 124 125 137 136 137 125 124 125 26 28 28
55439 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
55440 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55441 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55442 +4 4 4 4 4 4
55443 +4 0 0 6 6 6 26 28 28 156 155 156 220 221 221 220 221 221
55444 +174 174 174 193 200 203 193 200 203 193 200 203 205 212 215 220 221 221
55445 +220 221 221 167 166 167 60 73 81 7 11 13 0 0 0 0 0 0
55446 +3 3 3 4 4 4 4 4 4 4 4 4 4 4 5 4 4 5
55447 +4 4 5 1 1 2 1 1 2 4 5 7 22 40 52 10 87 144
55448 +10 87 144 10 87 144 10 87 144 22 40 52 4 5 7 1 1 2
55449 +1 1 2 4 4 5 4 4 4 4 4 4 4 4 4 4 4 4
55450 +5 5 5 2 2 2 0 0 0 4 0 0 16 19 21 60 73 81
55451 +137 136 137 167 166 167 158 157 158 137 136 137 131 129 131 131 129 131
55452 +125 124 125 125 124 125 131 129 131 155 154 155 60 74 84 5 7 8
55453 +0 0 0 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55454 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55455 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55456 +4 4 4 4 4 4
55457 +5 5 5 4 0 0 4 0 0 60 73 81 193 200 203 220 221 221
55458 +193 200 203 193 200 203 193 200 203 193 200 203 205 212 215 220 221 221
55459 +220 221 221 220 221 221 220 221 221 137 136 137 43 57 68 6 6 6
55460 +4 0 0 1 1 1 4 4 4 4 4 4 4 4 4 4 4 4
55461 +4 4 5 4 4 5 3 2 2 1 1 2 2 5 5 13 20 25
55462 +22 40 52 22 40 52 13 20 25 2 3 3 1 1 2 3 3 3
55463 +4 5 7 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55464 +1 1 1 0 0 0 2 3 3 41 54 63 131 129 131 166 165 166
55465 +166 165 166 155 154 155 153 152 153 137 136 137 137 136 137 125 124 125
55466 +125 124 125 137 136 137 137 136 137 125 124 125 37 38 37 4 3 3
55467 +4 3 3 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
55468 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55469 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55470 +4 4 4 4 4 4
55471 +4 3 3 6 6 6 6 6 6 13 16 17 60 73 81 167 166 167
55472 +220 221 221 220 221 221 220 221 221 193 200 203 193 200 203 193 200 203
55473 +205 212 215 220 221 221 220 221 221 244 246 246 205 212 215 125 124 125
55474 +24 26 27 0 0 0 0 0 0 2 2 2 5 5 5 5 5 5
55475 +4 4 4 4 4 4 4 4 4 4 4 5 1 1 2 4 5 7
55476 +4 5 7 4 5 7 1 1 2 3 2 2 4 4 5 4 4 4
55477 +4 4 4 4 4 4 5 5 5 4 4 4 0 0 0 0 0 0
55478 +2 0 0 26 28 28 125 124 125 174 174 174 174 174 174 166 165 166
55479 +156 155 156 153 152 153 137 136 137 137 136 137 131 129 131 137 136 137
55480 +137 136 137 137 136 137 60 74 84 30 32 34 4 0 0 4 0 0
55481 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55482 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55483 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55484 +4 4 4 4 4 4
55485 +5 5 5 6 6 6 4 0 0 4 0 0 6 6 6 26 28 28
55486 +125 124 125 174 174 174 220 221 221 220 221 221 220 221 221 193 200 203
55487 +205 212 215 220 221 221 205 212 215 220 221 221 220 221 221 244 246 246
55488 +193 200 203 60 74 84 13 16 17 4 0 0 0 0 0 3 3 3
55489 +5 5 5 5 5 5 4 4 4 4 4 4 4 4 5 3 3 3
55490 +1 1 2 3 3 3 4 4 5 4 4 5 4 4 4 4 4 4
55491 +5 5 5 5 5 5 2 2 2 0 0 0 0 0 0 13 16 17
55492 +60 74 84 174 174 174 193 200 203 174 174 174 167 166 167 163 162 163
55493 +153 152 153 153 152 153 137 136 137 137 136 137 153 152 153 137 136 137
55494 +125 124 125 41 54 63 24 26 27 4 0 0 4 0 0 5 5 5
55495 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55496 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55497 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55498 +4 4 4 4 4 4
55499 +4 3 3 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
55500 +6 6 6 37 38 37 131 129 131 220 221 221 220 221 221 220 221 221
55501 +193 200 203 193 200 203 220 221 221 205 212 215 220 221 221 244 246 246
55502 +244 246 246 244 246 246 174 174 174 41 54 63 0 0 0 0 0 0
55503 +0 0 0 4 4 4 5 5 5 5 5 5 4 4 4 4 4 5
55504 +4 4 5 4 4 5 4 4 4 4 4 4 6 6 6 6 6 6
55505 +3 3 3 0 0 0 2 0 0 13 16 17 60 73 81 156 155 156
55506 +220 221 221 193 200 203 174 174 174 165 164 165 163 162 163 154 153 154
55507 +153 152 153 153 152 153 158 157 158 163 162 163 137 136 137 60 73 81
55508 +13 16 17 4 0 0 4 0 0 4 3 3 4 4 4 4 4 4
55509 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55510 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55511 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55512 +4 4 4 4 4 4
55513 +5 5 5 4 3 3 4 3 3 6 6 6 6 6 6 6 6 6
55514 +6 6 6 6 6 6 6 6 6 37 38 37 167 166 167 244 246 246
55515 +244 246 246 220 221 221 205 212 215 205 212 215 220 221 221 193 200 203
55516 +220 221 221 244 246 246 244 246 246 244 246 246 137 136 137 37 38 37
55517 +3 2 2 0 0 0 1 1 1 5 5 5 5 5 5 4 4 4
55518 +4 4 4 4 4 4 4 4 4 5 5 5 4 4 4 1 1 1
55519 +0 0 0 5 5 5 43 57 68 153 152 153 193 200 203 220 221 221
55520 +177 184 187 174 174 174 167 166 167 166 165 166 158 157 158 157 156 157
55521 +158 157 158 166 165 166 156 155 156 85 115 134 13 16 17 4 0 0
55522 +4 0 0 4 0 0 5 5 5 5 5 5 4 4 4 4 4 4
55523 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55524 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55525 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55526 +4 4 4 4 4 4
55527 +5 5 5 4 3 3 6 6 6 6 6 6 4 0 0 6 6 6
55528 +6 6 6 6 6 6 6 6 6 6 6 6 13 16 17 60 73 81
55529 +177 184 187 220 221 221 220 221 221 220 221 221 205 212 215 220 221 221
55530 +220 221 221 205 212 215 220 221 221 244 246 246 244 246 246 205 212 215
55531 +125 124 125 30 32 34 0 0 0 0 0 0 2 2 2 5 5 5
55532 +4 4 4 4 4 4 4 4 4 1 1 1 0 0 0 1 0 0
55533 +37 38 37 131 129 131 205 212 215 220 221 221 193 200 203 174 174 174
55534 +174 174 174 174 174 174 167 166 167 165 164 165 166 165 166 167 166 167
55535 +158 157 158 125 124 125 37 38 37 4 0 0 4 0 0 4 0 0
55536 +4 3 3 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
55537 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55538 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55539 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55540 +4 4 4 4 4 4
55541 +4 4 4 5 5 5 4 3 3 4 3 3 6 6 6 6 6 6
55542 +4 0 0 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
55543 +26 28 28 125 124 125 205 212 215 220 221 221 220 221 221 220 221 221
55544 +205 212 215 220 221 221 205 212 215 220 221 221 220 221 221 244 246 246
55545 +244 246 246 190 197 201 60 74 84 16 19 21 4 0 0 0 0 0
55546 +0 0 0 0 0 0 0 0 0 0 0 0 16 19 21 120 125 127
55547 +177 184 187 220 221 221 205 212 215 177 184 187 174 174 174 177 184 187
55548 +174 174 174 174 174 174 167 166 167 174 174 174 166 165 166 137 136 137
55549 +60 73 81 13 16 17 4 0 0 4 0 0 4 3 3 6 6 6
55550 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55551 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55552 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55553 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55554 +4 4 4 4 4 4
55555 +5 5 5 4 3 3 5 5 5 4 3 3 6 6 6 4 0 0
55556 +6 6 6 6 6 6 4 0 0 6 6 6 4 0 0 6 6 6
55557 +6 6 6 6 6 6 37 38 37 137 136 137 193 200 203 220 221 221
55558 +220 221 221 205 212 215 220 221 221 205 212 215 205 212 215 220 221 221
55559 +220 221 221 220 221 221 244 246 246 166 165 166 43 57 68 2 2 2
55560 +0 0 0 4 0 0 16 19 21 60 73 81 157 156 157 202 210 214
55561 +220 221 221 193 200 203 177 184 187 177 184 187 177 184 187 174 174 174
55562 +174 174 174 174 174 174 174 174 174 157 156 157 60 74 84 24 26 27
55563 +4 0 0 4 0 0 4 0 0 6 6 6 4 4 4 4 4 4
55564 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55565 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55566 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55567 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55568 +4 4 4 4 4 4
55569 +4 4 4 4 4 4 5 5 5 4 3 3 5 5 5 6 6 6
55570 +6 6 6 4 0 0 6 6 6 6 6 6 6 6 6 4 0 0
55571 +4 0 0 4 0 0 6 6 6 24 26 27 60 73 81 167 166 167
55572 +220 221 221 220 221 221 220 221 221 205 212 215 205 212 215 205 212 215
55573 +205 212 215 220 221 221 220 221 221 220 221 221 205 212 215 137 136 137
55574 +60 74 84 125 124 125 137 136 137 190 197 201 220 221 221 193 200 203
55575 +177 184 187 177 184 187 177 184 187 174 174 174 174 174 174 177 184 187
55576 +190 197 201 174 174 174 125 124 125 37 38 37 6 6 6 4 0 0
55577 +4 0 0 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55578 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55579 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55580 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55581 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55582 +4 4 4 4 4 4
55583 +4 4 4 4 4 4 5 5 5 5 5 5 4 3 3 6 6 6
55584 +4 0 0 6 6 6 6 6 6 6 6 6 4 0 0 6 6 6
55585 +6 6 6 6 6 6 4 0 0 4 0 0 6 6 6 6 6 6
55586 +125 124 125 193 200 203 244 246 246 220 221 221 205 212 215 205 212 215
55587 +205 212 215 193 200 203 205 212 215 205 212 215 220 221 221 220 221 221
55588 +193 200 203 193 200 203 205 212 215 193 200 203 193 200 203 177 184 187
55589 +190 197 201 190 197 201 174 174 174 190 197 201 193 200 203 190 197 201
55590 +153 152 153 60 73 81 4 0 0 4 0 0 4 0 0 3 2 2
55591 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55592 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55593 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55594 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55595 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55596 +4 4 4 4 4 4
55597 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 4 3 3
55598 +6 6 6 4 3 3 4 3 3 4 3 3 6 6 6 6 6 6
55599 +4 0 0 6 6 6 6 6 6 6 6 6 4 0 0 4 0 0
55600 +4 0 0 26 28 28 131 129 131 220 221 221 244 246 246 220 221 221
55601 +205 212 215 193 200 203 205 212 215 193 200 203 193 200 203 205 212 215
55602 +220 221 221 193 200 203 193 200 203 193 200 203 190 197 201 174 174 174
55603 +174 174 174 190 197 201 193 200 203 193 200 203 167 166 167 125 124 125
55604 +6 6 6 4 0 0 4 0 0 4 3 3 4 4 4 4 4 4
55605 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55606 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55607 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55608 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55609 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55610 +4 4 4 4 4 4
55611 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
55612 +5 5 5 4 3 3 5 5 5 6 6 6 4 3 3 5 5 5
55613 +6 6 6 6 6 6 4 0 0 6 6 6 6 6 6 6 6 6
55614 +4 0 0 4 0 0 6 6 6 41 54 63 158 157 158 220 221 221
55615 +220 221 221 220 221 221 193 200 203 193 200 203 193 200 203 190 197 201
55616 +190 197 201 190 197 201 190 197 201 190 197 201 174 174 174 193 200 203
55617 +193 200 203 220 221 221 174 174 174 125 124 125 37 38 37 4 0 0
55618 +4 0 0 4 3 3 6 6 6 4 4 4 4 4 4 4 4 4
55619 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55620 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55621 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55622 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55623 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55624 +4 4 4 4 4 4
55625 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55626 +4 4 4 5 5 5 4 3 3 4 3 3 4 3 3 5 5 5
55627 +4 3 3 6 6 6 5 5 5 4 3 3 6 6 6 6 6 6
55628 +6 6 6 6 6 6 4 0 0 4 0 0 13 16 17 60 73 81
55629 +174 174 174 220 221 221 220 221 221 205 212 215 190 197 201 174 174 174
55630 +193 200 203 174 174 174 190 197 201 174 174 174 193 200 203 220 221 221
55631 +193 200 203 131 129 131 37 38 37 6 6 6 4 0 0 4 0 0
55632 +6 6 6 6 6 6 4 3 3 5 5 5 4 4 4 4 4 4
55633 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55634 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55635 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55636 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55637 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55638 +4 4 4 4 4 4
55639 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55640 +4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 5
55641 +5 5 5 4 3 3 4 3 3 5 5 5 4 3 3 4 3 3
55642 +5 5 5 6 6 6 6 6 6 4 0 0 6 6 6 6 6 6
55643 +6 6 6 125 124 125 174 174 174 220 221 221 220 221 221 193 200 203
55644 +193 200 203 193 200 203 193 200 203 193 200 203 220 221 221 158 157 158
55645 +60 73 81 6 6 6 4 0 0 4 0 0 5 5 5 6 6 6
55646 +5 5 5 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
55647 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55648 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55649 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55650 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55651 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55652 +4 4 4 4 4 4
55653 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55654 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55655 +4 4 4 5 5 5 5 5 5 4 3 3 5 5 5 4 3 3
55656 +5 5 5 5 5 5 6 6 6 6 6 6 4 0 0 4 0 0
55657 +4 0 0 4 0 0 26 28 28 125 124 125 174 174 174 193 200 203
55658 +193 200 203 174 174 174 193 200 203 167 166 167 125 124 125 6 6 6
55659 +6 6 6 6 6 6 4 0 0 6 6 6 6 6 6 5 5 5
55660 +4 3 3 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
55661 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55662 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55663 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55664 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55665 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55666 +4 4 4 4 4 4
55667 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55668 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55669 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
55670 +4 3 3 6 6 6 4 0 0 6 6 6 6 6 6 6 6 6
55671 +6 6 6 4 0 0 4 0 0 6 6 6 37 38 37 125 124 125
55672 +153 152 153 131 129 131 125 124 125 37 38 37 6 6 6 6 6 6
55673 +6 6 6 4 0 0 6 6 6 6 6 6 4 3 3 5 5 5
55674 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55675 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55676 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55677 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55678 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55679 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55680 +4 4 4 4 4 4
55681 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55682 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55683 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55684 +4 4 4 5 5 5 5 5 5 4 3 3 5 5 5 4 3 3
55685 +6 6 6 6 6 6 4 0 0 4 0 0 6 6 6 6 6 6
55686 +24 26 27 24 26 27 6 6 6 6 6 6 6 6 6 4 0 0
55687 +6 6 6 6 6 6 4 0 0 6 6 6 5 5 5 4 3 3
55688 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55689 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55690 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55691 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55692 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55693 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55694 +4 4 4 4 4 4
55695 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55696 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55697 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55698 +4 4 4 4 4 4 5 5 5 4 3 3 5 5 5 6 6 6
55699 +4 0 0 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
55700 +6 6 6 6 6 6 6 6 6 4 0 0 6 6 6 6 6 6
55701 +4 0 0 6 6 6 6 6 6 4 3 3 5 5 5 4 4 4
55702 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55703 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55704 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55705 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55706 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55707 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55708 +4 4 4 4 4 4
55709 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55710 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55711 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55712 +4 4 4 4 4 4 4 4 4 5 5 5 4 3 3 5 5 5
55713 +5 5 5 5 5 5 4 0 0 6 6 6 4 0 0 6 6 6
55714 +6 6 6 6 6 6 6 6 6 4 0 0 6 6 6 4 0 0
55715 +6 6 6 4 3 3 5 5 5 4 3 3 5 5 5 4 4 4
55716 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55717 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55718 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55719 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55720 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55721 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55722 +4 4 4 4 4 4
55723 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55724 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55725 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55726 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
55727 +4 3 3 6 6 6 4 3 3 6 6 6 6 6 6 6 6 6
55728 +4 0 0 6 6 6 4 0 0 6 6 6 6 6 6 6 6 6
55729 +6 6 6 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
55730 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55731 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55732 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55733 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55734 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55735 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55736 +4 4 4 4 4 4
55737 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55738 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55739 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55740 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55741 +4 4 4 5 5 5 4 3 3 5 5 5 4 0 0 6 6 6
55742 +6 6 6 4 0 0 6 6 6 6 6 6 4 0 0 6 6 6
55743 +4 3 3 5 5 5 5 5 5 4 4 4 4 4 4 4 4 4
55744 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55745 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55746 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55747 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55748 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55749 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55750 +4 4 4 4 4 4
55751 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55752 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55753 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55754 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55755 +4 4 4 5 5 5 4 3 3 5 5 5 6 6 6 4 3 3
55756 +4 3 3 6 6 6 6 6 6 4 3 3 6 6 6 4 3 3
55757 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55758 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55759 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55760 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55761 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55762 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55763 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55764 +4 4 4 4 4 4
55765 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55766 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55767 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55768 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55769 +4 4 4 4 4 4 4 4 4 5 5 5 4 3 3 6 6 6
55770 +5 5 5 4 3 3 4 3 3 4 3 3 5 5 5 5 5 5
55771 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55772 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55773 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55774 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55775 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55776 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55777 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55778 +4 4 4 4 4 4
55779 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55780 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55781 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55782 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55783 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 4 3 3
55784 +5 5 5 4 3 3 5 5 5 5 5 5 4 4 4 4 4 4
55785 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55786 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55787 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55788 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55789 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55790 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55791 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
55792 +4 4 4 4 4 4
55793 diff --git a/drivers/xen/xenfs/xenstored.c b/drivers/xen/xenfs/xenstored.c
55794 index fef20db..d28b1ab 100644
55795 --- a/drivers/xen/xenfs/xenstored.c
55796 +++ b/drivers/xen/xenfs/xenstored.c
55797 @@ -24,7 +24,12 @@ static int xsd_release(struct inode *inode, struct file *file)
55798 static int xsd_kva_open(struct inode *inode, struct file *file)
55799 {
55800 file->private_data = (void *)kasprintf(GFP_KERNEL, "0x%p",
55801 +#ifdef CONFIG_GRKERNSEC_HIDESYM
55802 + NULL);
55803 +#else
55804 xen_store_interface);
55805 +#endif
55806 +
55807 if (!file->private_data)
55808 return -ENOMEM;
55809 return 0;
55810 diff --git a/fs/9p/vfs_addr.c b/fs/9p/vfs_addr.c
55811 index c71e886..61d3d44b 100644
55812 --- a/fs/9p/vfs_addr.c
55813 +++ b/fs/9p/vfs_addr.c
55814 @@ -187,7 +187,7 @@ static int v9fs_vfs_writepage_locked(struct page *page)
55815
55816 retval = v9fs_file_write_internal(inode,
55817 v9inode->writeback_fid,
55818 - (__force const char __user *)buffer,
55819 + (const char __force_user *)buffer,
55820 len, &offset, 0);
55821 if (retval > 0)
55822 retval = 0;
55823 diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c
55824 index 53161ec..e261d8a 100644
55825 --- a/fs/9p/vfs_inode.c
55826 +++ b/fs/9p/vfs_inode.c
55827 @@ -1312,7 +1312,7 @@ static void *v9fs_vfs_follow_link(struct dentry *dentry, struct nameidata *nd)
55828 void
55829 v9fs_vfs_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
55830 {
55831 - char *s = nd_get_link(nd);
55832 + const char *s = nd_get_link(nd);
55833
55834 p9_debug(P9_DEBUG_VFS, " %s %s\n",
55835 dentry->d_name.name, IS_ERR(s) ? "<error>" : s);
55836 diff --git a/fs/Kconfig.binfmt b/fs/Kconfig.binfmt
55837 index 370b24c..ff0be7b 100644
55838 --- a/fs/Kconfig.binfmt
55839 +++ b/fs/Kconfig.binfmt
55840 @@ -103,7 +103,7 @@ config HAVE_AOUT
55841
55842 config BINFMT_AOUT
55843 tristate "Kernel support for a.out and ECOFF binaries"
55844 - depends on HAVE_AOUT
55845 + depends on HAVE_AOUT && BROKEN
55846 ---help---
55847 A.out (Assembler.OUTput) is a set of formats for libraries and
55848 executables used in the earliest versions of UNIX. Linux used
55849 diff --git a/fs/afs/inode.c b/fs/afs/inode.c
55850 index 2946712..f737435 100644
55851 --- a/fs/afs/inode.c
55852 +++ b/fs/afs/inode.c
55853 @@ -141,7 +141,7 @@ struct inode *afs_iget_autocell(struct inode *dir, const char *dev_name,
55854 struct afs_vnode *vnode;
55855 struct super_block *sb;
55856 struct inode *inode;
55857 - static atomic_t afs_autocell_ino;
55858 + static atomic_unchecked_t afs_autocell_ino;
55859
55860 _enter("{%x:%u},%*.*s,",
55861 AFS_FS_I(dir)->fid.vid, AFS_FS_I(dir)->fid.vnode,
55862 @@ -154,7 +154,7 @@ struct inode *afs_iget_autocell(struct inode *dir, const char *dev_name,
55863 data.fid.unique = 0;
55864 data.fid.vnode = 0;
55865
55866 - inode = iget5_locked(sb, atomic_inc_return(&afs_autocell_ino),
55867 + inode = iget5_locked(sb, atomic_inc_return_unchecked(&afs_autocell_ino),
55868 afs_iget5_autocell_test, afs_iget5_set,
55869 &data);
55870 if (!inode) {
55871 diff --git a/fs/aio.c b/fs/aio.c
55872 index a0ed6c7..882e5a6 100644
55873 --- a/fs/aio.c
55874 +++ b/fs/aio.c
55875 @@ -380,7 +380,7 @@ static int aio_setup_ring(struct kioctx *ctx)
55876 size += sizeof(struct io_event) * nr_events;
55877
55878 nr_pages = PFN_UP(size);
55879 - if (nr_pages < 0)
55880 + if (nr_pages <= 0)
55881 return -EINVAL;
55882
55883 file = aio_private_file(ctx, nr_pages);
55884 diff --git a/fs/attr.c b/fs/attr.c
55885 index 6530ced..4a827e2 100644
55886 --- a/fs/attr.c
55887 +++ b/fs/attr.c
55888 @@ -102,6 +102,7 @@ int inode_newsize_ok(const struct inode *inode, loff_t offset)
55889 unsigned long limit;
55890
55891 limit = rlimit(RLIMIT_FSIZE);
55892 + gr_learn_resource(current, RLIMIT_FSIZE, (unsigned long)offset, 1);
55893 if (limit != RLIM_INFINITY && offset > limit)
55894 goto out_sig;
55895 if (offset > inode->i_sb->s_maxbytes)
55896 diff --git a/fs/autofs4/waitq.c b/fs/autofs4/waitq.c
55897 index 116fd38..c04182da 100644
55898 --- a/fs/autofs4/waitq.c
55899 +++ b/fs/autofs4/waitq.c
55900 @@ -59,7 +59,7 @@ static int autofs4_write(struct autofs_sb_info *sbi,
55901 {
55902 unsigned long sigpipe, flags;
55903 mm_segment_t fs;
55904 - const char *data = (const char *)addr;
55905 + const char __user *data = (const char __force_user *)addr;
55906 ssize_t wr = 0;
55907
55908 sigpipe = sigismember(&current->pending.signal, SIGPIPE);
55909 @@ -340,6 +340,10 @@ static int validate_request(struct autofs_wait_queue **wait,
55910 return 1;
55911 }
55912
55913 +#ifdef CONFIG_GRKERNSEC_HIDESYM
55914 +static atomic_unchecked_t autofs_dummy_name_id = ATOMIC_INIT(0);
55915 +#endif
55916 +
55917 int autofs4_wait(struct autofs_sb_info *sbi, struct dentry *dentry,
55918 enum autofs_notify notify)
55919 {
55920 @@ -385,7 +389,12 @@ int autofs4_wait(struct autofs_sb_info *sbi, struct dentry *dentry,
55921
55922 /* If this is a direct mount request create a dummy name */
55923 if (IS_ROOT(dentry) && autofs_type_trigger(sbi->type))
55924 +#ifdef CONFIG_GRKERNSEC_HIDESYM
55925 + /* this name does get written to userland via autofs4_write() */
55926 + qstr.len = sprintf(name, "%08x", atomic_inc_return_unchecked(&autofs_dummy_name_id));
55927 +#else
55928 qstr.len = sprintf(name, "%p", dentry);
55929 +#endif
55930 else {
55931 qstr.len = autofs4_getpath(sbi, dentry, &name);
55932 if (!qstr.len) {
55933 diff --git a/fs/befs/endian.h b/fs/befs/endian.h
55934 index 2722387..56059b5 100644
55935 --- a/fs/befs/endian.h
55936 +++ b/fs/befs/endian.h
55937 @@ -11,7 +11,7 @@
55938
55939 #include <asm/byteorder.h>
55940
55941 -static inline u64
55942 +static inline u64 __intentional_overflow(-1)
55943 fs64_to_cpu(const struct super_block *sb, fs64 n)
55944 {
55945 if (BEFS_SB(sb)->byte_order == BEFS_BYTESEX_LE)
55946 @@ -29,7 +29,7 @@ cpu_to_fs64(const struct super_block *sb, u64 n)
55947 return (__force fs64)cpu_to_be64(n);
55948 }
55949
55950 -static inline u32
55951 +static inline u32 __intentional_overflow(-1)
55952 fs32_to_cpu(const struct super_block *sb, fs32 n)
55953 {
55954 if (BEFS_SB(sb)->byte_order == BEFS_BYTESEX_LE)
55955 @@ -47,7 +47,7 @@ cpu_to_fs32(const struct super_block *sb, u32 n)
55956 return (__force fs32)cpu_to_be32(n);
55957 }
55958
55959 -static inline u16
55960 +static inline u16 __intentional_overflow(-1)
55961 fs16_to_cpu(const struct super_block *sb, fs16 n)
55962 {
55963 if (BEFS_SB(sb)->byte_order == BEFS_BYTESEX_LE)
55964 diff --git a/fs/binfmt_aout.c b/fs/binfmt_aout.c
55965 index ca0ba15..0fa3257 100644
55966 --- a/fs/binfmt_aout.c
55967 +++ b/fs/binfmt_aout.c
55968 @@ -16,6 +16,7 @@
55969 #include <linux/string.h>
55970 #include <linux/fs.h>
55971 #include <linux/file.h>
55972 +#include <linux/security.h>
55973 #include <linux/stat.h>
55974 #include <linux/fcntl.h>
55975 #include <linux/ptrace.h>
55976 @@ -58,6 +59,8 @@ static int aout_core_dump(struct coredump_params *cprm)
55977 #endif
55978 # define START_STACK(u) ((void __user *)u.start_stack)
55979
55980 + memset(&dump, 0, sizeof(dump));
55981 +
55982 fs = get_fs();
55983 set_fs(KERNEL_DS);
55984 has_dumped = 1;
55985 @@ -68,10 +71,12 @@ static int aout_core_dump(struct coredump_params *cprm)
55986
55987 /* If the size of the dump file exceeds the rlimit, then see what would happen
55988 if we wrote the stack, but not the data area. */
55989 + gr_learn_resource(current, RLIMIT_CORE, (dump.u_dsize + dump.u_ssize+1) * PAGE_SIZE, 1);
55990 if ((dump.u_dsize + dump.u_ssize+1) * PAGE_SIZE > cprm->limit)
55991 dump.u_dsize = 0;
55992
55993 /* Make sure we have enough room to write the stack and data areas. */
55994 + gr_learn_resource(current, RLIMIT_CORE, (dump.u_ssize + 1) * PAGE_SIZE, 1);
55995 if ((dump.u_ssize + 1) * PAGE_SIZE > cprm->limit)
55996 dump.u_ssize = 0;
55997
55998 @@ -232,6 +237,8 @@ static int load_aout_binary(struct linux_binprm * bprm)
55999 rlim = rlimit(RLIMIT_DATA);
56000 if (rlim >= RLIM_INFINITY)
56001 rlim = ~0;
56002 +
56003 + gr_learn_resource(current, RLIMIT_DATA, ex.a_data + ex.a_bss, 1);
56004 if (ex.a_data + ex.a_bss > rlim)
56005 return -ENOMEM;
56006
56007 @@ -264,6 +271,27 @@ static int load_aout_binary(struct linux_binprm * bprm)
56008
56009 install_exec_creds(bprm);
56010
56011 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
56012 + current->mm->pax_flags = 0UL;
56013 +#endif
56014 +
56015 +#ifdef CONFIG_PAX_PAGEEXEC
56016 + if (!(N_FLAGS(ex) & F_PAX_PAGEEXEC)) {
56017 + current->mm->pax_flags |= MF_PAX_PAGEEXEC;
56018 +
56019 +#ifdef CONFIG_PAX_EMUTRAMP
56020 + if (N_FLAGS(ex) & F_PAX_EMUTRAMP)
56021 + current->mm->pax_flags |= MF_PAX_EMUTRAMP;
56022 +#endif
56023 +
56024 +#ifdef CONFIG_PAX_MPROTECT
56025 + if (!(N_FLAGS(ex) & F_PAX_MPROTECT))
56026 + current->mm->pax_flags |= MF_PAX_MPROTECT;
56027 +#endif
56028 +
56029 + }
56030 +#endif
56031 +
56032 if (N_MAGIC(ex) == OMAGIC) {
56033 unsigned long text_addr, map_size;
56034 loff_t pos;
56035 @@ -321,7 +349,7 @@ static int load_aout_binary(struct linux_binprm * bprm)
56036 }
56037
56038 error = vm_mmap(bprm->file, N_DATADDR(ex), ex.a_data,
56039 - PROT_READ | PROT_WRITE | PROT_EXEC,
56040 + PROT_READ | PROT_WRITE,
56041 MAP_FIXED | MAP_PRIVATE | MAP_DENYWRITE | MAP_EXECUTABLE,
56042 fd_offset + ex.a_text);
56043 if (error != N_DATADDR(ex)) {
56044 diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c
56045 index aa3cb62..bc53934 100644
56046 --- a/fs/binfmt_elf.c
56047 +++ b/fs/binfmt_elf.c
56048 @@ -34,6 +34,7 @@
56049 #include <linux/utsname.h>
56050 #include <linux/coredump.h>
56051 #include <linux/sched.h>
56052 +#include <linux/xattr.h>
56053 #include <asm/uaccess.h>
56054 #include <asm/param.h>
56055 #include <asm/page.h>
56056 @@ -47,7 +48,7 @@
56057
56058 static int load_elf_binary(struct linux_binprm *bprm);
56059 static unsigned long elf_map(struct file *, unsigned long, struct elf_phdr *,
56060 - int, int, unsigned long);
56061 + int, int, unsigned long) __intentional_overflow(-1);
56062
56063 #ifdef CONFIG_USELIB
56064 static int load_elf_library(struct file *);
56065 @@ -65,6 +66,14 @@ static int elf_core_dump(struct coredump_params *cprm);
56066 #define elf_core_dump NULL
56067 #endif
56068
56069 +#ifdef CONFIG_PAX_MPROTECT
56070 +static void elf_handle_mprotect(struct vm_area_struct *vma, unsigned long newflags);
56071 +#endif
56072 +
56073 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
56074 +static void elf_handle_mmap(struct file *file);
56075 +#endif
56076 +
56077 #if ELF_EXEC_PAGESIZE > PAGE_SIZE
56078 #define ELF_MIN_ALIGN ELF_EXEC_PAGESIZE
56079 #else
56080 @@ -84,6 +93,15 @@ static struct linux_binfmt elf_format = {
56081 .load_binary = load_elf_binary,
56082 .load_shlib = load_elf_library,
56083 .core_dump = elf_core_dump,
56084 +
56085 +#ifdef CONFIG_PAX_MPROTECT
56086 + .handle_mprotect= elf_handle_mprotect,
56087 +#endif
56088 +
56089 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
56090 + .handle_mmap = elf_handle_mmap,
56091 +#endif
56092 +
56093 .min_coredump = ELF_EXEC_PAGESIZE,
56094 };
56095
56096 @@ -91,6 +109,8 @@ static struct linux_binfmt elf_format = {
56097
56098 static int set_brk(unsigned long start, unsigned long end)
56099 {
56100 + unsigned long e = end;
56101 +
56102 start = ELF_PAGEALIGN(start);
56103 end = ELF_PAGEALIGN(end);
56104 if (end > start) {
56105 @@ -99,7 +119,7 @@ static int set_brk(unsigned long start, unsigned long end)
56106 if (BAD_ADDR(addr))
56107 return addr;
56108 }
56109 - current->mm->start_brk = current->mm->brk = end;
56110 + current->mm->start_brk = current->mm->brk = e;
56111 return 0;
56112 }
56113
56114 @@ -160,12 +180,13 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
56115 elf_addr_t __user *u_rand_bytes;
56116 const char *k_platform = ELF_PLATFORM;
56117 const char *k_base_platform = ELF_BASE_PLATFORM;
56118 - unsigned char k_rand_bytes[16];
56119 + u32 k_rand_bytes[4];
56120 int items;
56121 elf_addr_t *elf_info;
56122 int ei_index = 0;
56123 const struct cred *cred = current_cred();
56124 struct vm_area_struct *vma;
56125 + unsigned long saved_auxv[AT_VECTOR_SIZE];
56126
56127 /*
56128 * In some cases (e.g. Hyper-Threading), we want to avoid L1
56129 @@ -207,8 +228,12 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
56130 * Generate 16 random bytes for userspace PRNG seeding.
56131 */
56132 get_random_bytes(k_rand_bytes, sizeof(k_rand_bytes));
56133 - u_rand_bytes = (elf_addr_t __user *)
56134 - STACK_ALLOC(p, sizeof(k_rand_bytes));
56135 + prandom_seed(k_rand_bytes[0] ^ prandom_u32());
56136 + prandom_seed(k_rand_bytes[1] ^ prandom_u32());
56137 + prandom_seed(k_rand_bytes[2] ^ prandom_u32());
56138 + prandom_seed(k_rand_bytes[3] ^ prandom_u32());
56139 + p = STACK_ROUND(p, sizeof(k_rand_bytes));
56140 + u_rand_bytes = (elf_addr_t __user *) p;
56141 if (__copy_to_user(u_rand_bytes, k_rand_bytes, sizeof(k_rand_bytes)))
56142 return -EFAULT;
56143
56144 @@ -323,9 +348,11 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
56145 return -EFAULT;
56146 current->mm->env_end = p;
56147
56148 + memcpy(saved_auxv, elf_info, ei_index * sizeof(elf_addr_t));
56149 +
56150 /* Put the elf_info on the stack in the right place. */
56151 sp = (elf_addr_t __user *)envp + 1;
56152 - if (copy_to_user(sp, elf_info, ei_index * sizeof(elf_addr_t)))
56153 + if (copy_to_user(sp, saved_auxv, ei_index * sizeof(elf_addr_t)))
56154 return -EFAULT;
56155 return 0;
56156 }
56157 @@ -393,15 +420,14 @@ static unsigned long total_mapping_size(struct elf_phdr *cmds, int nr)
56158 an ELF header */
56159
56160 static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
56161 - struct file *interpreter, unsigned long *interp_map_addr,
56162 - unsigned long no_base)
56163 + struct file *interpreter, unsigned long no_base)
56164 {
56165 struct elf_phdr *elf_phdata;
56166 struct elf_phdr *eppnt;
56167 - unsigned long load_addr = 0;
56168 + unsigned long load_addr = 0, pax_task_size = TASK_SIZE;
56169 int load_addr_set = 0;
56170 unsigned long last_bss = 0, elf_bss = 0;
56171 - unsigned long error = ~0UL;
56172 + unsigned long error = -EINVAL;
56173 unsigned long total_size;
56174 int retval, i, size;
56175
56176 @@ -447,6 +473,11 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
56177 goto out_close;
56178 }
56179
56180 +#ifdef CONFIG_PAX_SEGMEXEC
56181 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC)
56182 + pax_task_size = SEGMEXEC_TASK_SIZE;
56183 +#endif
56184 +
56185 eppnt = elf_phdata;
56186 for (i = 0; i < interp_elf_ex->e_phnum; i++, eppnt++) {
56187 if (eppnt->p_type == PT_LOAD) {
56188 @@ -470,8 +501,6 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
56189 map_addr = elf_map(interpreter, load_addr + vaddr,
56190 eppnt, elf_prot, elf_type, total_size);
56191 total_size = 0;
56192 - if (!*interp_map_addr)
56193 - *interp_map_addr = map_addr;
56194 error = map_addr;
56195 if (BAD_ADDR(map_addr))
56196 goto out_close;
56197 @@ -490,8 +519,8 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
56198 k = load_addr + eppnt->p_vaddr;
56199 if (BAD_ADDR(k) ||
56200 eppnt->p_filesz > eppnt->p_memsz ||
56201 - eppnt->p_memsz > TASK_SIZE ||
56202 - TASK_SIZE - eppnt->p_memsz < k) {
56203 + eppnt->p_memsz > pax_task_size ||
56204 + pax_task_size - eppnt->p_memsz < k) {
56205 error = -ENOMEM;
56206 goto out_close;
56207 }
56208 @@ -530,9 +559,11 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
56209 elf_bss = ELF_PAGESTART(elf_bss + ELF_MIN_ALIGN - 1);
56210
56211 /* Map the last of the bss segment */
56212 - error = vm_brk(elf_bss, last_bss - elf_bss);
56213 - if (BAD_ADDR(error))
56214 - goto out_close;
56215 + if (last_bss > elf_bss) {
56216 + error = vm_brk(elf_bss, last_bss - elf_bss);
56217 + if (BAD_ADDR(error))
56218 + goto out_close;
56219 + }
56220 }
56221
56222 error = load_addr;
56223 @@ -543,6 +574,336 @@ out:
56224 return error;
56225 }
56226
56227 +#ifdef CONFIG_PAX_PT_PAX_FLAGS
56228 +#ifdef CONFIG_PAX_SOFTMODE
56229 +static unsigned long pax_parse_pt_pax_softmode(const struct elf_phdr * const elf_phdata)
56230 +{
56231 + unsigned long pax_flags = 0UL;
56232 +
56233 +#ifdef CONFIG_PAX_PAGEEXEC
56234 + if (elf_phdata->p_flags & PF_PAGEEXEC)
56235 + pax_flags |= MF_PAX_PAGEEXEC;
56236 +#endif
56237 +
56238 +#ifdef CONFIG_PAX_SEGMEXEC
56239 + if (elf_phdata->p_flags & PF_SEGMEXEC)
56240 + pax_flags |= MF_PAX_SEGMEXEC;
56241 +#endif
56242 +
56243 +#ifdef CONFIG_PAX_EMUTRAMP
56244 + if ((elf_phdata->p_flags & PF_EMUTRAMP) && (pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)))
56245 + pax_flags |= MF_PAX_EMUTRAMP;
56246 +#endif
56247 +
56248 +#ifdef CONFIG_PAX_MPROTECT
56249 + if (elf_phdata->p_flags & PF_MPROTECT)
56250 + pax_flags |= MF_PAX_MPROTECT;
56251 +#endif
56252 +
56253 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
56254 + if (randomize_va_space && (elf_phdata->p_flags & PF_RANDMMAP))
56255 + pax_flags |= MF_PAX_RANDMMAP;
56256 +#endif
56257 +
56258 + return pax_flags;
56259 +}
56260 +#endif
56261 +
56262 +static unsigned long pax_parse_pt_pax_hardmode(const struct elf_phdr * const elf_phdata)
56263 +{
56264 + unsigned long pax_flags = 0UL;
56265 +
56266 +#ifdef CONFIG_PAX_PAGEEXEC
56267 + if (!(elf_phdata->p_flags & PF_NOPAGEEXEC))
56268 + pax_flags |= MF_PAX_PAGEEXEC;
56269 +#endif
56270 +
56271 +#ifdef CONFIG_PAX_SEGMEXEC
56272 + if (!(elf_phdata->p_flags & PF_NOSEGMEXEC))
56273 + pax_flags |= MF_PAX_SEGMEXEC;
56274 +#endif
56275 +
56276 +#ifdef CONFIG_PAX_EMUTRAMP
56277 + if (!(elf_phdata->p_flags & PF_NOEMUTRAMP))
56278 + pax_flags |= MF_PAX_EMUTRAMP;
56279 +#endif
56280 +
56281 +#ifdef CONFIG_PAX_MPROTECT
56282 + if (!(elf_phdata->p_flags & PF_NOMPROTECT))
56283 + pax_flags |= MF_PAX_MPROTECT;
56284 +#endif
56285 +
56286 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
56287 + if (randomize_va_space && !(elf_phdata->p_flags & PF_NORANDMMAP))
56288 + pax_flags |= MF_PAX_RANDMMAP;
56289 +#endif
56290 +
56291 + return pax_flags;
56292 +}
56293 +#endif
56294 +
56295 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
56296 +#ifdef CONFIG_PAX_SOFTMODE
56297 +static unsigned long pax_parse_xattr_pax_softmode(unsigned long pax_flags_softmode)
56298 +{
56299 + unsigned long pax_flags = 0UL;
56300 +
56301 +#ifdef CONFIG_PAX_PAGEEXEC
56302 + if (pax_flags_softmode & MF_PAX_PAGEEXEC)
56303 + pax_flags |= MF_PAX_PAGEEXEC;
56304 +#endif
56305 +
56306 +#ifdef CONFIG_PAX_SEGMEXEC
56307 + if (pax_flags_softmode & MF_PAX_SEGMEXEC)
56308 + pax_flags |= MF_PAX_SEGMEXEC;
56309 +#endif
56310 +
56311 +#ifdef CONFIG_PAX_EMUTRAMP
56312 + if ((pax_flags_softmode & MF_PAX_EMUTRAMP) && (pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)))
56313 + pax_flags |= MF_PAX_EMUTRAMP;
56314 +#endif
56315 +
56316 +#ifdef CONFIG_PAX_MPROTECT
56317 + if (pax_flags_softmode & MF_PAX_MPROTECT)
56318 + pax_flags |= MF_PAX_MPROTECT;
56319 +#endif
56320 +
56321 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
56322 + if (randomize_va_space && (pax_flags_softmode & MF_PAX_RANDMMAP))
56323 + pax_flags |= MF_PAX_RANDMMAP;
56324 +#endif
56325 +
56326 + return pax_flags;
56327 +}
56328 +#endif
56329 +
56330 +static unsigned long pax_parse_xattr_pax_hardmode(unsigned long pax_flags_hardmode)
56331 +{
56332 + unsigned long pax_flags = 0UL;
56333 +
56334 +#ifdef CONFIG_PAX_PAGEEXEC
56335 + if (!(pax_flags_hardmode & MF_PAX_PAGEEXEC))
56336 + pax_flags |= MF_PAX_PAGEEXEC;
56337 +#endif
56338 +
56339 +#ifdef CONFIG_PAX_SEGMEXEC
56340 + if (!(pax_flags_hardmode & MF_PAX_SEGMEXEC))
56341 + pax_flags |= MF_PAX_SEGMEXEC;
56342 +#endif
56343 +
56344 +#ifdef CONFIG_PAX_EMUTRAMP
56345 + if (!(pax_flags_hardmode & MF_PAX_EMUTRAMP))
56346 + pax_flags |= MF_PAX_EMUTRAMP;
56347 +#endif
56348 +
56349 +#ifdef CONFIG_PAX_MPROTECT
56350 + if (!(pax_flags_hardmode & MF_PAX_MPROTECT))
56351 + pax_flags |= MF_PAX_MPROTECT;
56352 +#endif
56353 +
56354 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
56355 + if (randomize_va_space && !(pax_flags_hardmode & MF_PAX_RANDMMAP))
56356 + pax_flags |= MF_PAX_RANDMMAP;
56357 +#endif
56358 +
56359 + return pax_flags;
56360 +}
56361 +#endif
56362 +
56363 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
56364 +static unsigned long pax_parse_defaults(void)
56365 +{
56366 + unsigned long pax_flags = 0UL;
56367 +
56368 +#ifdef CONFIG_PAX_SOFTMODE
56369 + if (pax_softmode)
56370 + return pax_flags;
56371 +#endif
56372 +
56373 +#ifdef CONFIG_PAX_PAGEEXEC
56374 + pax_flags |= MF_PAX_PAGEEXEC;
56375 +#endif
56376 +
56377 +#ifdef CONFIG_PAX_SEGMEXEC
56378 + pax_flags |= MF_PAX_SEGMEXEC;
56379 +#endif
56380 +
56381 +#ifdef CONFIG_PAX_MPROTECT
56382 + pax_flags |= MF_PAX_MPROTECT;
56383 +#endif
56384 +
56385 +#ifdef CONFIG_PAX_RANDMMAP
56386 + if (randomize_va_space)
56387 + pax_flags |= MF_PAX_RANDMMAP;
56388 +#endif
56389 +
56390 + return pax_flags;
56391 +}
56392 +
56393 +static unsigned long pax_parse_ei_pax(const struct elfhdr * const elf_ex)
56394 +{
56395 + unsigned long pax_flags = PAX_PARSE_FLAGS_FALLBACK;
56396 +
56397 +#ifdef CONFIG_PAX_EI_PAX
56398 +
56399 +#ifdef CONFIG_PAX_SOFTMODE
56400 + if (pax_softmode)
56401 + return pax_flags;
56402 +#endif
56403 +
56404 + pax_flags = 0UL;
56405 +
56406 +#ifdef CONFIG_PAX_PAGEEXEC
56407 + if (!(elf_ex->e_ident[EI_PAX] & EF_PAX_PAGEEXEC))
56408 + pax_flags |= MF_PAX_PAGEEXEC;
56409 +#endif
56410 +
56411 +#ifdef CONFIG_PAX_SEGMEXEC
56412 + if (!(elf_ex->e_ident[EI_PAX] & EF_PAX_SEGMEXEC))
56413 + pax_flags |= MF_PAX_SEGMEXEC;
56414 +#endif
56415 +
56416 +#ifdef CONFIG_PAX_EMUTRAMP
56417 + if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) && (elf_ex->e_ident[EI_PAX] & EF_PAX_EMUTRAMP))
56418 + pax_flags |= MF_PAX_EMUTRAMP;
56419 +#endif
56420 +
56421 +#ifdef CONFIG_PAX_MPROTECT
56422 + if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) && !(elf_ex->e_ident[EI_PAX] & EF_PAX_MPROTECT))
56423 + pax_flags |= MF_PAX_MPROTECT;
56424 +#endif
56425 +
56426 +#ifdef CONFIG_PAX_ASLR
56427 + if (randomize_va_space && !(elf_ex->e_ident[EI_PAX] & EF_PAX_RANDMMAP))
56428 + pax_flags |= MF_PAX_RANDMMAP;
56429 +#endif
56430 +
56431 +#endif
56432 +
56433 + return pax_flags;
56434 +
56435 +}
56436 +
56437 +static unsigned long pax_parse_pt_pax(const struct elfhdr * const elf_ex, const struct elf_phdr * const elf_phdata)
56438 +{
56439 +
56440 +#ifdef CONFIG_PAX_PT_PAX_FLAGS
56441 + unsigned long i;
56442 +
56443 + for (i = 0UL; i < elf_ex->e_phnum; i++)
56444 + if (elf_phdata[i].p_type == PT_PAX_FLAGS) {
56445 + if (((elf_phdata[i].p_flags & PF_PAGEEXEC) && (elf_phdata[i].p_flags & PF_NOPAGEEXEC)) ||
56446 + ((elf_phdata[i].p_flags & PF_SEGMEXEC) && (elf_phdata[i].p_flags & PF_NOSEGMEXEC)) ||
56447 + ((elf_phdata[i].p_flags & PF_EMUTRAMP) && (elf_phdata[i].p_flags & PF_NOEMUTRAMP)) ||
56448 + ((elf_phdata[i].p_flags & PF_MPROTECT) && (elf_phdata[i].p_flags & PF_NOMPROTECT)) ||
56449 + ((elf_phdata[i].p_flags & PF_RANDMMAP) && (elf_phdata[i].p_flags & PF_NORANDMMAP)))
56450 + return PAX_PARSE_FLAGS_FALLBACK;
56451 +
56452 +#ifdef CONFIG_PAX_SOFTMODE
56453 + if (pax_softmode)
56454 + return pax_parse_pt_pax_softmode(&elf_phdata[i]);
56455 + else
56456 +#endif
56457 +
56458 + return pax_parse_pt_pax_hardmode(&elf_phdata[i]);
56459 + break;
56460 + }
56461 +#endif
56462 +
56463 + return PAX_PARSE_FLAGS_FALLBACK;
56464 +}
56465 +
56466 +static unsigned long pax_parse_xattr_pax(struct file * const file)
56467 +{
56468 +
56469 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
56470 + ssize_t xattr_size, i;
56471 + unsigned char xattr_value[sizeof("pemrs") - 1];
56472 + unsigned long pax_flags_hardmode = 0UL, pax_flags_softmode = 0UL;
56473 +
56474 + xattr_size = pax_getxattr(file->f_path.dentry, xattr_value, sizeof xattr_value);
56475 + if (xattr_size < 0 || xattr_size > sizeof xattr_value)
56476 + return PAX_PARSE_FLAGS_FALLBACK;
56477 +
56478 + for (i = 0; i < xattr_size; i++)
56479 + switch (xattr_value[i]) {
56480 + default:
56481 + return PAX_PARSE_FLAGS_FALLBACK;
56482 +
56483 +#define parse_flag(option1, option2, flag) \
56484 + case option1: \
56485 + if (pax_flags_hardmode & MF_PAX_##flag) \
56486 + return PAX_PARSE_FLAGS_FALLBACK;\
56487 + pax_flags_hardmode |= MF_PAX_##flag; \
56488 + break; \
56489 + case option2: \
56490 + if (pax_flags_softmode & MF_PAX_##flag) \
56491 + return PAX_PARSE_FLAGS_FALLBACK;\
56492 + pax_flags_softmode |= MF_PAX_##flag; \
56493 + break;
56494 +
56495 + parse_flag('p', 'P', PAGEEXEC);
56496 + parse_flag('e', 'E', EMUTRAMP);
56497 + parse_flag('m', 'M', MPROTECT);
56498 + parse_flag('r', 'R', RANDMMAP);
56499 + parse_flag('s', 'S', SEGMEXEC);
56500 +
56501 +#undef parse_flag
56502 + }
56503 +
56504 + if (pax_flags_hardmode & pax_flags_softmode)
56505 + return PAX_PARSE_FLAGS_FALLBACK;
56506 +
56507 +#ifdef CONFIG_PAX_SOFTMODE
56508 + if (pax_softmode)
56509 + return pax_parse_xattr_pax_softmode(pax_flags_softmode);
56510 + else
56511 +#endif
56512 +
56513 + return pax_parse_xattr_pax_hardmode(pax_flags_hardmode);
56514 +#else
56515 + return PAX_PARSE_FLAGS_FALLBACK;
56516 +#endif
56517 +
56518 +}
56519 +
56520 +static long pax_parse_pax_flags(const struct elfhdr * const elf_ex, const struct elf_phdr * const elf_phdata, struct file * const file)
56521 +{
56522 + unsigned long pax_flags, ei_pax_flags, pt_pax_flags, xattr_pax_flags;
56523 +
56524 + pax_flags = pax_parse_defaults();
56525 + ei_pax_flags = pax_parse_ei_pax(elf_ex);
56526 + pt_pax_flags = pax_parse_pt_pax(elf_ex, elf_phdata);
56527 + xattr_pax_flags = pax_parse_xattr_pax(file);
56528 +
56529 + if (pt_pax_flags != PAX_PARSE_FLAGS_FALLBACK &&
56530 + xattr_pax_flags != PAX_PARSE_FLAGS_FALLBACK &&
56531 + pt_pax_flags != xattr_pax_flags)
56532 + return -EINVAL;
56533 + if (xattr_pax_flags != PAX_PARSE_FLAGS_FALLBACK)
56534 + pax_flags = xattr_pax_flags;
56535 + else if (pt_pax_flags != PAX_PARSE_FLAGS_FALLBACK)
56536 + pax_flags = pt_pax_flags;
56537 + else if (ei_pax_flags != PAX_PARSE_FLAGS_FALLBACK)
56538 + pax_flags = ei_pax_flags;
56539 +
56540 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_PAX_SEGMEXEC)
56541 + if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) == (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
56542 + if ((__supported_pte_mask & _PAGE_NX))
56543 + pax_flags &= ~MF_PAX_SEGMEXEC;
56544 + else
56545 + pax_flags &= ~MF_PAX_PAGEEXEC;
56546 + }
56547 +#endif
56548 +
56549 + if (0 > pax_check_flags(&pax_flags))
56550 + return -EINVAL;
56551 +
56552 + current->mm->pax_flags = pax_flags;
56553 + return 0;
56554 +}
56555 +#endif
56556 +
56557 /*
56558 * These are the functions used to load ELF style executables and shared
56559 * libraries. There is no binary dependent code anywhere else.
56560 @@ -556,6 +917,11 @@ static unsigned long randomize_stack_top(unsigned long stack_top)
56561 {
56562 unsigned int random_variable = 0;
56563
56564 +#ifdef CONFIG_PAX_RANDUSTACK
56565 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
56566 + return stack_top - current->mm->delta_stack;
56567 +#endif
56568 +
56569 if ((current->flags & PF_RANDOMIZE) &&
56570 !(current->personality & ADDR_NO_RANDOMIZE)) {
56571 random_variable = get_random_int() & STACK_RND_MASK;
56572 @@ -574,7 +940,7 @@ static int load_elf_binary(struct linux_binprm *bprm)
56573 unsigned long load_addr = 0, load_bias = 0;
56574 int load_addr_set = 0;
56575 char * elf_interpreter = NULL;
56576 - unsigned long error;
56577 + unsigned long error = 0;
56578 struct elf_phdr *elf_ppnt, *elf_phdata;
56579 unsigned long elf_bss, elf_brk;
56580 int retval, i;
56581 @@ -589,6 +955,7 @@ static int load_elf_binary(struct linux_binprm *bprm)
56582 struct elfhdr elf_ex;
56583 struct elfhdr interp_elf_ex;
56584 } *loc;
56585 + unsigned long pax_task_size;
56586
56587 loc = kmalloc(sizeof(*loc), GFP_KERNEL);
56588 if (!loc) {
56589 @@ -726,6 +1093,77 @@ static int load_elf_binary(struct linux_binprm *bprm)
56590 /* Do this immediately, since STACK_TOP as used in setup_arg_pages
56591 may depend on the personality. */
56592 SET_PERSONALITY(loc->elf_ex);
56593 +
56594 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
56595 + current->mm->pax_flags = 0UL;
56596 +#endif
56597 +
56598 +#ifdef CONFIG_PAX_DLRESOLVE
56599 + current->mm->call_dl_resolve = 0UL;
56600 +#endif
56601 +
56602 +#if defined(CONFIG_PPC32) && defined(CONFIG_PAX_EMUSIGRT)
56603 + current->mm->call_syscall = 0UL;
56604 +#endif
56605 +
56606 +#ifdef CONFIG_PAX_ASLR
56607 + current->mm->delta_mmap = 0UL;
56608 + current->mm->delta_stack = 0UL;
56609 +#endif
56610 +
56611 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
56612 + if (0 > pax_parse_pax_flags(&loc->elf_ex, elf_phdata, bprm->file)) {
56613 + send_sig(SIGKILL, current, 0);
56614 + goto out_free_dentry;
56615 + }
56616 +#endif
56617 +
56618 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
56619 + pax_set_initial_flags(bprm);
56620 +#elif defined(CONFIG_PAX_HOOK_ACL_FLAGS)
56621 + if (pax_set_initial_flags_func)
56622 + (pax_set_initial_flags_func)(bprm);
56623 +#endif
56624 +
56625 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
56626 + if ((current->mm->pax_flags & MF_PAX_PAGEEXEC) && !(__supported_pte_mask & _PAGE_NX)) {
56627 + current->mm->context.user_cs_limit = PAGE_SIZE;
56628 + current->mm->def_flags |= VM_PAGEEXEC | VM_NOHUGEPAGE;
56629 + }
56630 +#endif
56631 +
56632 +#ifdef CONFIG_PAX_SEGMEXEC
56633 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC) {
56634 + current->mm->context.user_cs_base = SEGMEXEC_TASK_SIZE;
56635 + current->mm->context.user_cs_limit = TASK_SIZE-SEGMEXEC_TASK_SIZE;
56636 + pax_task_size = SEGMEXEC_TASK_SIZE;
56637 + current->mm->def_flags |= VM_NOHUGEPAGE;
56638 + } else
56639 +#endif
56640 +
56641 + pax_task_size = TASK_SIZE;
56642 +
56643 +#if defined(CONFIG_ARCH_TRACK_EXEC_LIMIT) || defined(CONFIG_PAX_SEGMEXEC)
56644 + if (current->mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
56645 + set_user_cs(current->mm->context.user_cs_base, current->mm->context.user_cs_limit, get_cpu());
56646 + put_cpu();
56647 + }
56648 +#endif
56649 +
56650 +#ifdef CONFIG_PAX_ASLR
56651 + if (current->mm->pax_flags & MF_PAX_RANDMMAP) {
56652 + current->mm->delta_mmap = (pax_get_random_long() & ((1UL << PAX_DELTA_MMAP_LEN)-1)) << PAGE_SHIFT;
56653 + current->mm->delta_stack = (pax_get_random_long() & ((1UL << PAX_DELTA_STACK_LEN)-1)) << PAGE_SHIFT;
56654 + }
56655 +#endif
56656 +
56657 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
56658 + if (current->mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
56659 + executable_stack = EXSTACK_DISABLE_X;
56660 + current->personality &= ~READ_IMPLIES_EXEC;
56661 + } else
56662 +#endif
56663 +
56664 if (elf_read_implies_exec(loc->elf_ex, executable_stack))
56665 current->personality |= READ_IMPLIES_EXEC;
56666
56667 @@ -815,6 +1253,20 @@ static int load_elf_binary(struct linux_binprm *bprm)
56668 #else
56669 load_bias = ELF_PAGESTART(ELF_ET_DYN_BASE - vaddr);
56670 #endif
56671 +
56672 +#ifdef CONFIG_PAX_RANDMMAP
56673 + /* PaX: randomize base address at the default exe base if requested */
56674 + if ((current->mm->pax_flags & MF_PAX_RANDMMAP) && elf_interpreter) {
56675 +#ifdef CONFIG_SPARC64
56676 + load_bias = (pax_get_random_long() & ((1UL << PAX_DELTA_MMAP_LEN) - 1)) << (PAGE_SHIFT+1);
56677 +#else
56678 + load_bias = (pax_get_random_long() & ((1UL << PAX_DELTA_MMAP_LEN) - 1)) << PAGE_SHIFT;
56679 +#endif
56680 + load_bias = ELF_PAGESTART(PAX_ELF_ET_DYN_BASE - vaddr + load_bias);
56681 + elf_flags |= MAP_FIXED;
56682 + }
56683 +#endif
56684 +
56685 }
56686
56687 error = elf_map(bprm->file, load_bias + vaddr, elf_ppnt,
56688 @@ -847,9 +1299,9 @@ static int load_elf_binary(struct linux_binprm *bprm)
56689 * allowed task size. Note that p_filesz must always be
56690 * <= p_memsz so it is only necessary to check p_memsz.
56691 */
56692 - if (BAD_ADDR(k) || elf_ppnt->p_filesz > elf_ppnt->p_memsz ||
56693 - elf_ppnt->p_memsz > TASK_SIZE ||
56694 - TASK_SIZE - elf_ppnt->p_memsz < k) {
56695 + if (k >= pax_task_size || elf_ppnt->p_filesz > elf_ppnt->p_memsz ||
56696 + elf_ppnt->p_memsz > pax_task_size ||
56697 + pax_task_size - elf_ppnt->p_memsz < k) {
56698 /* set_brk can never work. Avoid overflows. */
56699 send_sig(SIGKILL, current, 0);
56700 retval = -EINVAL;
56701 @@ -888,17 +1340,45 @@ static int load_elf_binary(struct linux_binprm *bprm)
56702 goto out_free_dentry;
56703 }
56704 if (likely(elf_bss != elf_brk) && unlikely(padzero(elf_bss))) {
56705 - send_sig(SIGSEGV, current, 0);
56706 - retval = -EFAULT; /* Nobody gets to see this, but.. */
56707 - goto out_free_dentry;
56708 + /*
56709 + * This bss-zeroing can fail if the ELF
56710 + * file specifies odd protections. So
56711 + * we don't check the return value
56712 + */
56713 }
56714
56715 +#ifdef CONFIG_PAX_RANDMMAP
56716 + if (current->mm->pax_flags & MF_PAX_RANDMMAP) {
56717 + unsigned long start, size, flags;
56718 + vm_flags_t vm_flags;
56719 +
56720 + start = ELF_PAGEALIGN(elf_brk);
56721 + size = PAGE_SIZE + ((pax_get_random_long() & ((1UL << 22) - 1UL)) << 4);
56722 + flags = MAP_FIXED | MAP_PRIVATE;
56723 + vm_flags = VM_DONTEXPAND | VM_DONTDUMP;
56724 +
56725 + down_write(&current->mm->mmap_sem);
56726 + start = get_unmapped_area(NULL, start, PAGE_ALIGN(size), 0, flags);
56727 + retval = -ENOMEM;
56728 + if (!IS_ERR_VALUE(start) && !find_vma_intersection(current->mm, start, start + size + PAGE_SIZE)) {
56729 +// if (current->personality & ADDR_NO_RANDOMIZE)
56730 +// vm_flags |= VM_READ | VM_MAYREAD;
56731 + start = mmap_region(NULL, start, PAGE_ALIGN(size), vm_flags, 0);
56732 + retval = IS_ERR_VALUE(start) ? start : 0;
56733 + }
56734 + up_write(&current->mm->mmap_sem);
56735 + if (retval == 0)
56736 + retval = set_brk(start + size, start + size + PAGE_SIZE);
56737 + if (retval < 0) {
56738 + send_sig(SIGKILL, current, 0);
56739 + goto out_free_dentry;
56740 + }
56741 + }
56742 +#endif
56743 +
56744 if (elf_interpreter) {
56745 - unsigned long interp_map_addr = 0;
56746 -
56747 elf_entry = load_elf_interp(&loc->interp_elf_ex,
56748 interpreter,
56749 - &interp_map_addr,
56750 load_bias);
56751 if (!IS_ERR((void *)elf_entry)) {
56752 /*
56753 @@ -1122,7 +1602,7 @@ static bool always_dump_vma(struct vm_area_struct *vma)
56754 * Decide what to dump of a segment, part, all or none.
56755 */
56756 static unsigned long vma_dump_size(struct vm_area_struct *vma,
56757 - unsigned long mm_flags)
56758 + unsigned long mm_flags, long signr)
56759 {
56760 #define FILTER(type) (mm_flags & (1UL << MMF_DUMP_##type))
56761
56762 @@ -1160,7 +1640,7 @@ static unsigned long vma_dump_size(struct vm_area_struct *vma,
56763 if (vma->vm_file == NULL)
56764 return 0;
56765
56766 - if (FILTER(MAPPED_PRIVATE))
56767 + if (signr == SIGKILL || FILTER(MAPPED_PRIVATE))
56768 goto whole;
56769
56770 /*
56771 @@ -1367,9 +1847,9 @@ static void fill_auxv_note(struct memelfnote *note, struct mm_struct *mm)
56772 {
56773 elf_addr_t *auxv = (elf_addr_t *) mm->saved_auxv;
56774 int i = 0;
56775 - do
56776 + do {
56777 i += 2;
56778 - while (auxv[i - 2] != AT_NULL);
56779 + } while (auxv[i - 2] != AT_NULL);
56780 fill_note(note, "CORE", NT_AUXV, i * sizeof(elf_addr_t), auxv);
56781 }
56782
56783 @@ -1378,7 +1858,7 @@ static void fill_siginfo_note(struct memelfnote *note, user_siginfo_t *csigdata,
56784 {
56785 mm_segment_t old_fs = get_fs();
56786 set_fs(KERNEL_DS);
56787 - copy_siginfo_to_user((user_siginfo_t __user *) csigdata, siginfo);
56788 + copy_siginfo_to_user((user_siginfo_t __force_user *) csigdata, siginfo);
56789 set_fs(old_fs);
56790 fill_note(note, "CORE", NT_SIGINFO, sizeof(*csigdata), csigdata);
56791 }
56792 @@ -2002,14 +2482,14 @@ static void fill_extnum_info(struct elfhdr *elf, struct elf_shdr *shdr4extnum,
56793 }
56794
56795 static size_t elf_core_vma_data_size(struct vm_area_struct *gate_vma,
56796 - unsigned long mm_flags)
56797 + struct coredump_params *cprm)
56798 {
56799 struct vm_area_struct *vma;
56800 size_t size = 0;
56801
56802 for (vma = first_vma(current, gate_vma); vma != NULL;
56803 vma = next_vma(vma, gate_vma))
56804 - size += vma_dump_size(vma, mm_flags);
56805 + size += vma_dump_size(vma, cprm->mm_flags, cprm->siginfo->si_signo);
56806 return size;
56807 }
56808
56809 @@ -2100,7 +2580,7 @@ static int elf_core_dump(struct coredump_params *cprm)
56810
56811 dataoff = offset = roundup(offset, ELF_EXEC_PAGESIZE);
56812
56813 - offset += elf_core_vma_data_size(gate_vma, cprm->mm_flags);
56814 + offset += elf_core_vma_data_size(gate_vma, cprm);
56815 offset += elf_core_extra_data_size();
56816 e_shoff = offset;
56817
56818 @@ -2128,7 +2608,7 @@ static int elf_core_dump(struct coredump_params *cprm)
56819 phdr.p_offset = offset;
56820 phdr.p_vaddr = vma->vm_start;
56821 phdr.p_paddr = 0;
56822 - phdr.p_filesz = vma_dump_size(vma, cprm->mm_flags);
56823 + phdr.p_filesz = vma_dump_size(vma, cprm->mm_flags, cprm->siginfo->si_signo);
56824 phdr.p_memsz = vma->vm_end - vma->vm_start;
56825 offset += phdr.p_filesz;
56826 phdr.p_flags = vma->vm_flags & VM_READ ? PF_R : 0;
56827 @@ -2161,7 +2641,7 @@ static int elf_core_dump(struct coredump_params *cprm)
56828 unsigned long addr;
56829 unsigned long end;
56830
56831 - end = vma->vm_start + vma_dump_size(vma, cprm->mm_flags);
56832 + end = vma->vm_start + vma_dump_size(vma, cprm->mm_flags, cprm->siginfo->si_signo);
56833
56834 for (addr = vma->vm_start; addr < end; addr += PAGE_SIZE) {
56835 struct page *page;
56836 @@ -2202,6 +2682,167 @@ out:
56837
56838 #endif /* CONFIG_ELF_CORE */
56839
56840 +#ifdef CONFIG_PAX_MPROTECT
56841 +/* PaX: non-PIC ELF libraries need relocations on their executable segments
56842 + * therefore we'll grant them VM_MAYWRITE once during their life. Similarly
56843 + * we'll remove VM_MAYWRITE for good on RELRO segments.
56844 + *
56845 + * The checks favour ld-linux.so behaviour which operates on a per ELF segment
56846 + * basis because we want to allow the common case and not the special ones.
56847 + */
56848 +static void elf_handle_mprotect(struct vm_area_struct *vma, unsigned long newflags)
56849 +{
56850 + struct elfhdr elf_h;
56851 + struct elf_phdr elf_p;
56852 + unsigned long i;
56853 + unsigned long oldflags;
56854 + bool is_textrel_rw, is_textrel_rx, is_relro;
56855 +
56856 + if (!(vma->vm_mm->pax_flags & MF_PAX_MPROTECT) || !vma->vm_file)
56857 + return;
56858 +
56859 + oldflags = vma->vm_flags & (VM_MAYEXEC | VM_MAYWRITE | VM_MAYREAD | VM_EXEC | VM_WRITE | VM_READ);
56860 + newflags &= VM_MAYEXEC | VM_MAYWRITE | VM_MAYREAD | VM_EXEC | VM_WRITE | VM_READ;
56861 +
56862 +#ifdef CONFIG_PAX_ELFRELOCS
56863 + /* possible TEXTREL */
56864 + is_textrel_rw = !vma->anon_vma && oldflags == (VM_MAYEXEC | VM_MAYREAD | VM_EXEC | VM_READ) && newflags == (VM_WRITE | VM_READ);
56865 + is_textrel_rx = vma->anon_vma && oldflags == (VM_MAYEXEC | VM_MAYWRITE | VM_MAYREAD | VM_WRITE | VM_READ) && newflags == (VM_EXEC | VM_READ);
56866 +#else
56867 + is_textrel_rw = false;
56868 + is_textrel_rx = false;
56869 +#endif
56870 +
56871 + /* possible RELRO */
56872 + is_relro = vma->anon_vma && oldflags == (VM_MAYWRITE | VM_MAYREAD | VM_READ) && newflags == (VM_MAYWRITE | VM_MAYREAD | VM_READ);
56873 +
56874 + if (!is_textrel_rw && !is_textrel_rx && !is_relro)
56875 + return;
56876 +
56877 + if (sizeof(elf_h) != kernel_read(vma->vm_file, 0UL, (char *)&elf_h, sizeof(elf_h)) ||
56878 + memcmp(elf_h.e_ident, ELFMAG, SELFMAG) ||
56879 +
56880 +#ifdef CONFIG_PAX_ETEXECRELOCS
56881 + ((is_textrel_rw || is_textrel_rx) && (elf_h.e_type != ET_DYN && elf_h.e_type != ET_EXEC)) ||
56882 +#else
56883 + ((is_textrel_rw || is_textrel_rx) && elf_h.e_type != ET_DYN) ||
56884 +#endif
56885 +
56886 + (is_relro && (elf_h.e_type != ET_DYN && elf_h.e_type != ET_EXEC)) ||
56887 + !elf_check_arch(&elf_h) ||
56888 + elf_h.e_phentsize != sizeof(struct elf_phdr) ||
56889 + elf_h.e_phnum > 65536UL / sizeof(struct elf_phdr))
56890 + return;
56891 +
56892 + for (i = 0UL; i < elf_h.e_phnum; i++) {
56893 + if (sizeof(elf_p) != kernel_read(vma->vm_file, elf_h.e_phoff + i*sizeof(elf_p), (char *)&elf_p, sizeof(elf_p)))
56894 + return;
56895 + switch (elf_p.p_type) {
56896 + case PT_DYNAMIC:
56897 + if (!is_textrel_rw && !is_textrel_rx)
56898 + continue;
56899 + i = 0UL;
56900 + while ((i+1) * sizeof(elf_dyn) <= elf_p.p_filesz) {
56901 + elf_dyn dyn;
56902 +
56903 + if (sizeof(dyn) != kernel_read(vma->vm_file, elf_p.p_offset + i*sizeof(dyn), (char *)&dyn, sizeof(dyn)))
56904 + break;
56905 + if (dyn.d_tag == DT_NULL)
56906 + break;
56907 + if (dyn.d_tag == DT_TEXTREL || (dyn.d_tag == DT_FLAGS && (dyn.d_un.d_val & DF_TEXTREL))) {
56908 + gr_log_textrel(vma);
56909 + if (is_textrel_rw)
56910 + vma->vm_flags |= VM_MAYWRITE;
56911 + else
56912 + /* PaX: disallow write access after relocs are done, hopefully noone else needs it... */
56913 + vma->vm_flags &= ~VM_MAYWRITE;
56914 + break;
56915 + }
56916 + i++;
56917 + }
56918 + is_textrel_rw = false;
56919 + is_textrel_rx = false;
56920 + continue;
56921 +
56922 + case PT_GNU_RELRO:
56923 + if (!is_relro)
56924 + continue;
56925 + if ((elf_p.p_offset >> PAGE_SHIFT) == vma->vm_pgoff && ELF_PAGEALIGN(elf_p.p_memsz) == vma->vm_end - vma->vm_start)
56926 + vma->vm_flags &= ~VM_MAYWRITE;
56927 + is_relro = false;
56928 + continue;
56929 +
56930 +#ifdef CONFIG_PAX_PT_PAX_FLAGS
56931 + case PT_PAX_FLAGS: {
56932 + const char *msg_mprotect = "", *msg_emutramp = "";
56933 + char *buffer_lib, *buffer_exe;
56934 +
56935 + if (elf_p.p_flags & PF_NOMPROTECT)
56936 + msg_mprotect = "MPROTECT disabled";
56937 +
56938 +#ifdef CONFIG_PAX_EMUTRAMP
56939 + if (!(vma->vm_mm->pax_flags & MF_PAX_EMUTRAMP) && !(elf_p.p_flags & PF_NOEMUTRAMP))
56940 + msg_emutramp = "EMUTRAMP enabled";
56941 +#endif
56942 +
56943 + if (!msg_mprotect[0] && !msg_emutramp[0])
56944 + continue;
56945 +
56946 + if (!printk_ratelimit())
56947 + continue;
56948 +
56949 + buffer_lib = (char *)__get_free_page(GFP_KERNEL);
56950 + buffer_exe = (char *)__get_free_page(GFP_KERNEL);
56951 + if (buffer_lib && buffer_exe) {
56952 + char *path_lib, *path_exe;
56953 +
56954 + path_lib = pax_get_path(&vma->vm_file->f_path, buffer_lib, PAGE_SIZE);
56955 + path_exe = pax_get_path(&vma->vm_mm->exe_file->f_path, buffer_exe, PAGE_SIZE);
56956 +
56957 + pr_info("PAX: %s wants %s%s%s on %s\n", path_lib, msg_mprotect,
56958 + (msg_mprotect[0] && msg_emutramp[0] ? " and " : ""), msg_emutramp, path_exe);
56959 +
56960 + }
56961 + free_page((unsigned long)buffer_exe);
56962 + free_page((unsigned long)buffer_lib);
56963 + continue;
56964 + }
56965 +#endif
56966 +
56967 + }
56968 + }
56969 +}
56970 +#endif
56971 +
56972 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
56973 +
56974 +extern int grsec_enable_log_rwxmaps;
56975 +
56976 +static void elf_handle_mmap(struct file *file)
56977 +{
56978 + struct elfhdr elf_h;
56979 + struct elf_phdr elf_p;
56980 + unsigned long i;
56981 +
56982 + if (!grsec_enable_log_rwxmaps)
56983 + return;
56984 +
56985 + if (sizeof(elf_h) != kernel_read(file, 0UL, (char *)&elf_h, sizeof(elf_h)) ||
56986 + memcmp(elf_h.e_ident, ELFMAG, SELFMAG) ||
56987 + (elf_h.e_type != ET_DYN && elf_h.e_type != ET_EXEC) || !elf_check_arch(&elf_h) ||
56988 + elf_h.e_phentsize != sizeof(struct elf_phdr) ||
56989 + elf_h.e_phnum > 65536UL / sizeof(struct elf_phdr))
56990 + return;
56991 +
56992 + for (i = 0UL; i < elf_h.e_phnum; i++) {
56993 + if (sizeof(elf_p) != kernel_read(file, elf_h.e_phoff + i*sizeof(elf_p), (char *)&elf_p, sizeof(elf_p)))
56994 + return;
56995 + if (elf_p.p_type == PT_GNU_STACK && (elf_p.p_flags & PF_X))
56996 + gr_log_ptgnustack(file);
56997 + }
56998 +}
56999 +#endif
57000 +
57001 static int __init init_elf_binfmt(void)
57002 {
57003 register_binfmt(&elf_format);
57004 diff --git a/fs/bio.c b/fs/bio.c
57005 index 6f0362b..26a7496 100644
57006 --- a/fs/bio.c
57007 +++ b/fs/bio.c
57008 @@ -1144,7 +1144,7 @@ struct bio *bio_copy_user_iov(struct request_queue *q,
57009 /*
57010 * Overflow, abort
57011 */
57012 - if (end < start)
57013 + if (end < start || end - start > INT_MAX - nr_pages)
57014 return ERR_PTR(-EINVAL);
57015
57016 nr_pages += end - start;
57017 @@ -1278,7 +1278,7 @@ static struct bio *__bio_map_user_iov(struct request_queue *q,
57018 /*
57019 * Overflow, abort
57020 */
57021 - if (end < start)
57022 + if (end < start || end - start > INT_MAX - nr_pages)
57023 return ERR_PTR(-EINVAL);
57024
57025 nr_pages += end - start;
57026 @@ -1540,7 +1540,7 @@ static void bio_copy_kern_endio(struct bio *bio, int err)
57027 const int read = bio_data_dir(bio) == READ;
57028 struct bio_map_data *bmd = bio->bi_private;
57029 int i;
57030 - char *p = bmd->sgvecs[0].iov_base;
57031 + char *p = (char __force_kernel *)bmd->sgvecs[0].iov_base;
57032
57033 bio_for_each_segment_all(bvec, bio, i) {
57034 char *addr = page_address(bvec->bv_page);
57035 diff --git a/fs/block_dev.c b/fs/block_dev.c
57036 index 552a8d1..d51ccf3 100644
57037 --- a/fs/block_dev.c
57038 +++ b/fs/block_dev.c
57039 @@ -637,7 +637,7 @@ static bool bd_may_claim(struct block_device *bdev, struct block_device *whole,
57040 else if (bdev->bd_contains == bdev)
57041 return true; /* is a whole device which isn't held */
57042
57043 - else if (whole->bd_holder == bd_may_claim)
57044 + else if (whole->bd_holder == (void *)bd_may_claim)
57045 return true; /* is a partition of a device that is being partitioned */
57046 else if (whole->bd_holder != NULL)
57047 return false; /* is a partition of a held device */
57048 diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c
57049 index 1bcfcdb..e942132 100644
57050 --- a/fs/btrfs/ctree.c
57051 +++ b/fs/btrfs/ctree.c
57052 @@ -1216,9 +1216,12 @@ static noinline int __btrfs_cow_block(struct btrfs_trans_handle *trans,
57053 free_extent_buffer(buf);
57054 add_root_to_dirty_list(root);
57055 } else {
57056 - if (root->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID)
57057 - parent_start = parent->start;
57058 - else
57059 + if (root->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID) {
57060 + if (parent)
57061 + parent_start = parent->start;
57062 + else
57063 + parent_start = 0;
57064 + } else
57065 parent_start = 0;
57066
57067 WARN_ON(trans->transid != btrfs_header_generation(parent));
57068 diff --git a/fs/btrfs/delayed-inode.c b/fs/btrfs/delayed-inode.c
57069 index 33e561a..16df7ae 100644
57070 --- a/fs/btrfs/delayed-inode.c
57071 +++ b/fs/btrfs/delayed-inode.c
57072 @@ -459,7 +459,7 @@ static int __btrfs_add_delayed_deletion_item(struct btrfs_delayed_node *node,
57073
57074 static void finish_one_item(struct btrfs_delayed_root *delayed_root)
57075 {
57076 - int seq = atomic_inc_return(&delayed_root->items_seq);
57077 + int seq = atomic_inc_return_unchecked(&delayed_root->items_seq);
57078 if ((atomic_dec_return(&delayed_root->items) <
57079 BTRFS_DELAYED_BACKGROUND || seq % BTRFS_DELAYED_BATCH == 0) &&
57080 waitqueue_active(&delayed_root->wait))
57081 @@ -1409,7 +1409,7 @@ void btrfs_assert_delayed_root_empty(struct btrfs_root *root)
57082
57083 static int could_end_wait(struct btrfs_delayed_root *delayed_root, int seq)
57084 {
57085 - int val = atomic_read(&delayed_root->items_seq);
57086 + int val = atomic_read_unchecked(&delayed_root->items_seq);
57087
57088 if (val < seq || val >= seq + BTRFS_DELAYED_BATCH)
57089 return 1;
57090 @@ -1433,7 +1433,7 @@ void btrfs_balance_delayed_items(struct btrfs_root *root)
57091 int seq;
57092 int ret;
57093
57094 - seq = atomic_read(&delayed_root->items_seq);
57095 + seq = atomic_read_unchecked(&delayed_root->items_seq);
57096
57097 ret = btrfs_wq_run_delayed_node(delayed_root, root, 0);
57098 if (ret)
57099 diff --git a/fs/btrfs/delayed-inode.h b/fs/btrfs/delayed-inode.h
57100 index f70119f..ab5894d 100644
57101 --- a/fs/btrfs/delayed-inode.h
57102 +++ b/fs/btrfs/delayed-inode.h
57103 @@ -43,7 +43,7 @@ struct btrfs_delayed_root {
57104 */
57105 struct list_head prepare_list;
57106 atomic_t items; /* for delayed items */
57107 - atomic_t items_seq; /* for delayed items */
57108 + atomic_unchecked_t items_seq; /* for delayed items */
57109 int nodes; /* for delayed nodes */
57110 wait_queue_head_t wait;
57111 };
57112 @@ -90,7 +90,7 @@ static inline void btrfs_init_delayed_root(
57113 struct btrfs_delayed_root *delayed_root)
57114 {
57115 atomic_set(&delayed_root->items, 0);
57116 - atomic_set(&delayed_root->items_seq, 0);
57117 + atomic_set_unchecked(&delayed_root->items_seq, 0);
57118 delayed_root->nodes = 0;
57119 spin_lock_init(&delayed_root->lock);
57120 init_waitqueue_head(&delayed_root->wait);
57121 diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
57122 index 2f6d7b1..f186382 100644
57123 --- a/fs/btrfs/ioctl.c
57124 +++ b/fs/btrfs/ioctl.c
57125 @@ -3575,9 +3575,12 @@ static long btrfs_ioctl_space_info(struct btrfs_root *root, void __user *arg)
57126 for (i = 0; i < num_types; i++) {
57127 struct btrfs_space_info *tmp;
57128
57129 + /* Don't copy in more than we allocated */
57130 if (!slot_count)
57131 break;
57132
57133 + slot_count--;
57134 +
57135 info = NULL;
57136 rcu_read_lock();
57137 list_for_each_entry_rcu(tmp, &root->fs_info->space_info,
57138 @@ -3599,10 +3602,7 @@ static long btrfs_ioctl_space_info(struct btrfs_root *root, void __user *arg)
57139 memcpy(dest, &space, sizeof(space));
57140 dest++;
57141 space_args.total_spaces++;
57142 - slot_count--;
57143 }
57144 - if (!slot_count)
57145 - break;
57146 }
57147 up_read(&info->groups_sem);
57148 }
57149 diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
57150 index 9601d25..2896d6c 100644
57151 --- a/fs/btrfs/super.c
57152 +++ b/fs/btrfs/super.c
57153 @@ -270,7 +270,7 @@ void __btrfs_abort_transaction(struct btrfs_trans_handle *trans,
57154 function, line, errstr);
57155 return;
57156 }
57157 - ACCESS_ONCE(trans->transaction->aborted) = errno;
57158 + ACCESS_ONCE_RW(trans->transaction->aborted) = errno;
57159 /* Wake up anybody who may be waiting on this transaction */
57160 wake_up(&root->fs_info->transaction_wait);
57161 wake_up(&root->fs_info->transaction_blocked_wait);
57162 diff --git a/fs/btrfs/sysfs.c b/fs/btrfs/sysfs.c
57163 index c5eb214..218cc24 100644
57164 --- a/fs/btrfs/sysfs.c
57165 +++ b/fs/btrfs/sysfs.c
57166 @@ -437,7 +437,7 @@ static int addrm_unknown_feature_attrs(struct btrfs_fs_info *fs_info, bool add)
57167 for (set = 0; set < FEAT_MAX; set++) {
57168 int i;
57169 struct attribute *attrs[2];
57170 - struct attribute_group agroup = {
57171 + attribute_group_no_const agroup = {
57172 .name = "features",
57173 .attrs = attrs,
57174 };
57175 diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c
57176 index e2f45fc..b036909 100644
57177 --- a/fs/btrfs/tree-log.c
57178 +++ b/fs/btrfs/tree-log.c
57179 @@ -2533,7 +2533,7 @@ int btrfs_sync_log(struct btrfs_trans_handle *trans,
57180 blk_finish_plug(&plug);
57181 btrfs_abort_transaction(trans, root, ret);
57182 btrfs_free_logged_extents(log, log_transid);
57183 - ACCESS_ONCE(root->fs_info->last_trans_log_full_commit) =
57184 + ACCESS_ONCE_RW(root->fs_info->last_trans_log_full_commit) =
57185 trans->transid;
57186 mutex_unlock(&root->log_mutex);
57187 goto out;
57188 @@ -2577,7 +2577,7 @@ int btrfs_sync_log(struct btrfs_trans_handle *trans,
57189 list_del_init(&root_log_ctx.list);
57190
57191 blk_finish_plug(&plug);
57192 - ACCESS_ONCE(root->fs_info->last_trans_log_full_commit) =
57193 + ACCESS_ONCE_RW(root->fs_info->last_trans_log_full_commit) =
57194 trans->transid;
57195 if (ret != -ENOSPC) {
57196 btrfs_abort_transaction(trans, root, ret);
57197 @@ -2622,7 +2622,7 @@ int btrfs_sync_log(struct btrfs_trans_handle *trans,
57198 * now that we've moved on to the tree of log tree roots,
57199 * check the full commit flag again
57200 */
57201 - if (ACCESS_ONCE(root->fs_info->last_trans_log_full_commit) ==
57202 + if (ACCESS_ONCE_RW(root->fs_info->last_trans_log_full_commit) ==
57203 trans->transid) {
57204 blk_finish_plug(&plug);
57205 btrfs_wait_marked_extents(log, &log->dirty_log_pages, mark);
57206 @@ -2637,7 +2637,7 @@ int btrfs_sync_log(struct btrfs_trans_handle *trans,
57207 EXTENT_DIRTY | EXTENT_NEW);
57208 blk_finish_plug(&plug);
57209 if (ret) {
57210 - ACCESS_ONCE(root->fs_info->last_trans_log_full_commit) =
57211 + ACCESS_ONCE_RW(root->fs_info->last_trans_log_full_commit) =
57212 trans->transid;
57213 btrfs_abort_transaction(trans, root, ret);
57214 btrfs_free_logged_extents(log, log_transid);
57215 @@ -2667,7 +2667,7 @@ int btrfs_sync_log(struct btrfs_trans_handle *trans,
57216 */
57217 ret = write_ctree_super(trans, root->fs_info->tree_root, 1);
57218 if (ret) {
57219 - ACCESS_ONCE(root->fs_info->last_trans_log_full_commit) =
57220 + ACCESS_ONCE_RW(root->fs_info->last_trans_log_full_commit) =
57221 trans->transid;
57222 btrfs_abort_transaction(trans, root, ret);
57223 goto out_wake_log_root;
57224 diff --git a/fs/buffer.c b/fs/buffer.c
57225 index 9ddb9fc..7aa2487 100644
57226 --- a/fs/buffer.c
57227 +++ b/fs/buffer.c
57228 @@ -3428,7 +3428,7 @@ void __init buffer_init(void)
57229 bh_cachep = kmem_cache_create("buffer_head",
57230 sizeof(struct buffer_head), 0,
57231 (SLAB_RECLAIM_ACCOUNT|SLAB_PANIC|
57232 - SLAB_MEM_SPREAD),
57233 + SLAB_MEM_SPREAD|SLAB_NO_SANITIZE),
57234 NULL);
57235
57236 /*
57237 diff --git a/fs/cachefiles/bind.c b/fs/cachefiles/bind.c
57238 index 5b99baf..47fffb5 100644
57239 --- a/fs/cachefiles/bind.c
57240 +++ b/fs/cachefiles/bind.c
57241 @@ -39,13 +39,11 @@ int cachefiles_daemon_bind(struct cachefiles_cache *cache, char *args)
57242 args);
57243
57244 /* start by checking things over */
57245 - ASSERT(cache->fstop_percent >= 0 &&
57246 - cache->fstop_percent < cache->fcull_percent &&
57247 + ASSERT(cache->fstop_percent < cache->fcull_percent &&
57248 cache->fcull_percent < cache->frun_percent &&
57249 cache->frun_percent < 100);
57250
57251 - ASSERT(cache->bstop_percent >= 0 &&
57252 - cache->bstop_percent < cache->bcull_percent &&
57253 + ASSERT(cache->bstop_percent < cache->bcull_percent &&
57254 cache->bcull_percent < cache->brun_percent &&
57255 cache->brun_percent < 100);
57256
57257 diff --git a/fs/cachefiles/daemon.c b/fs/cachefiles/daemon.c
57258 index 0a1467b..6a53245 100644
57259 --- a/fs/cachefiles/daemon.c
57260 +++ b/fs/cachefiles/daemon.c
57261 @@ -196,7 +196,7 @@ static ssize_t cachefiles_daemon_read(struct file *file, char __user *_buffer,
57262 if (n > buflen)
57263 return -EMSGSIZE;
57264
57265 - if (copy_to_user(_buffer, buffer, n) != 0)
57266 + if (n > sizeof(buffer) || copy_to_user(_buffer, buffer, n) != 0)
57267 return -EFAULT;
57268
57269 return n;
57270 @@ -222,7 +222,7 @@ static ssize_t cachefiles_daemon_write(struct file *file,
57271 if (test_bit(CACHEFILES_DEAD, &cache->flags))
57272 return -EIO;
57273
57274 - if (datalen < 0 || datalen > PAGE_SIZE - 1)
57275 + if (datalen > PAGE_SIZE - 1)
57276 return -EOPNOTSUPP;
57277
57278 /* drag the command string into the kernel so we can parse it */
57279 @@ -386,7 +386,7 @@ static int cachefiles_daemon_fstop(struct cachefiles_cache *cache, char *args)
57280 if (args[0] != '%' || args[1] != '\0')
57281 return -EINVAL;
57282
57283 - if (fstop < 0 || fstop >= cache->fcull_percent)
57284 + if (fstop >= cache->fcull_percent)
57285 return cachefiles_daemon_range_error(cache, args);
57286
57287 cache->fstop_percent = fstop;
57288 @@ -458,7 +458,7 @@ static int cachefiles_daemon_bstop(struct cachefiles_cache *cache, char *args)
57289 if (args[0] != '%' || args[1] != '\0')
57290 return -EINVAL;
57291
57292 - if (bstop < 0 || bstop >= cache->bcull_percent)
57293 + if (bstop >= cache->bcull_percent)
57294 return cachefiles_daemon_range_error(cache, args);
57295
57296 cache->bstop_percent = bstop;
57297 diff --git a/fs/cachefiles/internal.h b/fs/cachefiles/internal.h
57298 index 5349473..d6c0b93 100644
57299 --- a/fs/cachefiles/internal.h
57300 +++ b/fs/cachefiles/internal.h
57301 @@ -59,7 +59,7 @@ struct cachefiles_cache {
57302 wait_queue_head_t daemon_pollwq; /* poll waitqueue for daemon */
57303 struct rb_root active_nodes; /* active nodes (can't be culled) */
57304 rwlock_t active_lock; /* lock for active_nodes */
57305 - atomic_t gravecounter; /* graveyard uniquifier */
57306 + atomic_unchecked_t gravecounter; /* graveyard uniquifier */
57307 unsigned frun_percent; /* when to stop culling (% files) */
57308 unsigned fcull_percent; /* when to start culling (% files) */
57309 unsigned fstop_percent; /* when to stop allocating (% files) */
57310 @@ -171,19 +171,19 @@ extern int cachefiles_check_in_use(struct cachefiles_cache *cache,
57311 * proc.c
57312 */
57313 #ifdef CONFIG_CACHEFILES_HISTOGRAM
57314 -extern atomic_t cachefiles_lookup_histogram[HZ];
57315 -extern atomic_t cachefiles_mkdir_histogram[HZ];
57316 -extern atomic_t cachefiles_create_histogram[HZ];
57317 +extern atomic_unchecked_t cachefiles_lookup_histogram[HZ];
57318 +extern atomic_unchecked_t cachefiles_mkdir_histogram[HZ];
57319 +extern atomic_unchecked_t cachefiles_create_histogram[HZ];
57320
57321 extern int __init cachefiles_proc_init(void);
57322 extern void cachefiles_proc_cleanup(void);
57323 static inline
57324 -void cachefiles_hist(atomic_t histogram[], unsigned long start_jif)
57325 +void cachefiles_hist(atomic_unchecked_t histogram[], unsigned long start_jif)
57326 {
57327 unsigned long jif = jiffies - start_jif;
57328 if (jif >= HZ)
57329 jif = HZ - 1;
57330 - atomic_inc(&histogram[jif]);
57331 + atomic_inc_unchecked(&histogram[jif]);
57332 }
57333
57334 #else
57335 diff --git a/fs/cachefiles/namei.c b/fs/cachefiles/namei.c
57336 index c0a6817..ea811166 100644
57337 --- a/fs/cachefiles/namei.c
57338 +++ b/fs/cachefiles/namei.c
57339 @@ -317,7 +317,7 @@ try_again:
57340 /* first step is to make up a grave dentry in the graveyard */
57341 sprintf(nbuffer, "%08x%08x",
57342 (uint32_t) get_seconds(),
57343 - (uint32_t) atomic_inc_return(&cache->gravecounter));
57344 + (uint32_t) atomic_inc_return_unchecked(&cache->gravecounter));
57345
57346 /* do the multiway lock magic */
57347 trap = lock_rename(cache->graveyard, dir);
57348 diff --git a/fs/cachefiles/proc.c b/fs/cachefiles/proc.c
57349 index eccd339..4c1d995 100644
57350 --- a/fs/cachefiles/proc.c
57351 +++ b/fs/cachefiles/proc.c
57352 @@ -14,9 +14,9 @@
57353 #include <linux/seq_file.h>
57354 #include "internal.h"
57355
57356 -atomic_t cachefiles_lookup_histogram[HZ];
57357 -atomic_t cachefiles_mkdir_histogram[HZ];
57358 -atomic_t cachefiles_create_histogram[HZ];
57359 +atomic_unchecked_t cachefiles_lookup_histogram[HZ];
57360 +atomic_unchecked_t cachefiles_mkdir_histogram[HZ];
57361 +atomic_unchecked_t cachefiles_create_histogram[HZ];
57362
57363 /*
57364 * display the latency histogram
57365 @@ -35,9 +35,9 @@ static int cachefiles_histogram_show(struct seq_file *m, void *v)
57366 return 0;
57367 default:
57368 index = (unsigned long) v - 3;
57369 - x = atomic_read(&cachefiles_lookup_histogram[index]);
57370 - y = atomic_read(&cachefiles_mkdir_histogram[index]);
57371 - z = atomic_read(&cachefiles_create_histogram[index]);
57372 + x = atomic_read_unchecked(&cachefiles_lookup_histogram[index]);
57373 + y = atomic_read_unchecked(&cachefiles_mkdir_histogram[index]);
57374 + z = atomic_read_unchecked(&cachefiles_create_histogram[index]);
57375 if (x == 0 && y == 0 && z == 0)
57376 return 0;
57377
57378 diff --git a/fs/cachefiles/rdwr.c b/fs/cachefiles/rdwr.c
57379 index 4b1fb5c..0d2a699 100644
57380 --- a/fs/cachefiles/rdwr.c
57381 +++ b/fs/cachefiles/rdwr.c
57382 @@ -943,7 +943,7 @@ int cachefiles_write_page(struct fscache_storage *op, struct page *page)
57383 old_fs = get_fs();
57384 set_fs(KERNEL_DS);
57385 ret = file->f_op->write(
57386 - file, (const void __user *) data, len, &pos);
57387 + file, (const void __force_user *) data, len, &pos);
57388 set_fs(old_fs);
57389 kunmap(page);
57390 file_end_write(file);
57391 diff --git a/fs/ceph/dir.c b/fs/ceph/dir.c
57392 index c29d6ae..a56c4ae 100644
57393 --- a/fs/ceph/dir.c
57394 +++ b/fs/ceph/dir.c
57395 @@ -250,7 +250,7 @@ static int ceph_readdir(struct file *file, struct dir_context *ctx)
57396 struct ceph_fs_client *fsc = ceph_inode_to_client(inode);
57397 struct ceph_mds_client *mdsc = fsc->mdsc;
57398 unsigned frag = fpos_frag(ctx->pos);
57399 - int off = fpos_off(ctx->pos);
57400 + unsigned int off = fpos_off(ctx->pos);
57401 int err;
57402 u32 ftype;
57403 struct ceph_mds_reply_info_parsed *rinfo;
57404 diff --git a/fs/ceph/super.c b/fs/ceph/super.c
57405 index 06150fd..192061b 100644
57406 --- a/fs/ceph/super.c
57407 +++ b/fs/ceph/super.c
57408 @@ -895,7 +895,7 @@ static int ceph_compare_super(struct super_block *sb, void *data)
57409 /*
57410 * construct our own bdi so we can control readahead, etc.
57411 */
57412 -static atomic_long_t bdi_seq = ATOMIC_LONG_INIT(0);
57413 +static atomic_long_unchecked_t bdi_seq = ATOMIC_LONG_INIT(0);
57414
57415 static int ceph_register_bdi(struct super_block *sb,
57416 struct ceph_fs_client *fsc)
57417 @@ -912,7 +912,7 @@ static int ceph_register_bdi(struct super_block *sb,
57418 default_backing_dev_info.ra_pages;
57419
57420 err = bdi_register(&fsc->backing_dev_info, NULL, "ceph-%ld",
57421 - atomic_long_inc_return(&bdi_seq));
57422 + atomic_long_inc_return_unchecked(&bdi_seq));
57423 if (!err)
57424 sb->s_bdi = &fsc->backing_dev_info;
57425 return err;
57426 diff --git a/fs/cifs/cifs_debug.c b/fs/cifs/cifs_debug.c
57427 index f3ac415..3d2420c 100644
57428 --- a/fs/cifs/cifs_debug.c
57429 +++ b/fs/cifs/cifs_debug.c
57430 @@ -286,8 +286,8 @@ static ssize_t cifs_stats_proc_write(struct file *file,
57431
57432 if (c == '1' || c == 'y' || c == 'Y' || c == '0') {
57433 #ifdef CONFIG_CIFS_STATS2
57434 - atomic_set(&totBufAllocCount, 0);
57435 - atomic_set(&totSmBufAllocCount, 0);
57436 + atomic_set_unchecked(&totBufAllocCount, 0);
57437 + atomic_set_unchecked(&totSmBufAllocCount, 0);
57438 #endif /* CONFIG_CIFS_STATS2 */
57439 spin_lock(&cifs_tcp_ses_lock);
57440 list_for_each(tmp1, &cifs_tcp_ses_list) {
57441 @@ -300,7 +300,7 @@ static ssize_t cifs_stats_proc_write(struct file *file,
57442 tcon = list_entry(tmp3,
57443 struct cifs_tcon,
57444 tcon_list);
57445 - atomic_set(&tcon->num_smbs_sent, 0);
57446 + atomic_set_unchecked(&tcon->num_smbs_sent, 0);
57447 if (server->ops->clear_stats)
57448 server->ops->clear_stats(tcon);
57449 }
57450 @@ -332,8 +332,8 @@ static int cifs_stats_proc_show(struct seq_file *m, void *v)
57451 smBufAllocCount.counter, cifs_min_small);
57452 #ifdef CONFIG_CIFS_STATS2
57453 seq_printf(m, "Total Large %d Small %d Allocations\n",
57454 - atomic_read(&totBufAllocCount),
57455 - atomic_read(&totSmBufAllocCount));
57456 + atomic_read_unchecked(&totBufAllocCount),
57457 + atomic_read_unchecked(&totSmBufAllocCount));
57458 #endif /* CONFIG_CIFS_STATS2 */
57459
57460 seq_printf(m, "Operations (MIDs): %d\n", atomic_read(&midCount));
57461 @@ -362,7 +362,7 @@ static int cifs_stats_proc_show(struct seq_file *m, void *v)
57462 if (tcon->need_reconnect)
57463 seq_puts(m, "\tDISCONNECTED ");
57464 seq_printf(m, "\nSMBs: %d",
57465 - atomic_read(&tcon->num_smbs_sent));
57466 + atomic_read_unchecked(&tcon->num_smbs_sent));
57467 if (server->ops->print_stats)
57468 server->ops->print_stats(m, tcon);
57469 }
57470 diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
57471 index 5be1f997..fa1015a1 100644
57472 --- a/fs/cifs/cifsfs.c
57473 +++ b/fs/cifs/cifsfs.c
57474 @@ -1068,7 +1068,7 @@ cifs_init_request_bufs(void)
57475 */
57476 cifs_req_cachep = kmem_cache_create("cifs_request",
57477 CIFSMaxBufSize + max_hdr_size, 0,
57478 - SLAB_HWCACHE_ALIGN, NULL);
57479 + SLAB_HWCACHE_ALIGN | SLAB_USERCOPY, NULL);
57480 if (cifs_req_cachep == NULL)
57481 return -ENOMEM;
57482
57483 @@ -1095,7 +1095,7 @@ cifs_init_request_bufs(void)
57484 efficient to alloc 1 per page off the slab compared to 17K (5page)
57485 alloc of large cifs buffers even when page debugging is on */
57486 cifs_sm_req_cachep = kmem_cache_create("cifs_small_rq",
57487 - MAX_CIFS_SMALL_BUFFER_SIZE, 0, SLAB_HWCACHE_ALIGN,
57488 + MAX_CIFS_SMALL_BUFFER_SIZE, 0, SLAB_HWCACHE_ALIGN | SLAB_USERCOPY,
57489 NULL);
57490 if (cifs_sm_req_cachep == NULL) {
57491 mempool_destroy(cifs_req_poolp);
57492 @@ -1180,8 +1180,8 @@ init_cifs(void)
57493 atomic_set(&bufAllocCount, 0);
57494 atomic_set(&smBufAllocCount, 0);
57495 #ifdef CONFIG_CIFS_STATS2
57496 - atomic_set(&totBufAllocCount, 0);
57497 - atomic_set(&totSmBufAllocCount, 0);
57498 + atomic_set_unchecked(&totBufAllocCount, 0);
57499 + atomic_set_unchecked(&totSmBufAllocCount, 0);
57500 #endif /* CONFIG_CIFS_STATS2 */
57501
57502 atomic_set(&midCount, 0);
57503 diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h
57504 index 30f6e92..e915ba5 100644
57505 --- a/fs/cifs/cifsglob.h
57506 +++ b/fs/cifs/cifsglob.h
57507 @@ -806,35 +806,35 @@ struct cifs_tcon {
57508 __u16 Flags; /* optional support bits */
57509 enum statusEnum tidStatus;
57510 #ifdef CONFIG_CIFS_STATS
57511 - atomic_t num_smbs_sent;
57512 + atomic_unchecked_t num_smbs_sent;
57513 union {
57514 struct {
57515 - atomic_t num_writes;
57516 - atomic_t num_reads;
57517 - atomic_t num_flushes;
57518 - atomic_t num_oplock_brks;
57519 - atomic_t num_opens;
57520 - atomic_t num_closes;
57521 - atomic_t num_deletes;
57522 - atomic_t num_mkdirs;
57523 - atomic_t num_posixopens;
57524 - atomic_t num_posixmkdirs;
57525 - atomic_t num_rmdirs;
57526 - atomic_t num_renames;
57527 - atomic_t num_t2renames;
57528 - atomic_t num_ffirst;
57529 - atomic_t num_fnext;
57530 - atomic_t num_fclose;
57531 - atomic_t num_hardlinks;
57532 - atomic_t num_symlinks;
57533 - atomic_t num_locks;
57534 - atomic_t num_acl_get;
57535 - atomic_t num_acl_set;
57536 + atomic_unchecked_t num_writes;
57537 + atomic_unchecked_t num_reads;
57538 + atomic_unchecked_t num_flushes;
57539 + atomic_unchecked_t num_oplock_brks;
57540 + atomic_unchecked_t num_opens;
57541 + atomic_unchecked_t num_closes;
57542 + atomic_unchecked_t num_deletes;
57543 + atomic_unchecked_t num_mkdirs;
57544 + atomic_unchecked_t num_posixopens;
57545 + atomic_unchecked_t num_posixmkdirs;
57546 + atomic_unchecked_t num_rmdirs;
57547 + atomic_unchecked_t num_renames;
57548 + atomic_unchecked_t num_t2renames;
57549 + atomic_unchecked_t num_ffirst;
57550 + atomic_unchecked_t num_fnext;
57551 + atomic_unchecked_t num_fclose;
57552 + atomic_unchecked_t num_hardlinks;
57553 + atomic_unchecked_t num_symlinks;
57554 + atomic_unchecked_t num_locks;
57555 + atomic_unchecked_t num_acl_get;
57556 + atomic_unchecked_t num_acl_set;
57557 } cifs_stats;
57558 #ifdef CONFIG_CIFS_SMB2
57559 struct {
57560 - atomic_t smb2_com_sent[NUMBER_OF_SMB2_COMMANDS];
57561 - atomic_t smb2_com_failed[NUMBER_OF_SMB2_COMMANDS];
57562 + atomic_unchecked_t smb2_com_sent[NUMBER_OF_SMB2_COMMANDS];
57563 + atomic_unchecked_t smb2_com_failed[NUMBER_OF_SMB2_COMMANDS];
57564 } smb2_stats;
57565 #endif /* CONFIG_CIFS_SMB2 */
57566 } stats;
57567 @@ -1170,7 +1170,7 @@ convert_delimiter(char *path, char delim)
57568 }
57569
57570 #ifdef CONFIG_CIFS_STATS
57571 -#define cifs_stats_inc atomic_inc
57572 +#define cifs_stats_inc atomic_inc_unchecked
57573
57574 static inline void cifs_stats_bytes_written(struct cifs_tcon *tcon,
57575 unsigned int bytes)
57576 @@ -1536,8 +1536,8 @@ GLOBAL_EXTERN atomic_t tconInfoReconnectCount;
57577 /* Various Debug counters */
57578 GLOBAL_EXTERN atomic_t bufAllocCount; /* current number allocated */
57579 #ifdef CONFIG_CIFS_STATS2
57580 -GLOBAL_EXTERN atomic_t totBufAllocCount; /* total allocated over all time */
57581 -GLOBAL_EXTERN atomic_t totSmBufAllocCount;
57582 +GLOBAL_EXTERN atomic_unchecked_t totBufAllocCount; /* total allocated over all time */
57583 +GLOBAL_EXTERN atomic_unchecked_t totSmBufAllocCount;
57584 #endif
57585 GLOBAL_EXTERN atomic_t smBufAllocCount;
57586 GLOBAL_EXTERN atomic_t midCount;
57587 diff --git a/fs/cifs/file.c b/fs/cifs/file.c
57588 index 5ed03e0..e9a3a6c 100644
57589 --- a/fs/cifs/file.c
57590 +++ b/fs/cifs/file.c
57591 @@ -1900,10 +1900,14 @@ static int cifs_writepages(struct address_space *mapping,
57592 index = mapping->writeback_index; /* Start from prev offset */
57593 end = -1;
57594 } else {
57595 - index = wbc->range_start >> PAGE_CACHE_SHIFT;
57596 - end = wbc->range_end >> PAGE_CACHE_SHIFT;
57597 - if (wbc->range_start == 0 && wbc->range_end == LLONG_MAX)
57598 + if (wbc->range_start == 0 && wbc->range_end == LLONG_MAX) {
57599 range_whole = true;
57600 + index = 0;
57601 + end = ULONG_MAX;
57602 + } else {
57603 + index = wbc->range_start >> PAGE_CACHE_SHIFT;
57604 + end = wbc->range_end >> PAGE_CACHE_SHIFT;
57605 + }
57606 scanned = true;
57607 }
57608 retry:
57609 diff --git a/fs/cifs/misc.c b/fs/cifs/misc.c
57610 index 3b0c62e..f7d090c 100644
57611 --- a/fs/cifs/misc.c
57612 +++ b/fs/cifs/misc.c
57613 @@ -170,7 +170,7 @@ cifs_buf_get(void)
57614 memset(ret_buf, 0, buf_size + 3);
57615 atomic_inc(&bufAllocCount);
57616 #ifdef CONFIG_CIFS_STATS2
57617 - atomic_inc(&totBufAllocCount);
57618 + atomic_inc_unchecked(&totBufAllocCount);
57619 #endif /* CONFIG_CIFS_STATS2 */
57620 }
57621
57622 @@ -205,7 +205,7 @@ cifs_small_buf_get(void)
57623 /* memset(ret_buf, 0, sizeof(struct smb_hdr) + 27);*/
57624 atomic_inc(&smBufAllocCount);
57625 #ifdef CONFIG_CIFS_STATS2
57626 - atomic_inc(&totSmBufAllocCount);
57627 + atomic_inc_unchecked(&totSmBufAllocCount);
57628 #endif /* CONFIG_CIFS_STATS2 */
57629
57630 }
57631 diff --git a/fs/cifs/smb1ops.c b/fs/cifs/smb1ops.c
57632 index d1fdfa8..94558f8 100644
57633 --- a/fs/cifs/smb1ops.c
57634 +++ b/fs/cifs/smb1ops.c
57635 @@ -626,27 +626,27 @@ static void
57636 cifs_clear_stats(struct cifs_tcon *tcon)
57637 {
57638 #ifdef CONFIG_CIFS_STATS
57639 - atomic_set(&tcon->stats.cifs_stats.num_writes, 0);
57640 - atomic_set(&tcon->stats.cifs_stats.num_reads, 0);
57641 - atomic_set(&tcon->stats.cifs_stats.num_flushes, 0);
57642 - atomic_set(&tcon->stats.cifs_stats.num_oplock_brks, 0);
57643 - atomic_set(&tcon->stats.cifs_stats.num_opens, 0);
57644 - atomic_set(&tcon->stats.cifs_stats.num_posixopens, 0);
57645 - atomic_set(&tcon->stats.cifs_stats.num_posixmkdirs, 0);
57646 - atomic_set(&tcon->stats.cifs_stats.num_closes, 0);
57647 - atomic_set(&tcon->stats.cifs_stats.num_deletes, 0);
57648 - atomic_set(&tcon->stats.cifs_stats.num_mkdirs, 0);
57649 - atomic_set(&tcon->stats.cifs_stats.num_rmdirs, 0);
57650 - atomic_set(&tcon->stats.cifs_stats.num_renames, 0);
57651 - atomic_set(&tcon->stats.cifs_stats.num_t2renames, 0);
57652 - atomic_set(&tcon->stats.cifs_stats.num_ffirst, 0);
57653 - atomic_set(&tcon->stats.cifs_stats.num_fnext, 0);
57654 - atomic_set(&tcon->stats.cifs_stats.num_fclose, 0);
57655 - atomic_set(&tcon->stats.cifs_stats.num_hardlinks, 0);
57656 - atomic_set(&tcon->stats.cifs_stats.num_symlinks, 0);
57657 - atomic_set(&tcon->stats.cifs_stats.num_locks, 0);
57658 - atomic_set(&tcon->stats.cifs_stats.num_acl_get, 0);
57659 - atomic_set(&tcon->stats.cifs_stats.num_acl_set, 0);
57660 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_writes, 0);
57661 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_reads, 0);
57662 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_flushes, 0);
57663 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_oplock_brks, 0);
57664 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_opens, 0);
57665 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_posixopens, 0);
57666 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_posixmkdirs, 0);
57667 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_closes, 0);
57668 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_deletes, 0);
57669 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_mkdirs, 0);
57670 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_rmdirs, 0);
57671 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_renames, 0);
57672 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_t2renames, 0);
57673 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_ffirst, 0);
57674 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_fnext, 0);
57675 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_fclose, 0);
57676 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_hardlinks, 0);
57677 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_symlinks, 0);
57678 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_locks, 0);
57679 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_acl_get, 0);
57680 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_acl_set, 0);
57681 #endif
57682 }
57683
57684 @@ -655,36 +655,36 @@ cifs_print_stats(struct seq_file *m, struct cifs_tcon *tcon)
57685 {
57686 #ifdef CONFIG_CIFS_STATS
57687 seq_printf(m, " Oplocks breaks: %d",
57688 - atomic_read(&tcon->stats.cifs_stats.num_oplock_brks));
57689 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_oplock_brks));
57690 seq_printf(m, "\nReads: %d Bytes: %llu",
57691 - atomic_read(&tcon->stats.cifs_stats.num_reads),
57692 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_reads),
57693 (long long)(tcon->bytes_read));
57694 seq_printf(m, "\nWrites: %d Bytes: %llu",
57695 - atomic_read(&tcon->stats.cifs_stats.num_writes),
57696 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_writes),
57697 (long long)(tcon->bytes_written));
57698 seq_printf(m, "\nFlushes: %d",
57699 - atomic_read(&tcon->stats.cifs_stats.num_flushes));
57700 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_flushes));
57701 seq_printf(m, "\nLocks: %d HardLinks: %d Symlinks: %d",
57702 - atomic_read(&tcon->stats.cifs_stats.num_locks),
57703 - atomic_read(&tcon->stats.cifs_stats.num_hardlinks),
57704 - atomic_read(&tcon->stats.cifs_stats.num_symlinks));
57705 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_locks),
57706 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_hardlinks),
57707 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_symlinks));
57708 seq_printf(m, "\nOpens: %d Closes: %d Deletes: %d",
57709 - atomic_read(&tcon->stats.cifs_stats.num_opens),
57710 - atomic_read(&tcon->stats.cifs_stats.num_closes),
57711 - atomic_read(&tcon->stats.cifs_stats.num_deletes));
57712 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_opens),
57713 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_closes),
57714 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_deletes));
57715 seq_printf(m, "\nPosix Opens: %d Posix Mkdirs: %d",
57716 - atomic_read(&tcon->stats.cifs_stats.num_posixopens),
57717 - atomic_read(&tcon->stats.cifs_stats.num_posixmkdirs));
57718 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_posixopens),
57719 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_posixmkdirs));
57720 seq_printf(m, "\nMkdirs: %d Rmdirs: %d",
57721 - atomic_read(&tcon->stats.cifs_stats.num_mkdirs),
57722 - atomic_read(&tcon->stats.cifs_stats.num_rmdirs));
57723 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_mkdirs),
57724 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_rmdirs));
57725 seq_printf(m, "\nRenames: %d T2 Renames %d",
57726 - atomic_read(&tcon->stats.cifs_stats.num_renames),
57727 - atomic_read(&tcon->stats.cifs_stats.num_t2renames));
57728 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_renames),
57729 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_t2renames));
57730 seq_printf(m, "\nFindFirst: %d FNext %d FClose %d",
57731 - atomic_read(&tcon->stats.cifs_stats.num_ffirst),
57732 - atomic_read(&tcon->stats.cifs_stats.num_fnext),
57733 - atomic_read(&tcon->stats.cifs_stats.num_fclose));
57734 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_ffirst),
57735 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_fnext),
57736 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_fclose));
57737 #endif
57738 }
57739
57740 diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c
57741 index 35ddc3e..563e809 100644
57742 --- a/fs/cifs/smb2ops.c
57743 +++ b/fs/cifs/smb2ops.c
57744 @@ -364,8 +364,8 @@ smb2_clear_stats(struct cifs_tcon *tcon)
57745 #ifdef CONFIG_CIFS_STATS
57746 int i;
57747 for (i = 0; i < NUMBER_OF_SMB2_COMMANDS; i++) {
57748 - atomic_set(&tcon->stats.smb2_stats.smb2_com_sent[i], 0);
57749 - atomic_set(&tcon->stats.smb2_stats.smb2_com_failed[i], 0);
57750 + atomic_set_unchecked(&tcon->stats.smb2_stats.smb2_com_sent[i], 0);
57751 + atomic_set_unchecked(&tcon->stats.smb2_stats.smb2_com_failed[i], 0);
57752 }
57753 #endif
57754 }
57755 @@ -405,65 +405,65 @@ static void
57756 smb2_print_stats(struct seq_file *m, struct cifs_tcon *tcon)
57757 {
57758 #ifdef CONFIG_CIFS_STATS
57759 - atomic_t *sent = tcon->stats.smb2_stats.smb2_com_sent;
57760 - atomic_t *failed = tcon->stats.smb2_stats.smb2_com_failed;
57761 + atomic_unchecked_t *sent = tcon->stats.smb2_stats.smb2_com_sent;
57762 + atomic_unchecked_t *failed = tcon->stats.smb2_stats.smb2_com_failed;
57763 seq_printf(m, "\nNegotiates: %d sent %d failed",
57764 - atomic_read(&sent[SMB2_NEGOTIATE_HE]),
57765 - atomic_read(&failed[SMB2_NEGOTIATE_HE]));
57766 + atomic_read_unchecked(&sent[SMB2_NEGOTIATE_HE]),
57767 + atomic_read_unchecked(&failed[SMB2_NEGOTIATE_HE]));
57768 seq_printf(m, "\nSessionSetups: %d sent %d failed",
57769 - atomic_read(&sent[SMB2_SESSION_SETUP_HE]),
57770 - atomic_read(&failed[SMB2_SESSION_SETUP_HE]));
57771 + atomic_read_unchecked(&sent[SMB2_SESSION_SETUP_HE]),
57772 + atomic_read_unchecked(&failed[SMB2_SESSION_SETUP_HE]));
57773 seq_printf(m, "\nLogoffs: %d sent %d failed",
57774 - atomic_read(&sent[SMB2_LOGOFF_HE]),
57775 - atomic_read(&failed[SMB2_LOGOFF_HE]));
57776 + atomic_read_unchecked(&sent[SMB2_LOGOFF_HE]),
57777 + atomic_read_unchecked(&failed[SMB2_LOGOFF_HE]));
57778 seq_printf(m, "\nTreeConnects: %d sent %d failed",
57779 - atomic_read(&sent[SMB2_TREE_CONNECT_HE]),
57780 - atomic_read(&failed[SMB2_TREE_CONNECT_HE]));
57781 + atomic_read_unchecked(&sent[SMB2_TREE_CONNECT_HE]),
57782 + atomic_read_unchecked(&failed[SMB2_TREE_CONNECT_HE]));
57783 seq_printf(m, "\nTreeDisconnects: %d sent %d failed",
57784 - atomic_read(&sent[SMB2_TREE_DISCONNECT_HE]),
57785 - atomic_read(&failed[SMB2_TREE_DISCONNECT_HE]));
57786 + atomic_read_unchecked(&sent[SMB2_TREE_DISCONNECT_HE]),
57787 + atomic_read_unchecked(&failed[SMB2_TREE_DISCONNECT_HE]));
57788 seq_printf(m, "\nCreates: %d sent %d failed",
57789 - atomic_read(&sent[SMB2_CREATE_HE]),
57790 - atomic_read(&failed[SMB2_CREATE_HE]));
57791 + atomic_read_unchecked(&sent[SMB2_CREATE_HE]),
57792 + atomic_read_unchecked(&failed[SMB2_CREATE_HE]));
57793 seq_printf(m, "\nCloses: %d sent %d failed",
57794 - atomic_read(&sent[SMB2_CLOSE_HE]),
57795 - atomic_read(&failed[SMB2_CLOSE_HE]));
57796 + atomic_read_unchecked(&sent[SMB2_CLOSE_HE]),
57797 + atomic_read_unchecked(&failed[SMB2_CLOSE_HE]));
57798 seq_printf(m, "\nFlushes: %d sent %d failed",
57799 - atomic_read(&sent[SMB2_FLUSH_HE]),
57800 - atomic_read(&failed[SMB2_FLUSH_HE]));
57801 + atomic_read_unchecked(&sent[SMB2_FLUSH_HE]),
57802 + atomic_read_unchecked(&failed[SMB2_FLUSH_HE]));
57803 seq_printf(m, "\nReads: %d sent %d failed",
57804 - atomic_read(&sent[SMB2_READ_HE]),
57805 - atomic_read(&failed[SMB2_READ_HE]));
57806 + atomic_read_unchecked(&sent[SMB2_READ_HE]),
57807 + atomic_read_unchecked(&failed[SMB2_READ_HE]));
57808 seq_printf(m, "\nWrites: %d sent %d failed",
57809 - atomic_read(&sent[SMB2_WRITE_HE]),
57810 - atomic_read(&failed[SMB2_WRITE_HE]));
57811 + atomic_read_unchecked(&sent[SMB2_WRITE_HE]),
57812 + atomic_read_unchecked(&failed[SMB2_WRITE_HE]));
57813 seq_printf(m, "\nLocks: %d sent %d failed",
57814 - atomic_read(&sent[SMB2_LOCK_HE]),
57815 - atomic_read(&failed[SMB2_LOCK_HE]));
57816 + atomic_read_unchecked(&sent[SMB2_LOCK_HE]),
57817 + atomic_read_unchecked(&failed[SMB2_LOCK_HE]));
57818 seq_printf(m, "\nIOCTLs: %d sent %d failed",
57819 - atomic_read(&sent[SMB2_IOCTL_HE]),
57820 - atomic_read(&failed[SMB2_IOCTL_HE]));
57821 + atomic_read_unchecked(&sent[SMB2_IOCTL_HE]),
57822 + atomic_read_unchecked(&failed[SMB2_IOCTL_HE]));
57823 seq_printf(m, "\nCancels: %d sent %d failed",
57824 - atomic_read(&sent[SMB2_CANCEL_HE]),
57825 - atomic_read(&failed[SMB2_CANCEL_HE]));
57826 + atomic_read_unchecked(&sent[SMB2_CANCEL_HE]),
57827 + atomic_read_unchecked(&failed[SMB2_CANCEL_HE]));
57828 seq_printf(m, "\nEchos: %d sent %d failed",
57829 - atomic_read(&sent[SMB2_ECHO_HE]),
57830 - atomic_read(&failed[SMB2_ECHO_HE]));
57831 + atomic_read_unchecked(&sent[SMB2_ECHO_HE]),
57832 + atomic_read_unchecked(&failed[SMB2_ECHO_HE]));
57833 seq_printf(m, "\nQueryDirectories: %d sent %d failed",
57834 - atomic_read(&sent[SMB2_QUERY_DIRECTORY_HE]),
57835 - atomic_read(&failed[SMB2_QUERY_DIRECTORY_HE]));
57836 + atomic_read_unchecked(&sent[SMB2_QUERY_DIRECTORY_HE]),
57837 + atomic_read_unchecked(&failed[SMB2_QUERY_DIRECTORY_HE]));
57838 seq_printf(m, "\nChangeNotifies: %d sent %d failed",
57839 - atomic_read(&sent[SMB2_CHANGE_NOTIFY_HE]),
57840 - atomic_read(&failed[SMB2_CHANGE_NOTIFY_HE]));
57841 + atomic_read_unchecked(&sent[SMB2_CHANGE_NOTIFY_HE]),
57842 + atomic_read_unchecked(&failed[SMB2_CHANGE_NOTIFY_HE]));
57843 seq_printf(m, "\nQueryInfos: %d sent %d failed",
57844 - atomic_read(&sent[SMB2_QUERY_INFO_HE]),
57845 - atomic_read(&failed[SMB2_QUERY_INFO_HE]));
57846 + atomic_read_unchecked(&sent[SMB2_QUERY_INFO_HE]),
57847 + atomic_read_unchecked(&failed[SMB2_QUERY_INFO_HE]));
57848 seq_printf(m, "\nSetInfos: %d sent %d failed",
57849 - atomic_read(&sent[SMB2_SET_INFO_HE]),
57850 - atomic_read(&failed[SMB2_SET_INFO_HE]));
57851 + atomic_read_unchecked(&sent[SMB2_SET_INFO_HE]),
57852 + atomic_read_unchecked(&failed[SMB2_SET_INFO_HE]));
57853 seq_printf(m, "\nOplockBreaks: %d sent %d failed",
57854 - atomic_read(&sent[SMB2_OPLOCK_BREAK_HE]),
57855 - atomic_read(&failed[SMB2_OPLOCK_BREAK_HE]));
57856 + atomic_read_unchecked(&sent[SMB2_OPLOCK_BREAK_HE]),
57857 + atomic_read_unchecked(&failed[SMB2_OPLOCK_BREAK_HE]));
57858 #endif
57859 }
57860
57861 diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c
57862 index 3802f8c..3a98488 100644
57863 --- a/fs/cifs/smb2pdu.c
57864 +++ b/fs/cifs/smb2pdu.c
57865 @@ -2092,8 +2092,7 @@ SMB2_query_directory(const unsigned int xid, struct cifs_tcon *tcon,
57866 default:
57867 cifs_dbg(VFS, "info level %u isn't supported\n",
57868 srch_inf->info_level);
57869 - rc = -EINVAL;
57870 - goto qdir_exit;
57871 + return -EINVAL;
57872 }
57873
57874 req->FileIndex = cpu_to_le32(index);
57875 diff --git a/fs/coda/cache.c b/fs/coda/cache.c
57876 index 1da168c..8bc7ff6 100644
57877 --- a/fs/coda/cache.c
57878 +++ b/fs/coda/cache.c
57879 @@ -24,7 +24,7 @@
57880 #include "coda_linux.h"
57881 #include "coda_cache.h"
57882
57883 -static atomic_t permission_epoch = ATOMIC_INIT(0);
57884 +static atomic_unchecked_t permission_epoch = ATOMIC_INIT(0);
57885
57886 /* replace or extend an acl cache hit */
57887 void coda_cache_enter(struct inode *inode, int mask)
57888 @@ -32,7 +32,7 @@ void coda_cache_enter(struct inode *inode, int mask)
57889 struct coda_inode_info *cii = ITOC(inode);
57890
57891 spin_lock(&cii->c_lock);
57892 - cii->c_cached_epoch = atomic_read(&permission_epoch);
57893 + cii->c_cached_epoch = atomic_read_unchecked(&permission_epoch);
57894 if (!uid_eq(cii->c_uid, current_fsuid())) {
57895 cii->c_uid = current_fsuid();
57896 cii->c_cached_perm = mask;
57897 @@ -46,14 +46,14 @@ void coda_cache_clear_inode(struct inode *inode)
57898 {
57899 struct coda_inode_info *cii = ITOC(inode);
57900 spin_lock(&cii->c_lock);
57901 - cii->c_cached_epoch = atomic_read(&permission_epoch) - 1;
57902 + cii->c_cached_epoch = atomic_read_unchecked(&permission_epoch) - 1;
57903 spin_unlock(&cii->c_lock);
57904 }
57905
57906 /* remove all acl caches */
57907 void coda_cache_clear_all(struct super_block *sb)
57908 {
57909 - atomic_inc(&permission_epoch);
57910 + atomic_inc_unchecked(&permission_epoch);
57911 }
57912
57913
57914 @@ -66,7 +66,7 @@ int coda_cache_check(struct inode *inode, int mask)
57915 spin_lock(&cii->c_lock);
57916 hit = (mask & cii->c_cached_perm) == mask &&
57917 uid_eq(cii->c_uid, current_fsuid()) &&
57918 - cii->c_cached_epoch == atomic_read(&permission_epoch);
57919 + cii->c_cached_epoch == atomic_read_unchecked(&permission_epoch);
57920 spin_unlock(&cii->c_lock);
57921
57922 return hit;
57923 diff --git a/fs/compat.c b/fs/compat.c
57924 index 66d3d3c..9c10175 100644
57925 --- a/fs/compat.c
57926 +++ b/fs/compat.c
57927 @@ -54,7 +54,7 @@
57928 #include <asm/ioctls.h>
57929 #include "internal.h"
57930
57931 -int compat_log = 1;
57932 +int compat_log = 0;
57933
57934 int compat_printk(const char *fmt, ...)
57935 {
57936 @@ -512,7 +512,7 @@ COMPAT_SYSCALL_DEFINE2(io_setup, unsigned, nr_reqs, u32 __user *, ctx32p)
57937
57938 set_fs(KERNEL_DS);
57939 /* The __user pointer cast is valid because of the set_fs() */
57940 - ret = sys_io_setup(nr_reqs, (aio_context_t __user *) &ctx64);
57941 + ret = sys_io_setup(nr_reqs, (aio_context_t __force_user *) &ctx64);
57942 set_fs(oldfs);
57943 /* truncating is ok because it's a user address */
57944 if (!ret)
57945 @@ -562,7 +562,7 @@ ssize_t compat_rw_copy_check_uvector(int type,
57946 goto out;
57947
57948 ret = -EINVAL;
57949 - if (nr_segs > UIO_MAXIOV || nr_segs < 0)
57950 + if (nr_segs > UIO_MAXIOV)
57951 goto out;
57952 if (nr_segs > fast_segs) {
57953 ret = -ENOMEM;
57954 @@ -850,6 +850,7 @@ struct compat_old_linux_dirent {
57955 struct compat_readdir_callback {
57956 struct dir_context ctx;
57957 struct compat_old_linux_dirent __user *dirent;
57958 + struct file * file;
57959 int result;
57960 };
57961
57962 @@ -867,6 +868,10 @@ static int compat_fillonedir(void *__buf, const char *name, int namlen,
57963 buf->result = -EOVERFLOW;
57964 return -EOVERFLOW;
57965 }
57966 +
57967 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
57968 + return 0;
57969 +
57970 buf->result++;
57971 dirent = buf->dirent;
57972 if (!access_ok(VERIFY_WRITE, dirent,
57973 @@ -898,6 +903,7 @@ COMPAT_SYSCALL_DEFINE3(old_readdir, unsigned int, fd,
57974 if (!f.file)
57975 return -EBADF;
57976
57977 + buf.file = f.file;
57978 error = iterate_dir(f.file, &buf.ctx);
57979 if (buf.result)
57980 error = buf.result;
57981 @@ -917,6 +923,7 @@ struct compat_getdents_callback {
57982 struct dir_context ctx;
57983 struct compat_linux_dirent __user *current_dir;
57984 struct compat_linux_dirent __user *previous;
57985 + struct file * file;
57986 int count;
57987 int error;
57988 };
57989 @@ -938,6 +945,10 @@ static int compat_filldir(void *__buf, const char *name, int namlen,
57990 buf->error = -EOVERFLOW;
57991 return -EOVERFLOW;
57992 }
57993 +
57994 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
57995 + return 0;
57996 +
57997 dirent = buf->previous;
57998 if (dirent) {
57999 if (__put_user(offset, &dirent->d_off))
58000 @@ -983,6 +994,7 @@ COMPAT_SYSCALL_DEFINE3(getdents, unsigned int, fd,
58001 if (!f.file)
58002 return -EBADF;
58003
58004 + buf.file = f.file;
58005 error = iterate_dir(f.file, &buf.ctx);
58006 if (error >= 0)
58007 error = buf.error;
58008 @@ -1003,6 +1015,7 @@ struct compat_getdents_callback64 {
58009 struct dir_context ctx;
58010 struct linux_dirent64 __user *current_dir;
58011 struct linux_dirent64 __user *previous;
58012 + struct file * file;
58013 int count;
58014 int error;
58015 };
58016 @@ -1019,6 +1032,10 @@ static int compat_filldir64(void * __buf, const char * name, int namlen, loff_t
58017 buf->error = -EINVAL; /* only used if we fail.. */
58018 if (reclen > buf->count)
58019 return -EINVAL;
58020 +
58021 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
58022 + return 0;
58023 +
58024 dirent = buf->previous;
58025
58026 if (dirent) {
58027 @@ -1068,6 +1085,7 @@ COMPAT_SYSCALL_DEFINE3(getdents64, unsigned int, fd,
58028 if (!f.file)
58029 return -EBADF;
58030
58031 + buf.file = f.file;
58032 error = iterate_dir(f.file, &buf.ctx);
58033 if (error >= 0)
58034 error = buf.error;
58035 diff --git a/fs/compat_binfmt_elf.c b/fs/compat_binfmt_elf.c
58036 index 4d24d17..4f8c09e 100644
58037 --- a/fs/compat_binfmt_elf.c
58038 +++ b/fs/compat_binfmt_elf.c
58039 @@ -30,11 +30,13 @@
58040 #undef elf_phdr
58041 #undef elf_shdr
58042 #undef elf_note
58043 +#undef elf_dyn
58044 #undef elf_addr_t
58045 #define elfhdr elf32_hdr
58046 #define elf_phdr elf32_phdr
58047 #define elf_shdr elf32_shdr
58048 #define elf_note elf32_note
58049 +#define elf_dyn Elf32_Dyn
58050 #define elf_addr_t Elf32_Addr
58051
58052 /*
58053 diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c
58054 index e822890..59374d5 100644
58055 --- a/fs/compat_ioctl.c
58056 +++ b/fs/compat_ioctl.c
58057 @@ -621,7 +621,7 @@ static int serial_struct_ioctl(unsigned fd, unsigned cmd,
58058 return -EFAULT;
58059 if (__get_user(udata, &ss32->iomem_base))
58060 return -EFAULT;
58061 - ss.iomem_base = compat_ptr(udata);
58062 + ss.iomem_base = (unsigned char __force_kernel *)compat_ptr(udata);
58063 if (__get_user(ss.iomem_reg_shift, &ss32->iomem_reg_shift) ||
58064 __get_user(ss.port_high, &ss32->port_high))
58065 return -EFAULT;
58066 @@ -703,8 +703,8 @@ static int do_i2c_rdwr_ioctl(unsigned int fd, unsigned int cmd,
58067 for (i = 0; i < nmsgs; i++) {
58068 if (copy_in_user(&tmsgs[i].addr, &umsgs[i].addr, 3*sizeof(u16)))
58069 return -EFAULT;
58070 - if (get_user(datap, &umsgs[i].buf) ||
58071 - put_user(compat_ptr(datap), &tmsgs[i].buf))
58072 + if (get_user(datap, (u8 __user * __user *)&umsgs[i].buf) ||
58073 + put_user(compat_ptr(datap), (u8 __user * __user *)&tmsgs[i].buf))
58074 return -EFAULT;
58075 }
58076 return sys_ioctl(fd, cmd, (unsigned long)tdata);
58077 @@ -797,7 +797,7 @@ static int compat_ioctl_preallocate(struct file *file,
58078 copy_in_user(&p->l_len, &p32->l_len, sizeof(s64)) ||
58079 copy_in_user(&p->l_sysid, &p32->l_sysid, sizeof(s32)) ||
58080 copy_in_user(&p->l_pid, &p32->l_pid, sizeof(u32)) ||
58081 - copy_in_user(&p->l_pad, &p32->l_pad, 4*sizeof(u32)))
58082 + copy_in_user(p->l_pad, p32->l_pad, 4*sizeof(u32)))
58083 return -EFAULT;
58084
58085 return ioctl_preallocate(file, p);
58086 @@ -1618,8 +1618,8 @@ COMPAT_SYSCALL_DEFINE3(ioctl, unsigned int, fd, unsigned int, cmd,
58087 static int __init init_sys32_ioctl_cmp(const void *p, const void *q)
58088 {
58089 unsigned int a, b;
58090 - a = *(unsigned int *)p;
58091 - b = *(unsigned int *)q;
58092 + a = *(const unsigned int *)p;
58093 + b = *(const unsigned int *)q;
58094 if (a > b)
58095 return 1;
58096 if (a < b)
58097 diff --git a/fs/configfs/dir.c b/fs/configfs/dir.c
58098 index e081acb..911df21 100644
58099 --- a/fs/configfs/dir.c
58100 +++ b/fs/configfs/dir.c
58101 @@ -1548,7 +1548,8 @@ static int configfs_readdir(struct file *file, struct dir_context *ctx)
58102 }
58103 for (p = q->next; p != &parent_sd->s_children; p = p->next) {
58104 struct configfs_dirent *next;
58105 - const char *name;
58106 + const unsigned char * name;
58107 + char d_name[sizeof(next->s_dentry->d_iname)];
58108 int len;
58109 struct inode *inode = NULL;
58110
58111 @@ -1557,7 +1558,12 @@ static int configfs_readdir(struct file *file, struct dir_context *ctx)
58112 continue;
58113
58114 name = configfs_get_name(next);
58115 - len = strlen(name);
58116 + if (next->s_dentry && name == next->s_dentry->d_iname) {
58117 + len = next->s_dentry->d_name.len;
58118 + memcpy(d_name, name, len);
58119 + name = d_name;
58120 + } else
58121 + len = strlen(name);
58122
58123 /*
58124 * We'll have a dentry and an inode for
58125 diff --git a/fs/coredump.c b/fs/coredump.c
58126 index 0b2528f..836c55f 100644
58127 --- a/fs/coredump.c
58128 +++ b/fs/coredump.c
58129 @@ -442,8 +442,8 @@ static void wait_for_dump_helpers(struct file *file)
58130 struct pipe_inode_info *pipe = file->private_data;
58131
58132 pipe_lock(pipe);
58133 - pipe->readers++;
58134 - pipe->writers--;
58135 + atomic_inc(&pipe->readers);
58136 + atomic_dec(&pipe->writers);
58137 wake_up_interruptible_sync(&pipe->wait);
58138 kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
58139 pipe_unlock(pipe);
58140 @@ -452,11 +452,11 @@ static void wait_for_dump_helpers(struct file *file)
58141 * We actually want wait_event_freezable() but then we need
58142 * to clear TIF_SIGPENDING and improve dump_interrupted().
58143 */
58144 - wait_event_interruptible(pipe->wait, pipe->readers == 1);
58145 + wait_event_interruptible(pipe->wait, atomic_read(&pipe->readers) == 1);
58146
58147 pipe_lock(pipe);
58148 - pipe->readers--;
58149 - pipe->writers++;
58150 + atomic_dec(&pipe->readers);
58151 + atomic_inc(&pipe->writers);
58152 pipe_unlock(pipe);
58153 }
58154
58155 @@ -503,7 +503,9 @@ void do_coredump(const siginfo_t *siginfo)
58156 struct files_struct *displaced;
58157 bool need_nonrelative = false;
58158 bool core_dumped = false;
58159 - static atomic_t core_dump_count = ATOMIC_INIT(0);
58160 + static atomic_unchecked_t core_dump_count = ATOMIC_INIT(0);
58161 + long signr = siginfo->si_signo;
58162 + int dumpable;
58163 struct coredump_params cprm = {
58164 .siginfo = siginfo,
58165 .regs = signal_pt_regs(),
58166 @@ -516,12 +518,17 @@ void do_coredump(const siginfo_t *siginfo)
58167 .mm_flags = mm->flags,
58168 };
58169
58170 - audit_core_dumps(siginfo->si_signo);
58171 + audit_core_dumps(signr);
58172 +
58173 + dumpable = __get_dumpable(cprm.mm_flags);
58174 +
58175 + if (signr == SIGSEGV || signr == SIGBUS || signr == SIGKILL || signr == SIGILL)
58176 + gr_handle_brute_attach(dumpable);
58177
58178 binfmt = mm->binfmt;
58179 if (!binfmt || !binfmt->core_dump)
58180 goto fail;
58181 - if (!__get_dumpable(cprm.mm_flags))
58182 + if (!dumpable)
58183 goto fail;
58184
58185 cred = prepare_creds();
58186 @@ -540,7 +547,7 @@ void do_coredump(const siginfo_t *siginfo)
58187 need_nonrelative = true;
58188 }
58189
58190 - retval = coredump_wait(siginfo->si_signo, &core_state);
58191 + retval = coredump_wait(signr, &core_state);
58192 if (retval < 0)
58193 goto fail_creds;
58194
58195 @@ -583,7 +590,7 @@ void do_coredump(const siginfo_t *siginfo)
58196 }
58197 cprm.limit = RLIM_INFINITY;
58198
58199 - dump_count = atomic_inc_return(&core_dump_count);
58200 + dump_count = atomic_inc_return_unchecked(&core_dump_count);
58201 if (core_pipe_limit && (core_pipe_limit < dump_count)) {
58202 printk(KERN_WARNING "Pid %d(%s) over core_pipe_limit\n",
58203 task_tgid_vnr(current), current->comm);
58204 @@ -615,6 +622,8 @@ void do_coredump(const siginfo_t *siginfo)
58205 } else {
58206 struct inode *inode;
58207
58208 + gr_learn_resource(current, RLIMIT_CORE, binfmt->min_coredump, 1);
58209 +
58210 if (cprm.limit < binfmt->min_coredump)
58211 goto fail_unlock;
58212
58213 @@ -673,7 +682,7 @@ close_fail:
58214 filp_close(cprm.file, NULL);
58215 fail_dropcount:
58216 if (ispipe)
58217 - atomic_dec(&core_dump_count);
58218 + atomic_dec_unchecked(&core_dump_count);
58219 fail_unlock:
58220 kfree(cn.corename);
58221 coredump_finish(mm, core_dumped);
58222 @@ -694,6 +703,8 @@ int dump_emit(struct coredump_params *cprm, const void *addr, int nr)
58223 struct file *file = cprm->file;
58224 loff_t pos = file->f_pos;
58225 ssize_t n;
58226 +
58227 + gr_learn_resource(current, RLIMIT_CORE, cprm->written + nr, 1);
58228 if (cprm->written + nr > cprm->limit)
58229 return 0;
58230 while (nr) {
58231 diff --git a/fs/dcache.c b/fs/dcache.c
58232 index e99c6f5..2838bf58 100644
58233 --- a/fs/dcache.c
58234 +++ b/fs/dcache.c
58235 @@ -1445,7 +1445,7 @@ struct dentry *__d_alloc(struct super_block *sb, const struct qstr *name)
58236 */
58237 dentry->d_iname[DNAME_INLINE_LEN-1] = 0;
58238 if (name->len > DNAME_INLINE_LEN-1) {
58239 - dname = kmalloc(name->len + 1, GFP_KERNEL);
58240 + dname = kmalloc(round_up(name->len + 1, sizeof(unsigned long)), GFP_KERNEL);
58241 if (!dname) {
58242 kmem_cache_free(dentry_cache, dentry);
58243 return NULL;
58244 @@ -3413,7 +3413,8 @@ void __init vfs_caches_init(unsigned long mempages)
58245 mempages -= reserve;
58246
58247 names_cachep = kmem_cache_create("names_cache", PATH_MAX, 0,
58248 - SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
58249 + SLAB_HWCACHE_ALIGN|SLAB_PANIC|SLAB_USERCOPY|
58250 + SLAB_NO_SANITIZE, NULL);
58251
58252 dcache_init();
58253 inode_init();
58254 diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c
58255 index 8c41b52..145b1b9 100644
58256 --- a/fs/debugfs/inode.c
58257 +++ b/fs/debugfs/inode.c
58258 @@ -416,7 +416,11 @@ EXPORT_SYMBOL_GPL(debugfs_create_file);
58259 */
58260 struct dentry *debugfs_create_dir(const char *name, struct dentry *parent)
58261 {
58262 +#ifdef CONFIG_GRKERNSEC_SYSFS_RESTRICT
58263 + return __create_file(name, S_IFDIR | S_IRWXU,
58264 +#else
58265 return __create_file(name, S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO,
58266 +#endif
58267 parent, NULL, NULL);
58268 }
58269 EXPORT_SYMBOL_GPL(debugfs_create_dir);
58270 diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c
58271 index d4a9431..77f9b2e 100644
58272 --- a/fs/ecryptfs/inode.c
58273 +++ b/fs/ecryptfs/inode.c
58274 @@ -673,7 +673,7 @@ static char *ecryptfs_readlink_lower(struct dentry *dentry, size_t *bufsiz)
58275 old_fs = get_fs();
58276 set_fs(get_ds());
58277 rc = lower_dentry->d_inode->i_op->readlink(lower_dentry,
58278 - (char __user *)lower_buf,
58279 + (char __force_user *)lower_buf,
58280 PATH_MAX);
58281 set_fs(old_fs);
58282 if (rc < 0)
58283 diff --git a/fs/ecryptfs/miscdev.c b/fs/ecryptfs/miscdev.c
58284 index e4141f2..d8263e8 100644
58285 --- a/fs/ecryptfs/miscdev.c
58286 +++ b/fs/ecryptfs/miscdev.c
58287 @@ -304,7 +304,7 @@ check_list:
58288 goto out_unlock_msg_ctx;
58289 i = PKT_TYPE_SIZE + PKT_CTR_SIZE;
58290 if (msg_ctx->msg) {
58291 - if (copy_to_user(&buf[i], packet_length, packet_length_size))
58292 + if (packet_length_size > sizeof(packet_length) || copy_to_user(&buf[i], packet_length, packet_length_size))
58293 goto out_unlock_msg_ctx;
58294 i += packet_length_size;
58295 if (copy_to_user(&buf[i], msg_ctx->msg, msg_ctx->msg_size))
58296 diff --git a/fs/exec.c b/fs/exec.c
58297 index 238b7aa..a421d91 100644
58298 --- a/fs/exec.c
58299 +++ b/fs/exec.c
58300 @@ -56,8 +56,20 @@
58301 #include <linux/pipe_fs_i.h>
58302 #include <linux/oom.h>
58303 #include <linux/compat.h>
58304 +#include <linux/random.h>
58305 +#include <linux/seq_file.h>
58306 +#include <linux/coredump.h>
58307 +#include <linux/mman.h>
58308 +
58309 +#ifdef CONFIG_PAX_REFCOUNT
58310 +#include <linux/kallsyms.h>
58311 +#include <linux/kdebug.h>
58312 +#endif
58313 +
58314 +#include <trace/events/fs.h>
58315
58316 #include <asm/uaccess.h>
58317 +#include <asm/sections.h>
58318 #include <asm/mmu_context.h>
58319 #include <asm/tlb.h>
58320
58321 @@ -66,19 +78,34 @@
58322
58323 #include <trace/events/sched.h>
58324
58325 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
58326 +void __weak pax_set_initial_flags(struct linux_binprm *bprm)
58327 +{
58328 + 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");
58329 +}
58330 +#endif
58331 +
58332 +#ifdef CONFIG_PAX_HOOK_ACL_FLAGS
58333 +void (*pax_set_initial_flags_func)(struct linux_binprm *bprm);
58334 +EXPORT_SYMBOL(pax_set_initial_flags_func);
58335 +#endif
58336 +
58337 int suid_dumpable = 0;
58338
58339 static LIST_HEAD(formats);
58340 static DEFINE_RWLOCK(binfmt_lock);
58341
58342 +extern int gr_process_kernel_exec_ban(void);
58343 +extern int gr_process_suid_exec_ban(const struct linux_binprm *bprm);
58344 +
58345 void __register_binfmt(struct linux_binfmt * fmt, int insert)
58346 {
58347 BUG_ON(!fmt);
58348 if (WARN_ON(!fmt->load_binary))
58349 return;
58350 write_lock(&binfmt_lock);
58351 - insert ? list_add(&fmt->lh, &formats) :
58352 - list_add_tail(&fmt->lh, &formats);
58353 + insert ? pax_list_add((struct list_head *)&fmt->lh, &formats) :
58354 + pax_list_add_tail((struct list_head *)&fmt->lh, &formats);
58355 write_unlock(&binfmt_lock);
58356 }
58357
58358 @@ -87,7 +114,7 @@ EXPORT_SYMBOL(__register_binfmt);
58359 void unregister_binfmt(struct linux_binfmt * fmt)
58360 {
58361 write_lock(&binfmt_lock);
58362 - list_del(&fmt->lh);
58363 + pax_list_del((struct list_head *)&fmt->lh);
58364 write_unlock(&binfmt_lock);
58365 }
58366
58367 @@ -183,18 +210,10 @@ static struct page *get_arg_page(struct linux_binprm *bprm, unsigned long pos,
58368 int write)
58369 {
58370 struct page *page;
58371 - int ret;
58372
58373 -#ifdef CONFIG_STACK_GROWSUP
58374 - if (write) {
58375 - ret = expand_downwards(bprm->vma, pos);
58376 - if (ret < 0)
58377 - return NULL;
58378 - }
58379 -#endif
58380 - ret = get_user_pages(current, bprm->mm, pos,
58381 - 1, write, 1, &page, NULL);
58382 - if (ret <= 0)
58383 + if (0 > expand_downwards(bprm->vma, pos))
58384 + return NULL;
58385 + if (0 >= get_user_pages(current, bprm->mm, pos, 1, write, 1, &page, NULL))
58386 return NULL;
58387
58388 if (write) {
58389 @@ -210,6 +229,17 @@ static struct page *get_arg_page(struct linux_binprm *bprm, unsigned long pos,
58390 if (size <= ARG_MAX)
58391 return page;
58392
58393 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
58394 + // only allow 512KB for argv+env on suid/sgid binaries
58395 + // to prevent easy ASLR exhaustion
58396 + if (((!uid_eq(bprm->cred->euid, current_euid())) ||
58397 + (!gid_eq(bprm->cred->egid, current_egid()))) &&
58398 + (size > (512 * 1024))) {
58399 + put_page(page);
58400 + return NULL;
58401 + }
58402 +#endif
58403 +
58404 /*
58405 * Limit to 1/4-th the stack size for the argv+env strings.
58406 * This ensures that:
58407 @@ -269,6 +299,11 @@ static int __bprm_mm_init(struct linux_binprm *bprm)
58408 vma->vm_end = STACK_TOP_MAX;
58409 vma->vm_start = vma->vm_end - PAGE_SIZE;
58410 vma->vm_flags = VM_SOFTDIRTY | VM_STACK_FLAGS | VM_STACK_INCOMPLETE_SETUP;
58411 +
58412 +#ifdef CONFIG_PAX_SEGMEXEC
58413 + vma->vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
58414 +#endif
58415 +
58416 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
58417 INIT_LIST_HEAD(&vma->anon_vma_chain);
58418
58419 @@ -279,6 +314,12 @@ static int __bprm_mm_init(struct linux_binprm *bprm)
58420 mm->stack_vm = mm->total_vm = 1;
58421 up_write(&mm->mmap_sem);
58422 bprm->p = vma->vm_end - sizeof(void *);
58423 +
58424 +#ifdef CONFIG_PAX_RANDUSTACK
58425 + if (randomize_va_space)
58426 + bprm->p ^= prandom_u32() & ~PAGE_MASK;
58427 +#endif
58428 +
58429 return 0;
58430 err:
58431 up_write(&mm->mmap_sem);
58432 @@ -399,7 +440,7 @@ struct user_arg_ptr {
58433 } ptr;
58434 };
58435
58436 -static const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
58437 +const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
58438 {
58439 const char __user *native;
58440
58441 @@ -408,14 +449,14 @@ static const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
58442 compat_uptr_t compat;
58443
58444 if (get_user(compat, argv.ptr.compat + nr))
58445 - return ERR_PTR(-EFAULT);
58446 + return (const char __force_user *)ERR_PTR(-EFAULT);
58447
58448 return compat_ptr(compat);
58449 }
58450 #endif
58451
58452 if (get_user(native, argv.ptr.native + nr))
58453 - return ERR_PTR(-EFAULT);
58454 + return (const char __force_user *)ERR_PTR(-EFAULT);
58455
58456 return native;
58457 }
58458 @@ -434,7 +475,7 @@ static int count(struct user_arg_ptr argv, int max)
58459 if (!p)
58460 break;
58461
58462 - if (IS_ERR(p))
58463 + if (IS_ERR((const char __force_kernel *)p))
58464 return -EFAULT;
58465
58466 if (i >= max)
58467 @@ -469,7 +510,7 @@ static int copy_strings(int argc, struct user_arg_ptr argv,
58468
58469 ret = -EFAULT;
58470 str = get_user_arg_ptr(argv, argc);
58471 - if (IS_ERR(str))
58472 + if (IS_ERR((const char __force_kernel *)str))
58473 goto out;
58474
58475 len = strnlen_user(str, MAX_ARG_STRLEN);
58476 @@ -551,7 +592,7 @@ int copy_strings_kernel(int argc, const char *const *__argv,
58477 int r;
58478 mm_segment_t oldfs = get_fs();
58479 struct user_arg_ptr argv = {
58480 - .ptr.native = (const char __user *const __user *)__argv,
58481 + .ptr.native = (const char __user * const __force_user *)__argv,
58482 };
58483
58484 set_fs(KERNEL_DS);
58485 @@ -586,7 +627,8 @@ static int shift_arg_pages(struct vm_area_struct *vma, unsigned long shift)
58486 unsigned long new_end = old_end - shift;
58487 struct mmu_gather tlb;
58488
58489 - BUG_ON(new_start > new_end);
58490 + if (new_start >= new_end || new_start < mmap_min_addr)
58491 + return -ENOMEM;
58492
58493 /*
58494 * ensure there are no vmas between where we want to go
58495 @@ -595,6 +637,10 @@ static int shift_arg_pages(struct vm_area_struct *vma, unsigned long shift)
58496 if (vma != find_vma(mm, new_start))
58497 return -EFAULT;
58498
58499 +#ifdef CONFIG_PAX_SEGMEXEC
58500 + BUG_ON(pax_find_mirror_vma(vma));
58501 +#endif
58502 +
58503 /*
58504 * cover the whole range: [new_start, old_end)
58505 */
58506 @@ -675,10 +721,6 @@ int setup_arg_pages(struct linux_binprm *bprm,
58507 stack_top = arch_align_stack(stack_top);
58508 stack_top = PAGE_ALIGN(stack_top);
58509
58510 - if (unlikely(stack_top < mmap_min_addr) ||
58511 - unlikely(vma->vm_end - vma->vm_start >= stack_top - mmap_min_addr))
58512 - return -ENOMEM;
58513 -
58514 stack_shift = vma->vm_end - stack_top;
58515
58516 bprm->p -= stack_shift;
58517 @@ -690,8 +732,28 @@ int setup_arg_pages(struct linux_binprm *bprm,
58518 bprm->exec -= stack_shift;
58519
58520 down_write(&mm->mmap_sem);
58521 +
58522 + /* Move stack pages down in memory. */
58523 + if (stack_shift) {
58524 + ret = shift_arg_pages(vma, stack_shift);
58525 + if (ret)
58526 + goto out_unlock;
58527 + }
58528 +
58529 vm_flags = VM_STACK_FLAGS;
58530
58531 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
58532 + if (mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
58533 + vm_flags &= ~VM_EXEC;
58534 +
58535 +#ifdef CONFIG_PAX_MPROTECT
58536 + if (mm->pax_flags & MF_PAX_MPROTECT)
58537 + vm_flags &= ~VM_MAYEXEC;
58538 +#endif
58539 +
58540 + }
58541 +#endif
58542 +
58543 /*
58544 * Adjust stack execute permissions; explicitly enable for
58545 * EXSTACK_ENABLE_X, disable for EXSTACK_DISABLE_X and leave alone
58546 @@ -710,13 +772,6 @@ int setup_arg_pages(struct linux_binprm *bprm,
58547 goto out_unlock;
58548 BUG_ON(prev != vma);
58549
58550 - /* Move stack pages down in memory. */
58551 - if (stack_shift) {
58552 - ret = shift_arg_pages(vma, stack_shift);
58553 - if (ret)
58554 - goto out_unlock;
58555 - }
58556 -
58557 /* mprotect_fixup is overkill to remove the temporary stack flags */
58558 vma->vm_flags &= ~VM_STACK_INCOMPLETE_SETUP;
58559
58560 @@ -740,6 +795,27 @@ int setup_arg_pages(struct linux_binprm *bprm,
58561 #endif
58562 current->mm->start_stack = bprm->p;
58563 ret = expand_stack(vma, stack_base);
58564 +
58565 +#if !defined(CONFIG_STACK_GROWSUP) && defined(CONFIG_PAX_RANDMMAP)
58566 + if (!ret && (mm->pax_flags & MF_PAX_RANDMMAP) && STACK_TOP <= 0xFFFFFFFFU && STACK_TOP > vma->vm_end) {
58567 + unsigned long size;
58568 + vm_flags_t vm_flags;
58569 +
58570 + size = STACK_TOP - vma->vm_end;
58571 + vm_flags = VM_NONE | VM_DONTEXPAND | VM_DONTDUMP;
58572 +
58573 + ret = vma->vm_end != mmap_region(NULL, vma->vm_end, size, vm_flags, 0);
58574 +
58575 +#ifdef CONFIG_X86
58576 + if (!ret) {
58577 + size = PAGE_SIZE + mmap_min_addr + ((mm->delta_mmap ^ mm->delta_stack) & (0xFFUL << PAGE_SHIFT));
58578 + ret = 0 != mmap_region(NULL, 0, PAGE_ALIGN(size), vm_flags, 0);
58579 + }
58580 +#endif
58581 +
58582 + }
58583 +#endif
58584 +
58585 if (ret)
58586 ret = -EFAULT;
58587
58588 @@ -775,6 +851,8 @@ static struct file *do_open_exec(struct filename *name)
58589
58590 fsnotify_open(file);
58591
58592 + trace_open_exec(name->name);
58593 +
58594 err = deny_write_access(file);
58595 if (err)
58596 goto exit;
58597 @@ -804,7 +882,7 @@ int kernel_read(struct file *file, loff_t offset,
58598 old_fs = get_fs();
58599 set_fs(get_ds());
58600 /* The cast to a user pointer is valid due to the set_fs() */
58601 - result = vfs_read(file, (void __user *)addr, count, &pos);
58602 + result = vfs_read(file, (void __force_user *)addr, count, &pos);
58603 set_fs(old_fs);
58604 return result;
58605 }
58606 @@ -849,6 +927,7 @@ static int exec_mmap(struct mm_struct *mm)
58607 tsk->mm = mm;
58608 tsk->active_mm = mm;
58609 activate_mm(active_mm, mm);
58610 + populate_stack();
58611 tsk->mm->vmacache_seqnum = 0;
58612 vmacache_flush(tsk);
58613 task_unlock(tsk);
58614 @@ -1246,7 +1325,7 @@ static void check_unsafe_exec(struct linux_binprm *bprm)
58615 }
58616 rcu_read_unlock();
58617
58618 - if (p->fs->users > n_fs)
58619 + if (atomic_read(&p->fs->users) > n_fs)
58620 bprm->unsafe |= LSM_UNSAFE_SHARE;
58621 else
58622 p->fs->in_exec = 1;
58623 @@ -1422,6 +1501,31 @@ static int exec_binprm(struct linux_binprm *bprm)
58624 return ret;
58625 }
58626
58627 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
58628 +static DEFINE_PER_CPU(u64, exec_counter);
58629 +static int __init init_exec_counters(void)
58630 +{
58631 + unsigned int cpu;
58632 +
58633 + for_each_possible_cpu(cpu) {
58634 + per_cpu(exec_counter, cpu) = (u64)cpu;
58635 + }
58636 +
58637 + return 0;
58638 +}
58639 +early_initcall(init_exec_counters);
58640 +static inline void increment_exec_counter(void)
58641 +{
58642 + BUILD_BUG_ON(NR_CPUS > (1 << 16));
58643 + current->exec_id = this_cpu_add_return(exec_counter, 1 << 16);
58644 +}
58645 +#else
58646 +static inline void increment_exec_counter(void) {}
58647 +#endif
58648 +
58649 +extern void gr_handle_exec_args(struct linux_binprm *bprm,
58650 + struct user_arg_ptr argv);
58651 +
58652 /*
58653 * sys_execve() executes a new program.
58654 */
58655 @@ -1429,6 +1533,11 @@ static int do_execve_common(struct filename *filename,
58656 struct user_arg_ptr argv,
58657 struct user_arg_ptr envp)
58658 {
58659 +#ifdef CONFIG_GRKERNSEC
58660 + struct file *old_exec_file;
58661 + struct acl_subject_label *old_acl;
58662 + struct rlimit old_rlim[RLIM_NLIMITS];
58663 +#endif
58664 struct linux_binprm *bprm;
58665 struct file *file;
58666 struct files_struct *displaced;
58667 @@ -1437,6 +1546,8 @@ static int do_execve_common(struct filename *filename,
58668 if (IS_ERR(filename))
58669 return PTR_ERR(filename);
58670
58671 + gr_learn_resource(current, RLIMIT_NPROC, atomic_read(&current_user()->processes), 1);
58672 +
58673 /*
58674 * We move the actual failure in case of RLIMIT_NPROC excess from
58675 * set*uid() to execve() because too many poorly written programs
58676 @@ -1474,11 +1585,21 @@ static int do_execve_common(struct filename *filename,
58677 if (IS_ERR(file))
58678 goto out_unmark;
58679
58680 + if (gr_ptrace_readexec(file, bprm->unsafe)) {
58681 + retval = -EPERM;
58682 + goto out_unmark;
58683 + }
58684 +
58685 sched_exec();
58686
58687 bprm->file = file;
58688 bprm->filename = bprm->interp = filename->name;
58689
58690 + if (!gr_acl_handle_execve(file->f_path.dentry, file->f_path.mnt)) {
58691 + retval = -EACCES;
58692 + goto out_unmark;
58693 + }
58694 +
58695 retval = bprm_mm_init(bprm);
58696 if (retval)
58697 goto out_unmark;
58698 @@ -1495,24 +1616,70 @@ static int do_execve_common(struct filename *filename,
58699 if (retval < 0)
58700 goto out;
58701
58702 +#ifdef CONFIG_GRKERNSEC
58703 + old_acl = current->acl;
58704 + memcpy(old_rlim, current->signal->rlim, sizeof(old_rlim));
58705 + old_exec_file = current->exec_file;
58706 + get_file(file);
58707 + current->exec_file = file;
58708 +#endif
58709 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
58710 + /* limit suid stack to 8MB
58711 + * we saved the old limits above and will restore them if this exec fails
58712 + */
58713 + if (((!uid_eq(bprm->cred->euid, current_euid())) || (!gid_eq(bprm->cred->egid, current_egid()))) &&
58714 + (old_rlim[RLIMIT_STACK].rlim_cur > (8 * 1024 * 1024)))
58715 + current->signal->rlim[RLIMIT_STACK].rlim_cur = 8 * 1024 * 1024;
58716 +#endif
58717 +
58718 + if (gr_process_kernel_exec_ban() || gr_process_suid_exec_ban(bprm)) {
58719 + retval = -EPERM;
58720 + goto out_fail;
58721 + }
58722 +
58723 + if (!gr_tpe_allow(file)) {
58724 + retval = -EACCES;
58725 + goto out_fail;
58726 + }
58727 +
58728 + if (gr_check_crash_exec(file)) {
58729 + retval = -EACCES;
58730 + goto out_fail;
58731 + }
58732 +
58733 + retval = gr_set_proc_label(file->f_path.dentry, file->f_path.mnt,
58734 + bprm->unsafe);
58735 + if (retval < 0)
58736 + goto out_fail;
58737 +
58738 retval = copy_strings_kernel(1, &bprm->filename, bprm);
58739 if (retval < 0)
58740 - goto out;
58741 + goto out_fail;
58742
58743 bprm->exec = bprm->p;
58744 retval = copy_strings(bprm->envc, envp, bprm);
58745 if (retval < 0)
58746 - goto out;
58747 + goto out_fail;
58748
58749 retval = copy_strings(bprm->argc, argv, bprm);
58750 if (retval < 0)
58751 - goto out;
58752 + goto out_fail;
58753 +
58754 + gr_log_chroot_exec(file->f_path.dentry, file->f_path.mnt);
58755 +
58756 + gr_handle_exec_args(bprm, argv);
58757
58758 retval = exec_binprm(bprm);
58759 if (retval < 0)
58760 - goto out;
58761 + goto out_fail;
58762 +#ifdef CONFIG_GRKERNSEC
58763 + if (old_exec_file)
58764 + fput(old_exec_file);
58765 +#endif
58766
58767 /* execve succeeded */
58768 +
58769 + increment_exec_counter();
58770 current->fs->in_exec = 0;
58771 current->in_execve = 0;
58772 acct_update_integrals(current);
58773 @@ -1523,6 +1690,14 @@ static int do_execve_common(struct filename *filename,
58774 put_files_struct(displaced);
58775 return retval;
58776
58777 +out_fail:
58778 +#ifdef CONFIG_GRKERNSEC
58779 + current->acl = old_acl;
58780 + memcpy(current->signal->rlim, old_rlim, sizeof(old_rlim));
58781 + fput(current->exec_file);
58782 + current->exec_file = old_exec_file;
58783 +#endif
58784 +
58785 out:
58786 if (bprm->mm) {
58787 acct_arg_size(bprm, 0);
58788 @@ -1614,3 +1789,312 @@ COMPAT_SYSCALL_DEFINE3(execve, const char __user *, filename,
58789 return compat_do_execve(getname(filename), argv, envp);
58790 }
58791 #endif
58792 +
58793 +int pax_check_flags(unsigned long *flags)
58794 +{
58795 + int retval = 0;
58796 +
58797 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_SEGMEXEC)
58798 + if (*flags & MF_PAX_SEGMEXEC)
58799 + {
58800 + *flags &= ~MF_PAX_SEGMEXEC;
58801 + retval = -EINVAL;
58802 + }
58803 +#endif
58804 +
58805 + if ((*flags & MF_PAX_PAGEEXEC)
58806 +
58807 +#ifdef CONFIG_PAX_PAGEEXEC
58808 + && (*flags & MF_PAX_SEGMEXEC)
58809 +#endif
58810 +
58811 + )
58812 + {
58813 + *flags &= ~MF_PAX_PAGEEXEC;
58814 + retval = -EINVAL;
58815 + }
58816 +
58817 + if ((*flags & MF_PAX_MPROTECT)
58818 +
58819 +#ifdef CONFIG_PAX_MPROTECT
58820 + && !(*flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC))
58821 +#endif
58822 +
58823 + )
58824 + {
58825 + *flags &= ~MF_PAX_MPROTECT;
58826 + retval = -EINVAL;
58827 + }
58828 +
58829 + if ((*flags & MF_PAX_EMUTRAMP)
58830 +
58831 +#ifdef CONFIG_PAX_EMUTRAMP
58832 + && !(*flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC))
58833 +#endif
58834 +
58835 + )
58836 + {
58837 + *flags &= ~MF_PAX_EMUTRAMP;
58838 + retval = -EINVAL;
58839 + }
58840 +
58841 + return retval;
58842 +}
58843 +
58844 +EXPORT_SYMBOL(pax_check_flags);
58845 +
58846 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
58847 +char *pax_get_path(const struct path *path, char *buf, int buflen)
58848 +{
58849 + char *pathname = d_path(path, buf, buflen);
58850 +
58851 + if (IS_ERR(pathname))
58852 + goto toolong;
58853 +
58854 + pathname = mangle_path(buf, pathname, "\t\n\\");
58855 + if (!pathname)
58856 + goto toolong;
58857 +
58858 + *pathname = 0;
58859 + return buf;
58860 +
58861 +toolong:
58862 + return "<path too long>";
58863 +}
58864 +EXPORT_SYMBOL(pax_get_path);
58865 +
58866 +void pax_report_fault(struct pt_regs *regs, void *pc, void *sp)
58867 +{
58868 + struct task_struct *tsk = current;
58869 + struct mm_struct *mm = current->mm;
58870 + char *buffer_exec = (char *)__get_free_page(GFP_KERNEL);
58871 + char *buffer_fault = (char *)__get_free_page(GFP_KERNEL);
58872 + char *path_exec = NULL;
58873 + char *path_fault = NULL;
58874 + unsigned long start = 0UL, end = 0UL, offset = 0UL;
58875 + siginfo_t info = { };
58876 +
58877 + if (buffer_exec && buffer_fault) {
58878 + struct vm_area_struct *vma, *vma_exec = NULL, *vma_fault = NULL;
58879 +
58880 + down_read(&mm->mmap_sem);
58881 + vma = mm->mmap;
58882 + while (vma && (!vma_exec || !vma_fault)) {
58883 + if (vma->vm_file && mm->exe_file == vma->vm_file && (vma->vm_flags & VM_EXEC))
58884 + vma_exec = vma;
58885 + if (vma->vm_start <= (unsigned long)pc && (unsigned long)pc < vma->vm_end)
58886 + vma_fault = vma;
58887 + vma = vma->vm_next;
58888 + }
58889 + if (vma_exec)
58890 + path_exec = pax_get_path(&vma_exec->vm_file->f_path, buffer_exec, PAGE_SIZE);
58891 + if (vma_fault) {
58892 + start = vma_fault->vm_start;
58893 + end = vma_fault->vm_end;
58894 + offset = vma_fault->vm_pgoff << PAGE_SHIFT;
58895 + if (vma_fault->vm_file)
58896 + path_fault = pax_get_path(&vma_fault->vm_file->f_path, buffer_fault, PAGE_SIZE);
58897 + else if ((unsigned long)pc >= mm->start_brk && (unsigned long)pc < mm->brk)
58898 + path_fault = "<heap>";
58899 + else if (vma_fault->vm_flags & (VM_GROWSDOWN | VM_GROWSUP))
58900 + path_fault = "<stack>";
58901 + else
58902 + path_fault = "<anonymous mapping>";
58903 + }
58904 + up_read(&mm->mmap_sem);
58905 + }
58906 + if (tsk->signal->curr_ip)
58907 + printk(KERN_ERR "PAX: From %pI4: execution attempt in: %s, %08lx-%08lx %08lx\n", &tsk->signal->curr_ip, path_fault, start, end, offset);
58908 + else
58909 + printk(KERN_ERR "PAX: execution attempt in: %s, %08lx-%08lx %08lx\n", path_fault, start, end, offset);
58910 + 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),
58911 + from_kuid_munged(&init_user_ns, task_uid(tsk)), from_kuid_munged(&init_user_ns, task_euid(tsk)), pc, sp);
58912 + free_page((unsigned long)buffer_exec);
58913 + free_page((unsigned long)buffer_fault);
58914 + pax_report_insns(regs, pc, sp);
58915 + info.si_signo = SIGKILL;
58916 + info.si_errno = 0;
58917 + info.si_code = SI_KERNEL;
58918 + info.si_pid = 0;
58919 + info.si_uid = 0;
58920 + do_coredump(&info);
58921 +}
58922 +#endif
58923 +
58924 +#ifdef CONFIG_PAX_REFCOUNT
58925 +void pax_report_refcount_overflow(struct pt_regs *regs)
58926 +{
58927 + if (current->signal->curr_ip)
58928 + printk(KERN_ERR "PAX: From %pI4: refcount overflow detected in: %s:%d, uid/euid: %u/%u\n",
58929 + &current->signal->curr_ip, current->comm, task_pid_nr(current),
58930 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
58931 + else
58932 + printk(KERN_ERR "PAX: refcount overflow detected in: %s:%d, uid/euid: %u/%u\n", current->comm, task_pid_nr(current),
58933 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
58934 + print_symbol(KERN_ERR "PAX: refcount overflow occured at: %s\n", instruction_pointer(regs));
58935 + preempt_disable();
58936 + show_regs(regs);
58937 + preempt_enable();
58938 + force_sig_info(SIGKILL, SEND_SIG_FORCED, current);
58939 +}
58940 +#endif
58941 +
58942 +#ifdef CONFIG_PAX_USERCOPY
58943 +/* 0: not at all, 1: fully, 2: fully inside frame, -1: partially (implies an error) */
58944 +static noinline int check_stack_object(const void *obj, unsigned long len)
58945 +{
58946 + const void * const stack = task_stack_page(current);
58947 + const void * const stackend = stack + THREAD_SIZE;
58948 +
58949 +#if defined(CONFIG_FRAME_POINTER) && defined(CONFIG_X86)
58950 + const void *frame = NULL;
58951 + const void *oldframe;
58952 +#endif
58953 +
58954 + if (obj + len < obj)
58955 + return -1;
58956 +
58957 + if (obj + len <= stack || stackend <= obj)
58958 + return 0;
58959 +
58960 + if (obj < stack || stackend < obj + len)
58961 + return -1;
58962 +
58963 +#if defined(CONFIG_FRAME_POINTER) && defined(CONFIG_X86)
58964 + oldframe = __builtin_frame_address(1);
58965 + if (oldframe)
58966 + frame = __builtin_frame_address(2);
58967 + /*
58968 + low ----------------------------------------------> high
58969 + [saved bp][saved ip][args][local vars][saved bp][saved ip]
58970 + ^----------------^
58971 + allow copies only within here
58972 + */
58973 + while (stack <= frame && frame < stackend) {
58974 + /* if obj + len extends past the last frame, this
58975 + check won't pass and the next frame will be 0,
58976 + causing us to bail out and correctly report
58977 + the copy as invalid
58978 + */
58979 + if (obj + len <= frame)
58980 + return obj >= oldframe + 2 * sizeof(void *) ? 2 : -1;
58981 + oldframe = frame;
58982 + frame = *(const void * const *)frame;
58983 + }
58984 + return -1;
58985 +#else
58986 + return 1;
58987 +#endif
58988 +}
58989 +
58990 +static __noreturn void pax_report_usercopy(const void *ptr, unsigned long len, bool to_user, const char *type)
58991 +{
58992 + if (current->signal->curr_ip)
58993 + printk(KERN_ERR "PAX: From %pI4: kernel memory %s attempt detected %s %p (%s) (%lu bytes)\n",
58994 + &current->signal->curr_ip, to_user ? "leak" : "overwrite", to_user ? "from" : "to", ptr, type ? : "unknown", len);
58995 + else
58996 + printk(KERN_ERR "PAX: kernel memory %s attempt detected %s %p (%s) (%lu bytes)\n",
58997 + to_user ? "leak" : "overwrite", to_user ? "from" : "to", ptr, type ? : "unknown", len);
58998 + dump_stack();
58999 + gr_handle_kernel_exploit();
59000 + do_group_exit(SIGKILL);
59001 +}
59002 +#endif
59003 +
59004 +#ifdef CONFIG_PAX_USERCOPY
59005 +
59006 +static inline bool check_kernel_text_object(unsigned long low, unsigned long high)
59007 +{
59008 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
59009 + unsigned long textlow = ktla_ktva((unsigned long)_stext);
59010 +#ifdef CONFIG_MODULES
59011 + unsigned long texthigh = (unsigned long)MODULES_EXEC_VADDR;
59012 +#else
59013 + unsigned long texthigh = ktla_ktva((unsigned long)_etext);
59014 +#endif
59015 +
59016 +#else
59017 + unsigned long textlow = (unsigned long)_stext;
59018 + unsigned long texthigh = (unsigned long)_etext;
59019 +
59020 +#ifdef CONFIG_X86_64
59021 + /* check against linear mapping as well */
59022 + if (high > (unsigned long)__va(__pa(textlow)) &&
59023 + low < (unsigned long)__va(__pa(texthigh)))
59024 + return true;
59025 +#endif
59026 +
59027 +#endif
59028 +
59029 + if (high <= textlow || low >= texthigh)
59030 + return false;
59031 + else
59032 + return true;
59033 +}
59034 +#endif
59035 +
59036 +void __check_object_size(const void *ptr, unsigned long n, bool to_user, bool const_size)
59037 +{
59038 +#ifdef CONFIG_PAX_USERCOPY
59039 + const char *type;
59040 +#endif
59041 +
59042 +#ifndef CONFIG_STACK_GROWSUP
59043 + unsigned long stackstart = (unsigned long)task_stack_page(current);
59044 + unsigned long currentsp = (unsigned long)&stackstart;
59045 + if (unlikely((currentsp < stackstart + 512 ||
59046 + currentsp >= stackstart + THREAD_SIZE) && !in_interrupt()))
59047 + BUG();
59048 +#endif
59049 +
59050 +#ifndef CONFIG_PAX_USERCOPY_DEBUG
59051 + if (const_size)
59052 + return;
59053 +#endif
59054 +
59055 +#ifdef CONFIG_PAX_USERCOPY
59056 + if (!n)
59057 + return;
59058 +
59059 + type = check_heap_object(ptr, n);
59060 + if (!type) {
59061 + int ret = check_stack_object(ptr, n);
59062 + if (ret == 1 || ret == 2)
59063 + return;
59064 + if (ret == 0) {
59065 + if (check_kernel_text_object((unsigned long)ptr, (unsigned long)ptr + n))
59066 + type = "<kernel text>";
59067 + else
59068 + return;
59069 + } else
59070 + type = "<process stack>";
59071 + }
59072 +
59073 + pax_report_usercopy(ptr, n, to_user, type);
59074 +#endif
59075 +
59076 +}
59077 +EXPORT_SYMBOL(__check_object_size);
59078 +
59079 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
59080 +void pax_track_stack(void)
59081 +{
59082 + unsigned long sp = (unsigned long)&sp;
59083 + if (sp < current_thread_info()->lowest_stack &&
59084 + sp > (unsigned long)task_stack_page(current))
59085 + current_thread_info()->lowest_stack = sp;
59086 + if (unlikely((sp & ~(THREAD_SIZE - 1)) < (THREAD_SIZE/16)))
59087 + BUG();
59088 +}
59089 +EXPORT_SYMBOL(pax_track_stack);
59090 +#endif
59091 +
59092 +#ifdef CONFIG_PAX_SIZE_OVERFLOW
59093 +void report_size_overflow(const char *file, unsigned int line, const char *func, const char *ssa_name)
59094 +{
59095 + printk(KERN_ERR "PAX: size overflow detected in function %s %s:%u %s", func, file, line, ssa_name);
59096 + dump_stack();
59097 + do_group_exit(SIGKILL);
59098 +}
59099 +EXPORT_SYMBOL(report_size_overflow);
59100 +#endif
59101 diff --git a/fs/ext2/balloc.c b/fs/ext2/balloc.c
59102 index 9f9992b..8b59411 100644
59103 --- a/fs/ext2/balloc.c
59104 +++ b/fs/ext2/balloc.c
59105 @@ -1184,10 +1184,10 @@ static int ext2_has_free_blocks(struct ext2_sb_info *sbi)
59106
59107 free_blocks = percpu_counter_read_positive(&sbi->s_freeblocks_counter);
59108 root_blocks = le32_to_cpu(sbi->s_es->s_r_blocks_count);
59109 - if (free_blocks < root_blocks + 1 && !capable(CAP_SYS_RESOURCE) &&
59110 + if (free_blocks < root_blocks + 1 &&
59111 !uid_eq(sbi->s_resuid, current_fsuid()) &&
59112 (gid_eq(sbi->s_resgid, GLOBAL_ROOT_GID) ||
59113 - !in_group_p (sbi->s_resgid))) {
59114 + !in_group_p (sbi->s_resgid)) && !capable_nolog(CAP_SYS_RESOURCE)) {
59115 return 0;
59116 }
59117 return 1;
59118 diff --git a/fs/ext2/xattr.c b/fs/ext2/xattr.c
59119 index 9142614..97484fa 100644
59120 --- a/fs/ext2/xattr.c
59121 +++ b/fs/ext2/xattr.c
59122 @@ -247,7 +247,7 @@ ext2_xattr_list(struct dentry *dentry, char *buffer, size_t buffer_size)
59123 struct buffer_head *bh = NULL;
59124 struct ext2_xattr_entry *entry;
59125 char *end;
59126 - size_t rest = buffer_size;
59127 + size_t rest = buffer_size, total_size = 0;
59128 int error;
59129
59130 ea_idebug(inode, "buffer=%p, buffer_size=%ld",
59131 @@ -305,9 +305,10 @@ bad_block: ext2_error(inode->i_sb, "ext2_xattr_list",
59132 buffer += size;
59133 }
59134 rest -= size;
59135 + total_size += size;
59136 }
59137 }
59138 - error = buffer_size - rest; /* total size */
59139 + error = total_size;
59140
59141 cleanup:
59142 brelse(bh);
59143 diff --git a/fs/ext3/balloc.c b/fs/ext3/balloc.c
59144 index 158b5d4..2432610 100644
59145 --- a/fs/ext3/balloc.c
59146 +++ b/fs/ext3/balloc.c
59147 @@ -1438,10 +1438,10 @@ static int ext3_has_free_blocks(struct ext3_sb_info *sbi, int use_reservation)
59148
59149 free_blocks = percpu_counter_read_positive(&sbi->s_freeblocks_counter);
59150 root_blocks = le32_to_cpu(sbi->s_es->s_r_blocks_count);
59151 - if (free_blocks < root_blocks + 1 && !capable(CAP_SYS_RESOURCE) &&
59152 + if (free_blocks < root_blocks + 1 &&
59153 !use_reservation && !uid_eq(sbi->s_resuid, current_fsuid()) &&
59154 (gid_eq(sbi->s_resgid, GLOBAL_ROOT_GID) ||
59155 - !in_group_p (sbi->s_resgid))) {
59156 + !in_group_p (sbi->s_resgid)) && !capable_nolog(CAP_SYS_RESOURCE)) {
59157 return 0;
59158 }
59159 return 1;
59160 diff --git a/fs/ext3/xattr.c b/fs/ext3/xattr.c
59161 index c6874be..f8a6ae8 100644
59162 --- a/fs/ext3/xattr.c
59163 +++ b/fs/ext3/xattr.c
59164 @@ -330,7 +330,7 @@ static int
59165 ext3_xattr_list_entries(struct dentry *dentry, struct ext3_xattr_entry *entry,
59166 char *buffer, size_t buffer_size)
59167 {
59168 - size_t rest = buffer_size;
59169 + size_t rest = buffer_size, total_size = 0;
59170
59171 for (; !IS_LAST_ENTRY(entry); entry = EXT3_XATTR_NEXT(entry)) {
59172 const struct xattr_handler *handler =
59173 @@ -347,9 +347,10 @@ ext3_xattr_list_entries(struct dentry *dentry, struct ext3_xattr_entry *entry,
59174 buffer += size;
59175 }
59176 rest -= size;
59177 + total_size += size;
59178 }
59179 }
59180 - return buffer_size - rest;
59181 + return total_size;
59182 }
59183
59184 static int
59185 diff --git a/fs/ext4/balloc.c b/fs/ext4/balloc.c
59186 index 5c56785..77698a2 100644
59187 --- a/fs/ext4/balloc.c
59188 +++ b/fs/ext4/balloc.c
59189 @@ -534,8 +534,8 @@ static int ext4_has_free_clusters(struct ext4_sb_info *sbi,
59190 /* Hm, nope. Are (enough) root reserved clusters available? */
59191 if (uid_eq(sbi->s_resuid, current_fsuid()) ||
59192 (!gid_eq(sbi->s_resgid, GLOBAL_ROOT_GID) && in_group_p(sbi->s_resgid)) ||
59193 - capable(CAP_SYS_RESOURCE) ||
59194 - (flags & EXT4_MB_USE_ROOT_BLOCKS)) {
59195 + (flags & EXT4_MB_USE_ROOT_BLOCKS) ||
59196 + capable_nolog(CAP_SYS_RESOURCE)) {
59197
59198 if (free_clusters >= (nclusters + dirty_clusters +
59199 resv_clusters))
59200 diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
59201 index 66946aa..4706fa4 100644
59202 --- a/fs/ext4/ext4.h
59203 +++ b/fs/ext4/ext4.h
59204 @@ -1274,19 +1274,19 @@ struct ext4_sb_info {
59205 unsigned long s_mb_last_start;
59206
59207 /* stats for buddy allocator */
59208 - atomic_t s_bal_reqs; /* number of reqs with len > 1 */
59209 - atomic_t s_bal_success; /* we found long enough chunks */
59210 - atomic_t s_bal_allocated; /* in blocks */
59211 - atomic_t s_bal_ex_scanned; /* total extents scanned */
59212 - atomic_t s_bal_goals; /* goal hits */
59213 - atomic_t s_bal_breaks; /* too long searches */
59214 - atomic_t s_bal_2orders; /* 2^order hits */
59215 + atomic_unchecked_t s_bal_reqs; /* number of reqs with len > 1 */
59216 + atomic_unchecked_t s_bal_success; /* we found long enough chunks */
59217 + atomic_unchecked_t s_bal_allocated; /* in blocks */
59218 + atomic_unchecked_t s_bal_ex_scanned; /* total extents scanned */
59219 + atomic_unchecked_t s_bal_goals; /* goal hits */
59220 + atomic_unchecked_t s_bal_breaks; /* too long searches */
59221 + atomic_unchecked_t s_bal_2orders; /* 2^order hits */
59222 spinlock_t s_bal_lock;
59223 unsigned long s_mb_buddies_generated;
59224 unsigned long long s_mb_generation_time;
59225 - atomic_t s_mb_lost_chunks;
59226 - atomic_t s_mb_preallocated;
59227 - atomic_t s_mb_discarded;
59228 + atomic_unchecked_t s_mb_lost_chunks;
59229 + atomic_unchecked_t s_mb_preallocated;
59230 + atomic_unchecked_t s_mb_discarded;
59231 atomic_t s_lock_busy;
59232
59233 /* locality groups */
59234 diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
59235 index c8238a2..42c2029 100644
59236 --- a/fs/ext4/mballoc.c
59237 +++ b/fs/ext4/mballoc.c
59238 @@ -1889,7 +1889,7 @@ void ext4_mb_simple_scan_group(struct ext4_allocation_context *ac,
59239 BUG_ON(ac->ac_b_ex.fe_len != ac->ac_g_ex.fe_len);
59240
59241 if (EXT4_SB(sb)->s_mb_stats)
59242 - atomic_inc(&EXT4_SB(sb)->s_bal_2orders);
59243 + atomic_inc_unchecked(&EXT4_SB(sb)->s_bal_2orders);
59244
59245 break;
59246 }
59247 @@ -2199,7 +2199,7 @@ repeat:
59248 ac->ac_status = AC_STATUS_CONTINUE;
59249 ac->ac_flags |= EXT4_MB_HINT_FIRST;
59250 cr = 3;
59251 - atomic_inc(&sbi->s_mb_lost_chunks);
59252 + atomic_inc_unchecked(&sbi->s_mb_lost_chunks);
59253 goto repeat;
59254 }
59255 }
59256 @@ -2707,25 +2707,25 @@ int ext4_mb_release(struct super_block *sb)
59257 if (sbi->s_mb_stats) {
59258 ext4_msg(sb, KERN_INFO,
59259 "mballoc: %u blocks %u reqs (%u success)",
59260 - atomic_read(&sbi->s_bal_allocated),
59261 - atomic_read(&sbi->s_bal_reqs),
59262 - atomic_read(&sbi->s_bal_success));
59263 + atomic_read_unchecked(&sbi->s_bal_allocated),
59264 + atomic_read_unchecked(&sbi->s_bal_reqs),
59265 + atomic_read_unchecked(&sbi->s_bal_success));
59266 ext4_msg(sb, KERN_INFO,
59267 "mballoc: %u extents scanned, %u goal hits, "
59268 "%u 2^N hits, %u breaks, %u lost",
59269 - atomic_read(&sbi->s_bal_ex_scanned),
59270 - atomic_read(&sbi->s_bal_goals),
59271 - atomic_read(&sbi->s_bal_2orders),
59272 - atomic_read(&sbi->s_bal_breaks),
59273 - atomic_read(&sbi->s_mb_lost_chunks));
59274 + atomic_read_unchecked(&sbi->s_bal_ex_scanned),
59275 + atomic_read_unchecked(&sbi->s_bal_goals),
59276 + atomic_read_unchecked(&sbi->s_bal_2orders),
59277 + atomic_read_unchecked(&sbi->s_bal_breaks),
59278 + atomic_read_unchecked(&sbi->s_mb_lost_chunks));
59279 ext4_msg(sb, KERN_INFO,
59280 "mballoc: %lu generated and it took %Lu",
59281 sbi->s_mb_buddies_generated,
59282 sbi->s_mb_generation_time);
59283 ext4_msg(sb, KERN_INFO,
59284 "mballoc: %u preallocated, %u discarded",
59285 - atomic_read(&sbi->s_mb_preallocated),
59286 - atomic_read(&sbi->s_mb_discarded));
59287 + atomic_read_unchecked(&sbi->s_mb_preallocated),
59288 + atomic_read_unchecked(&sbi->s_mb_discarded));
59289 }
59290
59291 free_percpu(sbi->s_locality_groups);
59292 @@ -3179,16 +3179,16 @@ static void ext4_mb_collect_stats(struct ext4_allocation_context *ac)
59293 struct ext4_sb_info *sbi = EXT4_SB(ac->ac_sb);
59294
59295 if (sbi->s_mb_stats && ac->ac_g_ex.fe_len > 1) {
59296 - atomic_inc(&sbi->s_bal_reqs);
59297 - atomic_add(ac->ac_b_ex.fe_len, &sbi->s_bal_allocated);
59298 + atomic_inc_unchecked(&sbi->s_bal_reqs);
59299 + atomic_add_unchecked(ac->ac_b_ex.fe_len, &sbi->s_bal_allocated);
59300 if (ac->ac_b_ex.fe_len >= ac->ac_o_ex.fe_len)
59301 - atomic_inc(&sbi->s_bal_success);
59302 - atomic_add(ac->ac_found, &sbi->s_bal_ex_scanned);
59303 + atomic_inc_unchecked(&sbi->s_bal_success);
59304 + atomic_add_unchecked(ac->ac_found, &sbi->s_bal_ex_scanned);
59305 if (ac->ac_g_ex.fe_start == ac->ac_b_ex.fe_start &&
59306 ac->ac_g_ex.fe_group == ac->ac_b_ex.fe_group)
59307 - atomic_inc(&sbi->s_bal_goals);
59308 + atomic_inc_unchecked(&sbi->s_bal_goals);
59309 if (ac->ac_found > sbi->s_mb_max_to_scan)
59310 - atomic_inc(&sbi->s_bal_breaks);
59311 + atomic_inc_unchecked(&sbi->s_bal_breaks);
59312 }
59313
59314 if (ac->ac_op == EXT4_MB_HISTORY_ALLOC)
59315 @@ -3593,7 +3593,7 @@ ext4_mb_new_inode_pa(struct ext4_allocation_context *ac)
59316 trace_ext4_mb_new_inode_pa(ac, pa);
59317
59318 ext4_mb_use_inode_pa(ac, pa);
59319 - atomic_add(pa->pa_free, &sbi->s_mb_preallocated);
59320 + atomic_add_unchecked(pa->pa_free, &sbi->s_mb_preallocated);
59321
59322 ei = EXT4_I(ac->ac_inode);
59323 grp = ext4_get_group_info(sb, ac->ac_b_ex.fe_group);
59324 @@ -3653,7 +3653,7 @@ ext4_mb_new_group_pa(struct ext4_allocation_context *ac)
59325 trace_ext4_mb_new_group_pa(ac, pa);
59326
59327 ext4_mb_use_group_pa(ac, pa);
59328 - atomic_add(pa->pa_free, &EXT4_SB(sb)->s_mb_preallocated);
59329 + atomic_add_unchecked(pa->pa_free, &EXT4_SB(sb)->s_mb_preallocated);
59330
59331 grp = ext4_get_group_info(sb, ac->ac_b_ex.fe_group);
59332 lg = ac->ac_lg;
59333 @@ -3742,7 +3742,7 @@ ext4_mb_release_inode_pa(struct ext4_buddy *e4b, struct buffer_head *bitmap_bh,
59334 * from the bitmap and continue.
59335 */
59336 }
59337 - atomic_add(free, &sbi->s_mb_discarded);
59338 + atomic_add_unchecked(free, &sbi->s_mb_discarded);
59339
59340 return err;
59341 }
59342 @@ -3760,7 +3760,7 @@ ext4_mb_release_group_pa(struct ext4_buddy *e4b,
59343 ext4_get_group_no_and_offset(sb, pa->pa_pstart, &group, &bit);
59344 BUG_ON(group != e4b->bd_group && pa->pa_len != 0);
59345 mb_free_blocks(pa->pa_inode, e4b, bit, pa->pa_len);
59346 - atomic_add(pa->pa_len, &EXT4_SB(sb)->s_mb_discarded);
59347 + atomic_add_unchecked(pa->pa_len, &EXT4_SB(sb)->s_mb_discarded);
59348 trace_ext4_mballoc_discard(sb, NULL, group, bit, pa->pa_len);
59349
59350 return 0;
59351 diff --git a/fs/ext4/mmp.c b/fs/ext4/mmp.c
59352 index 04434ad..6404663 100644
59353 --- a/fs/ext4/mmp.c
59354 +++ b/fs/ext4/mmp.c
59355 @@ -113,7 +113,7 @@ static int read_mmp_block(struct super_block *sb, struct buffer_head **bh,
59356 void __dump_mmp_msg(struct super_block *sb, struct mmp_struct *mmp,
59357 const char *function, unsigned int line, const char *msg)
59358 {
59359 - __ext4_warning(sb, function, line, msg);
59360 + __ext4_warning(sb, function, line, "%s", msg);
59361 __ext4_warning(sb, function, line,
59362 "MMP failure info: last update time: %llu, last update "
59363 "node: %s, last update device: %s\n",
59364 diff --git a/fs/ext4/super.c b/fs/ext4/super.c
59365 index 6f9e6fa..5431c02 100644
59366 --- a/fs/ext4/super.c
59367 +++ b/fs/ext4/super.c
59368 @@ -1275,7 +1275,7 @@ static ext4_fsblk_t get_sb_block(void **data)
59369 }
59370
59371 #define DEFAULT_JOURNAL_IOPRIO (IOPRIO_PRIO_VALUE(IOPRIO_CLASS_BE, 3))
59372 -static char deprecated_msg[] = "Mount option \"%s\" will be removed by %s\n"
59373 +static const char deprecated_msg[] = "Mount option \"%s\" will be removed by %s\n"
59374 "Contact linux-ext4@vger.kernel.org if you think we should keep it.\n";
59375
59376 #ifdef CONFIG_QUOTA
59377 @@ -2455,7 +2455,7 @@ struct ext4_attr {
59378 int offset;
59379 int deprecated_val;
59380 } u;
59381 -};
59382 +} __do_const;
59383
59384 static int parse_strtoull(const char *buf,
59385 unsigned long long max, unsigned long long *value)
59386 diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c
59387 index 4eec399..1d9444c 100644
59388 --- a/fs/ext4/xattr.c
59389 +++ b/fs/ext4/xattr.c
59390 @@ -383,7 +383,7 @@ static int
59391 ext4_xattr_list_entries(struct dentry *dentry, struct ext4_xattr_entry *entry,
59392 char *buffer, size_t buffer_size)
59393 {
59394 - size_t rest = buffer_size;
59395 + size_t rest = buffer_size, total_size = 0;
59396
59397 for (; !IS_LAST_ENTRY(entry); entry = EXT4_XATTR_NEXT(entry)) {
59398 const struct xattr_handler *handler =
59399 @@ -400,9 +400,10 @@ ext4_xattr_list_entries(struct dentry *dentry, struct ext4_xattr_entry *entry,
59400 buffer += size;
59401 }
59402 rest -= size;
59403 + total_size += size;
59404 }
59405 }
59406 - return buffer_size - rest;
59407 + return total_size;
59408 }
59409
59410 static int
59411 diff --git a/fs/fcntl.c b/fs/fcntl.c
59412 index 72c82f6..a18b263 100644
59413 --- a/fs/fcntl.c
59414 +++ b/fs/fcntl.c
59415 @@ -106,6 +106,11 @@ int __f_setown(struct file *filp, struct pid *pid, enum pid_type type,
59416 if (err)
59417 return err;
59418
59419 + if (gr_handle_chroot_fowner(pid, type))
59420 + return -ENOENT;
59421 + if (gr_check_protected_task_fowner(pid, type))
59422 + return -EACCES;
59423 +
59424 f_modown(filp, pid, type, force);
59425 return 0;
59426 }
59427 diff --git a/fs/fhandle.c b/fs/fhandle.c
59428 index 999ff5c..ac037c9 100644
59429 --- a/fs/fhandle.c
59430 +++ b/fs/fhandle.c
59431 @@ -8,6 +8,7 @@
59432 #include <linux/fs_struct.h>
59433 #include <linux/fsnotify.h>
59434 #include <linux/personality.h>
59435 +#include <linux/grsecurity.h>
59436 #include <asm/uaccess.h>
59437 #include "internal.h"
59438 #include "mount.h"
59439 @@ -67,8 +68,7 @@ static long do_sys_name_to_handle(struct path *path,
59440 } else
59441 retval = 0;
59442 /* copy the mount id */
59443 - if (copy_to_user(mnt_id, &real_mount(path->mnt)->mnt_id,
59444 - sizeof(*mnt_id)) ||
59445 + if (put_user(real_mount(path->mnt)->mnt_id, mnt_id) ||
59446 copy_to_user(ufh, handle,
59447 sizeof(struct file_handle) + handle_bytes))
59448 retval = -EFAULT;
59449 @@ -175,7 +175,7 @@ static int handle_to_path(int mountdirfd, struct file_handle __user *ufh,
59450 * the directory. Ideally we would like CAP_DAC_SEARCH.
59451 * But we don't have that
59452 */
59453 - if (!capable(CAP_DAC_READ_SEARCH)) {
59454 + if (!capable(CAP_DAC_READ_SEARCH) || !gr_chroot_fhandle()) {
59455 retval = -EPERM;
59456 goto out_err;
59457 }
59458 diff --git a/fs/file.c b/fs/file.c
59459 index 8f294cf..d0f3872 100644
59460 --- a/fs/file.c
59461 +++ b/fs/file.c
59462 @@ -16,6 +16,7 @@
59463 #include <linux/slab.h>
59464 #include <linux/vmalloc.h>
59465 #include <linux/file.h>
59466 +#include <linux/security.h>
59467 #include <linux/fdtable.h>
59468 #include <linux/bitops.h>
59469 #include <linux/interrupt.h>
59470 @@ -144,7 +145,7 @@ out:
59471 * Return <0 error code on error; 1 on successful completion.
59472 * The files->file_lock should be held on entry, and will be held on exit.
59473 */
59474 -static int expand_fdtable(struct files_struct *files, int nr)
59475 +static int expand_fdtable(struct files_struct *files, unsigned int nr)
59476 __releases(files->file_lock)
59477 __acquires(files->file_lock)
59478 {
59479 @@ -189,7 +190,7 @@ static int expand_fdtable(struct files_struct *files, int nr)
59480 * expanded and execution may have blocked.
59481 * The files->file_lock should be held on entry, and will be held on exit.
59482 */
59483 -static int expand_files(struct files_struct *files, int nr)
59484 +static int expand_files(struct files_struct *files, unsigned int nr)
59485 {
59486 struct fdtable *fdt;
59487
59488 @@ -804,6 +805,7 @@ int replace_fd(unsigned fd, struct file *file, unsigned flags)
59489 if (!file)
59490 return __close_fd(files, fd);
59491
59492 + gr_learn_resource(current, RLIMIT_NOFILE, fd, 0);
59493 if (fd >= rlimit(RLIMIT_NOFILE))
59494 return -EBADF;
59495
59496 @@ -830,6 +832,7 @@ SYSCALL_DEFINE3(dup3, unsigned int, oldfd, unsigned int, newfd, int, flags)
59497 if (unlikely(oldfd == newfd))
59498 return -EINVAL;
59499
59500 + gr_learn_resource(current, RLIMIT_NOFILE, newfd, 0);
59501 if (newfd >= rlimit(RLIMIT_NOFILE))
59502 return -EBADF;
59503
59504 @@ -885,6 +888,7 @@ SYSCALL_DEFINE1(dup, unsigned int, fildes)
59505 int f_dupfd(unsigned int from, struct file *file, unsigned flags)
59506 {
59507 int err;
59508 + gr_learn_resource(current, RLIMIT_NOFILE, from, 0);
59509 if (from >= rlimit(RLIMIT_NOFILE))
59510 return -EINVAL;
59511 err = alloc_fd(from, flags);
59512 diff --git a/fs/filesystems.c b/fs/filesystems.c
59513 index 5797d45..7d7d79a 100644
59514 --- a/fs/filesystems.c
59515 +++ b/fs/filesystems.c
59516 @@ -275,7 +275,11 @@ struct file_system_type *get_fs_type(const char *name)
59517 int len = dot ? dot - name : strlen(name);
59518
59519 fs = __get_fs_type(name, len);
59520 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
59521 + if (!fs && (___request_module(true, "grsec_modharden_fs", "fs-%.*s", len, name) == 0))
59522 +#else
59523 if (!fs && (request_module("fs-%.*s", len, name) == 0))
59524 +#endif
59525 fs = __get_fs_type(name, len);
59526
59527 if (dot && fs && !(fs->fs_flags & FS_HAS_SUBTYPE)) {
59528 diff --git a/fs/fs_struct.c b/fs/fs_struct.c
59529 index 7dca743..543d620 100644
59530 --- a/fs/fs_struct.c
59531 +++ b/fs/fs_struct.c
59532 @@ -4,6 +4,7 @@
59533 #include <linux/path.h>
59534 #include <linux/slab.h>
59535 #include <linux/fs_struct.h>
59536 +#include <linux/grsecurity.h>
59537 #include "internal.h"
59538
59539 /*
59540 @@ -19,6 +20,7 @@ void set_fs_root(struct fs_struct *fs, const struct path *path)
59541 write_seqcount_begin(&fs->seq);
59542 old_root = fs->root;
59543 fs->root = *path;
59544 + gr_set_chroot_entries(current, path);
59545 write_seqcount_end(&fs->seq);
59546 spin_unlock(&fs->lock);
59547 if (old_root.dentry)
59548 @@ -67,6 +69,10 @@ void chroot_fs_refs(const struct path *old_root, const struct path *new_root)
59549 int hits = 0;
59550 spin_lock(&fs->lock);
59551 write_seqcount_begin(&fs->seq);
59552 + /* this root replacement is only done by pivot_root,
59553 + leave grsec's chroot tagging alone for this task
59554 + so that a pivoted root isn't treated as a chroot
59555 + */
59556 hits += replace_path(&fs->root, old_root, new_root);
59557 hits += replace_path(&fs->pwd, old_root, new_root);
59558 write_seqcount_end(&fs->seq);
59559 @@ -99,7 +105,8 @@ void exit_fs(struct task_struct *tsk)
59560 task_lock(tsk);
59561 spin_lock(&fs->lock);
59562 tsk->fs = NULL;
59563 - kill = !--fs->users;
59564 + gr_clear_chroot_entries(tsk);
59565 + kill = !atomic_dec_return(&fs->users);
59566 spin_unlock(&fs->lock);
59567 task_unlock(tsk);
59568 if (kill)
59569 @@ -112,7 +119,7 @@ struct fs_struct *copy_fs_struct(struct fs_struct *old)
59570 struct fs_struct *fs = kmem_cache_alloc(fs_cachep, GFP_KERNEL);
59571 /* We don't need to lock fs - think why ;-) */
59572 if (fs) {
59573 - fs->users = 1;
59574 + atomic_set(&fs->users, 1);
59575 fs->in_exec = 0;
59576 spin_lock_init(&fs->lock);
59577 seqcount_init(&fs->seq);
59578 @@ -121,6 +128,9 @@ struct fs_struct *copy_fs_struct(struct fs_struct *old)
59579 spin_lock(&old->lock);
59580 fs->root = old->root;
59581 path_get(&fs->root);
59582 + /* instead of calling gr_set_chroot_entries here,
59583 + we call it from every caller of this function
59584 + */
59585 fs->pwd = old->pwd;
59586 path_get(&fs->pwd);
59587 spin_unlock(&old->lock);
59588 @@ -139,8 +149,9 @@ int unshare_fs_struct(void)
59589
59590 task_lock(current);
59591 spin_lock(&fs->lock);
59592 - kill = !--fs->users;
59593 + kill = !atomic_dec_return(&fs->users);
59594 current->fs = new_fs;
59595 + gr_set_chroot_entries(current, &new_fs->root);
59596 spin_unlock(&fs->lock);
59597 task_unlock(current);
59598
59599 @@ -153,13 +164,13 @@ EXPORT_SYMBOL_GPL(unshare_fs_struct);
59600
59601 int current_umask(void)
59602 {
59603 - return current->fs->umask;
59604 + return current->fs->umask | gr_acl_umask();
59605 }
59606 EXPORT_SYMBOL(current_umask);
59607
59608 /* to be mentioned only in INIT_TASK */
59609 struct fs_struct init_fs = {
59610 - .users = 1,
59611 + .users = ATOMIC_INIT(1),
59612 .lock = __SPIN_LOCK_UNLOCKED(init_fs.lock),
59613 .seq = SEQCNT_ZERO(init_fs.seq),
59614 .umask = 0022,
59615 diff --git a/fs/fscache/cookie.c b/fs/fscache/cookie.c
59616 index 29d7feb..303644d 100644
59617 --- a/fs/fscache/cookie.c
59618 +++ b/fs/fscache/cookie.c
59619 @@ -19,7 +19,7 @@
59620
59621 struct kmem_cache *fscache_cookie_jar;
59622
59623 -static atomic_t fscache_object_debug_id = ATOMIC_INIT(0);
59624 +static atomic_unchecked_t fscache_object_debug_id = ATOMIC_INIT(0);
59625
59626 static int fscache_acquire_non_index_cookie(struct fscache_cookie *cookie);
59627 static int fscache_alloc_object(struct fscache_cache *cache,
59628 @@ -69,11 +69,11 @@ struct fscache_cookie *__fscache_acquire_cookie(
59629 parent ? (char *) parent->def->name : "<no-parent>",
59630 def->name, netfs_data, enable);
59631
59632 - fscache_stat(&fscache_n_acquires);
59633 + fscache_stat_unchecked(&fscache_n_acquires);
59634
59635 /* if there's no parent cookie, then we don't create one here either */
59636 if (!parent) {
59637 - fscache_stat(&fscache_n_acquires_null);
59638 + fscache_stat_unchecked(&fscache_n_acquires_null);
59639 _leave(" [no parent]");
59640 return NULL;
59641 }
59642 @@ -88,7 +88,7 @@ struct fscache_cookie *__fscache_acquire_cookie(
59643 /* allocate and initialise a cookie */
59644 cookie = kmem_cache_alloc(fscache_cookie_jar, GFP_KERNEL);
59645 if (!cookie) {
59646 - fscache_stat(&fscache_n_acquires_oom);
59647 + fscache_stat_unchecked(&fscache_n_acquires_oom);
59648 _leave(" [ENOMEM]");
59649 return NULL;
59650 }
59651 @@ -115,13 +115,13 @@ struct fscache_cookie *__fscache_acquire_cookie(
59652
59653 switch (cookie->def->type) {
59654 case FSCACHE_COOKIE_TYPE_INDEX:
59655 - fscache_stat(&fscache_n_cookie_index);
59656 + fscache_stat_unchecked(&fscache_n_cookie_index);
59657 break;
59658 case FSCACHE_COOKIE_TYPE_DATAFILE:
59659 - fscache_stat(&fscache_n_cookie_data);
59660 + fscache_stat_unchecked(&fscache_n_cookie_data);
59661 break;
59662 default:
59663 - fscache_stat(&fscache_n_cookie_special);
59664 + fscache_stat_unchecked(&fscache_n_cookie_special);
59665 break;
59666 }
59667
59668 @@ -135,7 +135,7 @@ struct fscache_cookie *__fscache_acquire_cookie(
59669 } else {
59670 atomic_dec(&parent->n_children);
59671 __fscache_cookie_put(cookie);
59672 - fscache_stat(&fscache_n_acquires_nobufs);
59673 + fscache_stat_unchecked(&fscache_n_acquires_nobufs);
59674 _leave(" = NULL");
59675 return NULL;
59676 }
59677 @@ -144,7 +144,7 @@ struct fscache_cookie *__fscache_acquire_cookie(
59678 }
59679 }
59680
59681 - fscache_stat(&fscache_n_acquires_ok);
59682 + fscache_stat_unchecked(&fscache_n_acquires_ok);
59683 _leave(" = %p", cookie);
59684 return cookie;
59685 }
59686 @@ -213,7 +213,7 @@ static int fscache_acquire_non_index_cookie(struct fscache_cookie *cookie)
59687 cache = fscache_select_cache_for_object(cookie->parent);
59688 if (!cache) {
59689 up_read(&fscache_addremove_sem);
59690 - fscache_stat(&fscache_n_acquires_no_cache);
59691 + fscache_stat_unchecked(&fscache_n_acquires_no_cache);
59692 _leave(" = -ENOMEDIUM [no cache]");
59693 return -ENOMEDIUM;
59694 }
59695 @@ -297,14 +297,14 @@ static int fscache_alloc_object(struct fscache_cache *cache,
59696 object = cache->ops->alloc_object(cache, cookie);
59697 fscache_stat_d(&fscache_n_cop_alloc_object);
59698 if (IS_ERR(object)) {
59699 - fscache_stat(&fscache_n_object_no_alloc);
59700 + fscache_stat_unchecked(&fscache_n_object_no_alloc);
59701 ret = PTR_ERR(object);
59702 goto error;
59703 }
59704
59705 - fscache_stat(&fscache_n_object_alloc);
59706 + fscache_stat_unchecked(&fscache_n_object_alloc);
59707
59708 - object->debug_id = atomic_inc_return(&fscache_object_debug_id);
59709 + object->debug_id = atomic_inc_return_unchecked(&fscache_object_debug_id);
59710
59711 _debug("ALLOC OBJ%x: %s {%lx}",
59712 object->debug_id, cookie->def->name, object->events);
59713 @@ -418,7 +418,7 @@ void __fscache_invalidate(struct fscache_cookie *cookie)
59714
59715 _enter("{%s}", cookie->def->name);
59716
59717 - fscache_stat(&fscache_n_invalidates);
59718 + fscache_stat_unchecked(&fscache_n_invalidates);
59719
59720 /* Only permit invalidation of data files. Invalidating an index will
59721 * require the caller to release all its attachments to the tree rooted
59722 @@ -477,10 +477,10 @@ void __fscache_update_cookie(struct fscache_cookie *cookie)
59723 {
59724 struct fscache_object *object;
59725
59726 - fscache_stat(&fscache_n_updates);
59727 + fscache_stat_unchecked(&fscache_n_updates);
59728
59729 if (!cookie) {
59730 - fscache_stat(&fscache_n_updates_null);
59731 + fscache_stat_unchecked(&fscache_n_updates_null);
59732 _leave(" [no cookie]");
59733 return;
59734 }
59735 @@ -581,12 +581,12 @@ EXPORT_SYMBOL(__fscache_disable_cookie);
59736 */
59737 void __fscache_relinquish_cookie(struct fscache_cookie *cookie, bool retire)
59738 {
59739 - fscache_stat(&fscache_n_relinquishes);
59740 + fscache_stat_unchecked(&fscache_n_relinquishes);
59741 if (retire)
59742 - fscache_stat(&fscache_n_relinquishes_retire);
59743 + fscache_stat_unchecked(&fscache_n_relinquishes_retire);
59744
59745 if (!cookie) {
59746 - fscache_stat(&fscache_n_relinquishes_null);
59747 + fscache_stat_unchecked(&fscache_n_relinquishes_null);
59748 _leave(" [no cookie]");
59749 return;
59750 }
59751 @@ -687,7 +687,7 @@ int __fscache_check_consistency(struct fscache_cookie *cookie)
59752 if (test_bit(FSCACHE_IOERROR, &object->cache->flags))
59753 goto inconsistent;
59754
59755 - op->debug_id = atomic_inc_return(&fscache_op_debug_id);
59756 + op->debug_id = atomic_inc_return_unchecked(&fscache_op_debug_id);
59757
59758 __fscache_use_cookie(cookie);
59759 if (fscache_submit_op(object, op) < 0)
59760 diff --git a/fs/fscache/internal.h b/fs/fscache/internal.h
59761 index 4226f66..0fb3f45 100644
59762 --- a/fs/fscache/internal.h
59763 +++ b/fs/fscache/internal.h
59764 @@ -133,8 +133,8 @@ extern void fscache_operation_gc(struct work_struct *);
59765 extern int fscache_wait_for_deferred_lookup(struct fscache_cookie *);
59766 extern int fscache_wait_for_operation_activation(struct fscache_object *,
59767 struct fscache_operation *,
59768 - atomic_t *,
59769 - atomic_t *,
59770 + atomic_unchecked_t *,
59771 + atomic_unchecked_t *,
59772 void (*)(struct fscache_operation *));
59773 extern void fscache_invalidate_writes(struct fscache_cookie *);
59774
59775 @@ -153,101 +153,101 @@ extern void fscache_proc_cleanup(void);
59776 * stats.c
59777 */
59778 #ifdef CONFIG_FSCACHE_STATS
59779 -extern atomic_t fscache_n_ops_processed[FSCACHE_MAX_THREADS];
59780 -extern atomic_t fscache_n_objs_processed[FSCACHE_MAX_THREADS];
59781 +extern atomic_unchecked_t fscache_n_ops_processed[FSCACHE_MAX_THREADS];
59782 +extern atomic_unchecked_t fscache_n_objs_processed[FSCACHE_MAX_THREADS];
59783
59784 -extern atomic_t fscache_n_op_pend;
59785 -extern atomic_t fscache_n_op_run;
59786 -extern atomic_t fscache_n_op_enqueue;
59787 -extern atomic_t fscache_n_op_deferred_release;
59788 -extern atomic_t fscache_n_op_release;
59789 -extern atomic_t fscache_n_op_gc;
59790 -extern atomic_t fscache_n_op_cancelled;
59791 -extern atomic_t fscache_n_op_rejected;
59792 +extern atomic_unchecked_t fscache_n_op_pend;
59793 +extern atomic_unchecked_t fscache_n_op_run;
59794 +extern atomic_unchecked_t fscache_n_op_enqueue;
59795 +extern atomic_unchecked_t fscache_n_op_deferred_release;
59796 +extern atomic_unchecked_t fscache_n_op_release;
59797 +extern atomic_unchecked_t fscache_n_op_gc;
59798 +extern atomic_unchecked_t fscache_n_op_cancelled;
59799 +extern atomic_unchecked_t fscache_n_op_rejected;
59800
59801 -extern atomic_t fscache_n_attr_changed;
59802 -extern atomic_t fscache_n_attr_changed_ok;
59803 -extern atomic_t fscache_n_attr_changed_nobufs;
59804 -extern atomic_t fscache_n_attr_changed_nomem;
59805 -extern atomic_t fscache_n_attr_changed_calls;
59806 +extern atomic_unchecked_t fscache_n_attr_changed;
59807 +extern atomic_unchecked_t fscache_n_attr_changed_ok;
59808 +extern atomic_unchecked_t fscache_n_attr_changed_nobufs;
59809 +extern atomic_unchecked_t fscache_n_attr_changed_nomem;
59810 +extern atomic_unchecked_t fscache_n_attr_changed_calls;
59811
59812 -extern atomic_t fscache_n_allocs;
59813 -extern atomic_t fscache_n_allocs_ok;
59814 -extern atomic_t fscache_n_allocs_wait;
59815 -extern atomic_t fscache_n_allocs_nobufs;
59816 -extern atomic_t fscache_n_allocs_intr;
59817 -extern atomic_t fscache_n_allocs_object_dead;
59818 -extern atomic_t fscache_n_alloc_ops;
59819 -extern atomic_t fscache_n_alloc_op_waits;
59820 +extern atomic_unchecked_t fscache_n_allocs;
59821 +extern atomic_unchecked_t fscache_n_allocs_ok;
59822 +extern atomic_unchecked_t fscache_n_allocs_wait;
59823 +extern atomic_unchecked_t fscache_n_allocs_nobufs;
59824 +extern atomic_unchecked_t fscache_n_allocs_intr;
59825 +extern atomic_unchecked_t fscache_n_allocs_object_dead;
59826 +extern atomic_unchecked_t fscache_n_alloc_ops;
59827 +extern atomic_unchecked_t fscache_n_alloc_op_waits;
59828
59829 -extern atomic_t fscache_n_retrievals;
59830 -extern atomic_t fscache_n_retrievals_ok;
59831 -extern atomic_t fscache_n_retrievals_wait;
59832 -extern atomic_t fscache_n_retrievals_nodata;
59833 -extern atomic_t fscache_n_retrievals_nobufs;
59834 -extern atomic_t fscache_n_retrievals_intr;
59835 -extern atomic_t fscache_n_retrievals_nomem;
59836 -extern atomic_t fscache_n_retrievals_object_dead;
59837 -extern atomic_t fscache_n_retrieval_ops;
59838 -extern atomic_t fscache_n_retrieval_op_waits;
59839 +extern atomic_unchecked_t fscache_n_retrievals;
59840 +extern atomic_unchecked_t fscache_n_retrievals_ok;
59841 +extern atomic_unchecked_t fscache_n_retrievals_wait;
59842 +extern atomic_unchecked_t fscache_n_retrievals_nodata;
59843 +extern atomic_unchecked_t fscache_n_retrievals_nobufs;
59844 +extern atomic_unchecked_t fscache_n_retrievals_intr;
59845 +extern atomic_unchecked_t fscache_n_retrievals_nomem;
59846 +extern atomic_unchecked_t fscache_n_retrievals_object_dead;
59847 +extern atomic_unchecked_t fscache_n_retrieval_ops;
59848 +extern atomic_unchecked_t fscache_n_retrieval_op_waits;
59849
59850 -extern atomic_t fscache_n_stores;
59851 -extern atomic_t fscache_n_stores_ok;
59852 -extern atomic_t fscache_n_stores_again;
59853 -extern atomic_t fscache_n_stores_nobufs;
59854 -extern atomic_t fscache_n_stores_oom;
59855 -extern atomic_t fscache_n_store_ops;
59856 -extern atomic_t fscache_n_store_calls;
59857 -extern atomic_t fscache_n_store_pages;
59858 -extern atomic_t fscache_n_store_radix_deletes;
59859 -extern atomic_t fscache_n_store_pages_over_limit;
59860 +extern atomic_unchecked_t fscache_n_stores;
59861 +extern atomic_unchecked_t fscache_n_stores_ok;
59862 +extern atomic_unchecked_t fscache_n_stores_again;
59863 +extern atomic_unchecked_t fscache_n_stores_nobufs;
59864 +extern atomic_unchecked_t fscache_n_stores_oom;
59865 +extern atomic_unchecked_t fscache_n_store_ops;
59866 +extern atomic_unchecked_t fscache_n_store_calls;
59867 +extern atomic_unchecked_t fscache_n_store_pages;
59868 +extern atomic_unchecked_t fscache_n_store_radix_deletes;
59869 +extern atomic_unchecked_t fscache_n_store_pages_over_limit;
59870
59871 -extern atomic_t fscache_n_store_vmscan_not_storing;
59872 -extern atomic_t fscache_n_store_vmscan_gone;
59873 -extern atomic_t fscache_n_store_vmscan_busy;
59874 -extern atomic_t fscache_n_store_vmscan_cancelled;
59875 -extern atomic_t fscache_n_store_vmscan_wait;
59876 +extern atomic_unchecked_t fscache_n_store_vmscan_not_storing;
59877 +extern atomic_unchecked_t fscache_n_store_vmscan_gone;
59878 +extern atomic_unchecked_t fscache_n_store_vmscan_busy;
59879 +extern atomic_unchecked_t fscache_n_store_vmscan_cancelled;
59880 +extern atomic_unchecked_t fscache_n_store_vmscan_wait;
59881
59882 -extern atomic_t fscache_n_marks;
59883 -extern atomic_t fscache_n_uncaches;
59884 +extern atomic_unchecked_t fscache_n_marks;
59885 +extern atomic_unchecked_t fscache_n_uncaches;
59886
59887 -extern atomic_t fscache_n_acquires;
59888 -extern atomic_t fscache_n_acquires_null;
59889 -extern atomic_t fscache_n_acquires_no_cache;
59890 -extern atomic_t fscache_n_acquires_ok;
59891 -extern atomic_t fscache_n_acquires_nobufs;
59892 -extern atomic_t fscache_n_acquires_oom;
59893 +extern atomic_unchecked_t fscache_n_acquires;
59894 +extern atomic_unchecked_t fscache_n_acquires_null;
59895 +extern atomic_unchecked_t fscache_n_acquires_no_cache;
59896 +extern atomic_unchecked_t fscache_n_acquires_ok;
59897 +extern atomic_unchecked_t fscache_n_acquires_nobufs;
59898 +extern atomic_unchecked_t fscache_n_acquires_oom;
59899
59900 -extern atomic_t fscache_n_invalidates;
59901 -extern atomic_t fscache_n_invalidates_run;
59902 +extern atomic_unchecked_t fscache_n_invalidates;
59903 +extern atomic_unchecked_t fscache_n_invalidates_run;
59904
59905 -extern atomic_t fscache_n_updates;
59906 -extern atomic_t fscache_n_updates_null;
59907 -extern atomic_t fscache_n_updates_run;
59908 +extern atomic_unchecked_t fscache_n_updates;
59909 +extern atomic_unchecked_t fscache_n_updates_null;
59910 +extern atomic_unchecked_t fscache_n_updates_run;
59911
59912 -extern atomic_t fscache_n_relinquishes;
59913 -extern atomic_t fscache_n_relinquishes_null;
59914 -extern atomic_t fscache_n_relinquishes_waitcrt;
59915 -extern atomic_t fscache_n_relinquishes_retire;
59916 +extern atomic_unchecked_t fscache_n_relinquishes;
59917 +extern atomic_unchecked_t fscache_n_relinquishes_null;
59918 +extern atomic_unchecked_t fscache_n_relinquishes_waitcrt;
59919 +extern atomic_unchecked_t fscache_n_relinquishes_retire;
59920
59921 -extern atomic_t fscache_n_cookie_index;
59922 -extern atomic_t fscache_n_cookie_data;
59923 -extern atomic_t fscache_n_cookie_special;
59924 +extern atomic_unchecked_t fscache_n_cookie_index;
59925 +extern atomic_unchecked_t fscache_n_cookie_data;
59926 +extern atomic_unchecked_t fscache_n_cookie_special;
59927
59928 -extern atomic_t fscache_n_object_alloc;
59929 -extern atomic_t fscache_n_object_no_alloc;
59930 -extern atomic_t fscache_n_object_lookups;
59931 -extern atomic_t fscache_n_object_lookups_negative;
59932 -extern atomic_t fscache_n_object_lookups_positive;
59933 -extern atomic_t fscache_n_object_lookups_timed_out;
59934 -extern atomic_t fscache_n_object_created;
59935 -extern atomic_t fscache_n_object_avail;
59936 -extern atomic_t fscache_n_object_dead;
59937 +extern atomic_unchecked_t fscache_n_object_alloc;
59938 +extern atomic_unchecked_t fscache_n_object_no_alloc;
59939 +extern atomic_unchecked_t fscache_n_object_lookups;
59940 +extern atomic_unchecked_t fscache_n_object_lookups_negative;
59941 +extern atomic_unchecked_t fscache_n_object_lookups_positive;
59942 +extern atomic_unchecked_t fscache_n_object_lookups_timed_out;
59943 +extern atomic_unchecked_t fscache_n_object_created;
59944 +extern atomic_unchecked_t fscache_n_object_avail;
59945 +extern atomic_unchecked_t fscache_n_object_dead;
59946
59947 -extern atomic_t fscache_n_checkaux_none;
59948 -extern atomic_t fscache_n_checkaux_okay;
59949 -extern atomic_t fscache_n_checkaux_update;
59950 -extern atomic_t fscache_n_checkaux_obsolete;
59951 +extern atomic_unchecked_t fscache_n_checkaux_none;
59952 +extern atomic_unchecked_t fscache_n_checkaux_okay;
59953 +extern atomic_unchecked_t fscache_n_checkaux_update;
59954 +extern atomic_unchecked_t fscache_n_checkaux_obsolete;
59955
59956 extern atomic_t fscache_n_cop_alloc_object;
59957 extern atomic_t fscache_n_cop_lookup_object;
59958 @@ -272,6 +272,11 @@ static inline void fscache_stat(atomic_t *stat)
59959 atomic_inc(stat);
59960 }
59961
59962 +static inline void fscache_stat_unchecked(atomic_unchecked_t *stat)
59963 +{
59964 + atomic_inc_unchecked(stat);
59965 +}
59966 +
59967 static inline void fscache_stat_d(atomic_t *stat)
59968 {
59969 atomic_dec(stat);
59970 @@ -284,6 +289,7 @@ extern const struct file_operations fscache_stats_fops;
59971
59972 #define __fscache_stat(stat) (NULL)
59973 #define fscache_stat(stat) do {} while (0)
59974 +#define fscache_stat_unchecked(stat) do {} while (0)
59975 #define fscache_stat_d(stat) do {} while (0)
59976 #endif
59977
59978 diff --git a/fs/fscache/object.c b/fs/fscache/object.c
59979 index d3b4539..ed0c659 100644
59980 --- a/fs/fscache/object.c
59981 +++ b/fs/fscache/object.c
59982 @@ -454,7 +454,7 @@ static const struct fscache_state *fscache_look_up_object(struct fscache_object
59983 _debug("LOOKUP \"%s\" in \"%s\"",
59984 cookie->def->name, object->cache->tag->name);
59985
59986 - fscache_stat(&fscache_n_object_lookups);
59987 + fscache_stat_unchecked(&fscache_n_object_lookups);
59988 fscache_stat(&fscache_n_cop_lookup_object);
59989 ret = object->cache->ops->lookup_object(object);
59990 fscache_stat_d(&fscache_n_cop_lookup_object);
59991 @@ -464,7 +464,7 @@ static const struct fscache_state *fscache_look_up_object(struct fscache_object
59992 if (ret == -ETIMEDOUT) {
59993 /* probably stuck behind another object, so move this one to
59994 * the back of the queue */
59995 - fscache_stat(&fscache_n_object_lookups_timed_out);
59996 + fscache_stat_unchecked(&fscache_n_object_lookups_timed_out);
59997 _leave(" [timeout]");
59998 return NO_TRANSIT;
59999 }
60000 @@ -492,7 +492,7 @@ void fscache_object_lookup_negative(struct fscache_object *object)
60001 _enter("{OBJ%x,%s}", object->debug_id, object->state->name);
60002
60003 if (!test_and_set_bit(FSCACHE_OBJECT_IS_LOOKED_UP, &object->flags)) {
60004 - fscache_stat(&fscache_n_object_lookups_negative);
60005 + fscache_stat_unchecked(&fscache_n_object_lookups_negative);
60006
60007 /* Allow write requests to begin stacking up and read requests to begin
60008 * returning ENODATA.
60009 @@ -527,7 +527,7 @@ void fscache_obtained_object(struct fscache_object *object)
60010 /* if we were still looking up, then we must have a positive lookup
60011 * result, in which case there may be data available */
60012 if (!test_and_set_bit(FSCACHE_OBJECT_IS_LOOKED_UP, &object->flags)) {
60013 - fscache_stat(&fscache_n_object_lookups_positive);
60014 + fscache_stat_unchecked(&fscache_n_object_lookups_positive);
60015
60016 /* We do (presumably) have data */
60017 clear_bit_unlock(FSCACHE_COOKIE_NO_DATA_YET, &cookie->flags);
60018 @@ -539,7 +539,7 @@ void fscache_obtained_object(struct fscache_object *object)
60019 clear_bit_unlock(FSCACHE_COOKIE_LOOKING_UP, &cookie->flags);
60020 wake_up_bit(&cookie->flags, FSCACHE_COOKIE_LOOKING_UP);
60021 } else {
60022 - fscache_stat(&fscache_n_object_created);
60023 + fscache_stat_unchecked(&fscache_n_object_created);
60024 }
60025
60026 set_bit(FSCACHE_OBJECT_IS_AVAILABLE, &object->flags);
60027 @@ -575,7 +575,7 @@ static const struct fscache_state *fscache_object_available(struct fscache_objec
60028 fscache_stat_d(&fscache_n_cop_lookup_complete);
60029
60030 fscache_hist(fscache_obj_instantiate_histogram, object->lookup_jif);
60031 - fscache_stat(&fscache_n_object_avail);
60032 + fscache_stat_unchecked(&fscache_n_object_avail);
60033
60034 _leave("");
60035 return transit_to(JUMPSTART_DEPS);
60036 @@ -722,7 +722,7 @@ static const struct fscache_state *fscache_drop_object(struct fscache_object *ob
60037
60038 /* this just shifts the object release to the work processor */
60039 fscache_put_object(object);
60040 - fscache_stat(&fscache_n_object_dead);
60041 + fscache_stat_unchecked(&fscache_n_object_dead);
60042
60043 _leave("");
60044 return transit_to(OBJECT_DEAD);
60045 @@ -887,7 +887,7 @@ enum fscache_checkaux fscache_check_aux(struct fscache_object *object,
60046 enum fscache_checkaux result;
60047
60048 if (!object->cookie->def->check_aux) {
60049 - fscache_stat(&fscache_n_checkaux_none);
60050 + fscache_stat_unchecked(&fscache_n_checkaux_none);
60051 return FSCACHE_CHECKAUX_OKAY;
60052 }
60053
60054 @@ -896,17 +896,17 @@ enum fscache_checkaux fscache_check_aux(struct fscache_object *object,
60055 switch (result) {
60056 /* entry okay as is */
60057 case FSCACHE_CHECKAUX_OKAY:
60058 - fscache_stat(&fscache_n_checkaux_okay);
60059 + fscache_stat_unchecked(&fscache_n_checkaux_okay);
60060 break;
60061
60062 /* entry requires update */
60063 case FSCACHE_CHECKAUX_NEEDS_UPDATE:
60064 - fscache_stat(&fscache_n_checkaux_update);
60065 + fscache_stat_unchecked(&fscache_n_checkaux_update);
60066 break;
60067
60068 /* entry requires deletion */
60069 case FSCACHE_CHECKAUX_OBSOLETE:
60070 - fscache_stat(&fscache_n_checkaux_obsolete);
60071 + fscache_stat_unchecked(&fscache_n_checkaux_obsolete);
60072 break;
60073
60074 default:
60075 @@ -992,7 +992,7 @@ static const struct fscache_state *fscache_invalidate_object(struct fscache_obje
60076 {
60077 const struct fscache_state *s;
60078
60079 - fscache_stat(&fscache_n_invalidates_run);
60080 + fscache_stat_unchecked(&fscache_n_invalidates_run);
60081 fscache_stat(&fscache_n_cop_invalidate_object);
60082 s = _fscache_invalidate_object(object, event);
60083 fscache_stat_d(&fscache_n_cop_invalidate_object);
60084 @@ -1007,7 +1007,7 @@ static const struct fscache_state *fscache_update_object(struct fscache_object *
60085 {
60086 _enter("{OBJ%x},%d", object->debug_id, event);
60087
60088 - fscache_stat(&fscache_n_updates_run);
60089 + fscache_stat_unchecked(&fscache_n_updates_run);
60090 fscache_stat(&fscache_n_cop_update_object);
60091 object->cache->ops->update_object(object);
60092 fscache_stat_d(&fscache_n_cop_update_object);
60093 diff --git a/fs/fscache/operation.c b/fs/fscache/operation.c
60094 index 318071a..379938b 100644
60095 --- a/fs/fscache/operation.c
60096 +++ b/fs/fscache/operation.c
60097 @@ -17,7 +17,7 @@
60098 #include <linux/slab.h>
60099 #include "internal.h"
60100
60101 -atomic_t fscache_op_debug_id;
60102 +atomic_unchecked_t fscache_op_debug_id;
60103 EXPORT_SYMBOL(fscache_op_debug_id);
60104
60105 /**
60106 @@ -39,7 +39,7 @@ void fscache_enqueue_operation(struct fscache_operation *op)
60107 ASSERTCMP(atomic_read(&op->usage), >, 0);
60108 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_IN_PROGRESS);
60109
60110 - fscache_stat(&fscache_n_op_enqueue);
60111 + fscache_stat_unchecked(&fscache_n_op_enqueue);
60112 switch (op->flags & FSCACHE_OP_TYPE) {
60113 case FSCACHE_OP_ASYNC:
60114 _debug("queue async");
60115 @@ -73,7 +73,7 @@ static void fscache_run_op(struct fscache_object *object,
60116 wake_up_bit(&op->flags, FSCACHE_OP_WAITING);
60117 if (op->processor)
60118 fscache_enqueue_operation(op);
60119 - fscache_stat(&fscache_n_op_run);
60120 + fscache_stat_unchecked(&fscache_n_op_run);
60121 }
60122
60123 /*
60124 @@ -105,11 +105,11 @@ int fscache_submit_exclusive_op(struct fscache_object *object,
60125 if (object->n_in_progress > 0) {
60126 atomic_inc(&op->usage);
60127 list_add_tail(&op->pend_link, &object->pending_ops);
60128 - fscache_stat(&fscache_n_op_pend);
60129 + fscache_stat_unchecked(&fscache_n_op_pend);
60130 } else if (!list_empty(&object->pending_ops)) {
60131 atomic_inc(&op->usage);
60132 list_add_tail(&op->pend_link, &object->pending_ops);
60133 - fscache_stat(&fscache_n_op_pend);
60134 + fscache_stat_unchecked(&fscache_n_op_pend);
60135 fscache_start_operations(object);
60136 } else {
60137 ASSERTCMP(object->n_in_progress, ==, 0);
60138 @@ -125,7 +125,7 @@ int fscache_submit_exclusive_op(struct fscache_object *object,
60139 object->n_exclusive++; /* reads and writes must wait */
60140 atomic_inc(&op->usage);
60141 list_add_tail(&op->pend_link, &object->pending_ops);
60142 - fscache_stat(&fscache_n_op_pend);
60143 + fscache_stat_unchecked(&fscache_n_op_pend);
60144 ret = 0;
60145 } else {
60146 /* If we're in any other state, there must have been an I/O
60147 @@ -212,11 +212,11 @@ int fscache_submit_op(struct fscache_object *object,
60148 if (object->n_exclusive > 0) {
60149 atomic_inc(&op->usage);
60150 list_add_tail(&op->pend_link, &object->pending_ops);
60151 - fscache_stat(&fscache_n_op_pend);
60152 + fscache_stat_unchecked(&fscache_n_op_pend);
60153 } else if (!list_empty(&object->pending_ops)) {
60154 atomic_inc(&op->usage);
60155 list_add_tail(&op->pend_link, &object->pending_ops);
60156 - fscache_stat(&fscache_n_op_pend);
60157 + fscache_stat_unchecked(&fscache_n_op_pend);
60158 fscache_start_operations(object);
60159 } else {
60160 ASSERTCMP(object->n_exclusive, ==, 0);
60161 @@ -228,10 +228,10 @@ int fscache_submit_op(struct fscache_object *object,
60162 object->n_ops++;
60163 atomic_inc(&op->usage);
60164 list_add_tail(&op->pend_link, &object->pending_ops);
60165 - fscache_stat(&fscache_n_op_pend);
60166 + fscache_stat_unchecked(&fscache_n_op_pend);
60167 ret = 0;
60168 } else if (fscache_object_is_dying(object)) {
60169 - fscache_stat(&fscache_n_op_rejected);
60170 + fscache_stat_unchecked(&fscache_n_op_rejected);
60171 op->state = FSCACHE_OP_ST_CANCELLED;
60172 ret = -ENOBUFS;
60173 } else if (!test_bit(FSCACHE_IOERROR, &object->cache->flags)) {
60174 @@ -310,7 +310,7 @@ int fscache_cancel_op(struct fscache_operation *op,
60175 ret = -EBUSY;
60176 if (op->state == FSCACHE_OP_ST_PENDING) {
60177 ASSERT(!list_empty(&op->pend_link));
60178 - fscache_stat(&fscache_n_op_cancelled);
60179 + fscache_stat_unchecked(&fscache_n_op_cancelled);
60180 list_del_init(&op->pend_link);
60181 if (do_cancel)
60182 do_cancel(op);
60183 @@ -342,7 +342,7 @@ void fscache_cancel_all_ops(struct fscache_object *object)
60184 while (!list_empty(&object->pending_ops)) {
60185 op = list_entry(object->pending_ops.next,
60186 struct fscache_operation, pend_link);
60187 - fscache_stat(&fscache_n_op_cancelled);
60188 + fscache_stat_unchecked(&fscache_n_op_cancelled);
60189 list_del_init(&op->pend_link);
60190
60191 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_PENDING);
60192 @@ -414,7 +414,7 @@ void fscache_put_operation(struct fscache_operation *op)
60193 op->state, ==, FSCACHE_OP_ST_CANCELLED);
60194 op->state = FSCACHE_OP_ST_DEAD;
60195
60196 - fscache_stat(&fscache_n_op_release);
60197 + fscache_stat_unchecked(&fscache_n_op_release);
60198
60199 if (op->release) {
60200 op->release(op);
60201 @@ -433,7 +433,7 @@ void fscache_put_operation(struct fscache_operation *op)
60202 * lock, and defer it otherwise */
60203 if (!spin_trylock(&object->lock)) {
60204 _debug("defer put");
60205 - fscache_stat(&fscache_n_op_deferred_release);
60206 + fscache_stat_unchecked(&fscache_n_op_deferred_release);
60207
60208 cache = object->cache;
60209 spin_lock(&cache->op_gc_list_lock);
60210 @@ -486,7 +486,7 @@ void fscache_operation_gc(struct work_struct *work)
60211
60212 _debug("GC DEFERRED REL OBJ%x OP%x",
60213 object->debug_id, op->debug_id);
60214 - fscache_stat(&fscache_n_op_gc);
60215 + fscache_stat_unchecked(&fscache_n_op_gc);
60216
60217 ASSERTCMP(atomic_read(&op->usage), ==, 0);
60218 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_DEAD);
60219 diff --git a/fs/fscache/page.c b/fs/fscache/page.c
60220 index 7f5c658..6c1e164 100644
60221 --- a/fs/fscache/page.c
60222 +++ b/fs/fscache/page.c
60223 @@ -61,7 +61,7 @@ try_again:
60224 val = radix_tree_lookup(&cookie->stores, page->index);
60225 if (!val) {
60226 rcu_read_unlock();
60227 - fscache_stat(&fscache_n_store_vmscan_not_storing);
60228 + fscache_stat_unchecked(&fscache_n_store_vmscan_not_storing);
60229 __fscache_uncache_page(cookie, page);
60230 return true;
60231 }
60232 @@ -91,11 +91,11 @@ try_again:
60233 spin_unlock(&cookie->stores_lock);
60234
60235 if (xpage) {
60236 - fscache_stat(&fscache_n_store_vmscan_cancelled);
60237 - fscache_stat(&fscache_n_store_radix_deletes);
60238 + fscache_stat_unchecked(&fscache_n_store_vmscan_cancelled);
60239 + fscache_stat_unchecked(&fscache_n_store_radix_deletes);
60240 ASSERTCMP(xpage, ==, page);
60241 } else {
60242 - fscache_stat(&fscache_n_store_vmscan_gone);
60243 + fscache_stat_unchecked(&fscache_n_store_vmscan_gone);
60244 }
60245
60246 wake_up_bit(&cookie->flags, 0);
60247 @@ -110,11 +110,11 @@ page_busy:
60248 * sleeping on memory allocation, so we may need to impose a timeout
60249 * too. */
60250 if (!(gfp & __GFP_WAIT) || !(gfp & __GFP_FS)) {
60251 - fscache_stat(&fscache_n_store_vmscan_busy);
60252 + fscache_stat_unchecked(&fscache_n_store_vmscan_busy);
60253 return false;
60254 }
60255
60256 - fscache_stat(&fscache_n_store_vmscan_wait);
60257 + fscache_stat_unchecked(&fscache_n_store_vmscan_wait);
60258 __fscache_wait_on_page_write(cookie, page);
60259 gfp &= ~__GFP_WAIT;
60260 goto try_again;
60261 @@ -140,7 +140,7 @@ static void fscache_end_page_write(struct fscache_object *object,
60262 FSCACHE_COOKIE_STORING_TAG);
60263 if (!radix_tree_tag_get(&cookie->stores, page->index,
60264 FSCACHE_COOKIE_PENDING_TAG)) {
60265 - fscache_stat(&fscache_n_store_radix_deletes);
60266 + fscache_stat_unchecked(&fscache_n_store_radix_deletes);
60267 xpage = radix_tree_delete(&cookie->stores, page->index);
60268 }
60269 spin_unlock(&cookie->stores_lock);
60270 @@ -161,7 +161,7 @@ static void fscache_attr_changed_op(struct fscache_operation *op)
60271
60272 _enter("{OBJ%x OP%x}", object->debug_id, op->debug_id);
60273
60274 - fscache_stat(&fscache_n_attr_changed_calls);
60275 + fscache_stat_unchecked(&fscache_n_attr_changed_calls);
60276
60277 if (fscache_object_is_active(object)) {
60278 fscache_stat(&fscache_n_cop_attr_changed);
60279 @@ -188,11 +188,11 @@ int __fscache_attr_changed(struct fscache_cookie *cookie)
60280
60281 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
60282
60283 - fscache_stat(&fscache_n_attr_changed);
60284 + fscache_stat_unchecked(&fscache_n_attr_changed);
60285
60286 op = kzalloc(sizeof(*op), GFP_KERNEL);
60287 if (!op) {
60288 - fscache_stat(&fscache_n_attr_changed_nomem);
60289 + fscache_stat_unchecked(&fscache_n_attr_changed_nomem);
60290 _leave(" = -ENOMEM");
60291 return -ENOMEM;
60292 }
60293 @@ -214,7 +214,7 @@ int __fscache_attr_changed(struct fscache_cookie *cookie)
60294 if (fscache_submit_exclusive_op(object, op) < 0)
60295 goto nobufs;
60296 spin_unlock(&cookie->lock);
60297 - fscache_stat(&fscache_n_attr_changed_ok);
60298 + fscache_stat_unchecked(&fscache_n_attr_changed_ok);
60299 fscache_put_operation(op);
60300 _leave(" = 0");
60301 return 0;
60302 @@ -225,7 +225,7 @@ nobufs:
60303 kfree(op);
60304 if (wake_cookie)
60305 __fscache_wake_unused_cookie(cookie);
60306 - fscache_stat(&fscache_n_attr_changed_nobufs);
60307 + fscache_stat_unchecked(&fscache_n_attr_changed_nobufs);
60308 _leave(" = %d", -ENOBUFS);
60309 return -ENOBUFS;
60310 }
60311 @@ -264,7 +264,7 @@ static struct fscache_retrieval *fscache_alloc_retrieval(
60312 /* allocate a retrieval operation and attempt to submit it */
60313 op = kzalloc(sizeof(*op), GFP_NOIO);
60314 if (!op) {
60315 - fscache_stat(&fscache_n_retrievals_nomem);
60316 + fscache_stat_unchecked(&fscache_n_retrievals_nomem);
60317 return NULL;
60318 }
60319
60320 @@ -294,13 +294,13 @@ int fscache_wait_for_deferred_lookup(struct fscache_cookie *cookie)
60321 return 0;
60322 }
60323
60324 - fscache_stat(&fscache_n_retrievals_wait);
60325 + fscache_stat_unchecked(&fscache_n_retrievals_wait);
60326
60327 jif = jiffies;
60328 if (wait_on_bit(&cookie->flags, FSCACHE_COOKIE_LOOKING_UP,
60329 fscache_wait_bit_interruptible,
60330 TASK_INTERRUPTIBLE) != 0) {
60331 - fscache_stat(&fscache_n_retrievals_intr);
60332 + fscache_stat_unchecked(&fscache_n_retrievals_intr);
60333 _leave(" = -ERESTARTSYS");
60334 return -ERESTARTSYS;
60335 }
60336 @@ -329,8 +329,8 @@ static void fscache_do_cancel_retrieval(struct fscache_operation *_op)
60337 */
60338 int fscache_wait_for_operation_activation(struct fscache_object *object,
60339 struct fscache_operation *op,
60340 - atomic_t *stat_op_waits,
60341 - atomic_t *stat_object_dead,
60342 + atomic_unchecked_t *stat_op_waits,
60343 + atomic_unchecked_t *stat_object_dead,
60344 void (*do_cancel)(struct fscache_operation *))
60345 {
60346 int ret;
60347 @@ -340,7 +340,7 @@ int fscache_wait_for_operation_activation(struct fscache_object *object,
60348
60349 _debug(">>> WT");
60350 if (stat_op_waits)
60351 - fscache_stat(stat_op_waits);
60352 + fscache_stat_unchecked(stat_op_waits);
60353 if (wait_on_bit(&op->flags, FSCACHE_OP_WAITING,
60354 fscache_wait_bit_interruptible,
60355 TASK_INTERRUPTIBLE) != 0) {
60356 @@ -358,7 +358,7 @@ int fscache_wait_for_operation_activation(struct fscache_object *object,
60357 check_if_dead:
60358 if (op->state == FSCACHE_OP_ST_CANCELLED) {
60359 if (stat_object_dead)
60360 - fscache_stat(stat_object_dead);
60361 + fscache_stat_unchecked(stat_object_dead);
60362 _leave(" = -ENOBUFS [cancelled]");
60363 return -ENOBUFS;
60364 }
60365 @@ -366,7 +366,7 @@ check_if_dead:
60366 pr_err("%s() = -ENOBUFS [obj dead %d]\n", __func__, op->state);
60367 fscache_cancel_op(op, do_cancel);
60368 if (stat_object_dead)
60369 - fscache_stat(stat_object_dead);
60370 + fscache_stat_unchecked(stat_object_dead);
60371 return -ENOBUFS;
60372 }
60373 return 0;
60374 @@ -394,7 +394,7 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
60375
60376 _enter("%p,%p,,,", cookie, page);
60377
60378 - fscache_stat(&fscache_n_retrievals);
60379 + fscache_stat_unchecked(&fscache_n_retrievals);
60380
60381 if (hlist_empty(&cookie->backing_objects))
60382 goto nobufs;
60383 @@ -436,7 +436,7 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
60384 goto nobufs_unlock_dec;
60385 spin_unlock(&cookie->lock);
60386
60387 - fscache_stat(&fscache_n_retrieval_ops);
60388 + fscache_stat_unchecked(&fscache_n_retrieval_ops);
60389
60390 /* pin the netfs read context in case we need to do the actual netfs
60391 * read because we've encountered a cache read failure */
60392 @@ -467,15 +467,15 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
60393
60394 error:
60395 if (ret == -ENOMEM)
60396 - fscache_stat(&fscache_n_retrievals_nomem);
60397 + fscache_stat_unchecked(&fscache_n_retrievals_nomem);
60398 else if (ret == -ERESTARTSYS)
60399 - fscache_stat(&fscache_n_retrievals_intr);
60400 + fscache_stat_unchecked(&fscache_n_retrievals_intr);
60401 else if (ret == -ENODATA)
60402 - fscache_stat(&fscache_n_retrievals_nodata);
60403 + fscache_stat_unchecked(&fscache_n_retrievals_nodata);
60404 else if (ret < 0)
60405 - fscache_stat(&fscache_n_retrievals_nobufs);
60406 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
60407 else
60408 - fscache_stat(&fscache_n_retrievals_ok);
60409 + fscache_stat_unchecked(&fscache_n_retrievals_ok);
60410
60411 fscache_put_retrieval(op);
60412 _leave(" = %d", ret);
60413 @@ -490,7 +490,7 @@ nobufs_unlock:
60414 __fscache_wake_unused_cookie(cookie);
60415 kfree(op);
60416 nobufs:
60417 - fscache_stat(&fscache_n_retrievals_nobufs);
60418 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
60419 _leave(" = -ENOBUFS");
60420 return -ENOBUFS;
60421 }
60422 @@ -529,7 +529,7 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
60423
60424 _enter("%p,,%d,,,", cookie, *nr_pages);
60425
60426 - fscache_stat(&fscache_n_retrievals);
60427 + fscache_stat_unchecked(&fscache_n_retrievals);
60428
60429 if (hlist_empty(&cookie->backing_objects))
60430 goto nobufs;
60431 @@ -567,7 +567,7 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
60432 goto nobufs_unlock_dec;
60433 spin_unlock(&cookie->lock);
60434
60435 - fscache_stat(&fscache_n_retrieval_ops);
60436 + fscache_stat_unchecked(&fscache_n_retrieval_ops);
60437
60438 /* pin the netfs read context in case we need to do the actual netfs
60439 * read because we've encountered a cache read failure */
60440 @@ -598,15 +598,15 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
60441
60442 error:
60443 if (ret == -ENOMEM)
60444 - fscache_stat(&fscache_n_retrievals_nomem);
60445 + fscache_stat_unchecked(&fscache_n_retrievals_nomem);
60446 else if (ret == -ERESTARTSYS)
60447 - fscache_stat(&fscache_n_retrievals_intr);
60448 + fscache_stat_unchecked(&fscache_n_retrievals_intr);
60449 else if (ret == -ENODATA)
60450 - fscache_stat(&fscache_n_retrievals_nodata);
60451 + fscache_stat_unchecked(&fscache_n_retrievals_nodata);
60452 else if (ret < 0)
60453 - fscache_stat(&fscache_n_retrievals_nobufs);
60454 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
60455 else
60456 - fscache_stat(&fscache_n_retrievals_ok);
60457 + fscache_stat_unchecked(&fscache_n_retrievals_ok);
60458
60459 fscache_put_retrieval(op);
60460 _leave(" = %d", ret);
60461 @@ -621,7 +621,7 @@ nobufs_unlock:
60462 if (wake_cookie)
60463 __fscache_wake_unused_cookie(cookie);
60464 nobufs:
60465 - fscache_stat(&fscache_n_retrievals_nobufs);
60466 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
60467 _leave(" = -ENOBUFS");
60468 return -ENOBUFS;
60469 }
60470 @@ -646,7 +646,7 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
60471
60472 _enter("%p,%p,,,", cookie, page);
60473
60474 - fscache_stat(&fscache_n_allocs);
60475 + fscache_stat_unchecked(&fscache_n_allocs);
60476
60477 if (hlist_empty(&cookie->backing_objects))
60478 goto nobufs;
60479 @@ -680,7 +680,7 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
60480 goto nobufs_unlock_dec;
60481 spin_unlock(&cookie->lock);
60482
60483 - fscache_stat(&fscache_n_alloc_ops);
60484 + fscache_stat_unchecked(&fscache_n_alloc_ops);
60485
60486 ret = fscache_wait_for_operation_activation(
60487 object, &op->op,
60488 @@ -697,11 +697,11 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
60489
60490 error:
60491 if (ret == -ERESTARTSYS)
60492 - fscache_stat(&fscache_n_allocs_intr);
60493 + fscache_stat_unchecked(&fscache_n_allocs_intr);
60494 else if (ret < 0)
60495 - fscache_stat(&fscache_n_allocs_nobufs);
60496 + fscache_stat_unchecked(&fscache_n_allocs_nobufs);
60497 else
60498 - fscache_stat(&fscache_n_allocs_ok);
60499 + fscache_stat_unchecked(&fscache_n_allocs_ok);
60500
60501 fscache_put_retrieval(op);
60502 _leave(" = %d", ret);
60503 @@ -715,7 +715,7 @@ nobufs_unlock:
60504 if (wake_cookie)
60505 __fscache_wake_unused_cookie(cookie);
60506 nobufs:
60507 - fscache_stat(&fscache_n_allocs_nobufs);
60508 + fscache_stat_unchecked(&fscache_n_allocs_nobufs);
60509 _leave(" = -ENOBUFS");
60510 return -ENOBUFS;
60511 }
60512 @@ -791,7 +791,7 @@ static void fscache_write_op(struct fscache_operation *_op)
60513
60514 spin_lock(&cookie->stores_lock);
60515
60516 - fscache_stat(&fscache_n_store_calls);
60517 + fscache_stat_unchecked(&fscache_n_store_calls);
60518
60519 /* find a page to store */
60520 page = NULL;
60521 @@ -802,7 +802,7 @@ static void fscache_write_op(struct fscache_operation *_op)
60522 page = results[0];
60523 _debug("gang %d [%lx]", n, page->index);
60524 if (page->index > op->store_limit) {
60525 - fscache_stat(&fscache_n_store_pages_over_limit);
60526 + fscache_stat_unchecked(&fscache_n_store_pages_over_limit);
60527 goto superseded;
60528 }
60529
60530 @@ -814,7 +814,7 @@ static void fscache_write_op(struct fscache_operation *_op)
60531 spin_unlock(&cookie->stores_lock);
60532 spin_unlock(&object->lock);
60533
60534 - fscache_stat(&fscache_n_store_pages);
60535 + fscache_stat_unchecked(&fscache_n_store_pages);
60536 fscache_stat(&fscache_n_cop_write_page);
60537 ret = object->cache->ops->write_page(op, page);
60538 fscache_stat_d(&fscache_n_cop_write_page);
60539 @@ -918,7 +918,7 @@ int __fscache_write_page(struct fscache_cookie *cookie,
60540 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
60541 ASSERT(PageFsCache(page));
60542
60543 - fscache_stat(&fscache_n_stores);
60544 + fscache_stat_unchecked(&fscache_n_stores);
60545
60546 if (test_bit(FSCACHE_COOKIE_INVALIDATING, &cookie->flags)) {
60547 _leave(" = -ENOBUFS [invalidating]");
60548 @@ -977,7 +977,7 @@ int __fscache_write_page(struct fscache_cookie *cookie,
60549 spin_unlock(&cookie->stores_lock);
60550 spin_unlock(&object->lock);
60551
60552 - op->op.debug_id = atomic_inc_return(&fscache_op_debug_id);
60553 + op->op.debug_id = atomic_inc_return_unchecked(&fscache_op_debug_id);
60554 op->store_limit = object->store_limit;
60555
60556 __fscache_use_cookie(cookie);
60557 @@ -986,8 +986,8 @@ int __fscache_write_page(struct fscache_cookie *cookie,
60558
60559 spin_unlock(&cookie->lock);
60560 radix_tree_preload_end();
60561 - fscache_stat(&fscache_n_store_ops);
60562 - fscache_stat(&fscache_n_stores_ok);
60563 + fscache_stat_unchecked(&fscache_n_store_ops);
60564 + fscache_stat_unchecked(&fscache_n_stores_ok);
60565
60566 /* the work queue now carries its own ref on the object */
60567 fscache_put_operation(&op->op);
60568 @@ -995,14 +995,14 @@ int __fscache_write_page(struct fscache_cookie *cookie,
60569 return 0;
60570
60571 already_queued:
60572 - fscache_stat(&fscache_n_stores_again);
60573 + fscache_stat_unchecked(&fscache_n_stores_again);
60574 already_pending:
60575 spin_unlock(&cookie->stores_lock);
60576 spin_unlock(&object->lock);
60577 spin_unlock(&cookie->lock);
60578 radix_tree_preload_end();
60579 kfree(op);
60580 - fscache_stat(&fscache_n_stores_ok);
60581 + fscache_stat_unchecked(&fscache_n_stores_ok);
60582 _leave(" = 0");
60583 return 0;
60584
60585 @@ -1024,14 +1024,14 @@ nobufs:
60586 kfree(op);
60587 if (wake_cookie)
60588 __fscache_wake_unused_cookie(cookie);
60589 - fscache_stat(&fscache_n_stores_nobufs);
60590 + fscache_stat_unchecked(&fscache_n_stores_nobufs);
60591 _leave(" = -ENOBUFS");
60592 return -ENOBUFS;
60593
60594 nomem_free:
60595 kfree(op);
60596 nomem:
60597 - fscache_stat(&fscache_n_stores_oom);
60598 + fscache_stat_unchecked(&fscache_n_stores_oom);
60599 _leave(" = -ENOMEM");
60600 return -ENOMEM;
60601 }
60602 @@ -1049,7 +1049,7 @@ void __fscache_uncache_page(struct fscache_cookie *cookie, struct page *page)
60603 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
60604 ASSERTCMP(page, !=, NULL);
60605
60606 - fscache_stat(&fscache_n_uncaches);
60607 + fscache_stat_unchecked(&fscache_n_uncaches);
60608
60609 /* cache withdrawal may beat us to it */
60610 if (!PageFsCache(page))
60611 @@ -1100,7 +1100,7 @@ void fscache_mark_page_cached(struct fscache_retrieval *op, struct page *page)
60612 struct fscache_cookie *cookie = op->op.object->cookie;
60613
60614 #ifdef CONFIG_FSCACHE_STATS
60615 - atomic_inc(&fscache_n_marks);
60616 + atomic_inc_unchecked(&fscache_n_marks);
60617 #endif
60618
60619 _debug("- mark %p{%lx}", page, page->index);
60620 diff --git a/fs/fscache/stats.c b/fs/fscache/stats.c
60621 index 40d13c7..ddf52b9 100644
60622 --- a/fs/fscache/stats.c
60623 +++ b/fs/fscache/stats.c
60624 @@ -18,99 +18,99 @@
60625 /*
60626 * operation counters
60627 */
60628 -atomic_t fscache_n_op_pend;
60629 -atomic_t fscache_n_op_run;
60630 -atomic_t fscache_n_op_enqueue;
60631 -atomic_t fscache_n_op_requeue;
60632 -atomic_t fscache_n_op_deferred_release;
60633 -atomic_t fscache_n_op_release;
60634 -atomic_t fscache_n_op_gc;
60635 -atomic_t fscache_n_op_cancelled;
60636 -atomic_t fscache_n_op_rejected;
60637 +atomic_unchecked_t fscache_n_op_pend;
60638 +atomic_unchecked_t fscache_n_op_run;
60639 +atomic_unchecked_t fscache_n_op_enqueue;
60640 +atomic_unchecked_t fscache_n_op_requeue;
60641 +atomic_unchecked_t fscache_n_op_deferred_release;
60642 +atomic_unchecked_t fscache_n_op_release;
60643 +atomic_unchecked_t fscache_n_op_gc;
60644 +atomic_unchecked_t fscache_n_op_cancelled;
60645 +atomic_unchecked_t fscache_n_op_rejected;
60646
60647 -atomic_t fscache_n_attr_changed;
60648 -atomic_t fscache_n_attr_changed_ok;
60649 -atomic_t fscache_n_attr_changed_nobufs;
60650 -atomic_t fscache_n_attr_changed_nomem;
60651 -atomic_t fscache_n_attr_changed_calls;
60652 +atomic_unchecked_t fscache_n_attr_changed;
60653 +atomic_unchecked_t fscache_n_attr_changed_ok;
60654 +atomic_unchecked_t fscache_n_attr_changed_nobufs;
60655 +atomic_unchecked_t fscache_n_attr_changed_nomem;
60656 +atomic_unchecked_t fscache_n_attr_changed_calls;
60657
60658 -atomic_t fscache_n_allocs;
60659 -atomic_t fscache_n_allocs_ok;
60660 -atomic_t fscache_n_allocs_wait;
60661 -atomic_t fscache_n_allocs_nobufs;
60662 -atomic_t fscache_n_allocs_intr;
60663 -atomic_t fscache_n_allocs_object_dead;
60664 -atomic_t fscache_n_alloc_ops;
60665 -atomic_t fscache_n_alloc_op_waits;
60666 +atomic_unchecked_t fscache_n_allocs;
60667 +atomic_unchecked_t fscache_n_allocs_ok;
60668 +atomic_unchecked_t fscache_n_allocs_wait;
60669 +atomic_unchecked_t fscache_n_allocs_nobufs;
60670 +atomic_unchecked_t fscache_n_allocs_intr;
60671 +atomic_unchecked_t fscache_n_allocs_object_dead;
60672 +atomic_unchecked_t fscache_n_alloc_ops;
60673 +atomic_unchecked_t fscache_n_alloc_op_waits;
60674
60675 -atomic_t fscache_n_retrievals;
60676 -atomic_t fscache_n_retrievals_ok;
60677 -atomic_t fscache_n_retrievals_wait;
60678 -atomic_t fscache_n_retrievals_nodata;
60679 -atomic_t fscache_n_retrievals_nobufs;
60680 -atomic_t fscache_n_retrievals_intr;
60681 -atomic_t fscache_n_retrievals_nomem;
60682 -atomic_t fscache_n_retrievals_object_dead;
60683 -atomic_t fscache_n_retrieval_ops;
60684 -atomic_t fscache_n_retrieval_op_waits;
60685 +atomic_unchecked_t fscache_n_retrievals;
60686 +atomic_unchecked_t fscache_n_retrievals_ok;
60687 +atomic_unchecked_t fscache_n_retrievals_wait;
60688 +atomic_unchecked_t fscache_n_retrievals_nodata;
60689 +atomic_unchecked_t fscache_n_retrievals_nobufs;
60690 +atomic_unchecked_t fscache_n_retrievals_intr;
60691 +atomic_unchecked_t fscache_n_retrievals_nomem;
60692 +atomic_unchecked_t fscache_n_retrievals_object_dead;
60693 +atomic_unchecked_t fscache_n_retrieval_ops;
60694 +atomic_unchecked_t fscache_n_retrieval_op_waits;
60695
60696 -atomic_t fscache_n_stores;
60697 -atomic_t fscache_n_stores_ok;
60698 -atomic_t fscache_n_stores_again;
60699 -atomic_t fscache_n_stores_nobufs;
60700 -atomic_t fscache_n_stores_oom;
60701 -atomic_t fscache_n_store_ops;
60702 -atomic_t fscache_n_store_calls;
60703 -atomic_t fscache_n_store_pages;
60704 -atomic_t fscache_n_store_radix_deletes;
60705 -atomic_t fscache_n_store_pages_over_limit;
60706 +atomic_unchecked_t fscache_n_stores;
60707 +atomic_unchecked_t fscache_n_stores_ok;
60708 +atomic_unchecked_t fscache_n_stores_again;
60709 +atomic_unchecked_t fscache_n_stores_nobufs;
60710 +atomic_unchecked_t fscache_n_stores_oom;
60711 +atomic_unchecked_t fscache_n_store_ops;
60712 +atomic_unchecked_t fscache_n_store_calls;
60713 +atomic_unchecked_t fscache_n_store_pages;
60714 +atomic_unchecked_t fscache_n_store_radix_deletes;
60715 +atomic_unchecked_t fscache_n_store_pages_over_limit;
60716
60717 -atomic_t fscache_n_store_vmscan_not_storing;
60718 -atomic_t fscache_n_store_vmscan_gone;
60719 -atomic_t fscache_n_store_vmscan_busy;
60720 -atomic_t fscache_n_store_vmscan_cancelled;
60721 -atomic_t fscache_n_store_vmscan_wait;
60722 +atomic_unchecked_t fscache_n_store_vmscan_not_storing;
60723 +atomic_unchecked_t fscache_n_store_vmscan_gone;
60724 +atomic_unchecked_t fscache_n_store_vmscan_busy;
60725 +atomic_unchecked_t fscache_n_store_vmscan_cancelled;
60726 +atomic_unchecked_t fscache_n_store_vmscan_wait;
60727
60728 -atomic_t fscache_n_marks;
60729 -atomic_t fscache_n_uncaches;
60730 +atomic_unchecked_t fscache_n_marks;
60731 +atomic_unchecked_t fscache_n_uncaches;
60732
60733 -atomic_t fscache_n_acquires;
60734 -atomic_t fscache_n_acquires_null;
60735 -atomic_t fscache_n_acquires_no_cache;
60736 -atomic_t fscache_n_acquires_ok;
60737 -atomic_t fscache_n_acquires_nobufs;
60738 -atomic_t fscache_n_acquires_oom;
60739 +atomic_unchecked_t fscache_n_acquires;
60740 +atomic_unchecked_t fscache_n_acquires_null;
60741 +atomic_unchecked_t fscache_n_acquires_no_cache;
60742 +atomic_unchecked_t fscache_n_acquires_ok;
60743 +atomic_unchecked_t fscache_n_acquires_nobufs;
60744 +atomic_unchecked_t fscache_n_acquires_oom;
60745
60746 -atomic_t fscache_n_invalidates;
60747 -atomic_t fscache_n_invalidates_run;
60748 +atomic_unchecked_t fscache_n_invalidates;
60749 +atomic_unchecked_t fscache_n_invalidates_run;
60750
60751 -atomic_t fscache_n_updates;
60752 -atomic_t fscache_n_updates_null;
60753 -atomic_t fscache_n_updates_run;
60754 +atomic_unchecked_t fscache_n_updates;
60755 +atomic_unchecked_t fscache_n_updates_null;
60756 +atomic_unchecked_t fscache_n_updates_run;
60757
60758 -atomic_t fscache_n_relinquishes;
60759 -atomic_t fscache_n_relinquishes_null;
60760 -atomic_t fscache_n_relinquishes_waitcrt;
60761 -atomic_t fscache_n_relinquishes_retire;
60762 +atomic_unchecked_t fscache_n_relinquishes;
60763 +atomic_unchecked_t fscache_n_relinquishes_null;
60764 +atomic_unchecked_t fscache_n_relinquishes_waitcrt;
60765 +atomic_unchecked_t fscache_n_relinquishes_retire;
60766
60767 -atomic_t fscache_n_cookie_index;
60768 -atomic_t fscache_n_cookie_data;
60769 -atomic_t fscache_n_cookie_special;
60770 +atomic_unchecked_t fscache_n_cookie_index;
60771 +atomic_unchecked_t fscache_n_cookie_data;
60772 +atomic_unchecked_t fscache_n_cookie_special;
60773
60774 -atomic_t fscache_n_object_alloc;
60775 -atomic_t fscache_n_object_no_alloc;
60776 -atomic_t fscache_n_object_lookups;
60777 -atomic_t fscache_n_object_lookups_negative;
60778 -atomic_t fscache_n_object_lookups_positive;
60779 -atomic_t fscache_n_object_lookups_timed_out;
60780 -atomic_t fscache_n_object_created;
60781 -atomic_t fscache_n_object_avail;
60782 -atomic_t fscache_n_object_dead;
60783 +atomic_unchecked_t fscache_n_object_alloc;
60784 +atomic_unchecked_t fscache_n_object_no_alloc;
60785 +atomic_unchecked_t fscache_n_object_lookups;
60786 +atomic_unchecked_t fscache_n_object_lookups_negative;
60787 +atomic_unchecked_t fscache_n_object_lookups_positive;
60788 +atomic_unchecked_t fscache_n_object_lookups_timed_out;
60789 +atomic_unchecked_t fscache_n_object_created;
60790 +atomic_unchecked_t fscache_n_object_avail;
60791 +atomic_unchecked_t fscache_n_object_dead;
60792
60793 -atomic_t fscache_n_checkaux_none;
60794 -atomic_t fscache_n_checkaux_okay;
60795 -atomic_t fscache_n_checkaux_update;
60796 -atomic_t fscache_n_checkaux_obsolete;
60797 +atomic_unchecked_t fscache_n_checkaux_none;
60798 +atomic_unchecked_t fscache_n_checkaux_okay;
60799 +atomic_unchecked_t fscache_n_checkaux_update;
60800 +atomic_unchecked_t fscache_n_checkaux_obsolete;
60801
60802 atomic_t fscache_n_cop_alloc_object;
60803 atomic_t fscache_n_cop_lookup_object;
60804 @@ -138,118 +138,118 @@ static int fscache_stats_show(struct seq_file *m, void *v)
60805 seq_puts(m, "FS-Cache statistics\n");
60806
60807 seq_printf(m, "Cookies: idx=%u dat=%u spc=%u\n",
60808 - atomic_read(&fscache_n_cookie_index),
60809 - atomic_read(&fscache_n_cookie_data),
60810 - atomic_read(&fscache_n_cookie_special));
60811 + atomic_read_unchecked(&fscache_n_cookie_index),
60812 + atomic_read_unchecked(&fscache_n_cookie_data),
60813 + atomic_read_unchecked(&fscache_n_cookie_special));
60814
60815 seq_printf(m, "Objects: alc=%u nal=%u avl=%u ded=%u\n",
60816 - atomic_read(&fscache_n_object_alloc),
60817 - atomic_read(&fscache_n_object_no_alloc),
60818 - atomic_read(&fscache_n_object_avail),
60819 - atomic_read(&fscache_n_object_dead));
60820 + atomic_read_unchecked(&fscache_n_object_alloc),
60821 + atomic_read_unchecked(&fscache_n_object_no_alloc),
60822 + atomic_read_unchecked(&fscache_n_object_avail),
60823 + atomic_read_unchecked(&fscache_n_object_dead));
60824 seq_printf(m, "ChkAux : non=%u ok=%u upd=%u obs=%u\n",
60825 - atomic_read(&fscache_n_checkaux_none),
60826 - atomic_read(&fscache_n_checkaux_okay),
60827 - atomic_read(&fscache_n_checkaux_update),
60828 - atomic_read(&fscache_n_checkaux_obsolete));
60829 + atomic_read_unchecked(&fscache_n_checkaux_none),
60830 + atomic_read_unchecked(&fscache_n_checkaux_okay),
60831 + atomic_read_unchecked(&fscache_n_checkaux_update),
60832 + atomic_read_unchecked(&fscache_n_checkaux_obsolete));
60833
60834 seq_printf(m, "Pages : mrk=%u unc=%u\n",
60835 - atomic_read(&fscache_n_marks),
60836 - atomic_read(&fscache_n_uncaches));
60837 + atomic_read_unchecked(&fscache_n_marks),
60838 + atomic_read_unchecked(&fscache_n_uncaches));
60839
60840 seq_printf(m, "Acquire: n=%u nul=%u noc=%u ok=%u nbf=%u"
60841 " oom=%u\n",
60842 - atomic_read(&fscache_n_acquires),
60843 - atomic_read(&fscache_n_acquires_null),
60844 - atomic_read(&fscache_n_acquires_no_cache),
60845 - atomic_read(&fscache_n_acquires_ok),
60846 - atomic_read(&fscache_n_acquires_nobufs),
60847 - atomic_read(&fscache_n_acquires_oom));
60848 + atomic_read_unchecked(&fscache_n_acquires),
60849 + atomic_read_unchecked(&fscache_n_acquires_null),
60850 + atomic_read_unchecked(&fscache_n_acquires_no_cache),
60851 + atomic_read_unchecked(&fscache_n_acquires_ok),
60852 + atomic_read_unchecked(&fscache_n_acquires_nobufs),
60853 + atomic_read_unchecked(&fscache_n_acquires_oom));
60854
60855 seq_printf(m, "Lookups: n=%u neg=%u pos=%u crt=%u tmo=%u\n",
60856 - atomic_read(&fscache_n_object_lookups),
60857 - atomic_read(&fscache_n_object_lookups_negative),
60858 - atomic_read(&fscache_n_object_lookups_positive),
60859 - atomic_read(&fscache_n_object_created),
60860 - atomic_read(&fscache_n_object_lookups_timed_out));
60861 + atomic_read_unchecked(&fscache_n_object_lookups),
60862 + atomic_read_unchecked(&fscache_n_object_lookups_negative),
60863 + atomic_read_unchecked(&fscache_n_object_lookups_positive),
60864 + atomic_read_unchecked(&fscache_n_object_created),
60865 + atomic_read_unchecked(&fscache_n_object_lookups_timed_out));
60866
60867 seq_printf(m, "Invals : n=%u run=%u\n",
60868 - atomic_read(&fscache_n_invalidates),
60869 - atomic_read(&fscache_n_invalidates_run));
60870 + atomic_read_unchecked(&fscache_n_invalidates),
60871 + atomic_read_unchecked(&fscache_n_invalidates_run));
60872
60873 seq_printf(m, "Updates: n=%u nul=%u run=%u\n",
60874 - atomic_read(&fscache_n_updates),
60875 - atomic_read(&fscache_n_updates_null),
60876 - atomic_read(&fscache_n_updates_run));
60877 + atomic_read_unchecked(&fscache_n_updates),
60878 + atomic_read_unchecked(&fscache_n_updates_null),
60879 + atomic_read_unchecked(&fscache_n_updates_run));
60880
60881 seq_printf(m, "Relinqs: n=%u nul=%u wcr=%u rtr=%u\n",
60882 - atomic_read(&fscache_n_relinquishes),
60883 - atomic_read(&fscache_n_relinquishes_null),
60884 - atomic_read(&fscache_n_relinquishes_waitcrt),
60885 - atomic_read(&fscache_n_relinquishes_retire));
60886 + atomic_read_unchecked(&fscache_n_relinquishes),
60887 + atomic_read_unchecked(&fscache_n_relinquishes_null),
60888 + atomic_read_unchecked(&fscache_n_relinquishes_waitcrt),
60889 + atomic_read_unchecked(&fscache_n_relinquishes_retire));
60890
60891 seq_printf(m, "AttrChg: n=%u ok=%u nbf=%u oom=%u run=%u\n",
60892 - atomic_read(&fscache_n_attr_changed),
60893 - atomic_read(&fscache_n_attr_changed_ok),
60894 - atomic_read(&fscache_n_attr_changed_nobufs),
60895 - atomic_read(&fscache_n_attr_changed_nomem),
60896 - atomic_read(&fscache_n_attr_changed_calls));
60897 + atomic_read_unchecked(&fscache_n_attr_changed),
60898 + atomic_read_unchecked(&fscache_n_attr_changed_ok),
60899 + atomic_read_unchecked(&fscache_n_attr_changed_nobufs),
60900 + atomic_read_unchecked(&fscache_n_attr_changed_nomem),
60901 + atomic_read_unchecked(&fscache_n_attr_changed_calls));
60902
60903 seq_printf(m, "Allocs : n=%u ok=%u wt=%u nbf=%u int=%u\n",
60904 - atomic_read(&fscache_n_allocs),
60905 - atomic_read(&fscache_n_allocs_ok),
60906 - atomic_read(&fscache_n_allocs_wait),
60907 - atomic_read(&fscache_n_allocs_nobufs),
60908 - atomic_read(&fscache_n_allocs_intr));
60909 + atomic_read_unchecked(&fscache_n_allocs),
60910 + atomic_read_unchecked(&fscache_n_allocs_ok),
60911 + atomic_read_unchecked(&fscache_n_allocs_wait),
60912 + atomic_read_unchecked(&fscache_n_allocs_nobufs),
60913 + atomic_read_unchecked(&fscache_n_allocs_intr));
60914 seq_printf(m, "Allocs : ops=%u owt=%u abt=%u\n",
60915 - atomic_read(&fscache_n_alloc_ops),
60916 - atomic_read(&fscache_n_alloc_op_waits),
60917 - atomic_read(&fscache_n_allocs_object_dead));
60918 + atomic_read_unchecked(&fscache_n_alloc_ops),
60919 + atomic_read_unchecked(&fscache_n_alloc_op_waits),
60920 + atomic_read_unchecked(&fscache_n_allocs_object_dead));
60921
60922 seq_printf(m, "Retrvls: n=%u ok=%u wt=%u nod=%u nbf=%u"
60923 " int=%u oom=%u\n",
60924 - atomic_read(&fscache_n_retrievals),
60925 - atomic_read(&fscache_n_retrievals_ok),
60926 - atomic_read(&fscache_n_retrievals_wait),
60927 - atomic_read(&fscache_n_retrievals_nodata),
60928 - atomic_read(&fscache_n_retrievals_nobufs),
60929 - atomic_read(&fscache_n_retrievals_intr),
60930 - atomic_read(&fscache_n_retrievals_nomem));
60931 + atomic_read_unchecked(&fscache_n_retrievals),
60932 + atomic_read_unchecked(&fscache_n_retrievals_ok),
60933 + atomic_read_unchecked(&fscache_n_retrievals_wait),
60934 + atomic_read_unchecked(&fscache_n_retrievals_nodata),
60935 + atomic_read_unchecked(&fscache_n_retrievals_nobufs),
60936 + atomic_read_unchecked(&fscache_n_retrievals_intr),
60937 + atomic_read_unchecked(&fscache_n_retrievals_nomem));
60938 seq_printf(m, "Retrvls: ops=%u owt=%u abt=%u\n",
60939 - atomic_read(&fscache_n_retrieval_ops),
60940 - atomic_read(&fscache_n_retrieval_op_waits),
60941 - atomic_read(&fscache_n_retrievals_object_dead));
60942 + atomic_read_unchecked(&fscache_n_retrieval_ops),
60943 + atomic_read_unchecked(&fscache_n_retrieval_op_waits),
60944 + atomic_read_unchecked(&fscache_n_retrievals_object_dead));
60945
60946 seq_printf(m, "Stores : n=%u ok=%u agn=%u nbf=%u oom=%u\n",
60947 - atomic_read(&fscache_n_stores),
60948 - atomic_read(&fscache_n_stores_ok),
60949 - atomic_read(&fscache_n_stores_again),
60950 - atomic_read(&fscache_n_stores_nobufs),
60951 - atomic_read(&fscache_n_stores_oom));
60952 + atomic_read_unchecked(&fscache_n_stores),
60953 + atomic_read_unchecked(&fscache_n_stores_ok),
60954 + atomic_read_unchecked(&fscache_n_stores_again),
60955 + atomic_read_unchecked(&fscache_n_stores_nobufs),
60956 + atomic_read_unchecked(&fscache_n_stores_oom));
60957 seq_printf(m, "Stores : ops=%u run=%u pgs=%u rxd=%u olm=%u\n",
60958 - atomic_read(&fscache_n_store_ops),
60959 - atomic_read(&fscache_n_store_calls),
60960 - atomic_read(&fscache_n_store_pages),
60961 - atomic_read(&fscache_n_store_radix_deletes),
60962 - atomic_read(&fscache_n_store_pages_over_limit));
60963 + atomic_read_unchecked(&fscache_n_store_ops),
60964 + atomic_read_unchecked(&fscache_n_store_calls),
60965 + atomic_read_unchecked(&fscache_n_store_pages),
60966 + atomic_read_unchecked(&fscache_n_store_radix_deletes),
60967 + atomic_read_unchecked(&fscache_n_store_pages_over_limit));
60968
60969 seq_printf(m, "VmScan : nos=%u gon=%u bsy=%u can=%u wt=%u\n",
60970 - atomic_read(&fscache_n_store_vmscan_not_storing),
60971 - atomic_read(&fscache_n_store_vmscan_gone),
60972 - atomic_read(&fscache_n_store_vmscan_busy),
60973 - atomic_read(&fscache_n_store_vmscan_cancelled),
60974 - atomic_read(&fscache_n_store_vmscan_wait));
60975 + atomic_read_unchecked(&fscache_n_store_vmscan_not_storing),
60976 + atomic_read_unchecked(&fscache_n_store_vmscan_gone),
60977 + atomic_read_unchecked(&fscache_n_store_vmscan_busy),
60978 + atomic_read_unchecked(&fscache_n_store_vmscan_cancelled),
60979 + atomic_read_unchecked(&fscache_n_store_vmscan_wait));
60980
60981 seq_printf(m, "Ops : pend=%u run=%u enq=%u can=%u rej=%u\n",
60982 - atomic_read(&fscache_n_op_pend),
60983 - atomic_read(&fscache_n_op_run),
60984 - atomic_read(&fscache_n_op_enqueue),
60985 - atomic_read(&fscache_n_op_cancelled),
60986 - atomic_read(&fscache_n_op_rejected));
60987 + atomic_read_unchecked(&fscache_n_op_pend),
60988 + atomic_read_unchecked(&fscache_n_op_run),
60989 + atomic_read_unchecked(&fscache_n_op_enqueue),
60990 + atomic_read_unchecked(&fscache_n_op_cancelled),
60991 + atomic_read_unchecked(&fscache_n_op_rejected));
60992 seq_printf(m, "Ops : dfr=%u rel=%u gc=%u\n",
60993 - atomic_read(&fscache_n_op_deferred_release),
60994 - atomic_read(&fscache_n_op_release),
60995 - atomic_read(&fscache_n_op_gc));
60996 + atomic_read_unchecked(&fscache_n_op_deferred_release),
60997 + atomic_read_unchecked(&fscache_n_op_release),
60998 + atomic_read_unchecked(&fscache_n_op_gc));
60999
61000 seq_printf(m, "CacheOp: alo=%d luo=%d luc=%d gro=%d\n",
61001 atomic_read(&fscache_n_cop_alloc_object),
61002 diff --git a/fs/fuse/cuse.c b/fs/fuse/cuse.c
61003 index 13b691a..1ffca5ae 100644
61004 --- a/fs/fuse/cuse.c
61005 +++ b/fs/fuse/cuse.c
61006 @@ -607,10 +607,12 @@ static int __init cuse_init(void)
61007 INIT_LIST_HEAD(&cuse_conntbl[i]);
61008
61009 /* inherit and extend fuse_dev_operations */
61010 - cuse_channel_fops = fuse_dev_operations;
61011 - cuse_channel_fops.owner = THIS_MODULE;
61012 - cuse_channel_fops.open = cuse_channel_open;
61013 - cuse_channel_fops.release = cuse_channel_release;
61014 + pax_open_kernel();
61015 + memcpy((void *)&cuse_channel_fops, &fuse_dev_operations, sizeof(fuse_dev_operations));
61016 + *(void **)&cuse_channel_fops.owner = THIS_MODULE;
61017 + *(void **)&cuse_channel_fops.open = cuse_channel_open;
61018 + *(void **)&cuse_channel_fops.release = cuse_channel_release;
61019 + pax_close_kernel();
61020
61021 cuse_class = class_create(THIS_MODULE, "cuse");
61022 if (IS_ERR(cuse_class))
61023 diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
61024 index aac71ce..fcd6a1b 100644
61025 --- a/fs/fuse/dev.c
61026 +++ b/fs/fuse/dev.c
61027 @@ -1323,7 +1323,7 @@ static ssize_t fuse_dev_splice_read(struct file *in, loff_t *ppos,
61028 ret = 0;
61029 pipe_lock(pipe);
61030
61031 - if (!pipe->readers) {
61032 + if (!atomic_read(&pipe->readers)) {
61033 send_sig(SIGPIPE, current, 0);
61034 if (!ret)
61035 ret = -EPIPE;
61036 @@ -1352,7 +1352,7 @@ static ssize_t fuse_dev_splice_read(struct file *in, loff_t *ppos,
61037 page_nr++;
61038 ret += buf->len;
61039
61040 - if (pipe->files)
61041 + if (atomic_read(&pipe->files))
61042 do_wakeup = 1;
61043 }
61044
61045 diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
61046 index 4219835..3473b7e 100644
61047 --- a/fs/fuse/dir.c
61048 +++ b/fs/fuse/dir.c
61049 @@ -1478,7 +1478,7 @@ static char *read_link(struct dentry *dentry)
61050 return link;
61051 }
61052
61053 -static void free_link(char *link)
61054 +static void free_link(const char *link)
61055 {
61056 if (!IS_ERR(link))
61057 free_page((unsigned long) link);
61058 diff --git a/fs/hostfs/hostfs_kern.c b/fs/hostfs/hostfs_kern.c
61059 index 9c470fd..aae410e 100644
61060 --- a/fs/hostfs/hostfs_kern.c
61061 +++ b/fs/hostfs/hostfs_kern.c
61062 @@ -898,7 +898,7 @@ static void *hostfs_follow_link(struct dentry *dentry, struct nameidata *nd)
61063
61064 static void hostfs_put_link(struct dentry *dentry, struct nameidata *nd, void *cookie)
61065 {
61066 - char *s = nd_get_link(nd);
61067 + const char *s = nd_get_link(nd);
61068 if (!IS_ERR(s))
61069 __putname(s);
61070 }
61071 diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
61072 index e19d4c0..8a357a9 100644
61073 --- a/fs/hugetlbfs/inode.c
61074 +++ b/fs/hugetlbfs/inode.c
61075 @@ -152,6 +152,7 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
61076 struct mm_struct *mm = current->mm;
61077 struct vm_area_struct *vma;
61078 struct hstate *h = hstate_file(file);
61079 + unsigned long offset = gr_rand_threadstack_offset(mm, file, flags);
61080 struct vm_unmapped_area_info info;
61081
61082 if (len & ~huge_page_mask(h))
61083 @@ -165,17 +166,26 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
61084 return addr;
61085 }
61086
61087 +#ifdef CONFIG_PAX_RANDMMAP
61088 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
61089 +#endif
61090 +
61091 if (addr) {
61092 addr = ALIGN(addr, huge_page_size(h));
61093 vma = find_vma(mm, addr);
61094 - if (TASK_SIZE - len >= addr &&
61095 - (!vma || addr + len <= vma->vm_start))
61096 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
61097 return addr;
61098 }
61099
61100 info.flags = 0;
61101 info.length = len;
61102 info.low_limit = TASK_UNMAPPED_BASE;
61103 +
61104 +#ifdef CONFIG_PAX_RANDMMAP
61105 + if (mm->pax_flags & MF_PAX_RANDMMAP)
61106 + info.low_limit += mm->delta_mmap;
61107 +#endif
61108 +
61109 info.high_limit = TASK_SIZE;
61110 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
61111 info.align_offset = 0;
61112 @@ -921,7 +931,7 @@ static struct file_system_type hugetlbfs_fs_type = {
61113 };
61114 MODULE_ALIAS_FS("hugetlbfs");
61115
61116 -static struct vfsmount *hugetlbfs_vfsmount[HUGE_MAX_HSTATE];
61117 +struct vfsmount *hugetlbfs_vfsmount[HUGE_MAX_HSTATE];
61118
61119 static int can_do_hugetlb_shm(void)
61120 {
61121 diff --git a/fs/inode.c b/fs/inode.c
61122 index d2fb2f2..a6444b0 100644
61123 --- a/fs/inode.c
61124 +++ b/fs/inode.c
61125 @@ -839,16 +839,20 @@ unsigned int get_next_ino(void)
61126 unsigned int *p = &get_cpu_var(last_ino);
61127 unsigned int res = *p;
61128
61129 +start:
61130 +
61131 #ifdef CONFIG_SMP
61132 if (unlikely((res & (LAST_INO_BATCH-1)) == 0)) {
61133 - static atomic_t shared_last_ino;
61134 - int next = atomic_add_return(LAST_INO_BATCH, &shared_last_ino);
61135 + static atomic_unchecked_t shared_last_ino;
61136 + int next = atomic_add_return_unchecked(LAST_INO_BATCH, &shared_last_ino);
61137
61138 res = next - LAST_INO_BATCH;
61139 }
61140 #endif
61141
61142 - *p = ++res;
61143 + if (unlikely(!++res))
61144 + goto start; /* never zero */
61145 + *p = res;
61146 put_cpu_var(last_ino);
61147 return res;
61148 }
61149 diff --git a/fs/jffs2/erase.c b/fs/jffs2/erase.c
61150 index 4a6cf28..d3a29d3 100644
61151 --- a/fs/jffs2/erase.c
61152 +++ b/fs/jffs2/erase.c
61153 @@ -452,7 +452,8 @@ static void jffs2_mark_erased_block(struct jffs2_sb_info *c, struct jffs2_eraseb
61154 struct jffs2_unknown_node marker = {
61155 .magic = cpu_to_je16(JFFS2_MAGIC_BITMASK),
61156 .nodetype = cpu_to_je16(JFFS2_NODETYPE_CLEANMARKER),
61157 - .totlen = cpu_to_je32(c->cleanmarker_size)
61158 + .totlen = cpu_to_je32(c->cleanmarker_size),
61159 + .hdr_crc = cpu_to_je32(0)
61160 };
61161
61162 jffs2_prealloc_raw_node_refs(c, jeb, 1);
61163 diff --git a/fs/jffs2/wbuf.c b/fs/jffs2/wbuf.c
61164 index a6597d6..41b30ec 100644
61165 --- a/fs/jffs2/wbuf.c
61166 +++ b/fs/jffs2/wbuf.c
61167 @@ -1023,7 +1023,8 @@ static const struct jffs2_unknown_node oob_cleanmarker =
61168 {
61169 .magic = constant_cpu_to_je16(JFFS2_MAGIC_BITMASK),
61170 .nodetype = constant_cpu_to_je16(JFFS2_NODETYPE_CLEANMARKER),
61171 - .totlen = constant_cpu_to_je32(8)
61172 + .totlen = constant_cpu_to_je32(8),
61173 + .hdr_crc = constant_cpu_to_je32(0)
61174 };
61175
61176 /*
61177 diff --git a/fs/jfs/super.c b/fs/jfs/super.c
61178 index 97f7fda..09bd33d 100644
61179 --- a/fs/jfs/super.c
61180 +++ b/fs/jfs/super.c
61181 @@ -885,7 +885,7 @@ static int __init init_jfs_fs(void)
61182
61183 jfs_inode_cachep =
61184 kmem_cache_create("jfs_ip", sizeof(struct jfs_inode_info), 0,
61185 - SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD,
61186 + SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD|SLAB_USERCOPY,
61187 init_once);
61188 if (jfs_inode_cachep == NULL)
61189 return -ENOMEM;
61190 diff --git a/fs/kernfs/dir.c b/fs/kernfs/dir.c
61191 index ac127cd..d8079db 100644
61192 --- a/fs/kernfs/dir.c
61193 +++ b/fs/kernfs/dir.c
61194 @@ -182,7 +182,7 @@ struct kernfs_node *kernfs_get_parent(struct kernfs_node *kn)
61195 *
61196 * Returns 31 bit hash of ns + name (so it fits in an off_t )
61197 */
61198 -static unsigned int kernfs_name_hash(const char *name, const void *ns)
61199 +static unsigned int kernfs_name_hash(const unsigned char *name, const void *ns)
61200 {
61201 unsigned long hash = init_name_hash();
61202 unsigned int len = strlen(name);
61203 diff --git a/fs/kernfs/file.c b/fs/kernfs/file.c
61204 index 5e9a80c..3853a24 100644
61205 --- a/fs/kernfs/file.c
61206 +++ b/fs/kernfs/file.c
61207 @@ -33,7 +33,7 @@ static DEFINE_MUTEX(kernfs_open_file_mutex);
61208
61209 struct kernfs_open_node {
61210 atomic_t refcnt;
61211 - atomic_t event;
61212 + atomic_unchecked_t event;
61213 wait_queue_head_t poll;
61214 struct list_head files; /* goes through kernfs_open_file.list */
61215 };
61216 @@ -149,7 +149,7 @@ static int kernfs_seq_show(struct seq_file *sf, void *v)
61217 {
61218 struct kernfs_open_file *of = sf->private;
61219
61220 - of->event = atomic_read(&of->kn->attr.open->event);
61221 + of->event = atomic_read_unchecked(&of->kn->attr.open->event);
61222
61223 return of->kn->attr.ops->seq_show(sf, v);
61224 }
61225 @@ -361,12 +361,12 @@ static int kernfs_vma_page_mkwrite(struct vm_area_struct *vma,
61226 return ret;
61227 }
61228
61229 -static int kernfs_vma_access(struct vm_area_struct *vma, unsigned long addr,
61230 - void *buf, int len, int write)
61231 +static ssize_t kernfs_vma_access(struct vm_area_struct *vma, unsigned long addr,
61232 + void *buf, size_t len, int write)
61233 {
61234 struct file *file = vma->vm_file;
61235 struct kernfs_open_file *of = kernfs_of(file);
61236 - int ret;
61237 + ssize_t ret;
61238
61239 if (!of->vm_ops)
61240 return -EINVAL;
61241 @@ -567,7 +567,7 @@ static int kernfs_get_open_node(struct kernfs_node *kn,
61242 return -ENOMEM;
61243
61244 atomic_set(&new_on->refcnt, 0);
61245 - atomic_set(&new_on->event, 1);
61246 + atomic_set_unchecked(&new_on->event, 1);
61247 init_waitqueue_head(&new_on->poll);
61248 INIT_LIST_HEAD(&new_on->files);
61249 goto retry;
61250 @@ -773,7 +773,7 @@ static unsigned int kernfs_fop_poll(struct file *filp, poll_table *wait)
61251
61252 kernfs_put_active(kn);
61253
61254 - if (of->event != atomic_read(&on->event))
61255 + if (of->event != atomic_read_unchecked(&on->event))
61256 goto trigger;
61257
61258 return DEFAULT_POLLMASK;
61259 @@ -798,7 +798,7 @@ void kernfs_notify(struct kernfs_node *kn)
61260 if (!WARN_ON(kernfs_type(kn) != KERNFS_FILE)) {
61261 on = kn->attr.open;
61262 if (on) {
61263 - atomic_inc(&on->event);
61264 + atomic_inc_unchecked(&on->event);
61265 wake_up_interruptible(&on->poll);
61266 }
61267 }
61268 diff --git a/fs/kernfs/symlink.c b/fs/kernfs/symlink.c
61269 index 8a19889..4c3069a 100644
61270 --- a/fs/kernfs/symlink.c
61271 +++ b/fs/kernfs/symlink.c
61272 @@ -128,7 +128,7 @@ static void *kernfs_iop_follow_link(struct dentry *dentry, struct nameidata *nd)
61273 static void kernfs_iop_put_link(struct dentry *dentry, struct nameidata *nd,
61274 void *cookie)
61275 {
61276 - char *page = nd_get_link(nd);
61277 + const char *page = nd_get_link(nd);
61278 if (!IS_ERR(page))
61279 free_page((unsigned long)page);
61280 }
61281 diff --git a/fs/libfs.c b/fs/libfs.c
61282 index a184424..944ddce 100644
61283 --- a/fs/libfs.c
61284 +++ b/fs/libfs.c
61285 @@ -159,6 +159,9 @@ int dcache_readdir(struct file *file, struct dir_context *ctx)
61286
61287 for (p = q->next; p != &dentry->d_subdirs; p = p->next) {
61288 struct dentry *next = list_entry(p, struct dentry, d_u.d_child);
61289 + char d_name[sizeof(next->d_iname)];
61290 + const unsigned char *name;
61291 +
61292 spin_lock_nested(&next->d_lock, DENTRY_D_LOCK_NESTED);
61293 if (!simple_positive(next)) {
61294 spin_unlock(&next->d_lock);
61295 @@ -167,7 +170,12 @@ int dcache_readdir(struct file *file, struct dir_context *ctx)
61296
61297 spin_unlock(&next->d_lock);
61298 spin_unlock(&dentry->d_lock);
61299 - if (!dir_emit(ctx, next->d_name.name, next->d_name.len,
61300 + name = next->d_name.name;
61301 + if (name == next->d_iname) {
61302 + memcpy(d_name, name, next->d_name.len);
61303 + name = d_name;
61304 + }
61305 + if (!dir_emit(ctx, name, next->d_name.len,
61306 next->d_inode->i_ino, dt_type(next->d_inode)))
61307 return 0;
61308 spin_lock(&dentry->d_lock);
61309 @@ -999,7 +1007,7 @@ EXPORT_SYMBOL(noop_fsync);
61310 void kfree_put_link(struct dentry *dentry, struct nameidata *nd,
61311 void *cookie)
61312 {
61313 - char *s = nd_get_link(nd);
61314 + const char *s = nd_get_link(nd);
61315 if (!IS_ERR(s))
61316 kfree(s);
61317 }
61318 diff --git a/fs/lockd/clntproc.c b/fs/lockd/clntproc.c
61319 index acd3947..1f896e2 100644
61320 --- a/fs/lockd/clntproc.c
61321 +++ b/fs/lockd/clntproc.c
61322 @@ -36,11 +36,11 @@ static const struct rpc_call_ops nlmclnt_cancel_ops;
61323 /*
61324 * Cookie counter for NLM requests
61325 */
61326 -static atomic_t nlm_cookie = ATOMIC_INIT(0x1234);
61327 +static atomic_unchecked_t nlm_cookie = ATOMIC_INIT(0x1234);
61328
61329 void nlmclnt_next_cookie(struct nlm_cookie *c)
61330 {
61331 - u32 cookie = atomic_inc_return(&nlm_cookie);
61332 + u32 cookie = atomic_inc_return_unchecked(&nlm_cookie);
61333
61334 memcpy(c->data, &cookie, 4);
61335 c->len=4;
61336 diff --git a/fs/locks.c b/fs/locks.c
61337 index e390bd9..c79870e 100644
61338 --- a/fs/locks.c
61339 +++ b/fs/locks.c
61340 @@ -2315,16 +2315,16 @@ void locks_remove_file(struct file *filp)
61341 locks_remove_posix(filp, (fl_owner_t)filp);
61342
61343 if (filp->f_op->flock) {
61344 - struct file_lock fl = {
61345 + struct file_lock flock = {
61346 .fl_pid = current->tgid,
61347 .fl_file = filp,
61348 .fl_flags = FL_FLOCK,
61349 .fl_type = F_UNLCK,
61350 .fl_end = OFFSET_MAX,
61351 };
61352 - filp->f_op->flock(filp, F_SETLKW, &fl);
61353 - if (fl.fl_ops && fl.fl_ops->fl_release_private)
61354 - fl.fl_ops->fl_release_private(&fl);
61355 + filp->f_op->flock(filp, F_SETLKW, &flock);
61356 + if (flock.fl_ops && flock.fl_ops->fl_release_private)
61357 + flock.fl_ops->fl_release_private(&flock);
61358 }
61359
61360 spin_lock(&inode->i_lock);
61361 diff --git a/fs/mount.h b/fs/mount.h
61362 index d55297f..f5b28c5 100644
61363 --- a/fs/mount.h
61364 +++ b/fs/mount.h
61365 @@ -11,7 +11,7 @@ struct mnt_namespace {
61366 u64 seq; /* Sequence number to prevent loops */
61367 wait_queue_head_t poll;
61368 u64 event;
61369 -};
61370 +} __randomize_layout;
61371
61372 struct mnt_pcp {
61373 int mnt_count;
61374 @@ -57,7 +57,7 @@ struct mount {
61375 int mnt_expiry_mark; /* true if marked for expiry */
61376 int mnt_pinned;
61377 struct path mnt_ex_mountpoint;
61378 -};
61379 +} __randomize_layout;
61380
61381 #define MNT_NS_INTERNAL ERR_PTR(-EINVAL) /* distinct from any mnt_namespace */
61382
61383 diff --git a/fs/namei.c b/fs/namei.c
61384 index 985c6f3..f67a0f8 100644
61385 --- a/fs/namei.c
61386 +++ b/fs/namei.c
61387 @@ -330,17 +330,32 @@ int generic_permission(struct inode *inode, int mask)
61388 if (ret != -EACCES)
61389 return ret;
61390
61391 +#ifdef CONFIG_GRKERNSEC
61392 + /* we'll block if we have to log due to a denied capability use */
61393 + if (mask & MAY_NOT_BLOCK)
61394 + return -ECHILD;
61395 +#endif
61396 +
61397 if (S_ISDIR(inode->i_mode)) {
61398 /* DACs are overridable for directories */
61399 - if (capable_wrt_inode_uidgid(inode, CAP_DAC_OVERRIDE))
61400 - return 0;
61401 if (!(mask & MAY_WRITE))
61402 - if (capable_wrt_inode_uidgid(inode,
61403 - CAP_DAC_READ_SEARCH))
61404 + if (capable_wrt_inode_uidgid_nolog(inode, CAP_DAC_OVERRIDE) ||
61405 + capable_wrt_inode_uidgid(inode, CAP_DAC_READ_SEARCH))
61406 return 0;
61407 + if (capable_wrt_inode_uidgid(inode, CAP_DAC_OVERRIDE))
61408 + return 0;
61409 return -EACCES;
61410 }
61411 /*
61412 + * Searching includes executable on directories, else just read.
61413 + */
61414 + mask &= MAY_READ | MAY_WRITE | MAY_EXEC;
61415 + if (mask == MAY_READ)
61416 + if (capable_wrt_inode_uidgid_nolog(inode, CAP_DAC_OVERRIDE) ||
61417 + capable_wrt_inode_uidgid(inode, CAP_DAC_READ_SEARCH))
61418 + return 0;
61419 +
61420 + /*
61421 * Read/write DACs are always overridable.
61422 * Executable DACs are overridable when there is
61423 * at least one exec bit set.
61424 @@ -349,14 +364,6 @@ int generic_permission(struct inode *inode, int mask)
61425 if (capable_wrt_inode_uidgid(inode, CAP_DAC_OVERRIDE))
61426 return 0;
61427
61428 - /*
61429 - * Searching includes executable on directories, else just read.
61430 - */
61431 - mask &= MAY_READ | MAY_WRITE | MAY_EXEC;
61432 - if (mask == MAY_READ)
61433 - if (capable_wrt_inode_uidgid(inode, CAP_DAC_READ_SEARCH))
61434 - return 0;
61435 -
61436 return -EACCES;
61437 }
61438 EXPORT_SYMBOL(generic_permission);
61439 @@ -824,7 +831,7 @@ follow_link(struct path *link, struct nameidata *nd, void **p)
61440 {
61441 struct dentry *dentry = link->dentry;
61442 int error;
61443 - char *s;
61444 + const char *s;
61445
61446 BUG_ON(nd->flags & LOOKUP_RCU);
61447
61448 @@ -845,6 +852,12 @@ follow_link(struct path *link, struct nameidata *nd, void **p)
61449 if (error)
61450 goto out_put_nd_path;
61451
61452 + if (gr_handle_follow_link(dentry->d_parent->d_inode,
61453 + dentry->d_inode, dentry, nd->path.mnt)) {
61454 + error = -EACCES;
61455 + goto out_put_nd_path;
61456 + }
61457 +
61458 nd->last_type = LAST_BIND;
61459 *p = dentry->d_inode->i_op->follow_link(dentry, nd);
61460 error = PTR_ERR(*p);
61461 @@ -1596,6 +1609,8 @@ static inline int nested_symlink(struct path *path, struct nameidata *nd)
61462 if (res)
61463 break;
61464 res = walk_component(nd, path, LOOKUP_FOLLOW);
61465 + if (res >= 0 && gr_handle_symlink_owner(&link, nd->inode))
61466 + res = -EACCES;
61467 put_link(nd, &link, cookie);
61468 } while (res > 0);
61469
61470 @@ -1669,7 +1684,7 @@ EXPORT_SYMBOL(full_name_hash);
61471 static inline unsigned long hash_name(const char *name, unsigned int *hashp)
61472 {
61473 unsigned long a, b, adata, bdata, mask, hash, len;
61474 - const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
61475 + static const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
61476
61477 hash = a = 0;
61478 len = -sizeof(unsigned long);
61479 @@ -1953,6 +1968,8 @@ static int path_lookupat(int dfd, const char *name,
61480 if (err)
61481 break;
61482 err = lookup_last(nd, &path);
61483 + if (!err && gr_handle_symlink_owner(&link, nd->inode))
61484 + err = -EACCES;
61485 put_link(nd, &link, cookie);
61486 }
61487 }
61488 @@ -1960,6 +1977,13 @@ static int path_lookupat(int dfd, const char *name,
61489 if (!err)
61490 err = complete_walk(nd);
61491
61492 + if (!err && !(nd->flags & LOOKUP_PARENT)) {
61493 + if (!gr_acl_handle_hidden_file(nd->path.dentry, nd->path.mnt)) {
61494 + path_put(&nd->path);
61495 + err = -ENOENT;
61496 + }
61497 + }
61498 +
61499 if (!err && nd->flags & LOOKUP_DIRECTORY) {
61500 if (!d_can_lookup(nd->path.dentry)) {
61501 path_put(&nd->path);
61502 @@ -1987,8 +2011,15 @@ static int filename_lookup(int dfd, struct filename *name,
61503 retval = path_lookupat(dfd, name->name,
61504 flags | LOOKUP_REVAL, nd);
61505
61506 - if (likely(!retval))
61507 + if (likely(!retval)) {
61508 audit_inode(name, nd->path.dentry, flags & LOOKUP_PARENT);
61509 + if (name->name[0] != '/' && nd->path.dentry && nd->inode) {
61510 + if (!gr_chroot_fchdir(nd->path.dentry, nd->path.mnt)) {
61511 + path_put(&nd->path);
61512 + return -ENOENT;
61513 + }
61514 + }
61515 + }
61516 return retval;
61517 }
61518
61519 @@ -2569,6 +2600,13 @@ static int may_open(struct path *path, int acc_mode, int flag)
61520 if (flag & O_NOATIME && !inode_owner_or_capable(inode))
61521 return -EPERM;
61522
61523 + if (gr_handle_rofs_blockwrite(dentry, path->mnt, acc_mode))
61524 + return -EPERM;
61525 + if (gr_handle_rawio(inode))
61526 + return -EPERM;
61527 + if (!gr_acl_handle_open(dentry, path->mnt, acc_mode))
61528 + return -EACCES;
61529 +
61530 return 0;
61531 }
61532
61533 @@ -2800,7 +2838,7 @@ looked_up:
61534 * cleared otherwise prior to returning.
61535 */
61536 static int lookup_open(struct nameidata *nd, struct path *path,
61537 - struct file *file,
61538 + struct path *link, struct file *file,
61539 const struct open_flags *op,
61540 bool got_write, int *opened)
61541 {
61542 @@ -2835,6 +2873,17 @@ static int lookup_open(struct nameidata *nd, struct path *path,
61543 /* Negative dentry, just create the file */
61544 if (!dentry->d_inode && (op->open_flag & O_CREAT)) {
61545 umode_t mode = op->mode;
61546 +
61547 + if (link && gr_handle_symlink_owner(link, dir->d_inode)) {
61548 + error = -EACCES;
61549 + goto out_dput;
61550 + }
61551 +
61552 + if (!gr_acl_handle_creat(dentry, dir, nd->path.mnt, op->open_flag, op->acc_mode, mode)) {
61553 + error = -EACCES;
61554 + goto out_dput;
61555 + }
61556 +
61557 if (!IS_POSIXACL(dir->d_inode))
61558 mode &= ~current_umask();
61559 /*
61560 @@ -2856,6 +2905,8 @@ static int lookup_open(struct nameidata *nd, struct path *path,
61561 nd->flags & LOOKUP_EXCL);
61562 if (error)
61563 goto out_dput;
61564 + else
61565 + gr_handle_create(dentry, nd->path.mnt);
61566 }
61567 out_no_open:
61568 path->dentry = dentry;
61569 @@ -2870,7 +2921,7 @@ out_dput:
61570 /*
61571 * Handle the last step of open()
61572 */
61573 -static int do_last(struct nameidata *nd, struct path *path,
61574 +static int do_last(struct nameidata *nd, struct path *path, struct path *link,
61575 struct file *file, const struct open_flags *op,
61576 int *opened, struct filename *name)
61577 {
61578 @@ -2920,6 +2971,15 @@ static int do_last(struct nameidata *nd, struct path *path,
61579 if (error)
61580 return error;
61581
61582 + if (!gr_acl_handle_hidden_file(dir, nd->path.mnt)) {
61583 + error = -ENOENT;
61584 + goto out;
61585 + }
61586 + if (link && gr_handle_symlink_owner(link, nd->inode)) {
61587 + error = -EACCES;
61588 + goto out;
61589 + }
61590 +
61591 audit_inode(name, dir, LOOKUP_PARENT);
61592 error = -EISDIR;
61593 /* trailing slashes? */
61594 @@ -2939,7 +2999,7 @@ retry_lookup:
61595 */
61596 }
61597 mutex_lock(&dir->d_inode->i_mutex);
61598 - error = lookup_open(nd, path, file, op, got_write, opened);
61599 + error = lookup_open(nd, path, link, file, op, got_write, opened);
61600 mutex_unlock(&dir->d_inode->i_mutex);
61601
61602 if (error <= 0) {
61603 @@ -2963,11 +3023,28 @@ retry_lookup:
61604 goto finish_open_created;
61605 }
61606
61607 + if (!gr_acl_handle_hidden_file(path->dentry, nd->path.mnt)) {
61608 + error = -ENOENT;
61609 + goto exit_dput;
61610 + }
61611 + if (link && gr_handle_symlink_owner(link, path->dentry->d_inode)) {
61612 + error = -EACCES;
61613 + goto exit_dput;
61614 + }
61615 +
61616 /*
61617 * create/update audit record if it already exists.
61618 */
61619 - if (d_is_positive(path->dentry))
61620 + if (d_is_positive(path->dentry)) {
61621 + /* only check if O_CREAT is specified, all other checks need to go
61622 + into may_open */
61623 + if (gr_handle_fifo(path->dentry, path->mnt, dir, open_flag, acc_mode)) {
61624 + error = -EACCES;
61625 + goto exit_dput;
61626 + }
61627 +
61628 audit_inode(name, path->dentry, 0);
61629 + }
61630
61631 /*
61632 * If atomic_open() acquired write access it is dropped now due to
61633 @@ -3008,6 +3085,11 @@ finish_lookup:
61634 }
61635 }
61636 BUG_ON(inode != path->dentry->d_inode);
61637 + /* if we're resolving a symlink to another symlink */
61638 + if (link && gr_handle_symlink_owner(link, inode)) {
61639 + error = -EACCES;
61640 + goto out;
61641 + }
61642 return 1;
61643 }
61644
61645 @@ -3017,7 +3099,6 @@ finish_lookup:
61646 save_parent.dentry = nd->path.dentry;
61647 save_parent.mnt = mntget(path->mnt);
61648 nd->path.dentry = path->dentry;
61649 -
61650 }
61651 nd->inode = inode;
61652 /* Why this, you ask? _Now_ we might have grown LOOKUP_JUMPED... */
61653 @@ -3027,7 +3108,18 @@ finish_open:
61654 path_put(&save_parent);
61655 return error;
61656 }
61657 +
61658 + if (!gr_acl_handle_hidden_file(nd->path.dentry, nd->path.mnt)) {
61659 + error = -ENOENT;
61660 + goto out;
61661 + }
61662 + if (link && gr_handle_symlink_owner(link, nd->inode)) {
61663 + error = -EACCES;
61664 + goto out;
61665 + }
61666 +
61667 audit_inode(name, nd->path.dentry, 0);
61668 +
61669 error = -EISDIR;
61670 if ((open_flag & O_CREAT) && d_is_dir(nd->path.dentry))
61671 goto out;
61672 @@ -3190,7 +3282,7 @@ static struct file *path_openat(int dfd, struct filename *pathname,
61673 if (unlikely(error))
61674 goto out;
61675
61676 - error = do_last(nd, &path, file, op, &opened, pathname);
61677 + error = do_last(nd, &path, NULL, file, op, &opened, pathname);
61678 while (unlikely(error > 0)) { /* trailing symlink */
61679 struct path link = path;
61680 void *cookie;
61681 @@ -3208,7 +3300,7 @@ static struct file *path_openat(int dfd, struct filename *pathname,
61682 error = follow_link(&link, nd, &cookie);
61683 if (unlikely(error))
61684 break;
61685 - error = do_last(nd, &path, file, op, &opened, pathname);
61686 + error = do_last(nd, &path, &link, file, op, &opened, pathname);
61687 put_link(nd, &link, cookie);
61688 }
61689 out:
61690 @@ -3308,9 +3400,11 @@ struct dentry *kern_path_create(int dfd, const char *pathname,
61691 goto unlock;
61692
61693 error = -EEXIST;
61694 - if (d_is_positive(dentry))
61695 + if (d_is_positive(dentry)) {
61696 + if (!gr_acl_handle_hidden_file(dentry, nd.path.mnt))
61697 + error = -ENOENT;
61698 goto fail;
61699 -
61700 + }
61701 /*
61702 * Special case - lookup gave negative, but... we had foo/bar/
61703 * From the vfs_mknod() POV we just have a negative dentry -
61704 @@ -3362,6 +3456,20 @@ struct dentry *user_path_create(int dfd, const char __user *pathname,
61705 }
61706 EXPORT_SYMBOL(user_path_create);
61707
61708 +static struct dentry *user_path_create_with_name(int dfd, const char __user *pathname, struct path *path, struct filename **to, unsigned int lookup_flags)
61709 +{
61710 + struct filename *tmp = getname(pathname);
61711 + struct dentry *res;
61712 + if (IS_ERR(tmp))
61713 + return ERR_CAST(tmp);
61714 + res = kern_path_create(dfd, tmp->name, path, lookup_flags);
61715 + if (IS_ERR(res))
61716 + putname(tmp);
61717 + else
61718 + *to = tmp;
61719 + return res;
61720 +}
61721 +
61722 int vfs_mknod(struct inode *dir, struct dentry *dentry, umode_t mode, dev_t dev)
61723 {
61724 int error = may_create(dir, dentry);
61725 @@ -3425,6 +3533,17 @@ retry:
61726
61727 if (!IS_POSIXACL(path.dentry->d_inode))
61728 mode &= ~current_umask();
61729 +
61730 + if (gr_handle_chroot_mknod(dentry, path.mnt, mode)) {
61731 + error = -EPERM;
61732 + goto out;
61733 + }
61734 +
61735 + if (!gr_acl_handle_mknod(dentry, path.dentry, path.mnt, mode)) {
61736 + error = -EACCES;
61737 + goto out;
61738 + }
61739 +
61740 error = security_path_mknod(&path, dentry, mode, dev);
61741 if (error)
61742 goto out;
61743 @@ -3441,6 +3560,8 @@ retry:
61744 break;
61745 }
61746 out:
61747 + if (!error)
61748 + gr_handle_create(dentry, path.mnt);
61749 done_path_create(&path, dentry);
61750 if (retry_estale(error, lookup_flags)) {
61751 lookup_flags |= LOOKUP_REVAL;
61752 @@ -3494,9 +3615,16 @@ retry:
61753
61754 if (!IS_POSIXACL(path.dentry->d_inode))
61755 mode &= ~current_umask();
61756 + if (!gr_acl_handle_mkdir(dentry, path.dentry, path.mnt)) {
61757 + error = -EACCES;
61758 + goto out;
61759 + }
61760 error = security_path_mkdir(&path, dentry, mode);
61761 if (!error)
61762 error = vfs_mkdir(path.dentry->d_inode, dentry, mode);
61763 + if (!error)
61764 + gr_handle_create(dentry, path.mnt);
61765 +out:
61766 done_path_create(&path, dentry);
61767 if (retry_estale(error, lookup_flags)) {
61768 lookup_flags |= LOOKUP_REVAL;
61769 @@ -3579,6 +3707,8 @@ static long do_rmdir(int dfd, const char __user *pathname)
61770 struct filename *name;
61771 struct dentry *dentry;
61772 struct nameidata nd;
61773 + ino_t saved_ino = 0;
61774 + dev_t saved_dev = 0;
61775 unsigned int lookup_flags = 0;
61776 retry:
61777 name = user_path_parent(dfd, pathname, &nd, lookup_flags);
61778 @@ -3611,10 +3741,21 @@ retry:
61779 error = -ENOENT;
61780 goto exit3;
61781 }
61782 +
61783 + saved_ino = dentry->d_inode->i_ino;
61784 + saved_dev = gr_get_dev_from_dentry(dentry);
61785 +
61786 + if (!gr_acl_handle_rmdir(dentry, nd.path.mnt)) {
61787 + error = -EACCES;
61788 + goto exit3;
61789 + }
61790 +
61791 error = security_path_rmdir(&nd.path, dentry);
61792 if (error)
61793 goto exit3;
61794 error = vfs_rmdir(nd.path.dentry->d_inode, dentry);
61795 + if (!error && (saved_dev || saved_ino))
61796 + gr_handle_delete(saved_ino, saved_dev);
61797 exit3:
61798 dput(dentry);
61799 exit2:
61800 @@ -3705,6 +3846,8 @@ static long do_unlinkat(int dfd, const char __user *pathname)
61801 struct nameidata nd;
61802 struct inode *inode = NULL;
61803 struct inode *delegated_inode = NULL;
61804 + ino_t saved_ino = 0;
61805 + dev_t saved_dev = 0;
61806 unsigned int lookup_flags = 0;
61807 retry:
61808 name = user_path_parent(dfd, pathname, &nd, lookup_flags);
61809 @@ -3731,10 +3874,22 @@ retry_deleg:
61810 if (d_is_negative(dentry))
61811 goto slashes;
61812 ihold(inode);
61813 +
61814 + if (inode->i_nlink <= 1) {
61815 + saved_ino = inode->i_ino;
61816 + saved_dev = gr_get_dev_from_dentry(dentry);
61817 + }
61818 + if (!gr_acl_handle_unlink(dentry, nd.path.mnt)) {
61819 + error = -EACCES;
61820 + goto exit2;
61821 + }
61822 +
61823 error = security_path_unlink(&nd.path, dentry);
61824 if (error)
61825 goto exit2;
61826 error = vfs_unlink(nd.path.dentry->d_inode, dentry, &delegated_inode);
61827 + if (!error && (saved_ino || saved_dev))
61828 + gr_handle_delete(saved_ino, saved_dev);
61829 exit2:
61830 dput(dentry);
61831 }
61832 @@ -3823,9 +3978,17 @@ retry:
61833 if (IS_ERR(dentry))
61834 goto out_putname;
61835
61836 + if (!gr_acl_handle_symlink(dentry, path.dentry, path.mnt, from)) {
61837 + error = -EACCES;
61838 + goto out;
61839 + }
61840 +
61841 error = security_path_symlink(&path, dentry, from->name);
61842 if (!error)
61843 error = vfs_symlink(path.dentry->d_inode, dentry, from->name);
61844 + if (!error)
61845 + gr_handle_create(dentry, path.mnt);
61846 +out:
61847 done_path_create(&path, dentry);
61848 if (retry_estale(error, lookup_flags)) {
61849 lookup_flags |= LOOKUP_REVAL;
61850 @@ -3929,6 +4092,7 @@ SYSCALL_DEFINE5(linkat, int, olddfd, const char __user *, oldname,
61851 struct dentry *new_dentry;
61852 struct path old_path, new_path;
61853 struct inode *delegated_inode = NULL;
61854 + struct filename *to = NULL;
61855 int how = 0;
61856 int error;
61857
61858 @@ -3952,7 +4116,7 @@ retry:
61859 if (error)
61860 return error;
61861
61862 - new_dentry = user_path_create(newdfd, newname, &new_path,
61863 + new_dentry = user_path_create_with_name(newdfd, newname, &new_path, &to,
61864 (how & LOOKUP_REVAL));
61865 error = PTR_ERR(new_dentry);
61866 if (IS_ERR(new_dentry))
61867 @@ -3964,11 +4128,28 @@ retry:
61868 error = may_linkat(&old_path);
61869 if (unlikely(error))
61870 goto out_dput;
61871 +
61872 + if (gr_handle_hardlink(old_path.dentry, old_path.mnt,
61873 + old_path.dentry->d_inode,
61874 + old_path.dentry->d_inode->i_mode, to)) {
61875 + error = -EACCES;
61876 + goto out_dput;
61877 + }
61878 +
61879 + if (!gr_acl_handle_link(new_dentry, new_path.dentry, new_path.mnt,
61880 + old_path.dentry, old_path.mnt, to)) {
61881 + error = -EACCES;
61882 + goto out_dput;
61883 + }
61884 +
61885 error = security_path_link(old_path.dentry, &new_path, new_dentry);
61886 if (error)
61887 goto out_dput;
61888 error = vfs_link(old_path.dentry, new_path.dentry->d_inode, new_dentry, &delegated_inode);
61889 + if (!error)
61890 + gr_handle_create(new_dentry, new_path.mnt);
61891 out_dput:
61892 + putname(to);
61893 done_path_create(&new_path, new_dentry);
61894 if (delegated_inode) {
61895 error = break_deleg_wait(&delegated_inode);
61896 @@ -4278,6 +4459,12 @@ retry_deleg:
61897 if (new_dentry == trap)
61898 goto exit5;
61899
61900 + error = gr_acl_handle_rename(new_dentry, new_dir, newnd.path.mnt,
61901 + old_dentry, old_dir->d_inode, oldnd.path.mnt,
61902 + to, flags);
61903 + if (error)
61904 + goto exit5;
61905 +
61906 error = security_path_rename(&oldnd.path, old_dentry,
61907 &newnd.path, new_dentry, flags);
61908 if (error)
61909 @@ -4285,6 +4472,9 @@ retry_deleg:
61910 error = vfs_rename(old_dir->d_inode, old_dentry,
61911 new_dir->d_inode, new_dentry,
61912 &delegated_inode, flags);
61913 + if (!error)
61914 + gr_handle_rename(old_dir->d_inode, new_dir->d_inode, old_dentry,
61915 + new_dentry, oldnd.path.mnt, new_dentry->d_inode ? 1 : 0, flags);
61916 exit5:
61917 dput(new_dentry);
61918 exit4:
61919 @@ -4327,14 +4517,24 @@ SYSCALL_DEFINE2(rename, const char __user *, oldname, const char __user *, newna
61920
61921 int readlink_copy(char __user *buffer, int buflen, const char *link)
61922 {
61923 + char tmpbuf[64];
61924 + const char *newlink;
61925 int len = PTR_ERR(link);
61926 +
61927 if (IS_ERR(link))
61928 goto out;
61929
61930 len = strlen(link);
61931 if (len > (unsigned) buflen)
61932 len = buflen;
61933 - if (copy_to_user(buffer, link, len))
61934 +
61935 + if (len < sizeof(tmpbuf)) {
61936 + memcpy(tmpbuf, link, len);
61937 + newlink = tmpbuf;
61938 + } else
61939 + newlink = link;
61940 +
61941 + if (copy_to_user(buffer, newlink, len))
61942 len = -EFAULT;
61943 out:
61944 return len;
61945 diff --git a/fs/namespace.c b/fs/namespace.c
61946 index 182bc41..72e3cf1 100644
61947 --- a/fs/namespace.c
61948 +++ b/fs/namespace.c
61949 @@ -1348,6 +1348,9 @@ static int do_umount(struct mount *mnt, int flags)
61950 if (!(sb->s_flags & MS_RDONLY))
61951 retval = do_remount_sb(sb, MS_RDONLY, NULL, 0);
61952 up_write(&sb->s_umount);
61953 +
61954 + gr_log_remount(mnt->mnt_devname, retval);
61955 +
61956 return retval;
61957 }
61958
61959 @@ -1370,6 +1373,9 @@ static int do_umount(struct mount *mnt, int flags)
61960 }
61961 unlock_mount_hash();
61962 namespace_unlock();
61963 +
61964 + gr_log_unmount(mnt->mnt_devname, retval);
61965 +
61966 return retval;
61967 }
61968
61969 @@ -1389,7 +1395,7 @@ static inline bool may_mount(void)
61970 * unixes. Our API is identical to OSF/1 to avoid making a mess of AMD
61971 */
61972
61973 -SYSCALL_DEFINE2(umount, char __user *, name, int, flags)
61974 +SYSCALL_DEFINE2(umount, const char __user *, name, int, flags)
61975 {
61976 struct path path;
61977 struct mount *mnt;
61978 @@ -1431,7 +1437,7 @@ out:
61979 /*
61980 * The 2.0 compatible umount. No flags.
61981 */
61982 -SYSCALL_DEFINE1(oldumount, char __user *, name)
61983 +SYSCALL_DEFINE1(oldumount, const char __user *, name)
61984 {
61985 return sys_umount(name, 0);
61986 }
61987 @@ -2440,6 +2446,16 @@ long do_mount(const char *dev_name, const char *dir_name,
61988 MS_NOATIME | MS_NODIRATIME | MS_RELATIME| MS_KERNMOUNT |
61989 MS_STRICTATIME);
61990
61991 + if (gr_handle_rofs_mount(path.dentry, path.mnt, mnt_flags)) {
61992 + retval = -EPERM;
61993 + goto dput_out;
61994 + }
61995 +
61996 + if (gr_handle_chroot_mount(path.dentry, path.mnt, dev_name)) {
61997 + retval = -EPERM;
61998 + goto dput_out;
61999 + }
62000 +
62001 if (flags & MS_REMOUNT)
62002 retval = do_remount(&path, flags & ~MS_REMOUNT, mnt_flags,
62003 data_page);
62004 @@ -2454,6 +2470,9 @@ long do_mount(const char *dev_name, const char *dir_name,
62005 dev_name, data_page);
62006 dput_out:
62007 path_put(&path);
62008 +
62009 + gr_log_mount(dev_name, dir_name, retval);
62010 +
62011 return retval;
62012 }
62013
62014 @@ -2471,7 +2490,7 @@ static void free_mnt_ns(struct mnt_namespace *ns)
62015 * number incrementing at 10Ghz will take 12,427 years to wrap which
62016 * is effectively never, so we can ignore the possibility.
62017 */
62018 -static atomic64_t mnt_ns_seq = ATOMIC64_INIT(1);
62019 +static atomic64_unchecked_t mnt_ns_seq = ATOMIC64_INIT(1);
62020
62021 static struct mnt_namespace *alloc_mnt_ns(struct user_namespace *user_ns)
62022 {
62023 @@ -2486,7 +2505,7 @@ static struct mnt_namespace *alloc_mnt_ns(struct user_namespace *user_ns)
62024 kfree(new_ns);
62025 return ERR_PTR(ret);
62026 }
62027 - new_ns->seq = atomic64_add_return(1, &mnt_ns_seq);
62028 + new_ns->seq = atomic64_inc_return_unchecked(&mnt_ns_seq);
62029 atomic_set(&new_ns->count, 1);
62030 new_ns->root = NULL;
62031 INIT_LIST_HEAD(&new_ns->list);
62032 @@ -2496,7 +2515,7 @@ static struct mnt_namespace *alloc_mnt_ns(struct user_namespace *user_ns)
62033 return new_ns;
62034 }
62035
62036 -struct mnt_namespace *copy_mnt_ns(unsigned long flags, struct mnt_namespace *ns,
62037 +__latent_entropy struct mnt_namespace *copy_mnt_ns(unsigned long flags, struct mnt_namespace *ns,
62038 struct user_namespace *user_ns, struct fs_struct *new_fs)
62039 {
62040 struct mnt_namespace *new_ns;
62041 @@ -2617,8 +2636,8 @@ struct dentry *mount_subtree(struct vfsmount *mnt, const char *name)
62042 }
62043 EXPORT_SYMBOL(mount_subtree);
62044
62045 -SYSCALL_DEFINE5(mount, char __user *, dev_name, char __user *, dir_name,
62046 - char __user *, type, unsigned long, flags, void __user *, data)
62047 +SYSCALL_DEFINE5(mount, const char __user *, dev_name, const char __user *, dir_name,
62048 + const char __user *, type, unsigned long, flags, void __user *, data)
62049 {
62050 int ret;
62051 char *kernel_type;
62052 @@ -2731,6 +2750,11 @@ SYSCALL_DEFINE2(pivot_root, const char __user *, new_root,
62053 if (error)
62054 goto out2;
62055
62056 + if (gr_handle_chroot_pivot()) {
62057 + error = -EPERM;
62058 + goto out2;
62059 + }
62060 +
62061 get_fs_root(current->fs, &root);
62062 old_mp = lock_mount(&old);
62063 error = PTR_ERR(old_mp);
62064 @@ -2999,7 +3023,7 @@ static int mntns_install(struct nsproxy *nsproxy, void *ns)
62065 !ns_capable(current_user_ns(), CAP_SYS_ADMIN))
62066 return -EPERM;
62067
62068 - if (fs->users != 1)
62069 + if (atomic_read(&fs->users) != 1)
62070 return -EINVAL;
62071
62072 get_mnt_ns(mnt_ns);
62073 diff --git a/fs/nfs/callback_xdr.c b/fs/nfs/callback_xdr.c
62074 index f4ccfe6..a5cf064 100644
62075 --- a/fs/nfs/callback_xdr.c
62076 +++ b/fs/nfs/callback_xdr.c
62077 @@ -51,7 +51,7 @@ struct callback_op {
62078 callback_decode_arg_t decode_args;
62079 callback_encode_res_t encode_res;
62080 long res_maxsize;
62081 -};
62082 +} __do_const;
62083
62084 static struct callback_op callback_ops[];
62085
62086 diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
62087 index 0c43897..0949f08 100644
62088 --- a/fs/nfs/inode.c
62089 +++ b/fs/nfs/inode.c
62090 @@ -1209,16 +1209,16 @@ static int nfs_size_need_update(const struct inode *inode, const struct nfs_fatt
62091 return nfs_size_to_loff_t(fattr->size) > i_size_read(inode);
62092 }
62093
62094 -static atomic_long_t nfs_attr_generation_counter;
62095 +static atomic_long_unchecked_t nfs_attr_generation_counter;
62096
62097 static unsigned long nfs_read_attr_generation_counter(void)
62098 {
62099 - return atomic_long_read(&nfs_attr_generation_counter);
62100 + return atomic_long_read_unchecked(&nfs_attr_generation_counter);
62101 }
62102
62103 unsigned long nfs_inc_attr_generation_counter(void)
62104 {
62105 - return atomic_long_inc_return(&nfs_attr_generation_counter);
62106 + return atomic_long_inc_return_unchecked(&nfs_attr_generation_counter);
62107 }
62108
62109 void nfs_fattr_init(struct nfs_fattr *fattr)
62110 diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c
62111 index d543222..2cfa2a2 100644
62112 --- a/fs/nfsd/nfs4proc.c
62113 +++ b/fs/nfsd/nfs4proc.c
62114 @@ -1178,7 +1178,7 @@ struct nfsd4_operation {
62115 nfsd4op_rsize op_rsize_bop;
62116 stateid_getter op_get_currentstateid;
62117 stateid_setter op_set_currentstateid;
62118 -};
62119 +} __do_const;
62120
62121 static struct nfsd4_operation nfsd4_ops[];
62122
62123 diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
62124 index 18881f3..40e5bef 100644
62125 --- a/fs/nfsd/nfs4xdr.c
62126 +++ b/fs/nfsd/nfs4xdr.c
62127 @@ -1530,7 +1530,7 @@ nfsd4_decode_notsupp(struct nfsd4_compoundargs *argp, void *p)
62128
62129 typedef __be32(*nfsd4_dec)(struct nfsd4_compoundargs *argp, void *);
62130
62131 -static nfsd4_dec nfsd4_dec_ops[] = {
62132 +static const nfsd4_dec nfsd4_dec_ops[] = {
62133 [OP_ACCESS] = (nfsd4_dec)nfsd4_decode_access,
62134 [OP_CLOSE] = (nfsd4_dec)nfsd4_decode_close,
62135 [OP_COMMIT] = (nfsd4_dec)nfsd4_decode_commit,
62136 diff --git a/fs/nfsd/nfscache.c b/fs/nfsd/nfscache.c
62137 index f8f060f..c4ba09a 100644
62138 --- a/fs/nfsd/nfscache.c
62139 +++ b/fs/nfsd/nfscache.c
62140 @@ -519,14 +519,17 @@ nfsd_cache_update(struct svc_rqst *rqstp, int cachetype, __be32 *statp)
62141 {
62142 struct svc_cacherep *rp = rqstp->rq_cacherep;
62143 struct kvec *resv = &rqstp->rq_res.head[0], *cachv;
62144 - int len;
62145 + long len;
62146 size_t bufsize = 0;
62147
62148 if (!rp)
62149 return;
62150
62151 - len = resv->iov_len - ((char*)statp - (char*)resv->iov_base);
62152 - len >>= 2;
62153 + if (statp) {
62154 + len = (char*)statp - (char*)resv->iov_base;
62155 + len = resv->iov_len - len;
62156 + len >>= 2;
62157 + }
62158
62159 /* Don't cache excessive amounts of data and XDR failures */
62160 if (!statp || len > (256 >> 2)) {
62161 diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
62162 index 16f0673..1c2c30ab 100644
62163 --- a/fs/nfsd/vfs.c
62164 +++ b/fs/nfsd/vfs.c
62165 @@ -843,7 +843,7 @@ nfsd_vfs_read(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
62166 } else {
62167 oldfs = get_fs();
62168 set_fs(KERNEL_DS);
62169 - host_err = vfs_readv(file, (struct iovec __user *)vec, vlen, &offset);
62170 + host_err = vfs_readv(file, (struct iovec __force_user *)vec, vlen, &offset);
62171 set_fs(oldfs);
62172 }
62173
62174 @@ -934,7 +934,7 @@ nfsd_vfs_write(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
62175
62176 /* Write the data. */
62177 oldfs = get_fs(); set_fs(KERNEL_DS);
62178 - host_err = vfs_writev(file, (struct iovec __user *)vec, vlen, &pos);
62179 + host_err = vfs_writev(file, (struct iovec __force_user *)vec, vlen, &pos);
62180 set_fs(oldfs);
62181 if (host_err < 0)
62182 goto out_nfserr;
62183 @@ -1479,7 +1479,7 @@ nfsd_readlink(struct svc_rqst *rqstp, struct svc_fh *fhp, char *buf, int *lenp)
62184 */
62185
62186 oldfs = get_fs(); set_fs(KERNEL_DS);
62187 - host_err = inode->i_op->readlink(path.dentry, (char __user *)buf, *lenp);
62188 + host_err = inode->i_op->readlink(path.dentry, (char __force_user *)buf, *lenp);
62189 set_fs(oldfs);
62190
62191 if (host_err < 0)
62192 diff --git a/fs/nls/nls_base.c b/fs/nls/nls_base.c
62193 index 52ccd34..43a53b1 100644
62194 --- a/fs/nls/nls_base.c
62195 +++ b/fs/nls/nls_base.c
62196 @@ -234,21 +234,25 @@ EXPORT_SYMBOL(utf16s_to_utf8s);
62197
62198 int __register_nls(struct nls_table *nls, struct module *owner)
62199 {
62200 - struct nls_table ** tmp = &tables;
62201 + struct nls_table *tmp = tables;
62202
62203 if (nls->next)
62204 return -EBUSY;
62205
62206 - nls->owner = owner;
62207 + pax_open_kernel();
62208 + *(void **)&nls->owner = owner;
62209 + pax_close_kernel();
62210 spin_lock(&nls_lock);
62211 - while (*tmp) {
62212 - if (nls == *tmp) {
62213 + while (tmp) {
62214 + if (nls == tmp) {
62215 spin_unlock(&nls_lock);
62216 return -EBUSY;
62217 }
62218 - tmp = &(*tmp)->next;
62219 + tmp = tmp->next;
62220 }
62221 - nls->next = tables;
62222 + pax_open_kernel();
62223 + *(struct nls_table **)&nls->next = tables;
62224 + pax_close_kernel();
62225 tables = nls;
62226 spin_unlock(&nls_lock);
62227 return 0;
62228 @@ -257,12 +261,14 @@ EXPORT_SYMBOL(__register_nls);
62229
62230 int unregister_nls(struct nls_table * nls)
62231 {
62232 - struct nls_table ** tmp = &tables;
62233 + struct nls_table * const * tmp = &tables;
62234
62235 spin_lock(&nls_lock);
62236 while (*tmp) {
62237 if (nls == *tmp) {
62238 - *tmp = nls->next;
62239 + pax_open_kernel();
62240 + *(struct nls_table **)tmp = nls->next;
62241 + pax_close_kernel();
62242 spin_unlock(&nls_lock);
62243 return 0;
62244 }
62245 diff --git a/fs/nls/nls_euc-jp.c b/fs/nls/nls_euc-jp.c
62246 index 162b3f1..6076a7c 100644
62247 --- a/fs/nls/nls_euc-jp.c
62248 +++ b/fs/nls/nls_euc-jp.c
62249 @@ -560,8 +560,10 @@ static int __init init_nls_euc_jp(void)
62250 p_nls = load_nls("cp932");
62251
62252 if (p_nls) {
62253 - table.charset2upper = p_nls->charset2upper;
62254 - table.charset2lower = p_nls->charset2lower;
62255 + pax_open_kernel();
62256 + *(const unsigned char **)&table.charset2upper = p_nls->charset2upper;
62257 + *(const unsigned char **)&table.charset2lower = p_nls->charset2lower;
62258 + pax_close_kernel();
62259 return register_nls(&table);
62260 }
62261
62262 diff --git a/fs/nls/nls_koi8-ru.c b/fs/nls/nls_koi8-ru.c
62263 index a80a741..7b96e1b 100644
62264 --- a/fs/nls/nls_koi8-ru.c
62265 +++ b/fs/nls/nls_koi8-ru.c
62266 @@ -62,8 +62,10 @@ static int __init init_nls_koi8_ru(void)
62267 p_nls = load_nls("koi8-u");
62268
62269 if (p_nls) {
62270 - table.charset2upper = p_nls->charset2upper;
62271 - table.charset2lower = p_nls->charset2lower;
62272 + pax_open_kernel();
62273 + *(const unsigned char **)&table.charset2upper = p_nls->charset2upper;
62274 + *(const unsigned char **)&table.charset2lower = p_nls->charset2lower;
62275 + pax_close_kernel();
62276 return register_nls(&table);
62277 }
62278
62279 diff --git a/fs/notify/fanotify/fanotify_user.c b/fs/notify/fanotify/fanotify_user.c
62280 index 732648b..d3b017f 100644
62281 --- a/fs/notify/fanotify/fanotify_user.c
62282 +++ b/fs/notify/fanotify/fanotify_user.c
62283 @@ -203,8 +203,8 @@ static ssize_t copy_event_to_user(struct fsnotify_group *group,
62284
62285 fd = fanotify_event_metadata.fd;
62286 ret = -EFAULT;
62287 - if (copy_to_user(buf, &fanotify_event_metadata,
62288 - fanotify_event_metadata.event_len))
62289 + if (fanotify_event_metadata.event_len > sizeof fanotify_event_metadata ||
62290 + copy_to_user(buf, &fanotify_event_metadata, fanotify_event_metadata.event_len))
62291 goto out_close_fd;
62292
62293 #ifdef CONFIG_FANOTIFY_ACCESS_PERMISSIONS
62294 diff --git a/fs/notify/notification.c b/fs/notify/notification.c
62295 index 1e58402..bb2d6f4 100644
62296 --- a/fs/notify/notification.c
62297 +++ b/fs/notify/notification.c
62298 @@ -48,7 +48,7 @@
62299 #include <linux/fsnotify_backend.h>
62300 #include "fsnotify.h"
62301
62302 -static atomic_t fsnotify_sync_cookie = ATOMIC_INIT(0);
62303 +static atomic_unchecked_t fsnotify_sync_cookie = ATOMIC_INIT(0);
62304
62305 /**
62306 * fsnotify_get_cookie - return a unique cookie for use in synchronizing events.
62307 @@ -56,7 +56,7 @@ static atomic_t fsnotify_sync_cookie = ATOMIC_INIT(0);
62308 */
62309 u32 fsnotify_get_cookie(void)
62310 {
62311 - return atomic_inc_return(&fsnotify_sync_cookie);
62312 + return atomic_inc_return_unchecked(&fsnotify_sync_cookie);
62313 }
62314 EXPORT_SYMBOL_GPL(fsnotify_get_cookie);
62315
62316 diff --git a/fs/ntfs/dir.c b/fs/ntfs/dir.c
62317 index 9e38daf..5727cae 100644
62318 --- a/fs/ntfs/dir.c
62319 +++ b/fs/ntfs/dir.c
62320 @@ -1310,7 +1310,7 @@ find_next_index_buffer:
62321 ia = (INDEX_ALLOCATION*)(kaddr + (ia_pos & ~PAGE_CACHE_MASK &
62322 ~(s64)(ndir->itype.index.block_size - 1)));
62323 /* Bounds checks. */
62324 - if (unlikely((u8*)ia < kaddr || (u8*)ia > kaddr + PAGE_CACHE_SIZE)) {
62325 + if (unlikely(!kaddr || (u8*)ia < kaddr || (u8*)ia > kaddr + PAGE_CACHE_SIZE)) {
62326 ntfs_error(sb, "Out of bounds check failed. Corrupt directory "
62327 "inode 0x%lx or driver bug.", vdir->i_ino);
62328 goto err_out;
62329 diff --git a/fs/ntfs/file.c b/fs/ntfs/file.c
62330 index db9bd8a..8338fb6 100644
62331 --- a/fs/ntfs/file.c
62332 +++ b/fs/ntfs/file.c
62333 @@ -1282,7 +1282,7 @@ static inline size_t ntfs_copy_from_user(struct page **pages,
62334 char *addr;
62335 size_t total = 0;
62336 unsigned len;
62337 - int left;
62338 + unsigned left;
62339
62340 do {
62341 len = PAGE_CACHE_SIZE - ofs;
62342 diff --git a/fs/ntfs/super.c b/fs/ntfs/super.c
62343 index 9de2491..3306095 100644
62344 --- a/fs/ntfs/super.c
62345 +++ b/fs/ntfs/super.c
62346 @@ -688,7 +688,7 @@ static struct buffer_head *read_ntfs_boot_sector(struct super_block *sb,
62347 if (!silent)
62348 ntfs_error(sb, "Primary boot sector is invalid.");
62349 } else if (!silent)
62350 - ntfs_error(sb, read_err_str, "primary");
62351 + ntfs_error(sb, read_err_str, "%s", "primary");
62352 if (!(NTFS_SB(sb)->on_errors & ON_ERRORS_RECOVER)) {
62353 if (bh_primary)
62354 brelse(bh_primary);
62355 @@ -704,7 +704,7 @@ static struct buffer_head *read_ntfs_boot_sector(struct super_block *sb,
62356 goto hotfix_primary_boot_sector;
62357 brelse(bh_backup);
62358 } else if (!silent)
62359 - ntfs_error(sb, read_err_str, "backup");
62360 + ntfs_error(sb, read_err_str, "%s", "backup");
62361 /* Try to read NT3.51- backup boot sector. */
62362 if ((bh_backup = sb_bread(sb, nr_blocks >> 1))) {
62363 if (is_boot_sector_ntfs(sb, (NTFS_BOOT_SECTOR*)
62364 @@ -715,7 +715,7 @@ static struct buffer_head *read_ntfs_boot_sector(struct super_block *sb,
62365 "sector.");
62366 brelse(bh_backup);
62367 } else if (!silent)
62368 - ntfs_error(sb, read_err_str, "backup");
62369 + ntfs_error(sb, read_err_str, "%s", "backup");
62370 /* We failed. Cleanup and return. */
62371 if (bh_primary)
62372 brelse(bh_primary);
62373 diff --git a/fs/ocfs2/localalloc.c b/fs/ocfs2/localalloc.c
62374 index 0440134..d52c93a 100644
62375 --- a/fs/ocfs2/localalloc.c
62376 +++ b/fs/ocfs2/localalloc.c
62377 @@ -1320,7 +1320,7 @@ static int ocfs2_local_alloc_slide_window(struct ocfs2_super *osb,
62378 goto bail;
62379 }
62380
62381 - atomic_inc(&osb->alloc_stats.moves);
62382 + atomic_inc_unchecked(&osb->alloc_stats.moves);
62383
62384 bail:
62385 if (handle)
62386 diff --git a/fs/ocfs2/ocfs2.h b/fs/ocfs2/ocfs2.h
62387 index 8d64a97..c37665d 100644
62388 --- a/fs/ocfs2/ocfs2.h
62389 +++ b/fs/ocfs2/ocfs2.h
62390 @@ -236,11 +236,11 @@ enum ocfs2_vol_state
62391
62392 struct ocfs2_alloc_stats
62393 {
62394 - atomic_t moves;
62395 - atomic_t local_data;
62396 - atomic_t bitmap_data;
62397 - atomic_t bg_allocs;
62398 - atomic_t bg_extends;
62399 + atomic_unchecked_t moves;
62400 + atomic_unchecked_t local_data;
62401 + atomic_unchecked_t bitmap_data;
62402 + atomic_unchecked_t bg_allocs;
62403 + atomic_unchecked_t bg_extends;
62404 };
62405
62406 enum ocfs2_local_alloc_state
62407 diff --git a/fs/ocfs2/suballoc.c b/fs/ocfs2/suballoc.c
62408 index 0cb889a..6a26b24 100644
62409 --- a/fs/ocfs2/suballoc.c
62410 +++ b/fs/ocfs2/suballoc.c
62411 @@ -867,7 +867,7 @@ static int ocfs2_reserve_suballoc_bits(struct ocfs2_super *osb,
62412 mlog_errno(status);
62413 goto bail;
62414 }
62415 - atomic_inc(&osb->alloc_stats.bg_extends);
62416 + atomic_inc_unchecked(&osb->alloc_stats.bg_extends);
62417
62418 /* You should never ask for this much metadata */
62419 BUG_ON(bits_wanted >
62420 @@ -2014,7 +2014,7 @@ int ocfs2_claim_metadata(handle_t *handle,
62421 mlog_errno(status);
62422 goto bail;
62423 }
62424 - atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
62425 + atomic_inc_unchecked(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
62426
62427 *suballoc_loc = res.sr_bg_blkno;
62428 *suballoc_bit_start = res.sr_bit_offset;
62429 @@ -2180,7 +2180,7 @@ int ocfs2_claim_new_inode_at_loc(handle_t *handle,
62430 trace_ocfs2_claim_new_inode_at_loc((unsigned long long)di_blkno,
62431 res->sr_bits);
62432
62433 - atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
62434 + atomic_inc_unchecked(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
62435
62436 BUG_ON(res->sr_bits != 1);
62437
62438 @@ -2222,7 +2222,7 @@ int ocfs2_claim_new_inode(handle_t *handle,
62439 mlog_errno(status);
62440 goto bail;
62441 }
62442 - atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
62443 + atomic_inc_unchecked(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
62444
62445 BUG_ON(res.sr_bits != 1);
62446
62447 @@ -2326,7 +2326,7 @@ int __ocfs2_claim_clusters(handle_t *handle,
62448 cluster_start,
62449 num_clusters);
62450 if (!status)
62451 - atomic_inc(&osb->alloc_stats.local_data);
62452 + atomic_inc_unchecked(&osb->alloc_stats.local_data);
62453 } else {
62454 if (min_clusters > (osb->bitmap_cpg - 1)) {
62455 /* The only paths asking for contiguousness
62456 @@ -2352,7 +2352,7 @@ int __ocfs2_claim_clusters(handle_t *handle,
62457 ocfs2_desc_bitmap_to_cluster_off(ac->ac_inode,
62458 res.sr_bg_blkno,
62459 res.sr_bit_offset);
62460 - atomic_inc(&osb->alloc_stats.bitmap_data);
62461 + atomic_inc_unchecked(&osb->alloc_stats.bitmap_data);
62462 *num_clusters = res.sr_bits;
62463 }
62464 }
62465 diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c
62466 index a7cdd56..c583144 100644
62467 --- a/fs/ocfs2/super.c
62468 +++ b/fs/ocfs2/super.c
62469 @@ -300,11 +300,11 @@ static int ocfs2_osb_dump(struct ocfs2_super *osb, char *buf, int len)
62470 "%10s => GlobalAllocs: %d LocalAllocs: %d "
62471 "SubAllocs: %d LAWinMoves: %d SAExtends: %d\n",
62472 "Stats",
62473 - atomic_read(&osb->alloc_stats.bitmap_data),
62474 - atomic_read(&osb->alloc_stats.local_data),
62475 - atomic_read(&osb->alloc_stats.bg_allocs),
62476 - atomic_read(&osb->alloc_stats.moves),
62477 - atomic_read(&osb->alloc_stats.bg_extends));
62478 + atomic_read_unchecked(&osb->alloc_stats.bitmap_data),
62479 + atomic_read_unchecked(&osb->alloc_stats.local_data),
62480 + atomic_read_unchecked(&osb->alloc_stats.bg_allocs),
62481 + atomic_read_unchecked(&osb->alloc_stats.moves),
62482 + atomic_read_unchecked(&osb->alloc_stats.bg_extends));
62483
62484 out += snprintf(buf + out, len - out,
62485 "%10s => State: %u Descriptor: %llu Size: %u bits "
62486 @@ -2104,11 +2104,11 @@ static int ocfs2_initialize_super(struct super_block *sb,
62487
62488 mutex_init(&osb->system_file_mutex);
62489
62490 - atomic_set(&osb->alloc_stats.moves, 0);
62491 - atomic_set(&osb->alloc_stats.local_data, 0);
62492 - atomic_set(&osb->alloc_stats.bitmap_data, 0);
62493 - atomic_set(&osb->alloc_stats.bg_allocs, 0);
62494 - atomic_set(&osb->alloc_stats.bg_extends, 0);
62495 + atomic_set_unchecked(&osb->alloc_stats.moves, 0);
62496 + atomic_set_unchecked(&osb->alloc_stats.local_data, 0);
62497 + atomic_set_unchecked(&osb->alloc_stats.bitmap_data, 0);
62498 + atomic_set_unchecked(&osb->alloc_stats.bg_allocs, 0);
62499 + atomic_set_unchecked(&osb->alloc_stats.bg_extends, 0);
62500
62501 /* Copy the blockcheck stats from the superblock probe */
62502 osb->osb_ecc_stats = *stats;
62503 diff --git a/fs/open.c b/fs/open.c
62504 index 9d64679..75f925c 100644
62505 --- a/fs/open.c
62506 +++ b/fs/open.c
62507 @@ -32,6 +32,8 @@
62508 #include <linux/dnotify.h>
62509 #include <linux/compat.h>
62510
62511 +#define CREATE_TRACE_POINTS
62512 +#include <trace/events/fs.h>
62513 #include "internal.h"
62514
62515 int do_truncate(struct dentry *dentry, loff_t length, unsigned int time_attrs,
62516 @@ -103,6 +105,8 @@ long vfs_truncate(struct path *path, loff_t length)
62517 error = locks_verify_truncate(inode, NULL, length);
62518 if (!error)
62519 error = security_path_truncate(path);
62520 + if (!error && !gr_acl_handle_truncate(path->dentry, path->mnt))
62521 + error = -EACCES;
62522 if (!error)
62523 error = do_truncate(path->dentry, length, 0, NULL);
62524
62525 @@ -187,6 +191,8 @@ static long do_sys_ftruncate(unsigned int fd, loff_t length, int small)
62526 error = locks_verify_truncate(inode, f.file, length);
62527 if (!error)
62528 error = security_path_truncate(&f.file->f_path);
62529 + if (!error && !gr_acl_handle_truncate(f.file->f_path.dentry, f.file->f_path.mnt))
62530 + error = -EACCES;
62531 if (!error)
62532 error = do_truncate(dentry, length, ATTR_MTIME|ATTR_CTIME, f.file);
62533 sb_end_write(inode->i_sb);
62534 @@ -381,6 +387,9 @@ retry:
62535 if (__mnt_is_readonly(path.mnt))
62536 res = -EROFS;
62537
62538 + if (!res && !gr_acl_handle_access(path.dentry, path.mnt, mode))
62539 + res = -EACCES;
62540 +
62541 out_path_release:
62542 path_put(&path);
62543 if (retry_estale(res, lookup_flags)) {
62544 @@ -412,6 +421,8 @@ retry:
62545 if (error)
62546 goto dput_and_out;
62547
62548 + gr_log_chdir(path.dentry, path.mnt);
62549 +
62550 set_fs_pwd(current->fs, &path);
62551
62552 dput_and_out:
62553 @@ -441,6 +452,13 @@ SYSCALL_DEFINE1(fchdir, unsigned int, fd)
62554 goto out_putf;
62555
62556 error = inode_permission(inode, MAY_EXEC | MAY_CHDIR);
62557 +
62558 + if (!error && !gr_chroot_fchdir(f.file->f_path.dentry, f.file->f_path.mnt))
62559 + error = -EPERM;
62560 +
62561 + if (!error)
62562 + gr_log_chdir(f.file->f_path.dentry, f.file->f_path.mnt);
62563 +
62564 if (!error)
62565 set_fs_pwd(current->fs, &f.file->f_path);
62566 out_putf:
62567 @@ -470,7 +488,13 @@ retry:
62568 if (error)
62569 goto dput_and_out;
62570
62571 + if (gr_handle_chroot_chroot(path.dentry, path.mnt))
62572 + goto dput_and_out;
62573 +
62574 set_fs_root(current->fs, &path);
62575 +
62576 + gr_handle_chroot_chdir(&path);
62577 +
62578 error = 0;
62579 dput_and_out:
62580 path_put(&path);
62581 @@ -494,6 +518,16 @@ static int chmod_common(struct path *path, umode_t mode)
62582 return error;
62583 retry_deleg:
62584 mutex_lock(&inode->i_mutex);
62585 +
62586 + if (!gr_acl_handle_chmod(path->dentry, path->mnt, &mode)) {
62587 + error = -EACCES;
62588 + goto out_unlock;
62589 + }
62590 + if (gr_handle_chroot_chmod(path->dentry, path->mnt, mode)) {
62591 + error = -EACCES;
62592 + goto out_unlock;
62593 + }
62594 +
62595 error = security_path_chmod(path, mode);
62596 if (error)
62597 goto out_unlock;
62598 @@ -559,6 +593,9 @@ static int chown_common(struct path *path, uid_t user, gid_t group)
62599 uid = make_kuid(current_user_ns(), user);
62600 gid = make_kgid(current_user_ns(), group);
62601
62602 + if (!gr_acl_handle_chown(path->dentry, path->mnt))
62603 + return -EACCES;
62604 +
62605 newattrs.ia_valid = ATTR_CTIME;
62606 if (user != (uid_t) -1) {
62607 if (!uid_valid(uid))
62608 @@ -978,6 +1015,7 @@ long do_sys_open(int dfd, const char __user *filename, int flags, umode_t mode)
62609 } else {
62610 fsnotify_open(f);
62611 fd_install(fd, f);
62612 + trace_do_sys_open(tmp->name, flags, mode);
62613 }
62614 }
62615 putname(tmp);
62616 diff --git a/fs/pipe.c b/fs/pipe.c
62617 index 034bffa..6c6b522 100644
62618 --- a/fs/pipe.c
62619 +++ b/fs/pipe.c
62620 @@ -56,7 +56,7 @@ unsigned int pipe_min_size = PAGE_SIZE;
62621
62622 static void pipe_lock_nested(struct pipe_inode_info *pipe, int subclass)
62623 {
62624 - if (pipe->files)
62625 + if (atomic_read(&pipe->files))
62626 mutex_lock_nested(&pipe->mutex, subclass);
62627 }
62628
62629 @@ -71,7 +71,7 @@ EXPORT_SYMBOL(pipe_lock);
62630
62631 void pipe_unlock(struct pipe_inode_info *pipe)
62632 {
62633 - if (pipe->files)
62634 + if (atomic_read(&pipe->files))
62635 mutex_unlock(&pipe->mutex);
62636 }
62637 EXPORT_SYMBOL(pipe_unlock);
62638 @@ -342,9 +342,9 @@ pipe_read(struct kiocb *iocb, const struct iovec *_iov,
62639 }
62640 if (bufs) /* More to do? */
62641 continue;
62642 - if (!pipe->writers)
62643 + if (!atomic_read(&pipe->writers))
62644 break;
62645 - if (!pipe->waiting_writers) {
62646 + if (!atomic_read(&pipe->waiting_writers)) {
62647 /* syscall merging: Usually we must not sleep
62648 * if O_NONBLOCK is set, or if we got some data.
62649 * But if a writer sleeps in kernel space, then
62650 @@ -406,7 +406,7 @@ pipe_write(struct kiocb *iocb, const struct iovec *_iov,
62651 ret = 0;
62652 __pipe_lock(pipe);
62653
62654 - if (!pipe->readers) {
62655 + if (!atomic_read(&pipe->readers)) {
62656 send_sig(SIGPIPE, current, 0);
62657 ret = -EPIPE;
62658 goto out;
62659 @@ -461,7 +461,7 @@ redo1:
62660 for (;;) {
62661 int bufs;
62662
62663 - if (!pipe->readers) {
62664 + if (!atomic_read(&pipe->readers)) {
62665 send_sig(SIGPIPE, current, 0);
62666 if (!ret)
62667 ret = -EPIPE;
62668 @@ -552,9 +552,9 @@ redo2:
62669 kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
62670 do_wakeup = 0;
62671 }
62672 - pipe->waiting_writers++;
62673 + atomic_inc(&pipe->waiting_writers);
62674 pipe_wait(pipe);
62675 - pipe->waiting_writers--;
62676 + atomic_dec(&pipe->waiting_writers);
62677 }
62678 out:
62679 __pipe_unlock(pipe);
62680 @@ -609,7 +609,7 @@ pipe_poll(struct file *filp, poll_table *wait)
62681 mask = 0;
62682 if (filp->f_mode & FMODE_READ) {
62683 mask = (nrbufs > 0) ? POLLIN | POLLRDNORM : 0;
62684 - if (!pipe->writers && filp->f_version != pipe->w_counter)
62685 + if (!atomic_read(&pipe->writers) && filp->f_version != pipe->w_counter)
62686 mask |= POLLHUP;
62687 }
62688
62689 @@ -619,7 +619,7 @@ pipe_poll(struct file *filp, poll_table *wait)
62690 * Most Unices do not set POLLERR for FIFOs but on Linux they
62691 * behave exactly like pipes for poll().
62692 */
62693 - if (!pipe->readers)
62694 + if (!atomic_read(&pipe->readers))
62695 mask |= POLLERR;
62696 }
62697
62698 @@ -631,7 +631,7 @@ static void put_pipe_info(struct inode *inode, struct pipe_inode_info *pipe)
62699 int kill = 0;
62700
62701 spin_lock(&inode->i_lock);
62702 - if (!--pipe->files) {
62703 + if (atomic_dec_and_test(&pipe->files)) {
62704 inode->i_pipe = NULL;
62705 kill = 1;
62706 }
62707 @@ -648,11 +648,11 @@ pipe_release(struct inode *inode, struct file *file)
62708
62709 __pipe_lock(pipe);
62710 if (file->f_mode & FMODE_READ)
62711 - pipe->readers--;
62712 + atomic_dec(&pipe->readers);
62713 if (file->f_mode & FMODE_WRITE)
62714 - pipe->writers--;
62715 + atomic_dec(&pipe->writers);
62716
62717 - if (pipe->readers || pipe->writers) {
62718 + if (atomic_read(&pipe->readers) || atomic_read(&pipe->writers)) {
62719 wake_up_interruptible_sync_poll(&pipe->wait, POLLIN | POLLOUT | POLLRDNORM | POLLWRNORM | POLLERR | POLLHUP);
62720 kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
62721 kill_fasync(&pipe->fasync_writers, SIGIO, POLL_OUT);
62722 @@ -717,7 +717,7 @@ void free_pipe_info(struct pipe_inode_info *pipe)
62723 kfree(pipe);
62724 }
62725
62726 -static struct vfsmount *pipe_mnt __read_mostly;
62727 +struct vfsmount *pipe_mnt __read_mostly;
62728
62729 /*
62730 * pipefs_dname() is called from d_path().
62731 @@ -747,8 +747,9 @@ static struct inode * get_pipe_inode(void)
62732 goto fail_iput;
62733
62734 inode->i_pipe = pipe;
62735 - pipe->files = 2;
62736 - pipe->readers = pipe->writers = 1;
62737 + atomic_set(&pipe->files, 2);
62738 + atomic_set(&pipe->readers, 1);
62739 + atomic_set(&pipe->writers, 1);
62740 inode->i_fop = &pipefifo_fops;
62741
62742 /*
62743 @@ -927,17 +928,17 @@ static int fifo_open(struct inode *inode, struct file *filp)
62744 spin_lock(&inode->i_lock);
62745 if (inode->i_pipe) {
62746 pipe = inode->i_pipe;
62747 - pipe->files++;
62748 + atomic_inc(&pipe->files);
62749 spin_unlock(&inode->i_lock);
62750 } else {
62751 spin_unlock(&inode->i_lock);
62752 pipe = alloc_pipe_info();
62753 if (!pipe)
62754 return -ENOMEM;
62755 - pipe->files = 1;
62756 + atomic_set(&pipe->files, 1);
62757 spin_lock(&inode->i_lock);
62758 if (unlikely(inode->i_pipe)) {
62759 - inode->i_pipe->files++;
62760 + atomic_inc(&inode->i_pipe->files);
62761 spin_unlock(&inode->i_lock);
62762 free_pipe_info(pipe);
62763 pipe = inode->i_pipe;
62764 @@ -962,10 +963,10 @@ static int fifo_open(struct inode *inode, struct file *filp)
62765 * opened, even when there is no process writing the FIFO.
62766 */
62767 pipe->r_counter++;
62768 - if (pipe->readers++ == 0)
62769 + if (atomic_inc_return(&pipe->readers) == 1)
62770 wake_up_partner(pipe);
62771
62772 - if (!is_pipe && !pipe->writers) {
62773 + if (!is_pipe && !atomic_read(&pipe->writers)) {
62774 if ((filp->f_flags & O_NONBLOCK)) {
62775 /* suppress POLLHUP until we have
62776 * seen a writer */
62777 @@ -984,14 +985,14 @@ static int fifo_open(struct inode *inode, struct file *filp)
62778 * errno=ENXIO when there is no process reading the FIFO.
62779 */
62780 ret = -ENXIO;
62781 - if (!is_pipe && (filp->f_flags & O_NONBLOCK) && !pipe->readers)
62782 + if (!is_pipe && (filp->f_flags & O_NONBLOCK) && !atomic_read(&pipe->readers))
62783 goto err;
62784
62785 pipe->w_counter++;
62786 - if (!pipe->writers++)
62787 + if (atomic_inc_return(&pipe->writers) == 1)
62788 wake_up_partner(pipe);
62789
62790 - if (!is_pipe && !pipe->readers) {
62791 + if (!is_pipe && !atomic_read(&pipe->readers)) {
62792 if (wait_for_partner(pipe, &pipe->r_counter))
62793 goto err_wr;
62794 }
62795 @@ -1005,11 +1006,11 @@ static int fifo_open(struct inode *inode, struct file *filp)
62796 * the process can at least talk to itself.
62797 */
62798
62799 - pipe->readers++;
62800 - pipe->writers++;
62801 + atomic_inc(&pipe->readers);
62802 + atomic_inc(&pipe->writers);
62803 pipe->r_counter++;
62804 pipe->w_counter++;
62805 - if (pipe->readers == 1 || pipe->writers == 1)
62806 + if (atomic_read(&pipe->readers) == 1 || atomic_read(&pipe->writers) == 1)
62807 wake_up_partner(pipe);
62808 break;
62809
62810 @@ -1023,13 +1024,13 @@ static int fifo_open(struct inode *inode, struct file *filp)
62811 return 0;
62812
62813 err_rd:
62814 - if (!--pipe->readers)
62815 + if (atomic_dec_and_test(&pipe->readers))
62816 wake_up_interruptible(&pipe->wait);
62817 ret = -ERESTARTSYS;
62818 goto err;
62819
62820 err_wr:
62821 - if (!--pipe->writers)
62822 + if (atomic_dec_and_test(&pipe->writers))
62823 wake_up_interruptible(&pipe->wait);
62824 ret = -ERESTARTSYS;
62825 goto err;
62826 diff --git a/fs/posix_acl.c b/fs/posix_acl.c
62827 index 0855f77..6787d50 100644
62828 --- a/fs/posix_acl.c
62829 +++ b/fs/posix_acl.c
62830 @@ -20,6 +20,7 @@
62831 #include <linux/xattr.h>
62832 #include <linux/export.h>
62833 #include <linux/user_namespace.h>
62834 +#include <linux/grsecurity.h>
62835
62836 struct posix_acl **acl_by_type(struct inode *inode, int type)
62837 {
62838 @@ -277,7 +278,7 @@ posix_acl_equiv_mode(const struct posix_acl *acl, umode_t *mode_p)
62839 }
62840 }
62841 if (mode_p)
62842 - *mode_p = (*mode_p & ~S_IRWXUGO) | mode;
62843 + *mode_p = ((*mode_p & ~S_IRWXUGO) | mode) & ~gr_acl_umask();
62844 return not_equiv;
62845 }
62846 EXPORT_SYMBOL(posix_acl_equiv_mode);
62847 @@ -427,7 +428,7 @@ static int posix_acl_create_masq(struct posix_acl *acl, umode_t *mode_p)
62848 mode &= (group_obj->e_perm << 3) | ~S_IRWXG;
62849 }
62850
62851 - *mode_p = (*mode_p & ~S_IRWXUGO) | mode;
62852 + *mode_p = ((*mode_p & ~S_IRWXUGO) | mode) & ~gr_acl_umask();
62853 return not_equiv;
62854 }
62855
62856 @@ -485,6 +486,8 @@ __posix_acl_create(struct posix_acl **acl, gfp_t gfp, umode_t *mode_p)
62857 struct posix_acl *clone = posix_acl_clone(*acl, gfp);
62858 int err = -ENOMEM;
62859 if (clone) {
62860 + *mode_p &= ~gr_acl_umask();
62861 +
62862 err = posix_acl_create_masq(clone, mode_p);
62863 if (err < 0) {
62864 posix_acl_release(clone);
62865 @@ -659,11 +662,12 @@ struct posix_acl *
62866 posix_acl_from_xattr(struct user_namespace *user_ns,
62867 const void *value, size_t size)
62868 {
62869 - posix_acl_xattr_header *header = (posix_acl_xattr_header *)value;
62870 - posix_acl_xattr_entry *entry = (posix_acl_xattr_entry *)(header+1), *end;
62871 + const posix_acl_xattr_header *header = (const posix_acl_xattr_header *)value;
62872 + const posix_acl_xattr_entry *entry = (const posix_acl_xattr_entry *)(header+1), *end;
62873 int count;
62874 struct posix_acl *acl;
62875 struct posix_acl_entry *acl_e;
62876 + umode_t umask = gr_acl_umask();
62877
62878 if (!value)
62879 return NULL;
62880 @@ -689,12 +693,18 @@ posix_acl_from_xattr(struct user_namespace *user_ns,
62881
62882 switch(acl_e->e_tag) {
62883 case ACL_USER_OBJ:
62884 + acl_e->e_perm &= ~((umask & S_IRWXU) >> 6);
62885 + break;
62886 case ACL_GROUP_OBJ:
62887 case ACL_MASK:
62888 + acl_e->e_perm &= ~((umask & S_IRWXG) >> 3);
62889 + break;
62890 case ACL_OTHER:
62891 + acl_e->e_perm &= ~(umask & S_IRWXO);
62892 break;
62893
62894 case ACL_USER:
62895 + acl_e->e_perm &= ~((umask & S_IRWXU) >> 6);
62896 acl_e->e_uid =
62897 make_kuid(user_ns,
62898 le32_to_cpu(entry->e_id));
62899 @@ -702,6 +712,7 @@ posix_acl_from_xattr(struct user_namespace *user_ns,
62900 goto fail;
62901 break;
62902 case ACL_GROUP:
62903 + acl_e->e_perm &= ~((umask & S_IRWXG) >> 3);
62904 acl_e->e_gid =
62905 make_kgid(user_ns,
62906 le32_to_cpu(entry->e_id));
62907 diff --git a/fs/proc/Kconfig b/fs/proc/Kconfig
62908 index 2183fcf..3c32a98 100644
62909 --- a/fs/proc/Kconfig
62910 +++ b/fs/proc/Kconfig
62911 @@ -30,7 +30,7 @@ config PROC_FS
62912
62913 config PROC_KCORE
62914 bool "/proc/kcore support" if !ARM
62915 - depends on PROC_FS && MMU
62916 + depends on PROC_FS && MMU && !GRKERNSEC_PROC_ADD
62917 help
62918 Provides a virtual ELF core file of the live kernel. This can
62919 be read with gdb and other ELF tools. No modifications can be
62920 @@ -38,8 +38,8 @@ config PROC_KCORE
62921
62922 config PROC_VMCORE
62923 bool "/proc/vmcore support"
62924 - depends on PROC_FS && CRASH_DUMP
62925 - default y
62926 + depends on PROC_FS && CRASH_DUMP && !GRKERNSEC
62927 + default n
62928 help
62929 Exports the dump image of crashed kernel in ELF format.
62930
62931 @@ -63,8 +63,8 @@ config PROC_SYSCTL
62932 limited in memory.
62933
62934 config PROC_PAGE_MONITOR
62935 - default y
62936 - depends on PROC_FS && MMU
62937 + default n
62938 + depends on PROC_FS && MMU && !GRKERNSEC
62939 bool "Enable /proc page monitoring" if EXPERT
62940 help
62941 Various /proc files exist to monitor process memory utilization:
62942 diff --git a/fs/proc/array.c b/fs/proc/array.c
62943 index 64db2bc..a8185d6 100644
62944 --- a/fs/proc/array.c
62945 +++ b/fs/proc/array.c
62946 @@ -60,6 +60,7 @@
62947 #include <linux/tty.h>
62948 #include <linux/string.h>
62949 #include <linux/mman.h>
62950 +#include <linux/grsecurity.h>
62951 #include <linux/proc_fs.h>
62952 #include <linux/ioport.h>
62953 #include <linux/uaccess.h>
62954 @@ -356,6 +357,21 @@ static void task_cpus_allowed(struct seq_file *m, struct task_struct *task)
62955 seq_putc(m, '\n');
62956 }
62957
62958 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
62959 +static inline void task_pax(struct seq_file *m, struct task_struct *p)
62960 +{
62961 + if (p->mm)
62962 + seq_printf(m, "PaX:\t%c%c%c%c%c\n",
62963 + p->mm->pax_flags & MF_PAX_PAGEEXEC ? 'P' : 'p',
62964 + p->mm->pax_flags & MF_PAX_EMUTRAMP ? 'E' : 'e',
62965 + p->mm->pax_flags & MF_PAX_MPROTECT ? 'M' : 'm',
62966 + p->mm->pax_flags & MF_PAX_RANDMMAP ? 'R' : 'r',
62967 + p->mm->pax_flags & MF_PAX_SEGMEXEC ? 'S' : 's');
62968 + else
62969 + seq_printf(m, "PaX:\t-----\n");
62970 +}
62971 +#endif
62972 +
62973 int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
62974 struct pid *pid, struct task_struct *task)
62975 {
62976 @@ -374,9 +390,24 @@ int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
62977 task_cpus_allowed(m, task);
62978 cpuset_task_status_allowed(m, task);
62979 task_context_switch_counts(m, task);
62980 +
62981 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
62982 + task_pax(m, task);
62983 +#endif
62984 +
62985 +#if defined(CONFIG_GRKERNSEC) && !defined(CONFIG_GRKERNSEC_NO_RBAC)
62986 + task_grsec_rbac(m, task);
62987 +#endif
62988 +
62989 return 0;
62990 }
62991
62992 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
62993 +#define PAX_RAND_FLAGS(_mm) (_mm != NULL && _mm != current->mm && \
62994 + (_mm->pax_flags & MF_PAX_RANDMMAP || \
62995 + _mm->pax_flags & MF_PAX_SEGMEXEC))
62996 +#endif
62997 +
62998 static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
62999 struct pid *pid, struct task_struct *task, int whole)
63000 {
63001 @@ -398,6 +429,13 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
63002 char tcomm[sizeof(task->comm)];
63003 unsigned long flags;
63004
63005 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
63006 + if (current->exec_id != m->exec_id) {
63007 + gr_log_badprocpid("stat");
63008 + return 0;
63009 + }
63010 +#endif
63011 +
63012 state = *get_task_state(task);
63013 vsize = eip = esp = 0;
63014 permitted = ptrace_may_access(task, PTRACE_MODE_READ | PTRACE_MODE_NOAUDIT);
63015 @@ -468,6 +506,19 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
63016 gtime = task_gtime(task);
63017 }
63018
63019 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
63020 + if (PAX_RAND_FLAGS(mm)) {
63021 + eip = 0;
63022 + esp = 0;
63023 + wchan = 0;
63024 + }
63025 +#endif
63026 +#ifdef CONFIG_GRKERNSEC_HIDESYM
63027 + wchan = 0;
63028 + eip =0;
63029 + esp =0;
63030 +#endif
63031 +
63032 /* scale priority and nice values from timeslices to -20..20 */
63033 /* to make it look like a "normal" Unix priority/nice value */
63034 priority = task_prio(task);
63035 @@ -504,9 +555,15 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
63036 seq_put_decimal_ull(m, ' ', vsize);
63037 seq_put_decimal_ull(m, ' ', mm ? get_mm_rss(mm) : 0);
63038 seq_put_decimal_ull(m, ' ', rsslim);
63039 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
63040 + seq_put_decimal_ull(m, ' ', PAX_RAND_FLAGS(mm) ? 1 : (mm ? (permitted ? mm->start_code : 1) : 0));
63041 + seq_put_decimal_ull(m, ' ', PAX_RAND_FLAGS(mm) ? 1 : (mm ? (permitted ? mm->end_code : 1) : 0));
63042 + seq_put_decimal_ull(m, ' ', PAX_RAND_FLAGS(mm) ? 0 : ((permitted && mm) ? mm->start_stack : 0));
63043 +#else
63044 seq_put_decimal_ull(m, ' ', mm ? (permitted ? mm->start_code : 1) : 0);
63045 seq_put_decimal_ull(m, ' ', mm ? (permitted ? mm->end_code : 1) : 0);
63046 seq_put_decimal_ull(m, ' ', (permitted && mm) ? mm->start_stack : 0);
63047 +#endif
63048 seq_put_decimal_ull(m, ' ', esp);
63049 seq_put_decimal_ull(m, ' ', eip);
63050 /* The signal information here is obsolete.
63051 @@ -528,7 +585,11 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
63052 seq_put_decimal_ull(m, ' ', cputime_to_clock_t(gtime));
63053 seq_put_decimal_ll(m, ' ', cputime_to_clock_t(cgtime));
63054
63055 - if (mm && permitted) {
63056 + if (mm && permitted
63057 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
63058 + && !PAX_RAND_FLAGS(mm)
63059 +#endif
63060 + ) {
63061 seq_put_decimal_ull(m, ' ', mm->start_data);
63062 seq_put_decimal_ull(m, ' ', mm->end_data);
63063 seq_put_decimal_ull(m, ' ', mm->start_brk);
63064 @@ -566,8 +627,15 @@ int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
63065 struct pid *pid, struct task_struct *task)
63066 {
63067 unsigned long size = 0, resident = 0, shared = 0, text = 0, data = 0;
63068 - struct mm_struct *mm = get_task_mm(task);
63069 + struct mm_struct *mm;
63070
63071 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
63072 + if (current->exec_id != m->exec_id) {
63073 + gr_log_badprocpid("statm");
63074 + return 0;
63075 + }
63076 +#endif
63077 + mm = get_task_mm(task);
63078 if (mm) {
63079 size = task_statm(mm, &shared, &text, &data, &resident);
63080 mmput(mm);
63081 @@ -590,6 +658,13 @@ int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
63082 return 0;
63083 }
63084
63085 +#ifdef CONFIG_GRKERNSEC_PROC_IPADDR
63086 +int proc_pid_ipaddr(struct task_struct *task, char *buffer)
63087 +{
63088 + return sprintf(buffer, "%pI4\n", &task->signal->curr_ip);
63089 +}
63090 +#endif
63091 +
63092 #ifdef CONFIG_CHECKPOINT_RESTORE
63093 static struct pid *
63094 get_children_pid(struct inode *inode, struct pid *pid_prev, loff_t pos)
63095 diff --git a/fs/proc/base.c b/fs/proc/base.c
63096 index 2d696b0..b9da447 100644
63097 --- a/fs/proc/base.c
63098 +++ b/fs/proc/base.c
63099 @@ -113,6 +113,14 @@ struct pid_entry {
63100 union proc_op op;
63101 };
63102
63103 +struct getdents_callback {
63104 + struct linux_dirent __user * current_dir;
63105 + struct linux_dirent __user * previous;
63106 + struct file * file;
63107 + int count;
63108 + int error;
63109 +};
63110 +
63111 #define NOD(NAME, MODE, IOP, FOP, OP) { \
63112 .name = (NAME), \
63113 .len = sizeof(NAME) - 1, \
63114 @@ -205,12 +213,28 @@ static int proc_pid_cmdline(struct task_struct *task, char *buffer)
63115 return get_cmdline(task, buffer, PAGE_SIZE);
63116 }
63117
63118 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
63119 +#define PAX_RAND_FLAGS(_mm) (_mm != NULL && _mm != current->mm && \
63120 + (_mm->pax_flags & MF_PAX_RANDMMAP || \
63121 + _mm->pax_flags & MF_PAX_SEGMEXEC))
63122 +#endif
63123 +
63124 static int proc_pid_auxv(struct task_struct *task, char *buffer)
63125 {
63126 struct mm_struct *mm = mm_access(task, PTRACE_MODE_READ);
63127 int res = PTR_ERR(mm);
63128 if (mm && !IS_ERR(mm)) {
63129 unsigned int nwords = 0;
63130 +
63131 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
63132 + /* allow if we're currently ptracing this task */
63133 + if (PAX_RAND_FLAGS(mm) &&
63134 + (!(task->ptrace & PT_PTRACED) || (task->parent != current))) {
63135 + mmput(mm);
63136 + return 0;
63137 + }
63138 +#endif
63139 +
63140 do {
63141 nwords += 2;
63142 } while (mm->saved_auxv[nwords - 2] != 0); /* AT_NULL */
63143 @@ -224,7 +248,7 @@ static int proc_pid_auxv(struct task_struct *task, char *buffer)
63144 }
63145
63146
63147 -#ifdef CONFIG_KALLSYMS
63148 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
63149 /*
63150 * Provides a wchan file via kallsyms in a proper one-value-per-file format.
63151 * Returns the resolved symbol. If that fails, simply return the address.
63152 @@ -263,7 +287,7 @@ static void unlock_trace(struct task_struct *task)
63153 mutex_unlock(&task->signal->cred_guard_mutex);
63154 }
63155
63156 -#ifdef CONFIG_STACKTRACE
63157 +#if defined(CONFIG_STACKTRACE) && !defined(CONFIG_GRKERNSEC_HIDESYM)
63158
63159 #define MAX_STACK_TRACE_DEPTH 64
63160
63161 @@ -486,7 +510,7 @@ static int proc_pid_limits(struct task_struct *task, char *buffer)
63162 return count;
63163 }
63164
63165 -#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
63166 +#if defined(CONFIG_HAVE_ARCH_TRACEHOOK) && !defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
63167 static int proc_pid_syscall(struct task_struct *task, char *buffer)
63168 {
63169 long nr;
63170 @@ -515,7 +539,7 @@ static int proc_pid_syscall(struct task_struct *task, char *buffer)
63171 /************************************************************************/
63172
63173 /* permission checks */
63174 -static int proc_fd_access_allowed(struct inode *inode)
63175 +static int proc_fd_access_allowed(struct inode *inode, unsigned int log)
63176 {
63177 struct task_struct *task;
63178 int allowed = 0;
63179 @@ -525,7 +549,10 @@ static int proc_fd_access_allowed(struct inode *inode)
63180 */
63181 task = get_proc_task(inode);
63182 if (task) {
63183 - allowed = ptrace_may_access(task, PTRACE_MODE_READ);
63184 + if (log)
63185 + allowed = ptrace_may_access(task, PTRACE_MODE_READ);
63186 + else
63187 + allowed = ptrace_may_access(task, PTRACE_MODE_READ | PTRACE_MODE_NOAUDIT);
63188 put_task_struct(task);
63189 }
63190 return allowed;
63191 @@ -556,10 +583,35 @@ static bool has_pid_permissions(struct pid_namespace *pid,
63192 struct task_struct *task,
63193 int hide_pid_min)
63194 {
63195 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
63196 + return false;
63197 +
63198 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
63199 + rcu_read_lock();
63200 + {
63201 + const struct cred *tmpcred = current_cred();
63202 + const struct cred *cred = __task_cred(task);
63203 +
63204 + if (uid_eq(tmpcred->uid, GLOBAL_ROOT_UID) || uid_eq(tmpcred->uid, cred->uid)
63205 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
63206 + || in_group_p(grsec_proc_gid)
63207 +#endif
63208 + ) {
63209 + rcu_read_unlock();
63210 + return true;
63211 + }
63212 + }
63213 + rcu_read_unlock();
63214 +
63215 + if (!pid->hide_pid)
63216 + return false;
63217 +#endif
63218 +
63219 if (pid->hide_pid < hide_pid_min)
63220 return true;
63221 if (in_group_p(pid->pid_gid))
63222 return true;
63223 +
63224 return ptrace_may_access(task, PTRACE_MODE_READ);
63225 }
63226
63227 @@ -577,7 +629,11 @@ static int proc_pid_permission(struct inode *inode, int mask)
63228 put_task_struct(task);
63229
63230 if (!has_perms) {
63231 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
63232 + {
63233 +#else
63234 if (pid->hide_pid == 2) {
63235 +#endif
63236 /*
63237 * Let's make getdents(), stat(), and open()
63238 * consistent with each other. If a process
63239 @@ -675,6 +731,11 @@ static int __mem_open(struct inode *inode, struct file *file, unsigned int mode)
63240 if (!task)
63241 return -ESRCH;
63242
63243 + if (gr_acl_handle_procpidmem(task)) {
63244 + put_task_struct(task);
63245 + return -EPERM;
63246 + }
63247 +
63248 mm = mm_access(task, mode);
63249 put_task_struct(task);
63250
63251 @@ -690,6 +751,10 @@ static int __mem_open(struct inode *inode, struct file *file, unsigned int mode)
63252
63253 file->private_data = mm;
63254
63255 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
63256 + file->f_version = current->exec_id;
63257 +#endif
63258 +
63259 return 0;
63260 }
63261
63262 @@ -711,6 +776,17 @@ static ssize_t mem_rw(struct file *file, char __user *buf,
63263 ssize_t copied;
63264 char *page;
63265
63266 +#ifdef CONFIG_GRKERNSEC
63267 + if (write)
63268 + return -EPERM;
63269 +#endif
63270 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
63271 + if (file->f_version != current->exec_id) {
63272 + gr_log_badprocpid("mem");
63273 + return 0;
63274 + }
63275 +#endif
63276 +
63277 if (!mm)
63278 return 0;
63279
63280 @@ -723,7 +799,7 @@ static ssize_t mem_rw(struct file *file, char __user *buf,
63281 goto free;
63282
63283 while (count > 0) {
63284 - int this_len = min_t(int, count, PAGE_SIZE);
63285 + ssize_t this_len = min_t(ssize_t, count, PAGE_SIZE);
63286
63287 if (write && copy_from_user(page, buf, this_len)) {
63288 copied = -EFAULT;
63289 @@ -815,6 +891,13 @@ static ssize_t environ_read(struct file *file, char __user *buf,
63290 if (!mm)
63291 return 0;
63292
63293 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
63294 + if (file->f_version != current->exec_id) {
63295 + gr_log_badprocpid("environ");
63296 + return 0;
63297 + }
63298 +#endif
63299 +
63300 page = (char *)__get_free_page(GFP_TEMPORARY);
63301 if (!page)
63302 return -ENOMEM;
63303 @@ -824,7 +907,7 @@ static ssize_t environ_read(struct file *file, char __user *buf,
63304 goto free;
63305 while (count > 0) {
63306 size_t this_len, max_len;
63307 - int retval;
63308 + ssize_t retval;
63309
63310 if (src >= (mm->env_end - mm->env_start))
63311 break;
63312 @@ -1438,7 +1521,7 @@ static void *proc_pid_follow_link(struct dentry *dentry, struct nameidata *nd)
63313 int error = -EACCES;
63314
63315 /* Are we allowed to snoop on the tasks file descriptors? */
63316 - if (!proc_fd_access_allowed(inode))
63317 + if (!proc_fd_access_allowed(inode, 0))
63318 goto out;
63319
63320 error = PROC_I(inode)->op.proc_get_link(dentry, &path);
63321 @@ -1482,8 +1565,18 @@ static int proc_pid_readlink(struct dentry * dentry, char __user * buffer, int b
63322 struct path path;
63323
63324 /* Are we allowed to snoop on the tasks file descriptors? */
63325 - if (!proc_fd_access_allowed(inode))
63326 - goto out;
63327 + /* logging this is needed for learning on chromium to work properly,
63328 + but we don't want to flood the logs from 'ps' which does a readlink
63329 + on /proc/fd/2 of tasks in the listing, nor do we want 'ps' to learn
63330 + CAP_SYS_PTRACE as it's not necessary for its basic functionality
63331 + */
63332 + if (dentry->d_name.name[0] == '2' && dentry->d_name.name[1] == '\0') {
63333 + if (!proc_fd_access_allowed(inode,0))
63334 + goto out;
63335 + } else {
63336 + if (!proc_fd_access_allowed(inode,1))
63337 + goto out;
63338 + }
63339
63340 error = PROC_I(inode)->op.proc_get_link(dentry, &path);
63341 if (error)
63342 @@ -1533,7 +1626,11 @@ struct inode *proc_pid_make_inode(struct super_block * sb, struct task_struct *t
63343 rcu_read_lock();
63344 cred = __task_cred(task);
63345 inode->i_uid = cred->euid;
63346 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
63347 + inode->i_gid = grsec_proc_gid;
63348 +#else
63349 inode->i_gid = cred->egid;
63350 +#endif
63351 rcu_read_unlock();
63352 }
63353 security_task_to_inode(task, inode);
63354 @@ -1569,10 +1666,19 @@ int pid_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)
63355 return -ENOENT;
63356 }
63357 if ((inode->i_mode == (S_IFDIR|S_IRUGO|S_IXUGO)) ||
63358 +#ifdef CONFIG_GRKERNSEC_PROC_USER
63359 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IXUSR)) ||
63360 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
63361 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IRGRP|S_IXUSR|S_IXGRP)) ||
63362 +#endif
63363 task_dumpable(task)) {
63364 cred = __task_cred(task);
63365 stat->uid = cred->euid;
63366 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
63367 + stat->gid = grsec_proc_gid;
63368 +#else
63369 stat->gid = cred->egid;
63370 +#endif
63371 }
63372 }
63373 rcu_read_unlock();
63374 @@ -1610,11 +1716,20 @@ int pid_revalidate(struct dentry *dentry, unsigned int flags)
63375
63376 if (task) {
63377 if ((inode->i_mode == (S_IFDIR|S_IRUGO|S_IXUGO)) ||
63378 +#ifdef CONFIG_GRKERNSEC_PROC_USER
63379 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IXUSR)) ||
63380 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
63381 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IRGRP|S_IXUSR|S_IXGRP)) ||
63382 +#endif
63383 task_dumpable(task)) {
63384 rcu_read_lock();
63385 cred = __task_cred(task);
63386 inode->i_uid = cred->euid;
63387 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
63388 + inode->i_gid = grsec_proc_gid;
63389 +#else
63390 inode->i_gid = cred->egid;
63391 +#endif
63392 rcu_read_unlock();
63393 } else {
63394 inode->i_uid = GLOBAL_ROOT_UID;
63395 @@ -2149,6 +2264,9 @@ static struct dentry *proc_pident_lookup(struct inode *dir,
63396 if (!task)
63397 goto out_no_task;
63398
63399 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
63400 + goto out;
63401 +
63402 /*
63403 * Yes, it does not scale. And it should not. Don't add
63404 * new entries into /proc/<tgid>/ without very good reasons.
63405 @@ -2179,6 +2297,9 @@ static int proc_pident_readdir(struct file *file, struct dir_context *ctx,
63406 if (!task)
63407 return -ENOENT;
63408
63409 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
63410 + goto out;
63411 +
63412 if (!dir_emit_dots(file, ctx))
63413 goto out;
63414
63415 @@ -2568,7 +2689,7 @@ static const struct pid_entry tgid_base_stuff[] = {
63416 REG("autogroup", S_IRUGO|S_IWUSR, proc_pid_sched_autogroup_operations),
63417 #endif
63418 REG("comm", S_IRUGO|S_IWUSR, proc_pid_set_comm_operations),
63419 -#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
63420 +#if defined(CONFIG_HAVE_ARCH_TRACEHOOK) && !defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
63421 INF("syscall", S_IRUSR, proc_pid_syscall),
63422 #endif
63423 INF("cmdline", S_IRUGO, proc_pid_cmdline),
63424 @@ -2593,10 +2714,10 @@ static const struct pid_entry tgid_base_stuff[] = {
63425 #ifdef CONFIG_SECURITY
63426 DIR("attr", S_IRUGO|S_IXUGO, proc_attr_dir_inode_operations, proc_attr_dir_operations),
63427 #endif
63428 -#ifdef CONFIG_KALLSYMS
63429 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
63430 INF("wchan", S_IRUGO, proc_pid_wchan),
63431 #endif
63432 -#ifdef CONFIG_STACKTRACE
63433 +#if defined(CONFIG_STACKTRACE) && !defined(CONFIG_GRKERNSEC_HIDESYM)
63434 ONE("stack", S_IRUSR, proc_pid_stack),
63435 #endif
63436 #ifdef CONFIG_SCHEDSTATS
63437 @@ -2630,6 +2751,9 @@ static const struct pid_entry tgid_base_stuff[] = {
63438 #ifdef CONFIG_HARDWALL
63439 INF("hardwall", S_IRUGO, proc_pid_hardwall),
63440 #endif
63441 +#ifdef CONFIG_GRKERNSEC_PROC_IPADDR
63442 + INF("ipaddr", S_IRUSR, proc_pid_ipaddr),
63443 +#endif
63444 #ifdef CONFIG_USER_NS
63445 REG("uid_map", S_IRUGO|S_IWUSR, proc_uid_map_operations),
63446 REG("gid_map", S_IRUGO|S_IWUSR, proc_gid_map_operations),
63447 @@ -2760,7 +2884,14 @@ static int proc_pid_instantiate(struct inode *dir,
63448 if (!inode)
63449 goto out;
63450
63451 +#ifdef CONFIG_GRKERNSEC_PROC_USER
63452 + inode->i_mode = S_IFDIR|S_IRUSR|S_IXUSR;
63453 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
63454 + inode->i_gid = grsec_proc_gid;
63455 + inode->i_mode = S_IFDIR|S_IRUSR|S_IRGRP|S_IXUSR|S_IXGRP;
63456 +#else
63457 inode->i_mode = S_IFDIR|S_IRUGO|S_IXUGO;
63458 +#endif
63459 inode->i_op = &proc_tgid_base_inode_operations;
63460 inode->i_fop = &proc_tgid_base_operations;
63461 inode->i_flags|=S_IMMUTABLE;
63462 @@ -2798,7 +2929,11 @@ struct dentry *proc_pid_lookup(struct inode *dir, struct dentry * dentry, unsign
63463 if (!task)
63464 goto out;
63465
63466 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
63467 + goto out_put_task;
63468 +
63469 result = proc_pid_instantiate(dir, dentry, task, NULL);
63470 +out_put_task:
63471 put_task_struct(task);
63472 out:
63473 return ERR_PTR(result);
63474 @@ -2904,7 +3039,7 @@ static const struct pid_entry tid_base_stuff[] = {
63475 REG("sched", S_IRUGO|S_IWUSR, proc_pid_sched_operations),
63476 #endif
63477 REG("comm", S_IRUGO|S_IWUSR, proc_pid_set_comm_operations),
63478 -#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
63479 +#if defined(CONFIG_HAVE_ARCH_TRACEHOOK) && !defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
63480 INF("syscall", S_IRUSR, proc_pid_syscall),
63481 #endif
63482 INF("cmdline", S_IRUGO, proc_pid_cmdline),
63483 @@ -2931,10 +3066,10 @@ static const struct pid_entry tid_base_stuff[] = {
63484 #ifdef CONFIG_SECURITY
63485 DIR("attr", S_IRUGO|S_IXUGO, proc_attr_dir_inode_operations, proc_attr_dir_operations),
63486 #endif
63487 -#ifdef CONFIG_KALLSYMS
63488 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
63489 INF("wchan", S_IRUGO, proc_pid_wchan),
63490 #endif
63491 -#ifdef CONFIG_STACKTRACE
63492 +#if defined(CONFIG_STACKTRACE) && !defined(CONFIG_GRKERNSEC_HIDESYM)
63493 ONE("stack", S_IRUSR, proc_pid_stack),
63494 #endif
63495 #ifdef CONFIG_SCHEDSTATS
63496 diff --git a/fs/proc/cmdline.c b/fs/proc/cmdline.c
63497 index cbd82df..c0407d2 100644
63498 --- a/fs/proc/cmdline.c
63499 +++ b/fs/proc/cmdline.c
63500 @@ -23,7 +23,11 @@ static const struct file_operations cmdline_proc_fops = {
63501
63502 static int __init proc_cmdline_init(void)
63503 {
63504 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
63505 + proc_create_grsec("cmdline", 0, NULL, &cmdline_proc_fops);
63506 +#else
63507 proc_create("cmdline", 0, NULL, &cmdline_proc_fops);
63508 +#endif
63509 return 0;
63510 }
63511 fs_initcall(proc_cmdline_init);
63512 diff --git a/fs/proc/devices.c b/fs/proc/devices.c
63513 index 50493ed..248166b 100644
63514 --- a/fs/proc/devices.c
63515 +++ b/fs/proc/devices.c
63516 @@ -64,7 +64,11 @@ static const struct file_operations proc_devinfo_operations = {
63517
63518 static int __init proc_devices_init(void)
63519 {
63520 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
63521 + proc_create_grsec("devices", 0, NULL, &proc_devinfo_operations);
63522 +#else
63523 proc_create("devices", 0, NULL, &proc_devinfo_operations);
63524 +#endif
63525 return 0;
63526 }
63527 fs_initcall(proc_devices_init);
63528 diff --git a/fs/proc/fd.c b/fs/proc/fd.c
63529 index 0788d09..9cc1385 100644
63530 --- a/fs/proc/fd.c
63531 +++ b/fs/proc/fd.c
63532 @@ -26,7 +26,8 @@ static int seq_show(struct seq_file *m, void *v)
63533 if (!task)
63534 return -ENOENT;
63535
63536 - files = get_files_struct(task);
63537 + if (!gr_acl_handle_procpidmem(task))
63538 + files = get_files_struct(task);
63539 put_task_struct(task);
63540
63541 if (files) {
63542 @@ -285,11 +286,21 @@ static struct dentry *proc_lookupfd(struct inode *dir, struct dentry *dentry,
63543 */
63544 int proc_fd_permission(struct inode *inode, int mask)
63545 {
63546 + struct task_struct *task;
63547 int rv = generic_permission(inode, mask);
63548 - if (rv == 0)
63549 - return 0;
63550 +
63551 if (task_tgid(current) == proc_pid(inode))
63552 rv = 0;
63553 +
63554 + task = get_proc_task(inode);
63555 + if (task == NULL)
63556 + return rv;
63557 +
63558 + if (gr_acl_handle_procpidmem(task))
63559 + rv = -EACCES;
63560 +
63561 + put_task_struct(task);
63562 +
63563 return rv;
63564 }
63565
63566 diff --git a/fs/proc/generic.c b/fs/proc/generic.c
63567 index b7f268e..3bea6b7 100644
63568 --- a/fs/proc/generic.c
63569 +++ b/fs/proc/generic.c
63570 @@ -23,6 +23,7 @@
63571 #include <linux/bitops.h>
63572 #include <linux/spinlock.h>
63573 #include <linux/completion.h>
63574 +#include <linux/grsecurity.h>
63575 #include <asm/uaccess.h>
63576
63577 #include "internal.h"
63578 @@ -207,6 +208,15 @@ struct dentry *proc_lookup(struct inode *dir, struct dentry *dentry,
63579 return proc_lookup_de(PDE(dir), dir, dentry);
63580 }
63581
63582 +struct dentry *proc_lookup_restrict(struct inode *dir, struct dentry *dentry,
63583 + unsigned int flags)
63584 +{
63585 + if (gr_proc_is_restricted())
63586 + return ERR_PTR(-EACCES);
63587 +
63588 + return proc_lookup_de(PDE(dir), dir, dentry);
63589 +}
63590 +
63591 /*
63592 * This returns non-zero if at EOF, so that the /proc
63593 * root directory can use this and check if it should
63594 @@ -264,6 +274,16 @@ int proc_readdir(struct file *file, struct dir_context *ctx)
63595 return proc_readdir_de(PDE(inode), file, ctx);
63596 }
63597
63598 +int proc_readdir_restrict(struct file *file, struct dir_context *ctx)
63599 +{
63600 + struct inode *inode = file_inode(file);
63601 +
63602 + if (gr_proc_is_restricted())
63603 + return -EACCES;
63604 +
63605 + return proc_readdir_de(PDE(inode), file, ctx);
63606 +}
63607 +
63608 /*
63609 * These are the generic /proc directory operations. They
63610 * use the in-memory "struct proc_dir_entry" tree to parse
63611 @@ -275,6 +295,12 @@ static const struct file_operations proc_dir_operations = {
63612 .iterate = proc_readdir,
63613 };
63614
63615 +static const struct file_operations proc_dir_restricted_operations = {
63616 + .llseek = generic_file_llseek,
63617 + .read = generic_read_dir,
63618 + .iterate = proc_readdir_restrict,
63619 +};
63620 +
63621 /*
63622 * proc directories can do almost nothing..
63623 */
63624 @@ -284,6 +310,12 @@ static const struct inode_operations proc_dir_inode_operations = {
63625 .setattr = proc_notify_change,
63626 };
63627
63628 +static const struct inode_operations proc_dir_restricted_inode_operations = {
63629 + .lookup = proc_lookup_restrict,
63630 + .getattr = proc_getattr,
63631 + .setattr = proc_notify_change,
63632 +};
63633 +
63634 static int proc_register(struct proc_dir_entry * dir, struct proc_dir_entry * dp)
63635 {
63636 struct proc_dir_entry *tmp;
63637 @@ -294,8 +326,13 @@ static int proc_register(struct proc_dir_entry * dir, struct proc_dir_entry * dp
63638 return ret;
63639
63640 if (S_ISDIR(dp->mode)) {
63641 - dp->proc_fops = &proc_dir_operations;
63642 - dp->proc_iops = &proc_dir_inode_operations;
63643 + if (dp->restricted) {
63644 + dp->proc_fops = &proc_dir_restricted_operations;
63645 + dp->proc_iops = &proc_dir_restricted_inode_operations;
63646 + } else {
63647 + dp->proc_fops = &proc_dir_operations;
63648 + dp->proc_iops = &proc_dir_inode_operations;
63649 + }
63650 dir->nlink++;
63651 } else if (S_ISLNK(dp->mode)) {
63652 dp->proc_iops = &proc_link_inode_operations;
63653 @@ -407,6 +444,27 @@ struct proc_dir_entry *proc_mkdir_data(const char *name, umode_t mode,
63654 }
63655 EXPORT_SYMBOL_GPL(proc_mkdir_data);
63656
63657 +struct proc_dir_entry *proc_mkdir_data_restrict(const char *name, umode_t mode,
63658 + struct proc_dir_entry *parent, void *data)
63659 +{
63660 + struct proc_dir_entry *ent;
63661 +
63662 + if (mode == 0)
63663 + mode = S_IRUGO | S_IXUGO;
63664 +
63665 + ent = __proc_create(&parent, name, S_IFDIR | mode, 2);
63666 + if (ent) {
63667 + ent->data = data;
63668 + ent->restricted = 1;
63669 + if (proc_register(parent, ent) < 0) {
63670 + kfree(ent);
63671 + ent = NULL;
63672 + }
63673 + }
63674 + return ent;
63675 +}
63676 +EXPORT_SYMBOL_GPL(proc_mkdir_data_restrict);
63677 +
63678 struct proc_dir_entry *proc_mkdir_mode(const char *name, umode_t mode,
63679 struct proc_dir_entry *parent)
63680 {
63681 @@ -421,6 +479,13 @@ struct proc_dir_entry *proc_mkdir(const char *name,
63682 }
63683 EXPORT_SYMBOL(proc_mkdir);
63684
63685 +struct proc_dir_entry *proc_mkdir_restrict(const char *name,
63686 + struct proc_dir_entry *parent)
63687 +{
63688 + return proc_mkdir_data_restrict(name, 0, parent, NULL);
63689 +}
63690 +EXPORT_SYMBOL(proc_mkdir_restrict);
63691 +
63692 struct proc_dir_entry *proc_create_data(const char *name, umode_t mode,
63693 struct proc_dir_entry *parent,
63694 const struct file_operations *proc_fops,
63695 diff --git a/fs/proc/inode.c b/fs/proc/inode.c
63696 index 0adbc02..bee4d0b 100644
63697 --- a/fs/proc/inode.c
63698 +++ b/fs/proc/inode.c
63699 @@ -23,11 +23,17 @@
63700 #include <linux/slab.h>
63701 #include <linux/mount.h>
63702 #include <linux/magic.h>
63703 +#include <linux/grsecurity.h>
63704
63705 #include <asm/uaccess.h>
63706
63707 #include "internal.h"
63708
63709 +#ifdef CONFIG_PROC_SYSCTL
63710 +extern const struct inode_operations proc_sys_inode_operations;
63711 +extern const struct inode_operations proc_sys_dir_operations;
63712 +#endif
63713 +
63714 static void proc_evict_inode(struct inode *inode)
63715 {
63716 struct proc_dir_entry *de;
63717 @@ -55,6 +61,13 @@ static void proc_evict_inode(struct inode *inode)
63718 ns = PROC_I(inode)->ns.ns;
63719 if (ns_ops && ns)
63720 ns_ops->put(ns);
63721 +
63722 +#ifdef CONFIG_PROC_SYSCTL
63723 + if (inode->i_op == &proc_sys_inode_operations ||
63724 + inode->i_op == &proc_sys_dir_operations)
63725 + gr_handle_delete(inode->i_ino, inode->i_sb->s_dev);
63726 +#endif
63727 +
63728 }
63729
63730 static struct kmem_cache * proc_inode_cachep;
63731 @@ -413,7 +426,11 @@ struct inode *proc_get_inode(struct super_block *sb, struct proc_dir_entry *de)
63732 if (de->mode) {
63733 inode->i_mode = de->mode;
63734 inode->i_uid = de->uid;
63735 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
63736 + inode->i_gid = grsec_proc_gid;
63737 +#else
63738 inode->i_gid = de->gid;
63739 +#endif
63740 }
63741 if (de->size)
63742 inode->i_size = de->size;
63743 diff --git a/fs/proc/internal.h b/fs/proc/internal.h
63744 index 3ab6d14..b26174e 100644
63745 --- a/fs/proc/internal.h
63746 +++ b/fs/proc/internal.h
63747 @@ -46,9 +46,10 @@ struct proc_dir_entry {
63748 struct completion *pde_unload_completion;
63749 struct list_head pde_openers; /* who did ->open, but not ->release */
63750 spinlock_t pde_unload_lock; /* proc_fops checks and pde_users bumps */
63751 + u8 restricted; /* a directory in /proc/net that should be restricted via GRKERNSEC_PROC */
63752 u8 namelen;
63753 char name[];
63754 -};
63755 +} __randomize_layout;
63756
63757 union proc_op {
63758 int (*proc_get_link)(struct dentry *, struct path *);
63759 @@ -67,7 +68,7 @@ struct proc_inode {
63760 struct ctl_table *sysctl_entry;
63761 struct proc_ns ns;
63762 struct inode vfs_inode;
63763 -};
63764 +} __randomize_layout;
63765
63766 /*
63767 * General functions
63768 @@ -155,6 +156,9 @@ extern int proc_pid_status(struct seq_file *, struct pid_namespace *,
63769 struct pid *, struct task_struct *);
63770 extern int proc_pid_statm(struct seq_file *, struct pid_namespace *,
63771 struct pid *, struct task_struct *);
63772 +#ifdef CONFIG_GRKERNSEC_PROC_IPADDR
63773 +extern int proc_pid_ipaddr(struct task_struct *task, char *buffer);
63774 +#endif
63775
63776 /*
63777 * base.c
63778 @@ -181,9 +185,11 @@ extern bool proc_fill_cache(struct file *, struct dir_context *, const char *, i
63779 extern spinlock_t proc_subdir_lock;
63780
63781 extern struct dentry *proc_lookup(struct inode *, struct dentry *, unsigned int);
63782 +extern struct dentry *proc_lookup_restrict(struct inode *, struct dentry *, unsigned int);
63783 extern struct dentry *proc_lookup_de(struct proc_dir_entry *, struct inode *,
63784 struct dentry *);
63785 extern int proc_readdir(struct file *, struct dir_context *);
63786 +extern int proc_readdir_restrict(struct file *, struct dir_context *);
63787 extern int proc_readdir_de(struct proc_dir_entry *, struct file *, struct dir_context *);
63788
63789 static inline struct proc_dir_entry *pde_get(struct proc_dir_entry *pde)
63790 diff --git a/fs/proc/interrupts.c b/fs/proc/interrupts.c
63791 index a352d57..cb94a5c 100644
63792 --- a/fs/proc/interrupts.c
63793 +++ b/fs/proc/interrupts.c
63794 @@ -47,7 +47,11 @@ static const struct file_operations proc_interrupts_operations = {
63795
63796 static int __init proc_interrupts_init(void)
63797 {
63798 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
63799 + proc_create_grsec("interrupts", 0, NULL, &proc_interrupts_operations);
63800 +#else
63801 proc_create("interrupts", 0, NULL, &proc_interrupts_operations);
63802 +#endif
63803 return 0;
63804 }
63805 fs_initcall(proc_interrupts_init);
63806 diff --git a/fs/proc/kcore.c b/fs/proc/kcore.c
63807 index 39e6ef3..2f9cb5e 100644
63808 --- a/fs/proc/kcore.c
63809 +++ b/fs/proc/kcore.c
63810 @@ -483,9 +483,10 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
63811 * the addresses in the elf_phdr on our list.
63812 */
63813 start = kc_offset_to_vaddr(*fpos - elf_buflen);
63814 - if ((tsz = (PAGE_SIZE - (start & ~PAGE_MASK))) > buflen)
63815 + tsz = PAGE_SIZE - (start & ~PAGE_MASK);
63816 + if (tsz > buflen)
63817 tsz = buflen;
63818 -
63819 +
63820 while (buflen) {
63821 struct kcore_list *m;
63822
63823 @@ -514,20 +515,23 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
63824 kfree(elf_buf);
63825 } else {
63826 if (kern_addr_valid(start)) {
63827 - unsigned long n;
63828 + char *elf_buf;
63829 + mm_segment_t oldfs;
63830
63831 - n = copy_to_user(buffer, (char *)start, tsz);
63832 - /*
63833 - * We cannot distinguish between fault on source
63834 - * and fault on destination. When this happens
63835 - * we clear too and hope it will trigger the
63836 - * EFAULT again.
63837 - */
63838 - if (n) {
63839 - if (clear_user(buffer + tsz - n,
63840 - n))
63841 + elf_buf = kmalloc(tsz, GFP_KERNEL);
63842 + if (!elf_buf)
63843 + return -ENOMEM;
63844 + oldfs = get_fs();
63845 + set_fs(KERNEL_DS);
63846 + if (!__copy_from_user(elf_buf, (const void __user *)start, tsz)) {
63847 + set_fs(oldfs);
63848 + if (copy_to_user(buffer, elf_buf, tsz)) {
63849 + kfree(elf_buf);
63850 return -EFAULT;
63851 + }
63852 }
63853 + set_fs(oldfs);
63854 + kfree(elf_buf);
63855 } else {
63856 if (clear_user(buffer, tsz))
63857 return -EFAULT;
63858 @@ -547,6 +551,9 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
63859
63860 static int open_kcore(struct inode *inode, struct file *filp)
63861 {
63862 +#if defined(CONFIG_GRKERNSEC_PROC_ADD) || defined(CONFIG_GRKERNSEC_HIDESYM)
63863 + return -EPERM;
63864 +#endif
63865 if (!capable(CAP_SYS_RAWIO))
63866 return -EPERM;
63867 if (kcore_need_update)
63868 diff --git a/fs/proc/meminfo.c b/fs/proc/meminfo.c
63869 index 7445af0..7c5113c 100644
63870 --- a/fs/proc/meminfo.c
63871 +++ b/fs/proc/meminfo.c
63872 @@ -187,7 +187,7 @@ static int meminfo_proc_show(struct seq_file *m, void *v)
63873 vmi.used >> 10,
63874 vmi.largest_chunk >> 10
63875 #ifdef CONFIG_MEMORY_FAILURE
63876 - ,atomic_long_read(&num_poisoned_pages) << (PAGE_SHIFT - 10)
63877 + ,atomic_long_read_unchecked(&num_poisoned_pages) << (PAGE_SHIFT - 10)
63878 #endif
63879 #ifdef CONFIG_TRANSPARENT_HUGEPAGE
63880 ,K(global_page_state(NR_ANON_TRANSPARENT_HUGEPAGES) *
63881 diff --git a/fs/proc/nommu.c b/fs/proc/nommu.c
63882 index d4a3574..b421ce9 100644
63883 --- a/fs/proc/nommu.c
63884 +++ b/fs/proc/nommu.c
63885 @@ -64,7 +64,7 @@ static int nommu_region_show(struct seq_file *m, struct vm_region *region)
63886
63887 if (file) {
63888 seq_pad(m, ' ');
63889 - seq_path(m, &file->f_path, "");
63890 + seq_path(m, &file->f_path, "\n\\");
63891 }
63892
63893 seq_putc(m, '\n');
63894 diff --git a/fs/proc/proc_net.c b/fs/proc/proc_net.c
63895 index 4677bb7..94067cd 100644
63896 --- a/fs/proc/proc_net.c
63897 +++ b/fs/proc/proc_net.c
63898 @@ -23,6 +23,7 @@
63899 #include <linux/nsproxy.h>
63900 #include <net/net_namespace.h>
63901 #include <linux/seq_file.h>
63902 +#include <linux/grsecurity.h>
63903
63904 #include "internal.h"
63905
63906 @@ -36,6 +37,8 @@ static struct net *get_proc_net(const struct inode *inode)
63907 return maybe_get_net(PDE_NET(PDE(inode)));
63908 }
63909
63910 +extern const struct seq_operations dev_seq_ops;
63911 +
63912 int seq_open_net(struct inode *ino, struct file *f,
63913 const struct seq_operations *ops, int size)
63914 {
63915 @@ -44,6 +47,10 @@ int seq_open_net(struct inode *ino, struct file *f,
63916
63917 BUG_ON(size < sizeof(*p));
63918
63919 + /* only permit access to /proc/net/dev */
63920 + if (ops != &dev_seq_ops && gr_proc_is_restricted())
63921 + return -EACCES;
63922 +
63923 net = get_proc_net(ino);
63924 if (net == NULL)
63925 return -ENXIO;
63926 @@ -66,6 +73,9 @@ int single_open_net(struct inode *inode, struct file *file,
63927 int err;
63928 struct net *net;
63929
63930 + if (gr_proc_is_restricted())
63931 + return -EACCES;
63932 +
63933 err = -ENXIO;
63934 net = get_proc_net(inode);
63935 if (net == NULL)
63936 diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c
63937 index 7129046..6914844 100644
63938 --- a/fs/proc/proc_sysctl.c
63939 +++ b/fs/proc/proc_sysctl.c
63940 @@ -11,13 +11,21 @@
63941 #include <linux/namei.h>
63942 #include <linux/mm.h>
63943 #include <linux/module.h>
63944 +#include <linux/nsproxy.h>
63945 +#ifdef CONFIG_GRKERNSEC
63946 +#include <net/net_namespace.h>
63947 +#endif
63948 #include "internal.h"
63949
63950 +extern int gr_handle_chroot_sysctl(const int op);
63951 +extern int gr_handle_sysctl_mod(const char *dirname, const char *name,
63952 + const int op);
63953 +
63954 static const struct dentry_operations proc_sys_dentry_operations;
63955 static const struct file_operations proc_sys_file_operations;
63956 -static const struct inode_operations proc_sys_inode_operations;
63957 +const struct inode_operations proc_sys_inode_operations;
63958 static const struct file_operations proc_sys_dir_file_operations;
63959 -static const struct inode_operations proc_sys_dir_operations;
63960 +const struct inode_operations proc_sys_dir_operations;
63961
63962 void proc_sys_poll_notify(struct ctl_table_poll *poll)
63963 {
63964 @@ -467,6 +475,9 @@ static struct dentry *proc_sys_lookup(struct inode *dir, struct dentry *dentry,
63965
63966 err = NULL;
63967 d_set_d_op(dentry, &proc_sys_dentry_operations);
63968 +
63969 + gr_handle_proc_create(dentry, inode);
63970 +
63971 d_add(dentry, inode);
63972
63973 out:
63974 @@ -482,6 +493,7 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
63975 struct inode *inode = file_inode(filp);
63976 struct ctl_table_header *head = grab_header(inode);
63977 struct ctl_table *table = PROC_I(inode)->sysctl_entry;
63978 + int op = write ? MAY_WRITE : MAY_READ;
63979 ssize_t error;
63980 size_t res;
63981
63982 @@ -493,7 +505,7 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
63983 * and won't be until we finish.
63984 */
63985 error = -EPERM;
63986 - if (sysctl_perm(head, table, write ? MAY_WRITE : MAY_READ))
63987 + if (sysctl_perm(head, table, op))
63988 goto out;
63989
63990 /* if that can happen at all, it should be -EINVAL, not -EISDIR */
63991 @@ -501,6 +513,27 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
63992 if (!table->proc_handler)
63993 goto out;
63994
63995 +#ifdef CONFIG_GRKERNSEC
63996 + error = -EPERM;
63997 + if (gr_handle_chroot_sysctl(op))
63998 + goto out;
63999 + dget(filp->f_path.dentry);
64000 + if (gr_handle_sysctl_mod(filp->f_path.dentry->d_parent->d_name.name, table->procname, op)) {
64001 + dput(filp->f_path.dentry);
64002 + goto out;
64003 + }
64004 + dput(filp->f_path.dentry);
64005 + if (!gr_acl_handle_open(filp->f_path.dentry, filp->f_path.mnt, op))
64006 + goto out;
64007 + if (write) {
64008 + if (current->nsproxy->net_ns != table->extra2) {
64009 + if (!capable(CAP_SYS_ADMIN))
64010 + goto out;
64011 + } else if (!ns_capable(current->nsproxy->net_ns->user_ns, CAP_NET_ADMIN))
64012 + goto out;
64013 + }
64014 +#endif
64015 +
64016 /* careful: calling conventions are nasty here */
64017 res = count;
64018 error = table->proc_handler(table, write, buf, &res, ppos);
64019 @@ -598,6 +631,9 @@ static bool proc_sys_fill_cache(struct file *file,
64020 return false;
64021 } else {
64022 d_set_d_op(child, &proc_sys_dentry_operations);
64023 +
64024 + gr_handle_proc_create(child, inode);
64025 +
64026 d_add(child, inode);
64027 }
64028 } else {
64029 @@ -641,6 +677,9 @@ static int scan(struct ctl_table_header *head, ctl_table *table,
64030 if ((*pos)++ < ctx->pos)
64031 return true;
64032
64033 + if (!gr_acl_handle_hidden_file(file->f_path.dentry, file->f_path.mnt))
64034 + return 0;
64035 +
64036 if (unlikely(S_ISLNK(table->mode)))
64037 res = proc_sys_link_fill_cache(file, ctx, head, table);
64038 else
64039 @@ -734,6 +773,9 @@ static int proc_sys_getattr(struct vfsmount *mnt, struct dentry *dentry, struct
64040 if (IS_ERR(head))
64041 return PTR_ERR(head);
64042
64043 + if (table && !gr_acl_handle_hidden_file(dentry, mnt))
64044 + return -ENOENT;
64045 +
64046 generic_fillattr(inode, stat);
64047 if (table)
64048 stat->mode = (stat->mode & S_IFMT) | table->mode;
64049 @@ -756,13 +798,13 @@ static const struct file_operations proc_sys_dir_file_operations = {
64050 .llseek = generic_file_llseek,
64051 };
64052
64053 -static const struct inode_operations proc_sys_inode_operations = {
64054 +const struct inode_operations proc_sys_inode_operations = {
64055 .permission = proc_sys_permission,
64056 .setattr = proc_sys_setattr,
64057 .getattr = proc_sys_getattr,
64058 };
64059
64060 -static const struct inode_operations proc_sys_dir_operations = {
64061 +const struct inode_operations proc_sys_dir_operations = {
64062 .lookup = proc_sys_lookup,
64063 .permission = proc_sys_permission,
64064 .setattr = proc_sys_setattr,
64065 @@ -839,7 +881,7 @@ static struct ctl_dir *find_subdir(struct ctl_dir *dir,
64066 static struct ctl_dir *new_dir(struct ctl_table_set *set,
64067 const char *name, int namelen)
64068 {
64069 - struct ctl_table *table;
64070 + ctl_table_no_const *table;
64071 struct ctl_dir *new;
64072 struct ctl_node *node;
64073 char *new_name;
64074 @@ -851,7 +893,7 @@ static struct ctl_dir *new_dir(struct ctl_table_set *set,
64075 return NULL;
64076
64077 node = (struct ctl_node *)(new + 1);
64078 - table = (struct ctl_table *)(node + 1);
64079 + table = (ctl_table_no_const *)(node + 1);
64080 new_name = (char *)(table + 2);
64081 memcpy(new_name, name, namelen);
64082 new_name[namelen] = '\0';
64083 @@ -1020,7 +1062,8 @@ static int sysctl_check_table(const char *path, struct ctl_table *table)
64084 static struct ctl_table_header *new_links(struct ctl_dir *dir, struct ctl_table *table,
64085 struct ctl_table_root *link_root)
64086 {
64087 - struct ctl_table *link_table, *entry, *link;
64088 + ctl_table_no_const *link_table, *link;
64089 + struct ctl_table *entry;
64090 struct ctl_table_header *links;
64091 struct ctl_node *node;
64092 char *link_name;
64093 @@ -1043,7 +1086,7 @@ static struct ctl_table_header *new_links(struct ctl_dir *dir, struct ctl_table
64094 return NULL;
64095
64096 node = (struct ctl_node *)(links + 1);
64097 - link_table = (struct ctl_table *)(node + nr_entries);
64098 + link_table = (ctl_table_no_const *)(node + nr_entries);
64099 link_name = (char *)&link_table[nr_entries + 1];
64100
64101 for (link = link_table, entry = table; entry->procname; link++, entry++) {
64102 @@ -1291,8 +1334,8 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
64103 struct ctl_table_header ***subheader, struct ctl_table_set *set,
64104 struct ctl_table *table)
64105 {
64106 - struct ctl_table *ctl_table_arg = NULL;
64107 - struct ctl_table *entry, *files;
64108 + ctl_table_no_const *ctl_table_arg = NULL, *files = NULL;
64109 + struct ctl_table *entry;
64110 int nr_files = 0;
64111 int nr_dirs = 0;
64112 int err = -ENOMEM;
64113 @@ -1304,10 +1347,9 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
64114 nr_files++;
64115 }
64116
64117 - files = table;
64118 /* If there are mixed files and directories we need a new table */
64119 if (nr_dirs && nr_files) {
64120 - struct ctl_table *new;
64121 + ctl_table_no_const *new;
64122 files = kzalloc(sizeof(struct ctl_table) * (nr_files + 1),
64123 GFP_KERNEL);
64124 if (!files)
64125 @@ -1325,7 +1367,7 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
64126 /* Register everything except a directory full of subdirectories */
64127 if (nr_files || !nr_dirs) {
64128 struct ctl_table_header *header;
64129 - header = __register_sysctl_table(set, path, files);
64130 + header = __register_sysctl_table(set, path, files ? files : table);
64131 if (!header) {
64132 kfree(ctl_table_arg);
64133 goto out;
64134 diff --git a/fs/proc/root.c b/fs/proc/root.c
64135 index 5dbadec..473af2f 100644
64136 --- a/fs/proc/root.c
64137 +++ b/fs/proc/root.c
64138 @@ -185,7 +185,15 @@ void __init proc_root_init(void)
64139 proc_mkdir("openprom", NULL);
64140 #endif
64141 proc_tty_init();
64142 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
64143 +#ifdef CONFIG_GRKERNSEC_PROC_USER
64144 + proc_mkdir_mode("bus", S_IRUSR | S_IXUSR, NULL);
64145 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
64146 + proc_mkdir_mode("bus", S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP, NULL);
64147 +#endif
64148 +#else
64149 proc_mkdir("bus", NULL);
64150 +#endif
64151 proc_sys_init();
64152 }
64153
64154 diff --git a/fs/proc/stat.c b/fs/proc/stat.c
64155 index 9d231e9..2e1b51a 100644
64156 --- a/fs/proc/stat.c
64157 +++ b/fs/proc/stat.c
64158 @@ -11,6 +11,7 @@
64159 #include <linux/irqnr.h>
64160 #include <linux/cputime.h>
64161 #include <linux/tick.h>
64162 +#include <linux/grsecurity.h>
64163
64164 #ifndef arch_irq_stat_cpu
64165 #define arch_irq_stat_cpu(cpu) 0
64166 @@ -87,6 +88,18 @@ static int show_stat(struct seq_file *p, void *v)
64167 u64 sum_softirq = 0;
64168 unsigned int per_softirq_sums[NR_SOFTIRQS] = {0};
64169 struct timespec boottime;
64170 + int unrestricted = 1;
64171 +
64172 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
64173 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
64174 + if (!uid_eq(current_uid(), GLOBAL_ROOT_UID)
64175 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
64176 + && !in_group_p(grsec_proc_gid)
64177 +#endif
64178 + )
64179 + unrestricted = 0;
64180 +#endif
64181 +#endif
64182
64183 user = nice = system = idle = iowait =
64184 irq = softirq = steal = 0;
64185 @@ -99,23 +112,25 @@ static int show_stat(struct seq_file *p, void *v)
64186 nice += kcpustat_cpu(i).cpustat[CPUTIME_NICE];
64187 system += kcpustat_cpu(i).cpustat[CPUTIME_SYSTEM];
64188 idle += get_idle_time(i);
64189 - iowait += get_iowait_time(i);
64190 - irq += kcpustat_cpu(i).cpustat[CPUTIME_IRQ];
64191 - softirq += kcpustat_cpu(i).cpustat[CPUTIME_SOFTIRQ];
64192 - steal += kcpustat_cpu(i).cpustat[CPUTIME_STEAL];
64193 - guest += kcpustat_cpu(i).cpustat[CPUTIME_GUEST];
64194 - guest_nice += kcpustat_cpu(i).cpustat[CPUTIME_GUEST_NICE];
64195 - sum += kstat_cpu_irqs_sum(i);
64196 - sum += arch_irq_stat_cpu(i);
64197 + if (unrestricted) {
64198 + iowait += get_iowait_time(i);
64199 + irq += kcpustat_cpu(i).cpustat[CPUTIME_IRQ];
64200 + softirq += kcpustat_cpu(i).cpustat[CPUTIME_SOFTIRQ];
64201 + steal += kcpustat_cpu(i).cpustat[CPUTIME_STEAL];
64202 + guest += kcpustat_cpu(i).cpustat[CPUTIME_GUEST];
64203 + guest_nice += kcpustat_cpu(i).cpustat[CPUTIME_GUEST_NICE];
64204 + sum += kstat_cpu_irqs_sum(i);
64205 + sum += arch_irq_stat_cpu(i);
64206 + for (j = 0; j < NR_SOFTIRQS; j++) {
64207 + unsigned int softirq_stat = kstat_softirqs_cpu(j, i);
64208
64209 - for (j = 0; j < NR_SOFTIRQS; j++) {
64210 - unsigned int softirq_stat = kstat_softirqs_cpu(j, i);
64211 -
64212 - per_softirq_sums[j] += softirq_stat;
64213 - sum_softirq += softirq_stat;
64214 + per_softirq_sums[j] += softirq_stat;
64215 + sum_softirq += softirq_stat;
64216 + }
64217 }
64218 }
64219 - sum += arch_irq_stat();
64220 + if (unrestricted)
64221 + sum += arch_irq_stat();
64222
64223 seq_puts(p, "cpu ");
64224 seq_put_decimal_ull(p, ' ', cputime64_to_clock_t(user));
64225 @@ -136,12 +151,14 @@ static int show_stat(struct seq_file *p, void *v)
64226 nice = kcpustat_cpu(i).cpustat[CPUTIME_NICE];
64227 system = kcpustat_cpu(i).cpustat[CPUTIME_SYSTEM];
64228 idle = get_idle_time(i);
64229 - iowait = get_iowait_time(i);
64230 - irq = kcpustat_cpu(i).cpustat[CPUTIME_IRQ];
64231 - softirq = kcpustat_cpu(i).cpustat[CPUTIME_SOFTIRQ];
64232 - steal = kcpustat_cpu(i).cpustat[CPUTIME_STEAL];
64233 - guest = kcpustat_cpu(i).cpustat[CPUTIME_GUEST];
64234 - guest_nice = kcpustat_cpu(i).cpustat[CPUTIME_GUEST_NICE];
64235 + if (unrestricted) {
64236 + iowait = get_iowait_time(i);
64237 + irq = kcpustat_cpu(i).cpustat[CPUTIME_IRQ];
64238 + softirq = kcpustat_cpu(i).cpustat[CPUTIME_SOFTIRQ];
64239 + steal = kcpustat_cpu(i).cpustat[CPUTIME_STEAL];
64240 + guest = kcpustat_cpu(i).cpustat[CPUTIME_GUEST];
64241 + guest_nice = kcpustat_cpu(i).cpustat[CPUTIME_GUEST_NICE];
64242 + }
64243 seq_printf(p, "cpu%d", i);
64244 seq_put_decimal_ull(p, ' ', cputime64_to_clock_t(user));
64245 seq_put_decimal_ull(p, ' ', cputime64_to_clock_t(nice));
64246 @@ -159,7 +176,7 @@ static int show_stat(struct seq_file *p, void *v)
64247
64248 /* sum again ? it could be updated? */
64249 for_each_irq_nr(j)
64250 - seq_put_decimal_ull(p, ' ', kstat_irqs(j));
64251 + seq_put_decimal_ull(p, ' ', unrestricted ? kstat_irqs(j) : 0ULL);
64252
64253 seq_printf(p,
64254 "\nctxt %llu\n"
64255 @@ -167,11 +184,11 @@ static int show_stat(struct seq_file *p, void *v)
64256 "processes %lu\n"
64257 "procs_running %lu\n"
64258 "procs_blocked %lu\n",
64259 - nr_context_switches(),
64260 + unrestricted ? nr_context_switches() : 0ULL,
64261 (unsigned long)jif,
64262 - total_forks,
64263 - nr_running(),
64264 - nr_iowait());
64265 + unrestricted ? total_forks : 0UL,
64266 + unrestricted ? nr_running() : 0UL,
64267 + unrestricted ? nr_iowait() : 0UL);
64268
64269 seq_printf(p, "softirq %llu", (unsigned long long)sum_softirq);
64270
64271 diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
64272 index c4b2646..84f0d7b 100644
64273 --- a/fs/proc/task_mmu.c
64274 +++ b/fs/proc/task_mmu.c
64275 @@ -13,12 +13,19 @@
64276 #include <linux/swap.h>
64277 #include <linux/swapops.h>
64278 #include <linux/mmu_notifier.h>
64279 +#include <linux/grsecurity.h>
64280
64281 #include <asm/elf.h>
64282 #include <asm/uaccess.h>
64283 #include <asm/tlbflush.h>
64284 #include "internal.h"
64285
64286 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
64287 +#define PAX_RAND_FLAGS(_mm) (_mm != NULL && _mm != current->mm && \
64288 + (_mm->pax_flags & MF_PAX_RANDMMAP || \
64289 + _mm->pax_flags & MF_PAX_SEGMEXEC))
64290 +#endif
64291 +
64292 void task_mem(struct seq_file *m, struct mm_struct *mm)
64293 {
64294 unsigned long data, text, lib, swap;
64295 @@ -54,8 +61,13 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
64296 "VmExe:\t%8lu kB\n"
64297 "VmLib:\t%8lu kB\n"
64298 "VmPTE:\t%8lu kB\n"
64299 - "VmSwap:\t%8lu kB\n",
64300 - hiwater_vm << (PAGE_SHIFT-10),
64301 + "VmSwap:\t%8lu kB\n"
64302 +
64303 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
64304 + "CsBase:\t%8lx\nCsLim:\t%8lx\n"
64305 +#endif
64306 +
64307 + ,hiwater_vm << (PAGE_SHIFT-10),
64308 total_vm << (PAGE_SHIFT-10),
64309 mm->locked_vm << (PAGE_SHIFT-10),
64310 mm->pinned_vm << (PAGE_SHIFT-10),
64311 @@ -65,7 +77,19 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
64312 mm->stack_vm << (PAGE_SHIFT-10), text, lib,
64313 (PTRS_PER_PTE * sizeof(pte_t) *
64314 atomic_long_read(&mm->nr_ptes)) >> 10,
64315 - swap << (PAGE_SHIFT-10));
64316 + swap << (PAGE_SHIFT-10)
64317 +
64318 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
64319 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
64320 + , PAX_RAND_FLAGS(mm) ? 0 : mm->context.user_cs_base
64321 + , PAX_RAND_FLAGS(mm) ? 0 : mm->context.user_cs_limit
64322 +#else
64323 + , mm->context.user_cs_base
64324 + , mm->context.user_cs_limit
64325 +#endif
64326 +#endif
64327 +
64328 + );
64329 }
64330
64331 unsigned long task_vsize(struct mm_struct *mm)
64332 @@ -271,13 +295,13 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
64333 pgoff = ((loff_t)vma->vm_pgoff) << PAGE_SHIFT;
64334 }
64335
64336 - /* We don't show the stack guard page in /proc/maps */
64337 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
64338 + start = PAX_RAND_FLAGS(mm) ? 0UL : vma->vm_start;
64339 + end = PAX_RAND_FLAGS(mm) ? 0UL : vma->vm_end;
64340 +#else
64341 start = vma->vm_start;
64342 - if (stack_guard_page_start(vma, start))
64343 - start += PAGE_SIZE;
64344 end = vma->vm_end;
64345 - if (stack_guard_page_end(vma, end))
64346 - end -= PAGE_SIZE;
64347 +#endif
64348
64349 seq_setwidth(m, 25 + sizeof(void *) * 6 - 1);
64350 seq_printf(m, "%08lx-%08lx %c%c%c%c %08llx %02x:%02x %lu ",
64351 @@ -287,7 +311,11 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
64352 flags & VM_WRITE ? 'w' : '-',
64353 flags & VM_EXEC ? 'x' : '-',
64354 flags & VM_MAYSHARE ? 's' : 'p',
64355 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
64356 + PAX_RAND_FLAGS(mm) ? 0UL : pgoff,
64357 +#else
64358 pgoff,
64359 +#endif
64360 MAJOR(dev), MINOR(dev), ino);
64361
64362 /*
64363 @@ -296,7 +324,7 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
64364 */
64365 if (file) {
64366 seq_pad(m, ' ');
64367 - seq_path(m, &file->f_path, "\n");
64368 + seq_path(m, &file->f_path, "\n\\");
64369 goto done;
64370 }
64371
64372 @@ -322,8 +350,9 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
64373 * Thread stack in /proc/PID/task/TID/maps or
64374 * the main process stack.
64375 */
64376 - if (!is_pid || (vma->vm_start <= mm->start_stack &&
64377 - vma->vm_end >= mm->start_stack)) {
64378 + if (!is_pid || (vma->vm_flags & (VM_GROWSDOWN | VM_GROWSUP)) ||
64379 + (vma->vm_start <= mm->start_stack &&
64380 + vma->vm_end >= mm->start_stack)) {
64381 name = "[stack]";
64382 } else {
64383 /* Thread stack in /proc/PID/maps */
64384 @@ -347,6 +376,13 @@ static int show_map(struct seq_file *m, void *v, int is_pid)
64385 struct proc_maps_private *priv = m->private;
64386 struct task_struct *task = priv->task;
64387
64388 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
64389 + if (current->exec_id != m->exec_id) {
64390 + gr_log_badprocpid("maps");
64391 + return 0;
64392 + }
64393 +#endif
64394 +
64395 show_map_vma(m, vma, is_pid);
64396
64397 if (m->count < m->size) /* vma is copied successfully */
64398 @@ -587,12 +623,23 @@ static int show_smap(struct seq_file *m, void *v, int is_pid)
64399 .private = &mss,
64400 };
64401
64402 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
64403 + if (current->exec_id != m->exec_id) {
64404 + gr_log_badprocpid("smaps");
64405 + return 0;
64406 + }
64407 +#endif
64408 memset(&mss, 0, sizeof mss);
64409 - mss.vma = vma;
64410 - /* mmap_sem is held in m_start */
64411 - if (vma->vm_mm && !is_vm_hugetlb_page(vma))
64412 - walk_page_range(vma->vm_start, vma->vm_end, &smaps_walk);
64413 -
64414 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
64415 + if (!PAX_RAND_FLAGS(vma->vm_mm)) {
64416 +#endif
64417 + mss.vma = vma;
64418 + /* mmap_sem is held in m_start */
64419 + if (vma->vm_mm && !is_vm_hugetlb_page(vma))
64420 + walk_page_range(vma->vm_start, vma->vm_end, &smaps_walk);
64421 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
64422 + }
64423 +#endif
64424 show_map_vma(m, vma, is_pid);
64425
64426 seq_printf(m,
64427 @@ -610,7 +657,11 @@ static int show_smap(struct seq_file *m, void *v, int is_pid)
64428 "KernelPageSize: %8lu kB\n"
64429 "MMUPageSize: %8lu kB\n"
64430 "Locked: %8lu kB\n",
64431 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
64432 + PAX_RAND_FLAGS(vma->vm_mm) ? 0UL : (vma->vm_end - vma->vm_start) >> 10,
64433 +#else
64434 (vma->vm_end - vma->vm_start) >> 10,
64435 +#endif
64436 mss.resident >> 10,
64437 (unsigned long)(mss.pss >> (10 + PSS_SHIFT)),
64438 mss.shared_clean >> 10,
64439 @@ -1388,6 +1439,13 @@ static int show_numa_map(struct seq_file *m, void *v, int is_pid)
64440 char buffer[64];
64441 int nid;
64442
64443 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
64444 + if (current->exec_id != m->exec_id) {
64445 + gr_log_badprocpid("numa_maps");
64446 + return 0;
64447 + }
64448 +#endif
64449 +
64450 if (!mm)
64451 return 0;
64452
64453 @@ -1405,11 +1463,15 @@ static int show_numa_map(struct seq_file *m, void *v, int is_pid)
64454 mpol_to_str(buffer, sizeof(buffer), pol);
64455 mpol_cond_put(pol);
64456
64457 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
64458 + seq_printf(m, "%08lx %s", PAX_RAND_FLAGS(vma->vm_mm) ? 0UL : vma->vm_start, buffer);
64459 +#else
64460 seq_printf(m, "%08lx %s", vma->vm_start, buffer);
64461 +#endif
64462
64463 if (file) {
64464 seq_printf(m, " file=");
64465 - seq_path(m, &file->f_path, "\n\t= ");
64466 + seq_path(m, &file->f_path, "\n\t\\= ");
64467 } else if (vma->vm_start <= mm->brk && vma->vm_end >= mm->start_brk) {
64468 seq_printf(m, " heap");
64469 } else {
64470 diff --git a/fs/proc/task_nommu.c b/fs/proc/task_nommu.c
64471 index 678455d..ebd3245 100644
64472 --- a/fs/proc/task_nommu.c
64473 +++ b/fs/proc/task_nommu.c
64474 @@ -51,7 +51,7 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
64475 else
64476 bytes += kobjsize(mm);
64477
64478 - if (current->fs && current->fs->users > 1)
64479 + if (current->fs && atomic_read(&current->fs->users) > 1)
64480 sbytes += kobjsize(current->fs);
64481 else
64482 bytes += kobjsize(current->fs);
64483 @@ -161,7 +161,7 @@ static int nommu_vma_show(struct seq_file *m, struct vm_area_struct *vma,
64484
64485 if (file) {
64486 seq_pad(m, ' ');
64487 - seq_path(m, &file->f_path, "");
64488 + seq_path(m, &file->f_path, "\n\\");
64489 } else if (mm) {
64490 pid_t tid = vm_is_stack(priv->task, vma, is_pid);
64491
64492 diff --git a/fs/proc/vmcore.c b/fs/proc/vmcore.c
64493 index 6a8e785..41f2a6c 100644
64494 --- a/fs/proc/vmcore.c
64495 +++ b/fs/proc/vmcore.c
64496 @@ -105,9 +105,13 @@ static ssize_t read_from_oldmem(char *buf, size_t count,
64497 nr_bytes = count;
64498
64499 /* If pfn is not ram, return zeros for sparse dump files */
64500 - if (pfn_is_ram(pfn) == 0)
64501 - memset(buf, 0, nr_bytes);
64502 - else {
64503 + if (pfn_is_ram(pfn) == 0) {
64504 + if (userbuf) {
64505 + if (clear_user((char __force_user *)buf, nr_bytes))
64506 + return -EFAULT;
64507 + } else
64508 + memset(buf, 0, nr_bytes);
64509 + } else {
64510 tmp = copy_oldmem_page(pfn, buf, nr_bytes,
64511 offset, userbuf);
64512 if (tmp < 0)
64513 @@ -170,7 +174,7 @@ int __weak remap_oldmem_pfn_range(struct vm_area_struct *vma,
64514 static int copy_to(void *target, void *src, size_t size, int userbuf)
64515 {
64516 if (userbuf) {
64517 - if (copy_to_user((char __user *) target, src, size))
64518 + if (copy_to_user((char __force_user *) target, src, size))
64519 return -EFAULT;
64520 } else {
64521 memcpy(target, src, size);
64522 @@ -233,7 +237,7 @@ static ssize_t __read_vmcore(char *buffer, size_t buflen, loff_t *fpos,
64523 if (*fpos < m->offset + m->size) {
64524 tsz = min_t(size_t, m->offset + m->size - *fpos, buflen);
64525 start = m->paddr + *fpos - m->offset;
64526 - tmp = read_from_oldmem(buffer, tsz, &start, userbuf);
64527 + tmp = read_from_oldmem((char __force_kernel *)buffer, tsz, &start, userbuf);
64528 if (tmp < 0)
64529 return tmp;
64530 buflen -= tsz;
64531 @@ -253,7 +257,7 @@ static ssize_t __read_vmcore(char *buffer, size_t buflen, loff_t *fpos,
64532 static ssize_t read_vmcore(struct file *file, char __user *buffer,
64533 size_t buflen, loff_t *fpos)
64534 {
64535 - return __read_vmcore((__force char *) buffer, buflen, fpos, 1);
64536 + return __read_vmcore((__force_kernel char *) buffer, buflen, fpos, 1);
64537 }
64538
64539 /*
64540 diff --git a/fs/qnx6/qnx6.h b/fs/qnx6/qnx6.h
64541 index b00fcc9..e0c6381 100644
64542 --- a/fs/qnx6/qnx6.h
64543 +++ b/fs/qnx6/qnx6.h
64544 @@ -74,7 +74,7 @@ enum {
64545 BYTESEX_BE,
64546 };
64547
64548 -static inline __u64 fs64_to_cpu(struct qnx6_sb_info *sbi, __fs64 n)
64549 +static inline __u64 __intentional_overflow(-1) fs64_to_cpu(struct qnx6_sb_info *sbi, __fs64 n)
64550 {
64551 if (sbi->s_bytesex == BYTESEX_LE)
64552 return le64_to_cpu((__force __le64)n);
64553 @@ -90,7 +90,7 @@ static inline __fs64 cpu_to_fs64(struct qnx6_sb_info *sbi, __u64 n)
64554 return (__force __fs64)cpu_to_be64(n);
64555 }
64556
64557 -static inline __u32 fs32_to_cpu(struct qnx6_sb_info *sbi, __fs32 n)
64558 +static inline __u32 __intentional_overflow(-1) fs32_to_cpu(struct qnx6_sb_info *sbi, __fs32 n)
64559 {
64560 if (sbi->s_bytesex == BYTESEX_LE)
64561 return le32_to_cpu((__force __le32)n);
64562 diff --git a/fs/quota/netlink.c b/fs/quota/netlink.c
64563 index 72d2917..c917c12 100644
64564 --- a/fs/quota/netlink.c
64565 +++ b/fs/quota/netlink.c
64566 @@ -45,7 +45,7 @@ static struct genl_family quota_genl_family = {
64567 void quota_send_warning(struct kqid qid, dev_t dev,
64568 const char warntype)
64569 {
64570 - static atomic_t seq;
64571 + static atomic_unchecked_t seq;
64572 struct sk_buff *skb;
64573 void *msg_head;
64574 int ret;
64575 @@ -61,7 +61,7 @@ void quota_send_warning(struct kqid qid, dev_t dev,
64576 "VFS: Not enough memory to send quota warning.\n");
64577 return;
64578 }
64579 - msg_head = genlmsg_put(skb, 0, atomic_add_return(1, &seq),
64580 + msg_head = genlmsg_put(skb, 0, atomic_add_return_unchecked(1, &seq),
64581 &quota_genl_family, 0, QUOTA_NL_C_WARNING);
64582 if (!msg_head) {
64583 printk(KERN_ERR
64584 diff --git a/fs/read_write.c b/fs/read_write.c
64585 index 31c6efa..a068805 100644
64586 --- a/fs/read_write.c
64587 +++ b/fs/read_write.c
64588 @@ -450,7 +450,7 @@ ssize_t __kernel_write(struct file *file, const char *buf, size_t count, loff_t
64589
64590 old_fs = get_fs();
64591 set_fs(get_ds());
64592 - p = (__force const char __user *)buf;
64593 + p = (const char __force_user *)buf;
64594 if (count > MAX_RW_COUNT)
64595 count = MAX_RW_COUNT;
64596 if (file->f_op->write)
64597 diff --git a/fs/readdir.c b/fs/readdir.c
64598 index 5b53d99..a6c3049 100644
64599 --- a/fs/readdir.c
64600 +++ b/fs/readdir.c
64601 @@ -17,6 +17,7 @@
64602 #include <linux/security.h>
64603 #include <linux/syscalls.h>
64604 #include <linux/unistd.h>
64605 +#include <linux/namei.h>
64606
64607 #include <asm/uaccess.h>
64608
64609 @@ -69,6 +70,7 @@ struct old_linux_dirent {
64610 struct readdir_callback {
64611 struct dir_context ctx;
64612 struct old_linux_dirent __user * dirent;
64613 + struct file * file;
64614 int result;
64615 };
64616
64617 @@ -86,6 +88,10 @@ static int fillonedir(void * __buf, const char * name, int namlen, loff_t offset
64618 buf->result = -EOVERFLOW;
64619 return -EOVERFLOW;
64620 }
64621 +
64622 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
64623 + return 0;
64624 +
64625 buf->result++;
64626 dirent = buf->dirent;
64627 if (!access_ok(VERIFY_WRITE, dirent,
64628 @@ -117,6 +123,7 @@ SYSCALL_DEFINE3(old_readdir, unsigned int, fd,
64629 if (!f.file)
64630 return -EBADF;
64631
64632 + buf.file = f.file;
64633 error = iterate_dir(f.file, &buf.ctx);
64634 if (buf.result)
64635 error = buf.result;
64636 @@ -142,6 +149,7 @@ struct getdents_callback {
64637 struct dir_context ctx;
64638 struct linux_dirent __user * current_dir;
64639 struct linux_dirent __user * previous;
64640 + struct file * file;
64641 int count;
64642 int error;
64643 };
64644 @@ -163,6 +171,10 @@ static int filldir(void * __buf, const char * name, int namlen, loff_t offset,
64645 buf->error = -EOVERFLOW;
64646 return -EOVERFLOW;
64647 }
64648 +
64649 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
64650 + return 0;
64651 +
64652 dirent = buf->previous;
64653 if (dirent) {
64654 if (__put_user(offset, &dirent->d_off))
64655 @@ -208,6 +220,7 @@ SYSCALL_DEFINE3(getdents, unsigned int, fd,
64656 if (!f.file)
64657 return -EBADF;
64658
64659 + buf.file = f.file;
64660 error = iterate_dir(f.file, &buf.ctx);
64661 if (error >= 0)
64662 error = buf.error;
64663 @@ -226,6 +239,7 @@ struct getdents_callback64 {
64664 struct dir_context ctx;
64665 struct linux_dirent64 __user * current_dir;
64666 struct linux_dirent64 __user * previous;
64667 + struct file *file;
64668 int count;
64669 int error;
64670 };
64671 @@ -241,6 +255,10 @@ static int filldir64(void * __buf, const char * name, int namlen, loff_t offset,
64672 buf->error = -EINVAL; /* only used if we fail.. */
64673 if (reclen > buf->count)
64674 return -EINVAL;
64675 +
64676 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
64677 + return 0;
64678 +
64679 dirent = buf->previous;
64680 if (dirent) {
64681 if (__put_user(offset, &dirent->d_off))
64682 @@ -288,6 +306,7 @@ SYSCALL_DEFINE3(getdents64, unsigned int, fd,
64683 if (!f.file)
64684 return -EBADF;
64685
64686 + buf.file = f.file;
64687 error = iterate_dir(f.file, &buf.ctx);
64688 if (error >= 0)
64689 error = buf.error;
64690 diff --git a/fs/reiserfs/do_balan.c b/fs/reiserfs/do_balan.c
64691 index 9a3c68c..767933e 100644
64692 --- a/fs/reiserfs/do_balan.c
64693 +++ b/fs/reiserfs/do_balan.c
64694 @@ -1546,7 +1546,7 @@ void do_balance(struct tree_balance *tb, /* tree_balance structure */
64695 return;
64696 }
64697
64698 - atomic_inc(&(fs_generation(tb->tb_sb)));
64699 + atomic_inc_unchecked(&(fs_generation(tb->tb_sb)));
64700 do_balance_starts(tb);
64701
64702 /* balance leaf returns 0 except if combining L R and S into
64703 diff --git a/fs/reiserfs/item_ops.c b/fs/reiserfs/item_ops.c
64704 index ee382ef..f4eb6eb5 100644
64705 --- a/fs/reiserfs/item_ops.c
64706 +++ b/fs/reiserfs/item_ops.c
64707 @@ -725,18 +725,18 @@ static void errcatch_print_vi(struct virtual_item *vi)
64708 }
64709
64710 static struct item_operations errcatch_ops = {
64711 - errcatch_bytes_number,
64712 - errcatch_decrement_key,
64713 - errcatch_is_left_mergeable,
64714 - errcatch_print_item,
64715 - errcatch_check_item,
64716 + .bytes_number = errcatch_bytes_number,
64717 + .decrement_key = errcatch_decrement_key,
64718 + .is_left_mergeable = errcatch_is_left_mergeable,
64719 + .print_item = errcatch_print_item,
64720 + .check_item = errcatch_check_item,
64721
64722 - errcatch_create_vi,
64723 - errcatch_check_left,
64724 - errcatch_check_right,
64725 - errcatch_part_size,
64726 - errcatch_unit_num,
64727 - errcatch_print_vi
64728 + .create_vi = errcatch_create_vi,
64729 + .check_left = errcatch_check_left,
64730 + .check_right = errcatch_check_right,
64731 + .part_size = errcatch_part_size,
64732 + .unit_num = errcatch_unit_num,
64733 + .print_vi = errcatch_print_vi
64734 };
64735
64736 //////////////////////////////////////////////////////////////////////////////
64737 diff --git a/fs/reiserfs/procfs.c b/fs/reiserfs/procfs.c
64738 index 02b0b7d..c85018b 100644
64739 --- a/fs/reiserfs/procfs.c
64740 +++ b/fs/reiserfs/procfs.c
64741 @@ -114,7 +114,7 @@ static int show_super(struct seq_file *m, void *unused)
64742 "SMALL_TAILS " : "NO_TAILS ",
64743 replay_only(sb) ? "REPLAY_ONLY " : "",
64744 convert_reiserfs(sb) ? "CONV " : "",
64745 - atomic_read(&r->s_generation_counter),
64746 + atomic_read_unchecked(&r->s_generation_counter),
64747 SF(s_disk_reads), SF(s_disk_writes), SF(s_fix_nodes),
64748 SF(s_do_balance), SF(s_unneeded_left_neighbor),
64749 SF(s_good_search_by_key_reada), SF(s_bmaps),
64750 diff --git a/fs/reiserfs/reiserfs.h b/fs/reiserfs/reiserfs.h
64751 index 83d4eac..04e39a7 100644
64752 --- a/fs/reiserfs/reiserfs.h
64753 +++ b/fs/reiserfs/reiserfs.h
64754 @@ -453,7 +453,7 @@ struct reiserfs_sb_info {
64755 /* Comment? -Hans */
64756 wait_queue_head_t s_wait;
64757 /* To be obsoleted soon by per buffer seals.. -Hans */
64758 - atomic_t s_generation_counter; // increased by one every time the
64759 + atomic_unchecked_t s_generation_counter; // increased by one every time the
64760 // tree gets re-balanced
64761 unsigned long s_properties; /* File system properties. Currently holds
64762 on-disk FS format */
64763 @@ -1972,7 +1972,7 @@ static inline loff_t max_reiserfs_offset(struct inode *inode)
64764 #define REISERFS_USER_MEM 1 /* reiserfs user memory mode */
64765
64766 #define fs_generation(s) (REISERFS_SB(s)->s_generation_counter)
64767 -#define get_generation(s) atomic_read (&fs_generation(s))
64768 +#define get_generation(s) atomic_read_unchecked (&fs_generation(s))
64769 #define FILESYSTEM_CHANGED_TB(tb) (get_generation((tb)->tb_sb) != (tb)->fs_gen)
64770 #define __fs_changed(gen,s) (gen != get_generation (s))
64771 #define fs_changed(gen,s) \
64772 diff --git a/fs/select.c b/fs/select.c
64773 index 467bb1c..cf9d65a 100644
64774 --- a/fs/select.c
64775 +++ b/fs/select.c
64776 @@ -20,6 +20,7 @@
64777 #include <linux/export.h>
64778 #include <linux/slab.h>
64779 #include <linux/poll.h>
64780 +#include <linux/security.h>
64781 #include <linux/personality.h> /* for STICKY_TIMEOUTS */
64782 #include <linux/file.h>
64783 #include <linux/fdtable.h>
64784 @@ -880,6 +881,7 @@ int do_sys_poll(struct pollfd __user *ufds, unsigned int nfds,
64785 struct poll_list *walk = head;
64786 unsigned long todo = nfds;
64787
64788 + gr_learn_resource(current, RLIMIT_NOFILE, nfds, 1);
64789 if (nfds > rlimit(RLIMIT_NOFILE))
64790 return -EINVAL;
64791
64792 diff --git a/fs/seq_file.c b/fs/seq_file.c
64793 index 1d641bb..c2f4743 100644
64794 --- a/fs/seq_file.c
64795 +++ b/fs/seq_file.c
64796 @@ -10,6 +10,8 @@
64797 #include <linux/seq_file.h>
64798 #include <linux/slab.h>
64799 #include <linux/cred.h>
64800 +#include <linux/sched.h>
64801 +#include <linux/grsecurity.h>
64802
64803 #include <asm/uaccess.h>
64804 #include <asm/page.h>
64805 @@ -60,6 +62,9 @@ int seq_open(struct file *file, const struct seq_operations *op)
64806 #ifdef CONFIG_USER_NS
64807 p->user_ns = file->f_cred->user_ns;
64808 #endif
64809 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
64810 + p->exec_id = current->exec_id;
64811 +#endif
64812
64813 /*
64814 * Wrappers around seq_open(e.g. swaps_open) need to be
64815 @@ -82,6 +87,16 @@ int seq_open(struct file *file, const struct seq_operations *op)
64816 }
64817 EXPORT_SYMBOL(seq_open);
64818
64819 +
64820 +int seq_open_restrict(struct file *file, const struct seq_operations *op)
64821 +{
64822 + if (gr_proc_is_restricted())
64823 + return -EACCES;
64824 +
64825 + return seq_open(file, op);
64826 +}
64827 +EXPORT_SYMBOL(seq_open_restrict);
64828 +
64829 static int traverse(struct seq_file *m, loff_t offset)
64830 {
64831 loff_t pos = 0, index;
64832 @@ -96,7 +111,7 @@ static int traverse(struct seq_file *m, loff_t offset)
64833 return 0;
64834 }
64835 if (!m->buf) {
64836 - m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL);
64837 + m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL | GFP_USERCOPY);
64838 if (!m->buf)
64839 return -ENOMEM;
64840 }
64841 @@ -137,7 +152,7 @@ Eoverflow:
64842 m->op->stop(m, p);
64843 kfree(m->buf);
64844 m->count = 0;
64845 - m->buf = kmalloc(m->size <<= 1, GFP_KERNEL);
64846 + m->buf = kmalloc(m->size <<= 1, GFP_KERNEL | GFP_USERCOPY);
64847 return !m->buf ? -ENOMEM : -EAGAIN;
64848 }
64849
64850 @@ -153,7 +168,7 @@ Eoverflow:
64851 ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos)
64852 {
64853 struct seq_file *m = file->private_data;
64854 - size_t copied = 0;
64855 + ssize_t copied = 0;
64856 loff_t pos;
64857 size_t n;
64858 void *p;
64859 @@ -192,7 +207,7 @@ ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos)
64860
64861 /* grab buffer if we didn't have one */
64862 if (!m->buf) {
64863 - m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL);
64864 + m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL | GFP_USERCOPY);
64865 if (!m->buf)
64866 goto Enomem;
64867 }
64868 @@ -234,7 +249,7 @@ ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos)
64869 m->op->stop(m, p);
64870 kfree(m->buf);
64871 m->count = 0;
64872 - m->buf = kmalloc(m->size <<= 1, GFP_KERNEL);
64873 + m->buf = kmalloc(m->size <<= 1, GFP_KERNEL | GFP_USERCOPY);
64874 if (!m->buf)
64875 goto Enomem;
64876 m->version = 0;
64877 @@ -584,7 +599,7 @@ static void single_stop(struct seq_file *p, void *v)
64878 int single_open(struct file *file, int (*show)(struct seq_file *, void *),
64879 void *data)
64880 {
64881 - struct seq_operations *op = kmalloc(sizeof(*op), GFP_KERNEL);
64882 + seq_operations_no_const *op = kzalloc(sizeof(*op), GFP_KERNEL);
64883 int res = -ENOMEM;
64884
64885 if (op) {
64886 @@ -620,6 +635,17 @@ int single_open_size(struct file *file, int (*show)(struct seq_file *, void *),
64887 }
64888 EXPORT_SYMBOL(single_open_size);
64889
64890 +int single_open_restrict(struct file *file, int (*show)(struct seq_file *, void *),
64891 + void *data)
64892 +{
64893 + if (gr_proc_is_restricted())
64894 + return -EACCES;
64895 +
64896 + return single_open(file, show, data);
64897 +}
64898 +EXPORT_SYMBOL(single_open_restrict);
64899 +
64900 +
64901 int single_release(struct inode *inode, struct file *file)
64902 {
64903 const struct seq_operations *op = ((struct seq_file *)file->private_data)->op;
64904 diff --git a/fs/splice.c b/fs/splice.c
64905 index e246954..bd4f5b5 100644
64906 --- a/fs/splice.c
64907 +++ b/fs/splice.c
64908 @@ -192,7 +192,7 @@ ssize_t splice_to_pipe(struct pipe_inode_info *pipe,
64909 pipe_lock(pipe);
64910
64911 for (;;) {
64912 - if (!pipe->readers) {
64913 + if (!atomic_read(&pipe->readers)) {
64914 send_sig(SIGPIPE, current, 0);
64915 if (!ret)
64916 ret = -EPIPE;
64917 @@ -215,7 +215,7 @@ ssize_t splice_to_pipe(struct pipe_inode_info *pipe,
64918 page_nr++;
64919 ret += buf->len;
64920
64921 - if (pipe->files)
64922 + if (atomic_read(&pipe->files))
64923 do_wakeup = 1;
64924
64925 if (!--spd->nr_pages)
64926 @@ -246,9 +246,9 @@ ssize_t splice_to_pipe(struct pipe_inode_info *pipe,
64927 do_wakeup = 0;
64928 }
64929
64930 - pipe->waiting_writers++;
64931 + atomic_inc(&pipe->waiting_writers);
64932 pipe_wait(pipe);
64933 - pipe->waiting_writers--;
64934 + atomic_dec(&pipe->waiting_writers);
64935 }
64936
64937 pipe_unlock(pipe);
64938 @@ -575,7 +575,7 @@ static ssize_t kernel_readv(struct file *file, const struct iovec *vec,
64939 old_fs = get_fs();
64940 set_fs(get_ds());
64941 /* The cast to a user pointer is valid due to the set_fs() */
64942 - res = vfs_readv(file, (const struct iovec __user *)vec, vlen, &pos);
64943 + res = vfs_readv(file, (const struct iovec __force_user *)vec, vlen, &pos);
64944 set_fs(old_fs);
64945
64946 return res;
64947 @@ -590,7 +590,7 @@ ssize_t kernel_write(struct file *file, const char *buf, size_t count,
64948 old_fs = get_fs();
64949 set_fs(get_ds());
64950 /* The cast to a user pointer is valid due to the set_fs() */
64951 - res = vfs_write(file, (__force const char __user *)buf, count, &pos);
64952 + res = vfs_write(file, (const char __force_user *)buf, count, &pos);
64953 set_fs(old_fs);
64954
64955 return res;
64956 @@ -643,7 +643,7 @@ ssize_t default_file_splice_read(struct file *in, loff_t *ppos,
64957 goto err;
64958
64959 this_len = min_t(size_t, len, PAGE_CACHE_SIZE - offset);
64960 - vec[i].iov_base = (void __user *) page_address(page);
64961 + vec[i].iov_base = (void __force_user *) page_address(page);
64962 vec[i].iov_len = this_len;
64963 spd.pages[i] = page;
64964 spd.nr_pages++;
64965 @@ -839,7 +839,7 @@ int splice_from_pipe_feed(struct pipe_inode_info *pipe, struct splice_desc *sd,
64966 ops->release(pipe, buf);
64967 pipe->curbuf = (pipe->curbuf + 1) & (pipe->buffers - 1);
64968 pipe->nrbufs--;
64969 - if (pipe->files)
64970 + if (atomic_read(&pipe->files))
64971 sd->need_wakeup = true;
64972 }
64973
64974 @@ -864,10 +864,10 @@ EXPORT_SYMBOL(splice_from_pipe_feed);
64975 int splice_from_pipe_next(struct pipe_inode_info *pipe, struct splice_desc *sd)
64976 {
64977 while (!pipe->nrbufs) {
64978 - if (!pipe->writers)
64979 + if (!atomic_read(&pipe->writers))
64980 return 0;
64981
64982 - if (!pipe->waiting_writers && sd->num_spliced)
64983 + if (!atomic_read(&pipe->waiting_writers) && sd->num_spliced)
64984 return 0;
64985
64986 if (sd->flags & SPLICE_F_NONBLOCK)
64987 @@ -1189,7 +1189,7 @@ ssize_t splice_direct_to_actor(struct file *in, struct splice_desc *sd,
64988 * out of the pipe right after the splice_to_pipe(). So set
64989 * PIPE_READERS appropriately.
64990 */
64991 - pipe->readers = 1;
64992 + atomic_set(&pipe->readers, 1);
64993
64994 current->splice_pipe = pipe;
64995 }
64996 @@ -1485,6 +1485,7 @@ static int get_iovec_page_array(const struct iovec __user *iov,
64997
64998 partial[buffers].offset = off;
64999 partial[buffers].len = plen;
65000 + partial[buffers].private = 0;
65001
65002 off = 0;
65003 len -= plen;
65004 @@ -1721,9 +1722,9 @@ static int ipipe_prep(struct pipe_inode_info *pipe, unsigned int flags)
65005 ret = -ERESTARTSYS;
65006 break;
65007 }
65008 - if (!pipe->writers)
65009 + if (!atomic_read(&pipe->writers))
65010 break;
65011 - if (!pipe->waiting_writers) {
65012 + if (!atomic_read(&pipe->waiting_writers)) {
65013 if (flags & SPLICE_F_NONBLOCK) {
65014 ret = -EAGAIN;
65015 break;
65016 @@ -1755,7 +1756,7 @@ static int opipe_prep(struct pipe_inode_info *pipe, unsigned int flags)
65017 pipe_lock(pipe);
65018
65019 while (pipe->nrbufs >= pipe->buffers) {
65020 - if (!pipe->readers) {
65021 + if (!atomic_read(&pipe->readers)) {
65022 send_sig(SIGPIPE, current, 0);
65023 ret = -EPIPE;
65024 break;
65025 @@ -1768,9 +1769,9 @@ static int opipe_prep(struct pipe_inode_info *pipe, unsigned int flags)
65026 ret = -ERESTARTSYS;
65027 break;
65028 }
65029 - pipe->waiting_writers++;
65030 + atomic_inc(&pipe->waiting_writers);
65031 pipe_wait(pipe);
65032 - pipe->waiting_writers--;
65033 + atomic_dec(&pipe->waiting_writers);
65034 }
65035
65036 pipe_unlock(pipe);
65037 @@ -1806,14 +1807,14 @@ retry:
65038 pipe_double_lock(ipipe, opipe);
65039
65040 do {
65041 - if (!opipe->readers) {
65042 + if (!atomic_read(&opipe->readers)) {
65043 send_sig(SIGPIPE, current, 0);
65044 if (!ret)
65045 ret = -EPIPE;
65046 break;
65047 }
65048
65049 - if (!ipipe->nrbufs && !ipipe->writers)
65050 + if (!ipipe->nrbufs && !atomic_read(&ipipe->writers))
65051 break;
65052
65053 /*
65054 @@ -1910,7 +1911,7 @@ static int link_pipe(struct pipe_inode_info *ipipe,
65055 pipe_double_lock(ipipe, opipe);
65056
65057 do {
65058 - if (!opipe->readers) {
65059 + if (!atomic_read(&opipe->readers)) {
65060 send_sig(SIGPIPE, current, 0);
65061 if (!ret)
65062 ret = -EPIPE;
65063 @@ -1955,7 +1956,7 @@ static int link_pipe(struct pipe_inode_info *ipipe,
65064 * return EAGAIN if we have the potential of some data in the
65065 * future, otherwise just return 0
65066 */
65067 - if (!ret && ipipe->waiting_writers && (flags & SPLICE_F_NONBLOCK))
65068 + if (!ret && atomic_read(&ipipe->waiting_writers) && (flags & SPLICE_F_NONBLOCK))
65069 ret = -EAGAIN;
65070
65071 pipe_unlock(ipipe);
65072 diff --git a/fs/stat.c b/fs/stat.c
65073 index ae0c3ce..9ee641c 100644
65074 --- a/fs/stat.c
65075 +++ b/fs/stat.c
65076 @@ -28,8 +28,13 @@ void generic_fillattr(struct inode *inode, struct kstat *stat)
65077 stat->gid = inode->i_gid;
65078 stat->rdev = inode->i_rdev;
65079 stat->size = i_size_read(inode);
65080 - stat->atime = inode->i_atime;
65081 - stat->mtime = inode->i_mtime;
65082 + if (is_sidechannel_device(inode) && !capable_nolog(CAP_MKNOD)) {
65083 + stat->atime = inode->i_ctime;
65084 + stat->mtime = inode->i_ctime;
65085 + } else {
65086 + stat->atime = inode->i_atime;
65087 + stat->mtime = inode->i_mtime;
65088 + }
65089 stat->ctime = inode->i_ctime;
65090 stat->blksize = (1 << inode->i_blkbits);
65091 stat->blocks = inode->i_blocks;
65092 @@ -52,9 +57,16 @@ EXPORT_SYMBOL(generic_fillattr);
65093 int vfs_getattr_nosec(struct path *path, struct kstat *stat)
65094 {
65095 struct inode *inode = path->dentry->d_inode;
65096 + int retval;
65097
65098 - if (inode->i_op->getattr)
65099 - return inode->i_op->getattr(path->mnt, path->dentry, stat);
65100 + if (inode->i_op->getattr) {
65101 + retval = inode->i_op->getattr(path->mnt, path->dentry, stat);
65102 + if (!retval && is_sidechannel_device(inode) && !capable_nolog(CAP_MKNOD)) {
65103 + stat->atime = stat->ctime;
65104 + stat->mtime = stat->ctime;
65105 + }
65106 + return retval;
65107 + }
65108
65109 generic_fillattr(inode, stat);
65110 return 0;
65111 diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c
65112 index 0b45ff4..847de5b 100644
65113 --- a/fs/sysfs/dir.c
65114 +++ b/fs/sysfs/dir.c
65115 @@ -41,9 +41,16 @@ void sysfs_warn_dup(struct kernfs_node *parent, const char *name)
65116 int sysfs_create_dir_ns(struct kobject *kobj, const void *ns)
65117 {
65118 struct kernfs_node *parent, *kn;
65119 + const char *name;
65120 + umode_t mode = S_IRWXU | S_IRUGO | S_IXUGO;
65121 +#ifdef CONFIG_GRKERNSEC_SYSFS_RESTRICT
65122 + const char *parent_name;
65123 +#endif
65124
65125 BUG_ON(!kobj);
65126
65127 + name = kobject_name(kobj);
65128 +
65129 if (kobj->parent)
65130 parent = kobj->parent->sd;
65131 else
65132 @@ -52,11 +59,22 @@ int sysfs_create_dir_ns(struct kobject *kobj, const void *ns)
65133 if (!parent)
65134 return -ENOENT;
65135
65136 - kn = kernfs_create_dir_ns(parent, kobject_name(kobj),
65137 - S_IRWXU | S_IRUGO | S_IXUGO, kobj, ns);
65138 +#ifdef CONFIG_GRKERNSEC_SYSFS_RESTRICT
65139 + parent_name = parent->name;
65140 + mode = S_IRWXU;
65141 +
65142 + if ((!strcmp(parent_name, "") && (!strcmp(name, "devices") || !strcmp(name, "fs"))) ||
65143 + (!strcmp(parent_name, "devices") && !strcmp(name, "system")) ||
65144 + (!strcmp(parent_name, "fs") && (!strcmp(name, "selinux") || !strcmp(name, "fuse") || !strcmp(name, "ecryptfs"))) ||
65145 + (!strcmp(parent_name, "system") && !strcmp(name, "cpu")))
65146 + mode = S_IRWXU | S_IRUGO | S_IXUGO;
65147 +#endif
65148 +
65149 + kn = kernfs_create_dir_ns(parent, name,
65150 + mode, kobj, ns);
65151 if (IS_ERR(kn)) {
65152 if (PTR_ERR(kn) == -EEXIST)
65153 - sysfs_warn_dup(parent, kobject_name(kobj));
65154 + sysfs_warn_dup(parent, name);
65155 return PTR_ERR(kn);
65156 }
65157
65158 diff --git a/fs/sysv/sysv.h b/fs/sysv/sysv.h
65159 index 69d4889..a810bd4 100644
65160 --- a/fs/sysv/sysv.h
65161 +++ b/fs/sysv/sysv.h
65162 @@ -188,7 +188,7 @@ static inline u32 PDP_swab(u32 x)
65163 #endif
65164 }
65165
65166 -static inline __u32 fs32_to_cpu(struct sysv_sb_info *sbi, __fs32 n)
65167 +static inline __u32 __intentional_overflow(-1) fs32_to_cpu(struct sysv_sb_info *sbi, __fs32 n)
65168 {
65169 if (sbi->s_bytesex == BYTESEX_PDP)
65170 return PDP_swab((__force __u32)n);
65171 diff --git a/fs/ubifs/io.c b/fs/ubifs/io.c
65172 index e18b988..f1d4ad0f 100644
65173 --- a/fs/ubifs/io.c
65174 +++ b/fs/ubifs/io.c
65175 @@ -155,7 +155,7 @@ int ubifs_leb_change(struct ubifs_info *c, int lnum, const void *buf, int len)
65176 return err;
65177 }
65178
65179 -int ubifs_leb_unmap(struct ubifs_info *c, int lnum)
65180 +int __intentional_overflow(-1) ubifs_leb_unmap(struct ubifs_info *c, int lnum)
65181 {
65182 int err;
65183
65184 diff --git a/fs/udf/misc.c b/fs/udf/misc.c
65185 index c175b4d..8f36a16 100644
65186 --- a/fs/udf/misc.c
65187 +++ b/fs/udf/misc.c
65188 @@ -289,7 +289,7 @@ void udf_new_tag(char *data, uint16_t ident, uint16_t version, uint16_t snum,
65189
65190 u8 udf_tag_checksum(const struct tag *t)
65191 {
65192 - u8 *data = (u8 *)t;
65193 + const u8 *data = (const u8 *)t;
65194 u8 checksum = 0;
65195 int i;
65196 for (i = 0; i < sizeof(struct tag); ++i)
65197 diff --git a/fs/ufs/swab.h b/fs/ufs/swab.h
65198 index 8d974c4..b82f6ec 100644
65199 --- a/fs/ufs/swab.h
65200 +++ b/fs/ufs/swab.h
65201 @@ -22,7 +22,7 @@ enum {
65202 BYTESEX_BE
65203 };
65204
65205 -static inline u64
65206 +static inline u64 __intentional_overflow(-1)
65207 fs64_to_cpu(struct super_block *sbp, __fs64 n)
65208 {
65209 if (UFS_SB(sbp)->s_bytesex == BYTESEX_LE)
65210 @@ -40,7 +40,7 @@ cpu_to_fs64(struct super_block *sbp, u64 n)
65211 return (__force __fs64)cpu_to_be64(n);
65212 }
65213
65214 -static inline u32
65215 +static inline u32 __intentional_overflow(-1)
65216 fs32_to_cpu(struct super_block *sbp, __fs32 n)
65217 {
65218 if (UFS_SB(sbp)->s_bytesex == BYTESEX_LE)
65219 diff --git a/fs/utimes.c b/fs/utimes.c
65220 index aa138d6..5f3a811 100644
65221 --- a/fs/utimes.c
65222 +++ b/fs/utimes.c
65223 @@ -1,6 +1,7 @@
65224 #include <linux/compiler.h>
65225 #include <linux/file.h>
65226 #include <linux/fs.h>
65227 +#include <linux/security.h>
65228 #include <linux/linkage.h>
65229 #include <linux/mount.h>
65230 #include <linux/namei.h>
65231 @@ -103,6 +104,12 @@ static int utimes_common(struct path *path, struct timespec *times)
65232 }
65233 }
65234 retry_deleg:
65235 +
65236 + if (!gr_acl_handle_utime(path->dentry, path->mnt)) {
65237 + error = -EACCES;
65238 + goto mnt_drop_write_and_out;
65239 + }
65240 +
65241 mutex_lock(&inode->i_mutex);
65242 error = notify_change(path->dentry, &newattrs, &delegated_inode);
65243 mutex_unlock(&inode->i_mutex);
65244 diff --git a/fs/xattr.c b/fs/xattr.c
65245 index 3377dff..f394815 100644
65246 --- a/fs/xattr.c
65247 +++ b/fs/xattr.c
65248 @@ -227,6 +227,27 @@ int vfs_xattr_cmp(struct dentry *dentry, const char *xattr_name,
65249 return rc;
65250 }
65251
65252 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
65253 +ssize_t
65254 +pax_getxattr(struct dentry *dentry, void *value, size_t size)
65255 +{
65256 + struct inode *inode = dentry->d_inode;
65257 + ssize_t error;
65258 +
65259 + error = inode_permission(inode, MAY_EXEC);
65260 + if (error)
65261 + return error;
65262 +
65263 + if (inode->i_op->getxattr)
65264 + error = inode->i_op->getxattr(dentry, XATTR_NAME_PAX_FLAGS, value, size);
65265 + else
65266 + error = -EOPNOTSUPP;
65267 +
65268 + return error;
65269 +}
65270 +EXPORT_SYMBOL(pax_getxattr);
65271 +#endif
65272 +
65273 ssize_t
65274 vfs_getxattr(struct dentry *dentry, const char *name, void *value, size_t size)
65275 {
65276 @@ -319,7 +340,7 @@ EXPORT_SYMBOL_GPL(vfs_removexattr);
65277 * Extended attribute SET operations
65278 */
65279 static long
65280 -setxattr(struct dentry *d, const char __user *name, const void __user *value,
65281 +setxattr(struct path *path, const char __user *name, const void __user *value,
65282 size_t size, int flags)
65283 {
65284 int error;
65285 @@ -355,7 +376,12 @@ setxattr(struct dentry *d, const char __user *name, const void __user *value,
65286 posix_acl_fix_xattr_from_user(kvalue, size);
65287 }
65288
65289 - error = vfs_setxattr(d, kname, kvalue, size, flags);
65290 + if (!gr_acl_handle_setxattr(path->dentry, path->mnt)) {
65291 + error = -EACCES;
65292 + goto out;
65293 + }
65294 +
65295 + error = vfs_setxattr(path->dentry, kname, kvalue, size, flags);
65296 out:
65297 if (vvalue)
65298 vfree(vvalue);
65299 @@ -377,7 +403,7 @@ retry:
65300 return error;
65301 error = mnt_want_write(path.mnt);
65302 if (!error) {
65303 - error = setxattr(path.dentry, name, value, size, flags);
65304 + error = setxattr(&path, name, value, size, flags);
65305 mnt_drop_write(path.mnt);
65306 }
65307 path_put(&path);
65308 @@ -401,7 +427,7 @@ retry:
65309 return error;
65310 error = mnt_want_write(path.mnt);
65311 if (!error) {
65312 - error = setxattr(path.dentry, name, value, size, flags);
65313 + error = setxattr(&path, name, value, size, flags);
65314 mnt_drop_write(path.mnt);
65315 }
65316 path_put(&path);
65317 @@ -416,16 +442,14 @@ SYSCALL_DEFINE5(fsetxattr, int, fd, const char __user *, name,
65318 const void __user *,value, size_t, size, int, flags)
65319 {
65320 struct fd f = fdget(fd);
65321 - struct dentry *dentry;
65322 int error = -EBADF;
65323
65324 if (!f.file)
65325 return error;
65326 - dentry = f.file->f_path.dentry;
65327 - audit_inode(NULL, dentry, 0);
65328 + audit_inode(NULL, f.file->f_path.dentry, 0);
65329 error = mnt_want_write_file(f.file);
65330 if (!error) {
65331 - error = setxattr(dentry, name, value, size, flags);
65332 + error = setxattr(&f.file->f_path, name, value, size, flags);
65333 mnt_drop_write_file(f.file);
65334 }
65335 fdput(f);
65336 @@ -626,7 +650,7 @@ SYSCALL_DEFINE3(flistxattr, int, fd, char __user *, list, size_t, size)
65337 * Extended attribute REMOVE operations
65338 */
65339 static long
65340 -removexattr(struct dentry *d, const char __user *name)
65341 +removexattr(struct path *path, const char __user *name)
65342 {
65343 int error;
65344 char kname[XATTR_NAME_MAX + 1];
65345 @@ -637,7 +661,10 @@ removexattr(struct dentry *d, const char __user *name)
65346 if (error < 0)
65347 return error;
65348
65349 - return vfs_removexattr(d, kname);
65350 + if (!gr_acl_handle_removexattr(path->dentry, path->mnt))
65351 + return -EACCES;
65352 +
65353 + return vfs_removexattr(path->dentry, kname);
65354 }
65355
65356 SYSCALL_DEFINE2(removexattr, const char __user *, pathname,
65357 @@ -652,7 +679,7 @@ retry:
65358 return error;
65359 error = mnt_want_write(path.mnt);
65360 if (!error) {
65361 - error = removexattr(path.dentry, name);
65362 + error = removexattr(&path, name);
65363 mnt_drop_write(path.mnt);
65364 }
65365 path_put(&path);
65366 @@ -675,7 +702,7 @@ retry:
65367 return error;
65368 error = mnt_want_write(path.mnt);
65369 if (!error) {
65370 - error = removexattr(path.dentry, name);
65371 + error = removexattr(&path, name);
65372 mnt_drop_write(path.mnt);
65373 }
65374 path_put(&path);
65375 @@ -689,16 +716,16 @@ retry:
65376 SYSCALL_DEFINE2(fremovexattr, int, fd, const char __user *, name)
65377 {
65378 struct fd f = fdget(fd);
65379 - struct dentry *dentry;
65380 + struct path *path;
65381 int error = -EBADF;
65382
65383 if (!f.file)
65384 return error;
65385 - dentry = f.file->f_path.dentry;
65386 - audit_inode(NULL, dentry, 0);
65387 + path = &f.file->f_path;
65388 + audit_inode(NULL, path->dentry, 0);
65389 error = mnt_want_write_file(f.file);
65390 if (!error) {
65391 - error = removexattr(dentry, name);
65392 + error = removexattr(path, name);
65393 mnt_drop_write_file(f.file);
65394 }
65395 fdput(f);
65396 diff --git a/fs/xfs/xfs_bmap.c b/fs/xfs/xfs_bmap.c
65397 index f0efc7e..ba72910 100644
65398 --- a/fs/xfs/xfs_bmap.c
65399 +++ b/fs/xfs/xfs_bmap.c
65400 @@ -584,7 +584,7 @@ xfs_bmap_validate_ret(
65401
65402 #else
65403 #define xfs_bmap_check_leaf_extents(cur, ip, whichfork) do { } while (0)
65404 -#define xfs_bmap_validate_ret(bno,len,flags,mval,onmap,nmap)
65405 +#define xfs_bmap_validate_ret(bno,len,flags,mval,onmap,nmap) do { } while (0)
65406 #endif /* DEBUG */
65407
65408 /*
65409 diff --git a/fs/xfs/xfs_dir2_readdir.c b/fs/xfs/xfs_dir2_readdir.c
65410 index aead369..0dfecfd 100644
65411 --- a/fs/xfs/xfs_dir2_readdir.c
65412 +++ b/fs/xfs/xfs_dir2_readdir.c
65413 @@ -160,7 +160,12 @@ xfs_dir2_sf_getdents(
65414 ino = dp->d_ops->sf_get_ino(sfp, sfep);
65415 filetype = dp->d_ops->sf_get_ftype(sfep);
65416 ctx->pos = off & 0x7fffffff;
65417 - if (!dir_emit(ctx, (char *)sfep->name, sfep->namelen, ino,
65418 + if (dp->i_df.if_u1.if_data == dp->i_df.if_u2.if_inline_data) {
65419 + char name[sfep->namelen];
65420 + memcpy(name, sfep->name, sfep->namelen);
65421 + if (!dir_emit(ctx, name, sfep->namelen, ino, xfs_dir3_get_dtype(mp, filetype)))
65422 + return 0;
65423 + } else if (!dir_emit(ctx, (char *)sfep->name, sfep->namelen, ino,
65424 xfs_dir3_get_dtype(mp, filetype)))
65425 return 0;
65426 sfep = dp->d_ops->sf_nextentry(sfp, sfep);
65427 diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
65428 index 6152cbe..f0f9eaa 100644
65429 --- a/fs/xfs/xfs_ioctl.c
65430 +++ b/fs/xfs/xfs_ioctl.c
65431 @@ -122,7 +122,7 @@ xfs_find_handle(
65432 }
65433
65434 error = -EFAULT;
65435 - if (copy_to_user(hreq->ohandle, &handle, hsize) ||
65436 + if (hsize > sizeof handle || copy_to_user(hreq->ohandle, &handle, hsize) ||
65437 copy_to_user(hreq->ohandlen, &hsize, sizeof(__s32)))
65438 goto out_put;
65439
65440 diff --git a/grsecurity/Kconfig b/grsecurity/Kconfig
65441 new file mode 100644
65442 index 0000000..bfd482c
65443 --- /dev/null
65444 +++ b/grsecurity/Kconfig
65445 @@ -0,0 +1,1176 @@
65446 +#
65447 +# grecurity configuration
65448 +#
65449 +menu "Memory Protections"
65450 +depends on GRKERNSEC
65451 +
65452 +config GRKERNSEC_KMEM
65453 + bool "Deny reading/writing to /dev/kmem, /dev/mem, and /dev/port"
65454 + default y if GRKERNSEC_CONFIG_AUTO
65455 + select STRICT_DEVMEM if (X86 || ARM || TILE || S390)
65456 + help
65457 + If you say Y here, /dev/kmem and /dev/mem won't be allowed to
65458 + be written to or read from to modify or leak the contents of the running
65459 + kernel. /dev/port will also not be allowed to be opened, writing to
65460 + /dev/cpu/*/msr will be prevented, and support for kexec will be removed.
65461 + If you have module support disabled, enabling this will close up several
65462 + ways that are currently used to insert malicious code into the running
65463 + kernel.
65464 +
65465 + Even with this feature enabled, we still highly recommend that
65466 + you use the RBAC system, as it is still possible for an attacker to
65467 + modify the running kernel through other more obscure methods.
65468 +
65469 + It is highly recommended that you say Y here if you meet all the
65470 + conditions above.
65471 +
65472 +config GRKERNSEC_VM86
65473 + bool "Restrict VM86 mode"
65474 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER)
65475 + depends on X86_32
65476 +
65477 + help
65478 + If you say Y here, only processes with CAP_SYS_RAWIO will be able to
65479 + make use of a special execution mode on 32bit x86 processors called
65480 + Virtual 8086 (VM86) mode. XFree86 may need vm86 mode for certain
65481 + video cards and will still work with this option enabled. The purpose
65482 + of the option is to prevent exploitation of emulation errors in
65483 + virtualization of vm86 mode like the one discovered in VMWare in 2009.
65484 + Nearly all users should be able to enable this option.
65485 +
65486 +config GRKERNSEC_IO
65487 + bool "Disable privileged I/O"
65488 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER)
65489 + depends on X86
65490 + select RTC_CLASS
65491 + select RTC_INTF_DEV
65492 + select RTC_DRV_CMOS
65493 +
65494 + help
65495 + If you say Y here, all ioperm and iopl calls will return an error.
65496 + Ioperm and iopl can be used to modify the running kernel.
65497 + Unfortunately, some programs need this access to operate properly,
65498 + the most notable of which are XFree86 and hwclock. hwclock can be
65499 + remedied by having RTC support in the kernel, so real-time
65500 + clock support is enabled if this option is enabled, to ensure
65501 + that hwclock operates correctly. If hwclock still does not work,
65502 + either update udev or symlink /dev/rtc to /dev/rtc0.
65503 +
65504 + If you're using XFree86 or a version of Xorg from 2012 or earlier,
65505 + you may not be able to boot into a graphical environment with this
65506 + option enabled. In this case, you should use the RBAC system instead.
65507 +
65508 +config GRKERNSEC_JIT_HARDEN
65509 + bool "Harden BPF JIT against spray attacks"
65510 + default y if GRKERNSEC_CONFIG_AUTO
65511 + depends on BPF_JIT && X86
65512 + help
65513 + If you say Y here, the native code generated by the kernel's Berkeley
65514 + Packet Filter (BPF) JIT engine will be hardened against JIT-spraying
65515 + attacks that attempt to fit attacker-beneficial instructions in
65516 + 32bit immediate fields of JIT-generated native instructions. The
65517 + attacker will generally aim to cause an unintended instruction sequence
65518 + of JIT-generated native code to execute by jumping into the middle of
65519 + a generated instruction. This feature effectively randomizes the 32bit
65520 + immediate constants present in the generated code to thwart such attacks.
65521 +
65522 + If you're using KERNEXEC, it's recommended that you enable this option
65523 + to supplement the hardening of the kernel.
65524 +
65525 +config GRKERNSEC_PERF_HARDEN
65526 + bool "Disable unprivileged PERF_EVENTS usage by default"
65527 + default y if GRKERNSEC_CONFIG_AUTO
65528 + depends on PERF_EVENTS
65529 + help
65530 + If you say Y here, the range of acceptable values for the
65531 + /proc/sys/kernel/perf_event_paranoid sysctl will be expanded to allow and
65532 + default to a new value: 3. When the sysctl is set to this value, no
65533 + unprivileged use of the PERF_EVENTS syscall interface will be permitted.
65534 +
65535 + Though PERF_EVENTS can be used legitimately for performance monitoring
65536 + and low-level application profiling, it is forced on regardless of
65537 + configuration, has been at fault for several vulnerabilities, and
65538 + creates new opportunities for side channels and other information leaks.
65539 +
65540 + This feature puts PERF_EVENTS into a secure default state and permits
65541 + the administrator to change out of it temporarily if unprivileged
65542 + application profiling is needed.
65543 +
65544 +config GRKERNSEC_RAND_THREADSTACK
65545 + bool "Insert random gaps between thread stacks"
65546 + default y if GRKERNSEC_CONFIG_AUTO
65547 + depends on PAX_RANDMMAP && !PPC
65548 + help
65549 + If you say Y here, a random-sized gap will be enforced between allocated
65550 + thread stacks. Glibc's NPTL and other threading libraries that
65551 + pass MAP_STACK to the kernel for thread stack allocation are supported.
65552 + The implementation currently provides 8 bits of entropy for the gap.
65553 +
65554 + Many distributions do not compile threaded remote services with the
65555 + -fstack-check argument to GCC, causing the variable-sized stack-based
65556 + allocator, alloca(), to not probe the stack on allocation. This
65557 + permits an unbounded alloca() to skip over any guard page and potentially
65558 + modify another thread's stack reliably. An enforced random gap
65559 + reduces the reliability of such an attack and increases the chance
65560 + that such a read/write to another thread's stack instead lands in
65561 + an unmapped area, causing a crash and triggering grsecurity's
65562 + anti-bruteforcing logic.
65563 +
65564 +config GRKERNSEC_PROC_MEMMAP
65565 + bool "Harden ASLR against information leaks and entropy reduction"
65566 + default y if (GRKERNSEC_CONFIG_AUTO || PAX_NOEXEC || PAX_ASLR)
65567 + depends on PAX_NOEXEC || PAX_ASLR
65568 + help
65569 + If you say Y here, the /proc/<pid>/maps and /proc/<pid>/stat files will
65570 + give no information about the addresses of its mappings if
65571 + PaX features that rely on random addresses are enabled on the task.
65572 + In addition to sanitizing this information and disabling other
65573 + dangerous sources of information, this option causes reads of sensitive
65574 + /proc/<pid> entries where the file descriptor was opened in a different
65575 + task than the one performing the read. Such attempts are logged.
65576 + This option also limits argv/env strings for suid/sgid binaries
65577 + to 512KB to prevent a complete exhaustion of the stack entropy provided
65578 + by ASLR. Finally, it places an 8MB stack resource limit on suid/sgid
65579 + binaries to prevent alternative mmap layouts from being abused.
65580 +
65581 + If you use PaX it is essential that you say Y here as it closes up
65582 + several holes that make full ASLR useless locally.
65583 +
65584 +
65585 +config GRKERNSEC_KSTACKOVERFLOW
65586 + bool "Prevent kernel stack overflows"
65587 + default y if GRKERNSEC_CONFIG_AUTO
65588 + depends on !IA64 && 64BIT
65589 + help
65590 + If you say Y here, the kernel's process stacks will be allocated
65591 + with vmalloc instead of the kernel's default allocator. This
65592 + introduces guard pages that in combination with the alloca checking
65593 + of the STACKLEAK feature prevents all forms of kernel process stack
65594 + overflow abuse. Note that this is different from kernel stack
65595 + buffer overflows.
65596 +
65597 +config GRKERNSEC_BRUTE
65598 + bool "Deter exploit bruteforcing"
65599 + default y if GRKERNSEC_CONFIG_AUTO
65600 + help
65601 + If you say Y here, attempts to bruteforce exploits against forking
65602 + daemons such as apache or sshd, as well as against suid/sgid binaries
65603 + will be deterred. When a child of a forking daemon is killed by PaX
65604 + or crashes due to an illegal instruction or other suspicious signal,
65605 + the parent process will be delayed 30 seconds upon every subsequent
65606 + fork until the administrator is able to assess the situation and
65607 + restart the daemon.
65608 + In the suid/sgid case, the attempt is logged, the user has all their
65609 + existing instances of the suid/sgid binary terminated and will
65610 + be unable to execute any suid/sgid binaries for 15 minutes.
65611 +
65612 + It is recommended that you also enable signal logging in the auditing
65613 + section so that logs are generated when a process triggers a suspicious
65614 + signal.
65615 + If the sysctl option is enabled, a sysctl option with name
65616 + "deter_bruteforce" is created.
65617 +
65618 +config GRKERNSEC_MODHARDEN
65619 + bool "Harden module auto-loading"
65620 + default y if GRKERNSEC_CONFIG_AUTO
65621 + depends on MODULES
65622 + help
65623 + If you say Y here, module auto-loading in response to use of some
65624 + feature implemented by an unloaded module will be restricted to
65625 + root users. Enabling this option helps defend against attacks
65626 + by unprivileged users who abuse the auto-loading behavior to
65627 + cause a vulnerable module to load that is then exploited.
65628 +
65629 + If this option prevents a legitimate use of auto-loading for a
65630 + non-root user, the administrator can execute modprobe manually
65631 + with the exact name of the module mentioned in the alert log.
65632 + Alternatively, the administrator can add the module to the list
65633 + of modules loaded at boot by modifying init scripts.
65634 +
65635 + Modification of init scripts will most likely be needed on
65636 + Ubuntu servers with encrypted home directory support enabled,
65637 + as the first non-root user logging in will cause the ecb(aes),
65638 + ecb(aes)-all, cbc(aes), and cbc(aes)-all modules to be loaded.
65639 +
65640 +config GRKERNSEC_HIDESYM
65641 + bool "Hide kernel symbols"
65642 + default y if GRKERNSEC_CONFIG_AUTO
65643 + select PAX_USERCOPY_SLABS
65644 + help
65645 + If you say Y here, getting information on loaded modules, and
65646 + displaying all kernel symbols through a syscall will be restricted
65647 + to users with CAP_SYS_MODULE. For software compatibility reasons,
65648 + /proc/kallsyms will be restricted to the root user. The RBAC
65649 + system can hide that entry even from root.
65650 +
65651 + This option also prevents leaking of kernel addresses through
65652 + several /proc entries.
65653 +
65654 + Note that this option is only effective provided the following
65655 + conditions are met:
65656 + 1) The kernel using grsecurity is not precompiled by some distribution
65657 + 2) You have also enabled GRKERNSEC_DMESG
65658 + 3) You are using the RBAC system and hiding other files such as your
65659 + kernel image and System.map. Alternatively, enabling this option
65660 + causes the permissions on /boot, /lib/modules, and the kernel
65661 + source directory to change at compile time to prevent
65662 + reading by non-root users.
65663 + If the above conditions are met, this option will aid in providing a
65664 + useful protection against local kernel exploitation of overflows
65665 + and arbitrary read/write vulnerabilities.
65666 +
65667 + It is highly recommended that you enable GRKERNSEC_PERF_HARDEN
65668 + in addition to this feature.
65669 +
65670 +config GRKERNSEC_RANDSTRUCT
65671 + bool "Randomize layout of sensitive kernel structures"
65672 + default y if GRKERNSEC_CONFIG_AUTO
65673 + select GRKERNSEC_HIDESYM
65674 + select MODVERSIONS if MODULES
65675 + help
65676 + If you say Y here, the layouts of a number of sensitive kernel
65677 + structures (task, fs, cred, etc) and all structures composed entirely
65678 + of function pointers (aka "ops" structs) will be randomized at compile-time.
65679 + This can introduce the requirement of an additional infoleak
65680 + vulnerability for exploits targeting these structure types.
65681 +
65682 + Enabling this feature will introduce some performance impact, slightly
65683 + increase memory usage, and prevent the use of forensic tools like
65684 + Volatility against the system (unless the kernel source tree isn't
65685 + cleaned after kernel installation).
65686 +
65687 + The seed used for compilation is located at tools/gcc/randomize_layout_seed.h.
65688 + It remains after a make clean to allow for external modules to be compiled
65689 + with the existing seed and will be removed by a make mrproper or
65690 + make distclean.
65691 +
65692 + Note that the implementation requires gcc 4.6.4. or newer. You may need
65693 + to install the supporting headers explicitly in addition to the normal
65694 + gcc package.
65695 +
65696 +config GRKERNSEC_RANDSTRUCT_PERFORMANCE
65697 + bool "Use cacheline-aware structure randomization"
65698 + depends on GRKERNSEC_RANDSTRUCT
65699 + default y if GRKERNSEC_CONFIG_PRIORITY_PERF
65700 + help
65701 + If you say Y here, the RANDSTRUCT randomization will make a best effort
65702 + at restricting randomization to cacheline-sized groups of elements. It
65703 + will further not randomize bitfields in structures. This reduces the
65704 + performance hit of RANDSTRUCT at the cost of weakened randomization.
65705 +
65706 +config GRKERNSEC_KERN_LOCKOUT
65707 + bool "Active kernel exploit response"
65708 + default y if GRKERNSEC_CONFIG_AUTO
65709 + depends on X86 || ARM || PPC || SPARC
65710 + help
65711 + If you say Y here, when a PaX alert is triggered due to suspicious
65712 + activity in the kernel (from KERNEXEC/UDEREF/USERCOPY)
65713 + or an OOPS occurs due to bad memory accesses, instead of just
65714 + terminating the offending process (and potentially allowing
65715 + a subsequent exploit from the same user), we will take one of two
65716 + actions:
65717 + If the user was root, we will panic the system
65718 + If the user was non-root, we will log the attempt, terminate
65719 + all processes owned by the user, then prevent them from creating
65720 + any new processes until the system is restarted
65721 + This deters repeated kernel exploitation/bruteforcing attempts
65722 + and is useful for later forensics.
65723 +
65724 +config GRKERNSEC_OLD_ARM_USERLAND
65725 + bool "Old ARM userland compatibility"
65726 + depends on ARM && (CPU_V6 || CPU_V6K || CPU_V7)
65727 + help
65728 + If you say Y here, stubs of executable code to perform such operations
65729 + as "compare-exchange" will be placed at fixed locations in the ARM vector
65730 + table. This is unfortunately needed for old ARM userland meant to run
65731 + across a wide range of processors. Without this option enabled,
65732 + the get_tls and data memory barrier stubs will be emulated by the kernel,
65733 + which is enough for Linaro userlands or other userlands designed for v6
65734 + and newer ARM CPUs. It's recommended that you try without this option enabled
65735 + first, and only enable it if your userland does not boot (it will likely fail
65736 + at init time).
65737 +
65738 +endmenu
65739 +menu "Role Based Access Control Options"
65740 +depends on GRKERNSEC
65741 +
65742 +config GRKERNSEC_RBAC_DEBUG
65743 + bool
65744 +
65745 +config GRKERNSEC_NO_RBAC
65746 + bool "Disable RBAC system"
65747 + help
65748 + If you say Y here, the /dev/grsec device will be removed from the kernel,
65749 + preventing the RBAC system from being enabled. You should only say Y
65750 + here if you have no intention of using the RBAC system, so as to prevent
65751 + an attacker with root access from misusing the RBAC system to hide files
65752 + and processes when loadable module support and /dev/[k]mem have been
65753 + locked down.
65754 +
65755 +config GRKERNSEC_ACL_HIDEKERN
65756 + bool "Hide kernel processes"
65757 + help
65758 + If you say Y here, all kernel threads will be hidden to all
65759 + processes but those whose subject has the "view hidden processes"
65760 + flag.
65761 +
65762 +config GRKERNSEC_ACL_MAXTRIES
65763 + int "Maximum tries before password lockout"
65764 + default 3
65765 + help
65766 + This option enforces the maximum number of times a user can attempt
65767 + to authorize themselves with the grsecurity RBAC system before being
65768 + denied the ability to attempt authorization again for a specified time.
65769 + The lower the number, the harder it will be to brute-force a password.
65770 +
65771 +config GRKERNSEC_ACL_TIMEOUT
65772 + int "Time to wait after max password tries, in seconds"
65773 + default 30
65774 + help
65775 + This option specifies the time the user must wait after attempting to
65776 + authorize to the RBAC system with the maximum number of invalid
65777 + passwords. The higher the number, the harder it will be to brute-force
65778 + a password.
65779 +
65780 +endmenu
65781 +menu "Filesystem Protections"
65782 +depends on GRKERNSEC
65783 +
65784 +config GRKERNSEC_PROC
65785 + bool "Proc restrictions"
65786 + default y if GRKERNSEC_CONFIG_AUTO
65787 + help
65788 + If you say Y here, the permissions of the /proc filesystem
65789 + will be altered to enhance system security and privacy. You MUST
65790 + choose either a user only restriction or a user and group restriction.
65791 + Depending upon the option you choose, you can either restrict users to
65792 + see only the processes they themselves run, or choose a group that can
65793 + view all processes and files normally restricted to root if you choose
65794 + the "restrict to user only" option. NOTE: If you're running identd or
65795 + ntpd as a non-root user, you will have to run it as the group you
65796 + specify here.
65797 +
65798 +config GRKERNSEC_PROC_USER
65799 + bool "Restrict /proc to user only"
65800 + depends on GRKERNSEC_PROC
65801 + help
65802 + If you say Y here, non-root users will only be able to view their own
65803 + processes, and restricts them from viewing network-related information,
65804 + and viewing kernel symbol and module information.
65805 +
65806 +config GRKERNSEC_PROC_USERGROUP
65807 + bool "Allow special group"
65808 + default y if GRKERNSEC_CONFIG_AUTO
65809 + depends on GRKERNSEC_PROC && !GRKERNSEC_PROC_USER
65810 + help
65811 + If you say Y here, you will be able to select a group that will be
65812 + able to view all processes and network-related information. If you've
65813 + enabled GRKERNSEC_HIDESYM, kernel and symbol information may still
65814 + remain hidden. This option is useful if you want to run identd as
65815 + a non-root user. The group you select may also be chosen at boot time
65816 + via "grsec_proc_gid=" on the kernel commandline.
65817 +
65818 +config GRKERNSEC_PROC_GID
65819 + int "GID for special group"
65820 + depends on GRKERNSEC_PROC_USERGROUP
65821 + default 1001
65822 +
65823 +config GRKERNSEC_PROC_ADD
65824 + bool "Additional restrictions"
65825 + default y if GRKERNSEC_CONFIG_AUTO
65826 + depends on GRKERNSEC_PROC_USER || GRKERNSEC_PROC_USERGROUP
65827 + help
65828 + If you say Y here, additional restrictions will be placed on
65829 + /proc that keep normal users from viewing device information and
65830 + slabinfo information that could be useful for exploits.
65831 +
65832 +config GRKERNSEC_LINK
65833 + bool "Linking restrictions"
65834 + default y if GRKERNSEC_CONFIG_AUTO
65835 + help
65836 + If you say Y here, /tmp race exploits will be prevented, since users
65837 + will no longer be able to follow symlinks owned by other users in
65838 + world-writable +t directories (e.g. /tmp), unless the owner of the
65839 + symlink is the owner of the directory. users will also not be
65840 + able to hardlink to files they do not own. If the sysctl option is
65841 + enabled, a sysctl option with name "linking_restrictions" is created.
65842 +
65843 +config GRKERNSEC_SYMLINKOWN
65844 + bool "Kernel-enforced SymlinksIfOwnerMatch"
65845 + default y if GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER
65846 + help
65847 + Apache's SymlinksIfOwnerMatch option has an inherent race condition
65848 + that prevents it from being used as a security feature. As Apache
65849 + verifies the symlink by performing a stat() against the target of
65850 + the symlink before it is followed, an attacker can setup a symlink
65851 + to point to a same-owned file, then replace the symlink with one
65852 + that targets another user's file just after Apache "validates" the
65853 + symlink -- a classic TOCTOU race. If you say Y here, a complete,
65854 + race-free replacement for Apache's "SymlinksIfOwnerMatch" option
65855 + will be in place for the group you specify. If the sysctl option
65856 + is enabled, a sysctl option with name "enforce_symlinksifowner" is
65857 + created.
65858 +
65859 +config GRKERNSEC_SYMLINKOWN_GID
65860 + int "GID for users with kernel-enforced SymlinksIfOwnerMatch"
65861 + depends on GRKERNSEC_SYMLINKOWN
65862 + default 1006
65863 + help
65864 + Setting this GID determines what group kernel-enforced
65865 + SymlinksIfOwnerMatch will be enabled for. If the sysctl option
65866 + is enabled, a sysctl option with name "symlinkown_gid" is created.
65867 +
65868 +config GRKERNSEC_FIFO
65869 + bool "FIFO restrictions"
65870 + default y if GRKERNSEC_CONFIG_AUTO
65871 + help
65872 + If you say Y here, users will not be able to write to FIFOs they don't
65873 + own in world-writable +t directories (e.g. /tmp), unless the owner of
65874 + the FIFO is the same owner of the directory it's held in. If the sysctl
65875 + option is enabled, a sysctl option with name "fifo_restrictions" is
65876 + created.
65877 +
65878 +config GRKERNSEC_SYSFS_RESTRICT
65879 + bool "Sysfs/debugfs restriction"
65880 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER)
65881 + depends on SYSFS
65882 + help
65883 + If you say Y here, sysfs (the pseudo-filesystem mounted at /sys) and
65884 + any filesystem normally mounted under it (e.g. debugfs) will be
65885 + mostly accessible only by root. These filesystems generally provide access
65886 + to hardware and debug information that isn't appropriate for unprivileged
65887 + users of the system. Sysfs and debugfs have also become a large source
65888 + of new vulnerabilities, ranging from infoleaks to local compromise.
65889 + There has been very little oversight with an eye toward security involved
65890 + in adding new exporters of information to these filesystems, so their
65891 + use is discouraged.
65892 + For reasons of compatibility, a few directories have been whitelisted
65893 + for access by non-root users:
65894 + /sys/fs/selinux
65895 + /sys/fs/fuse
65896 + /sys/devices/system/cpu
65897 +
65898 +config GRKERNSEC_ROFS
65899 + bool "Runtime read-only mount protection"
65900 + depends on SYSCTL
65901 + help
65902 + If you say Y here, a sysctl option with name "romount_protect" will
65903 + be created. By setting this option to 1 at runtime, filesystems
65904 + will be protected in the following ways:
65905 + * No new writable mounts will be allowed
65906 + * Existing read-only mounts won't be able to be remounted read/write
65907 + * Write operations will be denied on all block devices
65908 + This option acts independently of grsec_lock: once it is set to 1,
65909 + it cannot be turned off. Therefore, please be mindful of the resulting
65910 + behavior if this option is enabled in an init script on a read-only
65911 + filesystem.
65912 + Also be aware that as with other root-focused features, GRKERNSEC_KMEM
65913 + and GRKERNSEC_IO should be enabled and module loading disabled via
65914 + config or at runtime.
65915 + This feature is mainly intended for secure embedded systems.
65916 +
65917 +
65918 +config GRKERNSEC_DEVICE_SIDECHANNEL
65919 + bool "Eliminate stat/notify-based device sidechannels"
65920 + default y if GRKERNSEC_CONFIG_AUTO
65921 + help
65922 + If you say Y here, timing analyses on block or character
65923 + devices like /dev/ptmx using stat or inotify/dnotify/fanotify
65924 + will be thwarted for unprivileged users. If a process without
65925 + CAP_MKNOD stats such a device, the last access and last modify times
65926 + will match the device's create time. No access or modify events
65927 + will be triggered through inotify/dnotify/fanotify for such devices.
65928 + This feature will prevent attacks that may at a minimum
65929 + allow an attacker to determine the administrator's password length.
65930 +
65931 +config GRKERNSEC_CHROOT
65932 + bool "Chroot jail restrictions"
65933 + default y if GRKERNSEC_CONFIG_AUTO
65934 + help
65935 + If you say Y here, you will be able to choose several options that will
65936 + make breaking out of a chrooted jail much more difficult. If you
65937 + encounter no software incompatibilities with the following options, it
65938 + is recommended that you enable each one.
65939 +
65940 + Note that the chroot restrictions are not intended to apply to "chroots"
65941 + to directories that are simple bind mounts of the global root filesystem.
65942 + For several other reasons, a user shouldn't expect any significant
65943 + security by performing such a chroot.
65944 +
65945 +config GRKERNSEC_CHROOT_MOUNT
65946 + bool "Deny mounts"
65947 + default y if GRKERNSEC_CONFIG_AUTO
65948 + depends on GRKERNSEC_CHROOT
65949 + help
65950 + If you say Y here, processes inside a chroot will not be able to
65951 + mount or remount filesystems. If the sysctl option is enabled, a
65952 + sysctl option with name "chroot_deny_mount" is created.
65953 +
65954 +config GRKERNSEC_CHROOT_DOUBLE
65955 + bool "Deny double-chroots"
65956 + default y if GRKERNSEC_CONFIG_AUTO
65957 + depends on GRKERNSEC_CHROOT
65958 + help
65959 + If you say Y here, processes inside a chroot will not be able to chroot
65960 + again outside the chroot. This is a widely used method of breaking
65961 + out of a chroot jail and should not be allowed. If the sysctl
65962 + option is enabled, a sysctl option with name
65963 + "chroot_deny_chroot" is created.
65964 +
65965 +config GRKERNSEC_CHROOT_PIVOT
65966 + bool "Deny pivot_root in chroot"
65967 + default y if GRKERNSEC_CONFIG_AUTO
65968 + depends on GRKERNSEC_CHROOT
65969 + help
65970 + If you say Y here, processes inside a chroot will not be able to use
65971 + a function called pivot_root() that was introduced in Linux 2.3.41. It
65972 + works similar to chroot in that it changes the root filesystem. This
65973 + function could be misused in a chrooted process to attempt to break out
65974 + of the chroot, and therefore should not be allowed. If the sysctl
65975 + option is enabled, a sysctl option with name "chroot_deny_pivot" is
65976 + created.
65977 +
65978 +config GRKERNSEC_CHROOT_CHDIR
65979 + bool "Enforce chdir(\"/\") on all chroots"
65980 + default y if GRKERNSEC_CONFIG_AUTO
65981 + depends on GRKERNSEC_CHROOT
65982 + help
65983 + If you say Y here, the current working directory of all newly-chrooted
65984 + applications will be set to the the root directory of the chroot.
65985 + The man page on chroot(2) states:
65986 + Note that this call does not change the current working
65987 + directory, so that `.' can be outside the tree rooted at
65988 + `/'. In particular, the super-user can escape from a
65989 + `chroot jail' by doing `mkdir foo; chroot foo; cd ..'.
65990 +
65991 + It is recommended that you say Y here, since it's not known to break
65992 + any software. If the sysctl option is enabled, a sysctl option with
65993 + name "chroot_enforce_chdir" is created.
65994 +
65995 +config GRKERNSEC_CHROOT_CHMOD
65996 + bool "Deny (f)chmod +s"
65997 + default y if GRKERNSEC_CONFIG_AUTO
65998 + depends on GRKERNSEC_CHROOT
65999 + help
66000 + If you say Y here, processes inside a chroot will not be able to chmod
66001 + or fchmod files to make them have suid or sgid bits. This protects
66002 + against another published method of breaking a chroot. If the sysctl
66003 + option is enabled, a sysctl option with name "chroot_deny_chmod" is
66004 + created.
66005 +
66006 +config GRKERNSEC_CHROOT_FCHDIR
66007 + bool "Deny fchdir and fhandle out of chroot"
66008 + default y if GRKERNSEC_CONFIG_AUTO
66009 + depends on GRKERNSEC_CHROOT
66010 + help
66011 + If you say Y here, a well-known method of breaking chroots by fchdir'ing
66012 + to a file descriptor of the chrooting process that points to a directory
66013 + outside the filesystem will be stopped. Additionally, this option prevents
66014 + use of the recently-created syscall for opening files by a guessable "file
66015 + handle" inside a chroot. If the sysctl option is enabled, a sysctl option
66016 + with name "chroot_deny_fchdir" is created.
66017 +
66018 +config GRKERNSEC_CHROOT_MKNOD
66019 + bool "Deny mknod"
66020 + default y if GRKERNSEC_CONFIG_AUTO
66021 + depends on GRKERNSEC_CHROOT
66022 + help
66023 + If you say Y here, processes inside a chroot will not be allowed to
66024 + mknod. The problem with using mknod inside a chroot is that it
66025 + would allow an attacker to create a device entry that is the same
66026 + as one on the physical root of your system, which could range from
66027 + anything from the console device to a device for your harddrive (which
66028 + they could then use to wipe the drive or steal data). It is recommended
66029 + that you say Y here, unless you run into software incompatibilities.
66030 + If the sysctl option is enabled, a sysctl option with name
66031 + "chroot_deny_mknod" is created.
66032 +
66033 +config GRKERNSEC_CHROOT_SHMAT
66034 + bool "Deny shmat() out of chroot"
66035 + default y if GRKERNSEC_CONFIG_AUTO
66036 + depends on GRKERNSEC_CHROOT
66037 + help
66038 + If you say Y here, processes inside a chroot will not be able to attach
66039 + to shared memory segments that were created outside of the chroot jail.
66040 + It is recommended that you say Y here. If the sysctl option is enabled,
66041 + a sysctl option with name "chroot_deny_shmat" is created.
66042 +
66043 +config GRKERNSEC_CHROOT_UNIX
66044 + bool "Deny access to abstract AF_UNIX sockets out of chroot"
66045 + default y if GRKERNSEC_CONFIG_AUTO
66046 + depends on GRKERNSEC_CHROOT
66047 + help
66048 + If you say Y here, processes inside a chroot will not be able to
66049 + connect to abstract (meaning not belonging to a filesystem) Unix
66050 + domain sockets that were bound outside of a chroot. It is recommended
66051 + that you say Y here. If the sysctl option is enabled, a sysctl option
66052 + with name "chroot_deny_unix" is created.
66053 +
66054 +config GRKERNSEC_CHROOT_FINDTASK
66055 + bool "Protect outside processes"
66056 + default y if GRKERNSEC_CONFIG_AUTO
66057 + depends on GRKERNSEC_CHROOT
66058 + help
66059 + If you say Y here, processes inside a chroot will not be able to
66060 + kill, send signals with fcntl, ptrace, capget, getpgid, setpgid,
66061 + getsid, or view any process outside of the chroot. If the sysctl
66062 + option is enabled, a sysctl option with name "chroot_findtask" is
66063 + created.
66064 +
66065 +config GRKERNSEC_CHROOT_NICE
66066 + bool "Restrict priority changes"
66067 + default y if GRKERNSEC_CONFIG_AUTO
66068 + depends on GRKERNSEC_CHROOT
66069 + help
66070 + If you say Y here, processes inside a chroot will not be able to raise
66071 + the priority of processes in the chroot, or alter the priority of
66072 + processes outside the chroot. This provides more security than simply
66073 + removing CAP_SYS_NICE from the process' capability set. If the
66074 + sysctl option is enabled, a sysctl option with name "chroot_restrict_nice"
66075 + is created.
66076 +
66077 +config GRKERNSEC_CHROOT_SYSCTL
66078 + bool "Deny sysctl writes"
66079 + default y if GRKERNSEC_CONFIG_AUTO
66080 + depends on GRKERNSEC_CHROOT
66081 + help
66082 + If you say Y here, an attacker in a chroot will not be able to
66083 + write to sysctl entries, either by sysctl(2) or through a /proc
66084 + interface. It is strongly recommended that you say Y here. If the
66085 + sysctl option is enabled, a sysctl option with name
66086 + "chroot_deny_sysctl" is created.
66087 +
66088 +config GRKERNSEC_CHROOT_CAPS
66089 + bool "Capability restrictions"
66090 + default y if GRKERNSEC_CONFIG_AUTO
66091 + depends on GRKERNSEC_CHROOT
66092 + help
66093 + If you say Y here, the capabilities on all processes within a
66094 + chroot jail will be lowered to stop module insertion, raw i/o,
66095 + system and net admin tasks, rebooting the system, modifying immutable
66096 + files, modifying IPC owned by another, and changing the system time.
66097 + This is left an option because it can break some apps. Disable this
66098 + if your chrooted apps are having problems performing those kinds of
66099 + tasks. If the sysctl option is enabled, a sysctl option with
66100 + name "chroot_caps" is created.
66101 +
66102 +config GRKERNSEC_CHROOT_INITRD
66103 + bool "Exempt initrd tasks from restrictions"
66104 + default y if GRKERNSEC_CONFIG_AUTO
66105 + depends on GRKERNSEC_CHROOT && BLK_DEV_INITRD
66106 + help
66107 + If you say Y here, tasks started prior to init will be exempted from
66108 + grsecurity's chroot restrictions. This option is mainly meant to
66109 + resolve Plymouth's performing privileged operations unnecessarily
66110 + in a chroot.
66111 +
66112 +endmenu
66113 +menu "Kernel Auditing"
66114 +depends on GRKERNSEC
66115 +
66116 +config GRKERNSEC_AUDIT_GROUP
66117 + bool "Single group for auditing"
66118 + help
66119 + If you say Y here, the exec and chdir logging features will only operate
66120 + on a group you specify. This option is recommended if you only want to
66121 + watch certain users instead of having a large amount of logs from the
66122 + entire system. If the sysctl option is enabled, a sysctl option with
66123 + name "audit_group" is created.
66124 +
66125 +config GRKERNSEC_AUDIT_GID
66126 + int "GID for auditing"
66127 + depends on GRKERNSEC_AUDIT_GROUP
66128 + default 1007
66129 +
66130 +config GRKERNSEC_EXECLOG
66131 + bool "Exec logging"
66132 + help
66133 + If you say Y here, all execve() calls will be logged (since the
66134 + other exec*() calls are frontends to execve(), all execution
66135 + will be logged). Useful for shell-servers that like to keep track
66136 + of their users. If the sysctl option is enabled, a sysctl option with
66137 + name "exec_logging" is created.
66138 + WARNING: This option when enabled will produce a LOT of logs, especially
66139 + on an active system.
66140 +
66141 +config GRKERNSEC_RESLOG
66142 + bool "Resource logging"
66143 + default y if GRKERNSEC_CONFIG_AUTO
66144 + help
66145 + If you say Y here, all attempts to overstep resource limits will
66146 + be logged with the resource name, the requested size, and the current
66147 + limit. It is highly recommended that you say Y here. If the sysctl
66148 + option is enabled, a sysctl option with name "resource_logging" is
66149 + created. If the RBAC system is enabled, the sysctl value is ignored.
66150 +
66151 +config GRKERNSEC_CHROOT_EXECLOG
66152 + bool "Log execs within chroot"
66153 + help
66154 + If you say Y here, all executions inside a chroot jail will be logged
66155 + to syslog. This can cause a large amount of logs if certain
66156 + applications (eg. djb's daemontools) are installed on the system, and
66157 + is therefore left as an option. If the sysctl option is enabled, a
66158 + sysctl option with name "chroot_execlog" is created.
66159 +
66160 +config GRKERNSEC_AUDIT_PTRACE
66161 + bool "Ptrace logging"
66162 + help
66163 + If you say Y here, all attempts to attach to a process via ptrace
66164 + will be logged. If the sysctl option is enabled, a sysctl option
66165 + with name "audit_ptrace" is created.
66166 +
66167 +config GRKERNSEC_AUDIT_CHDIR
66168 + bool "Chdir logging"
66169 + help
66170 + If you say Y here, all chdir() calls will be logged. If the sysctl
66171 + option is enabled, a sysctl option with name "audit_chdir" is created.
66172 +
66173 +config GRKERNSEC_AUDIT_MOUNT
66174 + bool "(Un)Mount logging"
66175 + help
66176 + If you say Y here, all mounts and unmounts will be logged. If the
66177 + sysctl option is enabled, a sysctl option with name "audit_mount" is
66178 + created.
66179 +
66180 +config GRKERNSEC_SIGNAL
66181 + bool "Signal logging"
66182 + default y if GRKERNSEC_CONFIG_AUTO
66183 + help
66184 + If you say Y here, certain important signals will be logged, such as
66185 + SIGSEGV, which will as a result inform you of when a error in a program
66186 + occurred, which in some cases could mean a possible exploit attempt.
66187 + If the sysctl option is enabled, a sysctl option with name
66188 + "signal_logging" is created.
66189 +
66190 +config GRKERNSEC_FORKFAIL
66191 + bool "Fork failure logging"
66192 + help
66193 + If you say Y here, all failed fork() attempts will be logged.
66194 + This could suggest a fork bomb, or someone attempting to overstep
66195 + their process limit. If the sysctl option is enabled, a sysctl option
66196 + with name "forkfail_logging" is created.
66197 +
66198 +config GRKERNSEC_TIME
66199 + bool "Time change logging"
66200 + default y if GRKERNSEC_CONFIG_AUTO
66201 + help
66202 + If you say Y here, any changes of the system clock will be logged.
66203 + If the sysctl option is enabled, a sysctl option with name
66204 + "timechange_logging" is created.
66205 +
66206 +config GRKERNSEC_PROC_IPADDR
66207 + bool "/proc/<pid>/ipaddr support"
66208 + default y if GRKERNSEC_CONFIG_AUTO
66209 + help
66210 + If you say Y here, a new entry will be added to each /proc/<pid>
66211 + directory that contains the IP address of the person using the task.
66212 + The IP is carried across local TCP and AF_UNIX stream sockets.
66213 + This information can be useful for IDS/IPSes to perform remote response
66214 + to a local attack. The entry is readable by only the owner of the
66215 + process (and root if he has CAP_DAC_OVERRIDE, which can be removed via
66216 + the RBAC system), and thus does not create privacy concerns.
66217 +
66218 +config GRKERNSEC_RWXMAP_LOG
66219 + bool 'Denied RWX mmap/mprotect logging'
66220 + default y if GRKERNSEC_CONFIG_AUTO
66221 + depends on PAX_MPROTECT && !PAX_EMUPLT && !PAX_EMUSIGRT
66222 + help
66223 + If you say Y here, calls to mmap() and mprotect() with explicit
66224 + usage of PROT_WRITE and PROT_EXEC together will be logged when
66225 + denied by the PAX_MPROTECT feature. This feature will also
66226 + log other problematic scenarios that can occur when PAX_MPROTECT
66227 + is enabled on a binary, like textrels and PT_GNU_STACK. If the
66228 + sysctl option is enabled, a sysctl option with name "rwxmap_logging"
66229 + is created.
66230 +
66231 +endmenu
66232 +
66233 +menu "Executable Protections"
66234 +depends on GRKERNSEC
66235 +
66236 +config GRKERNSEC_DMESG
66237 + bool "Dmesg(8) restriction"
66238 + default y if GRKERNSEC_CONFIG_AUTO
66239 + help
66240 + If you say Y here, non-root users will not be able to use dmesg(8)
66241 + to view the contents of the kernel's circular log buffer.
66242 + The kernel's log buffer often contains kernel addresses and other
66243 + identifying information useful to an attacker in fingerprinting a
66244 + system for a targeted exploit.
66245 + If the sysctl option is enabled, a sysctl option with name "dmesg" is
66246 + created.
66247 +
66248 +config GRKERNSEC_HARDEN_PTRACE
66249 + bool "Deter ptrace-based process snooping"
66250 + default y if GRKERNSEC_CONFIG_AUTO
66251 + help
66252 + If you say Y here, TTY sniffers and other malicious monitoring
66253 + programs implemented through ptrace will be defeated. If you
66254 + have been using the RBAC system, this option has already been
66255 + enabled for several years for all users, with the ability to make
66256 + fine-grained exceptions.
66257 +
66258 + This option only affects the ability of non-root users to ptrace
66259 + processes that are not a descendent of the ptracing process.
66260 + This means that strace ./binary and gdb ./binary will still work,
66261 + but attaching to arbitrary processes will not. If the sysctl
66262 + option is enabled, a sysctl option with name "harden_ptrace" is
66263 + created.
66264 +
66265 +config GRKERNSEC_PTRACE_READEXEC
66266 + bool "Require read access to ptrace sensitive binaries"
66267 + default y if GRKERNSEC_CONFIG_AUTO
66268 + help
66269 + If you say Y here, unprivileged users will not be able to ptrace unreadable
66270 + binaries. This option is useful in environments that
66271 + remove the read bits (e.g. file mode 4711) from suid binaries to
66272 + prevent infoleaking of their contents. This option adds
66273 + consistency to the use of that file mode, as the binary could normally
66274 + be read out when run without privileges while ptracing.
66275 +
66276 + If the sysctl option is enabled, a sysctl option with name "ptrace_readexec"
66277 + is created.
66278 +
66279 +config GRKERNSEC_SETXID
66280 + bool "Enforce consistent multithreaded privileges"
66281 + default y if GRKERNSEC_CONFIG_AUTO
66282 + depends on (X86 || SPARC64 || PPC || ARM || MIPS)
66283 + help
66284 + If you say Y here, a change from a root uid to a non-root uid
66285 + in a multithreaded application will cause the resulting uids,
66286 + gids, supplementary groups, and capabilities in that thread
66287 + to be propagated to the other threads of the process. In most
66288 + cases this is unnecessary, as glibc will emulate this behavior
66289 + on behalf of the application. Other libcs do not act in the
66290 + same way, allowing the other threads of the process to continue
66291 + running with root privileges. If the sysctl option is enabled,
66292 + a sysctl option with name "consistent_setxid" is created.
66293 +
66294 +config GRKERNSEC_HARDEN_IPC
66295 + bool "Disallow access to overly-permissive IPC objects"
66296 + default y if GRKERNSEC_CONFIG_AUTO
66297 + depends on SYSVIPC
66298 + help
66299 + If you say Y here, access to overly-permissive IPC objects (shared
66300 + memory, message queues, and semaphores) will be denied for processes
66301 + given the following criteria beyond normal permission checks:
66302 + 1) If the IPC object is world-accessible and the euid doesn't match
66303 + that of the creator or current uid for the IPC object
66304 + 2) If the IPC object is group-accessible and the egid doesn't
66305 + match that of the creator or current gid for the IPC object
66306 + It's a common error to grant too much permission to these objects,
66307 + with impact ranging from denial of service and information leaking to
66308 + privilege escalation. This feature was developed in response to
66309 + research by Tim Brown:
66310 + http://labs.portcullis.co.uk/whitepapers/memory-squatting-attacks-on-system-v-shared-memory/
66311 + who found hundreds of such insecure usages. Processes with
66312 + CAP_IPC_OWNER are still permitted to access these IPC objects.
66313 + If the sysctl option is enabled, a sysctl option with name
66314 + "harden_ipc" is created.
66315 +
66316 +config GRKERNSEC_TPE
66317 + bool "Trusted Path Execution (TPE)"
66318 + default y if GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER
66319 + help
66320 + If you say Y here, you will be able to choose a gid to add to the
66321 + supplementary groups of users you want to mark as "untrusted."
66322 + These users will not be able to execute any files that are not in
66323 + root-owned directories writable only by root. If the sysctl option
66324 + is enabled, a sysctl option with name "tpe" is created.
66325 +
66326 +config GRKERNSEC_TPE_ALL
66327 + bool "Partially restrict all non-root users"
66328 + depends on GRKERNSEC_TPE
66329 + help
66330 + If you say Y here, all non-root users will be covered under
66331 + a weaker TPE restriction. This is separate from, and in addition to,
66332 + the main TPE options that you have selected elsewhere. Thus, if a
66333 + "trusted" GID is chosen, this restriction applies to even that GID.
66334 + Under this restriction, all non-root users will only be allowed to
66335 + execute files in directories they own that are not group or
66336 + world-writable, or in directories owned by root and writable only by
66337 + root. If the sysctl option is enabled, a sysctl option with name
66338 + "tpe_restrict_all" is created.
66339 +
66340 +config GRKERNSEC_TPE_INVERT
66341 + bool "Invert GID option"
66342 + depends on GRKERNSEC_TPE
66343 + help
66344 + If you say Y here, the group you specify in the TPE configuration will
66345 + decide what group TPE restrictions will be *disabled* for. This
66346 + option is useful if you want TPE restrictions to be applied to most
66347 + users on the system. If the sysctl option is enabled, a sysctl option
66348 + with name "tpe_invert" is created. Unlike other sysctl options, this
66349 + entry will default to on for backward-compatibility.
66350 +
66351 +config GRKERNSEC_TPE_GID
66352 + int
66353 + default GRKERNSEC_TPE_UNTRUSTED_GID if (GRKERNSEC_TPE && !GRKERNSEC_TPE_INVERT)
66354 + default GRKERNSEC_TPE_TRUSTED_GID if (GRKERNSEC_TPE && GRKERNSEC_TPE_INVERT)
66355 +
66356 +config GRKERNSEC_TPE_UNTRUSTED_GID
66357 + int "GID for TPE-untrusted users"
66358 + depends on GRKERNSEC_TPE && !GRKERNSEC_TPE_INVERT
66359 + default 1005
66360 + help
66361 + Setting this GID determines what group TPE restrictions will be
66362 + *enabled* for. If the sysctl option is enabled, a sysctl option
66363 + with name "tpe_gid" is created.
66364 +
66365 +config GRKERNSEC_TPE_TRUSTED_GID
66366 + int "GID for TPE-trusted users"
66367 + depends on GRKERNSEC_TPE && GRKERNSEC_TPE_INVERT
66368 + default 1005
66369 + help
66370 + Setting this GID determines what group TPE restrictions will be
66371 + *disabled* for. If the sysctl option is enabled, a sysctl option
66372 + with name "tpe_gid" is created.
66373 +
66374 +endmenu
66375 +menu "Network Protections"
66376 +depends on GRKERNSEC
66377 +
66378 +config GRKERNSEC_RANDNET
66379 + bool "Larger entropy pools"
66380 + default y if GRKERNSEC_CONFIG_AUTO
66381 + help
66382 + If you say Y here, the entropy pools used for many features of Linux
66383 + and grsecurity will be doubled in size. Since several grsecurity
66384 + features use additional randomness, it is recommended that you say Y
66385 + here. Saying Y here has a similar effect as modifying
66386 + /proc/sys/kernel/random/poolsize.
66387 +
66388 +config GRKERNSEC_BLACKHOLE
66389 + bool "TCP/UDP blackhole and LAST_ACK DoS prevention"
66390 + default y if GRKERNSEC_CONFIG_AUTO
66391 + depends on NET
66392 + help
66393 + If you say Y here, neither TCP resets nor ICMP
66394 + destination-unreachable packets will be sent in response to packets
66395 + sent to ports for which no associated listening process exists.
66396 + This feature supports both IPV4 and IPV6 and exempts the
66397 + loopback interface from blackholing. Enabling this feature
66398 + makes a host more resilient to DoS attacks and reduces network
66399 + visibility against scanners.
66400 +
66401 + The blackhole feature as-implemented is equivalent to the FreeBSD
66402 + blackhole feature, as it prevents RST responses to all packets, not
66403 + just SYNs. Under most application behavior this causes no
66404 + problems, but applications (like haproxy) may not close certain
66405 + connections in a way that cleanly terminates them on the remote
66406 + end, leaving the remote host in LAST_ACK state. Because of this
66407 + side-effect and to prevent intentional LAST_ACK DoSes, this
66408 + feature also adds automatic mitigation against such attacks.
66409 + The mitigation drastically reduces the amount of time a socket
66410 + can spend in LAST_ACK state. If you're using haproxy and not
66411 + all servers it connects to have this option enabled, consider
66412 + disabling this feature on the haproxy host.
66413 +
66414 + If the sysctl option is enabled, two sysctl options with names
66415 + "ip_blackhole" and "lastack_retries" will be created.
66416 + While "ip_blackhole" takes the standard zero/non-zero on/off
66417 + toggle, "lastack_retries" uses the same kinds of values as
66418 + "tcp_retries1" and "tcp_retries2". The default value of 4
66419 + prevents a socket from lasting more than 45 seconds in LAST_ACK
66420 + state.
66421 +
66422 +config GRKERNSEC_NO_SIMULT_CONNECT
66423 + bool "Disable TCP Simultaneous Connect"
66424 + default y if GRKERNSEC_CONFIG_AUTO
66425 + depends on NET
66426 + help
66427 + If you say Y here, a feature by Willy Tarreau will be enabled that
66428 + removes a weakness in Linux's strict implementation of TCP that
66429 + allows two clients to connect to each other without either entering
66430 + a listening state. The weakness allows an attacker to easily prevent
66431 + a client from connecting to a known server provided the source port
66432 + for the connection is guessed correctly.
66433 +
66434 + As the weakness could be used to prevent an antivirus or IPS from
66435 + fetching updates, or prevent an SSL gateway from fetching a CRL,
66436 + it should be eliminated by enabling this option. Though Linux is
66437 + one of few operating systems supporting simultaneous connect, it
66438 + has no legitimate use in practice and is rarely supported by firewalls.
66439 +
66440 +config GRKERNSEC_SOCKET
66441 + bool "Socket restrictions"
66442 + depends on NET
66443 + help
66444 + If you say Y here, you will be able to choose from several options.
66445 + If you assign a GID on your system and add it to the supplementary
66446 + groups of users you want to restrict socket access to, this patch
66447 + will perform up to three things, based on the option(s) you choose.
66448 +
66449 +config GRKERNSEC_SOCKET_ALL
66450 + bool "Deny any sockets to group"
66451 + depends on GRKERNSEC_SOCKET
66452 + help
66453 + If you say Y here, you will be able to choose a GID of whose users will
66454 + be unable to connect to other hosts from your machine or run server
66455 + applications from your machine. If the sysctl option is enabled, a
66456 + sysctl option with name "socket_all" is created.
66457 +
66458 +config GRKERNSEC_SOCKET_ALL_GID
66459 + int "GID to deny all sockets for"
66460 + depends on GRKERNSEC_SOCKET_ALL
66461 + default 1004
66462 + help
66463 + Here you can choose the GID to disable socket access for. Remember to
66464 + add the users you want socket access disabled for to the GID
66465 + specified here. If the sysctl option is enabled, a sysctl option
66466 + with name "socket_all_gid" is created.
66467 +
66468 +config GRKERNSEC_SOCKET_CLIENT
66469 + bool "Deny client sockets to group"
66470 + depends on GRKERNSEC_SOCKET
66471 + help
66472 + If you say Y here, you will be able to choose a GID of whose users will
66473 + be unable to connect to other hosts from your machine, but will be
66474 + able to run servers. If this option is enabled, all users in the group
66475 + you specify will have to use passive mode when initiating ftp transfers
66476 + from the shell on your machine. If the sysctl option is enabled, a
66477 + sysctl option with name "socket_client" is created.
66478 +
66479 +config GRKERNSEC_SOCKET_CLIENT_GID
66480 + int "GID to deny client sockets for"
66481 + depends on GRKERNSEC_SOCKET_CLIENT
66482 + default 1003
66483 + help
66484 + Here you can choose the GID to disable client socket access for.
66485 + Remember to add the users you want client socket access disabled for to
66486 + the GID specified here. If the sysctl option is enabled, a sysctl
66487 + option with name "socket_client_gid" is created.
66488 +
66489 +config GRKERNSEC_SOCKET_SERVER
66490 + bool "Deny server sockets to group"
66491 + depends on GRKERNSEC_SOCKET
66492 + help
66493 + If you say Y here, you will be able to choose a GID of whose users will
66494 + be unable to run server applications from your machine. If the sysctl
66495 + option is enabled, a sysctl option with name "socket_server" is created.
66496 +
66497 +config GRKERNSEC_SOCKET_SERVER_GID
66498 + int "GID to deny server sockets for"
66499 + depends on GRKERNSEC_SOCKET_SERVER
66500 + default 1002
66501 + help
66502 + Here you can choose the GID to disable server socket access for.
66503 + Remember to add the users you want server socket access disabled for to
66504 + the GID specified here. If the sysctl option is enabled, a sysctl
66505 + option with name "socket_server_gid" is created.
66506 +
66507 +endmenu
66508 +
66509 +menu "Physical Protections"
66510 +depends on GRKERNSEC
66511 +
66512 +config GRKERNSEC_DENYUSB
66513 + bool "Deny new USB connections after toggle"
66514 + default y if GRKERNSEC_CONFIG_AUTO
66515 + depends on SYSCTL && USB_SUPPORT
66516 + help
66517 + If you say Y here, a new sysctl option with name "deny_new_usb"
66518 + will be created. Setting its value to 1 will prevent any new
66519 + USB devices from being recognized by the OS. Any attempted USB
66520 + device insertion will be logged. This option is intended to be
66521 + used against custom USB devices designed to exploit vulnerabilities
66522 + in various USB device drivers.
66523 +
66524 + For greatest effectiveness, this sysctl should be set after any
66525 + relevant init scripts. This option is safe to enable in distros
66526 + as each user can choose whether or not to toggle the sysctl.
66527 +
66528 +config GRKERNSEC_DENYUSB_FORCE
66529 + bool "Reject all USB devices not connected at boot"
66530 + select USB
66531 + depends on GRKERNSEC_DENYUSB
66532 + help
66533 + If you say Y here, a variant of GRKERNSEC_DENYUSB will be enabled
66534 + that doesn't involve a sysctl entry. This option should only be
66535 + enabled if you're sure you want to deny all new USB connections
66536 + at runtime and don't want to modify init scripts. This should not
66537 + be enabled by distros. It forces the core USB code to be built
66538 + into the kernel image so that all devices connected at boot time
66539 + can be recognized and new USB device connections can be prevented
66540 + prior to init running.
66541 +
66542 +endmenu
66543 +
66544 +menu "Sysctl Support"
66545 +depends on GRKERNSEC && SYSCTL
66546 +
66547 +config GRKERNSEC_SYSCTL
66548 + bool "Sysctl support"
66549 + default y if GRKERNSEC_CONFIG_AUTO
66550 + help
66551 + If you say Y here, you will be able to change the options that
66552 + grsecurity runs with at bootup, without having to recompile your
66553 + kernel. You can echo values to files in /proc/sys/kernel/grsecurity
66554 + to enable (1) or disable (0) various features. All the sysctl entries
66555 + are mutable until the "grsec_lock" entry is set to a non-zero value.
66556 + All features enabled in the kernel configuration are disabled at boot
66557 + if you do not say Y to the "Turn on features by default" option.
66558 + All options should be set at startup, and the grsec_lock entry should
66559 + be set to a non-zero value after all the options are set.
66560 + *THIS IS EXTREMELY IMPORTANT*
66561 +
66562 +config GRKERNSEC_SYSCTL_DISTRO
66563 + bool "Extra sysctl support for distro makers (READ HELP)"
66564 + depends on GRKERNSEC_SYSCTL && GRKERNSEC_IO
66565 + help
66566 + If you say Y here, additional sysctl options will be created
66567 + for features that affect processes running as root. Therefore,
66568 + it is critical when using this option that the grsec_lock entry be
66569 + enabled after boot. Only distros with prebuilt kernel packages
66570 + with this option enabled that can ensure grsec_lock is enabled
66571 + after boot should use this option.
66572 + *Failure to set grsec_lock after boot makes all grsec features
66573 + this option covers useless*
66574 +
66575 + Currently this option creates the following sysctl entries:
66576 + "Disable Privileged I/O": "disable_priv_io"
66577 +
66578 +config GRKERNSEC_SYSCTL_ON
66579 + bool "Turn on features by default"
66580 + default y if GRKERNSEC_CONFIG_AUTO
66581 + depends on GRKERNSEC_SYSCTL
66582 + help
66583 + If you say Y here, instead of having all features enabled in the
66584 + kernel configuration disabled at boot time, the features will be
66585 + enabled at boot time. It is recommended you say Y here unless
66586 + there is some reason you would want all sysctl-tunable features to
66587 + be disabled by default. As mentioned elsewhere, it is important
66588 + to enable the grsec_lock entry once you have finished modifying
66589 + the sysctl entries.
66590 +
66591 +endmenu
66592 +menu "Logging Options"
66593 +depends on GRKERNSEC
66594 +
66595 +config GRKERNSEC_FLOODTIME
66596 + int "Seconds in between log messages (minimum)"
66597 + default 10
66598 + help
66599 + This option allows you to enforce the number of seconds between
66600 + grsecurity log messages. The default should be suitable for most
66601 + people, however, if you choose to change it, choose a value small enough
66602 + to allow informative logs to be produced, but large enough to
66603 + prevent flooding.
66604 +
66605 + Setting both this value and GRKERNSEC_FLOODBURST to 0 will disable
66606 + any rate limiting on grsecurity log messages.
66607 +
66608 +config GRKERNSEC_FLOODBURST
66609 + int "Number of messages in a burst (maximum)"
66610 + default 6
66611 + help
66612 + This option allows you to choose the maximum number of messages allowed
66613 + within the flood time interval you chose in a separate option. The
66614 + default should be suitable for most people, however if you find that
66615 + many of your logs are being interpreted as flooding, you may want to
66616 + raise this value.
66617 +
66618 + Setting both this value and GRKERNSEC_FLOODTIME to 0 will disable
66619 + any rate limiting on grsecurity log messages.
66620 +
66621 +endmenu
66622 diff --git a/grsecurity/Makefile b/grsecurity/Makefile
66623 new file mode 100644
66624 index 0000000..30ababb
66625 --- /dev/null
66626 +++ b/grsecurity/Makefile
66627 @@ -0,0 +1,54 @@
66628 +# grsecurity – access control and security hardening for Linux
66629 +# All code in this directory and various hooks located throughout the Linux kernel are
66630 +# Copyright (C) 2001-2014 Bradley Spengler, Open Source Security, Inc.
66631 +# http://www.grsecurity.net spender@grsecurity.net
66632 +#
66633 +# This program is free software; you can redistribute it and/or
66634 +# modify it under the terms of the GNU General Public License version 2
66635 +# as published by the Free Software Foundation.
66636 +#
66637 +# This program is distributed in the hope that it will be useful,
66638 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
66639 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
66640 +# GNU General Public License for more details.
66641 +#
66642 +# You should have received a copy of the GNU General Public License
66643 +# along with this program; if not, write to the Free Software
66644 +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
66645 +
66646 +KBUILD_CFLAGS += -Werror
66647 +
66648 +obj-y = grsec_chdir.o grsec_chroot.o grsec_exec.o grsec_fifo.o grsec_fork.o \
66649 + grsec_mount.o grsec_sig.o grsec_sysctl.o \
66650 + grsec_time.o grsec_tpe.o grsec_link.o grsec_pax.o grsec_ptrace.o \
66651 + grsec_usb.o grsec_ipc.o grsec_proc.o
66652 +
66653 +obj-$(CONFIG_GRKERNSEC) += grsec_init.o grsum.o gracl.o gracl_segv.o \
66654 + gracl_cap.o gracl_alloc.o gracl_shm.o grsec_mem.o gracl_fs.o \
66655 + gracl_learn.o grsec_log.o gracl_policy.o
66656 +ifdef CONFIG_COMPAT
66657 +obj-$(CONFIG_GRKERNSEC) += gracl_compat.o
66658 +endif
66659 +
66660 +obj-$(CONFIG_GRKERNSEC_RESLOG) += gracl_res.o
66661 +
66662 +ifdef CONFIG_NET
66663 +obj-y += grsec_sock.o
66664 +obj-$(CONFIG_GRKERNSEC) += gracl_ip.o
66665 +endif
66666 +
66667 +ifndef CONFIG_GRKERNSEC
66668 +obj-y += grsec_disabled.o
66669 +endif
66670 +
66671 +ifdef CONFIG_GRKERNSEC_HIDESYM
66672 +extra-y := grsec_hidesym.o
66673 +$(obj)/grsec_hidesym.o:
66674 + @-chmod -f 500 /boot
66675 + @-chmod -f 500 /lib/modules
66676 + @-chmod -f 500 /lib64/modules
66677 + @-chmod -f 500 /lib32/modules
66678 + @-chmod -f 700 .
66679 + @-chmod -f 700 $(objtree)
66680 + @echo ' grsec: protected kernel image paths'
66681 +endif
66682 diff --git a/grsecurity/gracl.c b/grsecurity/gracl.c
66683 new file mode 100644
66684 index 0000000..58223f6
66685 --- /dev/null
66686 +++ b/grsecurity/gracl.c
66687 @@ -0,0 +1,2702 @@
66688 +#include <linux/kernel.h>
66689 +#include <linux/module.h>
66690 +#include <linux/sched.h>
66691 +#include <linux/mm.h>
66692 +#include <linux/file.h>
66693 +#include <linux/fs.h>
66694 +#include <linux/namei.h>
66695 +#include <linux/mount.h>
66696 +#include <linux/tty.h>
66697 +#include <linux/proc_fs.h>
66698 +#include <linux/lglock.h>
66699 +#include <linux/slab.h>
66700 +#include <linux/vmalloc.h>
66701 +#include <linux/types.h>
66702 +#include <linux/sysctl.h>
66703 +#include <linux/netdevice.h>
66704 +#include <linux/ptrace.h>
66705 +#include <linux/gracl.h>
66706 +#include <linux/gralloc.h>
66707 +#include <linux/security.h>
66708 +#include <linux/grinternal.h>
66709 +#include <linux/pid_namespace.h>
66710 +#include <linux/stop_machine.h>
66711 +#include <linux/fdtable.h>
66712 +#include <linux/percpu.h>
66713 +#include <linux/lglock.h>
66714 +#include <linux/hugetlb.h>
66715 +#include <linux/posix-timers.h>
66716 +#include <linux/prefetch.h>
66717 +#if defined(CONFIG_BTRFS_FS) || defined(CONFIG_BTRFS_FS_MODULE)
66718 +#include <linux/magic.h>
66719 +#include <linux/pagemap.h>
66720 +#include "../fs/btrfs/async-thread.h"
66721 +#include "../fs/btrfs/ctree.h"
66722 +#include "../fs/btrfs/btrfs_inode.h"
66723 +#endif
66724 +#include "../fs/mount.h"
66725 +
66726 +#include <asm/uaccess.h>
66727 +#include <asm/errno.h>
66728 +#include <asm/mman.h>
66729 +
66730 +#define FOR_EACH_ROLE_START(role) \
66731 + role = running_polstate.role_list; \
66732 + while (role) {
66733 +
66734 +#define FOR_EACH_ROLE_END(role) \
66735 + role = role->prev; \
66736 + }
66737 +
66738 +extern struct path gr_real_root;
66739 +
66740 +static struct gr_policy_state running_polstate;
66741 +struct gr_policy_state *polstate = &running_polstate;
66742 +extern struct gr_alloc_state *current_alloc_state;
66743 +
66744 +extern char *gr_shared_page[4];
66745 +DEFINE_RWLOCK(gr_inode_lock);
66746 +
66747 +static unsigned int gr_status __read_only = GR_STATUS_INIT;
66748 +
66749 +#ifdef CONFIG_NET
66750 +extern struct vfsmount *sock_mnt;
66751 +#endif
66752 +
66753 +extern struct vfsmount *pipe_mnt;
66754 +extern struct vfsmount *shm_mnt;
66755 +
66756 +#ifdef CONFIG_HUGETLBFS
66757 +extern struct vfsmount *hugetlbfs_vfsmount[HUGE_MAX_HSTATE];
66758 +#endif
66759 +
66760 +extern u16 acl_sp_role_value;
66761 +extern struct acl_object_label *fakefs_obj_rw;
66762 +extern struct acl_object_label *fakefs_obj_rwx;
66763 +
66764 +int gr_acl_is_enabled(void)
66765 +{
66766 + return (gr_status & GR_READY);
66767 +}
66768 +
66769 +void gr_enable_rbac_system(void)
66770 +{
66771 + pax_open_kernel();
66772 + gr_status |= GR_READY;
66773 + pax_close_kernel();
66774 +}
66775 +
66776 +int gr_rbac_disable(void *unused)
66777 +{
66778 + pax_open_kernel();
66779 + gr_status &= ~GR_READY;
66780 + pax_close_kernel();
66781 +
66782 + return 0;
66783 +}
66784 +
66785 +static inline dev_t __get_dev(const struct dentry *dentry)
66786 +{
66787 +#if defined(CONFIG_BTRFS_FS) || defined(CONFIG_BTRFS_FS_MODULE)
66788 + if (dentry->d_sb->s_magic == BTRFS_SUPER_MAGIC)
66789 + return BTRFS_I(dentry->d_inode)->root->anon_dev;
66790 + else
66791 +#endif
66792 + return dentry->d_sb->s_dev;
66793 +}
66794 +
66795 +dev_t gr_get_dev_from_dentry(struct dentry *dentry)
66796 +{
66797 + return __get_dev(dentry);
66798 +}
66799 +
66800 +static char gr_task_roletype_to_char(struct task_struct *task)
66801 +{
66802 + switch (task->role->roletype &
66803 + (GR_ROLE_DEFAULT | GR_ROLE_USER | GR_ROLE_GROUP |
66804 + GR_ROLE_SPECIAL)) {
66805 + case GR_ROLE_DEFAULT:
66806 + return 'D';
66807 + case GR_ROLE_USER:
66808 + return 'U';
66809 + case GR_ROLE_GROUP:
66810 + return 'G';
66811 + case GR_ROLE_SPECIAL:
66812 + return 'S';
66813 + }
66814 +
66815 + return 'X';
66816 +}
66817 +
66818 +char gr_roletype_to_char(void)
66819 +{
66820 + return gr_task_roletype_to_char(current);
66821 +}
66822 +
66823 +__inline__ int
66824 +gr_acl_tpe_check(void)
66825 +{
66826 + if (unlikely(!(gr_status & GR_READY)))
66827 + return 0;
66828 + if (current->role->roletype & GR_ROLE_TPE)
66829 + return 1;
66830 + else
66831 + return 0;
66832 +}
66833 +
66834 +int
66835 +gr_handle_rawio(const struct inode *inode)
66836 +{
66837 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
66838 + if (inode && (S_ISBLK(inode->i_mode) || (S_ISCHR(inode->i_mode) && imajor(inode) == RAW_MAJOR)) &&
66839 + grsec_enable_chroot_caps && proc_is_chrooted(current) &&
66840 + !capable(CAP_SYS_RAWIO))
66841 + return 1;
66842 +#endif
66843 + return 0;
66844 +}
66845 +
66846 +int
66847 +gr_streq(const char *a, const char *b, const unsigned int lena, const unsigned int lenb)
66848 +{
66849 + if (likely(lena != lenb))
66850 + return 0;
66851 +
66852 + return !memcmp(a, b, lena);
66853 +}
66854 +
66855 +static int prepend(char **buffer, int *buflen, const char *str, int namelen)
66856 +{
66857 + *buflen -= namelen;
66858 + if (*buflen < 0)
66859 + return -ENAMETOOLONG;
66860 + *buffer -= namelen;
66861 + memcpy(*buffer, str, namelen);
66862 + return 0;
66863 +}
66864 +
66865 +static int prepend_name(char **buffer, int *buflen, struct qstr *name)
66866 +{
66867 + return prepend(buffer, buflen, name->name, name->len);
66868 +}
66869 +
66870 +static int prepend_path(const struct path *path, struct path *root,
66871 + char **buffer, int *buflen)
66872 +{
66873 + struct dentry *dentry = path->dentry;
66874 + struct vfsmount *vfsmnt = path->mnt;
66875 + struct mount *mnt = real_mount(vfsmnt);
66876 + bool slash = false;
66877 + int error = 0;
66878 +
66879 + while (dentry != root->dentry || vfsmnt != root->mnt) {
66880 + struct dentry * parent;
66881 +
66882 + if (dentry == vfsmnt->mnt_root || IS_ROOT(dentry)) {
66883 + /* Global root? */
66884 + if (!mnt_has_parent(mnt)) {
66885 + goto out;
66886 + }
66887 + dentry = mnt->mnt_mountpoint;
66888 + mnt = mnt->mnt_parent;
66889 + vfsmnt = &mnt->mnt;
66890 + continue;
66891 + }
66892 + parent = dentry->d_parent;
66893 + prefetch(parent);
66894 + spin_lock(&dentry->d_lock);
66895 + error = prepend_name(buffer, buflen, &dentry->d_name);
66896 + spin_unlock(&dentry->d_lock);
66897 + if (!error)
66898 + error = prepend(buffer, buflen, "/", 1);
66899 + if (error)
66900 + break;
66901 +
66902 + slash = true;
66903 + dentry = parent;
66904 + }
66905 +
66906 +out:
66907 + if (!error && !slash)
66908 + error = prepend(buffer, buflen, "/", 1);
66909 +
66910 + return error;
66911 +}
66912 +
66913 +/* this must be called with mount_lock and rename_lock held */
66914 +
66915 +static char *__our_d_path(const struct path *path, struct path *root,
66916 + char *buf, int buflen)
66917 +{
66918 + char *res = buf + buflen;
66919 + int error;
66920 +
66921 + prepend(&res, &buflen, "\0", 1);
66922 + error = prepend_path(path, root, &res, &buflen);
66923 + if (error)
66924 + return ERR_PTR(error);
66925 +
66926 + return res;
66927 +}
66928 +
66929 +static char *
66930 +gen_full_path(struct path *path, struct path *root, char *buf, int buflen)
66931 +{
66932 + char *retval;
66933 +
66934 + retval = __our_d_path(path, root, buf, buflen);
66935 + if (unlikely(IS_ERR(retval)))
66936 + retval = strcpy(buf, "<path too long>");
66937 + else if (unlikely(retval[1] == '/' && retval[2] == '\0'))
66938 + retval[1] = '\0';
66939 +
66940 + return retval;
66941 +}
66942 +
66943 +static char *
66944 +__d_real_path(const struct dentry *dentry, const struct vfsmount *vfsmnt,
66945 + char *buf, int buflen)
66946 +{
66947 + struct path path;
66948 + char *res;
66949 +
66950 + path.dentry = (struct dentry *)dentry;
66951 + path.mnt = (struct vfsmount *)vfsmnt;
66952 +
66953 + /* we can use gr_real_root.dentry, gr_real_root.mnt, because this is only called
66954 + by the RBAC system */
66955 + res = gen_full_path(&path, &gr_real_root, buf, buflen);
66956 +
66957 + return res;
66958 +}
66959 +
66960 +static char *
66961 +d_real_path(const struct dentry *dentry, const struct vfsmount *vfsmnt,
66962 + char *buf, int buflen)
66963 +{
66964 + char *res;
66965 + struct path path;
66966 + struct path root;
66967 + struct task_struct *reaper = init_pid_ns.child_reaper;
66968 +
66969 + path.dentry = (struct dentry *)dentry;
66970 + path.mnt = (struct vfsmount *)vfsmnt;
66971 +
66972 + /* we can't use gr_real_root.dentry, gr_real_root.mnt, because they belong only to the RBAC system */
66973 + get_fs_root(reaper->fs, &root);
66974 +
66975 + read_seqlock_excl(&mount_lock);
66976 + write_seqlock(&rename_lock);
66977 + res = gen_full_path(&path, &root, buf, buflen);
66978 + write_sequnlock(&rename_lock);
66979 + read_sequnlock_excl(&mount_lock);
66980 +
66981 + path_put(&root);
66982 + return res;
66983 +}
66984 +
66985 +char *
66986 +gr_to_filename_rbac(const struct dentry *dentry, const struct vfsmount *mnt)
66987 +{
66988 + char *ret;
66989 + read_seqlock_excl(&mount_lock);
66990 + write_seqlock(&rename_lock);
66991 + ret = __d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0],smp_processor_id()),
66992 + PAGE_SIZE);
66993 + write_sequnlock(&rename_lock);
66994 + read_sequnlock_excl(&mount_lock);
66995 + return ret;
66996 +}
66997 +
66998 +static char *
66999 +gr_to_proc_filename_rbac(const struct dentry *dentry, const struct vfsmount *mnt)
67000 +{
67001 + char *ret;
67002 + char *buf;
67003 + int buflen;
67004 +
67005 + read_seqlock_excl(&mount_lock);
67006 + write_seqlock(&rename_lock);
67007 + buf = per_cpu_ptr(gr_shared_page[0], smp_processor_id());
67008 + ret = __d_real_path(dentry, mnt, buf, PAGE_SIZE - 6);
67009 + buflen = (int)(ret - buf);
67010 + if (buflen >= 5)
67011 + prepend(&ret, &buflen, "/proc", 5);
67012 + else
67013 + ret = strcpy(buf, "<path too long>");
67014 + write_sequnlock(&rename_lock);
67015 + read_sequnlock_excl(&mount_lock);
67016 + return ret;
67017 +}
67018 +
67019 +char *
67020 +gr_to_filename_nolock(const struct dentry *dentry, const struct vfsmount *mnt)
67021 +{
67022 + return __d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0],smp_processor_id()),
67023 + PAGE_SIZE);
67024 +}
67025 +
67026 +char *
67027 +gr_to_filename(const struct dentry *dentry, const struct vfsmount *mnt)
67028 +{
67029 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0], smp_processor_id()),
67030 + PAGE_SIZE);
67031 +}
67032 +
67033 +char *
67034 +gr_to_filename1(const struct dentry *dentry, const struct vfsmount *mnt)
67035 +{
67036 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[1], smp_processor_id()),
67037 + PAGE_SIZE);
67038 +}
67039 +
67040 +char *
67041 +gr_to_filename2(const struct dentry *dentry, const struct vfsmount *mnt)
67042 +{
67043 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[2], smp_processor_id()),
67044 + PAGE_SIZE);
67045 +}
67046 +
67047 +char *
67048 +gr_to_filename3(const struct dentry *dentry, const struct vfsmount *mnt)
67049 +{
67050 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[3], smp_processor_id()),
67051 + PAGE_SIZE);
67052 +}
67053 +
67054 +__inline__ __u32
67055 +to_gr_audit(const __u32 reqmode)
67056 +{
67057 + /* masks off auditable permission flags, then shifts them to create
67058 + auditing flags, and adds the special case of append auditing if
67059 + we're requesting write */
67060 + return (((reqmode & ~GR_AUDITS) << 10) | ((reqmode & GR_WRITE) ? GR_AUDIT_APPEND : 0));
67061 +}
67062 +
67063 +struct acl_role_label *
67064 +__lookup_acl_role_label(const struct gr_policy_state *state, const struct task_struct *task, const uid_t uid,
67065 + const gid_t gid)
67066 +{
67067 + unsigned int index = gr_rhash(uid, GR_ROLE_USER, state->acl_role_set.r_size);
67068 + struct acl_role_label *match;
67069 + struct role_allowed_ip *ipp;
67070 + unsigned int x;
67071 + u32 curr_ip = task->signal->saved_ip;
67072 +
67073 + match = state->acl_role_set.r_hash[index];
67074 +
67075 + while (match) {
67076 + if ((match->roletype & (GR_ROLE_DOMAIN | GR_ROLE_USER)) == (GR_ROLE_DOMAIN | GR_ROLE_USER)) {
67077 + for (x = 0; x < match->domain_child_num; x++) {
67078 + if (match->domain_children[x] == uid)
67079 + goto found;
67080 + }
67081 + } else if (match->uidgid == uid && match->roletype & GR_ROLE_USER)
67082 + break;
67083 + match = match->next;
67084 + }
67085 +found:
67086 + if (match == NULL) {
67087 + try_group:
67088 + index = gr_rhash(gid, GR_ROLE_GROUP, state->acl_role_set.r_size);
67089 + match = state->acl_role_set.r_hash[index];
67090 +
67091 + while (match) {
67092 + if ((match->roletype & (GR_ROLE_DOMAIN | GR_ROLE_GROUP)) == (GR_ROLE_DOMAIN | GR_ROLE_GROUP)) {
67093 + for (x = 0; x < match->domain_child_num; x++) {
67094 + if (match->domain_children[x] == gid)
67095 + goto found2;
67096 + }
67097 + } else if (match->uidgid == gid && match->roletype & GR_ROLE_GROUP)
67098 + break;
67099 + match = match->next;
67100 + }
67101 +found2:
67102 + if (match == NULL)
67103 + match = state->default_role;
67104 + if (match->allowed_ips == NULL)
67105 + return match;
67106 + else {
67107 + for (ipp = match->allowed_ips; ipp; ipp = ipp->next) {
67108 + if (likely
67109 + ((ntohl(curr_ip) & ipp->netmask) ==
67110 + (ntohl(ipp->addr) & ipp->netmask)))
67111 + return match;
67112 + }
67113 + match = state->default_role;
67114 + }
67115 + } else if (match->allowed_ips == NULL) {
67116 + return match;
67117 + } else {
67118 + for (ipp = match->allowed_ips; ipp; ipp = ipp->next) {
67119 + if (likely
67120 + ((ntohl(curr_ip) & ipp->netmask) ==
67121 + (ntohl(ipp->addr) & ipp->netmask)))
67122 + return match;
67123 + }
67124 + goto try_group;
67125 + }
67126 +
67127 + return match;
67128 +}
67129 +
67130 +static struct acl_role_label *
67131 +lookup_acl_role_label(const struct task_struct *task, const uid_t uid,
67132 + const gid_t gid)
67133 +{
67134 + return __lookup_acl_role_label(&running_polstate, task, uid, gid);
67135 +}
67136 +
67137 +struct acl_subject_label *
67138 +lookup_acl_subj_label(const ino_t ino, const dev_t dev,
67139 + const struct acl_role_label *role)
67140 +{
67141 + unsigned int index = gr_fhash(ino, dev, role->subj_hash_size);
67142 + struct acl_subject_label *match;
67143 +
67144 + match = role->subj_hash[index];
67145 +
67146 + while (match && (match->inode != ino || match->device != dev ||
67147 + (match->mode & GR_DELETED))) {
67148 + match = match->next;
67149 + }
67150 +
67151 + if (match && !(match->mode & GR_DELETED))
67152 + return match;
67153 + else
67154 + return NULL;
67155 +}
67156 +
67157 +struct acl_subject_label *
67158 +lookup_acl_subj_label_deleted(const ino_t ino, const dev_t dev,
67159 + const struct acl_role_label *role)
67160 +{
67161 + unsigned int index = gr_fhash(ino, dev, role->subj_hash_size);
67162 + struct acl_subject_label *match;
67163 +
67164 + match = role->subj_hash[index];
67165 +
67166 + while (match && (match->inode != ino || match->device != dev ||
67167 + !(match->mode & GR_DELETED))) {
67168 + match = match->next;
67169 + }
67170 +
67171 + if (match && (match->mode & GR_DELETED))
67172 + return match;
67173 + else
67174 + return NULL;
67175 +}
67176 +
67177 +static struct acl_object_label *
67178 +lookup_acl_obj_label(const ino_t ino, const dev_t dev,
67179 + const struct acl_subject_label *subj)
67180 +{
67181 + unsigned int index = gr_fhash(ino, dev, subj->obj_hash_size);
67182 + struct acl_object_label *match;
67183 +
67184 + match = subj->obj_hash[index];
67185 +
67186 + while (match && (match->inode != ino || match->device != dev ||
67187 + (match->mode & GR_DELETED))) {
67188 + match = match->next;
67189 + }
67190 +
67191 + if (match && !(match->mode & GR_DELETED))
67192 + return match;
67193 + else
67194 + return NULL;
67195 +}
67196 +
67197 +static struct acl_object_label *
67198 +lookup_acl_obj_label_create(const ino_t ino, const dev_t dev,
67199 + const struct acl_subject_label *subj)
67200 +{
67201 + unsigned int index = gr_fhash(ino, dev, subj->obj_hash_size);
67202 + struct acl_object_label *match;
67203 +
67204 + match = subj->obj_hash[index];
67205 +
67206 + while (match && (match->inode != ino || match->device != dev ||
67207 + !(match->mode & GR_DELETED))) {
67208 + match = match->next;
67209 + }
67210 +
67211 + if (match && (match->mode & GR_DELETED))
67212 + return match;
67213 +
67214 + match = subj->obj_hash[index];
67215 +
67216 + while (match && (match->inode != ino || match->device != dev ||
67217 + (match->mode & GR_DELETED))) {
67218 + match = match->next;
67219 + }
67220 +
67221 + if (match && !(match->mode & GR_DELETED))
67222 + return match;
67223 + else
67224 + return NULL;
67225 +}
67226 +
67227 +struct name_entry *
67228 +__lookup_name_entry(const struct gr_policy_state *state, const char *name)
67229 +{
67230 + unsigned int len = strlen(name);
67231 + unsigned int key = full_name_hash(name, len);
67232 + unsigned int index = key % state->name_set.n_size;
67233 + struct name_entry *match;
67234 +
67235 + match = state->name_set.n_hash[index];
67236 +
67237 + while (match && (match->key != key || !gr_streq(match->name, name, match->len, len)))
67238 + match = match->next;
67239 +
67240 + return match;
67241 +}
67242 +
67243 +static struct name_entry *
67244 +lookup_name_entry(const char *name)
67245 +{
67246 + return __lookup_name_entry(&running_polstate, name);
67247 +}
67248 +
67249 +static struct name_entry *
67250 +lookup_name_entry_create(const char *name)
67251 +{
67252 + unsigned int len = strlen(name);
67253 + unsigned int key = full_name_hash(name, len);
67254 + unsigned int index = key % running_polstate.name_set.n_size;
67255 + struct name_entry *match;
67256 +
67257 + match = running_polstate.name_set.n_hash[index];
67258 +
67259 + while (match && (match->key != key || !gr_streq(match->name, name, match->len, len) ||
67260 + !match->deleted))
67261 + match = match->next;
67262 +
67263 + if (match && match->deleted)
67264 + return match;
67265 +
67266 + match = running_polstate.name_set.n_hash[index];
67267 +
67268 + while (match && (match->key != key || !gr_streq(match->name, name, match->len, len) ||
67269 + match->deleted))
67270 + match = match->next;
67271 +
67272 + if (match && !match->deleted)
67273 + return match;
67274 + else
67275 + return NULL;
67276 +}
67277 +
67278 +static struct inodev_entry *
67279 +lookup_inodev_entry(const ino_t ino, const dev_t dev)
67280 +{
67281 + unsigned int index = gr_fhash(ino, dev, running_polstate.inodev_set.i_size);
67282 + struct inodev_entry *match;
67283 +
67284 + match = running_polstate.inodev_set.i_hash[index];
67285 +
67286 + while (match && (match->nentry->inode != ino || match->nentry->device != dev))
67287 + match = match->next;
67288 +
67289 + return match;
67290 +}
67291 +
67292 +void
67293 +__insert_inodev_entry(const struct gr_policy_state *state, struct inodev_entry *entry)
67294 +{
67295 + unsigned int index = gr_fhash(entry->nentry->inode, entry->nentry->device,
67296 + state->inodev_set.i_size);
67297 + struct inodev_entry **curr;
67298 +
67299 + entry->prev = NULL;
67300 +
67301 + curr = &state->inodev_set.i_hash[index];
67302 + if (*curr != NULL)
67303 + (*curr)->prev = entry;
67304 +
67305 + entry->next = *curr;
67306 + *curr = entry;
67307 +
67308 + return;
67309 +}
67310 +
67311 +static void
67312 +insert_inodev_entry(struct inodev_entry *entry)
67313 +{
67314 + __insert_inodev_entry(&running_polstate, entry);
67315 +}
67316 +
67317 +void
67318 +insert_acl_obj_label(struct acl_object_label *obj,
67319 + struct acl_subject_label *subj)
67320 +{
67321 + unsigned int index =
67322 + gr_fhash(obj->inode, obj->device, subj->obj_hash_size);
67323 + struct acl_object_label **curr;
67324 +
67325 + obj->prev = NULL;
67326 +
67327 + curr = &subj->obj_hash[index];
67328 + if (*curr != NULL)
67329 + (*curr)->prev = obj;
67330 +
67331 + obj->next = *curr;
67332 + *curr = obj;
67333 +
67334 + return;
67335 +}
67336 +
67337 +void
67338 +insert_acl_subj_label(struct acl_subject_label *obj,
67339 + struct acl_role_label *role)
67340 +{
67341 + unsigned int index = gr_fhash(obj->inode, obj->device, role->subj_hash_size);
67342 + struct acl_subject_label **curr;
67343 +
67344 + obj->prev = NULL;
67345 +
67346 + curr = &role->subj_hash[index];
67347 + if (*curr != NULL)
67348 + (*curr)->prev = obj;
67349 +
67350 + obj->next = *curr;
67351 + *curr = obj;
67352 +
67353 + return;
67354 +}
67355 +
67356 +/* derived from glibc fnmatch() 0: match, 1: no match*/
67357 +
67358 +static int
67359 +glob_match(const char *p, const char *n)
67360 +{
67361 + char c;
67362 +
67363 + while ((c = *p++) != '\0') {
67364 + switch (c) {
67365 + case '?':
67366 + if (*n == '\0')
67367 + return 1;
67368 + else if (*n == '/')
67369 + return 1;
67370 + break;
67371 + case '\\':
67372 + if (*n != c)
67373 + return 1;
67374 + break;
67375 + case '*':
67376 + for (c = *p++; c == '?' || c == '*'; c = *p++) {
67377 + if (*n == '/')
67378 + return 1;
67379 + else if (c == '?') {
67380 + if (*n == '\0')
67381 + return 1;
67382 + else
67383 + ++n;
67384 + }
67385 + }
67386 + if (c == '\0') {
67387 + return 0;
67388 + } else {
67389 + const char *endp;
67390 +
67391 + if ((endp = strchr(n, '/')) == NULL)
67392 + endp = n + strlen(n);
67393 +
67394 + if (c == '[') {
67395 + for (--p; n < endp; ++n)
67396 + if (!glob_match(p, n))
67397 + return 0;
67398 + } else if (c == '/') {
67399 + while (*n != '\0' && *n != '/')
67400 + ++n;
67401 + if (*n == '/' && !glob_match(p, n + 1))
67402 + return 0;
67403 + } else {
67404 + for (--p; n < endp; ++n)
67405 + if (*n == c && !glob_match(p, n))
67406 + return 0;
67407 + }
67408 +
67409 + return 1;
67410 + }
67411 + case '[':
67412 + {
67413 + int not;
67414 + char cold;
67415 +
67416 + if (*n == '\0' || *n == '/')
67417 + return 1;
67418 +
67419 + not = (*p == '!' || *p == '^');
67420 + if (not)
67421 + ++p;
67422 +
67423 + c = *p++;
67424 + for (;;) {
67425 + unsigned char fn = (unsigned char)*n;
67426 +
67427 + if (c == '\0')
67428 + return 1;
67429 + else {
67430 + if (c == fn)
67431 + goto matched;
67432 + cold = c;
67433 + c = *p++;
67434 +
67435 + if (c == '-' && *p != ']') {
67436 + unsigned char cend = *p++;
67437 +
67438 + if (cend == '\0')
67439 + return 1;
67440 +
67441 + if (cold <= fn && fn <= cend)
67442 + goto matched;
67443 +
67444 + c = *p++;
67445 + }
67446 + }
67447 +
67448 + if (c == ']')
67449 + break;
67450 + }
67451 + if (!not)
67452 + return 1;
67453 + break;
67454 + matched:
67455 + while (c != ']') {
67456 + if (c == '\0')
67457 + return 1;
67458 +
67459 + c = *p++;
67460 + }
67461 + if (not)
67462 + return 1;
67463 + }
67464 + break;
67465 + default:
67466 + if (c != *n)
67467 + return 1;
67468 + }
67469 +
67470 + ++n;
67471 + }
67472 +
67473 + if (*n == '\0')
67474 + return 0;
67475 +
67476 + if (*n == '/')
67477 + return 0;
67478 +
67479 + return 1;
67480 +}
67481 +
67482 +static struct acl_object_label *
67483 +chk_glob_label(struct acl_object_label *globbed,
67484 + const struct dentry *dentry, const struct vfsmount *mnt, char **path)
67485 +{
67486 + struct acl_object_label *tmp;
67487 +
67488 + if (*path == NULL)
67489 + *path = gr_to_filename_nolock(dentry, mnt);
67490 +
67491 + tmp = globbed;
67492 +
67493 + while (tmp) {
67494 + if (!glob_match(tmp->filename, *path))
67495 + return tmp;
67496 + tmp = tmp->next;
67497 + }
67498 +
67499 + return NULL;
67500 +}
67501 +
67502 +static struct acl_object_label *
67503 +__full_lookup(const struct dentry *orig_dentry, const struct vfsmount *orig_mnt,
67504 + const ino_t curr_ino, const dev_t curr_dev,
67505 + const struct acl_subject_label *subj, char **path, const int checkglob)
67506 +{
67507 + struct acl_subject_label *tmpsubj;
67508 + struct acl_object_label *retval;
67509 + struct acl_object_label *retval2;
67510 +
67511 + tmpsubj = (struct acl_subject_label *) subj;
67512 + read_lock(&gr_inode_lock);
67513 + do {
67514 + retval = lookup_acl_obj_label(curr_ino, curr_dev, tmpsubj);
67515 + if (retval) {
67516 + if (checkglob && retval->globbed) {
67517 + retval2 = chk_glob_label(retval->globbed, orig_dentry, orig_mnt, path);
67518 + if (retval2)
67519 + retval = retval2;
67520 + }
67521 + break;
67522 + }
67523 + } while ((tmpsubj = tmpsubj->parent_subject));
67524 + read_unlock(&gr_inode_lock);
67525 +
67526 + return retval;
67527 +}
67528 +
67529 +static __inline__ struct acl_object_label *
67530 +full_lookup(const struct dentry *orig_dentry, const struct vfsmount *orig_mnt,
67531 + struct dentry *curr_dentry,
67532 + const struct acl_subject_label *subj, char **path, const int checkglob)
67533 +{
67534 + int newglob = checkglob;
67535 + ino_t inode;
67536 + dev_t device;
67537 +
67538 + /* if we aren't checking a subdirectory of the original path yet, don't do glob checking
67539 + as we don't want a / * rule to match instead of the / object
67540 + don't do this for create lookups that call this function though, since they're looking up
67541 + on the parent and thus need globbing checks on all paths
67542 + */
67543 + if (orig_dentry == curr_dentry && newglob != GR_CREATE_GLOB)
67544 + newglob = GR_NO_GLOB;
67545 +
67546 + spin_lock(&curr_dentry->d_lock);
67547 + inode = curr_dentry->d_inode->i_ino;
67548 + device = __get_dev(curr_dentry);
67549 + spin_unlock(&curr_dentry->d_lock);
67550 +
67551 + return __full_lookup(orig_dentry, orig_mnt, inode, device, subj, path, newglob);
67552 +}
67553 +
67554 +#ifdef CONFIG_HUGETLBFS
67555 +static inline bool
67556 +is_hugetlbfs_mnt(const struct vfsmount *mnt)
67557 +{
67558 + int i;
67559 + for (i = 0; i < HUGE_MAX_HSTATE; i++) {
67560 + if (unlikely(hugetlbfs_vfsmount[i] == mnt))
67561 + return true;
67562 + }
67563 +
67564 + return false;
67565 +}
67566 +#endif
67567 +
67568 +static struct acl_object_label *
67569 +__chk_obj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
67570 + const struct acl_subject_label *subj, char *path, const int checkglob)
67571 +{
67572 + struct dentry *dentry = (struct dentry *) l_dentry;
67573 + struct vfsmount *mnt = (struct vfsmount *) l_mnt;
67574 + struct mount *real_mnt = real_mount(mnt);
67575 + struct acl_object_label *retval;
67576 + struct dentry *parent;
67577 +
67578 + read_seqlock_excl(&mount_lock);
67579 + write_seqlock(&rename_lock);
67580 +
67581 + if (unlikely((mnt == shm_mnt && dentry->d_inode->i_nlink == 0) || mnt == pipe_mnt ||
67582 +#ifdef CONFIG_NET
67583 + mnt == sock_mnt ||
67584 +#endif
67585 +#ifdef CONFIG_HUGETLBFS
67586 + (is_hugetlbfs_mnt(mnt) && dentry->d_inode->i_nlink == 0) ||
67587 +#endif
67588 + /* ignore Eric Biederman */
67589 + IS_PRIVATE(l_dentry->d_inode))) {
67590 + retval = (subj->mode & GR_SHMEXEC) ? fakefs_obj_rwx : fakefs_obj_rw;
67591 + goto out;
67592 + }
67593 +
67594 + for (;;) {
67595 + if (dentry == gr_real_root.dentry && mnt == gr_real_root.mnt)
67596 + break;
67597 +
67598 + if (dentry == mnt->mnt_root || IS_ROOT(dentry)) {
67599 + if (!mnt_has_parent(real_mnt))
67600 + break;
67601 +
67602 + retval = full_lookup(l_dentry, l_mnt, dentry, subj, &path, checkglob);
67603 + if (retval != NULL)
67604 + goto out;
67605 +
67606 + dentry = real_mnt->mnt_mountpoint;
67607 + real_mnt = real_mnt->mnt_parent;
67608 + mnt = &real_mnt->mnt;
67609 + continue;
67610 + }
67611 +
67612 + parent = dentry->d_parent;
67613 + retval = full_lookup(l_dentry, l_mnt, dentry, subj, &path, checkglob);
67614 + if (retval != NULL)
67615 + goto out;
67616 +
67617 + dentry = parent;
67618 + }
67619 +
67620 + retval = full_lookup(l_dentry, l_mnt, dentry, subj, &path, checkglob);
67621 +
67622 + /* gr_real_root is pinned so we don't have to hold a reference */
67623 + if (retval == NULL)
67624 + retval = full_lookup(l_dentry, l_mnt, gr_real_root.dentry, subj, &path, checkglob);
67625 +out:
67626 + write_sequnlock(&rename_lock);
67627 + read_sequnlock_excl(&mount_lock);
67628 +
67629 + BUG_ON(retval == NULL);
67630 +
67631 + return retval;
67632 +}
67633 +
67634 +static __inline__ struct acl_object_label *
67635 +chk_obj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
67636 + const struct acl_subject_label *subj)
67637 +{
67638 + char *path = NULL;
67639 + return __chk_obj_label(l_dentry, l_mnt, subj, path, GR_REG_GLOB);
67640 +}
67641 +
67642 +static __inline__ struct acl_object_label *
67643 +chk_obj_label_noglob(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
67644 + const struct acl_subject_label *subj)
67645 +{
67646 + char *path = NULL;
67647 + return __chk_obj_label(l_dentry, l_mnt, subj, path, GR_NO_GLOB);
67648 +}
67649 +
67650 +static __inline__ struct acl_object_label *
67651 +chk_obj_create_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
67652 + const struct acl_subject_label *subj, char *path)
67653 +{
67654 + return __chk_obj_label(l_dentry, l_mnt, subj, path, GR_CREATE_GLOB);
67655 +}
67656 +
67657 +struct acl_subject_label *
67658 +chk_subj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
67659 + const struct acl_role_label *role)
67660 +{
67661 + struct dentry *dentry = (struct dentry *) l_dentry;
67662 + struct vfsmount *mnt = (struct vfsmount *) l_mnt;
67663 + struct mount *real_mnt = real_mount(mnt);
67664 + struct acl_subject_label *retval;
67665 + struct dentry *parent;
67666 +
67667 + read_seqlock_excl(&mount_lock);
67668 + write_seqlock(&rename_lock);
67669 +
67670 + for (;;) {
67671 + if (dentry == gr_real_root.dentry && mnt == gr_real_root.mnt)
67672 + break;
67673 + if (dentry == mnt->mnt_root || IS_ROOT(dentry)) {
67674 + if (!mnt_has_parent(real_mnt))
67675 + break;
67676 +
67677 + spin_lock(&dentry->d_lock);
67678 + read_lock(&gr_inode_lock);
67679 + retval =
67680 + lookup_acl_subj_label(dentry->d_inode->i_ino,
67681 + __get_dev(dentry), role);
67682 + read_unlock(&gr_inode_lock);
67683 + spin_unlock(&dentry->d_lock);
67684 + if (retval != NULL)
67685 + goto out;
67686 +
67687 + dentry = real_mnt->mnt_mountpoint;
67688 + real_mnt = real_mnt->mnt_parent;
67689 + mnt = &real_mnt->mnt;
67690 + continue;
67691 + }
67692 +
67693 + spin_lock(&dentry->d_lock);
67694 + read_lock(&gr_inode_lock);
67695 + retval = lookup_acl_subj_label(dentry->d_inode->i_ino,
67696 + __get_dev(dentry), role);
67697 + read_unlock(&gr_inode_lock);
67698 + parent = dentry->d_parent;
67699 + spin_unlock(&dentry->d_lock);
67700 +
67701 + if (retval != NULL)
67702 + goto out;
67703 +
67704 + dentry = parent;
67705 + }
67706 +
67707 + spin_lock(&dentry->d_lock);
67708 + read_lock(&gr_inode_lock);
67709 + retval = lookup_acl_subj_label(dentry->d_inode->i_ino,
67710 + __get_dev(dentry), role);
67711 + read_unlock(&gr_inode_lock);
67712 + spin_unlock(&dentry->d_lock);
67713 +
67714 + if (unlikely(retval == NULL)) {
67715 + /* gr_real_root is pinned, we don't need to hold a reference */
67716 + read_lock(&gr_inode_lock);
67717 + retval = lookup_acl_subj_label(gr_real_root.dentry->d_inode->i_ino,
67718 + __get_dev(gr_real_root.dentry), role);
67719 + read_unlock(&gr_inode_lock);
67720 + }
67721 +out:
67722 + write_sequnlock(&rename_lock);
67723 + read_sequnlock_excl(&mount_lock);
67724 +
67725 + BUG_ON(retval == NULL);
67726 +
67727 + return retval;
67728 +}
67729 +
67730 +void
67731 +assign_special_role(const char *rolename)
67732 +{
67733 + struct acl_object_label *obj;
67734 + struct acl_role_label *r;
67735 + struct acl_role_label *assigned = NULL;
67736 + struct task_struct *tsk;
67737 + struct file *filp;
67738 +
67739 + FOR_EACH_ROLE_START(r)
67740 + if (!strcmp(rolename, r->rolename) &&
67741 + (r->roletype & GR_ROLE_SPECIAL)) {
67742 + assigned = r;
67743 + break;
67744 + }
67745 + FOR_EACH_ROLE_END(r)
67746 +
67747 + if (!assigned)
67748 + return;
67749 +
67750 + read_lock(&tasklist_lock);
67751 + read_lock(&grsec_exec_file_lock);
67752 +
67753 + tsk = current->real_parent;
67754 + if (tsk == NULL)
67755 + goto out_unlock;
67756 +
67757 + filp = tsk->exec_file;
67758 + if (filp == NULL)
67759 + goto out_unlock;
67760 +
67761 + tsk->is_writable = 0;
67762 + tsk->inherited = 0;
67763 +
67764 + tsk->acl_sp_role = 1;
67765 + tsk->acl_role_id = ++acl_sp_role_value;
67766 + tsk->role = assigned;
67767 + tsk->acl = chk_subj_label(filp->f_path.dentry, filp->f_path.mnt, tsk->role);
67768 +
67769 + /* ignore additional mmap checks for processes that are writable
67770 + by the default ACL */
67771 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, running_polstate.default_role->root_label);
67772 + if (unlikely(obj->mode & GR_WRITE))
67773 + tsk->is_writable = 1;
67774 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, tsk->role->root_label);
67775 + if (unlikely(obj->mode & GR_WRITE))
67776 + tsk->is_writable = 1;
67777 +
67778 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
67779 + printk(KERN_ALERT "Assigning special role:%s subject:%s to process (%s:%d)\n", tsk->role->rolename,
67780 + tsk->acl->filename, tsk->comm, task_pid_nr(tsk));
67781 +#endif
67782 +
67783 +out_unlock:
67784 + read_unlock(&grsec_exec_file_lock);
67785 + read_unlock(&tasklist_lock);
67786 + return;
67787 +}
67788 +
67789 +
67790 +static void
67791 +gr_log_learn(const struct dentry *dentry, const struct vfsmount *mnt, const __u32 mode)
67792 +{
67793 + struct task_struct *task = current;
67794 + const struct cred *cred = current_cred();
67795 +
67796 + security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename, task->role->roletype,
67797 + GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), task->exec_file ? gr_to_filename1(task->exec_file->f_path.dentry,
67798 + task->exec_file->f_path.mnt) : task->acl->filename, task->acl->filename,
67799 + 1UL, 1UL, gr_to_filename(dentry, mnt), (unsigned long) mode, &task->signal->saved_ip);
67800 +
67801 + return;
67802 +}
67803 +
67804 +static void
67805 +gr_log_learn_uid_change(const kuid_t real, const kuid_t effective, const kuid_t fs)
67806 +{
67807 + struct task_struct *task = current;
67808 + const struct cred *cred = current_cred();
67809 +
67810 + security_learn(GR_ID_LEARN_MSG, task->role->rolename, task->role->roletype,
67811 + GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), task->exec_file ? gr_to_filename1(task->exec_file->f_path.dentry,
67812 + task->exec_file->f_path.mnt) : task->acl->filename, task->acl->filename,
67813 + 'u', GR_GLOBAL_UID(real), GR_GLOBAL_UID(effective), GR_GLOBAL_UID(fs), &task->signal->saved_ip);
67814 +
67815 + return;
67816 +}
67817 +
67818 +static void
67819 +gr_log_learn_gid_change(const kgid_t real, const kgid_t effective, const kgid_t fs)
67820 +{
67821 + struct task_struct *task = current;
67822 + const struct cred *cred = current_cred();
67823 +
67824 + security_learn(GR_ID_LEARN_MSG, task->role->rolename, task->role->roletype,
67825 + GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), task->exec_file ? gr_to_filename1(task->exec_file->f_path.dentry,
67826 + task->exec_file->f_path.mnt) : task->acl->filename, task->acl->filename,
67827 + 'g', GR_GLOBAL_GID(real), GR_GLOBAL_GID(effective), GR_GLOBAL_GID(fs), &task->signal->saved_ip);
67828 +
67829 + return;
67830 +}
67831 +
67832 +static void
67833 +gr_set_proc_res(struct task_struct *task)
67834 +{
67835 + struct acl_subject_label *proc;
67836 + unsigned short i;
67837 +
67838 + proc = task->acl;
67839 +
67840 + if (proc->mode & (GR_LEARN | GR_INHERITLEARN))
67841 + return;
67842 +
67843 + for (i = 0; i < RLIM_NLIMITS; i++) {
67844 + if (!(proc->resmask & (1U << i)))
67845 + continue;
67846 +
67847 + task->signal->rlim[i].rlim_cur = proc->res[i].rlim_cur;
67848 + task->signal->rlim[i].rlim_max = proc->res[i].rlim_max;
67849 +
67850 + if (i == RLIMIT_CPU)
67851 + update_rlimit_cpu(task, proc->res[i].rlim_cur);
67852 + }
67853 +
67854 + return;
67855 +}
67856 +
67857 +/* both of the below must be called with
67858 + rcu_read_lock();
67859 + read_lock(&tasklist_lock);
67860 + read_lock(&grsec_exec_file_lock);
67861 +*/
67862 +
67863 +struct acl_subject_label *__gr_get_subject_for_task(const struct gr_policy_state *state, struct task_struct *task, const char *filename)
67864 +{
67865 + char *tmpname;
67866 + struct acl_subject_label *tmpsubj;
67867 + struct file *filp;
67868 + struct name_entry *nmatch;
67869 +
67870 + filp = task->exec_file;
67871 + if (filp == NULL)
67872 + return NULL;
67873 +
67874 + /* the following is to apply the correct subject
67875 + on binaries running when the RBAC system
67876 + is enabled, when the binaries have been
67877 + replaced or deleted since their execution
67878 + -----
67879 + when the RBAC system starts, the inode/dev
67880 + from exec_file will be one the RBAC system
67881 + is unaware of. It only knows the inode/dev
67882 + of the present file on disk, or the absence
67883 + of it.
67884 + */
67885 +
67886 + if (filename)
67887 + nmatch = __lookup_name_entry(state, filename);
67888 + else {
67889 + preempt_disable();
67890 + tmpname = gr_to_filename_rbac(filp->f_path.dentry, filp->f_path.mnt);
67891 +
67892 + nmatch = __lookup_name_entry(state, tmpname);
67893 + preempt_enable();
67894 + }
67895 + tmpsubj = NULL;
67896 + if (nmatch) {
67897 + if (nmatch->deleted)
67898 + tmpsubj = lookup_acl_subj_label_deleted(nmatch->inode, nmatch->device, task->role);
67899 + else
67900 + tmpsubj = lookup_acl_subj_label(nmatch->inode, nmatch->device, task->role);
67901 + }
67902 + /* this also works for the reload case -- if we don't match a potentially inherited subject
67903 + then we fall back to a normal lookup based on the binary's ino/dev
67904 + */
67905 + if (tmpsubj == NULL)
67906 + tmpsubj = chk_subj_label(filp->f_path.dentry, filp->f_path.mnt, task->role);
67907 +
67908 + return tmpsubj;
67909 +}
67910 +
67911 +static struct acl_subject_label *gr_get_subject_for_task(struct task_struct *task, const char *filename)
67912 +{
67913 + return __gr_get_subject_for_task(&running_polstate, task, filename);
67914 +}
67915 +
67916 +void __gr_apply_subject_to_task(const struct gr_policy_state *state, struct task_struct *task, struct acl_subject_label *subj)
67917 +{
67918 + struct acl_object_label *obj;
67919 + struct file *filp;
67920 +
67921 + filp = task->exec_file;
67922 +
67923 + task->acl = subj;
67924 + task->is_writable = 0;
67925 + /* ignore additional mmap checks for processes that are writable
67926 + by the default ACL */
67927 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, state->default_role->root_label);
67928 + if (unlikely(obj->mode & GR_WRITE))
67929 + task->is_writable = 1;
67930 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, task->role->root_label);
67931 + if (unlikely(obj->mode & GR_WRITE))
67932 + task->is_writable = 1;
67933 +
67934 + gr_set_proc_res(task);
67935 +
67936 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
67937 + 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);
67938 +#endif
67939 +}
67940 +
67941 +static void gr_apply_subject_to_task(struct task_struct *task, struct acl_subject_label *subj)
67942 +{
67943 + __gr_apply_subject_to_task(&running_polstate, task, subj);
67944 +}
67945 +
67946 +__u32
67947 +gr_search_file(const struct dentry * dentry, const __u32 mode,
67948 + const struct vfsmount * mnt)
67949 +{
67950 + __u32 retval = mode;
67951 + struct acl_subject_label *curracl;
67952 + struct acl_object_label *currobj;
67953 +
67954 + if (unlikely(!(gr_status & GR_READY)))
67955 + return (mode & ~GR_AUDITS);
67956 +
67957 + curracl = current->acl;
67958 +
67959 + currobj = chk_obj_label(dentry, mnt, curracl);
67960 + retval = currobj->mode & mode;
67961 +
67962 + /* if we're opening a specified transfer file for writing
67963 + (e.g. /dev/initctl), then transfer our role to init
67964 + */
67965 + if (unlikely(currobj->mode & GR_INIT_TRANSFER && retval & GR_WRITE &&
67966 + current->role->roletype & GR_ROLE_PERSIST)) {
67967 + struct task_struct *task = init_pid_ns.child_reaper;
67968 +
67969 + if (task->role != current->role) {
67970 + struct acl_subject_label *subj;
67971 +
67972 + task->acl_sp_role = 0;
67973 + task->acl_role_id = current->acl_role_id;
67974 + task->role = current->role;
67975 + rcu_read_lock();
67976 + read_lock(&grsec_exec_file_lock);
67977 + subj = gr_get_subject_for_task(task, NULL);
67978 + gr_apply_subject_to_task(task, subj);
67979 + read_unlock(&grsec_exec_file_lock);
67980 + rcu_read_unlock();
67981 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_INIT_TRANSFER_MSG);
67982 + }
67983 + }
67984 +
67985 + if (unlikely
67986 + ((curracl->mode & (GR_LEARN | GR_INHERITLEARN)) && !(mode & GR_NOPTRACE)
67987 + && (retval != (mode & ~(GR_AUDITS | GR_SUPPRESS))))) {
67988 + __u32 new_mode = mode;
67989 +
67990 + new_mode &= ~(GR_AUDITS | GR_SUPPRESS);
67991 +
67992 + retval = new_mode;
67993 +
67994 + if (new_mode & GR_EXEC && curracl->mode & GR_INHERITLEARN)
67995 + new_mode |= GR_INHERIT;
67996 +
67997 + if (!(mode & GR_NOLEARN))
67998 + gr_log_learn(dentry, mnt, new_mode);
67999 + }
68000 +
68001 + return retval;
68002 +}
68003 +
68004 +struct acl_object_label *gr_get_create_object(const struct dentry *new_dentry,
68005 + const struct dentry *parent,
68006 + const struct vfsmount *mnt)
68007 +{
68008 + struct name_entry *match;
68009 + struct acl_object_label *matchpo;
68010 + struct acl_subject_label *curracl;
68011 + char *path;
68012 +
68013 + if (unlikely(!(gr_status & GR_READY)))
68014 + return NULL;
68015 +
68016 + preempt_disable();
68017 + path = gr_to_filename_rbac(new_dentry, mnt);
68018 + match = lookup_name_entry_create(path);
68019 +
68020 + curracl = current->acl;
68021 +
68022 + if (match) {
68023 + read_lock(&gr_inode_lock);
68024 + matchpo = lookup_acl_obj_label_create(match->inode, match->device, curracl);
68025 + read_unlock(&gr_inode_lock);
68026 +
68027 + if (matchpo) {
68028 + preempt_enable();
68029 + return matchpo;
68030 + }
68031 + }
68032 +
68033 + // lookup parent
68034 +
68035 + matchpo = chk_obj_create_label(parent, mnt, curracl, path);
68036 +
68037 + preempt_enable();
68038 + return matchpo;
68039 +}
68040 +
68041 +__u32
68042 +gr_check_create(const struct dentry * new_dentry, const struct dentry * parent,
68043 + const struct vfsmount * mnt, const __u32 mode)
68044 +{
68045 + struct acl_object_label *matchpo;
68046 + __u32 retval;
68047 +
68048 + if (unlikely(!(gr_status & GR_READY)))
68049 + return (mode & ~GR_AUDITS);
68050 +
68051 + matchpo = gr_get_create_object(new_dentry, parent, mnt);
68052 +
68053 + retval = matchpo->mode & mode;
68054 +
68055 + if ((retval != (mode & ~(GR_AUDITS | GR_SUPPRESS)))
68056 + && (current->acl->mode & (GR_LEARN | GR_INHERITLEARN))) {
68057 + __u32 new_mode = mode;
68058 +
68059 + new_mode &= ~(GR_AUDITS | GR_SUPPRESS);
68060 +
68061 + gr_log_learn(new_dentry, mnt, new_mode);
68062 + return new_mode;
68063 + }
68064 +
68065 + return retval;
68066 +}
68067 +
68068 +__u32
68069 +gr_check_link(const struct dentry * new_dentry,
68070 + const struct dentry * parent_dentry,
68071 + const struct vfsmount * parent_mnt,
68072 + const struct dentry * old_dentry, const struct vfsmount * old_mnt)
68073 +{
68074 + struct acl_object_label *obj;
68075 + __u32 oldmode, newmode;
68076 + __u32 needmode;
68077 + __u32 checkmodes = GR_FIND | GR_APPEND | GR_WRITE | GR_EXEC | GR_SETID | GR_READ |
68078 + GR_DELETE | GR_INHERIT;
68079 +
68080 + if (unlikely(!(gr_status & GR_READY)))
68081 + return (GR_CREATE | GR_LINK);
68082 +
68083 + obj = chk_obj_label(old_dentry, old_mnt, current->acl);
68084 + oldmode = obj->mode;
68085 +
68086 + obj = gr_get_create_object(new_dentry, parent_dentry, parent_mnt);
68087 + newmode = obj->mode;
68088 +
68089 + needmode = newmode & checkmodes;
68090 +
68091 + // old name for hardlink must have at least the permissions of the new name
68092 + if ((oldmode & needmode) != needmode)
68093 + goto bad;
68094 +
68095 + // if old name had restrictions/auditing, make sure the new name does as well
68096 + needmode = oldmode & (GR_NOPTRACE | GR_PTRACERD | GR_INHERIT | GR_AUDITS);
68097 +
68098 + // don't allow hardlinking of suid/sgid/fcapped files without permission
68099 + if (is_privileged_binary(old_dentry))
68100 + needmode |= GR_SETID;
68101 +
68102 + if ((newmode & needmode) != needmode)
68103 + goto bad;
68104 +
68105 + // enforce minimum permissions
68106 + if ((newmode & (GR_CREATE | GR_LINK)) == (GR_CREATE | GR_LINK))
68107 + return newmode;
68108 +bad:
68109 + needmode = oldmode;
68110 + if (is_privileged_binary(old_dentry))
68111 + needmode |= GR_SETID;
68112 +
68113 + if (current->acl->mode & (GR_LEARN | GR_INHERITLEARN)) {
68114 + gr_log_learn(old_dentry, old_mnt, needmode | GR_CREATE | GR_LINK);
68115 + return (GR_CREATE | GR_LINK);
68116 + } else if (newmode & GR_SUPPRESS)
68117 + return GR_SUPPRESS;
68118 + else
68119 + return 0;
68120 +}
68121 +
68122 +int
68123 +gr_check_hidden_task(const struct task_struct *task)
68124 +{
68125 + if (unlikely(!(gr_status & GR_READY)))
68126 + return 0;
68127 +
68128 + if (!(task->acl->mode & GR_PROCFIND) && !(current->acl->mode & GR_VIEW))
68129 + return 1;
68130 +
68131 + return 0;
68132 +}
68133 +
68134 +int
68135 +gr_check_protected_task(const struct task_struct *task)
68136 +{
68137 + if (unlikely(!(gr_status & GR_READY) || !task))
68138 + return 0;
68139 +
68140 + if ((task->acl->mode & GR_PROTECTED) && !(current->acl->mode & GR_KILL) &&
68141 + task->acl != current->acl)
68142 + return 1;
68143 +
68144 + return 0;
68145 +}
68146 +
68147 +int
68148 +gr_check_protected_task_fowner(struct pid *pid, enum pid_type type)
68149 +{
68150 + struct task_struct *p;
68151 + int ret = 0;
68152 +
68153 + if (unlikely(!(gr_status & GR_READY) || !pid))
68154 + return ret;
68155 +
68156 + read_lock(&tasklist_lock);
68157 + do_each_pid_task(pid, type, p) {
68158 + if ((p->acl->mode & GR_PROTECTED) && !(current->acl->mode & GR_KILL) &&
68159 + p->acl != current->acl) {
68160 + ret = 1;
68161 + goto out;
68162 + }
68163 + } while_each_pid_task(pid, type, p);
68164 +out:
68165 + read_unlock(&tasklist_lock);
68166 +
68167 + return ret;
68168 +}
68169 +
68170 +void
68171 +gr_copy_label(struct task_struct *tsk)
68172 +{
68173 + struct task_struct *p = current;
68174 +
68175 + tsk->inherited = p->inherited;
68176 + tsk->acl_sp_role = 0;
68177 + tsk->acl_role_id = p->acl_role_id;
68178 + tsk->acl = p->acl;
68179 + tsk->role = p->role;
68180 + tsk->signal->used_accept = 0;
68181 + tsk->signal->curr_ip = p->signal->curr_ip;
68182 + tsk->signal->saved_ip = p->signal->saved_ip;
68183 + if (p->exec_file)
68184 + get_file(p->exec_file);
68185 + tsk->exec_file = p->exec_file;
68186 + tsk->is_writable = p->is_writable;
68187 + if (unlikely(p->signal->used_accept)) {
68188 + p->signal->curr_ip = 0;
68189 + p->signal->saved_ip = 0;
68190 + }
68191 +
68192 + return;
68193 +}
68194 +
68195 +extern int gr_process_kernel_setuid_ban(struct user_struct *user);
68196 +
68197 +int
68198 +gr_check_user_change(kuid_t real, kuid_t effective, kuid_t fs)
68199 +{
68200 + unsigned int i;
68201 + __u16 num;
68202 + uid_t *uidlist;
68203 + uid_t curuid;
68204 + int realok = 0;
68205 + int effectiveok = 0;
68206 + int fsok = 0;
68207 + uid_t globalreal, globaleffective, globalfs;
68208 +
68209 +#if defined(CONFIG_GRKERNSEC_KERN_LOCKOUT)
68210 + struct user_struct *user;
68211 +
68212 + if (!uid_valid(real))
68213 + goto skipit;
68214 +
68215 + /* find user based on global namespace */
68216 +
68217 + globalreal = GR_GLOBAL_UID(real);
68218 +
68219 + user = find_user(make_kuid(&init_user_ns, globalreal));
68220 + if (user == NULL)
68221 + goto skipit;
68222 +
68223 + if (gr_process_kernel_setuid_ban(user)) {
68224 + /* for find_user */
68225 + free_uid(user);
68226 + return 1;
68227 + }
68228 +
68229 + /* for find_user */
68230 + free_uid(user);
68231 +
68232 +skipit:
68233 +#endif
68234 +
68235 + if (unlikely(!(gr_status & GR_READY)))
68236 + return 0;
68237 +
68238 + if (current->acl->mode & (GR_LEARN | GR_INHERITLEARN))
68239 + gr_log_learn_uid_change(real, effective, fs);
68240 +
68241 + num = current->acl->user_trans_num;
68242 + uidlist = current->acl->user_transitions;
68243 +
68244 + if (uidlist == NULL)
68245 + return 0;
68246 +
68247 + if (!uid_valid(real)) {
68248 + realok = 1;
68249 + globalreal = (uid_t)-1;
68250 + } else {
68251 + globalreal = GR_GLOBAL_UID(real);
68252 + }
68253 + if (!uid_valid(effective)) {
68254 + effectiveok = 1;
68255 + globaleffective = (uid_t)-1;
68256 + } else {
68257 + globaleffective = GR_GLOBAL_UID(effective);
68258 + }
68259 + if (!uid_valid(fs)) {
68260 + fsok = 1;
68261 + globalfs = (uid_t)-1;
68262 + } else {
68263 + globalfs = GR_GLOBAL_UID(fs);
68264 + }
68265 +
68266 + if (current->acl->user_trans_type & GR_ID_ALLOW) {
68267 + for (i = 0; i < num; i++) {
68268 + curuid = uidlist[i];
68269 + if (globalreal == curuid)
68270 + realok = 1;
68271 + if (globaleffective == curuid)
68272 + effectiveok = 1;
68273 + if (globalfs == curuid)
68274 + fsok = 1;
68275 + }
68276 + } else if (current->acl->user_trans_type & GR_ID_DENY) {
68277 + for (i = 0; i < num; i++) {
68278 + curuid = uidlist[i];
68279 + if (globalreal == curuid)
68280 + break;
68281 + if (globaleffective == curuid)
68282 + break;
68283 + if (globalfs == curuid)
68284 + break;
68285 + }
68286 + /* not in deny list */
68287 + if (i == num) {
68288 + realok = 1;
68289 + effectiveok = 1;
68290 + fsok = 1;
68291 + }
68292 + }
68293 +
68294 + if (realok && effectiveok && fsok)
68295 + return 0;
68296 + else {
68297 + gr_log_int(GR_DONT_AUDIT, GR_USRCHANGE_ACL_MSG, realok ? (effectiveok ? (fsok ? 0 : globalfs) : globaleffective) : globalreal);
68298 + return 1;
68299 + }
68300 +}
68301 +
68302 +int
68303 +gr_check_group_change(kgid_t real, kgid_t effective, kgid_t fs)
68304 +{
68305 + unsigned int i;
68306 + __u16 num;
68307 + gid_t *gidlist;
68308 + gid_t curgid;
68309 + int realok = 0;
68310 + int effectiveok = 0;
68311 + int fsok = 0;
68312 + gid_t globalreal, globaleffective, globalfs;
68313 +
68314 + if (unlikely(!(gr_status & GR_READY)))
68315 + return 0;
68316 +
68317 + if (current->acl->mode & (GR_LEARN | GR_INHERITLEARN))
68318 + gr_log_learn_gid_change(real, effective, fs);
68319 +
68320 + num = current->acl->group_trans_num;
68321 + gidlist = current->acl->group_transitions;
68322 +
68323 + if (gidlist == NULL)
68324 + return 0;
68325 +
68326 + if (!gid_valid(real)) {
68327 + realok = 1;
68328 + globalreal = (gid_t)-1;
68329 + } else {
68330 + globalreal = GR_GLOBAL_GID(real);
68331 + }
68332 + if (!gid_valid(effective)) {
68333 + effectiveok = 1;
68334 + globaleffective = (gid_t)-1;
68335 + } else {
68336 + globaleffective = GR_GLOBAL_GID(effective);
68337 + }
68338 + if (!gid_valid(fs)) {
68339 + fsok = 1;
68340 + globalfs = (gid_t)-1;
68341 + } else {
68342 + globalfs = GR_GLOBAL_GID(fs);
68343 + }
68344 +
68345 + if (current->acl->group_trans_type & GR_ID_ALLOW) {
68346 + for (i = 0; i < num; i++) {
68347 + curgid = gidlist[i];
68348 + if (globalreal == curgid)
68349 + realok = 1;
68350 + if (globaleffective == curgid)
68351 + effectiveok = 1;
68352 + if (globalfs == curgid)
68353 + fsok = 1;
68354 + }
68355 + } else if (current->acl->group_trans_type & GR_ID_DENY) {
68356 + for (i = 0; i < num; i++) {
68357 + curgid = gidlist[i];
68358 + if (globalreal == curgid)
68359 + break;
68360 + if (globaleffective == curgid)
68361 + break;
68362 + if (globalfs == curgid)
68363 + break;
68364 + }
68365 + /* not in deny list */
68366 + if (i == num) {
68367 + realok = 1;
68368 + effectiveok = 1;
68369 + fsok = 1;
68370 + }
68371 + }
68372 +
68373 + if (realok && effectiveok && fsok)
68374 + return 0;
68375 + else {
68376 + gr_log_int(GR_DONT_AUDIT, GR_GRPCHANGE_ACL_MSG, realok ? (effectiveok ? (fsok ? 0 : globalfs) : globaleffective) : globalreal);
68377 + return 1;
68378 + }
68379 +}
68380 +
68381 +extern int gr_acl_is_capable(const int cap);
68382 +
68383 +void
68384 +gr_set_role_label(struct task_struct *task, const kuid_t kuid, const kgid_t kgid)
68385 +{
68386 + struct acl_role_label *role = task->role;
68387 + struct acl_subject_label *subj = NULL;
68388 + struct acl_object_label *obj;
68389 + struct file *filp;
68390 + uid_t uid;
68391 + gid_t gid;
68392 +
68393 + if (unlikely(!(gr_status & GR_READY)))
68394 + return;
68395 +
68396 + uid = GR_GLOBAL_UID(kuid);
68397 + gid = GR_GLOBAL_GID(kgid);
68398 +
68399 + filp = task->exec_file;
68400 +
68401 + /* kernel process, we'll give them the kernel role */
68402 + if (unlikely(!filp)) {
68403 + task->role = running_polstate.kernel_role;
68404 + task->acl = running_polstate.kernel_role->root_label;
68405 + return;
68406 + } else if (!task->role || !(task->role->roletype & GR_ROLE_SPECIAL)) {
68407 + /* save the current ip at time of role lookup so that the proper
68408 + IP will be learned for role_allowed_ip */
68409 + task->signal->saved_ip = task->signal->curr_ip;
68410 + role = lookup_acl_role_label(task, uid, gid);
68411 + }
68412 +
68413 + /* don't change the role if we're not a privileged process */
68414 + if (role && task->role != role &&
68415 + (((role->roletype & GR_ROLE_USER) && !gr_acl_is_capable(CAP_SETUID)) ||
68416 + ((role->roletype & GR_ROLE_GROUP) && !gr_acl_is_capable(CAP_SETGID))))
68417 + return;
68418 +
68419 + /* perform subject lookup in possibly new role
68420 + we can use this result below in the case where role == task->role
68421 + */
68422 + subj = chk_subj_label(filp->f_path.dentry, filp->f_path.mnt, role);
68423 +
68424 + /* if we changed uid/gid, but result in the same role
68425 + and are using inheritance, don't lose the inherited subject
68426 + if current subject is other than what normal lookup
68427 + would result in, we arrived via inheritance, don't
68428 + lose subject
68429 + */
68430 + if (role != task->role || (!(task->acl->mode & GR_INHERITLEARN) &&
68431 + (subj == task->acl)))
68432 + task->acl = subj;
68433 +
68434 + /* leave task->inherited unaffected */
68435 +
68436 + task->role = role;
68437 +
68438 + task->is_writable = 0;
68439 +
68440 + /* ignore additional mmap checks for processes that are writable
68441 + by the default ACL */
68442 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, running_polstate.default_role->root_label);
68443 + if (unlikely(obj->mode & GR_WRITE))
68444 + task->is_writable = 1;
68445 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, task->role->root_label);
68446 + if (unlikely(obj->mode & GR_WRITE))
68447 + task->is_writable = 1;
68448 +
68449 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
68450 + 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);
68451 +#endif
68452 +
68453 + gr_set_proc_res(task);
68454 +
68455 + return;
68456 +}
68457 +
68458 +int
68459 +gr_set_proc_label(const struct dentry *dentry, const struct vfsmount *mnt,
68460 + const int unsafe_flags)
68461 +{
68462 + struct task_struct *task = current;
68463 + struct acl_subject_label *newacl;
68464 + struct acl_object_label *obj;
68465 + __u32 retmode;
68466 +
68467 + if (unlikely(!(gr_status & GR_READY)))
68468 + return 0;
68469 +
68470 + newacl = chk_subj_label(dentry, mnt, task->role);
68471 +
68472 + /* special handling for if we did an strace -f -p <pid> from an admin role, where pid then
68473 + did an exec
68474 + */
68475 + rcu_read_lock();
68476 + read_lock(&tasklist_lock);
68477 + if (task->ptrace && task->parent && ((task->parent->role->roletype & GR_ROLE_GOD) ||
68478 + (task->parent->acl->mode & GR_POVERRIDE))) {
68479 + read_unlock(&tasklist_lock);
68480 + rcu_read_unlock();
68481 + goto skip_check;
68482 + }
68483 + read_unlock(&tasklist_lock);
68484 + rcu_read_unlock();
68485 +
68486 + if (unsafe_flags && !(task->acl->mode & GR_POVERRIDE) && (task->acl != newacl) &&
68487 + !(task->role->roletype & GR_ROLE_GOD) &&
68488 + !gr_search_file(dentry, GR_PTRACERD, mnt) &&
68489 + !(task->acl->mode & (GR_LEARN | GR_INHERITLEARN))) {
68490 + if (unsafe_flags & LSM_UNSAFE_SHARE)
68491 + gr_log_fs_generic(GR_DONT_AUDIT, GR_UNSAFESHARE_EXEC_ACL_MSG, dentry, mnt);
68492 + else
68493 + gr_log_fs_generic(GR_DONT_AUDIT, GR_PTRACE_EXEC_ACL_MSG, dentry, mnt);
68494 + return -EACCES;
68495 + }
68496 +
68497 +skip_check:
68498 +
68499 + obj = chk_obj_label(dentry, mnt, task->acl);
68500 + retmode = obj->mode & (GR_INHERIT | GR_AUDIT_INHERIT);
68501 +
68502 + if (!(task->acl->mode & GR_INHERITLEARN) &&
68503 + ((newacl->mode & GR_LEARN) || !(retmode & GR_INHERIT))) {
68504 + if (obj->nested)
68505 + task->acl = obj->nested;
68506 + else
68507 + task->acl = newacl;
68508 + task->inherited = 0;
68509 + } else {
68510 + task->inherited = 1;
68511 + if (retmode & GR_INHERIT && retmode & GR_AUDIT_INHERIT)
68512 + gr_log_str_fs(GR_DO_AUDIT, GR_INHERIT_ACL_MSG, task->acl->filename, dentry, mnt);
68513 + }
68514 +
68515 + task->is_writable = 0;
68516 +
68517 + /* ignore additional mmap checks for processes that are writable
68518 + by the default ACL */
68519 + obj = chk_obj_label(dentry, mnt, running_polstate.default_role->root_label);
68520 + if (unlikely(obj->mode & GR_WRITE))
68521 + task->is_writable = 1;
68522 + obj = chk_obj_label(dentry, mnt, task->role->root_label);
68523 + if (unlikely(obj->mode & GR_WRITE))
68524 + task->is_writable = 1;
68525 +
68526 + gr_set_proc_res(task);
68527 +
68528 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
68529 + 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);
68530 +#endif
68531 + return 0;
68532 +}
68533 +
68534 +/* always called with valid inodev ptr */
68535 +static void
68536 +do_handle_delete(struct inodev_entry *inodev, const ino_t ino, const dev_t dev)
68537 +{
68538 + struct acl_object_label *matchpo;
68539 + struct acl_subject_label *matchps;
68540 + struct acl_subject_label *subj;
68541 + struct acl_role_label *role;
68542 + unsigned int x;
68543 +
68544 + FOR_EACH_ROLE_START(role)
68545 + FOR_EACH_SUBJECT_START(role, subj, x)
68546 + if ((matchpo = lookup_acl_obj_label(ino, dev, subj)) != NULL)
68547 + matchpo->mode |= GR_DELETED;
68548 + FOR_EACH_SUBJECT_END(subj,x)
68549 + FOR_EACH_NESTED_SUBJECT_START(role, subj)
68550 + /* nested subjects aren't in the role's subj_hash table */
68551 + if ((matchpo = lookup_acl_obj_label(ino, dev, subj)) != NULL)
68552 + matchpo->mode |= GR_DELETED;
68553 + FOR_EACH_NESTED_SUBJECT_END(subj)
68554 + if ((matchps = lookup_acl_subj_label(ino, dev, role)) != NULL)
68555 + matchps->mode |= GR_DELETED;
68556 + FOR_EACH_ROLE_END(role)
68557 +
68558 + inodev->nentry->deleted = 1;
68559 +
68560 + return;
68561 +}
68562 +
68563 +void
68564 +gr_handle_delete(const ino_t ino, const dev_t dev)
68565 +{
68566 + struct inodev_entry *inodev;
68567 +
68568 + if (unlikely(!(gr_status & GR_READY)))
68569 + return;
68570 +
68571 + write_lock(&gr_inode_lock);
68572 + inodev = lookup_inodev_entry(ino, dev);
68573 + if (inodev != NULL)
68574 + do_handle_delete(inodev, ino, dev);
68575 + write_unlock(&gr_inode_lock);
68576 +
68577 + return;
68578 +}
68579 +
68580 +static void
68581 +update_acl_obj_label(const ino_t oldinode, const dev_t olddevice,
68582 + const ino_t newinode, const dev_t newdevice,
68583 + struct acl_subject_label *subj)
68584 +{
68585 + unsigned int index = gr_fhash(oldinode, olddevice, subj->obj_hash_size);
68586 + struct acl_object_label *match;
68587 +
68588 + match = subj->obj_hash[index];
68589 +
68590 + while (match && (match->inode != oldinode ||
68591 + match->device != olddevice ||
68592 + !(match->mode & GR_DELETED)))
68593 + match = match->next;
68594 +
68595 + if (match && (match->inode == oldinode)
68596 + && (match->device == olddevice)
68597 + && (match->mode & GR_DELETED)) {
68598 + if (match->prev == NULL) {
68599 + subj->obj_hash[index] = match->next;
68600 + if (match->next != NULL)
68601 + match->next->prev = NULL;
68602 + } else {
68603 + match->prev->next = match->next;
68604 + if (match->next != NULL)
68605 + match->next->prev = match->prev;
68606 + }
68607 + match->prev = NULL;
68608 + match->next = NULL;
68609 + match->inode = newinode;
68610 + match->device = newdevice;
68611 + match->mode &= ~GR_DELETED;
68612 +
68613 + insert_acl_obj_label(match, subj);
68614 + }
68615 +
68616 + return;
68617 +}
68618 +
68619 +static void
68620 +update_acl_subj_label(const ino_t oldinode, const dev_t olddevice,
68621 + const ino_t newinode, const dev_t newdevice,
68622 + struct acl_role_label *role)
68623 +{
68624 + unsigned int index = gr_fhash(oldinode, olddevice, role->subj_hash_size);
68625 + struct acl_subject_label *match;
68626 +
68627 + match = role->subj_hash[index];
68628 +
68629 + while (match && (match->inode != oldinode ||
68630 + match->device != olddevice ||
68631 + !(match->mode & GR_DELETED)))
68632 + match = match->next;
68633 +
68634 + if (match && (match->inode == oldinode)
68635 + && (match->device == olddevice)
68636 + && (match->mode & GR_DELETED)) {
68637 + if (match->prev == NULL) {
68638 + role->subj_hash[index] = match->next;
68639 + if (match->next != NULL)
68640 + match->next->prev = NULL;
68641 + } else {
68642 + match->prev->next = match->next;
68643 + if (match->next != NULL)
68644 + match->next->prev = match->prev;
68645 + }
68646 + match->prev = NULL;
68647 + match->next = NULL;
68648 + match->inode = newinode;
68649 + match->device = newdevice;
68650 + match->mode &= ~GR_DELETED;
68651 +
68652 + insert_acl_subj_label(match, role);
68653 + }
68654 +
68655 + return;
68656 +}
68657 +
68658 +static void
68659 +update_inodev_entry(const ino_t oldinode, const dev_t olddevice,
68660 + const ino_t newinode, const dev_t newdevice)
68661 +{
68662 + unsigned int index = gr_fhash(oldinode, olddevice, running_polstate.inodev_set.i_size);
68663 + struct inodev_entry *match;
68664 +
68665 + match = running_polstate.inodev_set.i_hash[index];
68666 +
68667 + while (match && (match->nentry->inode != oldinode ||
68668 + match->nentry->device != olddevice || !match->nentry->deleted))
68669 + match = match->next;
68670 +
68671 + if (match && (match->nentry->inode == oldinode)
68672 + && (match->nentry->device == olddevice) &&
68673 + match->nentry->deleted) {
68674 + if (match->prev == NULL) {
68675 + running_polstate.inodev_set.i_hash[index] = match->next;
68676 + if (match->next != NULL)
68677 + match->next->prev = NULL;
68678 + } else {
68679 + match->prev->next = match->next;
68680 + if (match->next != NULL)
68681 + match->next->prev = match->prev;
68682 + }
68683 + match->prev = NULL;
68684 + match->next = NULL;
68685 + match->nentry->inode = newinode;
68686 + match->nentry->device = newdevice;
68687 + match->nentry->deleted = 0;
68688 +
68689 + insert_inodev_entry(match);
68690 + }
68691 +
68692 + return;
68693 +}
68694 +
68695 +static void
68696 +__do_handle_create(const struct name_entry *matchn, ino_t ino, dev_t dev)
68697 +{
68698 + struct acl_subject_label *subj;
68699 + struct acl_role_label *role;
68700 + unsigned int x;
68701 +
68702 + FOR_EACH_ROLE_START(role)
68703 + update_acl_subj_label(matchn->inode, matchn->device, ino, dev, role);
68704 +
68705 + FOR_EACH_NESTED_SUBJECT_START(role, subj)
68706 + if ((subj->inode == ino) && (subj->device == dev)) {
68707 + subj->inode = ino;
68708 + subj->device = dev;
68709 + }
68710 + /* nested subjects aren't in the role's subj_hash table */
68711 + update_acl_obj_label(matchn->inode, matchn->device,
68712 + ino, dev, subj);
68713 + FOR_EACH_NESTED_SUBJECT_END(subj)
68714 + FOR_EACH_SUBJECT_START(role, subj, x)
68715 + update_acl_obj_label(matchn->inode, matchn->device,
68716 + ino, dev, subj);
68717 + FOR_EACH_SUBJECT_END(subj,x)
68718 + FOR_EACH_ROLE_END(role)
68719 +
68720 + update_inodev_entry(matchn->inode, matchn->device, ino, dev);
68721 +
68722 + return;
68723 +}
68724 +
68725 +static void
68726 +do_handle_create(const struct name_entry *matchn, const struct dentry *dentry,
68727 + const struct vfsmount *mnt)
68728 +{
68729 + ino_t ino = dentry->d_inode->i_ino;
68730 + dev_t dev = __get_dev(dentry);
68731 +
68732 + __do_handle_create(matchn, ino, dev);
68733 +
68734 + return;
68735 +}
68736 +
68737 +void
68738 +gr_handle_create(const struct dentry *dentry, const struct vfsmount *mnt)
68739 +{
68740 + struct name_entry *matchn;
68741 +
68742 + if (unlikely(!(gr_status & GR_READY)))
68743 + return;
68744 +
68745 + preempt_disable();
68746 + matchn = lookup_name_entry(gr_to_filename_rbac(dentry, mnt));
68747 +
68748 + if (unlikely((unsigned long)matchn)) {
68749 + write_lock(&gr_inode_lock);
68750 + do_handle_create(matchn, dentry, mnt);
68751 + write_unlock(&gr_inode_lock);
68752 + }
68753 + preempt_enable();
68754 +
68755 + return;
68756 +}
68757 +
68758 +void
68759 +gr_handle_proc_create(const struct dentry *dentry, const struct inode *inode)
68760 +{
68761 + struct name_entry *matchn;
68762 +
68763 + if (unlikely(!(gr_status & GR_READY)))
68764 + return;
68765 +
68766 + preempt_disable();
68767 + matchn = lookup_name_entry(gr_to_proc_filename_rbac(dentry, init_pid_ns.proc_mnt));
68768 +
68769 + if (unlikely((unsigned long)matchn)) {
68770 + write_lock(&gr_inode_lock);
68771 + __do_handle_create(matchn, inode->i_ino, inode->i_sb->s_dev);
68772 + write_unlock(&gr_inode_lock);
68773 + }
68774 + preempt_enable();
68775 +
68776 + return;
68777 +}
68778 +
68779 +void
68780 +gr_handle_rename(struct inode *old_dir, struct inode *new_dir,
68781 + struct dentry *old_dentry,
68782 + struct dentry *new_dentry,
68783 + struct vfsmount *mnt, const __u8 replace, unsigned int flags)
68784 +{
68785 + struct name_entry *matchn;
68786 + struct name_entry *matchn2 = NULL;
68787 + struct inodev_entry *inodev;
68788 + struct inode *inode = new_dentry->d_inode;
68789 + ino_t old_ino = old_dentry->d_inode->i_ino;
68790 + dev_t old_dev = __get_dev(old_dentry);
68791 + unsigned int exchange = flags & RENAME_EXCHANGE;
68792 +
68793 + /* vfs_rename swaps the name and parent link for old_dentry and
68794 + new_dentry
68795 + at this point, old_dentry has the new name, parent link, and inode
68796 + for the renamed file
68797 + if a file is being replaced by a rename, new_dentry has the inode
68798 + and name for the replaced file
68799 + */
68800 +
68801 + if (unlikely(!(gr_status & GR_READY)))
68802 + return;
68803 +
68804 + preempt_disable();
68805 + matchn = lookup_name_entry(gr_to_filename_rbac(old_dentry, mnt));
68806 +
68807 + /* exchange cases:
68808 + a filename exists for the source, but not dest
68809 + do a recreate on source
68810 + a filename exists for the dest, but not source
68811 + do a recreate on dest
68812 + a filename exists for both source and dest
68813 + delete source and dest, then create source and dest
68814 + a filename exists for neither source nor dest
68815 + no updates needed
68816 +
68817 + the name entry lookups get us the old inode/dev associated with
68818 + each name, so do the deletes first (if possible) so that when
68819 + we do the create, we pick up on the right entries
68820 + */
68821 +
68822 + if (exchange)
68823 + matchn2 = lookup_name_entry(gr_to_filename_rbac(new_dentry, mnt));
68824 +
68825 + /* we wouldn't have to check d_inode if it weren't for
68826 + NFS silly-renaming
68827 + */
68828 +
68829 + write_lock(&gr_inode_lock);
68830 + if (unlikely((replace || exchange) && inode)) {
68831 + ino_t new_ino = inode->i_ino;
68832 + dev_t new_dev = __get_dev(new_dentry);
68833 +
68834 + inodev = lookup_inodev_entry(new_ino, new_dev);
68835 + if (inodev != NULL && ((inode->i_nlink <= 1) || S_ISDIR(inode->i_mode)))
68836 + do_handle_delete(inodev, new_ino, new_dev);
68837 + }
68838 +
68839 + inodev = lookup_inodev_entry(old_ino, old_dev);
68840 + if (inodev != NULL && ((old_dentry->d_inode->i_nlink <= 1) || S_ISDIR(old_dentry->d_inode->i_mode)))
68841 + do_handle_delete(inodev, old_ino, old_dev);
68842 +
68843 + if (unlikely(matchn != NULL))
68844 + do_handle_create(matchn, old_dentry, mnt);
68845 +
68846 + if (unlikely(matchn2 != NULL))
68847 + do_handle_create(matchn2, new_dentry, mnt);
68848 +
68849 + write_unlock(&gr_inode_lock);
68850 + preempt_enable();
68851 +
68852 + return;
68853 +}
68854 +
68855 +#if defined(CONFIG_GRKERNSEC_RESLOG) || !defined(CONFIG_GRKERNSEC_NO_RBAC)
68856 +static const unsigned long res_learn_bumps[GR_NLIMITS] = {
68857 + [RLIMIT_CPU] = GR_RLIM_CPU_BUMP,
68858 + [RLIMIT_FSIZE] = GR_RLIM_FSIZE_BUMP,
68859 + [RLIMIT_DATA] = GR_RLIM_DATA_BUMP,
68860 + [RLIMIT_STACK] = GR_RLIM_STACK_BUMP,
68861 + [RLIMIT_CORE] = GR_RLIM_CORE_BUMP,
68862 + [RLIMIT_RSS] = GR_RLIM_RSS_BUMP,
68863 + [RLIMIT_NPROC] = GR_RLIM_NPROC_BUMP,
68864 + [RLIMIT_NOFILE] = GR_RLIM_NOFILE_BUMP,
68865 + [RLIMIT_MEMLOCK] = GR_RLIM_MEMLOCK_BUMP,
68866 + [RLIMIT_AS] = GR_RLIM_AS_BUMP,
68867 + [RLIMIT_LOCKS] = GR_RLIM_LOCKS_BUMP,
68868 + [RLIMIT_SIGPENDING] = GR_RLIM_SIGPENDING_BUMP,
68869 + [RLIMIT_MSGQUEUE] = GR_RLIM_MSGQUEUE_BUMP,
68870 + [RLIMIT_NICE] = GR_RLIM_NICE_BUMP,
68871 + [RLIMIT_RTPRIO] = GR_RLIM_RTPRIO_BUMP,
68872 + [RLIMIT_RTTIME] = GR_RLIM_RTTIME_BUMP
68873 +};
68874 +
68875 +void
68876 +gr_learn_resource(const struct task_struct *task,
68877 + const int res, const unsigned long wanted, const int gt)
68878 +{
68879 + struct acl_subject_label *acl;
68880 + const struct cred *cred;
68881 +
68882 + if (unlikely((gr_status & GR_READY) &&
68883 + task->acl && (task->acl->mode & (GR_LEARN | GR_INHERITLEARN))))
68884 + goto skip_reslog;
68885 +
68886 + gr_log_resource(task, res, wanted, gt);
68887 +skip_reslog:
68888 +
68889 + if (unlikely(!(gr_status & GR_READY) || !wanted || res >= GR_NLIMITS))
68890 + return;
68891 +
68892 + acl = task->acl;
68893 +
68894 + if (likely(!acl || !(acl->mode & (GR_LEARN | GR_INHERITLEARN)) ||
68895 + !(acl->resmask & (1U << (unsigned short) res))))
68896 + return;
68897 +
68898 + if (wanted >= acl->res[res].rlim_cur) {
68899 + unsigned long res_add;
68900 +
68901 + res_add = wanted + res_learn_bumps[res];
68902 +
68903 + acl->res[res].rlim_cur = res_add;
68904 +
68905 + if (wanted > acl->res[res].rlim_max)
68906 + acl->res[res].rlim_max = res_add;
68907 +
68908 + /* only log the subject filename, since resource logging is supported for
68909 + single-subject learning only */
68910 + rcu_read_lock();
68911 + cred = __task_cred(task);
68912 + security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename,
68913 + task->role->roletype, GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), acl->filename,
68914 + acl->filename, acl->res[res].rlim_cur, acl->res[res].rlim_max,
68915 + "", (unsigned long) res, &task->signal->saved_ip);
68916 + rcu_read_unlock();
68917 + }
68918 +
68919 + return;
68920 +}
68921 +EXPORT_SYMBOL_GPL(gr_learn_resource);
68922 +#endif
68923 +
68924 +#if defined(CONFIG_PAX_HAVE_ACL_FLAGS) && (defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR))
68925 +void
68926 +pax_set_initial_flags(struct linux_binprm *bprm)
68927 +{
68928 + struct task_struct *task = current;
68929 + struct acl_subject_label *proc;
68930 + unsigned long flags;
68931 +
68932 + if (unlikely(!(gr_status & GR_READY)))
68933 + return;
68934 +
68935 + flags = pax_get_flags(task);
68936 +
68937 + proc = task->acl;
68938 +
68939 + if (proc->pax_flags & GR_PAX_DISABLE_PAGEEXEC)
68940 + flags &= ~MF_PAX_PAGEEXEC;
68941 + if (proc->pax_flags & GR_PAX_DISABLE_SEGMEXEC)
68942 + flags &= ~MF_PAX_SEGMEXEC;
68943 + if (proc->pax_flags & GR_PAX_DISABLE_RANDMMAP)
68944 + flags &= ~MF_PAX_RANDMMAP;
68945 + if (proc->pax_flags & GR_PAX_DISABLE_EMUTRAMP)
68946 + flags &= ~MF_PAX_EMUTRAMP;
68947 + if (proc->pax_flags & GR_PAX_DISABLE_MPROTECT)
68948 + flags &= ~MF_PAX_MPROTECT;
68949 +
68950 + if (proc->pax_flags & GR_PAX_ENABLE_PAGEEXEC)
68951 + flags |= MF_PAX_PAGEEXEC;
68952 + if (proc->pax_flags & GR_PAX_ENABLE_SEGMEXEC)
68953 + flags |= MF_PAX_SEGMEXEC;
68954 + if (proc->pax_flags & GR_PAX_ENABLE_RANDMMAP)
68955 + flags |= MF_PAX_RANDMMAP;
68956 + if (proc->pax_flags & GR_PAX_ENABLE_EMUTRAMP)
68957 + flags |= MF_PAX_EMUTRAMP;
68958 + if (proc->pax_flags & GR_PAX_ENABLE_MPROTECT)
68959 + flags |= MF_PAX_MPROTECT;
68960 +
68961 + pax_set_flags(task, flags);
68962 +
68963 + return;
68964 +}
68965 +#endif
68966 +
68967 +int
68968 +gr_handle_proc_ptrace(struct task_struct *task)
68969 +{
68970 + struct file *filp;
68971 + struct task_struct *tmp = task;
68972 + struct task_struct *curtemp = current;
68973 + __u32 retmode;
68974 +
68975 +#ifndef CONFIG_GRKERNSEC_HARDEN_PTRACE
68976 + if (unlikely(!(gr_status & GR_READY)))
68977 + return 0;
68978 +#endif
68979 +
68980 + read_lock(&tasklist_lock);
68981 + read_lock(&grsec_exec_file_lock);
68982 + filp = task->exec_file;
68983 +
68984 + while (task_pid_nr(tmp) > 0) {
68985 + if (tmp == curtemp)
68986 + break;
68987 + tmp = tmp->real_parent;
68988 + }
68989 +
68990 + if (!filp || (task_pid_nr(tmp) == 0 && ((grsec_enable_harden_ptrace && gr_is_global_nonroot(current_uid()) && !(gr_status & GR_READY)) ||
68991 + ((gr_status & GR_READY) && !(current->acl->mode & GR_RELAXPTRACE))))) {
68992 + read_unlock(&grsec_exec_file_lock);
68993 + read_unlock(&tasklist_lock);
68994 + return 1;
68995 + }
68996 +
68997 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
68998 + if (!(gr_status & GR_READY)) {
68999 + read_unlock(&grsec_exec_file_lock);
69000 + read_unlock(&tasklist_lock);
69001 + return 0;
69002 + }
69003 +#endif
69004 +
69005 + retmode = gr_search_file(filp->f_path.dentry, GR_NOPTRACE, filp->f_path.mnt);
69006 + read_unlock(&grsec_exec_file_lock);
69007 + read_unlock(&tasklist_lock);
69008 +
69009 + if (retmode & GR_NOPTRACE)
69010 + return 1;
69011 +
69012 + if (!(current->acl->mode & GR_POVERRIDE) && !(current->role->roletype & GR_ROLE_GOD)
69013 + && (current->acl != task->acl || (current->acl != current->role->root_label
69014 + && task_pid_nr(current) != task_pid_nr(task))))
69015 + return 1;
69016 +
69017 + return 0;
69018 +}
69019 +
69020 +void task_grsec_rbac(struct seq_file *m, struct task_struct *p)
69021 +{
69022 + if (unlikely(!(gr_status & GR_READY)))
69023 + return;
69024 +
69025 + if (!(current->role->roletype & GR_ROLE_GOD))
69026 + return;
69027 +
69028 + seq_printf(m, "RBAC:\t%.64s:%c:%.950s\n",
69029 + p->role->rolename, gr_task_roletype_to_char(p),
69030 + p->acl->filename);
69031 +}
69032 +
69033 +int
69034 +gr_handle_ptrace(struct task_struct *task, const long request)
69035 +{
69036 + struct task_struct *tmp = task;
69037 + struct task_struct *curtemp = current;
69038 + __u32 retmode;
69039 +
69040 +#ifndef CONFIG_GRKERNSEC_HARDEN_PTRACE
69041 + if (unlikely(!(gr_status & GR_READY)))
69042 + return 0;
69043 +#endif
69044 + if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) {
69045 + read_lock(&tasklist_lock);
69046 + while (task_pid_nr(tmp) > 0) {
69047 + if (tmp == curtemp)
69048 + break;
69049 + tmp = tmp->real_parent;
69050 + }
69051 +
69052 + if (task_pid_nr(tmp) == 0 && ((grsec_enable_harden_ptrace && gr_is_global_nonroot(current_uid()) && !(gr_status & GR_READY)) ||
69053 + ((gr_status & GR_READY) && !(current->acl->mode & GR_RELAXPTRACE)))) {
69054 + read_unlock(&tasklist_lock);
69055 + gr_log_ptrace(GR_DONT_AUDIT, GR_PTRACE_ACL_MSG, task);
69056 + return 1;
69057 + }
69058 + read_unlock(&tasklist_lock);
69059 + }
69060 +
69061 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
69062 + if (!(gr_status & GR_READY))
69063 + return 0;
69064 +#endif
69065 +
69066 + read_lock(&grsec_exec_file_lock);
69067 + if (unlikely(!task->exec_file)) {
69068 + read_unlock(&grsec_exec_file_lock);
69069 + return 0;
69070 + }
69071 +
69072 + retmode = gr_search_file(task->exec_file->f_path.dentry, GR_PTRACERD | GR_NOPTRACE, task->exec_file->f_path.mnt);
69073 + read_unlock(&grsec_exec_file_lock);
69074 +
69075 + if (retmode & GR_NOPTRACE) {
69076 + gr_log_ptrace(GR_DONT_AUDIT, GR_PTRACE_ACL_MSG, task);
69077 + return 1;
69078 + }
69079 +
69080 + if (retmode & GR_PTRACERD) {
69081 + switch (request) {
69082 + case PTRACE_SEIZE:
69083 + case PTRACE_POKETEXT:
69084 + case PTRACE_POKEDATA:
69085 + case PTRACE_POKEUSR:
69086 +#if !defined(CONFIG_PPC32) && !defined(CONFIG_PPC64) && !defined(CONFIG_PARISC) && !defined(CONFIG_ALPHA) && !defined(CONFIG_IA64)
69087 + case PTRACE_SETREGS:
69088 + case PTRACE_SETFPREGS:
69089 +#endif
69090 +#ifdef CONFIG_X86
69091 + case PTRACE_SETFPXREGS:
69092 +#endif
69093 +#ifdef CONFIG_ALTIVEC
69094 + case PTRACE_SETVRREGS:
69095 +#endif
69096 + return 1;
69097 + default:
69098 + return 0;
69099 + }
69100 + } else if (!(current->acl->mode & GR_POVERRIDE) &&
69101 + !(current->role->roletype & GR_ROLE_GOD) &&
69102 + (current->acl != task->acl)) {
69103 + gr_log_ptrace(GR_DONT_AUDIT, GR_PTRACE_ACL_MSG, task);
69104 + return 1;
69105 + }
69106 +
69107 + return 0;
69108 +}
69109 +
69110 +static int is_writable_mmap(const struct file *filp)
69111 +{
69112 + struct task_struct *task = current;
69113 + struct acl_object_label *obj, *obj2;
69114 +
69115 + if (gr_status & GR_READY && !(task->acl->mode & GR_OVERRIDE) &&
69116 + !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))) {
69117 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, running_polstate.default_role->root_label);
69118 + obj2 = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt,
69119 + task->role->root_label);
69120 + if (unlikely((obj->mode & GR_WRITE) || (obj2->mode & GR_WRITE))) {
69121 + gr_log_fs_generic(GR_DONT_AUDIT, GR_WRITLIB_ACL_MSG, filp->f_path.dentry, filp->f_path.mnt);
69122 + return 1;
69123 + }
69124 + }
69125 + return 0;
69126 +}
69127 +
69128 +int
69129 +gr_acl_handle_mmap(const struct file *file, const unsigned long prot)
69130 +{
69131 + __u32 mode;
69132 +
69133 + if (unlikely(!file || !(prot & PROT_EXEC)))
69134 + return 1;
69135 +
69136 + if (is_writable_mmap(file))
69137 + return 0;
69138 +
69139 + mode =
69140 + gr_search_file(file->f_path.dentry,
69141 + GR_EXEC | GR_AUDIT_EXEC | GR_SUPPRESS,
69142 + file->f_path.mnt);
69143 +
69144 + if (!gr_tpe_allow(file))
69145 + return 0;
69146 +
69147 + if (unlikely(!(mode & GR_EXEC) && !(mode & GR_SUPPRESS))) {
69148 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, GR_MMAP_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
69149 + return 0;
69150 + } else if (unlikely(!(mode & GR_EXEC))) {
69151 + return 0;
69152 + } else if (unlikely(mode & GR_EXEC && mode & GR_AUDIT_EXEC)) {
69153 + gr_log_fs_rbac_generic(GR_DO_AUDIT, GR_MMAP_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
69154 + return 1;
69155 + }
69156 +
69157 + return 1;
69158 +}
69159 +
69160 +int
69161 +gr_acl_handle_mprotect(const struct file *file, const unsigned long prot)
69162 +{
69163 + __u32 mode;
69164 +
69165 + if (unlikely(!file || !(prot & PROT_EXEC)))
69166 + return 1;
69167 +
69168 + if (is_writable_mmap(file))
69169 + return 0;
69170 +
69171 + mode =
69172 + gr_search_file(file->f_path.dentry,
69173 + GR_EXEC | GR_AUDIT_EXEC | GR_SUPPRESS,
69174 + file->f_path.mnt);
69175 +
69176 + if (!gr_tpe_allow(file))
69177 + return 0;
69178 +
69179 + if (unlikely(!(mode & GR_EXEC) && !(mode & GR_SUPPRESS))) {
69180 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, GR_MPROTECT_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
69181 + return 0;
69182 + } else if (unlikely(!(mode & GR_EXEC))) {
69183 + return 0;
69184 + } else if (unlikely(mode & GR_EXEC && mode & GR_AUDIT_EXEC)) {
69185 + gr_log_fs_rbac_generic(GR_DO_AUDIT, GR_MPROTECT_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
69186 + return 1;
69187 + }
69188 +
69189 + return 1;
69190 +}
69191 +
69192 +void
69193 +gr_acl_handle_psacct(struct task_struct *task, const long code)
69194 +{
69195 + unsigned long runtime, cputime;
69196 + cputime_t utime, stime;
69197 + unsigned int wday, cday;
69198 + __u8 whr, chr;
69199 + __u8 wmin, cmin;
69200 + __u8 wsec, csec;
69201 + struct timespec timeval;
69202 +
69203 + if (unlikely(!(gr_status & GR_READY) || !task->acl ||
69204 + !(task->acl->mode & GR_PROCACCT)))
69205 + return;
69206 +
69207 + do_posix_clock_monotonic_gettime(&timeval);
69208 + runtime = timeval.tv_sec - task->start_time.tv_sec;
69209 + wday = runtime / (60 * 60 * 24);
69210 + runtime -= wday * (60 * 60 * 24);
69211 + whr = runtime / (60 * 60);
69212 + runtime -= whr * (60 * 60);
69213 + wmin = runtime / 60;
69214 + runtime -= wmin * 60;
69215 + wsec = runtime;
69216 +
69217 + task_cputime(task, &utime, &stime);
69218 + cputime = cputime_to_secs(utime + stime);
69219 + cday = cputime / (60 * 60 * 24);
69220 + cputime -= cday * (60 * 60 * 24);
69221 + chr = cputime / (60 * 60);
69222 + cputime -= chr * (60 * 60);
69223 + cmin = cputime / 60;
69224 + cputime -= cmin * 60;
69225 + csec = cputime;
69226 +
69227 + gr_log_procacct(GR_DO_AUDIT, GR_ACL_PROCACCT_MSG, task, wday, whr, wmin, wsec, cday, chr, cmin, csec, code);
69228 +
69229 + return;
69230 +}
69231 +
69232 +#ifdef CONFIG_TASKSTATS
69233 +int gr_is_taskstats_denied(int pid)
69234 +{
69235 + struct task_struct *task;
69236 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
69237 + const struct cred *cred;
69238 +#endif
69239 + int ret = 0;
69240 +
69241 + /* restrict taskstats viewing to un-chrooted root users
69242 + who have the 'view' subject flag if the RBAC system is enabled
69243 + */
69244 +
69245 + rcu_read_lock();
69246 + read_lock(&tasklist_lock);
69247 + task = find_task_by_vpid(pid);
69248 + if (task) {
69249 +#ifdef CONFIG_GRKERNSEC_CHROOT
69250 + if (proc_is_chrooted(task))
69251 + ret = -EACCES;
69252 +#endif
69253 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
69254 + cred = __task_cred(task);
69255 +#ifdef CONFIG_GRKERNSEC_PROC_USER
69256 + if (gr_is_global_nonroot(cred->uid))
69257 + ret = -EACCES;
69258 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
69259 + if (gr_is_global_nonroot(cred->uid) && !groups_search(cred->group_info, grsec_proc_gid))
69260 + ret = -EACCES;
69261 +#endif
69262 +#endif
69263 + if (gr_status & GR_READY) {
69264 + if (!(task->acl->mode & GR_VIEW))
69265 + ret = -EACCES;
69266 + }
69267 + } else
69268 + ret = -ENOENT;
69269 +
69270 + read_unlock(&tasklist_lock);
69271 + rcu_read_unlock();
69272 +
69273 + return ret;
69274 +}
69275 +#endif
69276 +
69277 +/* AUXV entries are filled via a descendant of search_binary_handler
69278 + after we've already applied the subject for the target
69279 +*/
69280 +int gr_acl_enable_at_secure(void)
69281 +{
69282 + if (unlikely(!(gr_status & GR_READY)))
69283 + return 0;
69284 +
69285 + if (current->acl->mode & GR_ATSECURE)
69286 + return 1;
69287 +
69288 + return 0;
69289 +}
69290 +
69291 +int gr_acl_handle_filldir(const struct file *file, const char *name, const unsigned int namelen, const ino_t ino)
69292 +{
69293 + struct task_struct *task = current;
69294 + struct dentry *dentry = file->f_path.dentry;
69295 + struct vfsmount *mnt = file->f_path.mnt;
69296 + struct acl_object_label *obj, *tmp;
69297 + struct acl_subject_label *subj;
69298 + unsigned int bufsize;
69299 + int is_not_root;
69300 + char *path;
69301 + dev_t dev = __get_dev(dentry);
69302 +
69303 + if (unlikely(!(gr_status & GR_READY)))
69304 + return 1;
69305 +
69306 + if (task->acl->mode & (GR_LEARN | GR_INHERITLEARN))
69307 + return 1;
69308 +
69309 + /* ignore Eric Biederman */
69310 + if (IS_PRIVATE(dentry->d_inode))
69311 + return 1;
69312 +
69313 + subj = task->acl;
69314 + read_lock(&gr_inode_lock);
69315 + do {
69316 + obj = lookup_acl_obj_label(ino, dev, subj);
69317 + if (obj != NULL) {
69318 + read_unlock(&gr_inode_lock);
69319 + return (obj->mode & GR_FIND) ? 1 : 0;
69320 + }
69321 + } while ((subj = subj->parent_subject));
69322 + read_unlock(&gr_inode_lock);
69323 +
69324 + /* this is purely an optimization since we're looking for an object
69325 + for the directory we're doing a readdir on
69326 + if it's possible for any globbed object to match the entry we're
69327 + filling into the directory, then the object we find here will be
69328 + an anchor point with attached globbed objects
69329 + */
69330 + obj = chk_obj_label_noglob(dentry, mnt, task->acl);
69331 + if (obj->globbed == NULL)
69332 + return (obj->mode & GR_FIND) ? 1 : 0;
69333 +
69334 + is_not_root = ((obj->filename[0] == '/') &&
69335 + (obj->filename[1] == '\0')) ? 0 : 1;
69336 + bufsize = PAGE_SIZE - namelen - is_not_root;
69337 +
69338 + /* check bufsize > PAGE_SIZE || bufsize == 0 */
69339 + if (unlikely((bufsize - 1) > (PAGE_SIZE - 1)))
69340 + return 1;
69341 +
69342 + preempt_disable();
69343 + path = d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0], smp_processor_id()),
69344 + bufsize);
69345 +
69346 + bufsize = strlen(path);
69347 +
69348 + /* if base is "/", don't append an additional slash */
69349 + if (is_not_root)
69350 + *(path + bufsize) = '/';
69351 + memcpy(path + bufsize + is_not_root, name, namelen);
69352 + *(path + bufsize + namelen + is_not_root) = '\0';
69353 +
69354 + tmp = obj->globbed;
69355 + while (tmp) {
69356 + if (!glob_match(tmp->filename, path)) {
69357 + preempt_enable();
69358 + return (tmp->mode & GR_FIND) ? 1 : 0;
69359 + }
69360 + tmp = tmp->next;
69361 + }
69362 + preempt_enable();
69363 + return (obj->mode & GR_FIND) ? 1 : 0;
69364 +}
69365 +
69366 +void gr_put_exec_file(struct task_struct *task)
69367 +{
69368 + struct file *filp;
69369 +
69370 + write_lock(&grsec_exec_file_lock);
69371 + filp = task->exec_file;
69372 + task->exec_file = NULL;
69373 + write_unlock(&grsec_exec_file_lock);
69374 +
69375 + if (filp)
69376 + fput(filp);
69377 +
69378 + return;
69379 +}
69380 +
69381 +
69382 +#ifdef CONFIG_NETFILTER_XT_MATCH_GRADM_MODULE
69383 +EXPORT_SYMBOL_GPL(gr_acl_is_enabled);
69384 +#endif
69385 +#ifdef CONFIG_SECURITY
69386 +EXPORT_SYMBOL_GPL(gr_check_user_change);
69387 +EXPORT_SYMBOL_GPL(gr_check_group_change);
69388 +#endif
69389 +
69390 diff --git a/grsecurity/gracl_alloc.c b/grsecurity/gracl_alloc.c
69391 new file mode 100644
69392 index 0000000..18ffbbd
69393 --- /dev/null
69394 +++ b/grsecurity/gracl_alloc.c
69395 @@ -0,0 +1,105 @@
69396 +#include <linux/kernel.h>
69397 +#include <linux/mm.h>
69398 +#include <linux/slab.h>
69399 +#include <linux/vmalloc.h>
69400 +#include <linux/gracl.h>
69401 +#include <linux/grsecurity.h>
69402 +
69403 +static struct gr_alloc_state __current_alloc_state = { 1, 1, NULL };
69404 +struct gr_alloc_state *current_alloc_state = &__current_alloc_state;
69405 +
69406 +static __inline__ int
69407 +alloc_pop(void)
69408 +{
69409 + if (current_alloc_state->alloc_stack_next == 1)
69410 + return 0;
69411 +
69412 + kfree(current_alloc_state->alloc_stack[current_alloc_state->alloc_stack_next - 2]);
69413 +
69414 + current_alloc_state->alloc_stack_next--;
69415 +
69416 + return 1;
69417 +}
69418 +
69419 +static __inline__ int
69420 +alloc_push(void *buf)
69421 +{
69422 + if (current_alloc_state->alloc_stack_next >= current_alloc_state->alloc_stack_size)
69423 + return 1;
69424 +
69425 + current_alloc_state->alloc_stack[current_alloc_state->alloc_stack_next - 1] = buf;
69426 +
69427 + current_alloc_state->alloc_stack_next++;
69428 +
69429 + return 0;
69430 +}
69431 +
69432 +void *
69433 +acl_alloc(unsigned long len)
69434 +{
69435 + void *ret = NULL;
69436 +
69437 + if (!len || len > PAGE_SIZE)
69438 + goto out;
69439 +
69440 + ret = kmalloc(len, GFP_KERNEL);
69441 +
69442 + if (ret) {
69443 + if (alloc_push(ret)) {
69444 + kfree(ret);
69445 + ret = NULL;
69446 + }
69447 + }
69448 +
69449 +out:
69450 + return ret;
69451 +}
69452 +
69453 +void *
69454 +acl_alloc_num(unsigned long num, unsigned long len)
69455 +{
69456 + if (!len || (num > (PAGE_SIZE / len)))
69457 + return NULL;
69458 +
69459 + return acl_alloc(num * len);
69460 +}
69461 +
69462 +void
69463 +acl_free_all(void)
69464 +{
69465 + if (!current_alloc_state->alloc_stack)
69466 + return;
69467 +
69468 + while (alloc_pop()) ;
69469 +
69470 + if (current_alloc_state->alloc_stack) {
69471 + if ((current_alloc_state->alloc_stack_size * sizeof (void *)) <= PAGE_SIZE)
69472 + kfree(current_alloc_state->alloc_stack);
69473 + else
69474 + vfree(current_alloc_state->alloc_stack);
69475 + }
69476 +
69477 + current_alloc_state->alloc_stack = NULL;
69478 + current_alloc_state->alloc_stack_size = 1;
69479 + current_alloc_state->alloc_stack_next = 1;
69480 +
69481 + return;
69482 +}
69483 +
69484 +int
69485 +acl_alloc_stack_init(unsigned long size)
69486 +{
69487 + if ((size * sizeof (void *)) <= PAGE_SIZE)
69488 + current_alloc_state->alloc_stack =
69489 + (void **) kmalloc(size * sizeof (void *), GFP_KERNEL);
69490 + else
69491 + current_alloc_state->alloc_stack = (void **) vmalloc(size * sizeof (void *));
69492 +
69493 + current_alloc_state->alloc_stack_size = size;
69494 + current_alloc_state->alloc_stack_next = 1;
69495 +
69496 + if (!current_alloc_state->alloc_stack)
69497 + return 0;
69498 + else
69499 + return 1;
69500 +}
69501 diff --git a/grsecurity/gracl_cap.c b/grsecurity/gracl_cap.c
69502 new file mode 100644
69503 index 0000000..bdd51ea
69504 --- /dev/null
69505 +++ b/grsecurity/gracl_cap.c
69506 @@ -0,0 +1,110 @@
69507 +#include <linux/kernel.h>
69508 +#include <linux/module.h>
69509 +#include <linux/sched.h>
69510 +#include <linux/gracl.h>
69511 +#include <linux/grsecurity.h>
69512 +#include <linux/grinternal.h>
69513 +
69514 +extern const char *captab_log[];
69515 +extern int captab_log_entries;
69516 +
69517 +int gr_task_acl_is_capable(const struct task_struct *task, const struct cred *cred, const int cap)
69518 +{
69519 + struct acl_subject_label *curracl;
69520 + kernel_cap_t cap_drop = __cap_empty_set, cap_mask = __cap_empty_set;
69521 + kernel_cap_t cap_audit = __cap_empty_set;
69522 +
69523 + if (!gr_acl_is_enabled())
69524 + return 1;
69525 +
69526 + curracl = task->acl;
69527 +
69528 + cap_drop = curracl->cap_lower;
69529 + cap_mask = curracl->cap_mask;
69530 + cap_audit = curracl->cap_invert_audit;
69531 +
69532 + while ((curracl = curracl->parent_subject)) {
69533 + /* if the cap isn't specified in the current computed mask but is specified in the
69534 + current level subject, and is lowered in the current level subject, then add
69535 + it to the set of dropped capabilities
69536 + otherwise, add the current level subject's mask to the current computed mask
69537 + */
69538 + if (!cap_raised(cap_mask, cap) && cap_raised(curracl->cap_mask, cap)) {
69539 + cap_raise(cap_mask, cap);
69540 + if (cap_raised(curracl->cap_lower, cap))
69541 + cap_raise(cap_drop, cap);
69542 + if (cap_raised(curracl->cap_invert_audit, cap))
69543 + cap_raise(cap_audit, cap);
69544 + }
69545 + }
69546 +
69547 + if (!cap_raised(cap_drop, cap)) {
69548 + if (cap_raised(cap_audit, cap))
69549 + gr_log_cap(GR_DO_AUDIT, GR_CAP_ACL_MSG2, task, captab_log[cap]);
69550 + return 1;
69551 + }
69552 +
69553 + curracl = task->acl;
69554 +
69555 + if ((curracl->mode & (GR_LEARN | GR_INHERITLEARN))
69556 + && cap_raised(cred->cap_effective, cap)) {
69557 + security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename,
69558 + task->role->roletype, GR_GLOBAL_UID(cred->uid),
69559 + GR_GLOBAL_GID(cred->gid), task->exec_file ?
69560 + gr_to_filename(task->exec_file->f_path.dentry,
69561 + task->exec_file->f_path.mnt) : curracl->filename,
69562 + curracl->filename, 0UL,
69563 + 0UL, "", (unsigned long) cap, &task->signal->saved_ip);
69564 + return 1;
69565 + }
69566 +
69567 + if ((cap >= 0) && (cap < captab_log_entries) && cap_raised(cred->cap_effective, cap) && !cap_raised(cap_audit, cap))
69568 + gr_log_cap(GR_DONT_AUDIT, GR_CAP_ACL_MSG, task, captab_log[cap]);
69569 +
69570 + return 0;
69571 +}
69572 +
69573 +int
69574 +gr_acl_is_capable(const int cap)
69575 +{
69576 + return gr_task_acl_is_capable(current, current_cred(), cap);
69577 +}
69578 +
69579 +int gr_task_acl_is_capable_nolog(const struct task_struct *task, const int cap)
69580 +{
69581 + struct acl_subject_label *curracl;
69582 + kernel_cap_t cap_drop = __cap_empty_set, cap_mask = __cap_empty_set;
69583 +
69584 + if (!gr_acl_is_enabled())
69585 + return 1;
69586 +
69587 + curracl = task->acl;
69588 +
69589 + cap_drop = curracl->cap_lower;
69590 + cap_mask = curracl->cap_mask;
69591 +
69592 + while ((curracl = curracl->parent_subject)) {
69593 + /* if the cap isn't specified in the current computed mask but is specified in the
69594 + current level subject, and is lowered in the current level subject, then add
69595 + it to the set of dropped capabilities
69596 + otherwise, add the current level subject's mask to the current computed mask
69597 + */
69598 + if (!cap_raised(cap_mask, cap) && cap_raised(curracl->cap_mask, cap)) {
69599 + cap_raise(cap_mask, cap);
69600 + if (cap_raised(curracl->cap_lower, cap))
69601 + cap_raise(cap_drop, cap);
69602 + }
69603 + }
69604 +
69605 + if (!cap_raised(cap_drop, cap))
69606 + return 1;
69607 +
69608 + return 0;
69609 +}
69610 +
69611 +int
69612 +gr_acl_is_capable_nolog(const int cap)
69613 +{
69614 + return gr_task_acl_is_capable_nolog(current, cap);
69615 +}
69616 +
69617 diff --git a/grsecurity/gracl_compat.c b/grsecurity/gracl_compat.c
69618 new file mode 100644
69619 index 0000000..ca25605
69620 --- /dev/null
69621 +++ b/grsecurity/gracl_compat.c
69622 @@ -0,0 +1,270 @@
69623 +#include <linux/kernel.h>
69624 +#include <linux/gracl.h>
69625 +#include <linux/compat.h>
69626 +#include <linux/gracl_compat.h>
69627 +
69628 +#include <asm/uaccess.h>
69629 +
69630 +int copy_gr_arg_wrapper_compat(const char *buf, struct gr_arg_wrapper *uwrap)
69631 +{
69632 + struct gr_arg_wrapper_compat uwrapcompat;
69633 +
69634 + if (copy_from_user(&uwrapcompat, buf, sizeof(uwrapcompat)))
69635 + return -EFAULT;
69636 +
69637 + if (((uwrapcompat.version != GRSECURITY_VERSION) &&
69638 + (uwrapcompat.version != 0x2901)) ||
69639 + (uwrapcompat.size != sizeof(struct gr_arg_compat)))
69640 + return -EINVAL;
69641 +
69642 + uwrap->arg = compat_ptr(uwrapcompat.arg);
69643 + uwrap->version = uwrapcompat.version;
69644 + uwrap->size = sizeof(struct gr_arg);
69645 +
69646 + return 0;
69647 +}
69648 +
69649 +int copy_gr_arg_compat(const struct gr_arg __user *buf, struct gr_arg *arg)
69650 +{
69651 + struct gr_arg_compat argcompat;
69652 +
69653 + if (copy_from_user(&argcompat, buf, sizeof(argcompat)))
69654 + return -EFAULT;
69655 +
69656 + arg->role_db.r_table = compat_ptr(argcompat.role_db.r_table);
69657 + arg->role_db.num_pointers = argcompat.role_db.num_pointers;
69658 + arg->role_db.num_roles = argcompat.role_db.num_roles;
69659 + arg->role_db.num_domain_children = argcompat.role_db.num_domain_children;
69660 + arg->role_db.num_subjects = argcompat.role_db.num_subjects;
69661 + arg->role_db.num_objects = argcompat.role_db.num_objects;
69662 +
69663 + memcpy(&arg->pw, &argcompat.pw, sizeof(arg->pw));
69664 + memcpy(&arg->salt, &argcompat.salt, sizeof(arg->salt));
69665 + memcpy(&arg->sum, &argcompat.sum, sizeof(arg->sum));
69666 + memcpy(&arg->sp_role, &argcompat.sp_role, sizeof(arg->sp_role));
69667 + arg->sprole_pws = compat_ptr(argcompat.sprole_pws);
69668 + arg->segv_device = argcompat.segv_device;
69669 + arg->segv_inode = argcompat.segv_inode;
69670 + arg->segv_uid = argcompat.segv_uid;
69671 + arg->num_sprole_pws = argcompat.num_sprole_pws;
69672 + arg->mode = argcompat.mode;
69673 +
69674 + return 0;
69675 +}
69676 +
69677 +int copy_acl_object_label_compat(struct acl_object_label *obj, const struct acl_object_label *userp)
69678 +{
69679 + struct acl_object_label_compat objcompat;
69680 +
69681 + if (copy_from_user(&objcompat, userp, sizeof(objcompat)))
69682 + return -EFAULT;
69683 +
69684 + obj->filename = compat_ptr(objcompat.filename);
69685 + obj->inode = objcompat.inode;
69686 + obj->device = objcompat.device;
69687 + obj->mode = objcompat.mode;
69688 +
69689 + obj->nested = compat_ptr(objcompat.nested);
69690 + obj->globbed = compat_ptr(objcompat.globbed);
69691 +
69692 + obj->prev = compat_ptr(objcompat.prev);
69693 + obj->next = compat_ptr(objcompat.next);
69694 +
69695 + return 0;
69696 +}
69697 +
69698 +int copy_acl_subject_label_compat(struct acl_subject_label *subj, const struct acl_subject_label *userp)
69699 +{
69700 + unsigned int i;
69701 + struct acl_subject_label_compat subjcompat;
69702 +
69703 + if (copy_from_user(&subjcompat, userp, sizeof(subjcompat)))
69704 + return -EFAULT;
69705 +
69706 + subj->filename = compat_ptr(subjcompat.filename);
69707 + subj->inode = subjcompat.inode;
69708 + subj->device = subjcompat.device;
69709 + subj->mode = subjcompat.mode;
69710 + subj->cap_mask = subjcompat.cap_mask;
69711 + subj->cap_lower = subjcompat.cap_lower;
69712 + subj->cap_invert_audit = subjcompat.cap_invert_audit;
69713 +
69714 + for (i = 0; i < GR_NLIMITS; i++) {
69715 + if (subjcompat.res[i].rlim_cur == COMPAT_RLIM_INFINITY)
69716 + subj->res[i].rlim_cur = RLIM_INFINITY;
69717 + else
69718 + subj->res[i].rlim_cur = subjcompat.res[i].rlim_cur;
69719 + if (subjcompat.res[i].rlim_max == COMPAT_RLIM_INFINITY)
69720 + subj->res[i].rlim_max = RLIM_INFINITY;
69721 + else
69722 + subj->res[i].rlim_max = subjcompat.res[i].rlim_max;
69723 + }
69724 + subj->resmask = subjcompat.resmask;
69725 +
69726 + subj->user_trans_type = subjcompat.user_trans_type;
69727 + subj->group_trans_type = subjcompat.group_trans_type;
69728 + subj->user_transitions = compat_ptr(subjcompat.user_transitions);
69729 + subj->group_transitions = compat_ptr(subjcompat.group_transitions);
69730 + subj->user_trans_num = subjcompat.user_trans_num;
69731 + subj->group_trans_num = subjcompat.group_trans_num;
69732 +
69733 + memcpy(&subj->sock_families, &subjcompat.sock_families, sizeof(subj->sock_families));
69734 + memcpy(&subj->ip_proto, &subjcompat.ip_proto, sizeof(subj->ip_proto));
69735 + subj->ip_type = subjcompat.ip_type;
69736 + subj->ips = compat_ptr(subjcompat.ips);
69737 + subj->ip_num = subjcompat.ip_num;
69738 + subj->inaddr_any_override = subjcompat.inaddr_any_override;
69739 +
69740 + subj->crashes = subjcompat.crashes;
69741 + subj->expires = subjcompat.expires;
69742 +
69743 + subj->parent_subject = compat_ptr(subjcompat.parent_subject);
69744 + subj->hash = compat_ptr(subjcompat.hash);
69745 + subj->prev = compat_ptr(subjcompat.prev);
69746 + subj->next = compat_ptr(subjcompat.next);
69747 +
69748 + subj->obj_hash = compat_ptr(subjcompat.obj_hash);
69749 + subj->obj_hash_size = subjcompat.obj_hash_size;
69750 + subj->pax_flags = subjcompat.pax_flags;
69751 +
69752 + return 0;
69753 +}
69754 +
69755 +int copy_acl_role_label_compat(struct acl_role_label *role, const struct acl_role_label *userp)
69756 +{
69757 + struct acl_role_label_compat rolecompat;
69758 +
69759 + if (copy_from_user(&rolecompat, userp, sizeof(rolecompat)))
69760 + return -EFAULT;
69761 +
69762 + role->rolename = compat_ptr(rolecompat.rolename);
69763 + role->uidgid = rolecompat.uidgid;
69764 + role->roletype = rolecompat.roletype;
69765 +
69766 + role->auth_attempts = rolecompat.auth_attempts;
69767 + role->expires = rolecompat.expires;
69768 +
69769 + role->root_label = compat_ptr(rolecompat.root_label);
69770 + role->hash = compat_ptr(rolecompat.hash);
69771 +
69772 + role->prev = compat_ptr(rolecompat.prev);
69773 + role->next = compat_ptr(rolecompat.next);
69774 +
69775 + role->transitions = compat_ptr(rolecompat.transitions);
69776 + role->allowed_ips = compat_ptr(rolecompat.allowed_ips);
69777 + role->domain_children = compat_ptr(rolecompat.domain_children);
69778 + role->domain_child_num = rolecompat.domain_child_num;
69779 +
69780 + role->umask = rolecompat.umask;
69781 +
69782 + role->subj_hash = compat_ptr(rolecompat.subj_hash);
69783 + role->subj_hash_size = rolecompat.subj_hash_size;
69784 +
69785 + return 0;
69786 +}
69787 +
69788 +int copy_role_allowed_ip_compat(struct role_allowed_ip *roleip, const struct role_allowed_ip *userp)
69789 +{
69790 + struct role_allowed_ip_compat roleip_compat;
69791 +
69792 + if (copy_from_user(&roleip_compat, userp, sizeof(roleip_compat)))
69793 + return -EFAULT;
69794 +
69795 + roleip->addr = roleip_compat.addr;
69796 + roleip->netmask = roleip_compat.netmask;
69797 +
69798 + roleip->prev = compat_ptr(roleip_compat.prev);
69799 + roleip->next = compat_ptr(roleip_compat.next);
69800 +
69801 + return 0;
69802 +}
69803 +
69804 +int copy_role_transition_compat(struct role_transition *trans, const struct role_transition *userp)
69805 +{
69806 + struct role_transition_compat trans_compat;
69807 +
69808 + if (copy_from_user(&trans_compat, userp, sizeof(trans_compat)))
69809 + return -EFAULT;
69810 +
69811 + trans->rolename = compat_ptr(trans_compat.rolename);
69812 +
69813 + trans->prev = compat_ptr(trans_compat.prev);
69814 + trans->next = compat_ptr(trans_compat.next);
69815 +
69816 + return 0;
69817 +
69818 +}
69819 +
69820 +int copy_gr_hash_struct_compat(struct gr_hash_struct *hash, const struct gr_hash_struct *userp)
69821 +{
69822 + struct gr_hash_struct_compat hash_compat;
69823 +
69824 + if (copy_from_user(&hash_compat, userp, sizeof(hash_compat)))
69825 + return -EFAULT;
69826 +
69827 + hash->table = compat_ptr(hash_compat.table);
69828 + hash->nametable = compat_ptr(hash_compat.nametable);
69829 + hash->first = compat_ptr(hash_compat.first);
69830 +
69831 + hash->table_size = hash_compat.table_size;
69832 + hash->used_size = hash_compat.used_size;
69833 +
69834 + hash->type = hash_compat.type;
69835 +
69836 + return 0;
69837 +}
69838 +
69839 +int copy_pointer_from_array_compat(void *ptr, unsigned long idx, const void *userp)
69840 +{
69841 + compat_uptr_t ptrcompat;
69842 +
69843 + if (copy_from_user(&ptrcompat, userp + (idx * sizeof(ptrcompat)), sizeof(ptrcompat)))
69844 + return -EFAULT;
69845 +
69846 + *(void **)ptr = compat_ptr(ptrcompat);
69847 +
69848 + return 0;
69849 +}
69850 +
69851 +int copy_acl_ip_label_compat(struct acl_ip_label *ip, const struct acl_ip_label *userp)
69852 +{
69853 + struct acl_ip_label_compat ip_compat;
69854 +
69855 + if (copy_from_user(&ip_compat, userp, sizeof(ip_compat)))
69856 + return -EFAULT;
69857 +
69858 + ip->iface = compat_ptr(ip_compat.iface);
69859 + ip->addr = ip_compat.addr;
69860 + ip->netmask = ip_compat.netmask;
69861 + ip->low = ip_compat.low;
69862 + ip->high = ip_compat.high;
69863 + ip->mode = ip_compat.mode;
69864 + ip->type = ip_compat.type;
69865 +
69866 + memcpy(&ip->proto, &ip_compat.proto, sizeof(ip->proto));
69867 +
69868 + ip->prev = compat_ptr(ip_compat.prev);
69869 + ip->next = compat_ptr(ip_compat.next);
69870 +
69871 + return 0;
69872 +}
69873 +
69874 +int copy_sprole_pw_compat(struct sprole_pw *pw, unsigned long idx, const struct sprole_pw *userp)
69875 +{
69876 + struct sprole_pw_compat pw_compat;
69877 +
69878 + if (copy_from_user(&pw_compat, (const void *)userp + (sizeof(pw_compat) * idx), sizeof(pw_compat)))
69879 + return -EFAULT;
69880 +
69881 + pw->rolename = compat_ptr(pw_compat.rolename);
69882 + memcpy(&pw->salt, pw_compat.salt, sizeof(pw->salt));
69883 + memcpy(&pw->sum, pw_compat.sum, sizeof(pw->sum));
69884 +
69885 + return 0;
69886 +}
69887 +
69888 +size_t get_gr_arg_wrapper_size_compat(void)
69889 +{
69890 + return sizeof(struct gr_arg_wrapper_compat);
69891 +}
69892 +
69893 diff --git a/grsecurity/gracl_fs.c b/grsecurity/gracl_fs.c
69894 new file mode 100644
69895 index 0000000..4008fdc
69896 --- /dev/null
69897 +++ b/grsecurity/gracl_fs.c
69898 @@ -0,0 +1,445 @@
69899 +#include <linux/kernel.h>
69900 +#include <linux/sched.h>
69901 +#include <linux/types.h>
69902 +#include <linux/fs.h>
69903 +#include <linux/file.h>
69904 +#include <linux/stat.h>
69905 +#include <linux/grsecurity.h>
69906 +#include <linux/grinternal.h>
69907 +#include <linux/gracl.h>
69908 +
69909 +umode_t
69910 +gr_acl_umask(void)
69911 +{
69912 + if (unlikely(!gr_acl_is_enabled()))
69913 + return 0;
69914 +
69915 + return current->role->umask;
69916 +}
69917 +
69918 +__u32
69919 +gr_acl_handle_hidden_file(const struct dentry * dentry,
69920 + const struct vfsmount * mnt)
69921 +{
69922 + __u32 mode;
69923 +
69924 + if (unlikely(d_is_negative(dentry)))
69925 + return GR_FIND;
69926 +
69927 + mode =
69928 + gr_search_file(dentry, GR_FIND | GR_AUDIT_FIND | GR_SUPPRESS, mnt);
69929 +
69930 + if (unlikely(mode & GR_FIND && mode & GR_AUDIT_FIND)) {
69931 + gr_log_fs_rbac_generic(GR_DO_AUDIT, GR_HIDDEN_ACL_MSG, dentry, mnt);
69932 + return mode;
69933 + } else if (unlikely(!(mode & GR_FIND) && !(mode & GR_SUPPRESS))) {
69934 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, GR_HIDDEN_ACL_MSG, dentry, mnt);
69935 + return 0;
69936 + } else if (unlikely(!(mode & GR_FIND)))
69937 + return 0;
69938 +
69939 + return GR_FIND;
69940 +}
69941 +
69942 +__u32
69943 +gr_acl_handle_open(const struct dentry * dentry, const struct vfsmount * mnt,
69944 + int acc_mode)
69945 +{
69946 + __u32 reqmode = GR_FIND;
69947 + __u32 mode;
69948 +
69949 + if (unlikely(d_is_negative(dentry)))
69950 + return reqmode;
69951 +
69952 + if (acc_mode & MAY_APPEND)
69953 + reqmode |= GR_APPEND;
69954 + else if (acc_mode & MAY_WRITE)
69955 + reqmode |= GR_WRITE;
69956 + if ((acc_mode & MAY_READ) && !S_ISDIR(dentry->d_inode->i_mode))
69957 + reqmode |= GR_READ;
69958 +
69959 + mode =
69960 + gr_search_file(dentry, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS,
69961 + mnt);
69962 +
69963 + if (unlikely(((mode & reqmode) == reqmode) && mode & GR_AUDITS)) {
69964 + gr_log_fs_rbac_mode2(GR_DO_AUDIT, GR_OPEN_ACL_MSG, dentry, mnt,
69965 + reqmode & GR_READ ? " reading" : "",
69966 + reqmode & GR_WRITE ? " writing" : reqmode &
69967 + GR_APPEND ? " appending" : "");
69968 + return reqmode;
69969 + } else
69970 + if (unlikely((mode & reqmode) != reqmode && !(mode & GR_SUPPRESS)))
69971 + {
69972 + gr_log_fs_rbac_mode2(GR_DONT_AUDIT, GR_OPEN_ACL_MSG, dentry, mnt,
69973 + reqmode & GR_READ ? " reading" : "",
69974 + reqmode & GR_WRITE ? " writing" : reqmode &
69975 + GR_APPEND ? " appending" : "");
69976 + return 0;
69977 + } else if (unlikely((mode & reqmode) != reqmode))
69978 + return 0;
69979 +
69980 + return reqmode;
69981 +}
69982 +
69983 +__u32
69984 +gr_acl_handle_creat(const struct dentry * dentry,
69985 + const struct dentry * p_dentry,
69986 + const struct vfsmount * p_mnt, int open_flags, int acc_mode,
69987 + const int imode)
69988 +{
69989 + __u32 reqmode = GR_WRITE | GR_CREATE;
69990 + __u32 mode;
69991 +
69992 + if (acc_mode & MAY_APPEND)
69993 + reqmode |= GR_APPEND;
69994 + // if a directory was required or the directory already exists, then
69995 + // don't count this open as a read
69996 + if ((acc_mode & MAY_READ) &&
69997 + !((open_flags & O_DIRECTORY) || (dentry->d_inode && S_ISDIR(dentry->d_inode->i_mode))))
69998 + reqmode |= GR_READ;
69999 + if ((open_flags & O_CREAT) &&
70000 + ((imode & S_ISUID) || ((imode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))))
70001 + reqmode |= GR_SETID;
70002 +
70003 + mode =
70004 + gr_check_create(dentry, p_dentry, p_mnt,
70005 + reqmode | to_gr_audit(reqmode) | GR_SUPPRESS);
70006 +
70007 + if (unlikely(((mode & reqmode) == reqmode) && mode & GR_AUDITS)) {
70008 + gr_log_fs_rbac_mode2(GR_DO_AUDIT, GR_CREATE_ACL_MSG, dentry, p_mnt,
70009 + reqmode & GR_READ ? " reading" : "",
70010 + reqmode & GR_WRITE ? " writing" : reqmode &
70011 + GR_APPEND ? " appending" : "");
70012 + return reqmode;
70013 + } else
70014 + if (unlikely((mode & reqmode) != reqmode && !(mode & GR_SUPPRESS)))
70015 + {
70016 + gr_log_fs_rbac_mode2(GR_DONT_AUDIT, GR_CREATE_ACL_MSG, dentry, p_mnt,
70017 + reqmode & GR_READ ? " reading" : "",
70018 + reqmode & GR_WRITE ? " writing" : reqmode &
70019 + GR_APPEND ? " appending" : "");
70020 + return 0;
70021 + } else if (unlikely((mode & reqmode) != reqmode))
70022 + return 0;
70023 +
70024 + return reqmode;
70025 +}
70026 +
70027 +__u32
70028 +gr_acl_handle_access(const struct dentry * dentry, const struct vfsmount * mnt,
70029 + const int fmode)
70030 +{
70031 + __u32 mode, reqmode = GR_FIND;
70032 +
70033 + if ((fmode & S_IXOTH) && !S_ISDIR(dentry->d_inode->i_mode))
70034 + reqmode |= GR_EXEC;
70035 + if (fmode & S_IWOTH)
70036 + reqmode |= GR_WRITE;
70037 + if (fmode & S_IROTH)
70038 + reqmode |= GR_READ;
70039 +
70040 + mode =
70041 + gr_search_file(dentry, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS,
70042 + mnt);
70043 +
70044 + if (unlikely(((mode & reqmode) == reqmode) && mode & GR_AUDITS)) {
70045 + gr_log_fs_rbac_mode3(GR_DO_AUDIT, GR_ACCESS_ACL_MSG, dentry, mnt,
70046 + reqmode & GR_READ ? " reading" : "",
70047 + reqmode & GR_WRITE ? " writing" : "",
70048 + reqmode & GR_EXEC ? " executing" : "");
70049 + return reqmode;
70050 + } else
70051 + if (unlikely((mode & reqmode) != reqmode && !(mode & GR_SUPPRESS)))
70052 + {
70053 + gr_log_fs_rbac_mode3(GR_DONT_AUDIT, GR_ACCESS_ACL_MSG, dentry, mnt,
70054 + reqmode & GR_READ ? " reading" : "",
70055 + reqmode & GR_WRITE ? " writing" : "",
70056 + reqmode & GR_EXEC ? " executing" : "");
70057 + return 0;
70058 + } else if (unlikely((mode & reqmode) != reqmode))
70059 + return 0;
70060 +
70061 + return reqmode;
70062 +}
70063 +
70064 +static __u32 generic_fs_handler(const struct dentry *dentry, const struct vfsmount *mnt, __u32 reqmode, const char *fmt)
70065 +{
70066 + __u32 mode;
70067 +
70068 + mode = gr_search_file(dentry, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS, mnt);
70069 +
70070 + if (unlikely(((mode & (reqmode)) == (reqmode)) && mode & GR_AUDITS)) {
70071 + gr_log_fs_rbac_generic(GR_DO_AUDIT, fmt, dentry, mnt);
70072 + return mode;
70073 + } else if (unlikely((mode & (reqmode)) != (reqmode) && !(mode & GR_SUPPRESS))) {
70074 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, fmt, dentry, mnt);
70075 + return 0;
70076 + } else if (unlikely((mode & (reqmode)) != (reqmode)))
70077 + return 0;
70078 +
70079 + return (reqmode);
70080 +}
70081 +
70082 +__u32
70083 +gr_acl_handle_rmdir(const struct dentry * dentry, const struct vfsmount * mnt)
70084 +{
70085 + return generic_fs_handler(dentry, mnt, GR_WRITE | GR_DELETE , GR_RMDIR_ACL_MSG);
70086 +}
70087 +
70088 +__u32
70089 +gr_acl_handle_unlink(const struct dentry *dentry, const struct vfsmount *mnt)
70090 +{
70091 + return generic_fs_handler(dentry, mnt, GR_WRITE | GR_DELETE , GR_UNLINK_ACL_MSG);
70092 +}
70093 +
70094 +__u32
70095 +gr_acl_handle_truncate(const struct dentry *dentry, const struct vfsmount *mnt)
70096 +{
70097 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_TRUNCATE_ACL_MSG);
70098 +}
70099 +
70100 +__u32
70101 +gr_acl_handle_utime(const struct dentry *dentry, const struct vfsmount *mnt)
70102 +{
70103 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_ATIME_ACL_MSG);
70104 +}
70105 +
70106 +__u32
70107 +gr_acl_handle_chmod(const struct dentry *dentry, const struct vfsmount *mnt,
70108 + umode_t *modeptr)
70109 +{
70110 + umode_t mode;
70111 +
70112 + *modeptr &= ~gr_acl_umask();
70113 + mode = *modeptr;
70114 +
70115 + if (unlikely(dentry->d_inode && S_ISSOCK(dentry->d_inode->i_mode)))
70116 + return 1;
70117 +
70118 + if (unlikely(dentry->d_inode && !S_ISDIR(dentry->d_inode->i_mode) &&
70119 + ((mode & S_ISUID) || ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))))) {
70120 + return generic_fs_handler(dentry, mnt, GR_WRITE | GR_SETID,
70121 + GR_CHMOD_ACL_MSG);
70122 + } else {
70123 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_CHMOD_ACL_MSG);
70124 + }
70125 +}
70126 +
70127 +__u32
70128 +gr_acl_handle_chown(const struct dentry *dentry, const struct vfsmount *mnt)
70129 +{
70130 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_CHOWN_ACL_MSG);
70131 +}
70132 +
70133 +__u32
70134 +gr_acl_handle_setxattr(const struct dentry *dentry, const struct vfsmount *mnt)
70135 +{
70136 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_SETXATTR_ACL_MSG);
70137 +}
70138 +
70139 +__u32
70140 +gr_acl_handle_removexattr(const struct dentry *dentry, const struct vfsmount *mnt)
70141 +{
70142 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_REMOVEXATTR_ACL_MSG);
70143 +}
70144 +
70145 +__u32
70146 +gr_acl_handle_execve(const struct dentry *dentry, const struct vfsmount *mnt)
70147 +{
70148 + return generic_fs_handler(dentry, mnt, GR_EXEC, GR_EXEC_ACL_MSG);
70149 +}
70150 +
70151 +__u32
70152 +gr_acl_handle_unix(const struct dentry *dentry, const struct vfsmount *mnt)
70153 +{
70154 + return generic_fs_handler(dentry, mnt, GR_READ | GR_WRITE,
70155 + GR_UNIXCONNECT_ACL_MSG);
70156 +}
70157 +
70158 +/* hardlinks require at minimum create and link permission,
70159 + any additional privilege required is based on the
70160 + privilege of the file being linked to
70161 +*/
70162 +__u32
70163 +gr_acl_handle_link(const struct dentry * new_dentry,
70164 + const struct dentry * parent_dentry,
70165 + const struct vfsmount * parent_mnt,
70166 + const struct dentry * old_dentry,
70167 + const struct vfsmount * old_mnt, const struct filename *to)
70168 +{
70169 + __u32 mode;
70170 + __u32 needmode = GR_CREATE | GR_LINK;
70171 + __u32 needaudit = GR_AUDIT_CREATE | GR_AUDIT_LINK;
70172 +
70173 + mode =
70174 + gr_check_link(new_dentry, parent_dentry, parent_mnt, old_dentry,
70175 + old_mnt);
70176 +
70177 + if (unlikely(((mode & needmode) == needmode) && (mode & needaudit))) {
70178 + gr_log_fs_rbac_str(GR_DO_AUDIT, GR_LINK_ACL_MSG, old_dentry, old_mnt, to->name);
70179 + return mode;
70180 + } else if (unlikely(((mode & needmode) != needmode) && !(mode & GR_SUPPRESS))) {
70181 + gr_log_fs_rbac_str(GR_DONT_AUDIT, GR_LINK_ACL_MSG, old_dentry, old_mnt, to->name);
70182 + return 0;
70183 + } else if (unlikely((mode & needmode) != needmode))
70184 + return 0;
70185 +
70186 + return 1;
70187 +}
70188 +
70189 +__u32
70190 +gr_acl_handle_symlink(const struct dentry * new_dentry,
70191 + const struct dentry * parent_dentry,
70192 + const struct vfsmount * parent_mnt, const struct filename *from)
70193 +{
70194 + __u32 needmode = GR_WRITE | GR_CREATE;
70195 + __u32 mode;
70196 +
70197 + mode =
70198 + gr_check_create(new_dentry, parent_dentry, parent_mnt,
70199 + GR_CREATE | GR_AUDIT_CREATE |
70200 + GR_WRITE | GR_AUDIT_WRITE | GR_SUPPRESS);
70201 +
70202 + if (unlikely(mode & GR_WRITE && mode & GR_AUDITS)) {
70203 + gr_log_fs_str_rbac(GR_DO_AUDIT, GR_SYMLINK_ACL_MSG, from->name, new_dentry, parent_mnt);
70204 + return mode;
70205 + } else if (unlikely(((mode & needmode) != needmode) && !(mode & GR_SUPPRESS))) {
70206 + gr_log_fs_str_rbac(GR_DONT_AUDIT, GR_SYMLINK_ACL_MSG, from->name, new_dentry, parent_mnt);
70207 + return 0;
70208 + } else if (unlikely((mode & needmode) != needmode))
70209 + return 0;
70210 +
70211 + return (GR_WRITE | GR_CREATE);
70212 +}
70213 +
70214 +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)
70215 +{
70216 + __u32 mode;
70217 +
70218 + mode = gr_check_create(new_dentry, parent_dentry, parent_mnt, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS);
70219 +
70220 + if (unlikely(((mode & (reqmode)) == (reqmode)) && mode & GR_AUDITS)) {
70221 + gr_log_fs_rbac_generic(GR_DO_AUDIT, fmt, new_dentry, parent_mnt);
70222 + return mode;
70223 + } else if (unlikely((mode & (reqmode)) != (reqmode) && !(mode & GR_SUPPRESS))) {
70224 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, fmt, new_dentry, parent_mnt);
70225 + return 0;
70226 + } else if (unlikely((mode & (reqmode)) != (reqmode)))
70227 + return 0;
70228 +
70229 + return (reqmode);
70230 +}
70231 +
70232 +__u32
70233 +gr_acl_handle_mknod(const struct dentry * new_dentry,
70234 + const struct dentry * parent_dentry,
70235 + const struct vfsmount * parent_mnt,
70236 + const int mode)
70237 +{
70238 + __u32 reqmode = GR_WRITE | GR_CREATE;
70239 + if (unlikely((mode & S_ISUID) || ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))))
70240 + reqmode |= GR_SETID;
70241 +
70242 + return generic_fs_create_handler(new_dentry, parent_dentry, parent_mnt,
70243 + reqmode, GR_MKNOD_ACL_MSG);
70244 +}
70245 +
70246 +__u32
70247 +gr_acl_handle_mkdir(const struct dentry *new_dentry,
70248 + const struct dentry *parent_dentry,
70249 + const struct vfsmount *parent_mnt)
70250 +{
70251 + return generic_fs_create_handler(new_dentry, parent_dentry, parent_mnt,
70252 + GR_WRITE | GR_CREATE, GR_MKDIR_ACL_MSG);
70253 +}
70254 +
70255 +#define RENAME_CHECK_SUCCESS(old, new) \
70256 + (((old & (GR_WRITE | GR_READ)) == (GR_WRITE | GR_READ)) && \
70257 + ((new & (GR_WRITE | GR_READ)) == (GR_WRITE | GR_READ)))
70258 +
70259 +int
70260 +gr_acl_handle_rename(struct dentry *new_dentry,
70261 + struct dentry *parent_dentry,
70262 + const struct vfsmount *parent_mnt,
70263 + struct dentry *old_dentry,
70264 + struct inode *old_parent_inode,
70265 + struct vfsmount *old_mnt, const struct filename *newname, unsigned int flags)
70266 +{
70267 + __u32 comp1, comp2;
70268 + int error = 0;
70269 +
70270 + if (unlikely(!gr_acl_is_enabled()))
70271 + return 0;
70272 +
70273 + if (flags & RENAME_EXCHANGE) {
70274 + comp1 = gr_search_file(new_dentry, GR_READ | GR_WRITE |
70275 + GR_AUDIT_READ | GR_AUDIT_WRITE |
70276 + GR_SUPPRESS, parent_mnt);
70277 + comp2 =
70278 + gr_search_file(old_dentry,
70279 + GR_READ | GR_WRITE | GR_AUDIT_READ |
70280 + GR_AUDIT_WRITE | GR_SUPPRESS, old_mnt);
70281 + } else if (d_is_negative(new_dentry)) {
70282 + comp1 = gr_check_create(new_dentry, parent_dentry, parent_mnt,
70283 + GR_READ | GR_WRITE | GR_CREATE | GR_AUDIT_READ |
70284 + GR_AUDIT_WRITE | GR_AUDIT_CREATE | GR_SUPPRESS);
70285 + comp2 = gr_search_file(old_dentry, GR_READ | GR_WRITE |
70286 + GR_DELETE | GR_AUDIT_DELETE |
70287 + GR_AUDIT_READ | GR_AUDIT_WRITE |
70288 + GR_SUPPRESS, old_mnt);
70289 + } else {
70290 + comp1 = gr_search_file(new_dentry, GR_READ | GR_WRITE |
70291 + GR_CREATE | GR_DELETE |
70292 + GR_AUDIT_CREATE | GR_AUDIT_DELETE |
70293 + GR_AUDIT_READ | GR_AUDIT_WRITE |
70294 + GR_SUPPRESS, parent_mnt);
70295 + comp2 =
70296 + gr_search_file(old_dentry,
70297 + GR_READ | GR_WRITE | GR_AUDIT_READ |
70298 + GR_DELETE | GR_AUDIT_DELETE |
70299 + GR_AUDIT_WRITE | GR_SUPPRESS, old_mnt);
70300 + }
70301 +
70302 + if (RENAME_CHECK_SUCCESS(comp1, comp2) &&
70303 + ((comp1 & GR_AUDITS) || (comp2 & GR_AUDITS)))
70304 + gr_log_fs_rbac_str(GR_DO_AUDIT, GR_RENAME_ACL_MSG, old_dentry, old_mnt, newname->name);
70305 + else if (!RENAME_CHECK_SUCCESS(comp1, comp2) && !(comp1 & GR_SUPPRESS)
70306 + && !(comp2 & GR_SUPPRESS)) {
70307 + gr_log_fs_rbac_str(GR_DONT_AUDIT, GR_RENAME_ACL_MSG, old_dentry, old_mnt, newname->name);
70308 + error = -EACCES;
70309 + } else if (unlikely(!RENAME_CHECK_SUCCESS(comp1, comp2)))
70310 + error = -EACCES;
70311 +
70312 + return error;
70313 +}
70314 +
70315 +void
70316 +gr_acl_handle_exit(void)
70317 +{
70318 + u16 id;
70319 + char *rolename;
70320 +
70321 + if (unlikely(current->acl_sp_role && gr_acl_is_enabled() &&
70322 + !(current->role->roletype & GR_ROLE_PERSIST))) {
70323 + id = current->acl_role_id;
70324 + rolename = current->role->rolename;
70325 + gr_set_acls(1);
70326 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_SPROLEL_ACL_MSG, rolename, id);
70327 + }
70328 +
70329 + gr_put_exec_file(current);
70330 + return;
70331 +}
70332 +
70333 +int
70334 +gr_acl_handle_procpidmem(const struct task_struct *task)
70335 +{
70336 + if (unlikely(!gr_acl_is_enabled()))
70337 + return 0;
70338 +
70339 + if (task != current && task->acl->mode & GR_PROTPROCFD)
70340 + return -EACCES;
70341 +
70342 + return 0;
70343 +}
70344 diff --git a/grsecurity/gracl_ip.c b/grsecurity/gracl_ip.c
70345 new file mode 100644
70346 index 0000000..f056b81
70347 --- /dev/null
70348 +++ b/grsecurity/gracl_ip.c
70349 @@ -0,0 +1,386 @@
70350 +#include <linux/kernel.h>
70351 +#include <asm/uaccess.h>
70352 +#include <asm/errno.h>
70353 +#include <net/sock.h>
70354 +#include <linux/file.h>
70355 +#include <linux/fs.h>
70356 +#include <linux/net.h>
70357 +#include <linux/in.h>
70358 +#include <linux/skbuff.h>
70359 +#include <linux/ip.h>
70360 +#include <linux/udp.h>
70361 +#include <linux/types.h>
70362 +#include <linux/sched.h>
70363 +#include <linux/netdevice.h>
70364 +#include <linux/inetdevice.h>
70365 +#include <linux/gracl.h>
70366 +#include <linux/grsecurity.h>
70367 +#include <linux/grinternal.h>
70368 +
70369 +#define GR_BIND 0x01
70370 +#define GR_CONNECT 0x02
70371 +#define GR_INVERT 0x04
70372 +#define GR_BINDOVERRIDE 0x08
70373 +#define GR_CONNECTOVERRIDE 0x10
70374 +#define GR_SOCK_FAMILY 0x20
70375 +
70376 +static const char * gr_protocols[IPPROTO_MAX] = {
70377 + "ip", "icmp", "igmp", "ggp", "ipencap", "st", "tcp", "cbt",
70378 + "egp", "igp", "bbn-rcc", "nvp", "pup", "argus", "emcon", "xnet",
70379 + "chaos", "udp", "mux", "dcn", "hmp", "prm", "xns-idp", "trunk-1",
70380 + "trunk-2", "leaf-1", "leaf-2", "rdp", "irtp", "iso-tp4", "netblt", "mfe-nsp",
70381 + "merit-inp", "sep", "3pc", "idpr", "xtp", "ddp", "idpr-cmtp", "tp++",
70382 + "il", "ipv6", "sdrp", "ipv6-route", "ipv6-frag", "idrp", "rsvp", "gre",
70383 + "mhrp", "bna", "ipv6-crypt", "ipv6-auth", "i-nlsp", "swipe", "narp", "mobile",
70384 + "tlsp", "skip", "ipv6-icmp", "ipv6-nonxt", "ipv6-opts", "unknown:61", "cftp", "unknown:63",
70385 + "sat-expak", "kryptolan", "rvd", "ippc", "unknown:68", "sat-mon", "visa", "ipcv",
70386 + "cpnx", "cphb", "wsn", "pvp", "br-sat-mon", "sun-nd", "wb-mon", "wb-expak",
70387 + "iso-ip", "vmtp", "secure-vmtp", "vines", "ttp", "nfsnet-igp", "dgp", "tcf",
70388 + "eigrp", "ospf", "sprite-rpc", "larp", "mtp", "ax.25", "ipip", "micp",
70389 + "scc-sp", "etherip", "encap", "unknown:99", "gmtp", "ifmp", "pnni", "pim",
70390 + "aris", "scps", "qnx", "a/n", "ipcomp", "snp", "compaq-peer", "ipx-in-ip",
70391 + "vrrp", "pgm", "unknown:114", "l2tp", "ddx", "iatp", "stp", "srp",
70392 + "uti", "smp", "sm", "ptp", "isis", "fire", "crtp", "crdup",
70393 + "sscopmce", "iplt", "sps", "pipe", "sctp", "fc", "unkown:134", "unknown:135",
70394 + "unknown:136", "unknown:137", "unknown:138", "unknown:139", "unknown:140", "unknown:141", "unknown:142", "unknown:143",
70395 + "unknown:144", "unknown:145", "unknown:146", "unknown:147", "unknown:148", "unknown:149", "unknown:150", "unknown:151",
70396 + "unknown:152", "unknown:153", "unknown:154", "unknown:155", "unknown:156", "unknown:157", "unknown:158", "unknown:159",
70397 + "unknown:160", "unknown:161", "unknown:162", "unknown:163", "unknown:164", "unknown:165", "unknown:166", "unknown:167",
70398 + "unknown:168", "unknown:169", "unknown:170", "unknown:171", "unknown:172", "unknown:173", "unknown:174", "unknown:175",
70399 + "unknown:176", "unknown:177", "unknown:178", "unknown:179", "unknown:180", "unknown:181", "unknown:182", "unknown:183",
70400 + "unknown:184", "unknown:185", "unknown:186", "unknown:187", "unknown:188", "unknown:189", "unknown:190", "unknown:191",
70401 + "unknown:192", "unknown:193", "unknown:194", "unknown:195", "unknown:196", "unknown:197", "unknown:198", "unknown:199",
70402 + "unknown:200", "unknown:201", "unknown:202", "unknown:203", "unknown:204", "unknown:205", "unknown:206", "unknown:207",
70403 + "unknown:208", "unknown:209", "unknown:210", "unknown:211", "unknown:212", "unknown:213", "unknown:214", "unknown:215",
70404 + "unknown:216", "unknown:217", "unknown:218", "unknown:219", "unknown:220", "unknown:221", "unknown:222", "unknown:223",
70405 + "unknown:224", "unknown:225", "unknown:226", "unknown:227", "unknown:228", "unknown:229", "unknown:230", "unknown:231",
70406 + "unknown:232", "unknown:233", "unknown:234", "unknown:235", "unknown:236", "unknown:237", "unknown:238", "unknown:239",
70407 + "unknown:240", "unknown:241", "unknown:242", "unknown:243", "unknown:244", "unknown:245", "unknown:246", "unknown:247",
70408 + "unknown:248", "unknown:249", "unknown:250", "unknown:251", "unknown:252", "unknown:253", "unknown:254", "unknown:255",
70409 + };
70410 +
70411 +static const char * gr_socktypes[SOCK_MAX] = {
70412 + "unknown:0", "stream", "dgram", "raw", "rdm", "seqpacket", "unknown:6",
70413 + "unknown:7", "unknown:8", "unknown:9", "packet"
70414 + };
70415 +
70416 +static const char * gr_sockfamilies[AF_MAX+1] = {
70417 + "unspec", "unix", "inet", "ax25", "ipx", "appletalk", "netrom", "bridge", "atmpvc", "x25",
70418 + "inet6", "rose", "decnet", "netbeui", "security", "key", "netlink", "packet", "ash",
70419 + "econet", "atmsvc", "rds", "sna", "irda", "ppox", "wanpipe", "llc", "fam_27", "fam_28",
70420 + "tipc", "bluetooth", "iucv", "rxrpc", "isdn", "phonet", "ieee802154", "ciaf"
70421 + };
70422 +
70423 +const char *
70424 +gr_proto_to_name(unsigned char proto)
70425 +{
70426 + return gr_protocols[proto];
70427 +}
70428 +
70429 +const char *
70430 +gr_socktype_to_name(unsigned char type)
70431 +{
70432 + return gr_socktypes[type];
70433 +}
70434 +
70435 +const char *
70436 +gr_sockfamily_to_name(unsigned char family)
70437 +{
70438 + return gr_sockfamilies[family];
70439 +}
70440 +
70441 +extern const struct net_proto_family __rcu *net_families[NPROTO] __read_mostly;
70442 +
70443 +int
70444 +gr_search_socket(const int domain, const int type, const int protocol)
70445 +{
70446 + struct acl_subject_label *curr;
70447 + const struct cred *cred = current_cred();
70448 +
70449 + if (unlikely(!gr_acl_is_enabled()))
70450 + goto exit;
70451 +
70452 + if ((domain < 0) || (type < 0) || (protocol < 0) ||
70453 + (domain >= AF_MAX) || (type >= SOCK_MAX) || (protocol >= IPPROTO_MAX))
70454 + goto exit; // let the kernel handle it
70455 +
70456 + curr = current->acl;
70457 +
70458 + if (curr->sock_families[domain / 32] & (1U << (domain % 32))) {
70459 + /* the family is allowed, if this is PF_INET allow it only if
70460 + the extra sock type/protocol checks pass */
70461 + if (domain == PF_INET)
70462 + goto inet_check;
70463 + goto exit;
70464 + } else {
70465 + if (curr->mode & (GR_LEARN | GR_INHERITLEARN)) {
70466 + __u32 fakeip = 0;
70467 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
70468 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
70469 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
70470 + gr_to_filename(current->exec_file->f_path.dentry,
70471 + current->exec_file->f_path.mnt) :
70472 + curr->filename, curr->filename,
70473 + &fakeip, domain, 0, 0, GR_SOCK_FAMILY,
70474 + &current->signal->saved_ip);
70475 + goto exit;
70476 + }
70477 + goto exit_fail;
70478 + }
70479 +
70480 +inet_check:
70481 + /* the rest of this checking is for IPv4 only */
70482 + if (!curr->ips)
70483 + goto exit;
70484 +
70485 + if ((curr->ip_type & (1U << type)) &&
70486 + (curr->ip_proto[protocol / 32] & (1U << (protocol % 32))))
70487 + goto exit;
70488 +
70489 + if (curr->mode & (GR_LEARN | GR_INHERITLEARN)) {
70490 + /* we don't place acls on raw sockets , and sometimes
70491 + dgram/ip sockets are opened for ioctl and not
70492 + bind/connect, so we'll fake a bind learn log */
70493 + if (type == SOCK_RAW || type == SOCK_PACKET) {
70494 + __u32 fakeip = 0;
70495 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
70496 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
70497 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
70498 + gr_to_filename(current->exec_file->f_path.dentry,
70499 + current->exec_file->f_path.mnt) :
70500 + curr->filename, curr->filename,
70501 + &fakeip, 0, type,
70502 + protocol, GR_CONNECT, &current->signal->saved_ip);
70503 + } else if ((type == SOCK_DGRAM) && (protocol == IPPROTO_IP)) {
70504 + __u32 fakeip = 0;
70505 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
70506 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
70507 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
70508 + gr_to_filename(current->exec_file->f_path.dentry,
70509 + current->exec_file->f_path.mnt) :
70510 + curr->filename, curr->filename,
70511 + &fakeip, 0, type,
70512 + protocol, GR_BIND, &current->signal->saved_ip);
70513 + }
70514 + /* we'll log when they use connect or bind */
70515 + goto exit;
70516 + }
70517 +
70518 +exit_fail:
70519 + if (domain == PF_INET)
70520 + gr_log_str3(GR_DONT_AUDIT, GR_SOCK_MSG, gr_sockfamily_to_name(domain),
70521 + gr_socktype_to_name(type), gr_proto_to_name(protocol));
70522 + else if (rcu_access_pointer(net_families[domain]) != NULL)
70523 + gr_log_str2_int(GR_DONT_AUDIT, GR_SOCK_NOINET_MSG, gr_sockfamily_to_name(domain),
70524 + gr_socktype_to_name(type), protocol);
70525 +
70526 + return 0;
70527 +exit:
70528 + return 1;
70529 +}
70530 +
70531 +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)
70532 +{
70533 + if ((ip->mode & mode) &&
70534 + (ip_port >= ip->low) &&
70535 + (ip_port <= ip->high) &&
70536 + ((ntohl(ip_addr) & our_netmask) ==
70537 + (ntohl(our_addr) & our_netmask))
70538 + && (ip->proto[protocol / 32] & (1U << (protocol % 32)))
70539 + && (ip->type & (1U << type))) {
70540 + if (ip->mode & GR_INVERT)
70541 + return 2; // specifically denied
70542 + else
70543 + return 1; // allowed
70544 + }
70545 +
70546 + return 0; // not specifically allowed, may continue parsing
70547 +}
70548 +
70549 +static int
70550 +gr_search_connectbind(const int full_mode, struct sock *sk,
70551 + struct sockaddr_in *addr, const int type)
70552 +{
70553 + char iface[IFNAMSIZ] = {0};
70554 + struct acl_subject_label *curr;
70555 + struct acl_ip_label *ip;
70556 + struct inet_sock *isk;
70557 + struct net_device *dev;
70558 + struct in_device *idev;
70559 + unsigned long i;
70560 + int ret;
70561 + int mode = full_mode & (GR_BIND | GR_CONNECT);
70562 + __u32 ip_addr = 0;
70563 + __u32 our_addr;
70564 + __u32 our_netmask;
70565 + char *p;
70566 + __u16 ip_port = 0;
70567 + const struct cred *cred = current_cred();
70568 +
70569 + if (unlikely(!gr_acl_is_enabled() || sk->sk_family != PF_INET))
70570 + return 0;
70571 +
70572 + curr = current->acl;
70573 + isk = inet_sk(sk);
70574 +
70575 + /* INADDR_ANY overriding for binds, inaddr_any_override is already in network order */
70576 + if ((full_mode & GR_BINDOVERRIDE) && addr->sin_addr.s_addr == htonl(INADDR_ANY) && curr->inaddr_any_override != 0)
70577 + addr->sin_addr.s_addr = curr->inaddr_any_override;
70578 + if ((full_mode & GR_CONNECT) && isk->inet_saddr == htonl(INADDR_ANY) && curr->inaddr_any_override != 0) {
70579 + struct sockaddr_in saddr;
70580 + int err;
70581 +
70582 + saddr.sin_family = AF_INET;
70583 + saddr.sin_addr.s_addr = curr->inaddr_any_override;
70584 + saddr.sin_port = isk->inet_sport;
70585 +
70586 + err = security_socket_bind(sk->sk_socket, (struct sockaddr *)&saddr, sizeof(struct sockaddr_in));
70587 + if (err)
70588 + return err;
70589 +
70590 + err = sk->sk_socket->ops->bind(sk->sk_socket, (struct sockaddr *)&saddr, sizeof(struct sockaddr_in));
70591 + if (err)
70592 + return err;
70593 + }
70594 +
70595 + if (!curr->ips)
70596 + return 0;
70597 +
70598 + ip_addr = addr->sin_addr.s_addr;
70599 + ip_port = ntohs(addr->sin_port);
70600 +
70601 + if (curr->mode & (GR_LEARN | GR_INHERITLEARN)) {
70602 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
70603 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
70604 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
70605 + gr_to_filename(current->exec_file->f_path.dentry,
70606 + current->exec_file->f_path.mnt) :
70607 + curr->filename, curr->filename,
70608 + &ip_addr, ip_port, type,
70609 + sk->sk_protocol, mode, &current->signal->saved_ip);
70610 + return 0;
70611 + }
70612 +
70613 + for (i = 0; i < curr->ip_num; i++) {
70614 + ip = *(curr->ips + i);
70615 + if (ip->iface != NULL) {
70616 + strncpy(iface, ip->iface, IFNAMSIZ - 1);
70617 + p = strchr(iface, ':');
70618 + if (p != NULL)
70619 + *p = '\0';
70620 + dev = dev_get_by_name(sock_net(sk), iface);
70621 + if (dev == NULL)
70622 + continue;
70623 + idev = in_dev_get(dev);
70624 + if (idev == NULL) {
70625 + dev_put(dev);
70626 + continue;
70627 + }
70628 + rcu_read_lock();
70629 + for_ifa(idev) {
70630 + if (!strcmp(ip->iface, ifa->ifa_label)) {
70631 + our_addr = ifa->ifa_address;
70632 + our_netmask = 0xffffffff;
70633 + ret = check_ip_policy(ip, ip_addr, ip_port, sk->sk_protocol, mode, type, our_addr, our_netmask);
70634 + if (ret == 1) {
70635 + rcu_read_unlock();
70636 + in_dev_put(idev);
70637 + dev_put(dev);
70638 + return 0;
70639 + } else if (ret == 2) {
70640 + rcu_read_unlock();
70641 + in_dev_put(idev);
70642 + dev_put(dev);
70643 + goto denied;
70644 + }
70645 + }
70646 + } endfor_ifa(idev);
70647 + rcu_read_unlock();
70648 + in_dev_put(idev);
70649 + dev_put(dev);
70650 + } else {
70651 + our_addr = ip->addr;
70652 + our_netmask = ip->netmask;
70653 + ret = check_ip_policy(ip, ip_addr, ip_port, sk->sk_protocol, mode, type, our_addr, our_netmask);
70654 + if (ret == 1)
70655 + return 0;
70656 + else if (ret == 2)
70657 + goto denied;
70658 + }
70659 + }
70660 +
70661 +denied:
70662 + if (mode == GR_BIND)
70663 + 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));
70664 + else if (mode == GR_CONNECT)
70665 + 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));
70666 +
70667 + return -EACCES;
70668 +}
70669 +
70670 +int
70671 +gr_search_connect(struct socket *sock, struct sockaddr_in *addr)
70672 +{
70673 + /* always allow disconnection of dgram sockets with connect */
70674 + if (addr->sin_family == AF_UNSPEC)
70675 + return 0;
70676 + return gr_search_connectbind(GR_CONNECT | GR_CONNECTOVERRIDE, sock->sk, addr, sock->type);
70677 +}
70678 +
70679 +int
70680 +gr_search_bind(struct socket *sock, struct sockaddr_in *addr)
70681 +{
70682 + return gr_search_connectbind(GR_BIND | GR_BINDOVERRIDE, sock->sk, addr, sock->type);
70683 +}
70684 +
70685 +int gr_search_listen(struct socket *sock)
70686 +{
70687 + struct sock *sk = sock->sk;
70688 + struct sockaddr_in addr;
70689 +
70690 + addr.sin_addr.s_addr = inet_sk(sk)->inet_saddr;
70691 + addr.sin_port = inet_sk(sk)->inet_sport;
70692 +
70693 + return gr_search_connectbind(GR_BIND | GR_CONNECTOVERRIDE, sock->sk, &addr, sock->type);
70694 +}
70695 +
70696 +int gr_search_accept(struct socket *sock)
70697 +{
70698 + struct sock *sk = sock->sk;
70699 + struct sockaddr_in addr;
70700 +
70701 + addr.sin_addr.s_addr = inet_sk(sk)->inet_saddr;
70702 + addr.sin_port = inet_sk(sk)->inet_sport;
70703 +
70704 + return gr_search_connectbind(GR_BIND | GR_CONNECTOVERRIDE, sock->sk, &addr, sock->type);
70705 +}
70706 +
70707 +int
70708 +gr_search_udp_sendmsg(struct sock *sk, struct sockaddr_in *addr)
70709 +{
70710 + if (addr)
70711 + return gr_search_connectbind(GR_CONNECT, sk, addr, SOCK_DGRAM);
70712 + else {
70713 + struct sockaddr_in sin;
70714 + const struct inet_sock *inet = inet_sk(sk);
70715 +
70716 + sin.sin_addr.s_addr = inet->inet_daddr;
70717 + sin.sin_port = inet->inet_dport;
70718 +
70719 + return gr_search_connectbind(GR_CONNECT | GR_CONNECTOVERRIDE, sk, &sin, SOCK_DGRAM);
70720 + }
70721 +}
70722 +
70723 +int
70724 +gr_search_udp_recvmsg(struct sock *sk, const struct sk_buff *skb)
70725 +{
70726 + struct sockaddr_in sin;
70727 +
70728 + if (unlikely(skb->len < sizeof (struct udphdr)))
70729 + return 0; // skip this packet
70730 +
70731 + sin.sin_addr.s_addr = ip_hdr(skb)->saddr;
70732 + sin.sin_port = udp_hdr(skb)->source;
70733 +
70734 + return gr_search_connectbind(GR_CONNECT | GR_CONNECTOVERRIDE, sk, &sin, SOCK_DGRAM);
70735 +}
70736 diff --git a/grsecurity/gracl_learn.c b/grsecurity/gracl_learn.c
70737 new file mode 100644
70738 index 0000000..25f54ef
70739 --- /dev/null
70740 +++ b/grsecurity/gracl_learn.c
70741 @@ -0,0 +1,207 @@
70742 +#include <linux/kernel.h>
70743 +#include <linux/mm.h>
70744 +#include <linux/sched.h>
70745 +#include <linux/poll.h>
70746 +#include <linux/string.h>
70747 +#include <linux/file.h>
70748 +#include <linux/types.h>
70749 +#include <linux/vmalloc.h>
70750 +#include <linux/grinternal.h>
70751 +
70752 +extern ssize_t write_grsec_handler(struct file * file, const char __user * buf,
70753 + size_t count, loff_t *ppos);
70754 +extern int gr_acl_is_enabled(void);
70755 +
70756 +static DECLARE_WAIT_QUEUE_HEAD(learn_wait);
70757 +static int gr_learn_attached;
70758 +
70759 +/* use a 512k buffer */
70760 +#define LEARN_BUFFER_SIZE (512 * 1024)
70761 +
70762 +static DEFINE_SPINLOCK(gr_learn_lock);
70763 +static DEFINE_MUTEX(gr_learn_user_mutex);
70764 +
70765 +/* we need to maintain two buffers, so that the kernel context of grlearn
70766 + uses a semaphore around the userspace copying, and the other kernel contexts
70767 + use a spinlock when copying into the buffer, since they cannot sleep
70768 +*/
70769 +static char *learn_buffer;
70770 +static char *learn_buffer_user;
70771 +static int learn_buffer_len;
70772 +static int learn_buffer_user_len;
70773 +
70774 +static ssize_t
70775 +read_learn(struct file *file, char __user * buf, size_t count, loff_t * ppos)
70776 +{
70777 + DECLARE_WAITQUEUE(wait, current);
70778 + ssize_t retval = 0;
70779 +
70780 + add_wait_queue(&learn_wait, &wait);
70781 + set_current_state(TASK_INTERRUPTIBLE);
70782 + do {
70783 + mutex_lock(&gr_learn_user_mutex);
70784 + spin_lock(&gr_learn_lock);
70785 + if (learn_buffer_len)
70786 + break;
70787 + spin_unlock(&gr_learn_lock);
70788 + mutex_unlock(&gr_learn_user_mutex);
70789 + if (file->f_flags & O_NONBLOCK) {
70790 + retval = -EAGAIN;
70791 + goto out;
70792 + }
70793 + if (signal_pending(current)) {
70794 + retval = -ERESTARTSYS;
70795 + goto out;
70796 + }
70797 +
70798 + schedule();
70799 + } while (1);
70800 +
70801 + memcpy(learn_buffer_user, learn_buffer, learn_buffer_len);
70802 + learn_buffer_user_len = learn_buffer_len;
70803 + retval = learn_buffer_len;
70804 + learn_buffer_len = 0;
70805 +
70806 + spin_unlock(&gr_learn_lock);
70807 +
70808 + if (copy_to_user(buf, learn_buffer_user, learn_buffer_user_len))
70809 + retval = -EFAULT;
70810 +
70811 + mutex_unlock(&gr_learn_user_mutex);
70812 +out:
70813 + set_current_state(TASK_RUNNING);
70814 + remove_wait_queue(&learn_wait, &wait);
70815 + return retval;
70816 +}
70817 +
70818 +static unsigned int
70819 +poll_learn(struct file * file, poll_table * wait)
70820 +{
70821 + poll_wait(file, &learn_wait, wait);
70822 +
70823 + if (learn_buffer_len)
70824 + return (POLLIN | POLLRDNORM);
70825 +
70826 + return 0;
70827 +}
70828 +
70829 +void
70830 +gr_clear_learn_entries(void)
70831 +{
70832 + char *tmp;
70833 +
70834 + mutex_lock(&gr_learn_user_mutex);
70835 + spin_lock(&gr_learn_lock);
70836 + tmp = learn_buffer;
70837 + learn_buffer = NULL;
70838 + spin_unlock(&gr_learn_lock);
70839 + if (tmp)
70840 + vfree(tmp);
70841 + if (learn_buffer_user != NULL) {
70842 + vfree(learn_buffer_user);
70843 + learn_buffer_user = NULL;
70844 + }
70845 + learn_buffer_len = 0;
70846 + mutex_unlock(&gr_learn_user_mutex);
70847 +
70848 + return;
70849 +}
70850 +
70851 +void
70852 +gr_add_learn_entry(const char *fmt, ...)
70853 +{
70854 + va_list args;
70855 + unsigned int len;
70856 +
70857 + if (!gr_learn_attached)
70858 + return;
70859 +
70860 + spin_lock(&gr_learn_lock);
70861 +
70862 + /* leave a gap at the end so we know when it's "full" but don't have to
70863 + compute the exact length of the string we're trying to append
70864 + */
70865 + if (learn_buffer_len > LEARN_BUFFER_SIZE - 16384) {
70866 + spin_unlock(&gr_learn_lock);
70867 + wake_up_interruptible(&learn_wait);
70868 + return;
70869 + }
70870 + if (learn_buffer == NULL) {
70871 + spin_unlock(&gr_learn_lock);
70872 + return;
70873 + }
70874 +
70875 + va_start(args, fmt);
70876 + len = vsnprintf(learn_buffer + learn_buffer_len, LEARN_BUFFER_SIZE - learn_buffer_len, fmt, args);
70877 + va_end(args);
70878 +
70879 + learn_buffer_len += len + 1;
70880 +
70881 + spin_unlock(&gr_learn_lock);
70882 + wake_up_interruptible(&learn_wait);
70883 +
70884 + return;
70885 +}
70886 +
70887 +static int
70888 +open_learn(struct inode *inode, struct file *file)
70889 +{
70890 + if (file->f_mode & FMODE_READ && gr_learn_attached)
70891 + return -EBUSY;
70892 + if (file->f_mode & FMODE_READ) {
70893 + int retval = 0;
70894 + mutex_lock(&gr_learn_user_mutex);
70895 + if (learn_buffer == NULL)
70896 + learn_buffer = vmalloc(LEARN_BUFFER_SIZE);
70897 + if (learn_buffer_user == NULL)
70898 + learn_buffer_user = vmalloc(LEARN_BUFFER_SIZE);
70899 + if (learn_buffer == NULL) {
70900 + retval = -ENOMEM;
70901 + goto out_error;
70902 + }
70903 + if (learn_buffer_user == NULL) {
70904 + retval = -ENOMEM;
70905 + goto out_error;
70906 + }
70907 + learn_buffer_len = 0;
70908 + learn_buffer_user_len = 0;
70909 + gr_learn_attached = 1;
70910 +out_error:
70911 + mutex_unlock(&gr_learn_user_mutex);
70912 + return retval;
70913 + }
70914 + return 0;
70915 +}
70916 +
70917 +static int
70918 +close_learn(struct inode *inode, struct file *file)
70919 +{
70920 + if (file->f_mode & FMODE_READ) {
70921 + char *tmp = NULL;
70922 + mutex_lock(&gr_learn_user_mutex);
70923 + spin_lock(&gr_learn_lock);
70924 + tmp = learn_buffer;
70925 + learn_buffer = NULL;
70926 + spin_unlock(&gr_learn_lock);
70927 + if (tmp)
70928 + vfree(tmp);
70929 + if (learn_buffer_user != NULL) {
70930 + vfree(learn_buffer_user);
70931 + learn_buffer_user = NULL;
70932 + }
70933 + learn_buffer_len = 0;
70934 + learn_buffer_user_len = 0;
70935 + gr_learn_attached = 0;
70936 + mutex_unlock(&gr_learn_user_mutex);
70937 + }
70938 +
70939 + return 0;
70940 +}
70941 +
70942 +const struct file_operations grsec_fops = {
70943 + .read = read_learn,
70944 + .write = write_grsec_handler,
70945 + .open = open_learn,
70946 + .release = close_learn,
70947 + .poll = poll_learn,
70948 +};
70949 diff --git a/grsecurity/gracl_policy.c b/grsecurity/gracl_policy.c
70950 new file mode 100644
70951 index 0000000..361a099
70952 --- /dev/null
70953 +++ b/grsecurity/gracl_policy.c
70954 @@ -0,0 +1,1782 @@
70955 +#include <linux/kernel.h>
70956 +#include <linux/module.h>
70957 +#include <linux/sched.h>
70958 +#include <linux/mm.h>
70959 +#include <linux/file.h>
70960 +#include <linux/fs.h>
70961 +#include <linux/namei.h>
70962 +#include <linux/mount.h>
70963 +#include <linux/tty.h>
70964 +#include <linux/proc_fs.h>
70965 +#include <linux/lglock.h>
70966 +#include <linux/slab.h>
70967 +#include <linux/vmalloc.h>
70968 +#include <linux/types.h>
70969 +#include <linux/sysctl.h>
70970 +#include <linux/netdevice.h>
70971 +#include <linux/ptrace.h>
70972 +#include <linux/gracl.h>
70973 +#include <linux/gralloc.h>
70974 +#include <linux/security.h>
70975 +#include <linux/grinternal.h>
70976 +#include <linux/pid_namespace.h>
70977 +#include <linux/stop_machine.h>
70978 +#include <linux/fdtable.h>
70979 +#include <linux/percpu.h>
70980 +#include <linux/lglock.h>
70981 +#include <linux/hugetlb.h>
70982 +#include <linux/posix-timers.h>
70983 +#include "../fs/mount.h"
70984 +
70985 +#include <asm/uaccess.h>
70986 +#include <asm/errno.h>
70987 +#include <asm/mman.h>
70988 +
70989 +extern struct gr_policy_state *polstate;
70990 +
70991 +#define FOR_EACH_ROLE_START(role) \
70992 + role = polstate->role_list; \
70993 + while (role) {
70994 +
70995 +#define FOR_EACH_ROLE_END(role) \
70996 + role = role->prev; \
70997 + }
70998 +
70999 +struct path gr_real_root;
71000 +
71001 +extern struct gr_alloc_state *current_alloc_state;
71002 +
71003 +u16 acl_sp_role_value;
71004 +
71005 +static DEFINE_MUTEX(gr_dev_mutex);
71006 +
71007 +extern int chkpw(struct gr_arg *entry, unsigned char *salt, unsigned char *sum);
71008 +extern void gr_clear_learn_entries(void);
71009 +
71010 +static struct gr_arg gr_usermode;
71011 +static unsigned char gr_system_salt[GR_SALT_LEN];
71012 +static unsigned char gr_system_sum[GR_SHA_LEN];
71013 +
71014 +static unsigned int gr_auth_attempts = 0;
71015 +static unsigned long gr_auth_expires = 0UL;
71016 +
71017 +struct acl_object_label *fakefs_obj_rw;
71018 +struct acl_object_label *fakefs_obj_rwx;
71019 +
71020 +extern int gr_init_uidset(void);
71021 +extern void gr_free_uidset(void);
71022 +extern void gr_remove_uid(uid_t uid);
71023 +extern int gr_find_uid(uid_t uid);
71024 +
71025 +extern struct acl_subject_label *__gr_get_subject_for_task(const struct gr_policy_state *state, struct task_struct *task, const char *filename);
71026 +extern void __gr_apply_subject_to_task(struct gr_policy_state *state, struct task_struct *task, struct acl_subject_label *subj);
71027 +extern int gr_streq(const char *a, const char *b, const unsigned int lena, const unsigned int lenb);
71028 +extern void __insert_inodev_entry(const struct gr_policy_state *state, struct inodev_entry *entry);
71029 +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);
71030 +extern void insert_acl_obj_label(struct acl_object_label *obj, struct acl_subject_label *subj);
71031 +extern void insert_acl_subj_label(struct acl_subject_label *obj, struct acl_role_label *role);
71032 +extern struct name_entry * __lookup_name_entry(const struct gr_policy_state *state, const char *name);
71033 +extern char *gr_to_filename_rbac(const struct dentry *dentry, const struct vfsmount *mnt);
71034 +extern struct acl_subject_label *lookup_acl_subj_label(const ino_t ino, const dev_t dev, const struct acl_role_label *role);
71035 +extern struct acl_subject_label *lookup_acl_subj_label_deleted(const ino_t ino, const dev_t dev, const struct acl_role_label *role);
71036 +extern void assign_special_role(const char *rolename);
71037 +extern struct acl_subject_label *chk_subj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt, const struct acl_role_label *role);
71038 +extern int gr_rbac_disable(void *unused);
71039 +extern void gr_enable_rbac_system(void);
71040 +
71041 +static int copy_acl_object_label_normal(struct acl_object_label *obj, const struct acl_object_label *userp)
71042 +{
71043 + if (copy_from_user(obj, userp, sizeof(struct acl_object_label)))
71044 + return -EFAULT;
71045 +
71046 + return 0;
71047 +}
71048 +
71049 +static int copy_acl_ip_label_normal(struct acl_ip_label *ip, const struct acl_ip_label *userp)
71050 +{
71051 + if (copy_from_user(ip, userp, sizeof(struct acl_ip_label)))
71052 + return -EFAULT;
71053 +
71054 + return 0;
71055 +}
71056 +
71057 +static int copy_acl_subject_label_normal(struct acl_subject_label *subj, const struct acl_subject_label *userp)
71058 +{
71059 + if (copy_from_user(subj, userp, sizeof(struct acl_subject_label)))
71060 + return -EFAULT;
71061 +
71062 + return 0;
71063 +}
71064 +
71065 +static int copy_acl_role_label_normal(struct acl_role_label *role, const struct acl_role_label *userp)
71066 +{
71067 + if (copy_from_user(role, userp, sizeof(struct acl_role_label)))
71068 + return -EFAULT;
71069 +
71070 + return 0;
71071 +}
71072 +
71073 +static int copy_role_allowed_ip_normal(struct role_allowed_ip *roleip, const struct role_allowed_ip *userp)
71074 +{
71075 + if (copy_from_user(roleip, userp, sizeof(struct role_allowed_ip)))
71076 + return -EFAULT;
71077 +
71078 + return 0;
71079 +}
71080 +
71081 +static int copy_sprole_pw_normal(struct sprole_pw *pw, unsigned long idx, const struct sprole_pw *userp)
71082 +{
71083 + if (copy_from_user(pw, userp + idx, sizeof(struct sprole_pw)))
71084 + return -EFAULT;
71085 +
71086 + return 0;
71087 +}
71088 +
71089 +static int copy_gr_hash_struct_normal(struct gr_hash_struct *hash, const struct gr_hash_struct *userp)
71090 +{
71091 + if (copy_from_user(hash, userp, sizeof(struct gr_hash_struct)))
71092 + return -EFAULT;
71093 +
71094 + return 0;
71095 +}
71096 +
71097 +static int copy_role_transition_normal(struct role_transition *trans, const struct role_transition *userp)
71098 +{
71099 + if (copy_from_user(trans, userp, sizeof(struct role_transition)))
71100 + return -EFAULT;
71101 +
71102 + return 0;
71103 +}
71104 +
71105 +int copy_pointer_from_array_normal(void *ptr, unsigned long idx, const void *userp)
71106 +{
71107 + if (copy_from_user(ptr, userp + (idx * sizeof(void *)), sizeof(void *)))
71108 + return -EFAULT;
71109 +
71110 + return 0;
71111 +}
71112 +
71113 +static int copy_gr_arg_wrapper_normal(const char __user *buf, struct gr_arg_wrapper *uwrap)
71114 +{
71115 + if (copy_from_user(uwrap, buf, sizeof (struct gr_arg_wrapper)))
71116 + return -EFAULT;
71117 +
71118 + if (((uwrap->version != GRSECURITY_VERSION) &&
71119 + (uwrap->version != 0x2901)) ||
71120 + (uwrap->size != sizeof(struct gr_arg)))
71121 + return -EINVAL;
71122 +
71123 + return 0;
71124 +}
71125 +
71126 +static int copy_gr_arg_normal(const struct gr_arg __user *buf, struct gr_arg *arg)
71127 +{
71128 + if (copy_from_user(arg, buf, sizeof (struct gr_arg)))
71129 + return -EFAULT;
71130 +
71131 + return 0;
71132 +}
71133 +
71134 +static size_t get_gr_arg_wrapper_size_normal(void)
71135 +{
71136 + return sizeof(struct gr_arg_wrapper);
71137 +}
71138 +
71139 +#ifdef CONFIG_COMPAT
71140 +extern int copy_gr_arg_wrapper_compat(const char *buf, struct gr_arg_wrapper *uwrap);
71141 +extern int copy_gr_arg_compat(const struct gr_arg __user *buf, struct gr_arg *arg);
71142 +extern int copy_acl_object_label_compat(struct acl_object_label *obj, const struct acl_object_label *userp);
71143 +extern int copy_acl_subject_label_compat(struct acl_subject_label *subj, const struct acl_subject_label *userp);
71144 +extern int copy_acl_role_label_compat(struct acl_role_label *role, const struct acl_role_label *userp);
71145 +extern int copy_role_allowed_ip_compat(struct role_allowed_ip *roleip, const struct role_allowed_ip *userp);
71146 +extern int copy_role_transition_compat(struct role_transition *trans, const struct role_transition *userp);
71147 +extern int copy_gr_hash_struct_compat(struct gr_hash_struct *hash, const struct gr_hash_struct *userp);
71148 +extern int copy_pointer_from_array_compat(void *ptr, unsigned long idx, const void *userp);
71149 +extern int copy_acl_ip_label_compat(struct acl_ip_label *ip, const struct acl_ip_label *userp);
71150 +extern int copy_sprole_pw_compat(struct sprole_pw *pw, unsigned long idx, const struct sprole_pw *userp);
71151 +extern size_t get_gr_arg_wrapper_size_compat(void);
71152 +
71153 +int (* copy_gr_arg_wrapper)(const char *buf, struct gr_arg_wrapper *uwrap) __read_only;
71154 +int (* copy_gr_arg)(const struct gr_arg *buf, struct gr_arg *arg) __read_only;
71155 +int (* copy_acl_object_label)(struct acl_object_label *obj, const struct acl_object_label *userp) __read_only;
71156 +int (* copy_acl_subject_label)(struct acl_subject_label *subj, const struct acl_subject_label *userp) __read_only;
71157 +int (* copy_acl_role_label)(struct acl_role_label *role, const struct acl_role_label *userp) __read_only;
71158 +int (* copy_acl_ip_label)(struct acl_ip_label *ip, const struct acl_ip_label *userp) __read_only;
71159 +int (* copy_pointer_from_array)(void *ptr, unsigned long idx, const void *userp) __read_only;
71160 +int (* copy_sprole_pw)(struct sprole_pw *pw, unsigned long idx, const struct sprole_pw *userp) __read_only;
71161 +int (* copy_gr_hash_struct)(struct gr_hash_struct *hash, const struct gr_hash_struct *userp) __read_only;
71162 +int (* copy_role_transition)(struct role_transition *trans, const struct role_transition *userp) __read_only;
71163 +int (* copy_role_allowed_ip)(struct role_allowed_ip *roleip, const struct role_allowed_ip *userp) __read_only;
71164 +size_t (* get_gr_arg_wrapper_size)(void) __read_only;
71165 +
71166 +#else
71167 +#define copy_gr_arg_wrapper copy_gr_arg_wrapper_normal
71168 +#define copy_gr_arg copy_gr_arg_normal
71169 +#define copy_gr_hash_struct copy_gr_hash_struct_normal
71170 +#define copy_acl_object_label copy_acl_object_label_normal
71171 +#define copy_acl_subject_label copy_acl_subject_label_normal
71172 +#define copy_acl_role_label copy_acl_role_label_normal
71173 +#define copy_acl_ip_label copy_acl_ip_label_normal
71174 +#define copy_pointer_from_array copy_pointer_from_array_normal
71175 +#define copy_sprole_pw copy_sprole_pw_normal
71176 +#define copy_role_transition copy_role_transition_normal
71177 +#define copy_role_allowed_ip copy_role_allowed_ip_normal
71178 +#define get_gr_arg_wrapper_size get_gr_arg_wrapper_size_normal
71179 +#endif
71180 +
71181 +static struct acl_subject_label *
71182 +lookup_subject_map(const struct acl_subject_label *userp)
71183 +{
71184 + unsigned int index = gr_shash(userp, polstate->subj_map_set.s_size);
71185 + struct subject_map *match;
71186 +
71187 + match = polstate->subj_map_set.s_hash[index];
71188 +
71189 + while (match && match->user != userp)
71190 + match = match->next;
71191 +
71192 + if (match != NULL)
71193 + return match->kernel;
71194 + else
71195 + return NULL;
71196 +}
71197 +
71198 +static void
71199 +insert_subj_map_entry(struct subject_map *subjmap)
71200 +{
71201 + unsigned int index = gr_shash(subjmap->user, polstate->subj_map_set.s_size);
71202 + struct subject_map **curr;
71203 +
71204 + subjmap->prev = NULL;
71205 +
71206 + curr = &polstate->subj_map_set.s_hash[index];
71207 + if (*curr != NULL)
71208 + (*curr)->prev = subjmap;
71209 +
71210 + subjmap->next = *curr;
71211 + *curr = subjmap;
71212 +
71213 + return;
71214 +}
71215 +
71216 +static void
71217 +__insert_acl_role_label(struct acl_role_label *role, uid_t uidgid)
71218 +{
71219 + unsigned int index =
71220 + gr_rhash(uidgid, role->roletype & (GR_ROLE_USER | GR_ROLE_GROUP), polstate->acl_role_set.r_size);
71221 + struct acl_role_label **curr;
71222 + struct acl_role_label *tmp, *tmp2;
71223 +
71224 + curr = &polstate->acl_role_set.r_hash[index];
71225 +
71226 + /* simple case, slot is empty, just set it to our role */
71227 + if (*curr == NULL) {
71228 + *curr = role;
71229 + } else {
71230 + /* example:
71231 + 1 -> 2 -> 3 (adding 2 -> 3 to here)
71232 + 2 -> 3
71233 + */
71234 + /* first check to see if we can already be reached via this slot */
71235 + tmp = *curr;
71236 + while (tmp && tmp != role)
71237 + tmp = tmp->next;
71238 + if (tmp == role) {
71239 + /* we don't need to add ourselves to this slot's chain */
71240 + return;
71241 + }
71242 + /* we need to add ourselves to this chain, two cases */
71243 + if (role->next == NULL) {
71244 + /* simple case, append the current chain to our role */
71245 + role->next = *curr;
71246 + *curr = role;
71247 + } else {
71248 + /* 1 -> 2 -> 3 -> 4
71249 + 2 -> 3 -> 4
71250 + 3 -> 4 (adding 1 -> 2 -> 3 -> 4 to here)
71251 + */
71252 + /* trickier case: walk our role's chain until we find
71253 + the role for the start of the current slot's chain */
71254 + tmp = role;
71255 + tmp2 = *curr;
71256 + while (tmp->next && tmp->next != tmp2)
71257 + tmp = tmp->next;
71258 + if (tmp->next == tmp2) {
71259 + /* from example above, we found 3, so just
71260 + replace this slot's chain with ours */
71261 + *curr = role;
71262 + } else {
71263 + /* we didn't find a subset of our role's chain
71264 + in the current slot's chain, so append their
71265 + chain to ours, and set us as the first role in
71266 + the slot's chain
71267 +
71268 + we could fold this case with the case above,
71269 + but making it explicit for clarity
71270 + */
71271 + tmp->next = tmp2;
71272 + *curr = role;
71273 + }
71274 + }
71275 + }
71276 +
71277 + return;
71278 +}
71279 +
71280 +static void
71281 +insert_acl_role_label(struct acl_role_label *role)
71282 +{
71283 + int i;
71284 +
71285 + if (polstate->role_list == NULL) {
71286 + polstate->role_list = role;
71287 + role->prev = NULL;
71288 + } else {
71289 + role->prev = polstate->role_list;
71290 + polstate->role_list = role;
71291 + }
71292 +
71293 + /* used for hash chains */
71294 + role->next = NULL;
71295 +
71296 + if (role->roletype & GR_ROLE_DOMAIN) {
71297 + for (i = 0; i < role->domain_child_num; i++)
71298 + __insert_acl_role_label(role, role->domain_children[i]);
71299 + } else
71300 + __insert_acl_role_label(role, role->uidgid);
71301 +}
71302 +
71303 +static int
71304 +insert_name_entry(char *name, const ino_t inode, const dev_t device, __u8 deleted)
71305 +{
71306 + struct name_entry **curr, *nentry;
71307 + struct inodev_entry *ientry;
71308 + unsigned int len = strlen(name);
71309 + unsigned int key = full_name_hash(name, len);
71310 + unsigned int index = key % polstate->name_set.n_size;
71311 +
71312 + curr = &polstate->name_set.n_hash[index];
71313 +
71314 + while (*curr && ((*curr)->key != key || !gr_streq((*curr)->name, name, (*curr)->len, len)))
71315 + curr = &((*curr)->next);
71316 +
71317 + if (*curr != NULL)
71318 + return 1;
71319 +
71320 + nentry = acl_alloc(sizeof (struct name_entry));
71321 + if (nentry == NULL)
71322 + return 0;
71323 + ientry = acl_alloc(sizeof (struct inodev_entry));
71324 + if (ientry == NULL)
71325 + return 0;
71326 + ientry->nentry = nentry;
71327 +
71328 + nentry->key = key;
71329 + nentry->name = name;
71330 + nentry->inode = inode;
71331 + nentry->device = device;
71332 + nentry->len = len;
71333 + nentry->deleted = deleted;
71334 +
71335 + nentry->prev = NULL;
71336 + curr = &polstate->name_set.n_hash[index];
71337 + if (*curr != NULL)
71338 + (*curr)->prev = nentry;
71339 + nentry->next = *curr;
71340 + *curr = nentry;
71341 +
71342 + /* insert us into the table searchable by inode/dev */
71343 + __insert_inodev_entry(polstate, ientry);
71344 +
71345 + return 1;
71346 +}
71347 +
71348 +/* allocating chained hash tables, so optimal size is where lambda ~ 1 */
71349 +
71350 +static void *
71351 +create_table(__u32 * len, int elementsize)
71352 +{
71353 + unsigned int table_sizes[] = {
71354 + 7, 13, 31, 61, 127, 251, 509, 1021, 2039, 4093, 8191, 16381,
71355 + 32749, 65521, 131071, 262139, 524287, 1048573, 2097143,
71356 + 4194301, 8388593, 16777213, 33554393, 67108859
71357 + };
71358 + void *newtable = NULL;
71359 + unsigned int pwr = 0;
71360 +
71361 + while ((pwr < ((sizeof (table_sizes) / sizeof (table_sizes[0])) - 1)) &&
71362 + table_sizes[pwr] <= *len)
71363 + pwr++;
71364 +
71365 + if (table_sizes[pwr] <= *len || (table_sizes[pwr] > ULONG_MAX / elementsize))
71366 + return newtable;
71367 +
71368 + if ((table_sizes[pwr] * elementsize) <= PAGE_SIZE)
71369 + newtable =
71370 + kmalloc(table_sizes[pwr] * elementsize, GFP_KERNEL);
71371 + else
71372 + newtable = vmalloc(table_sizes[pwr] * elementsize);
71373 +
71374 + *len = table_sizes[pwr];
71375 +
71376 + return newtable;
71377 +}
71378 +
71379 +static int
71380 +init_variables(const struct gr_arg *arg, bool reload)
71381 +{
71382 + struct task_struct *reaper = init_pid_ns.child_reaper;
71383 + unsigned int stacksize;
71384 +
71385 + polstate->subj_map_set.s_size = arg->role_db.num_subjects;
71386 + polstate->acl_role_set.r_size = arg->role_db.num_roles + arg->role_db.num_domain_children;
71387 + polstate->name_set.n_size = arg->role_db.num_objects;
71388 + polstate->inodev_set.i_size = arg->role_db.num_objects;
71389 +
71390 + if (!polstate->subj_map_set.s_size || !polstate->acl_role_set.r_size ||
71391 + !polstate->name_set.n_size || !polstate->inodev_set.i_size)
71392 + return 1;
71393 +
71394 + if (!reload) {
71395 + if (!gr_init_uidset())
71396 + return 1;
71397 + }
71398 +
71399 + /* set up the stack that holds allocation info */
71400 +
71401 + stacksize = arg->role_db.num_pointers + 5;
71402 +
71403 + if (!acl_alloc_stack_init(stacksize))
71404 + return 1;
71405 +
71406 + if (!reload) {
71407 + /* grab reference for the real root dentry and vfsmount */
71408 + get_fs_root(reaper->fs, &gr_real_root);
71409 +
71410 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
71411 + 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);
71412 +#endif
71413 +
71414 + fakefs_obj_rw = kzalloc(sizeof(struct acl_object_label), GFP_KERNEL);
71415 + if (fakefs_obj_rw == NULL)
71416 + return 1;
71417 + fakefs_obj_rw->mode = GR_FIND | GR_READ | GR_WRITE;
71418 +
71419 + fakefs_obj_rwx = kzalloc(sizeof(struct acl_object_label), GFP_KERNEL);
71420 + if (fakefs_obj_rwx == NULL)
71421 + return 1;
71422 + fakefs_obj_rwx->mode = GR_FIND | GR_READ | GR_WRITE | GR_EXEC;
71423 + }
71424 +
71425 + polstate->subj_map_set.s_hash =
71426 + (struct subject_map **) create_table(&polstate->subj_map_set.s_size, sizeof(void *));
71427 + polstate->acl_role_set.r_hash =
71428 + (struct acl_role_label **) create_table(&polstate->acl_role_set.r_size, sizeof(void *));
71429 + polstate->name_set.n_hash = (struct name_entry **) create_table(&polstate->name_set.n_size, sizeof(void *));
71430 + polstate->inodev_set.i_hash =
71431 + (struct inodev_entry **) create_table(&polstate->inodev_set.i_size, sizeof(void *));
71432 +
71433 + if (!polstate->subj_map_set.s_hash || !polstate->acl_role_set.r_hash ||
71434 + !polstate->name_set.n_hash || !polstate->inodev_set.i_hash)
71435 + return 1;
71436 +
71437 + memset(polstate->subj_map_set.s_hash, 0,
71438 + sizeof(struct subject_map *) * polstate->subj_map_set.s_size);
71439 + memset(polstate->acl_role_set.r_hash, 0,
71440 + sizeof (struct acl_role_label *) * polstate->acl_role_set.r_size);
71441 + memset(polstate->name_set.n_hash, 0,
71442 + sizeof (struct name_entry *) * polstate->name_set.n_size);
71443 + memset(polstate->inodev_set.i_hash, 0,
71444 + sizeof (struct inodev_entry *) * polstate->inodev_set.i_size);
71445 +
71446 + return 0;
71447 +}
71448 +
71449 +/* free information not needed after startup
71450 + currently contains user->kernel pointer mappings for subjects
71451 +*/
71452 +
71453 +static void
71454 +free_init_variables(void)
71455 +{
71456 + __u32 i;
71457 +
71458 + if (polstate->subj_map_set.s_hash) {
71459 + for (i = 0; i < polstate->subj_map_set.s_size; i++) {
71460 + if (polstate->subj_map_set.s_hash[i]) {
71461 + kfree(polstate->subj_map_set.s_hash[i]);
71462 + polstate->subj_map_set.s_hash[i] = NULL;
71463 + }
71464 + }
71465 +
71466 + if ((polstate->subj_map_set.s_size * sizeof (struct subject_map *)) <=
71467 + PAGE_SIZE)
71468 + kfree(polstate->subj_map_set.s_hash);
71469 + else
71470 + vfree(polstate->subj_map_set.s_hash);
71471 + }
71472 +
71473 + return;
71474 +}
71475 +
71476 +static void
71477 +free_variables(bool reload)
71478 +{
71479 + struct acl_subject_label *s;
71480 + struct acl_role_label *r;
71481 + struct task_struct *task, *task2;
71482 + unsigned int x;
71483 +
71484 + if (!reload) {
71485 + gr_clear_learn_entries();
71486 +
71487 + read_lock(&tasklist_lock);
71488 + do_each_thread(task2, task) {
71489 + task->acl_sp_role = 0;
71490 + task->acl_role_id = 0;
71491 + task->inherited = 0;
71492 + task->acl = NULL;
71493 + task->role = NULL;
71494 + } while_each_thread(task2, task);
71495 + read_unlock(&tasklist_lock);
71496 +
71497 + kfree(fakefs_obj_rw);
71498 + fakefs_obj_rw = NULL;
71499 + kfree(fakefs_obj_rwx);
71500 + fakefs_obj_rwx = NULL;
71501 +
71502 + /* release the reference to the real root dentry and vfsmount */
71503 + path_put(&gr_real_root);
71504 + memset(&gr_real_root, 0, sizeof(gr_real_root));
71505 + }
71506 +
71507 + /* free all object hash tables */
71508 +
71509 + FOR_EACH_ROLE_START(r)
71510 + if (r->subj_hash == NULL)
71511 + goto next_role;
71512 + FOR_EACH_SUBJECT_START(r, s, x)
71513 + if (s->obj_hash == NULL)
71514 + break;
71515 + if ((s->obj_hash_size * sizeof (struct acl_object_label *)) <= PAGE_SIZE)
71516 + kfree(s->obj_hash);
71517 + else
71518 + vfree(s->obj_hash);
71519 + FOR_EACH_SUBJECT_END(s, x)
71520 + FOR_EACH_NESTED_SUBJECT_START(r, s)
71521 + if (s->obj_hash == NULL)
71522 + break;
71523 + if ((s->obj_hash_size * sizeof (struct acl_object_label *)) <= PAGE_SIZE)
71524 + kfree(s->obj_hash);
71525 + else
71526 + vfree(s->obj_hash);
71527 + FOR_EACH_NESTED_SUBJECT_END(s)
71528 + if ((r->subj_hash_size * sizeof (struct acl_subject_label *)) <= PAGE_SIZE)
71529 + kfree(r->subj_hash);
71530 + else
71531 + vfree(r->subj_hash);
71532 + r->subj_hash = NULL;
71533 +next_role:
71534 + FOR_EACH_ROLE_END(r)
71535 +
71536 + acl_free_all();
71537 +
71538 + if (polstate->acl_role_set.r_hash) {
71539 + if ((polstate->acl_role_set.r_size * sizeof (struct acl_role_label *)) <=
71540 + PAGE_SIZE)
71541 + kfree(polstate->acl_role_set.r_hash);
71542 + else
71543 + vfree(polstate->acl_role_set.r_hash);
71544 + }
71545 + if (polstate->name_set.n_hash) {
71546 + if ((polstate->name_set.n_size * sizeof (struct name_entry *)) <=
71547 + PAGE_SIZE)
71548 + kfree(polstate->name_set.n_hash);
71549 + else
71550 + vfree(polstate->name_set.n_hash);
71551 + }
71552 +
71553 + if (polstate->inodev_set.i_hash) {
71554 + if ((polstate->inodev_set.i_size * sizeof (struct inodev_entry *)) <=
71555 + PAGE_SIZE)
71556 + kfree(polstate->inodev_set.i_hash);
71557 + else
71558 + vfree(polstate->inodev_set.i_hash);
71559 + }
71560 +
71561 + if (!reload)
71562 + gr_free_uidset();
71563 +
71564 + memset(&polstate->name_set, 0, sizeof (struct name_db));
71565 + memset(&polstate->inodev_set, 0, sizeof (struct inodev_db));
71566 + memset(&polstate->acl_role_set, 0, sizeof (struct acl_role_db));
71567 + memset(&polstate->subj_map_set, 0, sizeof (struct acl_subj_map_db));
71568 +
71569 + polstate->default_role = NULL;
71570 + polstate->kernel_role = NULL;
71571 + polstate->role_list = NULL;
71572 +
71573 + return;
71574 +}
71575 +
71576 +static struct acl_subject_label *
71577 +do_copy_user_subj(struct acl_subject_label *userp, struct acl_role_label *role, int *already_copied);
71578 +
71579 +static int alloc_and_copy_string(char **name, unsigned int maxlen)
71580 +{
71581 + unsigned int len = strnlen_user(*name, maxlen);
71582 + char *tmp;
71583 +
71584 + if (!len || len >= maxlen)
71585 + return -EINVAL;
71586 +
71587 + if ((tmp = (char *) acl_alloc(len)) == NULL)
71588 + return -ENOMEM;
71589 +
71590 + if (copy_from_user(tmp, *name, len))
71591 + return -EFAULT;
71592 +
71593 + tmp[len-1] = '\0';
71594 + *name = tmp;
71595 +
71596 + return 0;
71597 +}
71598 +
71599 +static int
71600 +copy_user_glob(struct acl_object_label *obj)
71601 +{
71602 + struct acl_object_label *g_tmp, **guser;
71603 + int error;
71604 +
71605 + if (obj->globbed == NULL)
71606 + return 0;
71607 +
71608 + guser = &obj->globbed;
71609 + while (*guser) {
71610 + g_tmp = (struct acl_object_label *)
71611 + acl_alloc(sizeof (struct acl_object_label));
71612 + if (g_tmp == NULL)
71613 + return -ENOMEM;
71614 +
71615 + if (copy_acl_object_label(g_tmp, *guser))
71616 + return -EFAULT;
71617 +
71618 + error = alloc_and_copy_string(&g_tmp->filename, PATH_MAX);
71619 + if (error)
71620 + return error;
71621 +
71622 + *guser = g_tmp;
71623 + guser = &(g_tmp->next);
71624 + }
71625 +
71626 + return 0;
71627 +}
71628 +
71629 +static int
71630 +copy_user_objs(struct acl_object_label *userp, struct acl_subject_label *subj,
71631 + struct acl_role_label *role)
71632 +{
71633 + struct acl_object_label *o_tmp;
71634 + int ret;
71635 +
71636 + while (userp) {
71637 + if ((o_tmp = (struct acl_object_label *)
71638 + acl_alloc(sizeof (struct acl_object_label))) == NULL)
71639 + return -ENOMEM;
71640 +
71641 + if (copy_acl_object_label(o_tmp, userp))
71642 + return -EFAULT;
71643 +
71644 + userp = o_tmp->prev;
71645 +
71646 + ret = alloc_and_copy_string(&o_tmp->filename, PATH_MAX);
71647 + if (ret)
71648 + return ret;
71649 +
71650 + insert_acl_obj_label(o_tmp, subj);
71651 + if (!insert_name_entry(o_tmp->filename, o_tmp->inode,
71652 + o_tmp->device, (o_tmp->mode & GR_DELETED) ? 1 : 0))
71653 + return -ENOMEM;
71654 +
71655 + ret = copy_user_glob(o_tmp);
71656 + if (ret)
71657 + return ret;
71658 +
71659 + if (o_tmp->nested) {
71660 + int already_copied;
71661 +
71662 + o_tmp->nested = do_copy_user_subj(o_tmp->nested, role, &already_copied);
71663 + if (IS_ERR(o_tmp->nested))
71664 + return PTR_ERR(o_tmp->nested);
71665 +
71666 + /* insert into nested subject list if we haven't copied this one yet
71667 + to prevent duplicate entries */
71668 + if (!already_copied) {
71669 + o_tmp->nested->next = role->hash->first;
71670 + role->hash->first = o_tmp->nested;
71671 + }
71672 + }
71673 + }
71674 +
71675 + return 0;
71676 +}
71677 +
71678 +static __u32
71679 +count_user_subjs(struct acl_subject_label *userp)
71680 +{
71681 + struct acl_subject_label s_tmp;
71682 + __u32 num = 0;
71683 +
71684 + while (userp) {
71685 + if (copy_acl_subject_label(&s_tmp, userp))
71686 + break;
71687 +
71688 + userp = s_tmp.prev;
71689 + }
71690 +
71691 + return num;
71692 +}
71693 +
71694 +static int
71695 +copy_user_allowedips(struct acl_role_label *rolep)
71696 +{
71697 + struct role_allowed_ip *ruserip, *rtmp = NULL, *rlast;
71698 +
71699 + ruserip = rolep->allowed_ips;
71700 +
71701 + while (ruserip) {
71702 + rlast = rtmp;
71703 +
71704 + if ((rtmp = (struct role_allowed_ip *)
71705 + acl_alloc(sizeof (struct role_allowed_ip))) == NULL)
71706 + return -ENOMEM;
71707 +
71708 + if (copy_role_allowed_ip(rtmp, ruserip))
71709 + return -EFAULT;
71710 +
71711 + ruserip = rtmp->prev;
71712 +
71713 + if (!rlast) {
71714 + rtmp->prev = NULL;
71715 + rolep->allowed_ips = rtmp;
71716 + } else {
71717 + rlast->next = rtmp;
71718 + rtmp->prev = rlast;
71719 + }
71720 +
71721 + if (!ruserip)
71722 + rtmp->next = NULL;
71723 + }
71724 +
71725 + return 0;
71726 +}
71727 +
71728 +static int
71729 +copy_user_transitions(struct acl_role_label *rolep)
71730 +{
71731 + struct role_transition *rusertp, *rtmp = NULL, *rlast;
71732 + int error;
71733 +
71734 + rusertp = rolep->transitions;
71735 +
71736 + while (rusertp) {
71737 + rlast = rtmp;
71738 +
71739 + if ((rtmp = (struct role_transition *)
71740 + acl_alloc(sizeof (struct role_transition))) == NULL)
71741 + return -ENOMEM;
71742 +
71743 + if (copy_role_transition(rtmp, rusertp))
71744 + return -EFAULT;
71745 +
71746 + rusertp = rtmp->prev;
71747 +
71748 + error = alloc_and_copy_string(&rtmp->rolename, GR_SPROLE_LEN);
71749 + if (error)
71750 + return error;
71751 +
71752 + if (!rlast) {
71753 + rtmp->prev = NULL;
71754 + rolep->transitions = rtmp;
71755 + } else {
71756 + rlast->next = rtmp;
71757 + rtmp->prev = rlast;
71758 + }
71759 +
71760 + if (!rusertp)
71761 + rtmp->next = NULL;
71762 + }
71763 +
71764 + return 0;
71765 +}
71766 +
71767 +static __u32 count_user_objs(const struct acl_object_label __user *userp)
71768 +{
71769 + struct acl_object_label o_tmp;
71770 + __u32 num = 0;
71771 +
71772 + while (userp) {
71773 + if (copy_acl_object_label(&o_tmp, userp))
71774 + break;
71775 +
71776 + userp = o_tmp.prev;
71777 + num++;
71778 + }
71779 +
71780 + return num;
71781 +}
71782 +
71783 +static struct acl_subject_label *
71784 +do_copy_user_subj(struct acl_subject_label *userp, struct acl_role_label *role, int *already_copied)
71785 +{
71786 + struct acl_subject_label *s_tmp = NULL, *s_tmp2;
71787 + __u32 num_objs;
71788 + struct acl_ip_label **i_tmp, *i_utmp2;
71789 + struct gr_hash_struct ghash;
71790 + struct subject_map *subjmap;
71791 + unsigned int i_num;
71792 + int err;
71793 +
71794 + if (already_copied != NULL)
71795 + *already_copied = 0;
71796 +
71797 + s_tmp = lookup_subject_map(userp);
71798 +
71799 + /* we've already copied this subject into the kernel, just return
71800 + the reference to it, and don't copy it over again
71801 + */
71802 + if (s_tmp) {
71803 + if (already_copied != NULL)
71804 + *already_copied = 1;
71805 + return(s_tmp);
71806 + }
71807 +
71808 + if ((s_tmp = (struct acl_subject_label *)
71809 + acl_alloc(sizeof (struct acl_subject_label))) == NULL)
71810 + return ERR_PTR(-ENOMEM);
71811 +
71812 + subjmap = (struct subject_map *)kmalloc(sizeof (struct subject_map), GFP_KERNEL);
71813 + if (subjmap == NULL)
71814 + return ERR_PTR(-ENOMEM);
71815 +
71816 + subjmap->user = userp;
71817 + subjmap->kernel = s_tmp;
71818 + insert_subj_map_entry(subjmap);
71819 +
71820 + if (copy_acl_subject_label(s_tmp, userp))
71821 + return ERR_PTR(-EFAULT);
71822 +
71823 + err = alloc_and_copy_string(&s_tmp->filename, PATH_MAX);
71824 + if (err)
71825 + return ERR_PTR(err);
71826 +
71827 + if (!strcmp(s_tmp->filename, "/"))
71828 + role->root_label = s_tmp;
71829 +
71830 + if (copy_gr_hash_struct(&ghash, s_tmp->hash))
71831 + return ERR_PTR(-EFAULT);
71832 +
71833 + /* copy user and group transition tables */
71834 +
71835 + if (s_tmp->user_trans_num) {
71836 + uid_t *uidlist;
71837 +
71838 + uidlist = (uid_t *)acl_alloc_num(s_tmp->user_trans_num, sizeof(uid_t));
71839 + if (uidlist == NULL)
71840 + return ERR_PTR(-ENOMEM);
71841 + if (copy_from_user(uidlist, s_tmp->user_transitions, s_tmp->user_trans_num * sizeof(uid_t)))
71842 + return ERR_PTR(-EFAULT);
71843 +
71844 + s_tmp->user_transitions = uidlist;
71845 + }
71846 +
71847 + if (s_tmp->group_trans_num) {
71848 + gid_t *gidlist;
71849 +
71850 + gidlist = (gid_t *)acl_alloc_num(s_tmp->group_trans_num, sizeof(gid_t));
71851 + if (gidlist == NULL)
71852 + return ERR_PTR(-ENOMEM);
71853 + if (copy_from_user(gidlist, s_tmp->group_transitions, s_tmp->group_trans_num * sizeof(gid_t)))
71854 + return ERR_PTR(-EFAULT);
71855 +
71856 + s_tmp->group_transitions = gidlist;
71857 + }
71858 +
71859 + /* set up object hash table */
71860 + num_objs = count_user_objs(ghash.first);
71861 +
71862 + s_tmp->obj_hash_size = num_objs;
71863 + s_tmp->obj_hash =
71864 + (struct acl_object_label **)
71865 + create_table(&(s_tmp->obj_hash_size), sizeof(void *));
71866 +
71867 + if (!s_tmp->obj_hash)
71868 + return ERR_PTR(-ENOMEM);
71869 +
71870 + memset(s_tmp->obj_hash, 0,
71871 + s_tmp->obj_hash_size *
71872 + sizeof (struct acl_object_label *));
71873 +
71874 + /* add in objects */
71875 + err = copy_user_objs(ghash.first, s_tmp, role);
71876 +
71877 + if (err)
71878 + return ERR_PTR(err);
71879 +
71880 + /* set pointer for parent subject */
71881 + if (s_tmp->parent_subject) {
71882 + s_tmp2 = do_copy_user_subj(s_tmp->parent_subject, role, NULL);
71883 +
71884 + if (IS_ERR(s_tmp2))
71885 + return s_tmp2;
71886 +
71887 + s_tmp->parent_subject = s_tmp2;
71888 + }
71889 +
71890 + /* add in ip acls */
71891 +
71892 + if (!s_tmp->ip_num) {
71893 + s_tmp->ips = NULL;
71894 + goto insert;
71895 + }
71896 +
71897 + i_tmp =
71898 + (struct acl_ip_label **) acl_alloc_num(s_tmp->ip_num,
71899 + sizeof (struct acl_ip_label *));
71900 +
71901 + if (!i_tmp)
71902 + return ERR_PTR(-ENOMEM);
71903 +
71904 + for (i_num = 0; i_num < s_tmp->ip_num; i_num++) {
71905 + *(i_tmp + i_num) =
71906 + (struct acl_ip_label *)
71907 + acl_alloc(sizeof (struct acl_ip_label));
71908 + if (!*(i_tmp + i_num))
71909 + return ERR_PTR(-ENOMEM);
71910 +
71911 + if (copy_pointer_from_array(&i_utmp2, i_num, s_tmp->ips))
71912 + return ERR_PTR(-EFAULT);
71913 +
71914 + if (copy_acl_ip_label(*(i_tmp + i_num), i_utmp2))
71915 + return ERR_PTR(-EFAULT);
71916 +
71917 + if ((*(i_tmp + i_num))->iface == NULL)
71918 + continue;
71919 +
71920 + err = alloc_and_copy_string(&(*(i_tmp + i_num))->iface, IFNAMSIZ);
71921 + if (err)
71922 + return ERR_PTR(err);
71923 + }
71924 +
71925 + s_tmp->ips = i_tmp;
71926 +
71927 +insert:
71928 + if (!insert_name_entry(s_tmp->filename, s_tmp->inode,
71929 + s_tmp->device, (s_tmp->mode & GR_DELETED) ? 1 : 0))
71930 + return ERR_PTR(-ENOMEM);
71931 +
71932 + return s_tmp;
71933 +}
71934 +
71935 +static int
71936 +copy_user_subjs(struct acl_subject_label *userp, struct acl_role_label *role)
71937 +{
71938 + struct acl_subject_label s_pre;
71939 + struct acl_subject_label * ret;
71940 + int err;
71941 +
71942 + while (userp) {
71943 + if (copy_acl_subject_label(&s_pre, userp))
71944 + return -EFAULT;
71945 +
71946 + ret = do_copy_user_subj(userp, role, NULL);
71947 +
71948 + err = PTR_ERR(ret);
71949 + if (IS_ERR(ret))
71950 + return err;
71951 +
71952 + insert_acl_subj_label(ret, role);
71953 +
71954 + userp = s_pre.prev;
71955 + }
71956 +
71957 + return 0;
71958 +}
71959 +
71960 +static int
71961 +copy_user_acl(struct gr_arg *arg)
71962 +{
71963 + struct acl_role_label *r_tmp = NULL, **r_utmp, *r_utmp2;
71964 + struct acl_subject_label *subj_list;
71965 + struct sprole_pw *sptmp;
71966 + struct gr_hash_struct *ghash;
71967 + uid_t *domainlist;
71968 + unsigned int r_num;
71969 + int err = 0;
71970 + __u16 i;
71971 + __u32 num_subjs;
71972 +
71973 + /* we need a default and kernel role */
71974 + if (arg->role_db.num_roles < 2)
71975 + return -EINVAL;
71976 +
71977 + /* copy special role authentication info from userspace */
71978 +
71979 + polstate->num_sprole_pws = arg->num_sprole_pws;
71980 + polstate->acl_special_roles = (struct sprole_pw **) acl_alloc_num(polstate->num_sprole_pws, sizeof(struct sprole_pw *));
71981 +
71982 + if (!polstate->acl_special_roles && polstate->num_sprole_pws)
71983 + return -ENOMEM;
71984 +
71985 + for (i = 0; i < polstate->num_sprole_pws; i++) {
71986 + sptmp = (struct sprole_pw *) acl_alloc(sizeof(struct sprole_pw));
71987 + if (!sptmp)
71988 + return -ENOMEM;
71989 + if (copy_sprole_pw(sptmp, i, arg->sprole_pws))
71990 + return -EFAULT;
71991 +
71992 + err = alloc_and_copy_string((char **)&sptmp->rolename, GR_SPROLE_LEN);
71993 + if (err)
71994 + return err;
71995 +
71996 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
71997 + printk(KERN_ALERT "Copying special role %s\n", sptmp->rolename);
71998 +#endif
71999 +
72000 + polstate->acl_special_roles[i] = sptmp;
72001 + }
72002 +
72003 + r_utmp = (struct acl_role_label **) arg->role_db.r_table;
72004 +
72005 + for (r_num = 0; r_num < arg->role_db.num_roles; r_num++) {
72006 + r_tmp = acl_alloc(sizeof (struct acl_role_label));
72007 +
72008 + if (!r_tmp)
72009 + return -ENOMEM;
72010 +
72011 + if (copy_pointer_from_array(&r_utmp2, r_num, r_utmp))
72012 + return -EFAULT;
72013 +
72014 + if (copy_acl_role_label(r_tmp, r_utmp2))
72015 + return -EFAULT;
72016 +
72017 + err = alloc_and_copy_string(&r_tmp->rolename, GR_SPROLE_LEN);
72018 + if (err)
72019 + return err;
72020 +
72021 + if (!strcmp(r_tmp->rolename, "default")
72022 + && (r_tmp->roletype & GR_ROLE_DEFAULT)) {
72023 + polstate->default_role = r_tmp;
72024 + } else if (!strcmp(r_tmp->rolename, ":::kernel:::")) {
72025 + polstate->kernel_role = r_tmp;
72026 + }
72027 +
72028 + if ((ghash = (struct gr_hash_struct *) acl_alloc(sizeof(struct gr_hash_struct))) == NULL)
72029 + return -ENOMEM;
72030 +
72031 + if (copy_gr_hash_struct(ghash, r_tmp->hash))
72032 + return -EFAULT;
72033 +
72034 + r_tmp->hash = ghash;
72035 +
72036 + num_subjs = count_user_subjs(r_tmp->hash->first);
72037 +
72038 + r_tmp->subj_hash_size = num_subjs;
72039 + r_tmp->subj_hash =
72040 + (struct acl_subject_label **)
72041 + create_table(&(r_tmp->subj_hash_size), sizeof(void *));
72042 +
72043 + if (!r_tmp->subj_hash)
72044 + return -ENOMEM;
72045 +
72046 + err = copy_user_allowedips(r_tmp);
72047 + if (err)
72048 + return err;
72049 +
72050 + /* copy domain info */
72051 + if (r_tmp->domain_children != NULL) {
72052 + domainlist = acl_alloc_num(r_tmp->domain_child_num, sizeof(uid_t));
72053 + if (domainlist == NULL)
72054 + return -ENOMEM;
72055 +
72056 + if (copy_from_user(domainlist, r_tmp->domain_children, r_tmp->domain_child_num * sizeof(uid_t)))
72057 + return -EFAULT;
72058 +
72059 + r_tmp->domain_children = domainlist;
72060 + }
72061 +
72062 + err = copy_user_transitions(r_tmp);
72063 + if (err)
72064 + return err;
72065 +
72066 + memset(r_tmp->subj_hash, 0,
72067 + r_tmp->subj_hash_size *
72068 + sizeof (struct acl_subject_label *));
72069 +
72070 + /* acquire the list of subjects, then NULL out
72071 + the list prior to parsing the subjects for this role,
72072 + as during this parsing the list is replaced with a list
72073 + of *nested* subjects for the role
72074 + */
72075 + subj_list = r_tmp->hash->first;
72076 +
72077 + /* set nested subject list to null */
72078 + r_tmp->hash->first = NULL;
72079 +
72080 + err = copy_user_subjs(subj_list, r_tmp);
72081 +
72082 + if (err)
72083 + return err;
72084 +
72085 + insert_acl_role_label(r_tmp);
72086 + }
72087 +
72088 + if (polstate->default_role == NULL || polstate->kernel_role == NULL)
72089 + return -EINVAL;
72090 +
72091 + return err;
72092 +}
72093 +
72094 +static int gracl_reload_apply_policies(void *reload)
72095 +{
72096 + struct gr_reload_state *reload_state = (struct gr_reload_state *)reload;
72097 + struct task_struct *task, *task2;
72098 + struct acl_role_label *role, *rtmp;
72099 + struct acl_subject_label *subj;
72100 + const struct cred *cred;
72101 + int role_applied;
72102 + int ret = 0;
72103 +
72104 + memcpy(&reload_state->oldpolicy, reload_state->oldpolicy_ptr, sizeof(struct gr_policy_state));
72105 + memcpy(&reload_state->oldalloc, reload_state->oldalloc_ptr, sizeof(struct gr_alloc_state));
72106 +
72107 + /* first make sure we'll be able to apply the new policy cleanly */
72108 + do_each_thread(task2, task) {
72109 + if (task->exec_file == NULL)
72110 + continue;
72111 + role_applied = 0;
72112 + if (!reload_state->oldmode && task->role->roletype & GR_ROLE_SPECIAL) {
72113 + /* preserve special roles */
72114 + FOR_EACH_ROLE_START(role)
72115 + if ((role->roletype & GR_ROLE_SPECIAL) && !strcmp(task->role->rolename, role->rolename)) {
72116 + rtmp = task->role;
72117 + task->role = role;
72118 + role_applied = 1;
72119 + break;
72120 + }
72121 + FOR_EACH_ROLE_END(role)
72122 + }
72123 + if (!role_applied) {
72124 + cred = __task_cred(task);
72125 + rtmp = task->role;
72126 + task->role = __lookup_acl_role_label(polstate, task, GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid));
72127 + }
72128 + /* this handles non-nested inherited subjects, nested subjects will still
72129 + be dropped currently */
72130 + subj = __gr_get_subject_for_task(polstate, task, task->acl->filename);
72131 + task->tmpacl = __gr_get_subject_for_task(polstate, task, NULL);
72132 + /* change the role back so that we've made no modifications to the policy */
72133 + task->role = rtmp;
72134 +
72135 + if (subj == NULL || task->tmpacl == NULL) {
72136 + ret = -EINVAL;
72137 + goto out;
72138 + }
72139 + } while_each_thread(task2, task);
72140 +
72141 + /* now actually apply the policy */
72142 +
72143 + do_each_thread(task2, task) {
72144 + if (task->exec_file) {
72145 + role_applied = 0;
72146 + if (!reload_state->oldmode && task->role->roletype & GR_ROLE_SPECIAL) {
72147 + /* preserve special roles */
72148 + FOR_EACH_ROLE_START(role)
72149 + if ((role->roletype & GR_ROLE_SPECIAL) && !strcmp(task->role->rolename, role->rolename)) {
72150 + task->role = role;
72151 + role_applied = 1;
72152 + break;
72153 + }
72154 + FOR_EACH_ROLE_END(role)
72155 + }
72156 + if (!role_applied) {
72157 + cred = __task_cred(task);
72158 + task->role = __lookup_acl_role_label(polstate, task, GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid));
72159 + }
72160 + /* this handles non-nested inherited subjects, nested subjects will still
72161 + be dropped currently */
72162 + if (!reload_state->oldmode && task->inherited)
72163 + subj = __gr_get_subject_for_task(polstate, task, task->acl->filename);
72164 + else {
72165 + /* looked up and tagged to the task previously */
72166 + subj = task->tmpacl;
72167 + }
72168 + /* subj will be non-null */
72169 + __gr_apply_subject_to_task(polstate, task, subj);
72170 + if (reload_state->oldmode) {
72171 + task->acl_role_id = 0;
72172 + task->acl_sp_role = 0;
72173 + task->inherited = 0;
72174 + }
72175 + } else {
72176 + // it's a kernel process
72177 + task->role = polstate->kernel_role;
72178 + task->acl = polstate->kernel_role->root_label;
72179 +#ifdef CONFIG_GRKERNSEC_ACL_HIDEKERN
72180 + task->acl->mode &= ~GR_PROCFIND;
72181 +#endif
72182 + }
72183 + } while_each_thread(task2, task);
72184 +
72185 + memcpy(reload_state->oldpolicy_ptr, &reload_state->newpolicy, sizeof(struct gr_policy_state));
72186 + memcpy(reload_state->oldalloc_ptr, &reload_state->newalloc, sizeof(struct gr_alloc_state));
72187 +
72188 +out:
72189 +
72190 + return ret;
72191 +}
72192 +
72193 +static int gracl_reload(struct gr_arg *args, unsigned char oldmode)
72194 +{
72195 + struct gr_reload_state new_reload_state = { };
72196 + int err;
72197 +
72198 + new_reload_state.oldpolicy_ptr = polstate;
72199 + new_reload_state.oldalloc_ptr = current_alloc_state;
72200 + new_reload_state.oldmode = oldmode;
72201 +
72202 + current_alloc_state = &new_reload_state.newalloc;
72203 + polstate = &new_reload_state.newpolicy;
72204 +
72205 + /* everything relevant is now saved off, copy in the new policy */
72206 + if (init_variables(args, true)) {
72207 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_INITF_ACL_MSG, GR_VERSION);
72208 + err = -ENOMEM;
72209 + goto error;
72210 + }
72211 +
72212 + err = copy_user_acl(args);
72213 + free_init_variables();
72214 + if (err)
72215 + goto error;
72216 + /* the new policy is copied in, with the old policy available via saved_state
72217 + first go through applying roles, making sure to preserve special roles
72218 + then apply new subjects, making sure to preserve inherited and nested subjects,
72219 + though currently only inherited subjects will be preserved
72220 + */
72221 + err = stop_machine(gracl_reload_apply_policies, &new_reload_state, NULL);
72222 + if (err)
72223 + goto error;
72224 +
72225 + /* we've now applied the new policy, so restore the old policy state to free it */
72226 + polstate = &new_reload_state.oldpolicy;
72227 + current_alloc_state = &new_reload_state.oldalloc;
72228 + free_variables(true);
72229 +
72230 + /* oldpolicy/oldalloc_ptr point to the new policy/alloc states as they were copied
72231 + to running_polstate/current_alloc_state inside stop_machine
72232 + */
72233 + err = 0;
72234 + goto out;
72235 +error:
72236 + /* on error of loading the new policy, we'll just keep the previous
72237 + policy set around
72238 + */
72239 + free_variables(true);
72240 +
72241 + /* doesn't affect runtime, but maintains consistent state */
72242 +out:
72243 + polstate = new_reload_state.oldpolicy_ptr;
72244 + current_alloc_state = new_reload_state.oldalloc_ptr;
72245 +
72246 + return err;
72247 +}
72248 +
72249 +static int
72250 +gracl_init(struct gr_arg *args)
72251 +{
72252 + int error = 0;
72253 +
72254 + memcpy(&gr_system_salt, args->salt, sizeof(gr_system_salt));
72255 + memcpy(&gr_system_sum, args->sum, sizeof(gr_system_sum));
72256 +
72257 + if (init_variables(args, false)) {
72258 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_INITF_ACL_MSG, GR_VERSION);
72259 + error = -ENOMEM;
72260 + goto out;
72261 + }
72262 +
72263 + error = copy_user_acl(args);
72264 + free_init_variables();
72265 + if (error)
72266 + goto out;
72267 +
72268 + error = gr_set_acls(0);
72269 + if (error)
72270 + goto out;
72271 +
72272 + gr_enable_rbac_system();
72273 +
72274 + return 0;
72275 +
72276 +out:
72277 + free_variables(false);
72278 + return error;
72279 +}
72280 +
72281 +static int
72282 +lookup_special_role_auth(__u16 mode, const char *rolename, unsigned char **salt,
72283 + unsigned char **sum)
72284 +{
72285 + struct acl_role_label *r;
72286 + struct role_allowed_ip *ipp;
72287 + struct role_transition *trans;
72288 + unsigned int i;
72289 + int found = 0;
72290 + u32 curr_ip = current->signal->curr_ip;
72291 +
72292 + current->signal->saved_ip = curr_ip;
72293 +
72294 + /* check transition table */
72295 +
72296 + for (trans = current->role->transitions; trans; trans = trans->next) {
72297 + if (!strcmp(rolename, trans->rolename)) {
72298 + found = 1;
72299 + break;
72300 + }
72301 + }
72302 +
72303 + if (!found)
72304 + return 0;
72305 +
72306 + /* handle special roles that do not require authentication
72307 + and check ip */
72308 +
72309 + FOR_EACH_ROLE_START(r)
72310 + if (!strcmp(rolename, r->rolename) &&
72311 + (r->roletype & GR_ROLE_SPECIAL)) {
72312 + found = 0;
72313 + if (r->allowed_ips != NULL) {
72314 + for (ipp = r->allowed_ips; ipp; ipp = ipp->next) {
72315 + if ((ntohl(curr_ip) & ipp->netmask) ==
72316 + (ntohl(ipp->addr) & ipp->netmask))
72317 + found = 1;
72318 + }
72319 + } else
72320 + found = 2;
72321 + if (!found)
72322 + return 0;
72323 +
72324 + if (((mode == GR_SPROLE) && (r->roletype & GR_ROLE_NOPW)) ||
72325 + ((mode == GR_SPROLEPAM) && (r->roletype & GR_ROLE_PAM))) {
72326 + *salt = NULL;
72327 + *sum = NULL;
72328 + return 1;
72329 + }
72330 + }
72331 + FOR_EACH_ROLE_END(r)
72332 +
72333 + for (i = 0; i < polstate->num_sprole_pws; i++) {
72334 + if (!strcmp(rolename, polstate->acl_special_roles[i]->rolename)) {
72335 + *salt = polstate->acl_special_roles[i]->salt;
72336 + *sum = polstate->acl_special_roles[i]->sum;
72337 + return 1;
72338 + }
72339 + }
72340 +
72341 + return 0;
72342 +}
72343 +
72344 +int gr_check_secure_terminal(struct task_struct *task)
72345 +{
72346 + struct task_struct *p, *p2, *p3;
72347 + struct files_struct *files;
72348 + struct fdtable *fdt;
72349 + struct file *our_file = NULL, *file;
72350 + int i;
72351 +
72352 + if (task->signal->tty == NULL)
72353 + return 1;
72354 +
72355 + files = get_files_struct(task);
72356 + if (files != NULL) {
72357 + rcu_read_lock();
72358 + fdt = files_fdtable(files);
72359 + for (i=0; i < fdt->max_fds; i++) {
72360 + file = fcheck_files(files, i);
72361 + if (file && (our_file == NULL) && (file->private_data == task->signal->tty)) {
72362 + get_file(file);
72363 + our_file = file;
72364 + }
72365 + }
72366 + rcu_read_unlock();
72367 + put_files_struct(files);
72368 + }
72369 +
72370 + if (our_file == NULL)
72371 + return 1;
72372 +
72373 + read_lock(&tasklist_lock);
72374 + do_each_thread(p2, p) {
72375 + files = get_files_struct(p);
72376 + if (files == NULL ||
72377 + (p->signal && p->signal->tty == task->signal->tty)) {
72378 + if (files != NULL)
72379 + put_files_struct(files);
72380 + continue;
72381 + }
72382 + rcu_read_lock();
72383 + fdt = files_fdtable(files);
72384 + for (i=0; i < fdt->max_fds; i++) {
72385 + file = fcheck_files(files, i);
72386 + if (file && S_ISCHR(file->f_path.dentry->d_inode->i_mode) &&
72387 + file->f_path.dentry->d_inode->i_rdev == our_file->f_path.dentry->d_inode->i_rdev) {
72388 + p3 = task;
72389 + while (task_pid_nr(p3) > 0) {
72390 + if (p3 == p)
72391 + break;
72392 + p3 = p3->real_parent;
72393 + }
72394 + if (p3 == p)
72395 + break;
72396 + gr_log_ttysniff(GR_DONT_AUDIT_GOOD, GR_TTYSNIFF_ACL_MSG, p);
72397 + gr_handle_alertkill(p);
72398 + rcu_read_unlock();
72399 + put_files_struct(files);
72400 + read_unlock(&tasklist_lock);
72401 + fput(our_file);
72402 + return 0;
72403 + }
72404 + }
72405 + rcu_read_unlock();
72406 + put_files_struct(files);
72407 + } while_each_thread(p2, p);
72408 + read_unlock(&tasklist_lock);
72409 +
72410 + fput(our_file);
72411 + return 1;
72412 +}
72413 +
72414 +ssize_t
72415 +write_grsec_handler(struct file *file, const char __user * buf, size_t count, loff_t *ppos)
72416 +{
72417 + struct gr_arg_wrapper uwrap;
72418 + unsigned char *sprole_salt = NULL;
72419 + unsigned char *sprole_sum = NULL;
72420 + int error = 0;
72421 + int error2 = 0;
72422 + size_t req_count = 0;
72423 + unsigned char oldmode = 0;
72424 +
72425 + mutex_lock(&gr_dev_mutex);
72426 +
72427 + if (gr_acl_is_enabled() && !(current->acl->mode & GR_KERNELAUTH)) {
72428 + error = -EPERM;
72429 + goto out;
72430 + }
72431 +
72432 +#ifdef CONFIG_COMPAT
72433 + pax_open_kernel();
72434 + if (is_compat_task()) {
72435 + copy_gr_arg_wrapper = &copy_gr_arg_wrapper_compat;
72436 + copy_gr_arg = &copy_gr_arg_compat;
72437 + copy_acl_object_label = &copy_acl_object_label_compat;
72438 + copy_acl_subject_label = &copy_acl_subject_label_compat;
72439 + copy_acl_role_label = &copy_acl_role_label_compat;
72440 + copy_acl_ip_label = &copy_acl_ip_label_compat;
72441 + copy_role_allowed_ip = &copy_role_allowed_ip_compat;
72442 + copy_role_transition = &copy_role_transition_compat;
72443 + copy_sprole_pw = &copy_sprole_pw_compat;
72444 + copy_gr_hash_struct = &copy_gr_hash_struct_compat;
72445 + copy_pointer_from_array = &copy_pointer_from_array_compat;
72446 + get_gr_arg_wrapper_size = &get_gr_arg_wrapper_size_compat;
72447 + } else {
72448 + copy_gr_arg_wrapper = &copy_gr_arg_wrapper_normal;
72449 + copy_gr_arg = &copy_gr_arg_normal;
72450 + copy_acl_object_label = &copy_acl_object_label_normal;
72451 + copy_acl_subject_label = &copy_acl_subject_label_normal;
72452 + copy_acl_role_label = &copy_acl_role_label_normal;
72453 + copy_acl_ip_label = &copy_acl_ip_label_normal;
72454 + copy_role_allowed_ip = &copy_role_allowed_ip_normal;
72455 + copy_role_transition = &copy_role_transition_normal;
72456 + copy_sprole_pw = &copy_sprole_pw_normal;
72457 + copy_gr_hash_struct = &copy_gr_hash_struct_normal;
72458 + copy_pointer_from_array = &copy_pointer_from_array_normal;
72459 + get_gr_arg_wrapper_size = &get_gr_arg_wrapper_size_normal;
72460 + }
72461 + pax_close_kernel();
72462 +#endif
72463 +
72464 + req_count = get_gr_arg_wrapper_size();
72465 +
72466 + if (count != req_count) {
72467 + gr_log_int_int(GR_DONT_AUDIT_GOOD, GR_DEV_ACL_MSG, (int)count, (int)req_count);
72468 + error = -EINVAL;
72469 + goto out;
72470 + }
72471 +
72472 +
72473 + if (gr_auth_expires && time_after_eq(get_seconds(), gr_auth_expires)) {
72474 + gr_auth_expires = 0;
72475 + gr_auth_attempts = 0;
72476 + }
72477 +
72478 + error = copy_gr_arg_wrapper(buf, &uwrap);
72479 + if (error)
72480 + goto out;
72481 +
72482 + error = copy_gr_arg(uwrap.arg, &gr_usermode);
72483 + if (error)
72484 + goto out;
72485 +
72486 + if (gr_usermode.mode != GR_SPROLE && gr_usermode.mode != GR_SPROLEPAM &&
72487 + gr_auth_attempts >= CONFIG_GRKERNSEC_ACL_MAXTRIES &&
72488 + time_after(gr_auth_expires, get_seconds())) {
72489 + error = -EBUSY;
72490 + goto out;
72491 + }
72492 +
72493 + /* if non-root trying to do anything other than use a special role,
72494 + do not attempt authentication, do not count towards authentication
72495 + locking
72496 + */
72497 +
72498 + if (gr_usermode.mode != GR_SPROLE && gr_usermode.mode != GR_STATUS &&
72499 + gr_usermode.mode != GR_UNSPROLE && gr_usermode.mode != GR_SPROLEPAM &&
72500 + gr_is_global_nonroot(current_uid())) {
72501 + error = -EPERM;
72502 + goto out;
72503 + }
72504 +
72505 + /* ensure pw and special role name are null terminated */
72506 +
72507 + gr_usermode.pw[GR_PW_LEN - 1] = '\0';
72508 + gr_usermode.sp_role[GR_SPROLE_LEN - 1] = '\0';
72509 +
72510 + /* Okay.
72511 + * We have our enough of the argument structure..(we have yet
72512 + * to copy_from_user the tables themselves) . Copy the tables
72513 + * only if we need them, i.e. for loading operations. */
72514 +
72515 + switch (gr_usermode.mode) {
72516 + case GR_STATUS:
72517 + if (gr_acl_is_enabled()) {
72518 + error = 1;
72519 + if (!gr_check_secure_terminal(current))
72520 + error = 3;
72521 + } else
72522 + error = 2;
72523 + goto out;
72524 + case GR_SHUTDOWN:
72525 + if (gr_acl_is_enabled() && !(chkpw(&gr_usermode, (unsigned char *)&gr_system_salt, (unsigned char *)&gr_system_sum))) {
72526 + stop_machine(gr_rbac_disable, NULL, NULL);
72527 + free_variables(false);
72528 + memset(&gr_usermode, 0, sizeof(gr_usermode));
72529 + memset(&gr_system_salt, 0, sizeof(gr_system_salt));
72530 + memset(&gr_system_sum, 0, sizeof(gr_system_sum));
72531 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SHUTS_ACL_MSG);
72532 + } else if (gr_acl_is_enabled()) {
72533 + gr_log_noargs(GR_DONT_AUDIT, GR_SHUTF_ACL_MSG);
72534 + error = -EPERM;
72535 + } else {
72536 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SHUTI_ACL_MSG);
72537 + error = -EAGAIN;
72538 + }
72539 + break;
72540 + case GR_ENABLE:
72541 + if (!gr_acl_is_enabled() && !(error2 = gracl_init(&gr_usermode)))
72542 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_ENABLE_ACL_MSG, GR_VERSION);
72543 + else {
72544 + if (gr_acl_is_enabled())
72545 + error = -EAGAIN;
72546 + else
72547 + error = error2;
72548 + gr_log_str(GR_DONT_AUDIT, GR_ENABLEF_ACL_MSG, GR_VERSION);
72549 + }
72550 + break;
72551 + case GR_OLDRELOAD:
72552 + oldmode = 1;
72553 + case GR_RELOAD:
72554 + if (!gr_acl_is_enabled()) {
72555 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_RELOADI_ACL_MSG, GR_VERSION);
72556 + error = -EAGAIN;
72557 + } else if (!(chkpw(&gr_usermode, (unsigned char *)&gr_system_salt, (unsigned char *)&gr_system_sum))) {
72558 + error2 = gracl_reload(&gr_usermode, oldmode);
72559 + if (!error2)
72560 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_RELOAD_ACL_MSG, GR_VERSION);
72561 + else {
72562 + gr_log_str(GR_DONT_AUDIT, GR_RELOADF_ACL_MSG, GR_VERSION);
72563 + error = error2;
72564 + }
72565 + } else {
72566 + gr_log_str(GR_DONT_AUDIT, GR_RELOADF_ACL_MSG, GR_VERSION);
72567 + error = -EPERM;
72568 + }
72569 + break;
72570 + case GR_SEGVMOD:
72571 + if (unlikely(!gr_acl_is_enabled())) {
72572 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SEGVMODI_ACL_MSG);
72573 + error = -EAGAIN;
72574 + break;
72575 + }
72576 +
72577 + if (!(chkpw(&gr_usermode, (unsigned char *)&gr_system_salt, (unsigned char *)&gr_system_sum))) {
72578 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SEGVMODS_ACL_MSG);
72579 + if (gr_usermode.segv_device && gr_usermode.segv_inode) {
72580 + struct acl_subject_label *segvacl;
72581 + segvacl =
72582 + lookup_acl_subj_label(gr_usermode.segv_inode,
72583 + gr_usermode.segv_device,
72584 + current->role);
72585 + if (segvacl) {
72586 + segvacl->crashes = 0;
72587 + segvacl->expires = 0;
72588 + }
72589 + } else if (gr_find_uid(gr_usermode.segv_uid) >= 0) {
72590 + gr_remove_uid(gr_usermode.segv_uid);
72591 + }
72592 + } else {
72593 + gr_log_noargs(GR_DONT_AUDIT, GR_SEGVMODF_ACL_MSG);
72594 + error = -EPERM;
72595 + }
72596 + break;
72597 + case GR_SPROLE:
72598 + case GR_SPROLEPAM:
72599 + if (unlikely(!gr_acl_is_enabled())) {
72600 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SPROLEI_ACL_MSG);
72601 + error = -EAGAIN;
72602 + break;
72603 + }
72604 +
72605 + if (current->role->expires && time_after_eq(get_seconds(), current->role->expires)) {
72606 + current->role->expires = 0;
72607 + current->role->auth_attempts = 0;
72608 + }
72609 +
72610 + if (current->role->auth_attempts >= CONFIG_GRKERNSEC_ACL_MAXTRIES &&
72611 + time_after(current->role->expires, get_seconds())) {
72612 + error = -EBUSY;
72613 + goto out;
72614 + }
72615 +
72616 + if (lookup_special_role_auth
72617 + (gr_usermode.mode, gr_usermode.sp_role, &sprole_salt, &sprole_sum)
72618 + && ((!sprole_salt && !sprole_sum)
72619 + || !(chkpw(&gr_usermode, sprole_salt, sprole_sum)))) {
72620 + char *p = "";
72621 + assign_special_role(gr_usermode.sp_role);
72622 + read_lock(&tasklist_lock);
72623 + if (current->real_parent)
72624 + p = current->real_parent->role->rolename;
72625 + read_unlock(&tasklist_lock);
72626 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_SPROLES_ACL_MSG,
72627 + p, acl_sp_role_value);
72628 + } else {
72629 + gr_log_str(GR_DONT_AUDIT, GR_SPROLEF_ACL_MSG, gr_usermode.sp_role);
72630 + error = -EPERM;
72631 + if(!(current->role->auth_attempts++))
72632 + current->role->expires = get_seconds() + CONFIG_GRKERNSEC_ACL_TIMEOUT;
72633 +
72634 + goto out;
72635 + }
72636 + break;
72637 + case GR_UNSPROLE:
72638 + if (unlikely(!gr_acl_is_enabled())) {
72639 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_UNSPROLEI_ACL_MSG);
72640 + error = -EAGAIN;
72641 + break;
72642 + }
72643 +
72644 + if (current->role->roletype & GR_ROLE_SPECIAL) {
72645 + char *p = "";
72646 + int i = 0;
72647 +
72648 + read_lock(&tasklist_lock);
72649 + if (current->real_parent) {
72650 + p = current->real_parent->role->rolename;
72651 + i = current->real_parent->acl_role_id;
72652 + }
72653 + read_unlock(&tasklist_lock);
72654 +
72655 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_UNSPROLES_ACL_MSG, p, i);
72656 + gr_set_acls(1);
72657 + } else {
72658 + error = -EPERM;
72659 + goto out;
72660 + }
72661 + break;
72662 + default:
72663 + gr_log_int(GR_DONT_AUDIT, GR_INVMODE_ACL_MSG, gr_usermode.mode);
72664 + error = -EINVAL;
72665 + break;
72666 + }
72667 +
72668 + if (error != -EPERM)
72669 + goto out;
72670 +
72671 + if(!(gr_auth_attempts++))
72672 + gr_auth_expires = get_seconds() + CONFIG_GRKERNSEC_ACL_TIMEOUT;
72673 +
72674 + out:
72675 + mutex_unlock(&gr_dev_mutex);
72676 +
72677 + if (!error)
72678 + error = req_count;
72679 +
72680 + return error;
72681 +}
72682 +
72683 +int
72684 +gr_set_acls(const int type)
72685 +{
72686 + struct task_struct *task, *task2;
72687 + struct acl_role_label *role = current->role;
72688 + struct acl_subject_label *subj;
72689 + __u16 acl_role_id = current->acl_role_id;
72690 + const struct cred *cred;
72691 + int ret;
72692 +
72693 + rcu_read_lock();
72694 + read_lock(&tasklist_lock);
72695 + read_lock(&grsec_exec_file_lock);
72696 + do_each_thread(task2, task) {
72697 + /* check to see if we're called from the exit handler,
72698 + if so, only replace ACLs that have inherited the admin
72699 + ACL */
72700 +
72701 + if (type && (task->role != role ||
72702 + task->acl_role_id != acl_role_id))
72703 + continue;
72704 +
72705 + task->acl_role_id = 0;
72706 + task->acl_sp_role = 0;
72707 + task->inherited = 0;
72708 +
72709 + if (task->exec_file) {
72710 + cred = __task_cred(task);
72711 + task->role = __lookup_acl_role_label(polstate, task, GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid));
72712 + subj = __gr_get_subject_for_task(polstate, task, NULL);
72713 + if (subj == NULL) {
72714 + ret = -EINVAL;
72715 + read_unlock(&grsec_exec_file_lock);
72716 + read_unlock(&tasklist_lock);
72717 + rcu_read_unlock();
72718 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_DEFACL_MSG, task->comm, task_pid_nr(task));
72719 + return ret;
72720 + }
72721 + __gr_apply_subject_to_task(polstate, task, subj);
72722 + } else {
72723 + // it's a kernel process
72724 + task->role = polstate->kernel_role;
72725 + task->acl = polstate->kernel_role->root_label;
72726 +#ifdef CONFIG_GRKERNSEC_ACL_HIDEKERN
72727 + task->acl->mode &= ~GR_PROCFIND;
72728 +#endif
72729 + }
72730 + } while_each_thread(task2, task);
72731 + read_unlock(&grsec_exec_file_lock);
72732 + read_unlock(&tasklist_lock);
72733 + rcu_read_unlock();
72734 +
72735 + return 0;
72736 +}
72737 diff --git a/grsecurity/gracl_res.c b/grsecurity/gracl_res.c
72738 new file mode 100644
72739 index 0000000..39645c9
72740 --- /dev/null
72741 +++ b/grsecurity/gracl_res.c
72742 @@ -0,0 +1,68 @@
72743 +#include <linux/kernel.h>
72744 +#include <linux/sched.h>
72745 +#include <linux/gracl.h>
72746 +#include <linux/grinternal.h>
72747 +
72748 +static const char *restab_log[] = {
72749 + [RLIMIT_CPU] = "RLIMIT_CPU",
72750 + [RLIMIT_FSIZE] = "RLIMIT_FSIZE",
72751 + [RLIMIT_DATA] = "RLIMIT_DATA",
72752 + [RLIMIT_STACK] = "RLIMIT_STACK",
72753 + [RLIMIT_CORE] = "RLIMIT_CORE",
72754 + [RLIMIT_RSS] = "RLIMIT_RSS",
72755 + [RLIMIT_NPROC] = "RLIMIT_NPROC",
72756 + [RLIMIT_NOFILE] = "RLIMIT_NOFILE",
72757 + [RLIMIT_MEMLOCK] = "RLIMIT_MEMLOCK",
72758 + [RLIMIT_AS] = "RLIMIT_AS",
72759 + [RLIMIT_LOCKS] = "RLIMIT_LOCKS",
72760 + [RLIMIT_SIGPENDING] = "RLIMIT_SIGPENDING",
72761 + [RLIMIT_MSGQUEUE] = "RLIMIT_MSGQUEUE",
72762 + [RLIMIT_NICE] = "RLIMIT_NICE",
72763 + [RLIMIT_RTPRIO] = "RLIMIT_RTPRIO",
72764 + [RLIMIT_RTTIME] = "RLIMIT_RTTIME",
72765 + [GR_CRASH_RES] = "RLIMIT_CRASH"
72766 +};
72767 +
72768 +void
72769 +gr_log_resource(const struct task_struct *task,
72770 + const int res, const unsigned long wanted, const int gt)
72771 +{
72772 + const struct cred *cred;
72773 + unsigned long rlim;
72774 +
72775 + if (!gr_acl_is_enabled() && !grsec_resource_logging)
72776 + return;
72777 +
72778 + // not yet supported resource
72779 + if (unlikely(!restab_log[res]))
72780 + return;
72781 +
72782 + if (res == RLIMIT_CPU || res == RLIMIT_RTTIME)
72783 + rlim = task_rlimit_max(task, res);
72784 + else
72785 + rlim = task_rlimit(task, res);
72786 +
72787 + if (likely((rlim == RLIM_INFINITY) || (gt && wanted <= rlim) || (!gt && wanted < rlim)))
72788 + return;
72789 +
72790 + rcu_read_lock();
72791 + cred = __task_cred(task);
72792 +
72793 + if (res == RLIMIT_NPROC &&
72794 + (cap_raised(cred->cap_effective, CAP_SYS_ADMIN) ||
72795 + cap_raised(cred->cap_effective, CAP_SYS_RESOURCE)))
72796 + goto out_rcu_unlock;
72797 + else if (res == RLIMIT_MEMLOCK &&
72798 + cap_raised(cred->cap_effective, CAP_IPC_LOCK))
72799 + goto out_rcu_unlock;
72800 + else if (res == RLIMIT_NICE && cap_raised(cred->cap_effective, CAP_SYS_NICE))
72801 + goto out_rcu_unlock;
72802 + rcu_read_unlock();
72803 +
72804 + gr_log_res_ulong2_str(GR_DONT_AUDIT, GR_RESOURCE_MSG, task, wanted, restab_log[res], rlim);
72805 +
72806 + return;
72807 +out_rcu_unlock:
72808 + rcu_read_unlock();
72809 + return;
72810 +}
72811 diff --git a/grsecurity/gracl_segv.c b/grsecurity/gracl_segv.c
72812 new file mode 100644
72813 index 0000000..2040e61
72814 --- /dev/null
72815 +++ b/grsecurity/gracl_segv.c
72816 @@ -0,0 +1,313 @@
72817 +#include <linux/kernel.h>
72818 +#include <linux/mm.h>
72819 +#include <asm/uaccess.h>
72820 +#include <asm/errno.h>
72821 +#include <asm/mman.h>
72822 +#include <net/sock.h>
72823 +#include <linux/file.h>
72824 +#include <linux/fs.h>
72825 +#include <linux/net.h>
72826 +#include <linux/in.h>
72827 +#include <linux/slab.h>
72828 +#include <linux/types.h>
72829 +#include <linux/sched.h>
72830 +#include <linux/timer.h>
72831 +#include <linux/gracl.h>
72832 +#include <linux/grsecurity.h>
72833 +#include <linux/grinternal.h>
72834 +#if defined(CONFIG_BTRFS_FS) || defined(CONFIG_BTRFS_FS_MODULE)
72835 +#include <linux/magic.h>
72836 +#include <linux/pagemap.h>
72837 +#include "../fs/btrfs/async-thread.h"
72838 +#include "../fs/btrfs/ctree.h"
72839 +#include "../fs/btrfs/btrfs_inode.h"
72840 +#endif
72841 +
72842 +static struct crash_uid *uid_set;
72843 +static unsigned short uid_used;
72844 +static DEFINE_SPINLOCK(gr_uid_lock);
72845 +extern rwlock_t gr_inode_lock;
72846 +extern struct acl_subject_label *
72847 + lookup_acl_subj_label(const ino_t inode, const dev_t dev,
72848 + struct acl_role_label *role);
72849 +
72850 +static inline dev_t __get_dev(const struct dentry *dentry)
72851 +{
72852 +#if defined(CONFIG_BTRFS_FS) || defined(CONFIG_BTRFS_FS_MODULE)
72853 + if (dentry->d_sb->s_magic == BTRFS_SUPER_MAGIC)
72854 + return BTRFS_I(dentry->d_inode)->root->anon_dev;
72855 + else
72856 +#endif
72857 + return dentry->d_sb->s_dev;
72858 +}
72859 +
72860 +int
72861 +gr_init_uidset(void)
72862 +{
72863 + uid_set =
72864 + kmalloc(GR_UIDTABLE_MAX * sizeof (struct crash_uid), GFP_KERNEL);
72865 + uid_used = 0;
72866 +
72867 + return uid_set ? 1 : 0;
72868 +}
72869 +
72870 +void
72871 +gr_free_uidset(void)
72872 +{
72873 + if (uid_set) {
72874 + struct crash_uid *tmpset;
72875 + spin_lock(&gr_uid_lock);
72876 + tmpset = uid_set;
72877 + uid_set = NULL;
72878 + uid_used = 0;
72879 + spin_unlock(&gr_uid_lock);
72880 + if (tmpset)
72881 + kfree(tmpset);
72882 + }
72883 +
72884 + return;
72885 +}
72886 +
72887 +int
72888 +gr_find_uid(const uid_t uid)
72889 +{
72890 + struct crash_uid *tmp = uid_set;
72891 + uid_t buid;
72892 + int low = 0, high = uid_used - 1, mid;
72893 +
72894 + while (high >= low) {
72895 + mid = (low + high) >> 1;
72896 + buid = tmp[mid].uid;
72897 + if (buid == uid)
72898 + return mid;
72899 + if (buid > uid)
72900 + high = mid - 1;
72901 + if (buid < uid)
72902 + low = mid + 1;
72903 + }
72904 +
72905 + return -1;
72906 +}
72907 +
72908 +static __inline__ void
72909 +gr_insertsort(void)
72910 +{
72911 + unsigned short i, j;
72912 + struct crash_uid index;
72913 +
72914 + for (i = 1; i < uid_used; i++) {
72915 + index = uid_set[i];
72916 + j = i;
72917 + while ((j > 0) && uid_set[j - 1].uid > index.uid) {
72918 + uid_set[j] = uid_set[j - 1];
72919 + j--;
72920 + }
72921 + uid_set[j] = index;
72922 + }
72923 +
72924 + return;
72925 +}
72926 +
72927 +static __inline__ void
72928 +gr_insert_uid(const kuid_t kuid, const unsigned long expires)
72929 +{
72930 + int loc;
72931 + uid_t uid = GR_GLOBAL_UID(kuid);
72932 +
72933 + if (uid_used == GR_UIDTABLE_MAX)
72934 + return;
72935 +
72936 + loc = gr_find_uid(uid);
72937 +
72938 + if (loc >= 0) {
72939 + uid_set[loc].expires = expires;
72940 + return;
72941 + }
72942 +
72943 + uid_set[uid_used].uid = uid;
72944 + uid_set[uid_used].expires = expires;
72945 + uid_used++;
72946 +
72947 + gr_insertsort();
72948 +
72949 + return;
72950 +}
72951 +
72952 +void
72953 +gr_remove_uid(const unsigned short loc)
72954 +{
72955 + unsigned short i;
72956 +
72957 + for (i = loc + 1; i < uid_used; i++)
72958 + uid_set[i - 1] = uid_set[i];
72959 +
72960 + uid_used--;
72961 +
72962 + return;
72963 +}
72964 +
72965 +int
72966 +gr_check_crash_uid(const kuid_t kuid)
72967 +{
72968 + int loc;
72969 + int ret = 0;
72970 + uid_t uid;
72971 +
72972 + if (unlikely(!gr_acl_is_enabled()))
72973 + return 0;
72974 +
72975 + uid = GR_GLOBAL_UID(kuid);
72976 +
72977 + spin_lock(&gr_uid_lock);
72978 + loc = gr_find_uid(uid);
72979 +
72980 + if (loc < 0)
72981 + goto out_unlock;
72982 +
72983 + if (time_before_eq(uid_set[loc].expires, get_seconds()))
72984 + gr_remove_uid(loc);
72985 + else
72986 + ret = 1;
72987 +
72988 +out_unlock:
72989 + spin_unlock(&gr_uid_lock);
72990 + return ret;
72991 +}
72992 +
72993 +static __inline__ int
72994 +proc_is_setxid(const struct cred *cred)
72995 +{
72996 + if (!uid_eq(cred->uid, cred->euid) || !uid_eq(cred->uid, cred->suid) ||
72997 + !uid_eq(cred->uid, cred->fsuid))
72998 + return 1;
72999 + if (!gid_eq(cred->gid, cred->egid) || !gid_eq(cred->gid, cred->sgid) ||
73000 + !gid_eq(cred->gid, cred->fsgid))
73001 + return 1;
73002 +
73003 + return 0;
73004 +}
73005 +
73006 +extern int gr_fake_force_sig(int sig, struct task_struct *t);
73007 +
73008 +void
73009 +gr_handle_crash(struct task_struct *task, const int sig)
73010 +{
73011 + struct acl_subject_label *curr;
73012 + struct task_struct *tsk, *tsk2;
73013 + const struct cred *cred;
73014 + const struct cred *cred2;
73015 +
73016 + if (sig != SIGSEGV && sig != SIGKILL && sig != SIGBUS && sig != SIGILL)
73017 + return;
73018 +
73019 + if (unlikely(!gr_acl_is_enabled()))
73020 + return;
73021 +
73022 + curr = task->acl;
73023 +
73024 + if (!(curr->resmask & (1U << GR_CRASH_RES)))
73025 + return;
73026 +
73027 + if (time_before_eq(curr->expires, get_seconds())) {
73028 + curr->expires = 0;
73029 + curr->crashes = 0;
73030 + }
73031 +
73032 + curr->crashes++;
73033 +
73034 + if (!curr->expires)
73035 + curr->expires = get_seconds() + curr->res[GR_CRASH_RES].rlim_max;
73036 +
73037 + if ((curr->crashes >= curr->res[GR_CRASH_RES].rlim_cur) &&
73038 + time_after(curr->expires, get_seconds())) {
73039 + rcu_read_lock();
73040 + cred = __task_cred(task);
73041 + if (gr_is_global_nonroot(cred->uid) && proc_is_setxid(cred)) {
73042 + gr_log_crash1(GR_DONT_AUDIT, GR_SEGVSTART_ACL_MSG, task, curr->res[GR_CRASH_RES].rlim_max);
73043 + spin_lock(&gr_uid_lock);
73044 + gr_insert_uid(cred->uid, curr->expires);
73045 + spin_unlock(&gr_uid_lock);
73046 + curr->expires = 0;
73047 + curr->crashes = 0;
73048 + read_lock(&tasklist_lock);
73049 + do_each_thread(tsk2, tsk) {
73050 + cred2 = __task_cred(tsk);
73051 + if (tsk != task && uid_eq(cred2->uid, cred->uid))
73052 + gr_fake_force_sig(SIGKILL, tsk);
73053 + } while_each_thread(tsk2, tsk);
73054 + read_unlock(&tasklist_lock);
73055 + } else {
73056 + gr_log_crash2(GR_DONT_AUDIT, GR_SEGVNOSUID_ACL_MSG, task, curr->res[GR_CRASH_RES].rlim_max);
73057 + read_lock(&tasklist_lock);
73058 + read_lock(&grsec_exec_file_lock);
73059 + do_each_thread(tsk2, tsk) {
73060 + if (likely(tsk != task)) {
73061 + // if this thread has the same subject as the one that triggered
73062 + // RES_CRASH and it's the same binary, kill it
73063 + if (tsk->acl == task->acl && gr_is_same_file(tsk->exec_file, task->exec_file))
73064 + gr_fake_force_sig(SIGKILL, tsk);
73065 + }
73066 + } while_each_thread(tsk2, tsk);
73067 + read_unlock(&grsec_exec_file_lock);
73068 + read_unlock(&tasklist_lock);
73069 + }
73070 + rcu_read_unlock();
73071 + }
73072 +
73073 + return;
73074 +}
73075 +
73076 +int
73077 +gr_check_crash_exec(const struct file *filp)
73078 +{
73079 + struct acl_subject_label *curr;
73080 +
73081 + if (unlikely(!gr_acl_is_enabled()))
73082 + return 0;
73083 +
73084 + read_lock(&gr_inode_lock);
73085 + curr = lookup_acl_subj_label(filp->f_path.dentry->d_inode->i_ino,
73086 + __get_dev(filp->f_path.dentry),
73087 + current->role);
73088 + read_unlock(&gr_inode_lock);
73089 +
73090 + if (!curr || !(curr->resmask & (1U << GR_CRASH_RES)) ||
73091 + (!curr->crashes && !curr->expires))
73092 + return 0;
73093 +
73094 + if ((curr->crashes >= curr->res[GR_CRASH_RES].rlim_cur) &&
73095 + time_after(curr->expires, get_seconds()))
73096 + return 1;
73097 + else if (time_before_eq(curr->expires, get_seconds())) {
73098 + curr->crashes = 0;
73099 + curr->expires = 0;
73100 + }
73101 +
73102 + return 0;
73103 +}
73104 +
73105 +void
73106 +gr_handle_alertkill(struct task_struct *task)
73107 +{
73108 + struct acl_subject_label *curracl;
73109 + __u32 curr_ip;
73110 + struct task_struct *p, *p2;
73111 +
73112 + if (unlikely(!gr_acl_is_enabled()))
73113 + return;
73114 +
73115 + curracl = task->acl;
73116 + curr_ip = task->signal->curr_ip;
73117 +
73118 + if ((curracl->mode & GR_KILLIPPROC) && curr_ip) {
73119 + read_lock(&tasklist_lock);
73120 + do_each_thread(p2, p) {
73121 + if (p->signal->curr_ip == curr_ip)
73122 + gr_fake_force_sig(SIGKILL, p);
73123 + } while_each_thread(p2, p);
73124 + read_unlock(&tasklist_lock);
73125 + } else if (curracl->mode & GR_KILLPROC)
73126 + gr_fake_force_sig(SIGKILL, task);
73127 +
73128 + return;
73129 +}
73130 diff --git a/grsecurity/gracl_shm.c b/grsecurity/gracl_shm.c
73131 new file mode 100644
73132 index 0000000..98011b0
73133 --- /dev/null
73134 +++ b/grsecurity/gracl_shm.c
73135 @@ -0,0 +1,40 @@
73136 +#include <linux/kernel.h>
73137 +#include <linux/mm.h>
73138 +#include <linux/sched.h>
73139 +#include <linux/file.h>
73140 +#include <linux/ipc.h>
73141 +#include <linux/gracl.h>
73142 +#include <linux/grsecurity.h>
73143 +#include <linux/grinternal.h>
73144 +
73145 +int
73146 +gr_handle_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
73147 + const time_t shm_createtime, const kuid_t cuid, const int shmid)
73148 +{
73149 + struct task_struct *task;
73150 +
73151 + if (!gr_acl_is_enabled())
73152 + return 1;
73153 +
73154 + rcu_read_lock();
73155 + read_lock(&tasklist_lock);
73156 +
73157 + task = find_task_by_vpid(shm_cprid);
73158 +
73159 + if (unlikely(!task))
73160 + task = find_task_by_vpid(shm_lapid);
73161 +
73162 + if (unlikely(task && (time_before_eq((unsigned long)task->start_time.tv_sec, (unsigned long)shm_createtime) ||
73163 + (task_pid_nr(task) == shm_lapid)) &&
73164 + (task->acl->mode & GR_PROTSHM) &&
73165 + (task->acl != current->acl))) {
73166 + read_unlock(&tasklist_lock);
73167 + rcu_read_unlock();
73168 + gr_log_int3(GR_DONT_AUDIT, GR_SHMAT_ACL_MSG, GR_GLOBAL_UID(cuid), shm_cprid, shmid);
73169 + return 0;
73170 + }
73171 + read_unlock(&tasklist_lock);
73172 + rcu_read_unlock();
73173 +
73174 + return 1;
73175 +}
73176 diff --git a/grsecurity/grsec_chdir.c b/grsecurity/grsec_chdir.c
73177 new file mode 100644
73178 index 0000000..bc0be01
73179 --- /dev/null
73180 +++ b/grsecurity/grsec_chdir.c
73181 @@ -0,0 +1,19 @@
73182 +#include <linux/kernel.h>
73183 +#include <linux/sched.h>
73184 +#include <linux/fs.h>
73185 +#include <linux/file.h>
73186 +#include <linux/grsecurity.h>
73187 +#include <linux/grinternal.h>
73188 +
73189 +void
73190 +gr_log_chdir(const struct dentry *dentry, const struct vfsmount *mnt)
73191 +{
73192 +#ifdef CONFIG_GRKERNSEC_AUDIT_CHDIR
73193 + if ((grsec_enable_chdir && grsec_enable_group &&
73194 + in_group_p(grsec_audit_gid)) || (grsec_enable_chdir &&
73195 + !grsec_enable_group)) {
73196 + gr_log_fs_generic(GR_DO_AUDIT, GR_CHDIR_AUDIT_MSG, dentry, mnt);
73197 + }
73198 +#endif
73199 + return;
73200 +}
73201 diff --git a/grsecurity/grsec_chroot.c b/grsecurity/grsec_chroot.c
73202 new file mode 100644
73203 index 0000000..baa635c
73204 --- /dev/null
73205 +++ b/grsecurity/grsec_chroot.c
73206 @@ -0,0 +1,387 @@
73207 +#include <linux/kernel.h>
73208 +#include <linux/module.h>
73209 +#include <linux/sched.h>
73210 +#include <linux/file.h>
73211 +#include <linux/fs.h>
73212 +#include <linux/mount.h>
73213 +#include <linux/types.h>
73214 +#include "../fs/mount.h"
73215 +#include <linux/grsecurity.h>
73216 +#include <linux/grinternal.h>
73217 +
73218 +#ifdef CONFIG_GRKERNSEC_CHROOT_INITRD
73219 +int gr_init_ran;
73220 +#endif
73221 +
73222 +void gr_set_chroot_entries(struct task_struct *task, const struct path *path)
73223 +{
73224 +#ifdef CONFIG_GRKERNSEC
73225 + if (task_pid_nr(task) > 1 && path->dentry != init_task.fs->root.dentry &&
73226 + path->dentry != task->nsproxy->mnt_ns->root->mnt.mnt_root
73227 +#ifdef CONFIG_GRKERNSEC_CHROOT_INITRD
73228 + && gr_init_ran
73229 +#endif
73230 + )
73231 + task->gr_is_chrooted = 1;
73232 + else {
73233 +#ifdef CONFIG_GRKERNSEC_CHROOT_INITRD
73234 + if (task_pid_nr(task) == 1 && !gr_init_ran)
73235 + gr_init_ran = 1;
73236 +#endif
73237 + task->gr_is_chrooted = 0;
73238 + }
73239 +
73240 + task->gr_chroot_dentry = path->dentry;
73241 +#endif
73242 + return;
73243 +}
73244 +
73245 +void gr_clear_chroot_entries(struct task_struct *task)
73246 +{
73247 +#ifdef CONFIG_GRKERNSEC
73248 + task->gr_is_chrooted = 0;
73249 + task->gr_chroot_dentry = NULL;
73250 +#endif
73251 + return;
73252 +}
73253 +
73254 +int
73255 +gr_handle_chroot_unix(const pid_t pid)
73256 +{
73257 +#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
73258 + struct task_struct *p;
73259 +
73260 + if (unlikely(!grsec_enable_chroot_unix))
73261 + return 1;
73262 +
73263 + if (likely(!proc_is_chrooted(current)))
73264 + return 1;
73265 +
73266 + rcu_read_lock();
73267 + read_lock(&tasklist_lock);
73268 + p = find_task_by_vpid_unrestricted(pid);
73269 + if (unlikely(p && !have_same_root(current, p))) {
73270 + read_unlock(&tasklist_lock);
73271 + rcu_read_unlock();
73272 + gr_log_noargs(GR_DONT_AUDIT, GR_UNIX_CHROOT_MSG);
73273 + return 0;
73274 + }
73275 + read_unlock(&tasklist_lock);
73276 + rcu_read_unlock();
73277 +#endif
73278 + return 1;
73279 +}
73280 +
73281 +int
73282 +gr_handle_chroot_nice(void)
73283 +{
73284 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
73285 + if (grsec_enable_chroot_nice && proc_is_chrooted(current)) {
73286 + gr_log_noargs(GR_DONT_AUDIT, GR_NICE_CHROOT_MSG);
73287 + return -EPERM;
73288 + }
73289 +#endif
73290 + return 0;
73291 +}
73292 +
73293 +int
73294 +gr_handle_chroot_setpriority(struct task_struct *p, const int niceval)
73295 +{
73296 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
73297 + if (grsec_enable_chroot_nice && (niceval < task_nice(p))
73298 + && proc_is_chrooted(current)) {
73299 + gr_log_str_int(GR_DONT_AUDIT, GR_PRIORITY_CHROOT_MSG, p->comm, task_pid_nr(p));
73300 + return -EACCES;
73301 + }
73302 +#endif
73303 + return 0;
73304 +}
73305 +
73306 +int
73307 +gr_handle_chroot_fowner(struct pid *pid, enum pid_type type)
73308 +{
73309 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
73310 + struct task_struct *p;
73311 + int ret = 0;
73312 + if (!grsec_enable_chroot_findtask || !proc_is_chrooted(current) || !pid)
73313 + return ret;
73314 +
73315 + read_lock(&tasklist_lock);
73316 + do_each_pid_task(pid, type, p) {
73317 + if (!have_same_root(current, p)) {
73318 + ret = 1;
73319 + goto out;
73320 + }
73321 + } while_each_pid_task(pid, type, p);
73322 +out:
73323 + read_unlock(&tasklist_lock);
73324 + return ret;
73325 +#endif
73326 + return 0;
73327 +}
73328 +
73329 +int
73330 +gr_pid_is_chrooted(struct task_struct *p)
73331 +{
73332 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
73333 + if (!grsec_enable_chroot_findtask || !proc_is_chrooted(current) || p == NULL)
73334 + return 0;
73335 +
73336 + if ((p->exit_state & (EXIT_ZOMBIE | EXIT_DEAD)) ||
73337 + !have_same_root(current, p)) {
73338 + return 1;
73339 + }
73340 +#endif
73341 + return 0;
73342 +}
73343 +
73344 +EXPORT_SYMBOL_GPL(gr_pid_is_chrooted);
73345 +
73346 +#if defined(CONFIG_GRKERNSEC_CHROOT_DOUBLE) || defined(CONFIG_GRKERNSEC_CHROOT_FCHDIR)
73347 +int gr_is_outside_chroot(const struct dentry *u_dentry, const struct vfsmount *u_mnt)
73348 +{
73349 + struct path path, currentroot;
73350 + int ret = 0;
73351 +
73352 + path.dentry = (struct dentry *)u_dentry;
73353 + path.mnt = (struct vfsmount *)u_mnt;
73354 + get_fs_root(current->fs, &currentroot);
73355 + if (path_is_under(&path, &currentroot))
73356 + ret = 1;
73357 + path_put(&currentroot);
73358 +
73359 + return ret;
73360 +}
73361 +#endif
73362 +
73363 +int
73364 +gr_chroot_fchdir(struct dentry *u_dentry, struct vfsmount *u_mnt)
73365 +{
73366 +#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
73367 + if (!grsec_enable_chroot_fchdir)
73368 + return 1;
73369 +
73370 + if (!proc_is_chrooted(current))
73371 + return 1;
73372 + else if (!gr_is_outside_chroot(u_dentry, u_mnt)) {
73373 + gr_log_fs_generic(GR_DONT_AUDIT, GR_CHROOT_FCHDIR_MSG, u_dentry, u_mnt);
73374 + return 0;
73375 + }
73376 +#endif
73377 + return 1;
73378 +}
73379 +
73380 +int
73381 +gr_chroot_fhandle(void)
73382 +{
73383 +#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
73384 + if (!grsec_enable_chroot_fchdir)
73385 + return 1;
73386 +
73387 + if (!proc_is_chrooted(current))
73388 + return 1;
73389 + else {
73390 + gr_log_noargs(GR_DONT_AUDIT, GR_CHROOT_FHANDLE_MSG);
73391 + return 0;
73392 + }
73393 +#endif
73394 + return 1;
73395 +}
73396 +
73397 +int
73398 +gr_chroot_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
73399 + const time_t shm_createtime)
73400 +{
73401 +#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
73402 + struct task_struct *p;
73403 + time_t starttime;
73404 +
73405 + if (unlikely(!grsec_enable_chroot_shmat))
73406 + return 1;
73407 +
73408 + if (likely(!proc_is_chrooted(current)))
73409 + return 1;
73410 +
73411 + rcu_read_lock();
73412 + read_lock(&tasklist_lock);
73413 +
73414 + if ((p = find_task_by_vpid_unrestricted(shm_cprid))) {
73415 + starttime = p->start_time.tv_sec;
73416 + if (time_before_eq((unsigned long)starttime, (unsigned long)shm_createtime)) {
73417 + if (have_same_root(current, p)) {
73418 + goto allow;
73419 + } else {
73420 + read_unlock(&tasklist_lock);
73421 + rcu_read_unlock();
73422 + gr_log_noargs(GR_DONT_AUDIT, GR_SHMAT_CHROOT_MSG);
73423 + return 0;
73424 + }
73425 + }
73426 + /* creator exited, pid reuse, fall through to next check */
73427 + }
73428 + if ((p = find_task_by_vpid_unrestricted(shm_lapid))) {
73429 + if (unlikely(!have_same_root(current, p))) {
73430 + read_unlock(&tasklist_lock);
73431 + rcu_read_unlock();
73432 + gr_log_noargs(GR_DONT_AUDIT, GR_SHMAT_CHROOT_MSG);
73433 + return 0;
73434 + }
73435 + }
73436 +
73437 +allow:
73438 + read_unlock(&tasklist_lock);
73439 + rcu_read_unlock();
73440 +#endif
73441 + return 1;
73442 +}
73443 +
73444 +void
73445 +gr_log_chroot_exec(const struct dentry *dentry, const struct vfsmount *mnt)
73446 +{
73447 +#ifdef CONFIG_GRKERNSEC_CHROOT_EXECLOG
73448 + if (grsec_enable_chroot_execlog && proc_is_chrooted(current))
73449 + gr_log_fs_generic(GR_DO_AUDIT, GR_EXEC_CHROOT_MSG, dentry, mnt);
73450 +#endif
73451 + return;
73452 +}
73453 +
73454 +int
73455 +gr_handle_chroot_mknod(const struct dentry *dentry,
73456 + const struct vfsmount *mnt, const int mode)
73457 +{
73458 +#ifdef CONFIG_GRKERNSEC_CHROOT_MKNOD
73459 + if (grsec_enable_chroot_mknod && !S_ISFIFO(mode) && !S_ISREG(mode) &&
73460 + proc_is_chrooted(current)) {
73461 + gr_log_fs_generic(GR_DONT_AUDIT, GR_MKNOD_CHROOT_MSG, dentry, mnt);
73462 + return -EPERM;
73463 + }
73464 +#endif
73465 + return 0;
73466 +}
73467 +
73468 +int
73469 +gr_handle_chroot_mount(const struct dentry *dentry,
73470 + const struct vfsmount *mnt, const char *dev_name)
73471 +{
73472 +#ifdef CONFIG_GRKERNSEC_CHROOT_MOUNT
73473 + if (grsec_enable_chroot_mount && proc_is_chrooted(current)) {
73474 + gr_log_str_fs(GR_DONT_AUDIT, GR_MOUNT_CHROOT_MSG, dev_name ? dev_name : "none", dentry, mnt);
73475 + return -EPERM;
73476 + }
73477 +#endif
73478 + return 0;
73479 +}
73480 +
73481 +int
73482 +gr_handle_chroot_pivot(void)
73483 +{
73484 +#ifdef CONFIG_GRKERNSEC_CHROOT_PIVOT
73485 + if (grsec_enable_chroot_pivot && proc_is_chrooted(current)) {
73486 + gr_log_noargs(GR_DONT_AUDIT, GR_PIVOT_CHROOT_MSG);
73487 + return -EPERM;
73488 + }
73489 +#endif
73490 + return 0;
73491 +}
73492 +
73493 +int
73494 +gr_handle_chroot_chroot(const struct dentry *dentry, const struct vfsmount *mnt)
73495 +{
73496 +#ifdef CONFIG_GRKERNSEC_CHROOT_DOUBLE
73497 + if (grsec_enable_chroot_double && proc_is_chrooted(current) &&
73498 + !gr_is_outside_chroot(dentry, mnt)) {
73499 + gr_log_fs_generic(GR_DONT_AUDIT, GR_CHROOT_CHROOT_MSG, dentry, mnt);
73500 + return -EPERM;
73501 + }
73502 +#endif
73503 + return 0;
73504 +}
73505 +
73506 +extern const char *captab_log[];
73507 +extern int captab_log_entries;
73508 +
73509 +int
73510 +gr_task_chroot_is_capable(const struct task_struct *task, const struct cred *cred, const int cap)
73511 +{
73512 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
73513 + if (grsec_enable_chroot_caps && proc_is_chrooted(task)) {
73514 + kernel_cap_t chroot_caps = GR_CHROOT_CAPS;
73515 + if (cap_raised(chroot_caps, cap)) {
73516 + if (cap_raised(cred->cap_effective, cap) && cap < captab_log_entries) {
73517 + gr_log_cap(GR_DONT_AUDIT, GR_CAP_CHROOT_MSG, task, captab_log[cap]);
73518 + }
73519 + return 0;
73520 + }
73521 + }
73522 +#endif
73523 + return 1;
73524 +}
73525 +
73526 +int
73527 +gr_chroot_is_capable(const int cap)
73528 +{
73529 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
73530 + return gr_task_chroot_is_capable(current, current_cred(), cap);
73531 +#endif
73532 + return 1;
73533 +}
73534 +
73535 +int
73536 +gr_task_chroot_is_capable_nolog(const struct task_struct *task, const int cap)
73537 +{
73538 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
73539 + if (grsec_enable_chroot_caps && proc_is_chrooted(task)) {
73540 + kernel_cap_t chroot_caps = GR_CHROOT_CAPS;
73541 + if (cap_raised(chroot_caps, cap)) {
73542 + return 0;
73543 + }
73544 + }
73545 +#endif
73546 + return 1;
73547 +}
73548 +
73549 +int
73550 +gr_chroot_is_capable_nolog(const int cap)
73551 +{
73552 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
73553 + return gr_task_chroot_is_capable_nolog(current, cap);
73554 +#endif
73555 + return 1;
73556 +}
73557 +
73558 +int
73559 +gr_handle_chroot_sysctl(const int op)
73560 +{
73561 +#ifdef CONFIG_GRKERNSEC_CHROOT_SYSCTL
73562 + if (grsec_enable_chroot_sysctl && (op & MAY_WRITE) &&
73563 + proc_is_chrooted(current))
73564 + return -EACCES;
73565 +#endif
73566 + return 0;
73567 +}
73568 +
73569 +void
73570 +gr_handle_chroot_chdir(const struct path *path)
73571 +{
73572 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHDIR
73573 + if (grsec_enable_chroot_chdir)
73574 + set_fs_pwd(current->fs, path);
73575 +#endif
73576 + return;
73577 +}
73578 +
73579 +int
73580 +gr_handle_chroot_chmod(const struct dentry *dentry,
73581 + const struct vfsmount *mnt, const int mode)
73582 +{
73583 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHMOD
73584 + /* allow chmod +s on directories, but not files */
73585 + if (grsec_enable_chroot_chmod && !S_ISDIR(dentry->d_inode->i_mode) &&
73586 + ((mode & S_ISUID) || ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))) &&
73587 + proc_is_chrooted(current)) {
73588 + gr_log_fs_generic(GR_DONT_AUDIT, GR_CHMOD_CHROOT_MSG, dentry, mnt);
73589 + return -EPERM;
73590 + }
73591 +#endif
73592 + return 0;
73593 +}
73594 diff --git a/grsecurity/grsec_disabled.c b/grsecurity/grsec_disabled.c
73595 new file mode 100644
73596 index 0000000..de31e65
73597 --- /dev/null
73598 +++ b/grsecurity/grsec_disabled.c
73599 @@ -0,0 +1,434 @@
73600 +#include <linux/kernel.h>
73601 +#include <linux/module.h>
73602 +#include <linux/sched.h>
73603 +#include <linux/file.h>
73604 +#include <linux/fs.h>
73605 +#include <linux/kdev_t.h>
73606 +#include <linux/net.h>
73607 +#include <linux/in.h>
73608 +#include <linux/ip.h>
73609 +#include <linux/skbuff.h>
73610 +#include <linux/sysctl.h>
73611 +
73612 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
73613 +void
73614 +pax_set_initial_flags(struct linux_binprm *bprm)
73615 +{
73616 + return;
73617 +}
73618 +#endif
73619 +
73620 +#ifdef CONFIG_SYSCTL
73621 +__u32
73622 +gr_handle_sysctl(const struct ctl_table * table, const int op)
73623 +{
73624 + return 0;
73625 +}
73626 +#endif
73627 +
73628 +#ifdef CONFIG_TASKSTATS
73629 +int gr_is_taskstats_denied(int pid)
73630 +{
73631 + return 0;
73632 +}
73633 +#endif
73634 +
73635 +int
73636 +gr_acl_is_enabled(void)
73637 +{
73638 + return 0;
73639 +}
73640 +
73641 +void
73642 +gr_handle_proc_create(const struct dentry *dentry, const struct inode *inode)
73643 +{
73644 + return;
73645 +}
73646 +
73647 +int
73648 +gr_handle_rawio(const struct inode *inode)
73649 +{
73650 + return 0;
73651 +}
73652 +
73653 +void
73654 +gr_acl_handle_psacct(struct task_struct *task, const long code)
73655 +{
73656 + return;
73657 +}
73658 +
73659 +int
73660 +gr_handle_ptrace(struct task_struct *task, const long request)
73661 +{
73662 + return 0;
73663 +}
73664 +
73665 +int
73666 +gr_handle_proc_ptrace(struct task_struct *task)
73667 +{
73668 + return 0;
73669 +}
73670 +
73671 +int
73672 +gr_set_acls(const int type)
73673 +{
73674 + return 0;
73675 +}
73676 +
73677 +int
73678 +gr_check_hidden_task(const struct task_struct *tsk)
73679 +{
73680 + return 0;
73681 +}
73682 +
73683 +int
73684 +gr_check_protected_task(const struct task_struct *task)
73685 +{
73686 + return 0;
73687 +}
73688 +
73689 +int
73690 +gr_check_protected_task_fowner(struct pid *pid, enum pid_type type)
73691 +{
73692 + return 0;
73693 +}
73694 +
73695 +void
73696 +gr_copy_label(struct task_struct *tsk)
73697 +{
73698 + return;
73699 +}
73700 +
73701 +void
73702 +gr_set_pax_flags(struct task_struct *task)
73703 +{
73704 + return;
73705 +}
73706 +
73707 +int
73708 +gr_set_proc_label(const struct dentry *dentry, const struct vfsmount *mnt,
73709 + const int unsafe_share)
73710 +{
73711 + return 0;
73712 +}
73713 +
73714 +void
73715 +gr_handle_delete(const ino_t ino, const dev_t dev)
73716 +{
73717 + return;
73718 +}
73719 +
73720 +void
73721 +gr_handle_create(const struct dentry *dentry, const struct vfsmount *mnt)
73722 +{
73723 + return;
73724 +}
73725 +
73726 +void
73727 +gr_handle_crash(struct task_struct *task, const int sig)
73728 +{
73729 + return;
73730 +}
73731 +
73732 +int
73733 +gr_check_crash_exec(const struct file *filp)
73734 +{
73735 + return 0;
73736 +}
73737 +
73738 +int
73739 +gr_check_crash_uid(const kuid_t uid)
73740 +{
73741 + return 0;
73742 +}
73743 +
73744 +void
73745 +gr_handle_rename(struct inode *old_dir, struct inode *new_dir,
73746 + struct dentry *old_dentry,
73747 + struct dentry *new_dentry,
73748 + struct vfsmount *mnt, const __u8 replace, unsigned int flags)
73749 +{
73750 + return;
73751 +}
73752 +
73753 +int
73754 +gr_search_socket(const int family, const int type, const int protocol)
73755 +{
73756 + return 1;
73757 +}
73758 +
73759 +int
73760 +gr_search_connectbind(const int mode, const struct socket *sock,
73761 + const struct sockaddr_in *addr)
73762 +{
73763 + return 0;
73764 +}
73765 +
73766 +void
73767 +gr_handle_alertkill(struct task_struct *task)
73768 +{
73769 + return;
73770 +}
73771 +
73772 +__u32
73773 +gr_acl_handle_execve(const struct dentry * dentry, const struct vfsmount * mnt)
73774 +{
73775 + return 1;
73776 +}
73777 +
73778 +__u32
73779 +gr_acl_handle_hidden_file(const struct dentry * dentry,
73780 + const struct vfsmount * mnt)
73781 +{
73782 + return 1;
73783 +}
73784 +
73785 +__u32
73786 +gr_acl_handle_open(const struct dentry * dentry, const struct vfsmount * mnt,
73787 + int acc_mode)
73788 +{
73789 + return 1;
73790 +}
73791 +
73792 +__u32
73793 +gr_acl_handle_rmdir(const struct dentry * dentry, const struct vfsmount * mnt)
73794 +{
73795 + return 1;
73796 +}
73797 +
73798 +__u32
73799 +gr_acl_handle_unlink(const struct dentry * dentry, const struct vfsmount * mnt)
73800 +{
73801 + return 1;
73802 +}
73803 +
73804 +int
73805 +gr_acl_handle_mmap(const struct file *file, const unsigned long prot,
73806 + unsigned int *vm_flags)
73807 +{
73808 + return 1;
73809 +}
73810 +
73811 +__u32
73812 +gr_acl_handle_truncate(const struct dentry * dentry,
73813 + const struct vfsmount * mnt)
73814 +{
73815 + return 1;
73816 +}
73817 +
73818 +__u32
73819 +gr_acl_handle_utime(const struct dentry * dentry, const struct vfsmount * mnt)
73820 +{
73821 + return 1;
73822 +}
73823 +
73824 +__u32
73825 +gr_acl_handle_access(const struct dentry * dentry,
73826 + const struct vfsmount * mnt, const int fmode)
73827 +{
73828 + return 1;
73829 +}
73830 +
73831 +__u32
73832 +gr_acl_handle_chmod(const struct dentry * dentry, const struct vfsmount * mnt,
73833 + umode_t *mode)
73834 +{
73835 + return 1;
73836 +}
73837 +
73838 +__u32
73839 +gr_acl_handle_chown(const struct dentry * dentry, const struct vfsmount * mnt)
73840 +{
73841 + return 1;
73842 +}
73843 +
73844 +__u32
73845 +gr_acl_handle_setxattr(const struct dentry * dentry, const struct vfsmount * mnt)
73846 +{
73847 + return 1;
73848 +}
73849 +
73850 +__u32
73851 +gr_acl_handle_removexattr(const struct dentry * dentry, const struct vfsmount * mnt)
73852 +{
73853 + return 1;
73854 +}
73855 +
73856 +void
73857 +grsecurity_init(void)
73858 +{
73859 + return;
73860 +}
73861 +
73862 +umode_t gr_acl_umask(void)
73863 +{
73864 + return 0;
73865 +}
73866 +
73867 +__u32
73868 +gr_acl_handle_mknod(const struct dentry * new_dentry,
73869 + const struct dentry * parent_dentry,
73870 + const struct vfsmount * parent_mnt,
73871 + const int mode)
73872 +{
73873 + return 1;
73874 +}
73875 +
73876 +__u32
73877 +gr_acl_handle_mkdir(const struct dentry * new_dentry,
73878 + const struct dentry * parent_dentry,
73879 + const struct vfsmount * parent_mnt)
73880 +{
73881 + return 1;
73882 +}
73883 +
73884 +__u32
73885 +gr_acl_handle_symlink(const struct dentry * new_dentry,
73886 + const struct dentry * parent_dentry,
73887 + const struct vfsmount * parent_mnt, const struct filename *from)
73888 +{
73889 + return 1;
73890 +}
73891 +
73892 +__u32
73893 +gr_acl_handle_link(const struct dentry * new_dentry,
73894 + const struct dentry * parent_dentry,
73895 + const struct vfsmount * parent_mnt,
73896 + const struct dentry * old_dentry,
73897 + const struct vfsmount * old_mnt, const struct filename *to)
73898 +{
73899 + return 1;
73900 +}
73901 +
73902 +int
73903 +gr_acl_handle_rename(const struct dentry *new_dentry,
73904 + const struct dentry *parent_dentry,
73905 + const struct vfsmount *parent_mnt,
73906 + const struct dentry *old_dentry,
73907 + const struct inode *old_parent_inode,
73908 + const struct vfsmount *old_mnt, const struct filename *newname,
73909 + unsigned int flags)
73910 +{
73911 + return 0;
73912 +}
73913 +
73914 +int
73915 +gr_acl_handle_filldir(const struct file *file, const char *name,
73916 + const int namelen, const ino_t ino)
73917 +{
73918 + return 1;
73919 +}
73920 +
73921 +int
73922 +gr_handle_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
73923 + const time_t shm_createtime, const kuid_t cuid, const int shmid)
73924 +{
73925 + return 1;
73926 +}
73927 +
73928 +int
73929 +gr_search_bind(const struct socket *sock, const struct sockaddr_in *addr)
73930 +{
73931 + return 0;
73932 +}
73933 +
73934 +int
73935 +gr_search_accept(const struct socket *sock)
73936 +{
73937 + return 0;
73938 +}
73939 +
73940 +int
73941 +gr_search_listen(const struct socket *sock)
73942 +{
73943 + return 0;
73944 +}
73945 +
73946 +int
73947 +gr_search_connect(const struct socket *sock, const struct sockaddr_in *addr)
73948 +{
73949 + return 0;
73950 +}
73951 +
73952 +__u32
73953 +gr_acl_handle_unix(const struct dentry * dentry, const struct vfsmount * mnt)
73954 +{
73955 + return 1;
73956 +}
73957 +
73958 +__u32
73959 +gr_acl_handle_creat(const struct dentry * dentry,
73960 + const struct dentry * p_dentry,
73961 + const struct vfsmount * p_mnt, int open_flags, int acc_mode,
73962 + const int imode)
73963 +{
73964 + return 1;
73965 +}
73966 +
73967 +void
73968 +gr_acl_handle_exit(void)
73969 +{
73970 + return;
73971 +}
73972 +
73973 +int
73974 +gr_acl_handle_mprotect(const struct file *file, const unsigned long prot)
73975 +{
73976 + return 1;
73977 +}
73978 +
73979 +void
73980 +gr_set_role_label(const kuid_t uid, const kgid_t gid)
73981 +{
73982 + return;
73983 +}
73984 +
73985 +int
73986 +gr_acl_handle_procpidmem(const struct task_struct *task)
73987 +{
73988 + return 0;
73989 +}
73990 +
73991 +int
73992 +gr_search_udp_recvmsg(const struct sock *sk, const struct sk_buff *skb)
73993 +{
73994 + return 0;
73995 +}
73996 +
73997 +int
73998 +gr_search_udp_sendmsg(const struct sock *sk, const struct sockaddr_in *addr)
73999 +{
74000 + return 0;
74001 +}
74002 +
74003 +int
74004 +gr_check_user_change(kuid_t real, kuid_t effective, kuid_t fs)
74005 +{
74006 + return 0;
74007 +}
74008 +
74009 +int
74010 +gr_check_group_change(kgid_t real, kgid_t effective, kgid_t fs)
74011 +{
74012 + return 0;
74013 +}
74014 +
74015 +int gr_acl_enable_at_secure(void)
74016 +{
74017 + return 0;
74018 +}
74019 +
74020 +dev_t gr_get_dev_from_dentry(struct dentry *dentry)
74021 +{
74022 + return dentry->d_sb->s_dev;
74023 +}
74024 +
74025 +void gr_put_exec_file(struct task_struct *task)
74026 +{
74027 + return;
74028 +}
74029 +
74030 +#ifdef CONFIG_SECURITY
74031 +EXPORT_SYMBOL_GPL(gr_check_user_change);
74032 +EXPORT_SYMBOL_GPL(gr_check_group_change);
74033 +#endif
74034 diff --git a/grsecurity/grsec_exec.c b/grsecurity/grsec_exec.c
74035 new file mode 100644
74036 index 0000000..f35f454
74037 --- /dev/null
74038 +++ b/grsecurity/grsec_exec.c
74039 @@ -0,0 +1,187 @@
74040 +#include <linux/kernel.h>
74041 +#include <linux/sched.h>
74042 +#include <linux/file.h>
74043 +#include <linux/binfmts.h>
74044 +#include <linux/fs.h>
74045 +#include <linux/types.h>
74046 +#include <linux/grdefs.h>
74047 +#include <linux/grsecurity.h>
74048 +#include <linux/grinternal.h>
74049 +#include <linux/capability.h>
74050 +#include <linux/module.h>
74051 +#include <linux/compat.h>
74052 +
74053 +#include <asm/uaccess.h>
74054 +
74055 +#ifdef CONFIG_GRKERNSEC_EXECLOG
74056 +static char gr_exec_arg_buf[132];
74057 +static DEFINE_MUTEX(gr_exec_arg_mutex);
74058 +#endif
74059 +
74060 +struct user_arg_ptr {
74061 +#ifdef CONFIG_COMPAT
74062 + bool is_compat;
74063 +#endif
74064 + union {
74065 + const char __user *const __user *native;
74066 +#ifdef CONFIG_COMPAT
74067 + const compat_uptr_t __user *compat;
74068 +#endif
74069 + } ptr;
74070 +};
74071 +
74072 +extern const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr);
74073 +
74074 +void
74075 +gr_handle_exec_args(struct linux_binprm *bprm, struct user_arg_ptr argv)
74076 +{
74077 +#ifdef CONFIG_GRKERNSEC_EXECLOG
74078 + char *grarg = gr_exec_arg_buf;
74079 + unsigned int i, x, execlen = 0;
74080 + char c;
74081 +
74082 + if (!((grsec_enable_execlog && grsec_enable_group &&
74083 + in_group_p(grsec_audit_gid))
74084 + || (grsec_enable_execlog && !grsec_enable_group)))
74085 + return;
74086 +
74087 + mutex_lock(&gr_exec_arg_mutex);
74088 + memset(grarg, 0, sizeof(gr_exec_arg_buf));
74089 +
74090 + for (i = 0; i < bprm->argc && execlen < 128; i++) {
74091 + const char __user *p;
74092 + unsigned int len;
74093 +
74094 + p = get_user_arg_ptr(argv, i);
74095 + if (IS_ERR(p))
74096 + goto log;
74097 +
74098 + len = strnlen_user(p, 128 - execlen);
74099 + if (len > 128 - execlen)
74100 + len = 128 - execlen;
74101 + else if (len > 0)
74102 + len--;
74103 + if (copy_from_user(grarg + execlen, p, len))
74104 + goto log;
74105 +
74106 + /* rewrite unprintable characters */
74107 + for (x = 0; x < len; x++) {
74108 + c = *(grarg + execlen + x);
74109 + if (c < 32 || c > 126)
74110 + *(grarg + execlen + x) = ' ';
74111 + }
74112 +
74113 + execlen += len;
74114 + *(grarg + execlen) = ' ';
74115 + *(grarg + execlen + 1) = '\0';
74116 + execlen++;
74117 + }
74118 +
74119 + log:
74120 + gr_log_fs_str(GR_DO_AUDIT, GR_EXEC_AUDIT_MSG, bprm->file->f_path.dentry,
74121 + bprm->file->f_path.mnt, grarg);
74122 + mutex_unlock(&gr_exec_arg_mutex);
74123 +#endif
74124 + return;
74125 +}
74126 +
74127 +#ifdef CONFIG_GRKERNSEC
74128 +extern int gr_acl_is_capable(const int cap);
74129 +extern int gr_acl_is_capable_nolog(const int cap);
74130 +extern int gr_task_acl_is_capable(const struct task_struct *task, const struct cred *cred, const int cap);
74131 +extern int gr_task_acl_is_capable_nolog(const struct task_struct *task, const int cap);
74132 +extern int gr_chroot_is_capable(const int cap);
74133 +extern int gr_chroot_is_capable_nolog(const int cap);
74134 +extern int gr_task_chroot_is_capable(const struct task_struct *task, const struct cred *cred, const int cap);
74135 +extern int gr_task_chroot_is_capable_nolog(const struct task_struct *task, const int cap);
74136 +#endif
74137 +
74138 +const char *captab_log[] = {
74139 + "CAP_CHOWN",
74140 + "CAP_DAC_OVERRIDE",
74141 + "CAP_DAC_READ_SEARCH",
74142 + "CAP_FOWNER",
74143 + "CAP_FSETID",
74144 + "CAP_KILL",
74145 + "CAP_SETGID",
74146 + "CAP_SETUID",
74147 + "CAP_SETPCAP",
74148 + "CAP_LINUX_IMMUTABLE",
74149 + "CAP_NET_BIND_SERVICE",
74150 + "CAP_NET_BROADCAST",
74151 + "CAP_NET_ADMIN",
74152 + "CAP_NET_RAW",
74153 + "CAP_IPC_LOCK",
74154 + "CAP_IPC_OWNER",
74155 + "CAP_SYS_MODULE",
74156 + "CAP_SYS_RAWIO",
74157 + "CAP_SYS_CHROOT",
74158 + "CAP_SYS_PTRACE",
74159 + "CAP_SYS_PACCT",
74160 + "CAP_SYS_ADMIN",
74161 + "CAP_SYS_BOOT",
74162 + "CAP_SYS_NICE",
74163 + "CAP_SYS_RESOURCE",
74164 + "CAP_SYS_TIME",
74165 + "CAP_SYS_TTY_CONFIG",
74166 + "CAP_MKNOD",
74167 + "CAP_LEASE",
74168 + "CAP_AUDIT_WRITE",
74169 + "CAP_AUDIT_CONTROL",
74170 + "CAP_SETFCAP",
74171 + "CAP_MAC_OVERRIDE",
74172 + "CAP_MAC_ADMIN",
74173 + "CAP_SYSLOG",
74174 + "CAP_WAKE_ALARM"
74175 +};
74176 +
74177 +int captab_log_entries = sizeof(captab_log)/sizeof(captab_log[0]);
74178 +
74179 +int gr_is_capable(const int cap)
74180 +{
74181 +#ifdef CONFIG_GRKERNSEC
74182 + if (gr_acl_is_capable(cap) && gr_chroot_is_capable(cap))
74183 + return 1;
74184 + return 0;
74185 +#else
74186 + return 1;
74187 +#endif
74188 +}
74189 +
74190 +int gr_task_is_capable(const struct task_struct *task, const struct cred *cred, const int cap)
74191 +{
74192 +#ifdef CONFIG_GRKERNSEC
74193 + if (gr_task_acl_is_capable(task, cred, cap) && gr_task_chroot_is_capable(task, cred, cap))
74194 + return 1;
74195 + return 0;
74196 +#else
74197 + return 1;
74198 +#endif
74199 +}
74200 +
74201 +int gr_is_capable_nolog(const int cap)
74202 +{
74203 +#ifdef CONFIG_GRKERNSEC
74204 + if (gr_acl_is_capable_nolog(cap) && gr_chroot_is_capable_nolog(cap))
74205 + return 1;
74206 + return 0;
74207 +#else
74208 + return 1;
74209 +#endif
74210 +}
74211 +
74212 +int gr_task_is_capable_nolog(const struct task_struct *task, const int cap)
74213 +{
74214 +#ifdef CONFIG_GRKERNSEC
74215 + if (gr_task_acl_is_capable_nolog(task, cap) && gr_task_chroot_is_capable_nolog(task, cap))
74216 + return 1;
74217 + return 0;
74218 +#else
74219 + return 1;
74220 +#endif
74221 +}
74222 +
74223 +EXPORT_SYMBOL_GPL(gr_is_capable);
74224 +EXPORT_SYMBOL_GPL(gr_is_capable_nolog);
74225 +EXPORT_SYMBOL_GPL(gr_task_is_capable);
74226 +EXPORT_SYMBOL_GPL(gr_task_is_capable_nolog);
74227 diff --git a/grsecurity/grsec_fifo.c b/grsecurity/grsec_fifo.c
74228 new file mode 100644
74229 index 0000000..06cc6ea
74230 --- /dev/null
74231 +++ b/grsecurity/grsec_fifo.c
74232 @@ -0,0 +1,24 @@
74233 +#include <linux/kernel.h>
74234 +#include <linux/sched.h>
74235 +#include <linux/fs.h>
74236 +#include <linux/file.h>
74237 +#include <linux/grinternal.h>
74238 +
74239 +int
74240 +gr_handle_fifo(const struct dentry *dentry, const struct vfsmount *mnt,
74241 + const struct dentry *dir, const int flag, const int acc_mode)
74242 +{
74243 +#ifdef CONFIG_GRKERNSEC_FIFO
74244 + const struct cred *cred = current_cred();
74245 +
74246 + if (grsec_enable_fifo && S_ISFIFO(dentry->d_inode->i_mode) &&
74247 + !(flag & O_EXCL) && (dir->d_inode->i_mode & S_ISVTX) &&
74248 + !uid_eq(dentry->d_inode->i_uid, dir->d_inode->i_uid) &&
74249 + !uid_eq(cred->fsuid, dentry->d_inode->i_uid)) {
74250 + if (!inode_permission(dentry->d_inode, acc_mode))
74251 + 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));
74252 + return -EACCES;
74253 + }
74254 +#endif
74255 + return 0;
74256 +}
74257 diff --git a/grsecurity/grsec_fork.c b/grsecurity/grsec_fork.c
74258 new file mode 100644
74259 index 0000000..8ca18bf
74260 --- /dev/null
74261 +++ b/grsecurity/grsec_fork.c
74262 @@ -0,0 +1,23 @@
74263 +#include <linux/kernel.h>
74264 +#include <linux/sched.h>
74265 +#include <linux/grsecurity.h>
74266 +#include <linux/grinternal.h>
74267 +#include <linux/errno.h>
74268 +
74269 +void
74270 +gr_log_forkfail(const int retval)
74271 +{
74272 +#ifdef CONFIG_GRKERNSEC_FORKFAIL
74273 + if (grsec_enable_forkfail && (retval == -EAGAIN || retval == -ENOMEM)) {
74274 + switch (retval) {
74275 + case -EAGAIN:
74276 + gr_log_str(GR_DONT_AUDIT, GR_FAILFORK_MSG, "EAGAIN");
74277 + break;
74278 + case -ENOMEM:
74279 + gr_log_str(GR_DONT_AUDIT, GR_FAILFORK_MSG, "ENOMEM");
74280 + break;
74281 + }
74282 + }
74283 +#endif
74284 + return;
74285 +}
74286 diff --git a/grsecurity/grsec_init.c b/grsecurity/grsec_init.c
74287 new file mode 100644
74288 index 0000000..ae6c028
74289 --- /dev/null
74290 +++ b/grsecurity/grsec_init.c
74291 @@ -0,0 +1,272 @@
74292 +#include <linux/kernel.h>
74293 +#include <linux/sched.h>
74294 +#include <linux/mm.h>
74295 +#include <linux/gracl.h>
74296 +#include <linux/slab.h>
74297 +#include <linux/vmalloc.h>
74298 +#include <linux/percpu.h>
74299 +#include <linux/module.h>
74300 +
74301 +int grsec_enable_ptrace_readexec;
74302 +int grsec_enable_setxid;
74303 +int grsec_enable_symlinkown;
74304 +kgid_t grsec_symlinkown_gid;
74305 +int grsec_enable_brute;
74306 +int grsec_enable_link;
74307 +int grsec_enable_dmesg;
74308 +int grsec_enable_harden_ptrace;
74309 +int grsec_enable_harden_ipc;
74310 +int grsec_enable_fifo;
74311 +int grsec_enable_execlog;
74312 +int grsec_enable_signal;
74313 +int grsec_enable_forkfail;
74314 +int grsec_enable_audit_ptrace;
74315 +int grsec_enable_time;
74316 +int grsec_enable_group;
74317 +kgid_t grsec_audit_gid;
74318 +int grsec_enable_chdir;
74319 +int grsec_enable_mount;
74320 +int grsec_enable_rofs;
74321 +int grsec_deny_new_usb;
74322 +int grsec_enable_chroot_findtask;
74323 +int grsec_enable_chroot_mount;
74324 +int grsec_enable_chroot_shmat;
74325 +int grsec_enable_chroot_fchdir;
74326 +int grsec_enable_chroot_double;
74327 +int grsec_enable_chroot_pivot;
74328 +int grsec_enable_chroot_chdir;
74329 +int grsec_enable_chroot_chmod;
74330 +int grsec_enable_chroot_mknod;
74331 +int grsec_enable_chroot_nice;
74332 +int grsec_enable_chroot_execlog;
74333 +int grsec_enable_chroot_caps;
74334 +int grsec_enable_chroot_sysctl;
74335 +int grsec_enable_chroot_unix;
74336 +int grsec_enable_tpe;
74337 +kgid_t grsec_tpe_gid;
74338 +int grsec_enable_blackhole;
74339 +#ifdef CONFIG_IPV6_MODULE
74340 +EXPORT_SYMBOL_GPL(grsec_enable_blackhole);
74341 +#endif
74342 +int grsec_lastack_retries;
74343 +int grsec_enable_tpe_all;
74344 +int grsec_enable_tpe_invert;
74345 +int grsec_enable_socket_all;
74346 +kgid_t grsec_socket_all_gid;
74347 +int grsec_enable_socket_client;
74348 +kgid_t grsec_socket_client_gid;
74349 +int grsec_enable_socket_server;
74350 +kgid_t grsec_socket_server_gid;
74351 +int grsec_resource_logging;
74352 +int grsec_disable_privio;
74353 +int grsec_enable_log_rwxmaps;
74354 +int grsec_lock;
74355 +
74356 +DEFINE_SPINLOCK(grsec_alert_lock);
74357 +unsigned long grsec_alert_wtime = 0;
74358 +unsigned long grsec_alert_fyet = 0;
74359 +
74360 +DEFINE_SPINLOCK(grsec_audit_lock);
74361 +
74362 +DEFINE_RWLOCK(grsec_exec_file_lock);
74363 +
74364 +char *gr_shared_page[4];
74365 +
74366 +char *gr_alert_log_fmt;
74367 +char *gr_audit_log_fmt;
74368 +char *gr_alert_log_buf;
74369 +char *gr_audit_log_buf;
74370 +
74371 +void __init
74372 +grsecurity_init(void)
74373 +{
74374 + int j;
74375 + /* create the per-cpu shared pages */
74376 +
74377 +#ifdef CONFIG_X86
74378 + memset((char *)(0x41a + PAGE_OFFSET), 0, 36);
74379 +#endif
74380 +
74381 + for (j = 0; j < 4; j++) {
74382 + gr_shared_page[j] = (char *)__alloc_percpu(PAGE_SIZE, __alignof__(unsigned long long));
74383 + if (gr_shared_page[j] == NULL) {
74384 + panic("Unable to allocate grsecurity shared page");
74385 + return;
74386 + }
74387 + }
74388 +
74389 + /* allocate log buffers */
74390 + gr_alert_log_fmt = kmalloc(512, GFP_KERNEL);
74391 + if (!gr_alert_log_fmt) {
74392 + panic("Unable to allocate grsecurity alert log format buffer");
74393 + return;
74394 + }
74395 + gr_audit_log_fmt = kmalloc(512, GFP_KERNEL);
74396 + if (!gr_audit_log_fmt) {
74397 + panic("Unable to allocate grsecurity audit log format buffer");
74398 + return;
74399 + }
74400 + gr_alert_log_buf = (char *) get_zeroed_page(GFP_KERNEL);
74401 + if (!gr_alert_log_buf) {
74402 + panic("Unable to allocate grsecurity alert log buffer");
74403 + return;
74404 + }
74405 + gr_audit_log_buf = (char *) get_zeroed_page(GFP_KERNEL);
74406 + if (!gr_audit_log_buf) {
74407 + panic("Unable to allocate grsecurity audit log buffer");
74408 + return;
74409 + }
74410 +
74411 +#ifdef CONFIG_GRKERNSEC_IO
74412 +#if !defined(CONFIG_GRKERNSEC_SYSCTL_DISTRO)
74413 + grsec_disable_privio = 1;
74414 +#elif defined(CONFIG_GRKERNSEC_SYSCTL_ON)
74415 + grsec_disable_privio = 1;
74416 +#else
74417 + grsec_disable_privio = 0;
74418 +#endif
74419 +#endif
74420 +
74421 +#ifdef CONFIG_GRKERNSEC_TPE_INVERT
74422 + /* for backward compatibility, tpe_invert always defaults to on if
74423 + enabled in the kernel
74424 + */
74425 + grsec_enable_tpe_invert = 1;
74426 +#endif
74427 +
74428 +#if !defined(CONFIG_GRKERNSEC_SYSCTL) || defined(CONFIG_GRKERNSEC_SYSCTL_ON)
74429 +#ifndef CONFIG_GRKERNSEC_SYSCTL
74430 + grsec_lock = 1;
74431 +#endif
74432 +
74433 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
74434 + grsec_enable_log_rwxmaps = 1;
74435 +#endif
74436 +#ifdef CONFIG_GRKERNSEC_AUDIT_GROUP
74437 + grsec_enable_group = 1;
74438 + grsec_audit_gid = KGIDT_INIT(CONFIG_GRKERNSEC_AUDIT_GID);
74439 +#endif
74440 +#ifdef CONFIG_GRKERNSEC_PTRACE_READEXEC
74441 + grsec_enable_ptrace_readexec = 1;
74442 +#endif
74443 +#ifdef CONFIG_GRKERNSEC_AUDIT_CHDIR
74444 + grsec_enable_chdir = 1;
74445 +#endif
74446 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
74447 + grsec_enable_harden_ptrace = 1;
74448 +#endif
74449 +#ifdef CONFIG_GRKERNSEC_HARDEN_IPC
74450 + grsec_enable_harden_ipc = 1;
74451 +#endif
74452 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
74453 + grsec_enable_mount = 1;
74454 +#endif
74455 +#ifdef CONFIG_GRKERNSEC_LINK
74456 + grsec_enable_link = 1;
74457 +#endif
74458 +#ifdef CONFIG_GRKERNSEC_BRUTE
74459 + grsec_enable_brute = 1;
74460 +#endif
74461 +#ifdef CONFIG_GRKERNSEC_DMESG
74462 + grsec_enable_dmesg = 1;
74463 +#endif
74464 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
74465 + grsec_enable_blackhole = 1;
74466 + grsec_lastack_retries = 4;
74467 +#endif
74468 +#ifdef CONFIG_GRKERNSEC_FIFO
74469 + grsec_enable_fifo = 1;
74470 +#endif
74471 +#ifdef CONFIG_GRKERNSEC_EXECLOG
74472 + grsec_enable_execlog = 1;
74473 +#endif
74474 +#ifdef CONFIG_GRKERNSEC_SETXID
74475 + grsec_enable_setxid = 1;
74476 +#endif
74477 +#ifdef CONFIG_GRKERNSEC_SIGNAL
74478 + grsec_enable_signal = 1;
74479 +#endif
74480 +#ifdef CONFIG_GRKERNSEC_FORKFAIL
74481 + grsec_enable_forkfail = 1;
74482 +#endif
74483 +#ifdef CONFIG_GRKERNSEC_TIME
74484 + grsec_enable_time = 1;
74485 +#endif
74486 +#ifdef CONFIG_GRKERNSEC_RESLOG
74487 + grsec_resource_logging = 1;
74488 +#endif
74489 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
74490 + grsec_enable_chroot_findtask = 1;
74491 +#endif
74492 +#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
74493 + grsec_enable_chroot_unix = 1;
74494 +#endif
74495 +#ifdef CONFIG_GRKERNSEC_CHROOT_MOUNT
74496 + grsec_enable_chroot_mount = 1;
74497 +#endif
74498 +#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
74499 + grsec_enable_chroot_fchdir = 1;
74500 +#endif
74501 +#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
74502 + grsec_enable_chroot_shmat = 1;
74503 +#endif
74504 +#ifdef CONFIG_GRKERNSEC_AUDIT_PTRACE
74505 + grsec_enable_audit_ptrace = 1;
74506 +#endif
74507 +#ifdef CONFIG_GRKERNSEC_CHROOT_DOUBLE
74508 + grsec_enable_chroot_double = 1;
74509 +#endif
74510 +#ifdef CONFIG_GRKERNSEC_CHROOT_PIVOT
74511 + grsec_enable_chroot_pivot = 1;
74512 +#endif
74513 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHDIR
74514 + grsec_enable_chroot_chdir = 1;
74515 +#endif
74516 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHMOD
74517 + grsec_enable_chroot_chmod = 1;
74518 +#endif
74519 +#ifdef CONFIG_GRKERNSEC_CHROOT_MKNOD
74520 + grsec_enable_chroot_mknod = 1;
74521 +#endif
74522 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
74523 + grsec_enable_chroot_nice = 1;
74524 +#endif
74525 +#ifdef CONFIG_GRKERNSEC_CHROOT_EXECLOG
74526 + grsec_enable_chroot_execlog = 1;
74527 +#endif
74528 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
74529 + grsec_enable_chroot_caps = 1;
74530 +#endif
74531 +#ifdef CONFIG_GRKERNSEC_CHROOT_SYSCTL
74532 + grsec_enable_chroot_sysctl = 1;
74533 +#endif
74534 +#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
74535 + grsec_enable_symlinkown = 1;
74536 + grsec_symlinkown_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SYMLINKOWN_GID);
74537 +#endif
74538 +#ifdef CONFIG_GRKERNSEC_TPE
74539 + grsec_enable_tpe = 1;
74540 + grsec_tpe_gid = KGIDT_INIT(CONFIG_GRKERNSEC_TPE_GID);
74541 +#ifdef CONFIG_GRKERNSEC_TPE_ALL
74542 + grsec_enable_tpe_all = 1;
74543 +#endif
74544 +#endif
74545 +#ifdef CONFIG_GRKERNSEC_SOCKET_ALL
74546 + grsec_enable_socket_all = 1;
74547 + grsec_socket_all_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SOCKET_ALL_GID);
74548 +#endif
74549 +#ifdef CONFIG_GRKERNSEC_SOCKET_CLIENT
74550 + grsec_enable_socket_client = 1;
74551 + grsec_socket_client_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SOCKET_CLIENT_GID);
74552 +#endif
74553 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
74554 + grsec_enable_socket_server = 1;
74555 + grsec_socket_server_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SOCKET_SERVER_GID);
74556 +#endif
74557 +#endif
74558 +#ifdef CONFIG_GRKERNSEC_DENYUSB_FORCE
74559 + grsec_deny_new_usb = 1;
74560 +#endif
74561 +
74562 + return;
74563 +}
74564 diff --git a/grsecurity/grsec_ipc.c b/grsecurity/grsec_ipc.c
74565 new file mode 100644
74566 index 0000000..1773300
74567 --- /dev/null
74568 +++ b/grsecurity/grsec_ipc.c
74569 @@ -0,0 +1,48 @@
74570 +#include <linux/kernel.h>
74571 +#include <linux/mm.h>
74572 +#include <linux/sched.h>
74573 +#include <linux/file.h>
74574 +#include <linux/ipc.h>
74575 +#include <linux/ipc_namespace.h>
74576 +#include <linux/grsecurity.h>
74577 +#include <linux/grinternal.h>
74578 +
74579 +int
74580 +gr_ipc_permitted(struct ipc_namespace *ns, struct kern_ipc_perm *ipcp, int requested_mode, int granted_mode)
74581 +{
74582 +#ifdef CONFIG_GRKERNSEC_HARDEN_IPC
74583 + int write;
74584 + int orig_granted_mode;
74585 + kuid_t euid;
74586 + kgid_t egid;
74587 +
74588 + if (!grsec_enable_harden_ipc)
74589 + return 1;
74590 +
74591 + euid = current_euid();
74592 + egid = current_egid();
74593 +
74594 + write = requested_mode & 00002;
74595 + orig_granted_mode = ipcp->mode;
74596 +
74597 + if (uid_eq(euid, ipcp->cuid) || uid_eq(euid, ipcp->uid))
74598 + orig_granted_mode >>= 6;
74599 + else {
74600 + /* if likely wrong permissions, lock to user */
74601 + if (orig_granted_mode & 0007)
74602 + orig_granted_mode = 0;
74603 + /* otherwise do a egid-only check */
74604 + else if (gid_eq(egid, ipcp->cgid) || gid_eq(egid, ipcp->gid))
74605 + orig_granted_mode >>= 3;
74606 + /* otherwise, no access */
74607 + else
74608 + orig_granted_mode = 0;
74609 + }
74610 + if (!(requested_mode & ~granted_mode & 0007) && (requested_mode & ~orig_granted_mode & 0007) &&
74611 + !ns_capable_nolog(ns->user_ns, CAP_IPC_OWNER)) {
74612 + gr_log_str_int(GR_DONT_AUDIT, GR_IPC_DENIED_MSG, write ? "write" : "read", GR_GLOBAL_UID(ipcp->cuid));
74613 + return 0;
74614 + }
74615 +#endif
74616 + return 1;
74617 +}
74618 diff --git a/grsecurity/grsec_link.c b/grsecurity/grsec_link.c
74619 new file mode 100644
74620 index 0000000..5e05e20
74621 --- /dev/null
74622 +++ b/grsecurity/grsec_link.c
74623 @@ -0,0 +1,58 @@
74624 +#include <linux/kernel.h>
74625 +#include <linux/sched.h>
74626 +#include <linux/fs.h>
74627 +#include <linux/file.h>
74628 +#include <linux/grinternal.h>
74629 +
74630 +int gr_handle_symlink_owner(const struct path *link, const struct inode *target)
74631 +{
74632 +#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
74633 + const struct inode *link_inode = link->dentry->d_inode;
74634 +
74635 + if (grsec_enable_symlinkown && in_group_p(grsec_symlinkown_gid) &&
74636 + /* ignore root-owned links, e.g. /proc/self */
74637 + gr_is_global_nonroot(link_inode->i_uid) && target &&
74638 + !uid_eq(link_inode->i_uid, target->i_uid)) {
74639 + gr_log_fs_int2(GR_DONT_AUDIT, GR_SYMLINKOWNER_MSG, link->dentry, link->mnt, link_inode->i_uid, target->i_uid);
74640 + return 1;
74641 + }
74642 +#endif
74643 + return 0;
74644 +}
74645 +
74646 +int
74647 +gr_handle_follow_link(const struct inode *parent,
74648 + const struct inode *inode,
74649 + const struct dentry *dentry, const struct vfsmount *mnt)
74650 +{
74651 +#ifdef CONFIG_GRKERNSEC_LINK
74652 + const struct cred *cred = current_cred();
74653 +
74654 + if (grsec_enable_link && S_ISLNK(inode->i_mode) &&
74655 + (parent->i_mode & S_ISVTX) && !uid_eq(parent->i_uid, inode->i_uid) &&
74656 + (parent->i_mode & S_IWOTH) && !uid_eq(cred->fsuid, inode->i_uid)) {
74657 + gr_log_fs_int2(GR_DONT_AUDIT, GR_SYMLINK_MSG, dentry, mnt, inode->i_uid, inode->i_gid);
74658 + return -EACCES;
74659 + }
74660 +#endif
74661 + return 0;
74662 +}
74663 +
74664 +int
74665 +gr_handle_hardlink(const struct dentry *dentry,
74666 + const struct vfsmount *mnt,
74667 + struct inode *inode, const int mode, const struct filename *to)
74668 +{
74669 +#ifdef CONFIG_GRKERNSEC_LINK
74670 + const struct cred *cred = current_cred();
74671 +
74672 + if (grsec_enable_link && !uid_eq(cred->fsuid, inode->i_uid) &&
74673 + (!S_ISREG(mode) || is_privileged_binary(dentry) ||
74674 + (inode_permission(inode, MAY_READ | MAY_WRITE))) &&
74675 + !capable(CAP_FOWNER) && gr_is_global_nonroot(cred->uid)) {
74676 + gr_log_fs_int2_str(GR_DONT_AUDIT, GR_HARDLINK_MSG, dentry, mnt, inode->i_uid, inode->i_gid, to->name);
74677 + return -EPERM;
74678 + }
74679 +#endif
74680 + return 0;
74681 +}
74682 diff --git a/grsecurity/grsec_log.c b/grsecurity/grsec_log.c
74683 new file mode 100644
74684 index 0000000..dbe0a6b
74685 --- /dev/null
74686 +++ b/grsecurity/grsec_log.c
74687 @@ -0,0 +1,341 @@
74688 +#include <linux/kernel.h>
74689 +#include <linux/sched.h>
74690 +#include <linux/file.h>
74691 +#include <linux/tty.h>
74692 +#include <linux/fs.h>
74693 +#include <linux/mm.h>
74694 +#include <linux/grinternal.h>
74695 +
74696 +#ifdef CONFIG_TREE_PREEMPT_RCU
74697 +#define DISABLE_PREEMPT() preempt_disable()
74698 +#define ENABLE_PREEMPT() preempt_enable()
74699 +#else
74700 +#define DISABLE_PREEMPT()
74701 +#define ENABLE_PREEMPT()
74702 +#endif
74703 +
74704 +#define BEGIN_LOCKS(x) \
74705 + DISABLE_PREEMPT(); \
74706 + rcu_read_lock(); \
74707 + read_lock(&tasklist_lock); \
74708 + read_lock(&grsec_exec_file_lock); \
74709 + if (x != GR_DO_AUDIT) \
74710 + spin_lock(&grsec_alert_lock); \
74711 + else \
74712 + spin_lock(&grsec_audit_lock)
74713 +
74714 +#define END_LOCKS(x) \
74715 + if (x != GR_DO_AUDIT) \
74716 + spin_unlock(&grsec_alert_lock); \
74717 + else \
74718 + spin_unlock(&grsec_audit_lock); \
74719 + read_unlock(&grsec_exec_file_lock); \
74720 + read_unlock(&tasklist_lock); \
74721 + rcu_read_unlock(); \
74722 + ENABLE_PREEMPT(); \
74723 + if (x == GR_DONT_AUDIT) \
74724 + gr_handle_alertkill(current)
74725 +
74726 +enum {
74727 + FLOODING,
74728 + NO_FLOODING
74729 +};
74730 +
74731 +extern char *gr_alert_log_fmt;
74732 +extern char *gr_audit_log_fmt;
74733 +extern char *gr_alert_log_buf;
74734 +extern char *gr_audit_log_buf;
74735 +
74736 +static int gr_log_start(int audit)
74737 +{
74738 + char *loglevel = (audit == GR_DO_AUDIT) ? KERN_INFO : KERN_ALERT;
74739 + char *fmt = (audit == GR_DO_AUDIT) ? gr_audit_log_fmt : gr_alert_log_fmt;
74740 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
74741 +#if (CONFIG_GRKERNSEC_FLOODTIME > 0 && CONFIG_GRKERNSEC_FLOODBURST > 0)
74742 + unsigned long curr_secs = get_seconds();
74743 +
74744 + if (audit == GR_DO_AUDIT)
74745 + goto set_fmt;
74746 +
74747 + if (!grsec_alert_wtime || time_after(curr_secs, grsec_alert_wtime + CONFIG_GRKERNSEC_FLOODTIME)) {
74748 + grsec_alert_wtime = curr_secs;
74749 + grsec_alert_fyet = 0;
74750 + } else if (time_before_eq(curr_secs, grsec_alert_wtime + CONFIG_GRKERNSEC_FLOODTIME)
74751 + && (grsec_alert_fyet < CONFIG_GRKERNSEC_FLOODBURST)) {
74752 + grsec_alert_fyet++;
74753 + } else if (grsec_alert_fyet == CONFIG_GRKERNSEC_FLOODBURST) {
74754 + grsec_alert_wtime = curr_secs;
74755 + grsec_alert_fyet++;
74756 + printk(KERN_ALERT "grsec: more alerts, logging disabled for %d seconds\n", CONFIG_GRKERNSEC_FLOODTIME);
74757 + return FLOODING;
74758 + }
74759 + else return FLOODING;
74760 +
74761 +set_fmt:
74762 +#endif
74763 + memset(buf, 0, PAGE_SIZE);
74764 + if (current->signal->curr_ip && gr_acl_is_enabled()) {
74765 + sprintf(fmt, "%s%s", loglevel, "grsec: From %pI4: (%.64s:%c:%.950s) ");
74766 + snprintf(buf, PAGE_SIZE - 1, fmt, &current->signal->curr_ip, current->role->rolename, gr_roletype_to_char(), current->acl->filename);
74767 + } else if (current->signal->curr_ip) {
74768 + sprintf(fmt, "%s%s", loglevel, "grsec: From %pI4: ");
74769 + snprintf(buf, PAGE_SIZE - 1, fmt, &current->signal->curr_ip);
74770 + } else if (gr_acl_is_enabled()) {
74771 + sprintf(fmt, "%s%s", loglevel, "grsec: (%.64s:%c:%.950s) ");
74772 + snprintf(buf, PAGE_SIZE - 1, fmt, current->role->rolename, gr_roletype_to_char(), current->acl->filename);
74773 + } else {
74774 + sprintf(fmt, "%s%s", loglevel, "grsec: ");
74775 + strcpy(buf, fmt);
74776 + }
74777 +
74778 + return NO_FLOODING;
74779 +}
74780 +
74781 +static void gr_log_middle(int audit, const char *msg, va_list ap)
74782 + __attribute__ ((format (printf, 2, 0)));
74783 +
74784 +static void gr_log_middle(int audit, const char *msg, va_list ap)
74785 +{
74786 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
74787 + unsigned int len = strlen(buf);
74788 +
74789 + vsnprintf(buf + len, PAGE_SIZE - len - 1, msg, ap);
74790 +
74791 + return;
74792 +}
74793 +
74794 +static void gr_log_middle_varargs(int audit, const char *msg, ...)
74795 + __attribute__ ((format (printf, 2, 3)));
74796 +
74797 +static void gr_log_middle_varargs(int audit, const char *msg, ...)
74798 +{
74799 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
74800 + unsigned int len = strlen(buf);
74801 + va_list ap;
74802 +
74803 + va_start(ap, msg);
74804 + vsnprintf(buf + len, PAGE_SIZE - len - 1, msg, ap);
74805 + va_end(ap);
74806 +
74807 + return;
74808 +}
74809 +
74810 +static void gr_log_end(int audit, int append_default)
74811 +{
74812 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
74813 + if (append_default) {
74814 + struct task_struct *task = current;
74815 + struct task_struct *parent = task->real_parent;
74816 + const struct cred *cred = __task_cred(task);
74817 + const struct cred *pcred = __task_cred(parent);
74818 + unsigned int len = strlen(buf);
74819 +
74820 + 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));
74821 + }
74822 +
74823 + printk("%s\n", buf);
74824 +
74825 + return;
74826 +}
74827 +
74828 +void gr_log_varargs(int audit, const char *msg, int argtypes, ...)
74829 +{
74830 + int logtype;
74831 + char *result = (audit == GR_DO_AUDIT) ? "successful" : "denied";
74832 + char *str1 = NULL, *str2 = NULL, *str3 = NULL;
74833 + void *voidptr = NULL;
74834 + int num1 = 0, num2 = 0;
74835 + unsigned long ulong1 = 0, ulong2 = 0;
74836 + struct dentry *dentry = NULL;
74837 + struct vfsmount *mnt = NULL;
74838 + struct file *file = NULL;
74839 + struct task_struct *task = NULL;
74840 + struct vm_area_struct *vma = NULL;
74841 + const struct cred *cred, *pcred;
74842 + va_list ap;
74843 +
74844 + BEGIN_LOCKS(audit);
74845 + logtype = gr_log_start(audit);
74846 + if (logtype == FLOODING) {
74847 + END_LOCKS(audit);
74848 + return;
74849 + }
74850 + va_start(ap, argtypes);
74851 + switch (argtypes) {
74852 + case GR_TTYSNIFF:
74853 + task = va_arg(ap, struct task_struct *);
74854 + 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));
74855 + break;
74856 + case GR_SYSCTL_HIDDEN:
74857 + str1 = va_arg(ap, char *);
74858 + gr_log_middle_varargs(audit, msg, result, str1);
74859 + break;
74860 + case GR_RBAC:
74861 + dentry = va_arg(ap, struct dentry *);
74862 + mnt = va_arg(ap, struct vfsmount *);
74863 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt));
74864 + break;
74865 + case GR_RBAC_STR:
74866 + dentry = va_arg(ap, struct dentry *);
74867 + mnt = va_arg(ap, struct vfsmount *);
74868 + str1 = va_arg(ap, char *);
74869 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt), str1);
74870 + break;
74871 + case GR_STR_RBAC:
74872 + str1 = va_arg(ap, char *);
74873 + dentry = va_arg(ap, struct dentry *);
74874 + mnt = va_arg(ap, struct vfsmount *);
74875 + gr_log_middle_varargs(audit, msg, result, str1, gr_to_filename(dentry, mnt));
74876 + break;
74877 + case GR_RBAC_MODE2:
74878 + dentry = va_arg(ap, struct dentry *);
74879 + mnt = va_arg(ap, struct vfsmount *);
74880 + str1 = va_arg(ap, char *);
74881 + str2 = va_arg(ap, char *);
74882 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt), str1, str2);
74883 + break;
74884 + case GR_RBAC_MODE3:
74885 + dentry = va_arg(ap, struct dentry *);
74886 + mnt = va_arg(ap, struct vfsmount *);
74887 + str1 = va_arg(ap, char *);
74888 + str2 = va_arg(ap, char *);
74889 + str3 = va_arg(ap, char *);
74890 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt), str1, str2, str3);
74891 + break;
74892 + case GR_FILENAME:
74893 + dentry = va_arg(ap, struct dentry *);
74894 + mnt = va_arg(ap, struct vfsmount *);
74895 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt));
74896 + break;
74897 + case GR_STR_FILENAME:
74898 + str1 = va_arg(ap, char *);
74899 + dentry = va_arg(ap, struct dentry *);
74900 + mnt = va_arg(ap, struct vfsmount *);
74901 + gr_log_middle_varargs(audit, msg, str1, gr_to_filename(dentry, mnt));
74902 + break;
74903 + case GR_FILENAME_STR:
74904 + dentry = va_arg(ap, struct dentry *);
74905 + mnt = va_arg(ap, struct vfsmount *);
74906 + str1 = va_arg(ap, char *);
74907 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt), str1);
74908 + break;
74909 + case GR_FILENAME_TWO_INT:
74910 + dentry = va_arg(ap, struct dentry *);
74911 + mnt = va_arg(ap, struct vfsmount *);
74912 + num1 = va_arg(ap, int);
74913 + num2 = va_arg(ap, int);
74914 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt), num1, num2);
74915 + break;
74916 + case GR_FILENAME_TWO_INT_STR:
74917 + dentry = va_arg(ap, struct dentry *);
74918 + mnt = va_arg(ap, struct vfsmount *);
74919 + num1 = va_arg(ap, int);
74920 + num2 = va_arg(ap, int);
74921 + str1 = va_arg(ap, char *);
74922 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt), num1, num2, str1);
74923 + break;
74924 + case GR_TEXTREL:
74925 + file = va_arg(ap, struct file *);
74926 + ulong1 = va_arg(ap, unsigned long);
74927 + ulong2 = va_arg(ap, unsigned long);
74928 + gr_log_middle_varargs(audit, msg, file ? gr_to_filename(file->f_path.dentry, file->f_path.mnt) : "<anonymous mapping>", ulong1, ulong2);
74929 + break;
74930 + case GR_PTRACE:
74931 + task = va_arg(ap, struct task_struct *);
74932 + 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));
74933 + break;
74934 + case GR_RESOURCE:
74935 + task = va_arg(ap, struct task_struct *);
74936 + cred = __task_cred(task);
74937 + pcred = __task_cred(task->real_parent);
74938 + ulong1 = va_arg(ap, unsigned long);
74939 + str1 = va_arg(ap, char *);
74940 + ulong2 = va_arg(ap, unsigned long);
74941 + 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));
74942 + break;
74943 + case GR_CAP:
74944 + task = va_arg(ap, struct task_struct *);
74945 + cred = __task_cred(task);
74946 + pcred = __task_cred(task->real_parent);
74947 + str1 = va_arg(ap, char *);
74948 + 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));
74949 + break;
74950 + case GR_SIG:
74951 + str1 = va_arg(ap, char *);
74952 + voidptr = va_arg(ap, void *);
74953 + gr_log_middle_varargs(audit, msg, str1, voidptr);
74954 + break;
74955 + case GR_SIG2:
74956 + task = va_arg(ap, struct task_struct *);
74957 + cred = __task_cred(task);
74958 + pcred = __task_cred(task->real_parent);
74959 + num1 = va_arg(ap, int);
74960 + 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));
74961 + break;
74962 + case GR_CRASH1:
74963 + task = va_arg(ap, struct task_struct *);
74964 + cred = __task_cred(task);
74965 + pcred = __task_cred(task->real_parent);
74966 + ulong1 = va_arg(ap, unsigned long);
74967 + 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);
74968 + break;
74969 + case GR_CRASH2:
74970 + task = va_arg(ap, struct task_struct *);
74971 + cred = __task_cred(task);
74972 + pcred = __task_cred(task->real_parent);
74973 + ulong1 = va_arg(ap, unsigned long);
74974 + 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);
74975 + break;
74976 + case GR_RWXMAP:
74977 + file = va_arg(ap, struct file *);
74978 + gr_log_middle_varargs(audit, msg, file ? gr_to_filename(file->f_path.dentry, file->f_path.mnt) : "<anonymous mapping>");
74979 + break;
74980 + case GR_RWXMAPVMA:
74981 + vma = va_arg(ap, struct vm_area_struct *);
74982 + if (vma->vm_file)
74983 + str1 = gr_to_filename(vma->vm_file->f_path.dentry, vma->vm_file->f_path.mnt);
74984 + else if (vma->vm_flags & (VM_GROWSDOWN | VM_GROWSUP))
74985 + str1 = "<stack>";
74986 + else if (vma->vm_start <= current->mm->brk &&
74987 + vma->vm_end >= current->mm->start_brk)
74988 + str1 = "<heap>";
74989 + else
74990 + str1 = "<anonymous mapping>";
74991 + gr_log_middle_varargs(audit, msg, str1);
74992 + break;
74993 + case GR_PSACCT:
74994 + {
74995 + unsigned int wday, cday;
74996 + __u8 whr, chr;
74997 + __u8 wmin, cmin;
74998 + __u8 wsec, csec;
74999 + char cur_tty[64] = { 0 };
75000 + char parent_tty[64] = { 0 };
75001 +
75002 + task = va_arg(ap, struct task_struct *);
75003 + wday = va_arg(ap, unsigned int);
75004 + cday = va_arg(ap, unsigned int);
75005 + whr = va_arg(ap, int);
75006 + chr = va_arg(ap, int);
75007 + wmin = va_arg(ap, int);
75008 + cmin = va_arg(ap, int);
75009 + wsec = va_arg(ap, int);
75010 + csec = va_arg(ap, int);
75011 + ulong1 = va_arg(ap, unsigned long);
75012 + cred = __task_cred(task);
75013 + pcred = __task_cred(task->real_parent);
75014 +
75015 + 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));
75016 + }
75017 + break;
75018 + default:
75019 + gr_log_middle(audit, msg, ap);
75020 + }
75021 + va_end(ap);
75022 + // these don't need DEFAULTSECARGS printed on the end
75023 + if (argtypes == GR_CRASH1 || argtypes == GR_CRASH2)
75024 + gr_log_end(audit, 0);
75025 + else
75026 + gr_log_end(audit, 1);
75027 + END_LOCKS(audit);
75028 +}
75029 diff --git a/grsecurity/grsec_mem.c b/grsecurity/grsec_mem.c
75030 new file mode 100644
75031 index 0000000..0e39d8c
75032 --- /dev/null
75033 +++ b/grsecurity/grsec_mem.c
75034 @@ -0,0 +1,48 @@
75035 +#include <linux/kernel.h>
75036 +#include <linux/sched.h>
75037 +#include <linux/mm.h>
75038 +#include <linux/mman.h>
75039 +#include <linux/module.h>
75040 +#include <linux/grinternal.h>
75041 +
75042 +void gr_handle_msr_write(void)
75043 +{
75044 + gr_log_noargs(GR_DONT_AUDIT, GR_MSRWRITE_MSG);
75045 + return;
75046 +}
75047 +EXPORT_SYMBOL_GPL(gr_handle_msr_write);
75048 +
75049 +void
75050 +gr_handle_ioperm(void)
75051 +{
75052 + gr_log_noargs(GR_DONT_AUDIT, GR_IOPERM_MSG);
75053 + return;
75054 +}
75055 +
75056 +void
75057 +gr_handle_iopl(void)
75058 +{
75059 + gr_log_noargs(GR_DONT_AUDIT, GR_IOPL_MSG);
75060 + return;
75061 +}
75062 +
75063 +void
75064 +gr_handle_mem_readwrite(u64 from, u64 to)
75065 +{
75066 + gr_log_two_u64(GR_DONT_AUDIT, GR_MEM_READWRITE_MSG, from, to);
75067 + return;
75068 +}
75069 +
75070 +void
75071 +gr_handle_vm86(void)
75072 +{
75073 + gr_log_noargs(GR_DONT_AUDIT, GR_VM86_MSG);
75074 + return;
75075 +}
75076 +
75077 +void
75078 +gr_log_badprocpid(const char *entry)
75079 +{
75080 + gr_log_str(GR_DONT_AUDIT, GR_BADPROCPID_MSG, entry);
75081 + return;
75082 +}
75083 diff --git a/grsecurity/grsec_mount.c b/grsecurity/grsec_mount.c
75084 new file mode 100644
75085 index 0000000..cd9e124
75086 --- /dev/null
75087 +++ b/grsecurity/grsec_mount.c
75088 @@ -0,0 +1,65 @@
75089 +#include <linux/kernel.h>
75090 +#include <linux/sched.h>
75091 +#include <linux/mount.h>
75092 +#include <linux/major.h>
75093 +#include <linux/grsecurity.h>
75094 +#include <linux/grinternal.h>
75095 +
75096 +void
75097 +gr_log_remount(const char *devname, const int retval)
75098 +{
75099 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
75100 + if (grsec_enable_mount && (retval >= 0))
75101 + gr_log_str(GR_DO_AUDIT, GR_REMOUNT_AUDIT_MSG, devname ? devname : "none");
75102 +#endif
75103 + return;
75104 +}
75105 +
75106 +void
75107 +gr_log_unmount(const char *devname, const int retval)
75108 +{
75109 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
75110 + if (grsec_enable_mount && (retval >= 0))
75111 + gr_log_str(GR_DO_AUDIT, GR_UNMOUNT_AUDIT_MSG, devname ? devname : "none");
75112 +#endif
75113 + return;
75114 +}
75115 +
75116 +void
75117 +gr_log_mount(const char *from, const char *to, const int retval)
75118 +{
75119 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
75120 + if (grsec_enable_mount && (retval >= 0))
75121 + gr_log_str_str(GR_DO_AUDIT, GR_MOUNT_AUDIT_MSG, from ? from : "none", to);
75122 +#endif
75123 + return;
75124 +}
75125 +
75126 +int
75127 +gr_handle_rofs_mount(struct dentry *dentry, struct vfsmount *mnt, int mnt_flags)
75128 +{
75129 +#ifdef CONFIG_GRKERNSEC_ROFS
75130 + if (grsec_enable_rofs && !(mnt_flags & MNT_READONLY)) {
75131 + gr_log_fs_generic(GR_DO_AUDIT, GR_ROFS_MOUNT_MSG, dentry, mnt);
75132 + return -EPERM;
75133 + } else
75134 + return 0;
75135 +#endif
75136 + return 0;
75137 +}
75138 +
75139 +int
75140 +gr_handle_rofs_blockwrite(struct dentry *dentry, struct vfsmount *mnt, int acc_mode)
75141 +{
75142 +#ifdef CONFIG_GRKERNSEC_ROFS
75143 + struct inode *inode = dentry->d_inode;
75144 +
75145 + if (grsec_enable_rofs && (acc_mode & MAY_WRITE) &&
75146 + inode && (S_ISBLK(inode->i_mode) || (S_ISCHR(inode->i_mode) && imajor(inode) == RAW_MAJOR))) {
75147 + gr_log_fs_generic(GR_DO_AUDIT, GR_ROFS_BLOCKWRITE_MSG, dentry, mnt);
75148 + return -EPERM;
75149 + } else
75150 + return 0;
75151 +#endif
75152 + return 0;
75153 +}
75154 diff --git a/grsecurity/grsec_pax.c b/grsecurity/grsec_pax.c
75155 new file mode 100644
75156 index 0000000..6ee9d50
75157 --- /dev/null
75158 +++ b/grsecurity/grsec_pax.c
75159 @@ -0,0 +1,45 @@
75160 +#include <linux/kernel.h>
75161 +#include <linux/sched.h>
75162 +#include <linux/mm.h>
75163 +#include <linux/file.h>
75164 +#include <linux/grinternal.h>
75165 +#include <linux/grsecurity.h>
75166 +
75167 +void
75168 +gr_log_textrel(struct vm_area_struct * vma)
75169 +{
75170 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
75171 + if (grsec_enable_log_rwxmaps)
75172 + gr_log_textrel_ulong_ulong(GR_DONT_AUDIT, GR_TEXTREL_AUDIT_MSG, vma->vm_file, vma->vm_start, vma->vm_pgoff);
75173 +#endif
75174 + return;
75175 +}
75176 +
75177 +void gr_log_ptgnustack(struct file *file)
75178 +{
75179 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
75180 + if (grsec_enable_log_rwxmaps)
75181 + gr_log_rwxmap(GR_DONT_AUDIT, GR_PTGNUSTACK_MSG, file);
75182 +#endif
75183 + return;
75184 +}
75185 +
75186 +void
75187 +gr_log_rwxmmap(struct file *file)
75188 +{
75189 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
75190 + if (grsec_enable_log_rwxmaps)
75191 + gr_log_rwxmap(GR_DONT_AUDIT, GR_RWXMMAP_MSG, file);
75192 +#endif
75193 + return;
75194 +}
75195 +
75196 +void
75197 +gr_log_rwxmprotect(struct vm_area_struct *vma)
75198 +{
75199 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
75200 + if (grsec_enable_log_rwxmaps)
75201 + gr_log_rwxmap_vma(GR_DONT_AUDIT, GR_RWXMPROTECT_MSG, vma);
75202 +#endif
75203 + return;
75204 +}
75205 diff --git a/grsecurity/grsec_proc.c b/grsecurity/grsec_proc.c
75206 new file mode 100644
75207 index 0000000..2005a3a
75208 --- /dev/null
75209 +++ b/grsecurity/grsec_proc.c
75210 @@ -0,0 +1,20 @@
75211 +#include <linux/kernel.h>
75212 +#include <linux/sched.h>
75213 +#include <linux/grsecurity.h>
75214 +#include <linux/grinternal.h>
75215 +
75216 +int gr_proc_is_restricted(void)
75217 +{
75218 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
75219 + const struct cred *cred = current_cred();
75220 +#endif
75221 +
75222 +#ifdef CONFIG_GRKERNSEC_PROC_USER
75223 + if (!uid_eq(cred->fsuid, GLOBAL_ROOT_UID))
75224 + return -EACCES;
75225 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
75226 + if (!uid_eq(cred->fsuid, GLOBAL_ROOT_UID) && !in_group_p(grsec_proc_gid))
75227 + return -EACCES;
75228 +#endif
75229 + return 0;
75230 +}
75231 diff --git a/grsecurity/grsec_ptrace.c b/grsecurity/grsec_ptrace.c
75232 new file mode 100644
75233 index 0000000..f7f29aa
75234 --- /dev/null
75235 +++ b/grsecurity/grsec_ptrace.c
75236 @@ -0,0 +1,30 @@
75237 +#include <linux/kernel.h>
75238 +#include <linux/sched.h>
75239 +#include <linux/grinternal.h>
75240 +#include <linux/security.h>
75241 +
75242 +void
75243 +gr_audit_ptrace(struct task_struct *task)
75244 +{
75245 +#ifdef CONFIG_GRKERNSEC_AUDIT_PTRACE
75246 + if (grsec_enable_audit_ptrace)
75247 + gr_log_ptrace(GR_DO_AUDIT, GR_PTRACE_AUDIT_MSG, task);
75248 +#endif
75249 + return;
75250 +}
75251 +
75252 +int
75253 +gr_ptrace_readexec(struct file *file, int unsafe_flags)
75254 +{
75255 +#ifdef CONFIG_GRKERNSEC_PTRACE_READEXEC
75256 + const struct dentry *dentry = file->f_path.dentry;
75257 + const struct vfsmount *mnt = file->f_path.mnt;
75258 +
75259 + if (grsec_enable_ptrace_readexec && (unsafe_flags & LSM_UNSAFE_PTRACE) &&
75260 + (inode_permission(dentry->d_inode, MAY_READ) || !gr_acl_handle_open(dentry, mnt, MAY_READ))) {
75261 + gr_log_fs_generic(GR_DONT_AUDIT, GR_PTRACE_READEXEC_MSG, dentry, mnt);
75262 + return -EACCES;
75263 + }
75264 +#endif
75265 + return 0;
75266 +}
75267 diff --git a/grsecurity/grsec_sig.c b/grsecurity/grsec_sig.c
75268 new file mode 100644
75269 index 0000000..3860c7e
75270 --- /dev/null
75271 +++ b/grsecurity/grsec_sig.c
75272 @@ -0,0 +1,236 @@
75273 +#include <linux/kernel.h>
75274 +#include <linux/sched.h>
75275 +#include <linux/fs.h>
75276 +#include <linux/delay.h>
75277 +#include <linux/grsecurity.h>
75278 +#include <linux/grinternal.h>
75279 +#include <linux/hardirq.h>
75280 +
75281 +char *signames[] = {
75282 + [SIGSEGV] = "Segmentation fault",
75283 + [SIGILL] = "Illegal instruction",
75284 + [SIGABRT] = "Abort",
75285 + [SIGBUS] = "Invalid alignment/Bus error"
75286 +};
75287 +
75288 +void
75289 +gr_log_signal(const int sig, const void *addr, const struct task_struct *t)
75290 +{
75291 +#ifdef CONFIG_GRKERNSEC_SIGNAL
75292 + if (grsec_enable_signal && ((sig == SIGSEGV) || (sig == SIGILL) ||
75293 + (sig == SIGABRT) || (sig == SIGBUS))) {
75294 + if (task_pid_nr(t) == task_pid_nr(current)) {
75295 + gr_log_sig_addr(GR_DONT_AUDIT_GOOD, GR_UNISIGLOG_MSG, signames[sig], addr);
75296 + } else {
75297 + gr_log_sig_task(GR_DONT_AUDIT_GOOD, GR_DUALSIGLOG_MSG, t, sig);
75298 + }
75299 + }
75300 +#endif
75301 + return;
75302 +}
75303 +
75304 +int
75305 +gr_handle_signal(const struct task_struct *p, const int sig)
75306 +{
75307 +#ifdef CONFIG_GRKERNSEC
75308 + /* ignore the 0 signal for protected task checks */
75309 + if (task_pid_nr(current) > 1 && sig && gr_check_protected_task(p)) {
75310 + gr_log_sig_task(GR_DONT_AUDIT, GR_SIG_ACL_MSG, p, sig);
75311 + return -EPERM;
75312 + } else if (gr_pid_is_chrooted((struct task_struct *)p)) {
75313 + return -EPERM;
75314 + }
75315 +#endif
75316 + return 0;
75317 +}
75318 +
75319 +#ifdef CONFIG_GRKERNSEC
75320 +extern int specific_send_sig_info(int sig, struct siginfo *info, struct task_struct *t);
75321 +
75322 +int gr_fake_force_sig(int sig, struct task_struct *t)
75323 +{
75324 + unsigned long int flags;
75325 + int ret, blocked, ignored;
75326 + struct k_sigaction *action;
75327 +
75328 + spin_lock_irqsave(&t->sighand->siglock, flags);
75329 + action = &t->sighand->action[sig-1];
75330 + ignored = action->sa.sa_handler == SIG_IGN;
75331 + blocked = sigismember(&t->blocked, sig);
75332 + if (blocked || ignored) {
75333 + action->sa.sa_handler = SIG_DFL;
75334 + if (blocked) {
75335 + sigdelset(&t->blocked, sig);
75336 + recalc_sigpending_and_wake(t);
75337 + }
75338 + }
75339 + if (action->sa.sa_handler == SIG_DFL)
75340 + t->signal->flags &= ~SIGNAL_UNKILLABLE;
75341 + ret = specific_send_sig_info(sig, SEND_SIG_PRIV, t);
75342 +
75343 + spin_unlock_irqrestore(&t->sighand->siglock, flags);
75344 +
75345 + return ret;
75346 +}
75347 +#endif
75348 +
75349 +#define GR_USER_BAN_TIME (15 * 60)
75350 +#define GR_DAEMON_BRUTE_TIME (30 * 60)
75351 +
75352 +void gr_handle_brute_attach(int dumpable)
75353 +{
75354 +#ifdef CONFIG_GRKERNSEC_BRUTE
75355 + struct task_struct *p = current;
75356 + kuid_t uid = GLOBAL_ROOT_UID;
75357 + int daemon = 0;
75358 +
75359 + if (!grsec_enable_brute)
75360 + return;
75361 +
75362 + rcu_read_lock();
75363 + read_lock(&tasklist_lock);
75364 + read_lock(&grsec_exec_file_lock);
75365 + if (p->real_parent && gr_is_same_file(p->real_parent->exec_file, p->exec_file)) {
75366 + p->real_parent->brute_expires = get_seconds() + GR_DAEMON_BRUTE_TIME;
75367 + p->real_parent->brute = 1;
75368 + daemon = 1;
75369 + } else {
75370 + const struct cred *cred = __task_cred(p), *cred2;
75371 + struct task_struct *tsk, *tsk2;
75372 +
75373 + if (dumpable != SUID_DUMP_USER && gr_is_global_nonroot(cred->uid)) {
75374 + struct user_struct *user;
75375 +
75376 + uid = cred->uid;
75377 +
75378 + /* this is put upon execution past expiration */
75379 + user = find_user(uid);
75380 + if (user == NULL)
75381 + goto unlock;
75382 + user->suid_banned = 1;
75383 + user->suid_ban_expires = get_seconds() + GR_USER_BAN_TIME;
75384 + if (user->suid_ban_expires == ~0UL)
75385 + user->suid_ban_expires--;
75386 +
75387 + /* only kill other threads of the same binary, from the same user */
75388 + do_each_thread(tsk2, tsk) {
75389 + cred2 = __task_cred(tsk);
75390 + if (tsk != p && uid_eq(cred2->uid, uid) && gr_is_same_file(tsk->exec_file, p->exec_file))
75391 + gr_fake_force_sig(SIGKILL, tsk);
75392 + } while_each_thread(tsk2, tsk);
75393 + }
75394 + }
75395 +unlock:
75396 + read_unlock(&grsec_exec_file_lock);
75397 + read_unlock(&tasklist_lock);
75398 + rcu_read_unlock();
75399 +
75400 + if (gr_is_global_nonroot(uid))
75401 + 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);
75402 + else if (daemon)
75403 + gr_log_noargs(GR_DONT_AUDIT, GR_BRUTE_DAEMON_MSG);
75404 +
75405 +#endif
75406 + return;
75407 +}
75408 +
75409 +void gr_handle_brute_check(void)
75410 +{
75411 +#ifdef CONFIG_GRKERNSEC_BRUTE
75412 + struct task_struct *p = current;
75413 +
75414 + if (unlikely(p->brute)) {
75415 + if (!grsec_enable_brute)
75416 + p->brute = 0;
75417 + else if (time_before(get_seconds(), p->brute_expires))
75418 + msleep(30 * 1000);
75419 + }
75420 +#endif
75421 + return;
75422 +}
75423 +
75424 +void gr_handle_kernel_exploit(void)
75425 +{
75426 +#ifdef CONFIG_GRKERNSEC_KERN_LOCKOUT
75427 + const struct cred *cred;
75428 + struct task_struct *tsk, *tsk2;
75429 + struct user_struct *user;
75430 + kuid_t uid;
75431 +
75432 + if (in_irq() || in_serving_softirq() || in_nmi())
75433 + panic("grsec: halting the system due to suspicious kernel crash caused in interrupt context");
75434 +
75435 + uid = current_uid();
75436 +
75437 + if (gr_is_global_root(uid))
75438 + panic("grsec: halting the system due to suspicious kernel crash caused by root");
75439 + else {
75440 + /* kill all the processes of this user, hold a reference
75441 + to their creds struct, and prevent them from creating
75442 + another process until system reset
75443 + */
75444 + printk(KERN_ALERT "grsec: banning user with uid %u until system restart for suspicious kernel crash\n",
75445 + GR_GLOBAL_UID(uid));
75446 + /* we intentionally leak this ref */
75447 + user = get_uid(current->cred->user);
75448 + if (user)
75449 + user->kernel_banned = 1;
75450 +
75451 + /* kill all processes of this user */
75452 + read_lock(&tasklist_lock);
75453 + do_each_thread(tsk2, tsk) {
75454 + cred = __task_cred(tsk);
75455 + if (uid_eq(cred->uid, uid))
75456 + gr_fake_force_sig(SIGKILL, tsk);
75457 + } while_each_thread(tsk2, tsk);
75458 + read_unlock(&tasklist_lock);
75459 + }
75460 +#endif
75461 +}
75462 +
75463 +#ifdef CONFIG_GRKERNSEC_BRUTE
75464 +static bool suid_ban_expired(struct user_struct *user)
75465 +{
75466 + if (user->suid_ban_expires != ~0UL && time_after_eq(get_seconds(), user->suid_ban_expires)) {
75467 + user->suid_banned = 0;
75468 + user->suid_ban_expires = 0;
75469 + free_uid(user);
75470 + return true;
75471 + }
75472 +
75473 + return false;
75474 +}
75475 +#endif
75476 +
75477 +int gr_process_kernel_exec_ban(void)
75478 +{
75479 +#ifdef CONFIG_GRKERNSEC_KERN_LOCKOUT
75480 + if (unlikely(current->cred->user->kernel_banned))
75481 + return -EPERM;
75482 +#endif
75483 + return 0;
75484 +}
75485 +
75486 +int gr_process_kernel_setuid_ban(struct user_struct *user)
75487 +{
75488 +#ifdef CONFIG_GRKERNSEC_KERN_LOCKOUT
75489 + if (unlikely(user->kernel_banned))
75490 + gr_fake_force_sig(SIGKILL, current);
75491 +#endif
75492 + return 0;
75493 +}
75494 +
75495 +int gr_process_suid_exec_ban(const struct linux_binprm *bprm)
75496 +{
75497 +#ifdef CONFIG_GRKERNSEC_BRUTE
75498 + struct user_struct *user = current->cred->user;
75499 + if (unlikely(user->suid_banned)) {
75500 + if (suid_ban_expired(user))
75501 + return 0;
75502 + /* disallow execution of suid binaries only */
75503 + else if (!uid_eq(bprm->cred->euid, current->cred->uid))
75504 + return -EPERM;
75505 + }
75506 +#endif
75507 + return 0;
75508 +}
75509 diff --git a/grsecurity/grsec_sock.c b/grsecurity/grsec_sock.c
75510 new file mode 100644
75511 index 0000000..c0aef3a
75512 --- /dev/null
75513 +++ b/grsecurity/grsec_sock.c
75514 @@ -0,0 +1,244 @@
75515 +#include <linux/kernel.h>
75516 +#include <linux/module.h>
75517 +#include <linux/sched.h>
75518 +#include <linux/file.h>
75519 +#include <linux/net.h>
75520 +#include <linux/in.h>
75521 +#include <linux/ip.h>
75522 +#include <net/sock.h>
75523 +#include <net/inet_sock.h>
75524 +#include <linux/grsecurity.h>
75525 +#include <linux/grinternal.h>
75526 +#include <linux/gracl.h>
75527 +
75528 +extern int gr_search_udp_recvmsg(const struct sock *sk, const struct sk_buff *skb);
75529 +extern int gr_search_udp_sendmsg(const struct sock *sk, const struct sockaddr_in *addr);
75530 +
75531 +EXPORT_SYMBOL_GPL(gr_search_udp_recvmsg);
75532 +EXPORT_SYMBOL_GPL(gr_search_udp_sendmsg);
75533 +
75534 +#ifdef CONFIG_UNIX_MODULE
75535 +EXPORT_SYMBOL_GPL(gr_acl_handle_unix);
75536 +EXPORT_SYMBOL_GPL(gr_acl_handle_mknod);
75537 +EXPORT_SYMBOL_GPL(gr_handle_chroot_unix);
75538 +EXPORT_SYMBOL_GPL(gr_handle_create);
75539 +#endif
75540 +
75541 +#ifdef CONFIG_GRKERNSEC
75542 +#define gr_conn_table_size 32749
75543 +struct conn_table_entry {
75544 + struct conn_table_entry *next;
75545 + struct signal_struct *sig;
75546 +};
75547 +
75548 +struct conn_table_entry *gr_conn_table[gr_conn_table_size];
75549 +DEFINE_SPINLOCK(gr_conn_table_lock);
75550 +
75551 +extern const char * gr_socktype_to_name(unsigned char type);
75552 +extern const char * gr_proto_to_name(unsigned char proto);
75553 +extern const char * gr_sockfamily_to_name(unsigned char family);
75554 +
75555 +static __inline__ int
75556 +conn_hash(__u32 saddr, __u32 daddr, __u16 sport, __u16 dport, unsigned int size)
75557 +{
75558 + return ((daddr + saddr + (sport << 8) + (dport << 16)) % size);
75559 +}
75560 +
75561 +static __inline__ int
75562 +conn_match(const struct signal_struct *sig, __u32 saddr, __u32 daddr,
75563 + __u16 sport, __u16 dport)
75564 +{
75565 + if (unlikely(sig->gr_saddr == saddr && sig->gr_daddr == daddr &&
75566 + sig->gr_sport == sport && sig->gr_dport == dport))
75567 + return 1;
75568 + else
75569 + return 0;
75570 +}
75571 +
75572 +static void gr_add_to_task_ip_table_nolock(struct signal_struct *sig, struct conn_table_entry *newent)
75573 +{
75574 + struct conn_table_entry **match;
75575 + unsigned int index;
75576 +
75577 + index = conn_hash(sig->gr_saddr, sig->gr_daddr,
75578 + sig->gr_sport, sig->gr_dport,
75579 + gr_conn_table_size);
75580 +
75581 + newent->sig = sig;
75582 +
75583 + match = &gr_conn_table[index];
75584 + newent->next = *match;
75585 + *match = newent;
75586 +
75587 + return;
75588 +}
75589 +
75590 +static void gr_del_task_from_ip_table_nolock(struct signal_struct *sig)
75591 +{
75592 + struct conn_table_entry *match, *last = NULL;
75593 + unsigned int index;
75594 +
75595 + index = conn_hash(sig->gr_saddr, sig->gr_daddr,
75596 + sig->gr_sport, sig->gr_dport,
75597 + gr_conn_table_size);
75598 +
75599 + match = gr_conn_table[index];
75600 + while (match && !conn_match(match->sig,
75601 + sig->gr_saddr, sig->gr_daddr, sig->gr_sport,
75602 + sig->gr_dport)) {
75603 + last = match;
75604 + match = match->next;
75605 + }
75606 +
75607 + if (match) {
75608 + if (last)
75609 + last->next = match->next;
75610 + else
75611 + gr_conn_table[index] = NULL;
75612 + kfree(match);
75613 + }
75614 +
75615 + return;
75616 +}
75617 +
75618 +static struct signal_struct * gr_lookup_task_ip_table(__u32 saddr, __u32 daddr,
75619 + __u16 sport, __u16 dport)
75620 +{
75621 + struct conn_table_entry *match;
75622 + unsigned int index;
75623 +
75624 + index = conn_hash(saddr, daddr, sport, dport, gr_conn_table_size);
75625 +
75626 + match = gr_conn_table[index];
75627 + while (match && !conn_match(match->sig, saddr, daddr, sport, dport))
75628 + match = match->next;
75629 +
75630 + if (match)
75631 + return match->sig;
75632 + else
75633 + return NULL;
75634 +}
75635 +
75636 +#endif
75637 +
75638 +void gr_update_task_in_ip_table(struct task_struct *task, const struct inet_sock *inet)
75639 +{
75640 +#ifdef CONFIG_GRKERNSEC
75641 + struct signal_struct *sig = task->signal;
75642 + struct conn_table_entry *newent;
75643 +
75644 + newent = kmalloc(sizeof(struct conn_table_entry), GFP_ATOMIC);
75645 + if (newent == NULL)
75646 + return;
75647 + /* no bh lock needed since we are called with bh disabled */
75648 + spin_lock(&gr_conn_table_lock);
75649 + gr_del_task_from_ip_table_nolock(sig);
75650 + sig->gr_saddr = inet->inet_rcv_saddr;
75651 + sig->gr_daddr = inet->inet_daddr;
75652 + sig->gr_sport = inet->inet_sport;
75653 + sig->gr_dport = inet->inet_dport;
75654 + gr_add_to_task_ip_table_nolock(sig, newent);
75655 + spin_unlock(&gr_conn_table_lock);
75656 +#endif
75657 + return;
75658 +}
75659 +
75660 +void gr_del_task_from_ip_table(struct task_struct *task)
75661 +{
75662 +#ifdef CONFIG_GRKERNSEC
75663 + spin_lock_bh(&gr_conn_table_lock);
75664 + gr_del_task_from_ip_table_nolock(task->signal);
75665 + spin_unlock_bh(&gr_conn_table_lock);
75666 +#endif
75667 + return;
75668 +}
75669 +
75670 +void
75671 +gr_attach_curr_ip(const struct sock *sk)
75672 +{
75673 +#ifdef CONFIG_GRKERNSEC
75674 + struct signal_struct *p, *set;
75675 + const struct inet_sock *inet = inet_sk(sk);
75676 +
75677 + if (unlikely(sk->sk_protocol != IPPROTO_TCP))
75678 + return;
75679 +
75680 + set = current->signal;
75681 +
75682 + spin_lock_bh(&gr_conn_table_lock);
75683 + p = gr_lookup_task_ip_table(inet->inet_daddr, inet->inet_rcv_saddr,
75684 + inet->inet_dport, inet->inet_sport);
75685 + if (unlikely(p != NULL)) {
75686 + set->curr_ip = p->curr_ip;
75687 + set->used_accept = 1;
75688 + gr_del_task_from_ip_table_nolock(p);
75689 + spin_unlock_bh(&gr_conn_table_lock);
75690 + return;
75691 + }
75692 + spin_unlock_bh(&gr_conn_table_lock);
75693 +
75694 + set->curr_ip = inet->inet_daddr;
75695 + set->used_accept = 1;
75696 +#endif
75697 + return;
75698 +}
75699 +
75700 +int
75701 +gr_handle_sock_all(const int family, const int type, const int protocol)
75702 +{
75703 +#ifdef CONFIG_GRKERNSEC_SOCKET_ALL
75704 + if (grsec_enable_socket_all && in_group_p(grsec_socket_all_gid) &&
75705 + (family != AF_UNIX)) {
75706 + if (family == AF_INET)
75707 + gr_log_str3(GR_DONT_AUDIT, GR_SOCK_MSG, gr_sockfamily_to_name(family), gr_socktype_to_name(type), gr_proto_to_name(protocol));
75708 + else
75709 + gr_log_str2_int(GR_DONT_AUDIT, GR_SOCK_NOINET_MSG, gr_sockfamily_to_name(family), gr_socktype_to_name(type), protocol);
75710 + return -EACCES;
75711 + }
75712 +#endif
75713 + return 0;
75714 +}
75715 +
75716 +int
75717 +gr_handle_sock_server(const struct sockaddr *sck)
75718 +{
75719 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
75720 + if (grsec_enable_socket_server &&
75721 + in_group_p(grsec_socket_server_gid) &&
75722 + sck && (sck->sa_family != AF_UNIX) &&
75723 + (sck->sa_family != AF_LOCAL)) {
75724 + gr_log_noargs(GR_DONT_AUDIT, GR_BIND_MSG);
75725 + return -EACCES;
75726 + }
75727 +#endif
75728 + return 0;
75729 +}
75730 +
75731 +int
75732 +gr_handle_sock_server_other(const struct sock *sck)
75733 +{
75734 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
75735 + if (grsec_enable_socket_server &&
75736 + in_group_p(grsec_socket_server_gid) &&
75737 + sck && (sck->sk_family != AF_UNIX) &&
75738 + (sck->sk_family != AF_LOCAL)) {
75739 + gr_log_noargs(GR_DONT_AUDIT, GR_BIND_MSG);
75740 + return -EACCES;
75741 + }
75742 +#endif
75743 + return 0;
75744 +}
75745 +
75746 +int
75747 +gr_handle_sock_client(const struct sockaddr *sck)
75748 +{
75749 +#ifdef CONFIG_GRKERNSEC_SOCKET_CLIENT
75750 + if (grsec_enable_socket_client && in_group_p(grsec_socket_client_gid) &&
75751 + sck && (sck->sa_family != AF_UNIX) &&
75752 + (sck->sa_family != AF_LOCAL)) {
75753 + gr_log_noargs(GR_DONT_AUDIT, GR_CONNECT_MSG);
75754 + return -EACCES;
75755 + }
75756 +#endif
75757 + return 0;
75758 +}
75759 diff --git a/grsecurity/grsec_sysctl.c b/grsecurity/grsec_sysctl.c
75760 new file mode 100644
75761 index 0000000..8159888
75762 --- /dev/null
75763 +++ b/grsecurity/grsec_sysctl.c
75764 @@ -0,0 +1,479 @@
75765 +#include <linux/kernel.h>
75766 +#include <linux/sched.h>
75767 +#include <linux/sysctl.h>
75768 +#include <linux/grsecurity.h>
75769 +#include <linux/grinternal.h>
75770 +
75771 +int
75772 +gr_handle_sysctl_mod(const char *dirname, const char *name, const int op)
75773 +{
75774 +#ifdef CONFIG_GRKERNSEC_SYSCTL
75775 + if (dirname == NULL || name == NULL)
75776 + return 0;
75777 + if (!strcmp(dirname, "grsecurity") && grsec_lock && (op & MAY_WRITE)) {
75778 + gr_log_str(GR_DONT_AUDIT, GR_SYSCTL_MSG, name);
75779 + return -EACCES;
75780 + }
75781 +#endif
75782 + return 0;
75783 +}
75784 +
75785 +#if defined(CONFIG_GRKERNSEC_ROFS) || defined(CONFIG_GRKERNSEC_DENYUSB)
75786 +static int __maybe_unused __read_only one = 1;
75787 +#endif
75788 +
75789 +#if defined(CONFIG_GRKERNSEC_SYSCTL) || defined(CONFIG_GRKERNSEC_ROFS) || \
75790 + defined(CONFIG_GRKERNSEC_DENYUSB)
75791 +struct ctl_table grsecurity_table[] = {
75792 +#ifdef CONFIG_GRKERNSEC_SYSCTL
75793 +#ifdef CONFIG_GRKERNSEC_SYSCTL_DISTRO
75794 +#ifdef CONFIG_GRKERNSEC_IO
75795 + {
75796 + .procname = "disable_priv_io",
75797 + .data = &grsec_disable_privio,
75798 + .maxlen = sizeof(int),
75799 + .mode = 0600,
75800 + .proc_handler = &proc_dointvec,
75801 + },
75802 +#endif
75803 +#endif
75804 +#ifdef CONFIG_GRKERNSEC_LINK
75805 + {
75806 + .procname = "linking_restrictions",
75807 + .data = &grsec_enable_link,
75808 + .maxlen = sizeof(int),
75809 + .mode = 0600,
75810 + .proc_handler = &proc_dointvec,
75811 + },
75812 +#endif
75813 +#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
75814 + {
75815 + .procname = "enforce_symlinksifowner",
75816 + .data = &grsec_enable_symlinkown,
75817 + .maxlen = sizeof(int),
75818 + .mode = 0600,
75819 + .proc_handler = &proc_dointvec,
75820 + },
75821 + {
75822 + .procname = "symlinkown_gid",
75823 + .data = &grsec_symlinkown_gid,
75824 + .maxlen = sizeof(int),
75825 + .mode = 0600,
75826 + .proc_handler = &proc_dointvec,
75827 + },
75828 +#endif
75829 +#ifdef CONFIG_GRKERNSEC_BRUTE
75830 + {
75831 + .procname = "deter_bruteforce",
75832 + .data = &grsec_enable_brute,
75833 + .maxlen = sizeof(int),
75834 + .mode = 0600,
75835 + .proc_handler = &proc_dointvec,
75836 + },
75837 +#endif
75838 +#ifdef CONFIG_GRKERNSEC_FIFO
75839 + {
75840 + .procname = "fifo_restrictions",
75841 + .data = &grsec_enable_fifo,
75842 + .maxlen = sizeof(int),
75843 + .mode = 0600,
75844 + .proc_handler = &proc_dointvec,
75845 + },
75846 +#endif
75847 +#ifdef CONFIG_GRKERNSEC_PTRACE_READEXEC
75848 + {
75849 + .procname = "ptrace_readexec",
75850 + .data = &grsec_enable_ptrace_readexec,
75851 + .maxlen = sizeof(int),
75852 + .mode = 0600,
75853 + .proc_handler = &proc_dointvec,
75854 + },
75855 +#endif
75856 +#ifdef CONFIG_GRKERNSEC_SETXID
75857 + {
75858 + .procname = "consistent_setxid",
75859 + .data = &grsec_enable_setxid,
75860 + .maxlen = sizeof(int),
75861 + .mode = 0600,
75862 + .proc_handler = &proc_dointvec,
75863 + },
75864 +#endif
75865 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
75866 + {
75867 + .procname = "ip_blackhole",
75868 + .data = &grsec_enable_blackhole,
75869 + .maxlen = sizeof(int),
75870 + .mode = 0600,
75871 + .proc_handler = &proc_dointvec,
75872 + },
75873 + {
75874 + .procname = "lastack_retries",
75875 + .data = &grsec_lastack_retries,
75876 + .maxlen = sizeof(int),
75877 + .mode = 0600,
75878 + .proc_handler = &proc_dointvec,
75879 + },
75880 +#endif
75881 +#ifdef CONFIG_GRKERNSEC_EXECLOG
75882 + {
75883 + .procname = "exec_logging",
75884 + .data = &grsec_enable_execlog,
75885 + .maxlen = sizeof(int),
75886 + .mode = 0600,
75887 + .proc_handler = &proc_dointvec,
75888 + },
75889 +#endif
75890 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
75891 + {
75892 + .procname = "rwxmap_logging",
75893 + .data = &grsec_enable_log_rwxmaps,
75894 + .maxlen = sizeof(int),
75895 + .mode = 0600,
75896 + .proc_handler = &proc_dointvec,
75897 + },
75898 +#endif
75899 +#ifdef CONFIG_GRKERNSEC_SIGNAL
75900 + {
75901 + .procname = "signal_logging",
75902 + .data = &grsec_enable_signal,
75903 + .maxlen = sizeof(int),
75904 + .mode = 0600,
75905 + .proc_handler = &proc_dointvec,
75906 + },
75907 +#endif
75908 +#ifdef CONFIG_GRKERNSEC_FORKFAIL
75909 + {
75910 + .procname = "forkfail_logging",
75911 + .data = &grsec_enable_forkfail,
75912 + .maxlen = sizeof(int),
75913 + .mode = 0600,
75914 + .proc_handler = &proc_dointvec,
75915 + },
75916 +#endif
75917 +#ifdef CONFIG_GRKERNSEC_TIME
75918 + {
75919 + .procname = "timechange_logging",
75920 + .data = &grsec_enable_time,
75921 + .maxlen = sizeof(int),
75922 + .mode = 0600,
75923 + .proc_handler = &proc_dointvec,
75924 + },
75925 +#endif
75926 +#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
75927 + {
75928 + .procname = "chroot_deny_shmat",
75929 + .data = &grsec_enable_chroot_shmat,
75930 + .maxlen = sizeof(int),
75931 + .mode = 0600,
75932 + .proc_handler = &proc_dointvec,
75933 + },
75934 +#endif
75935 +#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
75936 + {
75937 + .procname = "chroot_deny_unix",
75938 + .data = &grsec_enable_chroot_unix,
75939 + .maxlen = sizeof(int),
75940 + .mode = 0600,
75941 + .proc_handler = &proc_dointvec,
75942 + },
75943 +#endif
75944 +#ifdef CONFIG_GRKERNSEC_CHROOT_MOUNT
75945 + {
75946 + .procname = "chroot_deny_mount",
75947 + .data = &grsec_enable_chroot_mount,
75948 + .maxlen = sizeof(int),
75949 + .mode = 0600,
75950 + .proc_handler = &proc_dointvec,
75951 + },
75952 +#endif
75953 +#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
75954 + {
75955 + .procname = "chroot_deny_fchdir",
75956 + .data = &grsec_enable_chroot_fchdir,
75957 + .maxlen = sizeof(int),
75958 + .mode = 0600,
75959 + .proc_handler = &proc_dointvec,
75960 + },
75961 +#endif
75962 +#ifdef CONFIG_GRKERNSEC_CHROOT_DOUBLE
75963 + {
75964 + .procname = "chroot_deny_chroot",
75965 + .data = &grsec_enable_chroot_double,
75966 + .maxlen = sizeof(int),
75967 + .mode = 0600,
75968 + .proc_handler = &proc_dointvec,
75969 + },
75970 +#endif
75971 +#ifdef CONFIG_GRKERNSEC_CHROOT_PIVOT
75972 + {
75973 + .procname = "chroot_deny_pivot",
75974 + .data = &grsec_enable_chroot_pivot,
75975 + .maxlen = sizeof(int),
75976 + .mode = 0600,
75977 + .proc_handler = &proc_dointvec,
75978 + },
75979 +#endif
75980 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHDIR
75981 + {
75982 + .procname = "chroot_enforce_chdir",
75983 + .data = &grsec_enable_chroot_chdir,
75984 + .maxlen = sizeof(int),
75985 + .mode = 0600,
75986 + .proc_handler = &proc_dointvec,
75987 + },
75988 +#endif
75989 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHMOD
75990 + {
75991 + .procname = "chroot_deny_chmod",
75992 + .data = &grsec_enable_chroot_chmod,
75993 + .maxlen = sizeof(int),
75994 + .mode = 0600,
75995 + .proc_handler = &proc_dointvec,
75996 + },
75997 +#endif
75998 +#ifdef CONFIG_GRKERNSEC_CHROOT_MKNOD
75999 + {
76000 + .procname = "chroot_deny_mknod",
76001 + .data = &grsec_enable_chroot_mknod,
76002 + .maxlen = sizeof(int),
76003 + .mode = 0600,
76004 + .proc_handler = &proc_dointvec,
76005 + },
76006 +#endif
76007 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
76008 + {
76009 + .procname = "chroot_restrict_nice",
76010 + .data = &grsec_enable_chroot_nice,
76011 + .maxlen = sizeof(int),
76012 + .mode = 0600,
76013 + .proc_handler = &proc_dointvec,
76014 + },
76015 +#endif
76016 +#ifdef CONFIG_GRKERNSEC_CHROOT_EXECLOG
76017 + {
76018 + .procname = "chroot_execlog",
76019 + .data = &grsec_enable_chroot_execlog,
76020 + .maxlen = sizeof(int),
76021 + .mode = 0600,
76022 + .proc_handler = &proc_dointvec,
76023 + },
76024 +#endif
76025 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
76026 + {
76027 + .procname = "chroot_caps",
76028 + .data = &grsec_enable_chroot_caps,
76029 + .maxlen = sizeof(int),
76030 + .mode = 0600,
76031 + .proc_handler = &proc_dointvec,
76032 + },
76033 +#endif
76034 +#ifdef CONFIG_GRKERNSEC_CHROOT_SYSCTL
76035 + {
76036 + .procname = "chroot_deny_sysctl",
76037 + .data = &grsec_enable_chroot_sysctl,
76038 + .maxlen = sizeof(int),
76039 + .mode = 0600,
76040 + .proc_handler = &proc_dointvec,
76041 + },
76042 +#endif
76043 +#ifdef CONFIG_GRKERNSEC_TPE
76044 + {
76045 + .procname = "tpe",
76046 + .data = &grsec_enable_tpe,
76047 + .maxlen = sizeof(int),
76048 + .mode = 0600,
76049 + .proc_handler = &proc_dointvec,
76050 + },
76051 + {
76052 + .procname = "tpe_gid",
76053 + .data = &grsec_tpe_gid,
76054 + .maxlen = sizeof(int),
76055 + .mode = 0600,
76056 + .proc_handler = &proc_dointvec,
76057 + },
76058 +#endif
76059 +#ifdef CONFIG_GRKERNSEC_TPE_INVERT
76060 + {
76061 + .procname = "tpe_invert",
76062 + .data = &grsec_enable_tpe_invert,
76063 + .maxlen = sizeof(int),
76064 + .mode = 0600,
76065 + .proc_handler = &proc_dointvec,
76066 + },
76067 +#endif
76068 +#ifdef CONFIG_GRKERNSEC_TPE_ALL
76069 + {
76070 + .procname = "tpe_restrict_all",
76071 + .data = &grsec_enable_tpe_all,
76072 + .maxlen = sizeof(int),
76073 + .mode = 0600,
76074 + .proc_handler = &proc_dointvec,
76075 + },
76076 +#endif
76077 +#ifdef CONFIG_GRKERNSEC_SOCKET_ALL
76078 + {
76079 + .procname = "socket_all",
76080 + .data = &grsec_enable_socket_all,
76081 + .maxlen = sizeof(int),
76082 + .mode = 0600,
76083 + .proc_handler = &proc_dointvec,
76084 + },
76085 + {
76086 + .procname = "socket_all_gid",
76087 + .data = &grsec_socket_all_gid,
76088 + .maxlen = sizeof(int),
76089 + .mode = 0600,
76090 + .proc_handler = &proc_dointvec,
76091 + },
76092 +#endif
76093 +#ifdef CONFIG_GRKERNSEC_SOCKET_CLIENT
76094 + {
76095 + .procname = "socket_client",
76096 + .data = &grsec_enable_socket_client,
76097 + .maxlen = sizeof(int),
76098 + .mode = 0600,
76099 + .proc_handler = &proc_dointvec,
76100 + },
76101 + {
76102 + .procname = "socket_client_gid",
76103 + .data = &grsec_socket_client_gid,
76104 + .maxlen = sizeof(int),
76105 + .mode = 0600,
76106 + .proc_handler = &proc_dointvec,
76107 + },
76108 +#endif
76109 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
76110 + {
76111 + .procname = "socket_server",
76112 + .data = &grsec_enable_socket_server,
76113 + .maxlen = sizeof(int),
76114 + .mode = 0600,
76115 + .proc_handler = &proc_dointvec,
76116 + },
76117 + {
76118 + .procname = "socket_server_gid",
76119 + .data = &grsec_socket_server_gid,
76120 + .maxlen = sizeof(int),
76121 + .mode = 0600,
76122 + .proc_handler = &proc_dointvec,
76123 + },
76124 +#endif
76125 +#ifdef CONFIG_GRKERNSEC_AUDIT_GROUP
76126 + {
76127 + .procname = "audit_group",
76128 + .data = &grsec_enable_group,
76129 + .maxlen = sizeof(int),
76130 + .mode = 0600,
76131 + .proc_handler = &proc_dointvec,
76132 + },
76133 + {
76134 + .procname = "audit_gid",
76135 + .data = &grsec_audit_gid,
76136 + .maxlen = sizeof(int),
76137 + .mode = 0600,
76138 + .proc_handler = &proc_dointvec,
76139 + },
76140 +#endif
76141 +#ifdef CONFIG_GRKERNSEC_AUDIT_CHDIR
76142 + {
76143 + .procname = "audit_chdir",
76144 + .data = &grsec_enable_chdir,
76145 + .maxlen = sizeof(int),
76146 + .mode = 0600,
76147 + .proc_handler = &proc_dointvec,
76148 + },
76149 +#endif
76150 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
76151 + {
76152 + .procname = "audit_mount",
76153 + .data = &grsec_enable_mount,
76154 + .maxlen = sizeof(int),
76155 + .mode = 0600,
76156 + .proc_handler = &proc_dointvec,
76157 + },
76158 +#endif
76159 +#ifdef CONFIG_GRKERNSEC_DMESG
76160 + {
76161 + .procname = "dmesg",
76162 + .data = &grsec_enable_dmesg,
76163 + .maxlen = sizeof(int),
76164 + .mode = 0600,
76165 + .proc_handler = &proc_dointvec,
76166 + },
76167 +#endif
76168 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
76169 + {
76170 + .procname = "chroot_findtask",
76171 + .data = &grsec_enable_chroot_findtask,
76172 + .maxlen = sizeof(int),
76173 + .mode = 0600,
76174 + .proc_handler = &proc_dointvec,
76175 + },
76176 +#endif
76177 +#ifdef CONFIG_GRKERNSEC_RESLOG
76178 + {
76179 + .procname = "resource_logging",
76180 + .data = &grsec_resource_logging,
76181 + .maxlen = sizeof(int),
76182 + .mode = 0600,
76183 + .proc_handler = &proc_dointvec,
76184 + },
76185 +#endif
76186 +#ifdef CONFIG_GRKERNSEC_AUDIT_PTRACE
76187 + {
76188 + .procname = "audit_ptrace",
76189 + .data = &grsec_enable_audit_ptrace,
76190 + .maxlen = sizeof(int),
76191 + .mode = 0600,
76192 + .proc_handler = &proc_dointvec,
76193 + },
76194 +#endif
76195 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
76196 + {
76197 + .procname = "harden_ptrace",
76198 + .data = &grsec_enable_harden_ptrace,
76199 + .maxlen = sizeof(int),
76200 + .mode = 0600,
76201 + .proc_handler = &proc_dointvec,
76202 + },
76203 +#endif
76204 +#ifdef CONFIG_GRKERNSEC_HARDEN_IPC
76205 + {
76206 + .procname = "harden_ipc",
76207 + .data = &grsec_enable_harden_ipc,
76208 + .maxlen = sizeof(int),
76209 + .mode = 0600,
76210 + .proc_handler = &proc_dointvec,
76211 + },
76212 +#endif
76213 + {
76214 + .procname = "grsec_lock",
76215 + .data = &grsec_lock,
76216 + .maxlen = sizeof(int),
76217 + .mode = 0600,
76218 + .proc_handler = &proc_dointvec,
76219 + },
76220 +#endif
76221 +#ifdef CONFIG_GRKERNSEC_ROFS
76222 + {
76223 + .procname = "romount_protect",
76224 + .data = &grsec_enable_rofs,
76225 + .maxlen = sizeof(int),
76226 + .mode = 0600,
76227 + .proc_handler = &proc_dointvec_minmax,
76228 + .extra1 = &one,
76229 + .extra2 = &one,
76230 + },
76231 +#endif
76232 +#if defined(CONFIG_GRKERNSEC_DENYUSB) && !defined(CONFIG_GRKERNSEC_DENYUSB_FORCE)
76233 + {
76234 + .procname = "deny_new_usb",
76235 + .data = &grsec_deny_new_usb,
76236 + .maxlen = sizeof(int),
76237 + .mode = 0600,
76238 + .proc_handler = &proc_dointvec,
76239 + },
76240 +#endif
76241 + { }
76242 +};
76243 +#endif
76244 diff --git a/grsecurity/grsec_time.c b/grsecurity/grsec_time.c
76245 new file mode 100644
76246 index 0000000..61b514e
76247 --- /dev/null
76248 +++ b/grsecurity/grsec_time.c
76249 @@ -0,0 +1,16 @@
76250 +#include <linux/kernel.h>
76251 +#include <linux/sched.h>
76252 +#include <linux/grinternal.h>
76253 +#include <linux/module.h>
76254 +
76255 +void
76256 +gr_log_timechange(void)
76257 +{
76258 +#ifdef CONFIG_GRKERNSEC_TIME
76259 + if (grsec_enable_time)
76260 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_TIME_MSG);
76261 +#endif
76262 + return;
76263 +}
76264 +
76265 +EXPORT_SYMBOL_GPL(gr_log_timechange);
76266 diff --git a/grsecurity/grsec_tpe.c b/grsecurity/grsec_tpe.c
76267 new file mode 100644
76268 index 0000000..d1953de
76269 --- /dev/null
76270 +++ b/grsecurity/grsec_tpe.c
76271 @@ -0,0 +1,78 @@
76272 +#include <linux/kernel.h>
76273 +#include <linux/sched.h>
76274 +#include <linux/file.h>
76275 +#include <linux/fs.h>
76276 +#include <linux/grinternal.h>
76277 +
76278 +extern int gr_acl_tpe_check(void);
76279 +
76280 +int
76281 +gr_tpe_allow(const struct file *file)
76282 +{
76283 +#ifdef CONFIG_GRKERNSEC
76284 + struct inode *inode = file->f_path.dentry->d_parent->d_inode;
76285 + struct inode *file_inode = file->f_path.dentry->d_inode;
76286 + const struct cred *cred = current_cred();
76287 + char *msg = NULL;
76288 + char *msg2 = NULL;
76289 +
76290 + // never restrict root
76291 + if (gr_is_global_root(cred->uid))
76292 + return 1;
76293 +
76294 + if (grsec_enable_tpe) {
76295 +#ifdef CONFIG_GRKERNSEC_TPE_INVERT
76296 + if (grsec_enable_tpe_invert && !in_group_p(grsec_tpe_gid))
76297 + msg = "not being in trusted group";
76298 + else if (!grsec_enable_tpe_invert && in_group_p(grsec_tpe_gid))
76299 + msg = "being in untrusted group";
76300 +#else
76301 + if (in_group_p(grsec_tpe_gid))
76302 + msg = "being in untrusted group";
76303 +#endif
76304 + }
76305 + if (!msg && gr_acl_tpe_check())
76306 + msg = "being in untrusted role";
76307 +
76308 + // not in any affected group/role
76309 + if (!msg)
76310 + goto next_check;
76311 +
76312 + if (gr_is_global_nonroot(inode->i_uid))
76313 + msg2 = "file in non-root-owned directory";
76314 + else if (inode->i_mode & S_IWOTH)
76315 + msg2 = "file in world-writable directory";
76316 + else if (inode->i_mode & S_IWGRP)
76317 + msg2 = "file in group-writable directory";
76318 + else if (file_inode->i_mode & S_IWOTH)
76319 + msg2 = "file is world-writable";
76320 +
76321 + if (msg && msg2) {
76322 + char fullmsg[70] = {0};
76323 + snprintf(fullmsg, sizeof(fullmsg)-1, "%s and %s", msg, msg2);
76324 + gr_log_str_fs(GR_DONT_AUDIT, GR_EXEC_TPE_MSG, fullmsg, file->f_path.dentry, file->f_path.mnt);
76325 + return 0;
76326 + }
76327 + msg = NULL;
76328 +next_check:
76329 +#ifdef CONFIG_GRKERNSEC_TPE_ALL
76330 + if (!grsec_enable_tpe || !grsec_enable_tpe_all)
76331 + return 1;
76332 +
76333 + if (gr_is_global_nonroot(inode->i_uid) && !uid_eq(inode->i_uid, cred->uid))
76334 + msg = "directory not owned by user";
76335 + else if (inode->i_mode & S_IWOTH)
76336 + msg = "file in world-writable directory";
76337 + else if (inode->i_mode & S_IWGRP)
76338 + msg = "file in group-writable directory";
76339 + else if (file_inode->i_mode & S_IWOTH)
76340 + msg = "file is world-writable";
76341 +
76342 + if (msg) {
76343 + gr_log_str_fs(GR_DONT_AUDIT, GR_EXEC_TPE_MSG, msg, file->f_path.dentry, file->f_path.mnt);
76344 + return 0;
76345 + }
76346 +#endif
76347 +#endif
76348 + return 1;
76349 +}
76350 diff --git a/grsecurity/grsec_usb.c b/grsecurity/grsec_usb.c
76351 new file mode 100644
76352 index 0000000..ae02d8e
76353 --- /dev/null
76354 +++ b/grsecurity/grsec_usb.c
76355 @@ -0,0 +1,15 @@
76356 +#include <linux/kernel.h>
76357 +#include <linux/grinternal.h>
76358 +#include <linux/module.h>
76359 +
76360 +int gr_handle_new_usb(void)
76361 +{
76362 +#ifdef CONFIG_GRKERNSEC_DENYUSB
76363 + if (grsec_deny_new_usb) {
76364 + printk(KERN_ALERT "grsec: denied insert of new USB device\n");
76365 + return 1;
76366 + }
76367 +#endif
76368 + return 0;
76369 +}
76370 +EXPORT_SYMBOL_GPL(gr_handle_new_usb);
76371 diff --git a/grsecurity/grsum.c b/grsecurity/grsum.c
76372 new file mode 100644
76373 index 0000000..9f7b1ac
76374 --- /dev/null
76375 +++ b/grsecurity/grsum.c
76376 @@ -0,0 +1,61 @@
76377 +#include <linux/err.h>
76378 +#include <linux/kernel.h>
76379 +#include <linux/sched.h>
76380 +#include <linux/mm.h>
76381 +#include <linux/scatterlist.h>
76382 +#include <linux/crypto.h>
76383 +#include <linux/gracl.h>
76384 +
76385 +
76386 +#if !defined(CONFIG_CRYPTO) || defined(CONFIG_CRYPTO_MODULE) || !defined(CONFIG_CRYPTO_SHA256) || defined(CONFIG_CRYPTO_SHA256_MODULE)
76387 +#error "crypto and sha256 must be built into the kernel"
76388 +#endif
76389 +
76390 +int
76391 +chkpw(struct gr_arg *entry, unsigned char *salt, unsigned char *sum)
76392 +{
76393 + char *p;
76394 + struct crypto_hash *tfm;
76395 + struct hash_desc desc;
76396 + struct scatterlist sg;
76397 + unsigned char temp_sum[GR_SHA_LEN];
76398 + volatile int retval = 0;
76399 + volatile int dummy = 0;
76400 + unsigned int i;
76401 +
76402 + sg_init_table(&sg, 1);
76403 +
76404 + tfm = crypto_alloc_hash("sha256", 0, CRYPTO_ALG_ASYNC);
76405 + if (IS_ERR(tfm)) {
76406 + /* should never happen, since sha256 should be built in */
76407 + return 1;
76408 + }
76409 +
76410 + desc.tfm = tfm;
76411 + desc.flags = 0;
76412 +
76413 + crypto_hash_init(&desc);
76414 +
76415 + p = salt;
76416 + sg_set_buf(&sg, p, GR_SALT_LEN);
76417 + crypto_hash_update(&desc, &sg, sg.length);
76418 +
76419 + p = entry->pw;
76420 + sg_set_buf(&sg, p, strlen(p));
76421 +
76422 + crypto_hash_update(&desc, &sg, sg.length);
76423 +
76424 + crypto_hash_final(&desc, temp_sum);
76425 +
76426 + memset(entry->pw, 0, GR_PW_LEN);
76427 +
76428 + for (i = 0; i < GR_SHA_LEN; i++)
76429 + if (sum[i] != temp_sum[i])
76430 + retval = 1;
76431 + else
76432 + dummy = 1; // waste a cycle
76433 +
76434 + crypto_free_hash(tfm);
76435 +
76436 + return retval;
76437 +}
76438 diff --git a/include/asm-generic/4level-fixup.h b/include/asm-generic/4level-fixup.h
76439 index 77ff547..181834f 100644
76440 --- a/include/asm-generic/4level-fixup.h
76441 +++ b/include/asm-generic/4level-fixup.h
76442 @@ -13,8 +13,10 @@
76443 #define pmd_alloc(mm, pud, address) \
76444 ((unlikely(pgd_none(*(pud))) && __pmd_alloc(mm, pud, address))? \
76445 NULL: pmd_offset(pud, address))
76446 +#define pmd_alloc_kernel(mm, pud, address) pmd_alloc((mm), (pud), (address))
76447
76448 #define pud_alloc(mm, pgd, address) (pgd)
76449 +#define pud_alloc_kernel(mm, pgd, address) pud_alloc((mm), (pgd), (address))
76450 #define pud_offset(pgd, start) (pgd)
76451 #define pud_none(pud) 0
76452 #define pud_bad(pud) 0
76453 diff --git a/include/asm-generic/atomic-long.h b/include/asm-generic/atomic-long.h
76454 index b7babf0..97f4c4f 100644
76455 --- a/include/asm-generic/atomic-long.h
76456 +++ b/include/asm-generic/atomic-long.h
76457 @@ -22,6 +22,12 @@
76458
76459 typedef atomic64_t atomic_long_t;
76460
76461 +#ifdef CONFIG_PAX_REFCOUNT
76462 +typedef atomic64_unchecked_t atomic_long_unchecked_t;
76463 +#else
76464 +typedef atomic64_t atomic_long_unchecked_t;
76465 +#endif
76466 +
76467 #define ATOMIC_LONG_INIT(i) ATOMIC64_INIT(i)
76468
76469 static inline long atomic_long_read(atomic_long_t *l)
76470 @@ -31,6 +37,15 @@ static inline long atomic_long_read(atomic_long_t *l)
76471 return (long)atomic64_read(v);
76472 }
76473
76474 +#ifdef CONFIG_PAX_REFCOUNT
76475 +static inline long atomic_long_read_unchecked(atomic_long_unchecked_t *l)
76476 +{
76477 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
76478 +
76479 + return (long)atomic64_read_unchecked(v);
76480 +}
76481 +#endif
76482 +
76483 static inline void atomic_long_set(atomic_long_t *l, long i)
76484 {
76485 atomic64_t *v = (atomic64_t *)l;
76486 @@ -38,6 +53,15 @@ static inline void atomic_long_set(atomic_long_t *l, long i)
76487 atomic64_set(v, i);
76488 }
76489
76490 +#ifdef CONFIG_PAX_REFCOUNT
76491 +static inline void atomic_long_set_unchecked(atomic_long_unchecked_t *l, long i)
76492 +{
76493 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
76494 +
76495 + atomic64_set_unchecked(v, i);
76496 +}
76497 +#endif
76498 +
76499 static inline void atomic_long_inc(atomic_long_t *l)
76500 {
76501 atomic64_t *v = (atomic64_t *)l;
76502 @@ -45,6 +69,15 @@ static inline void atomic_long_inc(atomic_long_t *l)
76503 atomic64_inc(v);
76504 }
76505
76506 +#ifdef CONFIG_PAX_REFCOUNT
76507 +static inline void atomic_long_inc_unchecked(atomic_long_unchecked_t *l)
76508 +{
76509 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
76510 +
76511 + atomic64_inc_unchecked(v);
76512 +}
76513 +#endif
76514 +
76515 static inline void atomic_long_dec(atomic_long_t *l)
76516 {
76517 atomic64_t *v = (atomic64_t *)l;
76518 @@ -52,6 +85,15 @@ static inline void atomic_long_dec(atomic_long_t *l)
76519 atomic64_dec(v);
76520 }
76521
76522 +#ifdef CONFIG_PAX_REFCOUNT
76523 +static inline void atomic_long_dec_unchecked(atomic_long_unchecked_t *l)
76524 +{
76525 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
76526 +
76527 + atomic64_dec_unchecked(v);
76528 +}
76529 +#endif
76530 +
76531 static inline void atomic_long_add(long i, atomic_long_t *l)
76532 {
76533 atomic64_t *v = (atomic64_t *)l;
76534 @@ -59,6 +101,15 @@ static inline void atomic_long_add(long i, atomic_long_t *l)
76535 atomic64_add(i, v);
76536 }
76537
76538 +#ifdef CONFIG_PAX_REFCOUNT
76539 +static inline void atomic_long_add_unchecked(long i, atomic_long_unchecked_t *l)
76540 +{
76541 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
76542 +
76543 + atomic64_add_unchecked(i, v);
76544 +}
76545 +#endif
76546 +
76547 static inline void atomic_long_sub(long i, atomic_long_t *l)
76548 {
76549 atomic64_t *v = (atomic64_t *)l;
76550 @@ -66,6 +117,15 @@ static inline void atomic_long_sub(long i, atomic_long_t *l)
76551 atomic64_sub(i, v);
76552 }
76553
76554 +#ifdef CONFIG_PAX_REFCOUNT
76555 +static inline void atomic_long_sub_unchecked(long i, atomic_long_unchecked_t *l)
76556 +{
76557 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
76558 +
76559 + atomic64_sub_unchecked(i, v);
76560 +}
76561 +#endif
76562 +
76563 static inline int atomic_long_sub_and_test(long i, atomic_long_t *l)
76564 {
76565 atomic64_t *v = (atomic64_t *)l;
76566 @@ -94,13 +154,22 @@ static inline int atomic_long_add_negative(long i, atomic_long_t *l)
76567 return atomic64_add_negative(i, v);
76568 }
76569
76570 -static inline long atomic_long_add_return(long i, atomic_long_t *l)
76571 +static inline long __intentional_overflow(-1) atomic_long_add_return(long i, atomic_long_t *l)
76572 {
76573 atomic64_t *v = (atomic64_t *)l;
76574
76575 return (long)atomic64_add_return(i, v);
76576 }
76577
76578 +#ifdef CONFIG_PAX_REFCOUNT
76579 +static inline long atomic_long_add_return_unchecked(long i, atomic_long_unchecked_t *l)
76580 +{
76581 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
76582 +
76583 + return (long)atomic64_add_return_unchecked(i, v);
76584 +}
76585 +#endif
76586 +
76587 static inline long atomic_long_sub_return(long i, atomic_long_t *l)
76588 {
76589 atomic64_t *v = (atomic64_t *)l;
76590 @@ -115,6 +184,15 @@ static inline long atomic_long_inc_return(atomic_long_t *l)
76591 return (long)atomic64_inc_return(v);
76592 }
76593
76594 +#ifdef CONFIG_PAX_REFCOUNT
76595 +static inline long atomic_long_inc_return_unchecked(atomic_long_unchecked_t *l)
76596 +{
76597 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
76598 +
76599 + return (long)atomic64_inc_return_unchecked(v);
76600 +}
76601 +#endif
76602 +
76603 static inline long atomic_long_dec_return(atomic_long_t *l)
76604 {
76605 atomic64_t *v = (atomic64_t *)l;
76606 @@ -140,6 +218,12 @@ static inline long atomic_long_add_unless(atomic_long_t *l, long a, long u)
76607
76608 typedef atomic_t atomic_long_t;
76609
76610 +#ifdef CONFIG_PAX_REFCOUNT
76611 +typedef atomic_unchecked_t atomic_long_unchecked_t;
76612 +#else
76613 +typedef atomic_t atomic_long_unchecked_t;
76614 +#endif
76615 +
76616 #define ATOMIC_LONG_INIT(i) ATOMIC_INIT(i)
76617 static inline long atomic_long_read(atomic_long_t *l)
76618 {
76619 @@ -148,6 +232,15 @@ static inline long atomic_long_read(atomic_long_t *l)
76620 return (long)atomic_read(v);
76621 }
76622
76623 +#ifdef CONFIG_PAX_REFCOUNT
76624 +static inline long atomic_long_read_unchecked(atomic_long_unchecked_t *l)
76625 +{
76626 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
76627 +
76628 + return (long)atomic_read_unchecked(v);
76629 +}
76630 +#endif
76631 +
76632 static inline void atomic_long_set(atomic_long_t *l, long i)
76633 {
76634 atomic_t *v = (atomic_t *)l;
76635 @@ -155,6 +248,15 @@ static inline void atomic_long_set(atomic_long_t *l, long i)
76636 atomic_set(v, i);
76637 }
76638
76639 +#ifdef CONFIG_PAX_REFCOUNT
76640 +static inline void atomic_long_set_unchecked(atomic_long_unchecked_t *l, long i)
76641 +{
76642 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
76643 +
76644 + atomic_set_unchecked(v, i);
76645 +}
76646 +#endif
76647 +
76648 static inline void atomic_long_inc(atomic_long_t *l)
76649 {
76650 atomic_t *v = (atomic_t *)l;
76651 @@ -162,6 +264,15 @@ static inline void atomic_long_inc(atomic_long_t *l)
76652 atomic_inc(v);
76653 }
76654
76655 +#ifdef CONFIG_PAX_REFCOUNT
76656 +static inline void atomic_long_inc_unchecked(atomic_long_unchecked_t *l)
76657 +{
76658 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
76659 +
76660 + atomic_inc_unchecked(v);
76661 +}
76662 +#endif
76663 +
76664 static inline void atomic_long_dec(atomic_long_t *l)
76665 {
76666 atomic_t *v = (atomic_t *)l;
76667 @@ -169,6 +280,15 @@ static inline void atomic_long_dec(atomic_long_t *l)
76668 atomic_dec(v);
76669 }
76670
76671 +#ifdef CONFIG_PAX_REFCOUNT
76672 +static inline void atomic_long_dec_unchecked(atomic_long_unchecked_t *l)
76673 +{
76674 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
76675 +
76676 + atomic_dec_unchecked(v);
76677 +}
76678 +#endif
76679 +
76680 static inline void atomic_long_add(long i, atomic_long_t *l)
76681 {
76682 atomic_t *v = (atomic_t *)l;
76683 @@ -176,6 +296,15 @@ static inline void atomic_long_add(long i, atomic_long_t *l)
76684 atomic_add(i, v);
76685 }
76686
76687 +#ifdef CONFIG_PAX_REFCOUNT
76688 +static inline void atomic_long_add_unchecked(long i, atomic_long_unchecked_t *l)
76689 +{
76690 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
76691 +
76692 + atomic_add_unchecked(i, v);
76693 +}
76694 +#endif
76695 +
76696 static inline void atomic_long_sub(long i, atomic_long_t *l)
76697 {
76698 atomic_t *v = (atomic_t *)l;
76699 @@ -183,6 +312,15 @@ static inline void atomic_long_sub(long i, atomic_long_t *l)
76700 atomic_sub(i, v);
76701 }
76702
76703 +#ifdef CONFIG_PAX_REFCOUNT
76704 +static inline void atomic_long_sub_unchecked(long i, atomic_long_unchecked_t *l)
76705 +{
76706 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
76707 +
76708 + atomic_sub_unchecked(i, v);
76709 +}
76710 +#endif
76711 +
76712 static inline int atomic_long_sub_and_test(long i, atomic_long_t *l)
76713 {
76714 atomic_t *v = (atomic_t *)l;
76715 @@ -218,6 +356,16 @@ static inline long atomic_long_add_return(long i, atomic_long_t *l)
76716 return (long)atomic_add_return(i, v);
76717 }
76718
76719 +#ifdef CONFIG_PAX_REFCOUNT
76720 +static inline long atomic_long_add_return_unchecked(long i, atomic_long_unchecked_t *l)
76721 +{
76722 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
76723 +
76724 + return (long)atomic_add_return_unchecked(i, v);
76725 +}
76726 +
76727 +#endif
76728 +
76729 static inline long atomic_long_sub_return(long i, atomic_long_t *l)
76730 {
76731 atomic_t *v = (atomic_t *)l;
76732 @@ -232,6 +380,15 @@ static inline long atomic_long_inc_return(atomic_long_t *l)
76733 return (long)atomic_inc_return(v);
76734 }
76735
76736 +#ifdef CONFIG_PAX_REFCOUNT
76737 +static inline long atomic_long_inc_return_unchecked(atomic_long_unchecked_t *l)
76738 +{
76739 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
76740 +
76741 + return (long)atomic_inc_return_unchecked(v);
76742 +}
76743 +#endif
76744 +
76745 static inline long atomic_long_dec_return(atomic_long_t *l)
76746 {
76747 atomic_t *v = (atomic_t *)l;
76748 @@ -255,4 +412,57 @@ static inline long atomic_long_add_unless(atomic_long_t *l, long a, long u)
76749
76750 #endif /* BITS_PER_LONG == 64 */
76751
76752 +#ifdef CONFIG_PAX_REFCOUNT
76753 +static inline void pax_refcount_needs_these_functions(void)
76754 +{
76755 + atomic_read_unchecked((atomic_unchecked_t *)NULL);
76756 + atomic_set_unchecked((atomic_unchecked_t *)NULL, 0);
76757 + atomic_add_unchecked(0, (atomic_unchecked_t *)NULL);
76758 + atomic_sub_unchecked(0, (atomic_unchecked_t *)NULL);
76759 + atomic_inc_unchecked((atomic_unchecked_t *)NULL);
76760 + (void)atomic_inc_and_test_unchecked((atomic_unchecked_t *)NULL);
76761 + atomic_inc_return_unchecked((atomic_unchecked_t *)NULL);
76762 + atomic_add_return_unchecked(0, (atomic_unchecked_t *)NULL);
76763 + atomic_dec_unchecked((atomic_unchecked_t *)NULL);
76764 + atomic_cmpxchg_unchecked((atomic_unchecked_t *)NULL, 0, 0);
76765 + (void)atomic_xchg_unchecked((atomic_unchecked_t *)NULL, 0);
76766 +#ifdef CONFIG_X86
76767 + atomic_clear_mask_unchecked(0, NULL);
76768 + atomic_set_mask_unchecked(0, NULL);
76769 +#endif
76770 +
76771 + atomic_long_read_unchecked((atomic_long_unchecked_t *)NULL);
76772 + atomic_long_set_unchecked((atomic_long_unchecked_t *)NULL, 0);
76773 + atomic_long_add_unchecked(0, (atomic_long_unchecked_t *)NULL);
76774 + atomic_long_sub_unchecked(0, (atomic_long_unchecked_t *)NULL);
76775 + atomic_long_inc_unchecked((atomic_long_unchecked_t *)NULL);
76776 + atomic_long_add_return_unchecked(0, (atomic_long_unchecked_t *)NULL);
76777 + atomic_long_inc_return_unchecked((atomic_long_unchecked_t *)NULL);
76778 + atomic_long_dec_unchecked((atomic_long_unchecked_t *)NULL);
76779 +}
76780 +#else
76781 +#define atomic_read_unchecked(v) atomic_read(v)
76782 +#define atomic_set_unchecked(v, i) atomic_set((v), (i))
76783 +#define atomic_add_unchecked(i, v) atomic_add((i), (v))
76784 +#define atomic_sub_unchecked(i, v) atomic_sub((i), (v))
76785 +#define atomic_inc_unchecked(v) atomic_inc(v)
76786 +#define atomic_inc_and_test_unchecked(v) atomic_inc_and_test(v)
76787 +#define atomic_inc_return_unchecked(v) atomic_inc_return(v)
76788 +#define atomic_add_return_unchecked(i, v) atomic_add_return((i), (v))
76789 +#define atomic_dec_unchecked(v) atomic_dec(v)
76790 +#define atomic_cmpxchg_unchecked(v, o, n) atomic_cmpxchg((v), (o), (n))
76791 +#define atomic_xchg_unchecked(v, i) atomic_xchg((v), (i))
76792 +#define atomic_clear_mask_unchecked(mask, v) atomic_clear_mask((mask), (v))
76793 +#define atomic_set_mask_unchecked(mask, v) atomic_set_mask((mask), (v))
76794 +
76795 +#define atomic_long_read_unchecked(v) atomic_long_read(v)
76796 +#define atomic_long_set_unchecked(v, i) atomic_long_set((v), (i))
76797 +#define atomic_long_add_unchecked(i, v) atomic_long_add((i), (v))
76798 +#define atomic_long_sub_unchecked(i, v) atomic_long_sub((i), (v))
76799 +#define atomic_long_inc_unchecked(v) atomic_long_inc(v)
76800 +#define atomic_long_add_return_unchecked(i, v) atomic_long_add_return((i), (v))
76801 +#define atomic_long_inc_return_unchecked(v) atomic_long_inc_return(v)
76802 +#define atomic_long_dec_unchecked(v) atomic_long_dec(v)
76803 +#endif
76804 +
76805 #endif /* _ASM_GENERIC_ATOMIC_LONG_H */
76806 diff --git a/include/asm-generic/atomic.h b/include/asm-generic/atomic.h
76807 index 33bd2de..f31bff97 100644
76808 --- a/include/asm-generic/atomic.h
76809 +++ b/include/asm-generic/atomic.h
76810 @@ -153,7 +153,7 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
76811 * Atomically clears the bits set in @mask from @v
76812 */
76813 #ifndef atomic_clear_mask
76814 -static inline void atomic_clear_mask(unsigned long mask, atomic_t *v)
76815 +static inline void atomic_clear_mask(unsigned int mask, atomic_t *v)
76816 {
76817 unsigned long flags;
76818
76819 diff --git a/include/asm-generic/atomic64.h b/include/asm-generic/atomic64.h
76820 index b18ce4f..2ee2843 100644
76821 --- a/include/asm-generic/atomic64.h
76822 +++ b/include/asm-generic/atomic64.h
76823 @@ -16,6 +16,8 @@ typedef struct {
76824 long long counter;
76825 } atomic64_t;
76826
76827 +typedef atomic64_t atomic64_unchecked_t;
76828 +
76829 #define ATOMIC64_INIT(i) { (i) }
76830
76831 extern long long atomic64_read(const atomic64_t *v);
76832 @@ -39,4 +41,14 @@ extern int atomic64_add_unless(atomic64_t *v, long long a, long long u);
76833 #define atomic64_dec_and_test(v) (atomic64_dec_return((v)) == 0)
76834 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1LL, 0LL)
76835
76836 +#define atomic64_read_unchecked(v) atomic64_read(v)
76837 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
76838 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
76839 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
76840 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
76841 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
76842 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
76843 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
76844 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
76845 +
76846 #endif /* _ASM_GENERIC_ATOMIC64_H */
76847 diff --git a/include/asm-generic/barrier.h b/include/asm-generic/barrier.h
76848 index 6f692f8..2ad9dd2 100644
76849 --- a/include/asm-generic/barrier.h
76850 +++ b/include/asm-generic/barrier.h
76851 @@ -66,7 +66,7 @@
76852 do { \
76853 compiletime_assert_atomic_type(*p); \
76854 smp_mb(); \
76855 - ACCESS_ONCE(*p) = (v); \
76856 + ACCESS_ONCE_RW(*p) = (v); \
76857 } while (0)
76858
76859 #define smp_load_acquire(p) \
76860 diff --git a/include/asm-generic/bitops/__fls.h b/include/asm-generic/bitops/__fls.h
76861 index a60a7cc..0fe12f2 100644
76862 --- a/include/asm-generic/bitops/__fls.h
76863 +++ b/include/asm-generic/bitops/__fls.h
76864 @@ -9,7 +9,7 @@
76865 *
76866 * Undefined if no set bit exists, so code should check against 0 first.
76867 */
76868 -static __always_inline unsigned long __fls(unsigned long word)
76869 +static __always_inline unsigned long __intentional_overflow(-1) __fls(unsigned long word)
76870 {
76871 int num = BITS_PER_LONG - 1;
76872
76873 diff --git a/include/asm-generic/bitops/fls.h b/include/asm-generic/bitops/fls.h
76874 index 0576d1f..dad6c71 100644
76875 --- a/include/asm-generic/bitops/fls.h
76876 +++ b/include/asm-generic/bitops/fls.h
76877 @@ -9,7 +9,7 @@
76878 * Note fls(0) = 0, fls(1) = 1, fls(0x80000000) = 32.
76879 */
76880
76881 -static __always_inline int fls(int x)
76882 +static __always_inline int __intentional_overflow(-1) fls(int x)
76883 {
76884 int r = 32;
76885
76886 diff --git a/include/asm-generic/bitops/fls64.h b/include/asm-generic/bitops/fls64.h
76887 index b097cf8..3d40e14 100644
76888 --- a/include/asm-generic/bitops/fls64.h
76889 +++ b/include/asm-generic/bitops/fls64.h
76890 @@ -15,7 +15,7 @@
76891 * at position 64.
76892 */
76893 #if BITS_PER_LONG == 32
76894 -static __always_inline int fls64(__u64 x)
76895 +static __always_inline int __intentional_overflow(-1) fls64(__u64 x)
76896 {
76897 __u32 h = x >> 32;
76898 if (h)
76899 @@ -23,7 +23,7 @@ static __always_inline int fls64(__u64 x)
76900 return fls(x);
76901 }
76902 #elif BITS_PER_LONG == 64
76903 -static __always_inline int fls64(__u64 x)
76904 +static __always_inline int __intentional_overflow(-1) fls64(__u64 x)
76905 {
76906 if (x == 0)
76907 return 0;
76908 diff --git a/include/asm-generic/cache.h b/include/asm-generic/cache.h
76909 index 1bfcfe5..e04c5c9 100644
76910 --- a/include/asm-generic/cache.h
76911 +++ b/include/asm-generic/cache.h
76912 @@ -6,7 +6,7 @@
76913 * cache lines need to provide their own cache.h.
76914 */
76915
76916 -#define L1_CACHE_SHIFT 5
76917 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
76918 +#define L1_CACHE_SHIFT 5UL
76919 +#define L1_CACHE_BYTES (1UL << L1_CACHE_SHIFT)
76920
76921 #endif /* __ASM_GENERIC_CACHE_H */
76922 diff --git a/include/asm-generic/emergency-restart.h b/include/asm-generic/emergency-restart.h
76923 index 0d68a1e..b74a761 100644
76924 --- a/include/asm-generic/emergency-restart.h
76925 +++ b/include/asm-generic/emergency-restart.h
76926 @@ -1,7 +1,7 @@
76927 #ifndef _ASM_GENERIC_EMERGENCY_RESTART_H
76928 #define _ASM_GENERIC_EMERGENCY_RESTART_H
76929
76930 -static inline void machine_emergency_restart(void)
76931 +static inline __noreturn void machine_emergency_restart(void)
76932 {
76933 machine_restart(NULL);
76934 }
76935 diff --git a/include/asm-generic/io.h b/include/asm-generic/io.h
76936 index 975e1cc..0b8a083 100644
76937 --- a/include/asm-generic/io.h
76938 +++ b/include/asm-generic/io.h
76939 @@ -289,7 +289,7 @@ static inline void pci_iounmap(struct pci_dev *dev, void __iomem *p)
76940 * These are pretty trivial
76941 */
76942 #ifndef virt_to_phys
76943 -static inline unsigned long virt_to_phys(volatile void *address)
76944 +static inline unsigned long __intentional_overflow(-1) virt_to_phys(volatile void *address)
76945 {
76946 return __pa((unsigned long)address);
76947 }
76948 diff --git a/include/asm-generic/kmap_types.h b/include/asm-generic/kmap_types.h
76949 index 90f99c7..00ce236 100644
76950 --- a/include/asm-generic/kmap_types.h
76951 +++ b/include/asm-generic/kmap_types.h
76952 @@ -2,9 +2,9 @@
76953 #define _ASM_GENERIC_KMAP_TYPES_H
76954
76955 #ifdef __WITH_KM_FENCE
76956 -# define KM_TYPE_NR 41
76957 +# define KM_TYPE_NR 42
76958 #else
76959 -# define KM_TYPE_NR 20
76960 +# define KM_TYPE_NR 21
76961 #endif
76962
76963 #endif
76964 diff --git a/include/asm-generic/local.h b/include/asm-generic/local.h
76965 index 9ceb03b..62b0b8f 100644
76966 --- a/include/asm-generic/local.h
76967 +++ b/include/asm-generic/local.h
76968 @@ -23,24 +23,37 @@ typedef struct
76969 atomic_long_t a;
76970 } local_t;
76971
76972 +typedef struct {
76973 + atomic_long_unchecked_t a;
76974 +} local_unchecked_t;
76975 +
76976 #define LOCAL_INIT(i) { ATOMIC_LONG_INIT(i) }
76977
76978 #define local_read(l) atomic_long_read(&(l)->a)
76979 +#define local_read_unchecked(l) atomic_long_read_unchecked(&(l)->a)
76980 #define local_set(l,i) atomic_long_set((&(l)->a),(i))
76981 +#define local_set_unchecked(l,i) atomic_long_set_unchecked((&(l)->a),(i))
76982 #define local_inc(l) atomic_long_inc(&(l)->a)
76983 +#define local_inc_unchecked(l) atomic_long_inc_unchecked(&(l)->a)
76984 #define local_dec(l) atomic_long_dec(&(l)->a)
76985 +#define local_dec_unchecked(l) atomic_long_dec_unchecked(&(l)->a)
76986 #define local_add(i,l) atomic_long_add((i),(&(l)->a))
76987 +#define local_add_unchecked(i,l) atomic_long_add_unchecked((i),(&(l)->a))
76988 #define local_sub(i,l) atomic_long_sub((i),(&(l)->a))
76989 +#define local_sub_unchecked(i,l) atomic_long_sub_unchecked((i),(&(l)->a))
76990
76991 #define local_sub_and_test(i, l) atomic_long_sub_and_test((i), (&(l)->a))
76992 #define local_dec_and_test(l) atomic_long_dec_and_test(&(l)->a)
76993 #define local_inc_and_test(l) atomic_long_inc_and_test(&(l)->a)
76994 #define local_add_negative(i, l) atomic_long_add_negative((i), (&(l)->a))
76995 #define local_add_return(i, l) atomic_long_add_return((i), (&(l)->a))
76996 +#define local_add_return_unchecked(i, l) atomic_long_add_return_unchecked((i), (&(l)->a))
76997 #define local_sub_return(i, l) atomic_long_sub_return((i), (&(l)->a))
76998 #define local_inc_return(l) atomic_long_inc_return(&(l)->a)
76999 +#define local_dec_return(l) atomic_long_dec_return(&(l)->a)
77000
77001 #define local_cmpxchg(l, o, n) atomic_long_cmpxchg((&(l)->a), (o), (n))
77002 +#define local_cmpxchg_unchecked(l, o, n) atomic_long_cmpxchg((&(l)->a), (o), (n))
77003 #define local_xchg(l, n) atomic_long_xchg((&(l)->a), (n))
77004 #define local_add_unless(l, _a, u) atomic_long_add_unless((&(l)->a), (_a), (u))
77005 #define local_inc_not_zero(l) atomic_long_inc_not_zero(&(l)->a)
77006 diff --git a/include/asm-generic/pgtable-nopmd.h b/include/asm-generic/pgtable-nopmd.h
77007 index 725612b..9cc513a 100644
77008 --- a/include/asm-generic/pgtable-nopmd.h
77009 +++ b/include/asm-generic/pgtable-nopmd.h
77010 @@ -1,14 +1,19 @@
77011 #ifndef _PGTABLE_NOPMD_H
77012 #define _PGTABLE_NOPMD_H
77013
77014 -#ifndef __ASSEMBLY__
77015 -
77016 #include <asm-generic/pgtable-nopud.h>
77017
77018 -struct mm_struct;
77019 -
77020 #define __PAGETABLE_PMD_FOLDED
77021
77022 +#define PMD_SHIFT PUD_SHIFT
77023 +#define PTRS_PER_PMD 1
77024 +#define PMD_SIZE (_AC(1,UL) << PMD_SHIFT)
77025 +#define PMD_MASK (~(PMD_SIZE-1))
77026 +
77027 +#ifndef __ASSEMBLY__
77028 +
77029 +struct mm_struct;
77030 +
77031 /*
77032 * Having the pmd type consist of a pud gets the size right, and allows
77033 * us to conceptually access the pud entry that this pmd is folded into
77034 @@ -16,11 +21,6 @@ struct mm_struct;
77035 */
77036 typedef struct { pud_t pud; } pmd_t;
77037
77038 -#define PMD_SHIFT PUD_SHIFT
77039 -#define PTRS_PER_PMD 1
77040 -#define PMD_SIZE (1UL << PMD_SHIFT)
77041 -#define PMD_MASK (~(PMD_SIZE-1))
77042 -
77043 /*
77044 * The "pud_xxx()" functions here are trivial for a folded two-level
77045 * setup: the pmd is never bad, and a pmd always exists (as it's folded
77046 diff --git a/include/asm-generic/pgtable-nopud.h b/include/asm-generic/pgtable-nopud.h
77047 index 810431d..0ec4804f 100644
77048 --- a/include/asm-generic/pgtable-nopud.h
77049 +++ b/include/asm-generic/pgtable-nopud.h
77050 @@ -1,10 +1,15 @@
77051 #ifndef _PGTABLE_NOPUD_H
77052 #define _PGTABLE_NOPUD_H
77053
77054 -#ifndef __ASSEMBLY__
77055 -
77056 #define __PAGETABLE_PUD_FOLDED
77057
77058 +#define PUD_SHIFT PGDIR_SHIFT
77059 +#define PTRS_PER_PUD 1
77060 +#define PUD_SIZE (_AC(1,UL) << PUD_SHIFT)
77061 +#define PUD_MASK (~(PUD_SIZE-1))
77062 +
77063 +#ifndef __ASSEMBLY__
77064 +
77065 /*
77066 * Having the pud type consist of a pgd gets the size right, and allows
77067 * us to conceptually access the pgd entry that this pud is folded into
77068 @@ -12,11 +17,6 @@
77069 */
77070 typedef struct { pgd_t pgd; } pud_t;
77071
77072 -#define PUD_SHIFT PGDIR_SHIFT
77073 -#define PTRS_PER_PUD 1
77074 -#define PUD_SIZE (1UL << PUD_SHIFT)
77075 -#define PUD_MASK (~(PUD_SIZE-1))
77076 -
77077 /*
77078 * The "pgd_xxx()" functions here are trivial for a folded two-level
77079 * setup: the pud is never bad, and a pud always exists (as it's folded
77080 @@ -29,6 +29,7 @@ static inline void pgd_clear(pgd_t *pgd) { }
77081 #define pud_ERROR(pud) (pgd_ERROR((pud).pgd))
77082
77083 #define pgd_populate(mm, pgd, pud) do { } while (0)
77084 +#define pgd_populate_kernel(mm, pgd, pud) do { } while (0)
77085 /*
77086 * (puds are folded into pgds so this doesn't get actually called,
77087 * but the define is needed for a generic inline function.)
77088 diff --git a/include/asm-generic/pgtable.h b/include/asm-generic/pgtable.h
77089 index a8015a7..7a4407b 100644
77090 --- a/include/asm-generic/pgtable.h
77091 +++ b/include/asm-generic/pgtable.h
77092 @@ -815,6 +815,22 @@ static inline void pmdp_set_numa(struct mm_struct *mm, unsigned long addr,
77093 }
77094 #endif /* CONFIG_NUMA_BALANCING */
77095
77096 +#ifndef __HAVE_ARCH_PAX_OPEN_KERNEL
77097 +#ifdef CONFIG_PAX_KERNEXEC
77098 +#error KERNEXEC requires pax_open_kernel
77099 +#else
77100 +static inline unsigned long pax_open_kernel(void) { return 0; }
77101 +#endif
77102 +#endif
77103 +
77104 +#ifndef __HAVE_ARCH_PAX_CLOSE_KERNEL
77105 +#ifdef CONFIG_PAX_KERNEXEC
77106 +#error KERNEXEC requires pax_close_kernel
77107 +#else
77108 +static inline unsigned long pax_close_kernel(void) { return 0; }
77109 +#endif
77110 +#endif
77111 +
77112 #endif /* CONFIG_MMU */
77113
77114 #endif /* !__ASSEMBLY__ */
77115 diff --git a/include/asm-generic/uaccess.h b/include/asm-generic/uaccess.h
77116 index 72d8803..cb9749c 100644
77117 --- a/include/asm-generic/uaccess.h
77118 +++ b/include/asm-generic/uaccess.h
77119 @@ -343,4 +343,20 @@ clear_user(void __user *to, unsigned long n)
77120 return __clear_user(to, n);
77121 }
77122
77123 +#ifndef __HAVE_ARCH_PAX_OPEN_USERLAND
77124 +#ifdef CONFIG_PAX_MEMORY_UDEREF
77125 +#error UDEREF requires pax_open_userland
77126 +#else
77127 +static inline unsigned long pax_open_userland(void) { return 0; }
77128 +#endif
77129 +#endif
77130 +
77131 +#ifndef __HAVE_ARCH_PAX_CLOSE_USERLAND
77132 +#ifdef CONFIG_PAX_MEMORY_UDEREF
77133 +#error UDEREF requires pax_close_userland
77134 +#else
77135 +static inline unsigned long pax_close_userland(void) { return 0; }
77136 +#endif
77137 +#endif
77138 +
77139 #endif /* __ASM_GENERIC_UACCESS_H */
77140 diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
77141 index 146e4ff..f4f9609 100644
77142 --- a/include/asm-generic/vmlinux.lds.h
77143 +++ b/include/asm-generic/vmlinux.lds.h
77144 @@ -251,6 +251,7 @@
77145 .rodata : AT(ADDR(.rodata) - LOAD_OFFSET) { \
77146 VMLINUX_SYMBOL(__start_rodata) = .; \
77147 *(.rodata) *(.rodata.*) \
77148 + *(.data..read_only) \
77149 *(__vermagic) /* Kernel version magic */ \
77150 . = ALIGN(8); \
77151 VMLINUX_SYMBOL(__start___tracepoints_ptrs) = .; \
77152 @@ -737,17 +738,18 @@
77153 * section in the linker script will go there too. @phdr should have
77154 * a leading colon.
77155 *
77156 - * Note that this macros defines __per_cpu_load as an absolute symbol.
77157 + * Note that this macros defines per_cpu_load as an absolute symbol.
77158 * If there is no need to put the percpu section at a predetermined
77159 * address, use PERCPU_SECTION.
77160 */
77161 #define PERCPU_VADDR(cacheline, vaddr, phdr) \
77162 - VMLINUX_SYMBOL(__per_cpu_load) = .; \
77163 - .data..percpu vaddr : AT(VMLINUX_SYMBOL(__per_cpu_load) \
77164 + per_cpu_load = .; \
77165 + .data..percpu vaddr : AT(VMLINUX_SYMBOL(per_cpu_load) \
77166 - LOAD_OFFSET) { \
77167 + VMLINUX_SYMBOL(__per_cpu_load) = . + per_cpu_load; \
77168 PERCPU_INPUT(cacheline) \
77169 } phdr \
77170 - . = VMLINUX_SYMBOL(__per_cpu_load) + SIZEOF(.data..percpu);
77171 + . = VMLINUX_SYMBOL(per_cpu_load) + SIZEOF(.data..percpu);
77172
77173 /**
77174 * PERCPU_SECTION - define output section for percpu area, simple version
77175 diff --git a/include/crypto/algapi.h b/include/crypto/algapi.h
77176 index 016c2f1..c4baa98 100644
77177 --- a/include/crypto/algapi.h
77178 +++ b/include/crypto/algapi.h
77179 @@ -34,7 +34,7 @@ struct crypto_type {
77180 unsigned int maskclear;
77181 unsigned int maskset;
77182 unsigned int tfmsize;
77183 -};
77184 +} __do_const;
77185
77186 struct crypto_instance {
77187 struct crypto_alg alg;
77188 diff --git a/include/drm/drmP.h b/include/drm/drmP.h
77189 index a7c2a86..078f1b6 100644
77190 --- a/include/drm/drmP.h
77191 +++ b/include/drm/drmP.h
77192 @@ -68,6 +68,7 @@
77193 #include <linux/workqueue.h>
77194 #include <linux/poll.h>
77195 #include <asm/pgalloc.h>
77196 +#include <asm/local.h>
77197 #include <drm/drm.h>
77198 #include <drm/drm_sarea.h>
77199 #include <drm/drm_vma_manager.h>
77200 @@ -268,10 +269,12 @@ do { \
77201 * \param cmd command.
77202 * \param arg argument.
77203 */
77204 -typedef int drm_ioctl_t(struct drm_device *dev, void *data,
77205 +typedef int (* const drm_ioctl_t)(struct drm_device *dev, void *data,
77206 + struct drm_file *file_priv);
77207 +typedef int (* drm_ioctl_no_const_t)(struct drm_device *dev, void *data,
77208 struct drm_file *file_priv);
77209
77210 -typedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd,
77211 +typedef int (* const drm_ioctl_compat_t)(struct file *filp, unsigned int cmd,
77212 unsigned long arg);
77213
77214 #define DRM_IOCTL_NR(n) _IOC_NR(n)
77215 @@ -287,10 +290,10 @@ typedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd,
77216 struct drm_ioctl_desc {
77217 unsigned int cmd;
77218 int flags;
77219 - drm_ioctl_t *func;
77220 + drm_ioctl_t func;
77221 unsigned int cmd_drv;
77222 const char *name;
77223 -};
77224 +} __do_const;
77225
77226 /**
77227 * Creates a driver or general drm_ioctl_desc array entry for the given
77228 @@ -1001,7 +1004,8 @@ struct drm_info_list {
77229 int (*show)(struct seq_file*, void*); /** show callback */
77230 u32 driver_features; /**< Required driver features for this entry */
77231 void *data;
77232 -};
77233 +} __do_const;
77234 +typedef struct drm_info_list __no_const drm_info_list_no_const;
77235
77236 /**
77237 * debugfs node structure. This structure represents a debugfs file.
77238 @@ -1083,7 +1087,7 @@ struct drm_device {
77239
77240 /** \name Usage Counters */
77241 /*@{ */
77242 - int open_count; /**< Outstanding files open */
77243 + local_t open_count; /**< Outstanding files open */
77244 int buf_use; /**< Buffers in use -- cannot alloc */
77245 atomic_t buf_alloc; /**< Buffer allocation in progress */
77246 /*@} */
77247 diff --git a/include/drm/drm_crtc_helper.h b/include/drm/drm_crtc_helper.h
77248 index 36a5feb..d9f01aa 100644
77249 --- a/include/drm/drm_crtc_helper.h
77250 +++ b/include/drm/drm_crtc_helper.h
77251 @@ -109,7 +109,7 @@ struct drm_encoder_helper_funcs {
77252 struct drm_connector *connector);
77253 /* disable encoder when not in use - more explicit than dpms off */
77254 void (*disable)(struct drm_encoder *encoder);
77255 -};
77256 +} __no_const;
77257
77258 /**
77259 * drm_connector_helper_funcs - helper operations for connectors
77260 diff --git a/include/drm/i915_pciids.h b/include/drm/i915_pciids.h
77261 index 012d58f..d0a0642 100644
77262 --- a/include/drm/i915_pciids.h
77263 +++ b/include/drm/i915_pciids.h
77264 @@ -37,7 +37,7 @@
77265 */
77266 #define INTEL_VGA_DEVICE(id, info) { \
77267 0x8086, id, \
77268 - ~0, ~0, \
77269 + PCI_ANY_ID, PCI_ANY_ID, \
77270 0x030000, 0xff0000, \
77271 (unsigned long) info }
77272
77273 diff --git a/include/drm/ttm/ttm_memory.h b/include/drm/ttm/ttm_memory.h
77274 index 72dcbe8..8db58d7 100644
77275 --- a/include/drm/ttm/ttm_memory.h
77276 +++ b/include/drm/ttm/ttm_memory.h
77277 @@ -48,7 +48,7 @@
77278
77279 struct ttm_mem_shrink {
77280 int (*do_shrink) (struct ttm_mem_shrink *);
77281 -};
77282 +} __no_const;
77283
77284 /**
77285 * struct ttm_mem_global - Global memory accounting structure.
77286 diff --git a/include/drm/ttm/ttm_page_alloc.h b/include/drm/ttm/ttm_page_alloc.h
77287 index 49a8284..9643967 100644
77288 --- a/include/drm/ttm/ttm_page_alloc.h
77289 +++ b/include/drm/ttm/ttm_page_alloc.h
77290 @@ -80,6 +80,7 @@ void ttm_dma_page_alloc_fini(void);
77291 */
77292 extern int ttm_dma_page_alloc_debugfs(struct seq_file *m, void *data);
77293
77294 +struct device;
77295 extern int ttm_dma_populate(struct ttm_dma_tt *ttm_dma, struct device *dev);
77296 extern void ttm_dma_unpopulate(struct ttm_dma_tt *ttm_dma, struct device *dev);
77297
77298 diff --git a/include/keys/asymmetric-subtype.h b/include/keys/asymmetric-subtype.h
77299 index 4b840e8..155d235 100644
77300 --- a/include/keys/asymmetric-subtype.h
77301 +++ b/include/keys/asymmetric-subtype.h
77302 @@ -37,7 +37,7 @@ struct asymmetric_key_subtype {
77303 /* Verify the signature on a key of this subtype (optional) */
77304 int (*verify_signature)(const struct key *key,
77305 const struct public_key_signature *sig);
77306 -};
77307 +} __do_const;
77308
77309 /**
77310 * asymmetric_key_subtype - Get the subtype from an asymmetric key
77311 diff --git a/include/linux/atmdev.h b/include/linux/atmdev.h
77312 index c1da539..1dcec55 100644
77313 --- a/include/linux/atmdev.h
77314 +++ b/include/linux/atmdev.h
77315 @@ -28,7 +28,7 @@ struct compat_atm_iobuf {
77316 #endif
77317
77318 struct k_atm_aal_stats {
77319 -#define __HANDLE_ITEM(i) atomic_t i
77320 +#define __HANDLE_ITEM(i) atomic_unchecked_t i
77321 __AAL_STAT_ITEMS
77322 #undef __HANDLE_ITEM
77323 };
77324 @@ -200,7 +200,7 @@ struct atmdev_ops { /* only send is required */
77325 int (*change_qos)(struct atm_vcc *vcc,struct atm_qos *qos,int flags);
77326 int (*proc_read)(struct atm_dev *dev,loff_t *pos,char *page);
77327 struct module *owner;
77328 -};
77329 +} __do_const ;
77330
77331 struct atmphy_ops {
77332 int (*start)(struct atm_dev *dev);
77333 diff --git a/include/linux/audit.h b/include/linux/audit.h
77334 index 22cfddb..ab759e8 100644
77335 --- a/include/linux/audit.h
77336 +++ b/include/linux/audit.h
77337 @@ -210,7 +210,7 @@ static inline void audit_ptrace(struct task_struct *t)
77338 extern unsigned int audit_serial(void);
77339 extern int auditsc_get_stamp(struct audit_context *ctx,
77340 struct timespec *t, unsigned int *serial);
77341 -extern int audit_set_loginuid(kuid_t loginuid);
77342 +extern int __intentional_overflow(-1) audit_set_loginuid(kuid_t loginuid);
77343
77344 static inline kuid_t audit_get_loginuid(struct task_struct *tsk)
77345 {
77346 diff --git a/include/linux/binfmts.h b/include/linux/binfmts.h
77347 index 61f29e5..e67c658 100644
77348 --- a/include/linux/binfmts.h
77349 +++ b/include/linux/binfmts.h
77350 @@ -44,7 +44,7 @@ struct linux_binprm {
77351 unsigned interp_flags;
77352 unsigned interp_data;
77353 unsigned long loader, exec;
77354 -};
77355 +} __randomize_layout;
77356
77357 #define BINPRM_FLAGS_ENFORCE_NONDUMP_BIT 0
77358 #define BINPRM_FLAGS_ENFORCE_NONDUMP (1 << BINPRM_FLAGS_ENFORCE_NONDUMP_BIT)
77359 @@ -73,8 +73,10 @@ struct linux_binfmt {
77360 int (*load_binary)(struct linux_binprm *);
77361 int (*load_shlib)(struct file *);
77362 int (*core_dump)(struct coredump_params *cprm);
77363 + void (*handle_mprotect)(struct vm_area_struct *vma, unsigned long newflags);
77364 + void (*handle_mmap)(struct file *);
77365 unsigned long min_coredump; /* minimal dump size */
77366 -};
77367 +} __do_const __randomize_layout;
77368
77369 extern void __register_binfmt(struct linux_binfmt *fmt, int insert);
77370
77371 diff --git a/include/linux/bitops.h b/include/linux/bitops.h
77372 index be5fd38..d71192a 100644
77373 --- a/include/linux/bitops.h
77374 +++ b/include/linux/bitops.h
77375 @@ -102,7 +102,7 @@ static inline __u64 ror64(__u64 word, unsigned int shift)
77376 * @word: value to rotate
77377 * @shift: bits to roll
77378 */
77379 -static inline __u32 rol32(__u32 word, unsigned int shift)
77380 +static inline __u32 __intentional_overflow(-1) rol32(__u32 word, unsigned int shift)
77381 {
77382 return (word << shift) | (word >> (32 - shift));
77383 }
77384 @@ -112,7 +112,7 @@ static inline __u32 rol32(__u32 word, unsigned int shift)
77385 * @word: value to rotate
77386 * @shift: bits to roll
77387 */
77388 -static inline __u32 ror32(__u32 word, unsigned int shift)
77389 +static inline __u32 __intentional_overflow(-1) ror32(__u32 word, unsigned int shift)
77390 {
77391 return (word >> shift) | (word << (32 - shift));
77392 }
77393 @@ -168,7 +168,7 @@ static inline __s32 sign_extend32(__u32 value, int index)
77394 return (__s32)(value << shift) >> shift;
77395 }
77396
77397 -static inline unsigned fls_long(unsigned long l)
77398 +static inline unsigned __intentional_overflow(-1) fls_long(unsigned long l)
77399 {
77400 if (sizeof(l) == 4)
77401 return fls(l);
77402 diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
77403 index 0d84981..bb741c0 100644
77404 --- a/include/linux/blkdev.h
77405 +++ b/include/linux/blkdev.h
77406 @@ -1584,7 +1584,7 @@ struct block_device_operations {
77407 /* this callback is with swap_lock and sometimes page table lock held */
77408 void (*swap_slot_free_notify) (struct block_device *, unsigned long);
77409 struct module *owner;
77410 -};
77411 +} __do_const;
77412
77413 extern int __blkdev_driver_ioctl(struct block_device *, fmode_t, unsigned int,
77414 unsigned long);
77415 diff --git a/include/linux/blktrace_api.h b/include/linux/blktrace_api.h
77416 index afc1343..9735539 100644
77417 --- a/include/linux/blktrace_api.h
77418 +++ b/include/linux/blktrace_api.h
77419 @@ -25,7 +25,7 @@ struct blk_trace {
77420 struct dentry *dropped_file;
77421 struct dentry *msg_file;
77422 struct list_head running_list;
77423 - atomic_t dropped;
77424 + atomic_unchecked_t dropped;
77425 };
77426
77427 extern int blk_trace_ioctl(struct block_device *, unsigned, char __user *);
77428 diff --git a/include/linux/cache.h b/include/linux/cache.h
77429 index 17e7e82..1d7da26 100644
77430 --- a/include/linux/cache.h
77431 +++ b/include/linux/cache.h
77432 @@ -16,6 +16,14 @@
77433 #define __read_mostly
77434 #endif
77435
77436 +#ifndef __read_only
77437 +#ifdef CONFIG_PAX_KERNEXEC
77438 +#error KERNEXEC requires __read_only
77439 +#else
77440 +#define __read_only __read_mostly
77441 +#endif
77442 +#endif
77443 +
77444 #ifndef ____cacheline_aligned
77445 #define ____cacheline_aligned __attribute__((__aligned__(SMP_CACHE_BYTES)))
77446 #endif
77447 diff --git a/include/linux/capability.h b/include/linux/capability.h
77448 index 84b13ad..172cdee 100644
77449 --- a/include/linux/capability.h
77450 +++ b/include/linux/capability.h
77451 @@ -211,9 +211,14 @@ extern bool has_ns_capability_noaudit(struct task_struct *t,
77452 extern bool capable(int cap);
77453 extern bool ns_capable(struct user_namespace *ns, int cap);
77454 extern bool capable_wrt_inode_uidgid(const struct inode *inode, int cap);
77455 +extern bool capable_wrt_inode_uidgid_nolog(const struct inode *inode, int cap);
77456 extern bool file_ns_capable(const struct file *file, struct user_namespace *ns, int cap);
77457 +extern bool capable_nolog(int cap);
77458 +extern bool ns_capable_nolog(struct user_namespace *ns, int cap);
77459
77460 /* audit system wants to get cap info from files as well */
77461 extern int get_vfs_caps_from_disk(const struct dentry *dentry, struct cpu_vfs_cap_data *cpu_caps);
77462
77463 +extern int is_privileged_binary(const struct dentry *dentry);
77464 +
77465 #endif /* !_LINUX_CAPABILITY_H */
77466 diff --git a/include/linux/cdrom.h b/include/linux/cdrom.h
77467 index 8609d57..86e4d79 100644
77468 --- a/include/linux/cdrom.h
77469 +++ b/include/linux/cdrom.h
77470 @@ -87,7 +87,6 @@ struct cdrom_device_ops {
77471
77472 /* driver specifications */
77473 const int capability; /* capability flags */
77474 - int n_minors; /* number of active minor devices */
77475 /* handle uniform packets for scsi type devices (scsi,atapi) */
77476 int (*generic_packet) (struct cdrom_device_info *,
77477 struct packet_command *);
77478 diff --git a/include/linux/cleancache.h b/include/linux/cleancache.h
77479 index 4ce9056..86caac6 100644
77480 --- a/include/linux/cleancache.h
77481 +++ b/include/linux/cleancache.h
77482 @@ -31,7 +31,7 @@ struct cleancache_ops {
77483 void (*invalidate_page)(int, struct cleancache_filekey, pgoff_t);
77484 void (*invalidate_inode)(int, struct cleancache_filekey);
77485 void (*invalidate_fs)(int);
77486 -};
77487 +} __no_const;
77488
77489 extern struct cleancache_ops *
77490 cleancache_register_ops(struct cleancache_ops *ops);
77491 diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h
77492 index 5119174..8e264f8 100644
77493 --- a/include/linux/clk-provider.h
77494 +++ b/include/linux/clk-provider.h
77495 @@ -174,6 +174,7 @@ struct clk_ops {
77496 void (*init)(struct clk_hw *hw);
77497 int (*debug_init)(struct clk_hw *hw, struct dentry *dentry);
77498 };
77499 +typedef struct clk_ops __no_const clk_ops_no_const;
77500
77501 /**
77502 * struct clk_init_data - holds init data that's common to all clocks and is
77503 diff --git a/include/linux/compat.h b/include/linux/compat.h
77504 index e649426..a74047b 100644
77505 --- a/include/linux/compat.h
77506 +++ b/include/linux/compat.h
77507 @@ -316,7 +316,7 @@ compat_sys_get_robust_list(int pid, compat_uptr_t __user *head_ptr,
77508 compat_size_t __user *len_ptr);
77509
77510 asmlinkage long compat_sys_ipc(u32, int, int, u32, compat_uptr_t, u32);
77511 -asmlinkage long compat_sys_shmat(int shmid, compat_uptr_t shmaddr, int shmflg);
77512 +asmlinkage long compat_sys_shmat(int shmid, compat_uptr_t shmaddr, int shmflg) __intentional_overflow(0);
77513 asmlinkage long compat_sys_semctl(int semid, int semnum, int cmd, int arg);
77514 asmlinkage long compat_sys_msgsnd(int msqid, compat_uptr_t msgp,
77515 compat_ssize_t msgsz, int msgflg);
77516 @@ -436,7 +436,7 @@ extern int compat_ptrace_request(struct task_struct *child,
77517 extern long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
77518 compat_ulong_t addr, compat_ulong_t data);
77519 asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
77520 - compat_long_t addr, compat_long_t data);
77521 + compat_ulong_t addr, compat_ulong_t data);
77522
77523 asmlinkage long compat_sys_lookup_dcookie(u32, u32, char __user *, compat_size_t);
77524 /*
77525 diff --git a/include/linux/compiler-gcc4.h b/include/linux/compiler-gcc4.h
77526 index 2507fd2..55203f8 100644
77527 --- a/include/linux/compiler-gcc4.h
77528 +++ b/include/linux/compiler-gcc4.h
77529 @@ -39,9 +39,34 @@
77530 # define __compiletime_warning(message) __attribute__((warning(message)))
77531 # define __compiletime_error(message) __attribute__((error(message)))
77532 #endif /* __CHECKER__ */
77533 +
77534 +#define __alloc_size(...) __attribute((alloc_size(__VA_ARGS__)))
77535 +#define __bos(ptr, arg) __builtin_object_size((ptr), (arg))
77536 +#define __bos0(ptr) __bos((ptr), 0)
77537 +#define __bos1(ptr) __bos((ptr), 1)
77538 #endif /* GCC_VERSION >= 40300 */
77539
77540 #if GCC_VERSION >= 40500
77541 +
77542 +#ifdef RANDSTRUCT_PLUGIN
77543 +#define __randomize_layout __attribute__((randomize_layout))
77544 +#define __no_randomize_layout __attribute__((no_randomize_layout))
77545 +#endif
77546 +
77547 +#ifdef CONSTIFY_PLUGIN
77548 +#define __no_const __attribute__((no_const))
77549 +#define __do_const __attribute__((do_const))
77550 +#endif
77551 +
77552 +#ifdef SIZE_OVERFLOW_PLUGIN
77553 +#define __size_overflow(...) __attribute__((size_overflow(__VA_ARGS__)))
77554 +#define __intentional_overflow(...) __attribute__((intentional_overflow(__VA_ARGS__)))
77555 +#endif
77556 +
77557 +#ifdef LATENT_ENTROPY_PLUGIN
77558 +#define __latent_entropy __attribute__((latent_entropy))
77559 +#endif
77560 +
77561 /*
77562 * Mark a position in code as unreachable. This can be used to
77563 * suppress control flow warnings after asm blocks that transfer
77564 diff --git a/include/linux/compiler.h b/include/linux/compiler.h
77565 index ee7239e..7c11769 100644
77566 --- a/include/linux/compiler.h
77567 +++ b/include/linux/compiler.h
77568 @@ -5,11 +5,14 @@
77569
77570 #ifdef __CHECKER__
77571 # define __user __attribute__((noderef, address_space(1)))
77572 +# define __force_user __force __user
77573 # define __kernel __attribute__((address_space(0)))
77574 +# define __force_kernel __force __kernel
77575 # define __safe __attribute__((safe))
77576 # define __force __attribute__((force))
77577 # define __nocast __attribute__((nocast))
77578 # define __iomem __attribute__((noderef, address_space(2)))
77579 +# define __force_iomem __force __iomem
77580 # define __must_hold(x) __attribute__((context(x,1,1)))
77581 # define __acquires(x) __attribute__((context(x,0,1)))
77582 # define __releases(x) __attribute__((context(x,1,0)))
77583 @@ -17,20 +20,37 @@
77584 # define __release(x) __context__(x,-1)
77585 # define __cond_lock(x,c) ((c) ? ({ __acquire(x); 1; }) : 0)
77586 # define __percpu __attribute__((noderef, address_space(3)))
77587 +# define __force_percpu __force __percpu
77588 #ifdef CONFIG_SPARSE_RCU_POINTER
77589 # define __rcu __attribute__((noderef, address_space(4)))
77590 +# define __force_rcu __force __rcu
77591 #else
77592 # define __rcu
77593 +# define __force_rcu
77594 #endif
77595 extern void __chk_user_ptr(const volatile void __user *);
77596 extern void __chk_io_ptr(const volatile void __iomem *);
77597 #else
77598 -# define __user
77599 -# define __kernel
77600 +# ifdef CHECKER_PLUGIN
77601 +//# define __user
77602 +//# define __force_user
77603 +//# define __kernel
77604 +//# define __force_kernel
77605 +# else
77606 +# ifdef STRUCTLEAK_PLUGIN
77607 +# define __user __attribute__((user))
77608 +# else
77609 +# define __user
77610 +# endif
77611 +# define __force_user
77612 +# define __kernel
77613 +# define __force_kernel
77614 +# endif
77615 # define __safe
77616 # define __force
77617 # define __nocast
77618 # define __iomem
77619 +# define __force_iomem
77620 # define __chk_user_ptr(x) (void)0
77621 # define __chk_io_ptr(x) (void)0
77622 # define __builtin_warning(x, y...) (1)
77623 @@ -41,7 +61,9 @@ extern void __chk_io_ptr(const volatile void __iomem *);
77624 # define __release(x) (void)0
77625 # define __cond_lock(x,c) (c)
77626 # define __percpu
77627 +# define __force_percpu
77628 # define __rcu
77629 +# define __force_rcu
77630 #endif
77631
77632 /* Indirect macros required for expanded argument pasting, eg. __LINE__. */
77633 @@ -286,6 +308,34 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
77634 # define __attribute_const__ /* unimplemented */
77635 #endif
77636
77637 +#ifndef __randomize_layout
77638 +# define __randomize_layout
77639 +#endif
77640 +
77641 +#ifndef __no_randomize_layout
77642 +# define __no_randomize_layout
77643 +#endif
77644 +
77645 +#ifndef __no_const
77646 +# define __no_const
77647 +#endif
77648 +
77649 +#ifndef __do_const
77650 +# define __do_const
77651 +#endif
77652 +
77653 +#ifndef __size_overflow
77654 +# define __size_overflow(...)
77655 +#endif
77656 +
77657 +#ifndef __intentional_overflow
77658 +# define __intentional_overflow(...)
77659 +#endif
77660 +
77661 +#ifndef __latent_entropy
77662 +# define __latent_entropy
77663 +#endif
77664 +
77665 /*
77666 * Tell gcc if a function is cold. The compiler will assume any path
77667 * directly leading to the call is unlikely.
77668 @@ -295,6 +345,22 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
77669 #define __cold
77670 #endif
77671
77672 +#ifndef __alloc_size
77673 +#define __alloc_size(...)
77674 +#endif
77675 +
77676 +#ifndef __bos
77677 +#define __bos(ptr, arg)
77678 +#endif
77679 +
77680 +#ifndef __bos0
77681 +#define __bos0(ptr)
77682 +#endif
77683 +
77684 +#ifndef __bos1
77685 +#define __bos1(ptr)
77686 +#endif
77687 +
77688 /* Simple shorthand for a section definition */
77689 #ifndef __section
77690 # define __section(S) __attribute__ ((__section__(#S)))
77691 @@ -369,7 +435,8 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
77692 * use is to mediate communication between process-level code and irq/NMI
77693 * handlers, all running on the same CPU.
77694 */
77695 -#define ACCESS_ONCE(x) (*(volatile typeof(x) *)&(x))
77696 +#define ACCESS_ONCE(x) (*(volatile const typeof(x) *)&(x))
77697 +#define ACCESS_ONCE_RW(x) (*(volatile typeof(x) *)&(x))
77698
77699 /* Ignore/forbid kprobes attach on very low level functions marked by this attribute: */
77700 #ifdef CONFIG_KPROBES
77701 diff --git a/include/linux/completion.h b/include/linux/completion.h
77702 index 5d5aaae..0ea9b84 100644
77703 --- a/include/linux/completion.h
77704 +++ b/include/linux/completion.h
77705 @@ -90,16 +90,16 @@ static inline void reinit_completion(struct completion *x)
77706
77707 extern void wait_for_completion(struct completion *);
77708 extern void wait_for_completion_io(struct completion *);
77709 -extern int wait_for_completion_interruptible(struct completion *x);
77710 -extern int wait_for_completion_killable(struct completion *x);
77711 +extern int wait_for_completion_interruptible(struct completion *x) __intentional_overflow(-1);
77712 +extern int wait_for_completion_killable(struct completion *x) __intentional_overflow(-1);
77713 extern unsigned long wait_for_completion_timeout(struct completion *x,
77714 - unsigned long timeout);
77715 + unsigned long timeout) __intentional_overflow(-1);
77716 extern unsigned long wait_for_completion_io_timeout(struct completion *x,
77717 - unsigned long timeout);
77718 + unsigned long timeout) __intentional_overflow(-1);
77719 extern long wait_for_completion_interruptible_timeout(
77720 - struct completion *x, unsigned long timeout);
77721 + struct completion *x, unsigned long timeout) __intentional_overflow(-1);
77722 extern long wait_for_completion_killable_timeout(
77723 - struct completion *x, unsigned long timeout);
77724 + struct completion *x, unsigned long timeout) __intentional_overflow(-1);
77725 extern bool try_wait_for_completion(struct completion *x);
77726 extern bool completion_done(struct completion *x);
77727
77728 diff --git a/include/linux/configfs.h b/include/linux/configfs.h
77729 index 34025df..d94bbbc 100644
77730 --- a/include/linux/configfs.h
77731 +++ b/include/linux/configfs.h
77732 @@ -125,7 +125,7 @@ struct configfs_attribute {
77733 const char *ca_name;
77734 struct module *ca_owner;
77735 umode_t ca_mode;
77736 -};
77737 +} __do_const;
77738
77739 /*
77740 * Users often need to create attribute structures for their configurable
77741 diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h
77742 index 5ae5100..b809662 100644
77743 --- a/include/linux/cpufreq.h
77744 +++ b/include/linux/cpufreq.h
77745 @@ -200,6 +200,7 @@ struct global_attr {
77746 ssize_t (*store)(struct kobject *a, struct attribute *b,
77747 const char *c, size_t count);
77748 };
77749 +typedef struct global_attr __no_const global_attr_no_const;
77750
77751 #define define_one_global_ro(_name) \
77752 static struct global_attr _name = \
77753 @@ -242,7 +243,7 @@ struct cpufreq_driver {
77754 bool boost_supported;
77755 bool boost_enabled;
77756 int (*set_boost) (int state);
77757 -};
77758 +} __do_const;
77759
77760 /* flags */
77761 #define CPUFREQ_STICKY (1 << 0) /* driver isn't removed even if
77762 diff --git a/include/linux/cpuidle.h b/include/linux/cpuidle.h
77763 index b0238cb..db89e1e 100644
77764 --- a/include/linux/cpuidle.h
77765 +++ b/include/linux/cpuidle.h
77766 @@ -50,7 +50,8 @@ struct cpuidle_state {
77767 int index);
77768
77769 int (*enter_dead) (struct cpuidle_device *dev, int index);
77770 -};
77771 +} __do_const;
77772 +typedef struct cpuidle_state __no_const cpuidle_state_no_const;
77773
77774 /* Idle State Flags */
77775 #define CPUIDLE_FLAG_TIME_VALID (0x01) /* is residency time measurable? */
77776 @@ -211,7 +212,7 @@ struct cpuidle_governor {
77777 void (*reflect) (struct cpuidle_device *dev, int index);
77778
77779 struct module *owner;
77780 -};
77781 +} __do_const;
77782
77783 #ifdef CONFIG_CPU_IDLE
77784 extern int cpuidle_register_governor(struct cpuidle_governor *gov);
77785 diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h
77786 index d08e4d2..95fad61 100644
77787 --- a/include/linux/cpumask.h
77788 +++ b/include/linux/cpumask.h
77789 @@ -118,17 +118,17 @@ static inline unsigned int cpumask_first(const struct cpumask *srcp)
77790 }
77791
77792 /* Valid inputs for n are -1 and 0. */
77793 -static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)
77794 +static inline unsigned int __intentional_overflow(-1) cpumask_next(int n, const struct cpumask *srcp)
77795 {
77796 return n+1;
77797 }
77798
77799 -static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
77800 +static inline unsigned int __intentional_overflow(-1) cpumask_next_zero(int n, const struct cpumask *srcp)
77801 {
77802 return n+1;
77803 }
77804
77805 -static inline unsigned int cpumask_next_and(int n,
77806 +static inline unsigned int __intentional_overflow(-1) cpumask_next_and(int n,
77807 const struct cpumask *srcp,
77808 const struct cpumask *andp)
77809 {
77810 @@ -167,7 +167,7 @@ static inline unsigned int cpumask_first(const struct cpumask *srcp)
77811 *
77812 * Returns >= nr_cpu_ids if no further cpus set.
77813 */
77814 -static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)
77815 +static inline unsigned int __intentional_overflow(-1) cpumask_next(int n, const struct cpumask *srcp)
77816 {
77817 /* -1 is a legal arg here. */
77818 if (n != -1)
77819 @@ -182,7 +182,7 @@ static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)
77820 *
77821 * Returns >= nr_cpu_ids if no further cpus unset.
77822 */
77823 -static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
77824 +static inline unsigned int __intentional_overflow(-1) cpumask_next_zero(int n, const struct cpumask *srcp)
77825 {
77826 /* -1 is a legal arg here. */
77827 if (n != -1)
77828 @@ -190,7 +190,7 @@ static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
77829 return find_next_zero_bit(cpumask_bits(srcp), nr_cpumask_bits, n+1);
77830 }
77831
77832 -int cpumask_next_and(int n, const struct cpumask *, const struct cpumask *);
77833 +int cpumask_next_and(int n, const struct cpumask *, const struct cpumask *) __intentional_overflow(-1);
77834 int cpumask_any_but(const struct cpumask *mask, unsigned int cpu);
77835
77836 /**
77837 diff --git a/include/linux/cred.h b/include/linux/cred.h
77838 index f61d6c8..d372d95 100644
77839 --- a/include/linux/cred.h
77840 +++ b/include/linux/cred.h
77841 @@ -35,7 +35,7 @@ struct group_info {
77842 int nblocks;
77843 kgid_t small_block[NGROUPS_SMALL];
77844 kgid_t *blocks[0];
77845 -};
77846 +} __randomize_layout;
77847
77848 /**
77849 * get_group_info - Get a reference to a group info structure
77850 @@ -136,7 +136,7 @@ struct cred {
77851 struct user_namespace *user_ns; /* user_ns the caps and keyrings are relative to. */
77852 struct group_info *group_info; /* supplementary groups for euid/fsgid */
77853 struct rcu_head rcu; /* RCU deletion hook */
77854 -};
77855 +} __randomize_layout;
77856
77857 extern void __put_cred(struct cred *);
77858 extern void exit_creds(struct task_struct *);
77859 @@ -194,6 +194,9 @@ static inline void validate_creds_for_do_exit(struct task_struct *tsk)
77860 static inline void validate_process_creds(void)
77861 {
77862 }
77863 +static inline void validate_task_creds(struct task_struct *task)
77864 +{
77865 +}
77866 #endif
77867
77868 /**
77869 @@ -322,6 +325,7 @@ static inline void put_cred(const struct cred *_cred)
77870
77871 #define task_uid(task) (task_cred_xxx((task), uid))
77872 #define task_euid(task) (task_cred_xxx((task), euid))
77873 +#define task_securebits(task) (task_cred_xxx((task), securebits))
77874
77875 #define current_cred_xxx(xxx) \
77876 ({ \
77877 diff --git a/include/linux/crypto.h b/include/linux/crypto.h
77878 index b92eadf..b4ecdc1 100644
77879 --- a/include/linux/crypto.h
77880 +++ b/include/linux/crypto.h
77881 @@ -373,7 +373,7 @@ struct cipher_tfm {
77882 const u8 *key, unsigned int keylen);
77883 void (*cit_encrypt_one)(struct crypto_tfm *tfm, u8 *dst, const u8 *src);
77884 void (*cit_decrypt_one)(struct crypto_tfm *tfm, u8 *dst, const u8 *src);
77885 -};
77886 +} __no_const;
77887
77888 struct hash_tfm {
77889 int (*init)(struct hash_desc *desc);
77890 @@ -394,13 +394,13 @@ struct compress_tfm {
77891 int (*cot_decompress)(struct crypto_tfm *tfm,
77892 const u8 *src, unsigned int slen,
77893 u8 *dst, unsigned int *dlen);
77894 -};
77895 +} __no_const;
77896
77897 struct rng_tfm {
77898 int (*rng_gen_random)(struct crypto_rng *tfm, u8 *rdata,
77899 unsigned int dlen);
77900 int (*rng_reset)(struct crypto_rng *tfm, u8 *seed, unsigned int slen);
77901 -};
77902 +} __no_const;
77903
77904 #define crt_ablkcipher crt_u.ablkcipher
77905 #define crt_aead crt_u.aead
77906 diff --git a/include/linux/ctype.h b/include/linux/ctype.h
77907 index 653589e..4ef254a 100644
77908 --- a/include/linux/ctype.h
77909 +++ b/include/linux/ctype.h
77910 @@ -56,7 +56,7 @@ static inline unsigned char __toupper(unsigned char c)
77911 * Fast implementation of tolower() for internal usage. Do not use in your
77912 * code.
77913 */
77914 -static inline char _tolower(const char c)
77915 +static inline unsigned char _tolower(const unsigned char c)
77916 {
77917 return c | 0x20;
77918 }
77919 diff --git a/include/linux/dcache.h b/include/linux/dcache.h
77920 index 3c7ec32..4ca97cc 100644
77921 --- a/include/linux/dcache.h
77922 +++ b/include/linux/dcache.h
77923 @@ -133,7 +133,7 @@ struct dentry {
77924 } d_u;
77925 struct list_head d_subdirs; /* our children */
77926 struct hlist_node d_alias; /* inode alias list */
77927 -};
77928 +} __randomize_layout;
77929
77930 /*
77931 * dentry->d_lock spinlock nesting subclasses:
77932 diff --git a/include/linux/decompress/mm.h b/include/linux/decompress/mm.h
77933 index 7925bf0..d5143d2 100644
77934 --- a/include/linux/decompress/mm.h
77935 +++ b/include/linux/decompress/mm.h
77936 @@ -77,7 +77,7 @@ static void free(void *where)
77937 * warnings when not needed (indeed large_malloc / large_free are not
77938 * needed by inflate */
77939
77940 -#define malloc(a) kmalloc(a, GFP_KERNEL)
77941 +#define malloc(a) kmalloc((a), GFP_KERNEL)
77942 #define free(a) kfree(a)
77943
77944 #define large_malloc(a) vmalloc(a)
77945 diff --git a/include/linux/devfreq.h b/include/linux/devfreq.h
77946 index d48dc00..211ee54 100644
77947 --- a/include/linux/devfreq.h
77948 +++ b/include/linux/devfreq.h
77949 @@ -114,7 +114,7 @@ struct devfreq_governor {
77950 int (*get_target_freq)(struct devfreq *this, unsigned long *freq);
77951 int (*event_handler)(struct devfreq *devfreq,
77952 unsigned int event, void *data);
77953 -};
77954 +} __do_const;
77955
77956 /**
77957 * struct devfreq - Device devfreq structure
77958 diff --git a/include/linux/device.h b/include/linux/device.h
77959 index d1d1c05..a90fdb0 100644
77960 --- a/include/linux/device.h
77961 +++ b/include/linux/device.h
77962 @@ -310,7 +310,7 @@ struct subsys_interface {
77963 struct list_head node;
77964 int (*add_dev)(struct device *dev, struct subsys_interface *sif);
77965 int (*remove_dev)(struct device *dev, struct subsys_interface *sif);
77966 -};
77967 +} __do_const;
77968
77969 int subsys_interface_register(struct subsys_interface *sif);
77970 void subsys_interface_unregister(struct subsys_interface *sif);
77971 @@ -506,7 +506,7 @@ struct device_type {
77972 void (*release)(struct device *dev);
77973
77974 const struct dev_pm_ops *pm;
77975 -};
77976 +} __do_const;
77977
77978 /* interface for exporting device attributes */
77979 struct device_attribute {
77980 @@ -516,11 +516,12 @@ struct device_attribute {
77981 ssize_t (*store)(struct device *dev, struct device_attribute *attr,
77982 const char *buf, size_t count);
77983 };
77984 +typedef struct device_attribute __no_const device_attribute_no_const;
77985
77986 struct dev_ext_attribute {
77987 struct device_attribute attr;
77988 void *var;
77989 -};
77990 +} __do_const;
77991
77992 ssize_t device_show_ulong(struct device *dev, struct device_attribute *attr,
77993 char *buf);
77994 diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h
77995 index fd4aee2..1f28db9 100644
77996 --- a/include/linux/dma-mapping.h
77997 +++ b/include/linux/dma-mapping.h
77998 @@ -54,7 +54,7 @@ struct dma_map_ops {
77999 u64 (*get_required_mask)(struct device *dev);
78000 #endif
78001 int is_phys;
78002 -};
78003 +} __do_const;
78004
78005 #define DMA_BIT_MASK(n) (((n) == 64) ? ~0ULL : ((1ULL<<(n))-1))
78006
78007 diff --git a/include/linux/dmaengine.h b/include/linux/dmaengine.h
78008 index 72cb0dd..7fe9a4b 100644
78009 --- a/include/linux/dmaengine.h
78010 +++ b/include/linux/dmaengine.h
78011 @@ -1147,9 +1147,9 @@ struct dma_pinned_list {
78012 struct dma_pinned_list *dma_pin_iovec_pages(struct iovec *iov, size_t len);
78013 void dma_unpin_iovec_pages(struct dma_pinned_list* pinned_list);
78014
78015 -dma_cookie_t dma_memcpy_to_iovec(struct dma_chan *chan, struct iovec *iov,
78016 +dma_cookie_t __intentional_overflow(0) dma_memcpy_to_iovec(struct dma_chan *chan, struct iovec *iov,
78017 struct dma_pinned_list *pinned_list, unsigned char *kdata, size_t len);
78018 -dma_cookie_t dma_memcpy_pg_to_iovec(struct dma_chan *chan, struct iovec *iov,
78019 +dma_cookie_t __intentional_overflow(0) dma_memcpy_pg_to_iovec(struct dma_chan *chan, struct iovec *iov,
78020 struct dma_pinned_list *pinned_list, struct page *page,
78021 unsigned int offset, size_t len);
78022
78023 diff --git a/include/linux/efi.h b/include/linux/efi.h
78024 index 6c100ff..e3289b4 100644
78025 --- a/include/linux/efi.h
78026 +++ b/include/linux/efi.h
78027 @@ -1009,6 +1009,7 @@ struct efivar_operations {
78028 efi_set_variable_t *set_variable;
78029 efi_query_variable_store_t *query_variable_store;
78030 };
78031 +typedef struct efivar_operations __no_const efivar_operations_no_const;
78032
78033 struct efivars {
78034 /*
78035 diff --git a/include/linux/elf.h b/include/linux/elf.h
78036 index 67a5fa7..b817372 100644
78037 --- a/include/linux/elf.h
78038 +++ b/include/linux/elf.h
78039 @@ -24,6 +24,7 @@ extern Elf32_Dyn _DYNAMIC [];
78040 #define elf_note elf32_note
78041 #define elf_addr_t Elf32_Off
78042 #define Elf_Half Elf32_Half
78043 +#define elf_dyn Elf32_Dyn
78044
78045 #else
78046
78047 @@ -34,6 +35,7 @@ extern Elf64_Dyn _DYNAMIC [];
78048 #define elf_note elf64_note
78049 #define elf_addr_t Elf64_Off
78050 #define Elf_Half Elf64_Half
78051 +#define elf_dyn Elf64_Dyn
78052
78053 #endif
78054
78055 diff --git a/include/linux/err.h b/include/linux/err.h
78056 index a729120..6ede2c9 100644
78057 --- a/include/linux/err.h
78058 +++ b/include/linux/err.h
78059 @@ -20,12 +20,12 @@
78060
78061 #define IS_ERR_VALUE(x) unlikely((x) >= (unsigned long)-MAX_ERRNO)
78062
78063 -static inline void * __must_check ERR_PTR(long error)
78064 +static inline void * __must_check __intentional_overflow(-1) ERR_PTR(long error)
78065 {
78066 return (void *) error;
78067 }
78068
78069 -static inline long __must_check PTR_ERR(__force const void *ptr)
78070 +static inline long __must_check __intentional_overflow(-1) PTR_ERR(__force const void *ptr)
78071 {
78072 return (long) ptr;
78073 }
78074 diff --git a/include/linux/extcon.h b/include/linux/extcon.h
78075 index f488145..3b6b04e 100644
78076 --- a/include/linux/extcon.h
78077 +++ b/include/linux/extcon.h
78078 @@ -135,7 +135,7 @@ struct extcon_dev {
78079 /* /sys/class/extcon/.../mutually_exclusive/... */
78080 struct attribute_group attr_g_muex;
78081 struct attribute **attrs_muex;
78082 - struct device_attribute *d_attrs_muex;
78083 + device_attribute_no_const *d_attrs_muex;
78084 };
78085
78086 /**
78087 diff --git a/include/linux/fb.h b/include/linux/fb.h
78088 index fe6ac95..898d41d 100644
78089 --- a/include/linux/fb.h
78090 +++ b/include/linux/fb.h
78091 @@ -304,7 +304,7 @@ struct fb_ops {
78092 /* called at KDB enter and leave time to prepare the console */
78093 int (*fb_debug_enter)(struct fb_info *info);
78094 int (*fb_debug_leave)(struct fb_info *info);
78095 -};
78096 +} __do_const;
78097
78098 #ifdef CONFIG_FB_TILEBLITTING
78099 #define FB_TILE_CURSOR_NONE 0
78100 diff --git a/include/linux/fdtable.h b/include/linux/fdtable.h
78101 index 230f87b..1fd0485 100644
78102 --- a/include/linux/fdtable.h
78103 +++ b/include/linux/fdtable.h
78104 @@ -100,7 +100,7 @@ struct files_struct *get_files_struct(struct task_struct *);
78105 void put_files_struct(struct files_struct *fs);
78106 void reset_files_struct(struct files_struct *);
78107 int unshare_files(struct files_struct **);
78108 -struct files_struct *dup_fd(struct files_struct *, int *);
78109 +struct files_struct *dup_fd(struct files_struct *, int *) __latent_entropy;
78110 void do_close_on_exec(struct files_struct *);
78111 int iterate_fd(struct files_struct *, unsigned,
78112 int (*)(const void *, struct file *, unsigned),
78113 diff --git a/include/linux/frontswap.h b/include/linux/frontswap.h
78114 index 8293262..2b3b8bd 100644
78115 --- a/include/linux/frontswap.h
78116 +++ b/include/linux/frontswap.h
78117 @@ -11,7 +11,7 @@ struct frontswap_ops {
78118 int (*load)(unsigned, pgoff_t, struct page *);
78119 void (*invalidate_page)(unsigned, pgoff_t);
78120 void (*invalidate_area)(unsigned);
78121 -};
78122 +} __no_const;
78123
78124 extern bool frontswap_enabled;
78125 extern struct frontswap_ops *
78126 diff --git a/include/linux/fs.h b/include/linux/fs.h
78127 index 8780312..425cc22 100644
78128 --- a/include/linux/fs.h
78129 +++ b/include/linux/fs.h
78130 @@ -398,7 +398,7 @@ struct address_space {
78131 spinlock_t private_lock; /* for use by the address_space */
78132 struct list_head private_list; /* ditto */
78133 void *private_data; /* ditto */
78134 -} __attribute__((aligned(sizeof(long))));
78135 +} __attribute__((aligned(sizeof(long)))) __randomize_layout;
78136 /*
78137 * On most architectures that alignment is already the case; but
78138 * must be enforced here for CRIS, to let the least significant bit
78139 @@ -441,7 +441,7 @@ struct block_device {
78140 int bd_fsfreeze_count;
78141 /* Mutex for freeze */
78142 struct mutex bd_fsfreeze_mutex;
78143 -};
78144 +} __randomize_layout;
78145
78146 /*
78147 * Radix-tree tags, for tagging dirty and writeback pages within the pagecache
78148 @@ -585,7 +585,7 @@ struct inode {
78149 #endif
78150
78151 void *i_private; /* fs or device private pointer */
78152 -};
78153 +} __randomize_layout;
78154
78155 static inline int inode_unhashed(struct inode *inode)
78156 {
78157 @@ -778,7 +778,7 @@ struct file {
78158 struct list_head f_tfile_llink;
78159 #endif /* #ifdef CONFIG_EPOLL */
78160 struct address_space *f_mapping;
78161 -} __attribute__((aligned(4))); /* lest something weird decides that 2 is OK */
78162 +} __attribute__((aligned(4))) __randomize_layout; /* lest something weird decides that 2 is OK */
78163
78164 struct file_handle {
78165 __u32 handle_bytes;
78166 @@ -906,7 +906,7 @@ struct file_lock {
78167 int state; /* state of grant or error if -ve */
78168 } afs;
78169 } fl_u;
78170 -};
78171 +} __randomize_layout;
78172
78173 /* The following constant reflects the upper bound of the file/locking space */
78174 #ifndef OFFSET_MAX
78175 @@ -1255,7 +1255,7 @@ struct super_block {
78176 struct list_lru s_dentry_lru ____cacheline_aligned_in_smp;
78177 struct list_lru s_inode_lru ____cacheline_aligned_in_smp;
78178 struct rcu_head rcu;
78179 -};
78180 +} __randomize_layout;
78181
78182 extern struct timespec current_fs_time(struct super_block *sb);
78183
78184 @@ -1477,7 +1477,8 @@ struct file_operations {
78185 long (*fallocate)(struct file *file, int mode, loff_t offset,
78186 loff_t len);
78187 int (*show_fdinfo)(struct seq_file *m, struct file *f);
78188 -};
78189 +} __do_const __randomize_layout;
78190 +typedef struct file_operations __no_const file_operations_no_const;
78191
78192 struct inode_operations {
78193 struct dentry * (*lookup) (struct inode *,struct dentry *, unsigned int);
78194 @@ -2757,4 +2758,14 @@ static inline bool dir_relax(struct inode *inode)
78195 return !IS_DEADDIR(inode);
78196 }
78197
78198 +static inline bool is_sidechannel_device(const struct inode *inode)
78199 +{
78200 +#ifdef CONFIG_GRKERNSEC_DEVICE_SIDECHANNEL
78201 + umode_t mode = inode->i_mode;
78202 + return ((S_ISCHR(mode) || S_ISBLK(mode)) && (mode & (S_IROTH | S_IWOTH)));
78203 +#else
78204 + return false;
78205 +#endif
78206 +}
78207 +
78208 #endif /* _LINUX_FS_H */
78209 diff --git a/include/linux/fs_struct.h b/include/linux/fs_struct.h
78210 index 0efc3e6..fd23610 100644
78211 --- a/include/linux/fs_struct.h
78212 +++ b/include/linux/fs_struct.h
78213 @@ -6,13 +6,13 @@
78214 #include <linux/seqlock.h>
78215
78216 struct fs_struct {
78217 - int users;
78218 + atomic_t users;
78219 spinlock_t lock;
78220 seqcount_t seq;
78221 int umask;
78222 int in_exec;
78223 struct path root, pwd;
78224 -};
78225 +} __randomize_layout;
78226
78227 extern struct kmem_cache *fs_cachep;
78228
78229 diff --git a/include/linux/fscache-cache.h b/include/linux/fscache-cache.h
78230 index 7714849..a4a5c7a 100644
78231 --- a/include/linux/fscache-cache.h
78232 +++ b/include/linux/fscache-cache.h
78233 @@ -113,7 +113,7 @@ struct fscache_operation {
78234 fscache_operation_release_t release;
78235 };
78236
78237 -extern atomic_t fscache_op_debug_id;
78238 +extern atomic_unchecked_t fscache_op_debug_id;
78239 extern void fscache_op_work_func(struct work_struct *work);
78240
78241 extern void fscache_enqueue_operation(struct fscache_operation *);
78242 @@ -135,7 +135,7 @@ static inline void fscache_operation_init(struct fscache_operation *op,
78243 INIT_WORK(&op->work, fscache_op_work_func);
78244 atomic_set(&op->usage, 1);
78245 op->state = FSCACHE_OP_ST_INITIALISED;
78246 - op->debug_id = atomic_inc_return(&fscache_op_debug_id);
78247 + op->debug_id = atomic_inc_return_unchecked(&fscache_op_debug_id);
78248 op->processor = processor;
78249 op->release = release;
78250 INIT_LIST_HEAD(&op->pend_link);
78251 diff --git a/include/linux/fscache.h b/include/linux/fscache.h
78252 index 115bb81..e7b812b 100644
78253 --- a/include/linux/fscache.h
78254 +++ b/include/linux/fscache.h
78255 @@ -152,7 +152,7 @@ struct fscache_cookie_def {
78256 * - this is mandatory for any object that may have data
78257 */
78258 void (*now_uncached)(void *cookie_netfs_data);
78259 -};
78260 +} __do_const;
78261
78262 /*
78263 * fscache cached network filesystem type
78264 diff --git a/include/linux/fsnotify.h b/include/linux/fsnotify.h
78265 index 1c804b0..1432c2b 100644
78266 --- a/include/linux/fsnotify.h
78267 +++ b/include/linux/fsnotify.h
78268 @@ -195,6 +195,9 @@ static inline void fsnotify_access(struct file *file)
78269 struct inode *inode = file_inode(file);
78270 __u32 mask = FS_ACCESS;
78271
78272 + if (is_sidechannel_device(inode))
78273 + return;
78274 +
78275 if (S_ISDIR(inode->i_mode))
78276 mask |= FS_ISDIR;
78277
78278 @@ -213,6 +216,9 @@ static inline void fsnotify_modify(struct file *file)
78279 struct inode *inode = file_inode(file);
78280 __u32 mask = FS_MODIFY;
78281
78282 + if (is_sidechannel_device(inode))
78283 + return;
78284 +
78285 if (S_ISDIR(inode->i_mode))
78286 mask |= FS_ISDIR;
78287
78288 @@ -315,7 +321,7 @@ static inline void fsnotify_change(struct dentry *dentry, unsigned int ia_valid)
78289 */
78290 static inline const unsigned char *fsnotify_oldname_init(const unsigned char *name)
78291 {
78292 - return kstrdup(name, GFP_KERNEL);
78293 + return (const unsigned char *)kstrdup((const char *)name, GFP_KERNEL);
78294 }
78295
78296 /*
78297 diff --git a/include/linux/genhd.h b/include/linux/genhd.h
78298 index 9f3c275..8bdff5d 100644
78299 --- a/include/linux/genhd.h
78300 +++ b/include/linux/genhd.h
78301 @@ -194,7 +194,7 @@ struct gendisk {
78302 struct kobject *slave_dir;
78303
78304 struct timer_rand_state *random;
78305 - atomic_t sync_io; /* RAID */
78306 + atomic_unchecked_t sync_io; /* RAID */
78307 struct disk_events *ev;
78308 #ifdef CONFIG_BLK_DEV_INTEGRITY
78309 struct blk_integrity *integrity;
78310 @@ -435,7 +435,7 @@ extern void disk_flush_events(struct gendisk *disk, unsigned int mask);
78311 extern unsigned int disk_clear_events(struct gendisk *disk, unsigned int mask);
78312
78313 /* drivers/char/random.c */
78314 -extern void add_disk_randomness(struct gendisk *disk);
78315 +extern void add_disk_randomness(struct gendisk *disk) __latent_entropy;
78316 extern void rand_initialize_disk(struct gendisk *disk);
78317
78318 static inline sector_t get_start_sect(struct block_device *bdev)
78319 diff --git a/include/linux/genl_magic_func.h b/include/linux/genl_magic_func.h
78320 index c0894dd..2fbf10c 100644
78321 --- a/include/linux/genl_magic_func.h
78322 +++ b/include/linux/genl_magic_func.h
78323 @@ -246,7 +246,7 @@ const char *CONCAT_(GENL_MAGIC_FAMILY, _genl_cmd_to_str)(__u8 cmd)
78324 },
78325
78326 #define ZZZ_genl_ops CONCAT_(GENL_MAGIC_FAMILY, _genl_ops)
78327 -static struct genl_ops ZZZ_genl_ops[] __read_mostly = {
78328 +static struct genl_ops ZZZ_genl_ops[] = {
78329 #include GENL_MAGIC_INCLUDE_FILE
78330 };
78331
78332 diff --git a/include/linux/gfp.h b/include/linux/gfp.h
78333 index 39b81dc..819dc51 100644
78334 --- a/include/linux/gfp.h
78335 +++ b/include/linux/gfp.h
78336 @@ -36,6 +36,13 @@ struct vm_area_struct;
78337 #define ___GFP_NO_KSWAPD 0x400000u
78338 #define ___GFP_OTHER_NODE 0x800000u
78339 #define ___GFP_WRITE 0x1000000u
78340 +
78341 +#ifdef CONFIG_PAX_USERCOPY_SLABS
78342 +#define ___GFP_USERCOPY 0x2000000u
78343 +#else
78344 +#define ___GFP_USERCOPY 0
78345 +#endif
78346 +
78347 /* If the above are modified, __GFP_BITS_SHIFT may need updating */
78348
78349 /*
78350 @@ -93,6 +100,7 @@ struct vm_area_struct;
78351 #define __GFP_OTHER_NODE ((__force gfp_t)___GFP_OTHER_NODE) /* On behalf of other node */
78352 #define __GFP_KMEMCG ((__force gfp_t)___GFP_KMEMCG) /* Allocation comes from a memcg-accounted resource */
78353 #define __GFP_WRITE ((__force gfp_t)___GFP_WRITE) /* Allocator intends to dirty page */
78354 +#define __GFP_USERCOPY ((__force gfp_t)___GFP_USERCOPY)/* Allocator intends to copy page to/from userland */
78355
78356 /*
78357 * This may seem redundant, but it's a way of annotating false positives vs.
78358 @@ -100,7 +108,7 @@ struct vm_area_struct;
78359 */
78360 #define __GFP_NOTRACK_FALSE_POSITIVE (__GFP_NOTRACK)
78361
78362 -#define __GFP_BITS_SHIFT 25 /* Room for N __GFP_FOO bits */
78363 +#define __GFP_BITS_SHIFT 26 /* Room for N __GFP_FOO bits */
78364 #define __GFP_BITS_MASK ((__force gfp_t)((1 << __GFP_BITS_SHIFT) - 1))
78365
78366 /* This equals 0, but use constants in case they ever change */
78367 @@ -158,6 +166,8 @@ struct vm_area_struct;
78368 /* 4GB DMA on some platforms */
78369 #define GFP_DMA32 __GFP_DMA32
78370
78371 +#define GFP_USERCOPY __GFP_USERCOPY
78372 +
78373 /* Convert GFP flags to their corresponding migrate type */
78374 static inline int allocflags_to_migratetype(gfp_t gfp_flags)
78375 {
78376 diff --git a/include/linux/gracl.h b/include/linux/gracl.h
78377 new file mode 100644
78378 index 0000000..edb2cb6
78379 --- /dev/null
78380 +++ b/include/linux/gracl.h
78381 @@ -0,0 +1,340 @@
78382 +#ifndef GR_ACL_H
78383 +#define GR_ACL_H
78384 +
78385 +#include <linux/grdefs.h>
78386 +#include <linux/resource.h>
78387 +#include <linux/capability.h>
78388 +#include <linux/dcache.h>
78389 +#include <asm/resource.h>
78390 +
78391 +/* Major status information */
78392 +
78393 +#define GR_VERSION "grsecurity 3.0"
78394 +#define GRSECURITY_VERSION 0x3000
78395 +
78396 +enum {
78397 + GR_SHUTDOWN = 0,
78398 + GR_ENABLE = 1,
78399 + GR_SPROLE = 2,
78400 + GR_OLDRELOAD = 3,
78401 + GR_SEGVMOD = 4,
78402 + GR_STATUS = 5,
78403 + GR_UNSPROLE = 6,
78404 + GR_PASSSET = 7,
78405 + GR_SPROLEPAM = 8,
78406 + GR_RELOAD = 9,
78407 +};
78408 +
78409 +/* Password setup definitions
78410 + * kernel/grhash.c */
78411 +enum {
78412 + GR_PW_LEN = 128,
78413 + GR_SALT_LEN = 16,
78414 + GR_SHA_LEN = 32,
78415 +};
78416 +
78417 +enum {
78418 + GR_SPROLE_LEN = 64,
78419 +};
78420 +
78421 +enum {
78422 + GR_NO_GLOB = 0,
78423 + GR_REG_GLOB,
78424 + GR_CREATE_GLOB
78425 +};
78426 +
78427 +#define GR_NLIMITS 32
78428 +
78429 +/* Begin Data Structures */
78430 +
78431 +struct sprole_pw {
78432 + unsigned char *rolename;
78433 + unsigned char salt[GR_SALT_LEN];
78434 + unsigned char sum[GR_SHA_LEN]; /* 256-bit SHA hash of the password */
78435 +};
78436 +
78437 +struct name_entry {
78438 + __u32 key;
78439 + ino_t inode;
78440 + dev_t device;
78441 + char *name;
78442 + __u16 len;
78443 + __u8 deleted;
78444 + struct name_entry *prev;
78445 + struct name_entry *next;
78446 +};
78447 +
78448 +struct inodev_entry {
78449 + struct name_entry *nentry;
78450 + struct inodev_entry *prev;
78451 + struct inodev_entry *next;
78452 +};
78453 +
78454 +struct acl_role_db {
78455 + struct acl_role_label **r_hash;
78456 + __u32 r_size;
78457 +};
78458 +
78459 +struct inodev_db {
78460 + struct inodev_entry **i_hash;
78461 + __u32 i_size;
78462 +};
78463 +
78464 +struct name_db {
78465 + struct name_entry **n_hash;
78466 + __u32 n_size;
78467 +};
78468 +
78469 +struct crash_uid {
78470 + uid_t uid;
78471 + unsigned long expires;
78472 +};
78473 +
78474 +struct gr_hash_struct {
78475 + void **table;
78476 + void **nametable;
78477 + void *first;
78478 + __u32 table_size;
78479 + __u32 used_size;
78480 + int type;
78481 +};
78482 +
78483 +/* Userspace Grsecurity ACL data structures */
78484 +
78485 +struct acl_subject_label {
78486 + char *filename;
78487 + ino_t inode;
78488 + dev_t device;
78489 + __u32 mode;
78490 + kernel_cap_t cap_mask;
78491 + kernel_cap_t cap_lower;
78492 + kernel_cap_t cap_invert_audit;
78493 +
78494 + struct rlimit res[GR_NLIMITS];
78495 + __u32 resmask;
78496 +
78497 + __u8 user_trans_type;
78498 + __u8 group_trans_type;
78499 + uid_t *user_transitions;
78500 + gid_t *group_transitions;
78501 + __u16 user_trans_num;
78502 + __u16 group_trans_num;
78503 +
78504 + __u32 sock_families[2];
78505 + __u32 ip_proto[8];
78506 + __u32 ip_type;
78507 + struct acl_ip_label **ips;
78508 + __u32 ip_num;
78509 + __u32 inaddr_any_override;
78510 +
78511 + __u32 crashes;
78512 + unsigned long expires;
78513 +
78514 + struct acl_subject_label *parent_subject;
78515 + struct gr_hash_struct *hash;
78516 + struct acl_subject_label *prev;
78517 + struct acl_subject_label *next;
78518 +
78519 + struct acl_object_label **obj_hash;
78520 + __u32 obj_hash_size;
78521 + __u16 pax_flags;
78522 +};
78523 +
78524 +struct role_allowed_ip {
78525 + __u32 addr;
78526 + __u32 netmask;
78527 +
78528 + struct role_allowed_ip *prev;
78529 + struct role_allowed_ip *next;
78530 +};
78531 +
78532 +struct role_transition {
78533 + char *rolename;
78534 +
78535 + struct role_transition *prev;
78536 + struct role_transition *next;
78537 +};
78538 +
78539 +struct acl_role_label {
78540 + char *rolename;
78541 + uid_t uidgid;
78542 + __u16 roletype;
78543 +
78544 + __u16 auth_attempts;
78545 + unsigned long expires;
78546 +
78547 + struct acl_subject_label *root_label;
78548 + struct gr_hash_struct *hash;
78549 +
78550 + struct acl_role_label *prev;
78551 + struct acl_role_label *next;
78552 +
78553 + struct role_transition *transitions;
78554 + struct role_allowed_ip *allowed_ips;
78555 + uid_t *domain_children;
78556 + __u16 domain_child_num;
78557 +
78558 + umode_t umask;
78559 +
78560 + struct acl_subject_label **subj_hash;
78561 + __u32 subj_hash_size;
78562 +};
78563 +
78564 +struct user_acl_role_db {
78565 + struct acl_role_label **r_table;
78566 + __u32 num_pointers; /* Number of allocations to track */
78567 + __u32 num_roles; /* Number of roles */
78568 + __u32 num_domain_children; /* Number of domain children */
78569 + __u32 num_subjects; /* Number of subjects */
78570 + __u32 num_objects; /* Number of objects */
78571 +};
78572 +
78573 +struct acl_object_label {
78574 + char *filename;
78575 + ino_t inode;
78576 + dev_t device;
78577 + __u32 mode;
78578 +
78579 + struct acl_subject_label *nested;
78580 + struct acl_object_label *globbed;
78581 +
78582 + /* next two structures not used */
78583 +
78584 + struct acl_object_label *prev;
78585 + struct acl_object_label *next;
78586 +};
78587 +
78588 +struct acl_ip_label {
78589 + char *iface;
78590 + __u32 addr;
78591 + __u32 netmask;
78592 + __u16 low, high;
78593 + __u8 mode;
78594 + __u32 type;
78595 + __u32 proto[8];
78596 +
78597 + /* next two structures not used */
78598 +
78599 + struct acl_ip_label *prev;
78600 + struct acl_ip_label *next;
78601 +};
78602 +
78603 +struct gr_arg {
78604 + struct user_acl_role_db role_db;
78605 + unsigned char pw[GR_PW_LEN];
78606 + unsigned char salt[GR_SALT_LEN];
78607 + unsigned char sum[GR_SHA_LEN];
78608 + unsigned char sp_role[GR_SPROLE_LEN];
78609 + struct sprole_pw *sprole_pws;
78610 + dev_t segv_device;
78611 + ino_t segv_inode;
78612 + uid_t segv_uid;
78613 + __u16 num_sprole_pws;
78614 + __u16 mode;
78615 +};
78616 +
78617 +struct gr_arg_wrapper {
78618 + struct gr_arg *arg;
78619 + __u32 version;
78620 + __u32 size;
78621 +};
78622 +
78623 +struct subject_map {
78624 + struct acl_subject_label *user;
78625 + struct acl_subject_label *kernel;
78626 + struct subject_map *prev;
78627 + struct subject_map *next;
78628 +};
78629 +
78630 +struct acl_subj_map_db {
78631 + struct subject_map **s_hash;
78632 + __u32 s_size;
78633 +};
78634 +
78635 +struct gr_policy_state {
78636 + struct sprole_pw **acl_special_roles;
78637 + __u16 num_sprole_pws;
78638 + struct acl_role_label *kernel_role;
78639 + struct acl_role_label *role_list;
78640 + struct acl_role_label *default_role;
78641 + struct acl_role_db acl_role_set;
78642 + struct acl_subj_map_db subj_map_set;
78643 + struct name_db name_set;
78644 + struct inodev_db inodev_set;
78645 +};
78646 +
78647 +struct gr_alloc_state {
78648 + unsigned long alloc_stack_next;
78649 + unsigned long alloc_stack_size;
78650 + void **alloc_stack;
78651 +};
78652 +
78653 +struct gr_reload_state {
78654 + struct gr_policy_state oldpolicy;
78655 + struct gr_alloc_state oldalloc;
78656 + struct gr_policy_state newpolicy;
78657 + struct gr_alloc_state newalloc;
78658 + struct gr_policy_state *oldpolicy_ptr;
78659 + struct gr_alloc_state *oldalloc_ptr;
78660 + unsigned char oldmode;
78661 +};
78662 +
78663 +/* End Data Structures Section */
78664 +
78665 +/* Hash functions generated by empirical testing by Brad Spengler
78666 + Makes good use of the low bits of the inode. Generally 0-1 times
78667 + in loop for successful match. 0-3 for unsuccessful match.
78668 + Shift/add algorithm with modulus of table size and an XOR*/
78669 +
78670 +static __inline__ unsigned int
78671 +gr_rhash(const uid_t uid, const __u16 type, const unsigned int sz)
78672 +{
78673 + return ((((uid + type) << (16 + type)) ^ uid) % sz);
78674 +}
78675 +
78676 + static __inline__ unsigned int
78677 +gr_shash(const struct acl_subject_label *userp, const unsigned int sz)
78678 +{
78679 + return ((const unsigned long)userp % sz);
78680 +}
78681 +
78682 +static __inline__ unsigned int
78683 +gr_fhash(const ino_t ino, const dev_t dev, const unsigned int sz)
78684 +{
78685 + return (((ino + dev) ^ ((ino << 13) + (ino << 23) + (dev << 9))) % sz);
78686 +}
78687 +
78688 +static __inline__ unsigned int
78689 +gr_nhash(const char *name, const __u16 len, const unsigned int sz)
78690 +{
78691 + return full_name_hash((const unsigned char *)name, len) % sz;
78692 +}
78693 +
78694 +#define FOR_EACH_SUBJECT_START(role,subj,iter) \
78695 + subj = NULL; \
78696 + iter = 0; \
78697 + while (iter < role->subj_hash_size) { \
78698 + if (subj == NULL) \
78699 + subj = role->subj_hash[iter]; \
78700 + if (subj == NULL) { \
78701 + iter++; \
78702 + continue; \
78703 + }
78704 +
78705 +#define FOR_EACH_SUBJECT_END(subj,iter) \
78706 + subj = subj->next; \
78707 + if (subj == NULL) \
78708 + iter++; \
78709 + }
78710 +
78711 +
78712 +#define FOR_EACH_NESTED_SUBJECT_START(role,subj) \
78713 + subj = role->hash->first; \
78714 + while (subj != NULL) {
78715 +
78716 +#define FOR_EACH_NESTED_SUBJECT_END(subj) \
78717 + subj = subj->next; \
78718 + }
78719 +
78720 +#endif
78721 +
78722 diff --git a/include/linux/gracl_compat.h b/include/linux/gracl_compat.h
78723 new file mode 100644
78724 index 0000000..33ebd1f
78725 --- /dev/null
78726 +++ b/include/linux/gracl_compat.h
78727 @@ -0,0 +1,156 @@
78728 +#ifndef GR_ACL_COMPAT_H
78729 +#define GR_ACL_COMPAT_H
78730 +
78731 +#include <linux/resource.h>
78732 +#include <asm/resource.h>
78733 +
78734 +struct sprole_pw_compat {
78735 + compat_uptr_t rolename;
78736 + unsigned char salt[GR_SALT_LEN];
78737 + unsigned char sum[GR_SHA_LEN];
78738 +};
78739 +
78740 +struct gr_hash_struct_compat {
78741 + compat_uptr_t table;
78742 + compat_uptr_t nametable;
78743 + compat_uptr_t first;
78744 + __u32 table_size;
78745 + __u32 used_size;
78746 + int type;
78747 +};
78748 +
78749 +struct acl_subject_label_compat {
78750 + compat_uptr_t filename;
78751 + compat_ino_t inode;
78752 + __u32 device;
78753 + __u32 mode;
78754 + kernel_cap_t cap_mask;
78755 + kernel_cap_t cap_lower;
78756 + kernel_cap_t cap_invert_audit;
78757 +
78758 + struct compat_rlimit res[GR_NLIMITS];
78759 + __u32 resmask;
78760 +
78761 + __u8 user_trans_type;
78762 + __u8 group_trans_type;
78763 + compat_uptr_t user_transitions;
78764 + compat_uptr_t group_transitions;
78765 + __u16 user_trans_num;
78766 + __u16 group_trans_num;
78767 +
78768 + __u32 sock_families[2];
78769 + __u32 ip_proto[8];
78770 + __u32 ip_type;
78771 + compat_uptr_t ips;
78772 + __u32 ip_num;
78773 + __u32 inaddr_any_override;
78774 +
78775 + __u32 crashes;
78776 + compat_ulong_t expires;
78777 +
78778 + compat_uptr_t parent_subject;
78779 + compat_uptr_t hash;
78780 + compat_uptr_t prev;
78781 + compat_uptr_t next;
78782 +
78783 + compat_uptr_t obj_hash;
78784 + __u32 obj_hash_size;
78785 + __u16 pax_flags;
78786 +};
78787 +
78788 +struct role_allowed_ip_compat {
78789 + __u32 addr;
78790 + __u32 netmask;
78791 +
78792 + compat_uptr_t prev;
78793 + compat_uptr_t next;
78794 +};
78795 +
78796 +struct role_transition_compat {
78797 + compat_uptr_t rolename;
78798 +
78799 + compat_uptr_t prev;
78800 + compat_uptr_t next;
78801 +};
78802 +
78803 +struct acl_role_label_compat {
78804 + compat_uptr_t rolename;
78805 + uid_t uidgid;
78806 + __u16 roletype;
78807 +
78808 + __u16 auth_attempts;
78809 + compat_ulong_t expires;
78810 +
78811 + compat_uptr_t root_label;
78812 + compat_uptr_t hash;
78813 +
78814 + compat_uptr_t prev;
78815 + compat_uptr_t next;
78816 +
78817 + compat_uptr_t transitions;
78818 + compat_uptr_t allowed_ips;
78819 + compat_uptr_t domain_children;
78820 + __u16 domain_child_num;
78821 +
78822 + umode_t umask;
78823 +
78824 + compat_uptr_t subj_hash;
78825 + __u32 subj_hash_size;
78826 +};
78827 +
78828 +struct user_acl_role_db_compat {
78829 + compat_uptr_t r_table;
78830 + __u32 num_pointers;
78831 + __u32 num_roles;
78832 + __u32 num_domain_children;
78833 + __u32 num_subjects;
78834 + __u32 num_objects;
78835 +};
78836 +
78837 +struct acl_object_label_compat {
78838 + compat_uptr_t filename;
78839 + compat_ino_t inode;
78840 + __u32 device;
78841 + __u32 mode;
78842 +
78843 + compat_uptr_t nested;
78844 + compat_uptr_t globbed;
78845 +
78846 + compat_uptr_t prev;
78847 + compat_uptr_t next;
78848 +};
78849 +
78850 +struct acl_ip_label_compat {
78851 + compat_uptr_t iface;
78852 + __u32 addr;
78853 + __u32 netmask;
78854 + __u16 low, high;
78855 + __u8 mode;
78856 + __u32 type;
78857 + __u32 proto[8];
78858 +
78859 + compat_uptr_t prev;
78860 + compat_uptr_t next;
78861 +};
78862 +
78863 +struct gr_arg_compat {
78864 + struct user_acl_role_db_compat role_db;
78865 + unsigned char pw[GR_PW_LEN];
78866 + unsigned char salt[GR_SALT_LEN];
78867 + unsigned char sum[GR_SHA_LEN];
78868 + unsigned char sp_role[GR_SPROLE_LEN];
78869 + compat_uptr_t sprole_pws;
78870 + __u32 segv_device;
78871 + compat_ino_t segv_inode;
78872 + uid_t segv_uid;
78873 + __u16 num_sprole_pws;
78874 + __u16 mode;
78875 +};
78876 +
78877 +struct gr_arg_wrapper_compat {
78878 + compat_uptr_t arg;
78879 + __u32 version;
78880 + __u32 size;
78881 +};
78882 +
78883 +#endif
78884 diff --git a/include/linux/gralloc.h b/include/linux/gralloc.h
78885 new file mode 100644
78886 index 0000000..323ecf2
78887 --- /dev/null
78888 +++ b/include/linux/gralloc.h
78889 @@ -0,0 +1,9 @@
78890 +#ifndef __GRALLOC_H
78891 +#define __GRALLOC_H
78892 +
78893 +void acl_free_all(void);
78894 +int acl_alloc_stack_init(unsigned long size);
78895 +void *acl_alloc(unsigned long len);
78896 +void *acl_alloc_num(unsigned long num, unsigned long len);
78897 +
78898 +#endif
78899 diff --git a/include/linux/grdefs.h b/include/linux/grdefs.h
78900 new file mode 100644
78901 index 0000000..be66033
78902 --- /dev/null
78903 +++ b/include/linux/grdefs.h
78904 @@ -0,0 +1,140 @@
78905 +#ifndef GRDEFS_H
78906 +#define GRDEFS_H
78907 +
78908 +/* Begin grsecurity status declarations */
78909 +
78910 +enum {
78911 + GR_READY = 0x01,
78912 + GR_STATUS_INIT = 0x00 // disabled state
78913 +};
78914 +
78915 +/* Begin ACL declarations */
78916 +
78917 +/* Role flags */
78918 +
78919 +enum {
78920 + GR_ROLE_USER = 0x0001,
78921 + GR_ROLE_GROUP = 0x0002,
78922 + GR_ROLE_DEFAULT = 0x0004,
78923 + GR_ROLE_SPECIAL = 0x0008,
78924 + GR_ROLE_AUTH = 0x0010,
78925 + GR_ROLE_NOPW = 0x0020,
78926 + GR_ROLE_GOD = 0x0040,
78927 + GR_ROLE_LEARN = 0x0080,
78928 + GR_ROLE_TPE = 0x0100,
78929 + GR_ROLE_DOMAIN = 0x0200,
78930 + GR_ROLE_PAM = 0x0400,
78931 + GR_ROLE_PERSIST = 0x0800
78932 +};
78933 +
78934 +/* ACL Subject and Object mode flags */
78935 +enum {
78936 + GR_DELETED = 0x80000000
78937 +};
78938 +
78939 +/* ACL Object-only mode flags */
78940 +enum {
78941 + GR_READ = 0x00000001,
78942 + GR_APPEND = 0x00000002,
78943 + GR_WRITE = 0x00000004,
78944 + GR_EXEC = 0x00000008,
78945 + GR_FIND = 0x00000010,
78946 + GR_INHERIT = 0x00000020,
78947 + GR_SETID = 0x00000040,
78948 + GR_CREATE = 0x00000080,
78949 + GR_DELETE = 0x00000100,
78950 + GR_LINK = 0x00000200,
78951 + GR_AUDIT_READ = 0x00000400,
78952 + GR_AUDIT_APPEND = 0x00000800,
78953 + GR_AUDIT_WRITE = 0x00001000,
78954 + GR_AUDIT_EXEC = 0x00002000,
78955 + GR_AUDIT_FIND = 0x00004000,
78956 + GR_AUDIT_INHERIT= 0x00008000,
78957 + GR_AUDIT_SETID = 0x00010000,
78958 + GR_AUDIT_CREATE = 0x00020000,
78959 + GR_AUDIT_DELETE = 0x00040000,
78960 + GR_AUDIT_LINK = 0x00080000,
78961 + GR_PTRACERD = 0x00100000,
78962 + GR_NOPTRACE = 0x00200000,
78963 + GR_SUPPRESS = 0x00400000,
78964 + GR_NOLEARN = 0x00800000,
78965 + GR_INIT_TRANSFER= 0x01000000
78966 +};
78967 +
78968 +#define GR_AUDITS (GR_AUDIT_READ | GR_AUDIT_WRITE | GR_AUDIT_APPEND | GR_AUDIT_EXEC | \
78969 + GR_AUDIT_FIND | GR_AUDIT_INHERIT | GR_AUDIT_SETID | \
78970 + GR_AUDIT_CREATE | GR_AUDIT_DELETE | GR_AUDIT_LINK)
78971 +
78972 +/* ACL subject-only mode flags */
78973 +enum {
78974 + GR_KILL = 0x00000001,
78975 + GR_VIEW = 0x00000002,
78976 + GR_PROTECTED = 0x00000004,
78977 + GR_LEARN = 0x00000008,
78978 + GR_OVERRIDE = 0x00000010,
78979 + /* just a placeholder, this mode is only used in userspace */
78980 + GR_DUMMY = 0x00000020,
78981 + GR_PROTSHM = 0x00000040,
78982 + GR_KILLPROC = 0x00000080,
78983 + GR_KILLIPPROC = 0x00000100,
78984 + /* just a placeholder, this mode is only used in userspace */
78985 + GR_NOTROJAN = 0x00000200,
78986 + GR_PROTPROCFD = 0x00000400,
78987 + GR_PROCACCT = 0x00000800,
78988 + GR_RELAXPTRACE = 0x00001000,
78989 + //GR_NESTED = 0x00002000,
78990 + GR_INHERITLEARN = 0x00004000,
78991 + GR_PROCFIND = 0x00008000,
78992 + GR_POVERRIDE = 0x00010000,
78993 + GR_KERNELAUTH = 0x00020000,
78994 + GR_ATSECURE = 0x00040000,
78995 + GR_SHMEXEC = 0x00080000
78996 +};
78997 +
78998 +enum {
78999 + GR_PAX_ENABLE_SEGMEXEC = 0x0001,
79000 + GR_PAX_ENABLE_PAGEEXEC = 0x0002,
79001 + GR_PAX_ENABLE_MPROTECT = 0x0004,
79002 + GR_PAX_ENABLE_RANDMMAP = 0x0008,
79003 + GR_PAX_ENABLE_EMUTRAMP = 0x0010,
79004 + GR_PAX_DISABLE_SEGMEXEC = 0x0100,
79005 + GR_PAX_DISABLE_PAGEEXEC = 0x0200,
79006 + GR_PAX_DISABLE_MPROTECT = 0x0400,
79007 + GR_PAX_DISABLE_RANDMMAP = 0x0800,
79008 + GR_PAX_DISABLE_EMUTRAMP = 0x1000,
79009 +};
79010 +
79011 +enum {
79012 + GR_ID_USER = 0x01,
79013 + GR_ID_GROUP = 0x02,
79014 +};
79015 +
79016 +enum {
79017 + GR_ID_ALLOW = 0x01,
79018 + GR_ID_DENY = 0x02,
79019 +};
79020 +
79021 +#define GR_CRASH_RES 31
79022 +#define GR_UIDTABLE_MAX 500
79023 +
79024 +/* begin resource learning section */
79025 +enum {
79026 + GR_RLIM_CPU_BUMP = 60,
79027 + GR_RLIM_FSIZE_BUMP = 50000,
79028 + GR_RLIM_DATA_BUMP = 10000,
79029 + GR_RLIM_STACK_BUMP = 1000,
79030 + GR_RLIM_CORE_BUMP = 10000,
79031 + GR_RLIM_RSS_BUMP = 500000,
79032 + GR_RLIM_NPROC_BUMP = 1,
79033 + GR_RLIM_NOFILE_BUMP = 5,
79034 + GR_RLIM_MEMLOCK_BUMP = 50000,
79035 + GR_RLIM_AS_BUMP = 500000,
79036 + GR_RLIM_LOCKS_BUMP = 2,
79037 + GR_RLIM_SIGPENDING_BUMP = 5,
79038 + GR_RLIM_MSGQUEUE_BUMP = 10000,
79039 + GR_RLIM_NICE_BUMP = 1,
79040 + GR_RLIM_RTPRIO_BUMP = 1,
79041 + GR_RLIM_RTTIME_BUMP = 1000000
79042 +};
79043 +
79044 +#endif
79045 diff --git a/include/linux/grinternal.h b/include/linux/grinternal.h
79046 new file mode 100644
79047 index 0000000..d25522e
79048 --- /dev/null
79049 +++ b/include/linux/grinternal.h
79050 @@ -0,0 +1,229 @@
79051 +#ifndef __GRINTERNAL_H
79052 +#define __GRINTERNAL_H
79053 +
79054 +#ifdef CONFIG_GRKERNSEC
79055 +
79056 +#include <linux/fs.h>
79057 +#include <linux/mnt_namespace.h>
79058 +#include <linux/nsproxy.h>
79059 +#include <linux/gracl.h>
79060 +#include <linux/grdefs.h>
79061 +#include <linux/grmsg.h>
79062 +
79063 +void gr_add_learn_entry(const char *fmt, ...)
79064 + __attribute__ ((format (printf, 1, 2)));
79065 +__u32 gr_search_file(const struct dentry *dentry, const __u32 mode,
79066 + const struct vfsmount *mnt);
79067 +__u32 gr_check_create(const struct dentry *new_dentry,
79068 + const struct dentry *parent,
79069 + const struct vfsmount *mnt, const __u32 mode);
79070 +int gr_check_protected_task(const struct task_struct *task);
79071 +__u32 to_gr_audit(const __u32 reqmode);
79072 +int gr_set_acls(const int type);
79073 +int gr_acl_is_enabled(void);
79074 +char gr_roletype_to_char(void);
79075 +
79076 +void gr_handle_alertkill(struct task_struct *task);
79077 +char *gr_to_filename(const struct dentry *dentry,
79078 + const struct vfsmount *mnt);
79079 +char *gr_to_filename1(const struct dentry *dentry,
79080 + const struct vfsmount *mnt);
79081 +char *gr_to_filename2(const struct dentry *dentry,
79082 + const struct vfsmount *mnt);
79083 +char *gr_to_filename3(const struct dentry *dentry,
79084 + const struct vfsmount *mnt);
79085 +
79086 +extern int grsec_enable_ptrace_readexec;
79087 +extern int grsec_enable_harden_ptrace;
79088 +extern int grsec_enable_link;
79089 +extern int grsec_enable_fifo;
79090 +extern int grsec_enable_execve;
79091 +extern int grsec_enable_shm;
79092 +extern int grsec_enable_execlog;
79093 +extern int grsec_enable_signal;
79094 +extern int grsec_enable_audit_ptrace;
79095 +extern int grsec_enable_forkfail;
79096 +extern int grsec_enable_time;
79097 +extern int grsec_enable_rofs;
79098 +extern int grsec_deny_new_usb;
79099 +extern int grsec_enable_chroot_shmat;
79100 +extern int grsec_enable_chroot_mount;
79101 +extern int grsec_enable_chroot_double;
79102 +extern int grsec_enable_chroot_pivot;
79103 +extern int grsec_enable_chroot_chdir;
79104 +extern int grsec_enable_chroot_chmod;
79105 +extern int grsec_enable_chroot_mknod;
79106 +extern int grsec_enable_chroot_fchdir;
79107 +extern int grsec_enable_chroot_nice;
79108 +extern int grsec_enable_chroot_execlog;
79109 +extern int grsec_enable_chroot_caps;
79110 +extern int grsec_enable_chroot_sysctl;
79111 +extern int grsec_enable_chroot_unix;
79112 +extern int grsec_enable_symlinkown;
79113 +extern kgid_t grsec_symlinkown_gid;
79114 +extern int grsec_enable_tpe;
79115 +extern kgid_t grsec_tpe_gid;
79116 +extern int grsec_enable_tpe_all;
79117 +extern int grsec_enable_tpe_invert;
79118 +extern int grsec_enable_socket_all;
79119 +extern kgid_t grsec_socket_all_gid;
79120 +extern int grsec_enable_socket_client;
79121 +extern kgid_t grsec_socket_client_gid;
79122 +extern int grsec_enable_socket_server;
79123 +extern kgid_t grsec_socket_server_gid;
79124 +extern kgid_t grsec_audit_gid;
79125 +extern int grsec_enable_group;
79126 +extern int grsec_enable_log_rwxmaps;
79127 +extern int grsec_enable_mount;
79128 +extern int grsec_enable_chdir;
79129 +extern int grsec_resource_logging;
79130 +extern int grsec_enable_blackhole;
79131 +extern int grsec_lastack_retries;
79132 +extern int grsec_enable_brute;
79133 +extern int grsec_enable_harden_ipc;
79134 +extern int grsec_lock;
79135 +
79136 +extern spinlock_t grsec_alert_lock;
79137 +extern unsigned long grsec_alert_wtime;
79138 +extern unsigned long grsec_alert_fyet;
79139 +
79140 +extern spinlock_t grsec_audit_lock;
79141 +
79142 +extern rwlock_t grsec_exec_file_lock;
79143 +
79144 +#define gr_task_fullpath(tsk) ((tsk)->exec_file ? \
79145 + gr_to_filename2((tsk)->exec_file->f_path.dentry, \
79146 + (tsk)->exec_file->f_path.mnt) : "/")
79147 +
79148 +#define gr_parent_task_fullpath(tsk) ((tsk)->real_parent->exec_file ? \
79149 + gr_to_filename3((tsk)->real_parent->exec_file->f_path.dentry, \
79150 + (tsk)->real_parent->exec_file->f_path.mnt) : "/")
79151 +
79152 +#define gr_task_fullpath0(tsk) ((tsk)->exec_file ? \
79153 + gr_to_filename((tsk)->exec_file->f_path.dentry, \
79154 + (tsk)->exec_file->f_path.mnt) : "/")
79155 +
79156 +#define gr_parent_task_fullpath0(tsk) ((tsk)->real_parent->exec_file ? \
79157 + gr_to_filename1((tsk)->real_parent->exec_file->f_path.dentry, \
79158 + (tsk)->real_parent->exec_file->f_path.mnt) : "/")
79159 +
79160 +#define proc_is_chrooted(tsk_a) ((tsk_a)->gr_is_chrooted)
79161 +
79162 +#define have_same_root(tsk_a,tsk_b) ((tsk_a)->gr_chroot_dentry == (tsk_b)->gr_chroot_dentry)
79163 +
79164 +static inline bool gr_is_same_file(const struct file *file1, const struct file *file2)
79165 +{
79166 + if (file1 && file2) {
79167 + const struct inode *inode1 = file1->f_path.dentry->d_inode;
79168 + const struct inode *inode2 = file2->f_path.dentry->d_inode;
79169 + if (inode1->i_ino == inode2->i_ino && inode1->i_sb->s_dev == inode2->i_sb->s_dev)
79170 + return true;
79171 + }
79172 +
79173 + return false;
79174 +}
79175 +
79176 +#define GR_CHROOT_CAPS {{ \
79177 + CAP_TO_MASK(CAP_LINUX_IMMUTABLE) | CAP_TO_MASK(CAP_NET_ADMIN) | \
79178 + CAP_TO_MASK(CAP_SYS_MODULE) | CAP_TO_MASK(CAP_SYS_RAWIO) | \
79179 + CAP_TO_MASK(CAP_SYS_PACCT) | CAP_TO_MASK(CAP_SYS_ADMIN) | \
79180 + CAP_TO_MASK(CAP_SYS_BOOT) | CAP_TO_MASK(CAP_SYS_TIME) | \
79181 + CAP_TO_MASK(CAP_NET_RAW) | CAP_TO_MASK(CAP_SYS_TTY_CONFIG) | \
79182 + CAP_TO_MASK(CAP_IPC_OWNER) | CAP_TO_MASK(CAP_SETFCAP), \
79183 + CAP_TO_MASK(CAP_SYSLOG) | CAP_TO_MASK(CAP_MAC_ADMIN) }}
79184 +
79185 +#define security_learn(normal_msg,args...) \
79186 +({ \
79187 + read_lock(&grsec_exec_file_lock); \
79188 + gr_add_learn_entry(normal_msg "\n", ## args); \
79189 + read_unlock(&grsec_exec_file_lock); \
79190 +})
79191 +
79192 +enum {
79193 + GR_DO_AUDIT,
79194 + GR_DONT_AUDIT,
79195 + /* used for non-audit messages that we shouldn't kill the task on */
79196 + GR_DONT_AUDIT_GOOD
79197 +};
79198 +
79199 +enum {
79200 + GR_TTYSNIFF,
79201 + GR_RBAC,
79202 + GR_RBAC_STR,
79203 + GR_STR_RBAC,
79204 + GR_RBAC_MODE2,
79205 + GR_RBAC_MODE3,
79206 + GR_FILENAME,
79207 + GR_SYSCTL_HIDDEN,
79208 + GR_NOARGS,
79209 + GR_ONE_INT,
79210 + GR_ONE_INT_TWO_STR,
79211 + GR_ONE_STR,
79212 + GR_STR_INT,
79213 + GR_TWO_STR_INT,
79214 + GR_TWO_INT,
79215 + GR_TWO_U64,
79216 + GR_THREE_INT,
79217 + GR_FIVE_INT_TWO_STR,
79218 + GR_TWO_STR,
79219 + GR_THREE_STR,
79220 + GR_FOUR_STR,
79221 + GR_STR_FILENAME,
79222 + GR_FILENAME_STR,
79223 + GR_FILENAME_TWO_INT,
79224 + GR_FILENAME_TWO_INT_STR,
79225 + GR_TEXTREL,
79226 + GR_PTRACE,
79227 + GR_RESOURCE,
79228 + GR_CAP,
79229 + GR_SIG,
79230 + GR_SIG2,
79231 + GR_CRASH1,
79232 + GR_CRASH2,
79233 + GR_PSACCT,
79234 + GR_RWXMAP,
79235 + GR_RWXMAPVMA
79236 +};
79237 +
79238 +#define gr_log_hidden_sysctl(audit, msg, str) gr_log_varargs(audit, msg, GR_SYSCTL_HIDDEN, str)
79239 +#define gr_log_ttysniff(audit, msg, task) gr_log_varargs(audit, msg, GR_TTYSNIFF, task)
79240 +#define gr_log_fs_rbac_generic(audit, msg, dentry, mnt) gr_log_varargs(audit, msg, GR_RBAC, dentry, mnt)
79241 +#define gr_log_fs_rbac_str(audit, msg, dentry, mnt, str) gr_log_varargs(audit, msg, GR_RBAC_STR, dentry, mnt, str)
79242 +#define gr_log_fs_str_rbac(audit, msg, str, dentry, mnt) gr_log_varargs(audit, msg, GR_STR_RBAC, str, dentry, mnt)
79243 +#define gr_log_fs_rbac_mode2(audit, msg, dentry, mnt, str1, str2) gr_log_varargs(audit, msg, GR_RBAC_MODE2, dentry, mnt, str1, str2)
79244 +#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)
79245 +#define gr_log_fs_generic(audit, msg, dentry, mnt) gr_log_varargs(audit, msg, GR_FILENAME, dentry, mnt)
79246 +#define gr_log_noargs(audit, msg) gr_log_varargs(audit, msg, GR_NOARGS)
79247 +#define gr_log_int(audit, msg, num) gr_log_varargs(audit, msg, GR_ONE_INT, num)
79248 +#define gr_log_int_str2(audit, msg, num, str1, str2) gr_log_varargs(audit, msg, GR_ONE_INT_TWO_STR, num, str1, str2)
79249 +#define gr_log_str(audit, msg, str) gr_log_varargs(audit, msg, GR_ONE_STR, str)
79250 +#define gr_log_str_int(audit, msg, str, num) gr_log_varargs(audit, msg, GR_STR_INT, str, num)
79251 +#define gr_log_int_int(audit, msg, num1, num2) gr_log_varargs(audit, msg, GR_TWO_INT, num1, num2)
79252 +#define gr_log_two_u64(audit, msg, num1, num2) gr_log_varargs(audit, msg, GR_TWO_U64, num1, num2)
79253 +#define gr_log_int3(audit, msg, num1, num2, num3) gr_log_varargs(audit, msg, GR_THREE_INT, num1, num2, num3)
79254 +#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)
79255 +#define gr_log_str_str(audit, msg, str1, str2) gr_log_varargs(audit, msg, GR_TWO_STR, str1, str2)
79256 +#define gr_log_str2_int(audit, msg, str1, str2, num) gr_log_varargs(audit, msg, GR_TWO_STR_INT, str1, str2, num)
79257 +#define gr_log_str3(audit, msg, str1, str2, str3) gr_log_varargs(audit, msg, GR_THREE_STR, str1, str2, str3)
79258 +#define gr_log_str4(audit, msg, str1, str2, str3, str4) gr_log_varargs(audit, msg, GR_FOUR_STR, str1, str2, str3, str4)
79259 +#define gr_log_str_fs(audit, msg, str, dentry, mnt) gr_log_varargs(audit, msg, GR_STR_FILENAME, str, dentry, mnt)
79260 +#define gr_log_fs_str(audit, msg, dentry, mnt, str) gr_log_varargs(audit, msg, GR_FILENAME_STR, dentry, mnt, str)
79261 +#define gr_log_fs_int2(audit, msg, dentry, mnt, num1, num2) gr_log_varargs(audit, msg, GR_FILENAME_TWO_INT, dentry, mnt, num1, num2)
79262 +#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)
79263 +#define gr_log_textrel_ulong_ulong(audit, msg, file, ulong1, ulong2) gr_log_varargs(audit, msg, GR_TEXTREL, file, ulong1, ulong2)
79264 +#define gr_log_ptrace(audit, msg, task) gr_log_varargs(audit, msg, GR_PTRACE, task)
79265 +#define gr_log_res_ulong2_str(audit, msg, task, ulong1, str, ulong2) gr_log_varargs(audit, msg, GR_RESOURCE, task, ulong1, str, ulong2)
79266 +#define gr_log_cap(audit, msg, task, str) gr_log_varargs(audit, msg, GR_CAP, task, str)
79267 +#define gr_log_sig_addr(audit, msg, str, addr) gr_log_varargs(audit, msg, GR_SIG, str, addr)
79268 +#define gr_log_sig_task(audit, msg, task, num) gr_log_varargs(audit, msg, GR_SIG2, task, num)
79269 +#define gr_log_crash1(audit, msg, task, ulong) gr_log_varargs(audit, msg, GR_CRASH1, task, ulong)
79270 +#define gr_log_crash2(audit, msg, task, ulong1) gr_log_varargs(audit, msg, GR_CRASH2, task, ulong1)
79271 +#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)
79272 +#define gr_log_rwxmap(audit, msg, str) gr_log_varargs(audit, msg, GR_RWXMAP, str)
79273 +#define gr_log_rwxmap_vma(audit, msg, str) gr_log_varargs(audit, msg, GR_RWXMAPVMA, str)
79274 +
79275 +void gr_log_varargs(int audit, const char *msg, int argtypes, ...);
79276 +
79277 +#endif
79278 +
79279 +#endif
79280 diff --git a/include/linux/grmsg.h b/include/linux/grmsg.h
79281 new file mode 100644
79282 index 0000000..b02ba9d
79283 --- /dev/null
79284 +++ b/include/linux/grmsg.h
79285 @@ -0,0 +1,117 @@
79286 +#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"
79287 +#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"
79288 +#define GR_PTRACE_ACL_MSG "denied ptrace of %.950s(%.16s:%d) by "
79289 +#define GR_STOPMOD_MSG "denied modification of module state by "
79290 +#define GR_ROFS_BLOCKWRITE_MSG "denied write to block device %.950s by "
79291 +#define GR_ROFS_MOUNT_MSG "denied writable mount of %.950s by "
79292 +#define GR_IOPERM_MSG "denied use of ioperm() by "
79293 +#define GR_IOPL_MSG "denied use of iopl() by "
79294 +#define GR_SHMAT_ACL_MSG "denied attach of shared memory of UID %u, PID %d, ID %u by "
79295 +#define GR_UNIX_CHROOT_MSG "denied connect() to abstract AF_UNIX socket outside of chroot by "
79296 +#define GR_SHMAT_CHROOT_MSG "denied attach of shared memory outside of chroot by "
79297 +#define GR_MEM_READWRITE_MSG "denied access of range %Lx -> %Lx in /dev/mem by "
79298 +#define GR_SYMLINK_MSG "not following symlink %.950s owned by %d.%d by "
79299 +#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"
79300 +#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"
79301 +#define GR_HIDDEN_ACL_MSG "%s access to hidden file %.950s by "
79302 +#define GR_OPEN_ACL_MSG "%s open of %.950s for%s%s by "
79303 +#define GR_CREATE_ACL_MSG "%s create of %.950s for%s%s by "
79304 +#define GR_FIFO_MSG "denied writing FIFO %.950s of %d.%d by "
79305 +#define GR_MKNOD_CHROOT_MSG "denied mknod of %.950s from chroot by "
79306 +#define GR_MKNOD_ACL_MSG "%s mknod of %.950s by "
79307 +#define GR_UNIXCONNECT_ACL_MSG "%s connect() to the unix domain socket %.950s by "
79308 +#define GR_TTYSNIFF_ACL_MSG "terminal being sniffed by IP:%pI4 %.480s[%.16s:%d], parent %.480s[%.16s:%d] against "
79309 +#define GR_MKDIR_ACL_MSG "%s mkdir of %.950s by "
79310 +#define GR_RMDIR_ACL_MSG "%s rmdir of %.950s by "
79311 +#define GR_UNLINK_ACL_MSG "%s unlink of %.950s by "
79312 +#define GR_SYMLINK_ACL_MSG "%s symlink from %.480s to %.480s by "
79313 +#define GR_HARDLINK_MSG "denied hardlink of %.930s (owned by %d.%d) to %.30s for "
79314 +#define GR_LINK_ACL_MSG "%s link of %.480s to %.480s by "
79315 +#define GR_INHERIT_ACL_MSG "successful inherit of %.480s's ACL for %.480s by "
79316 +#define GR_RENAME_ACL_MSG "%s rename of %.480s to %.480s by "
79317 +#define GR_UNSAFESHARE_EXEC_ACL_MSG "denied exec with cloned fs of %.950s by "
79318 +#define GR_PTRACE_EXEC_ACL_MSG "denied ptrace of %.950s by "
79319 +#define GR_EXEC_ACL_MSG "%s execution of %.950s by "
79320 +#define GR_EXEC_TPE_MSG "denied untrusted exec (due to %.70s) of %.950s by "
79321 +#define GR_SEGVSTART_ACL_MSG "possible exploit bruteforcing on " DEFAULTSECMSG " banning uid %u from login for %lu seconds"
79322 +#define GR_SEGVNOSUID_ACL_MSG "possible exploit bruteforcing on " DEFAULTSECMSG " banning execution for %lu seconds"
79323 +#define GR_MOUNT_CHROOT_MSG "denied mount of %.256s as %.930s from chroot by "
79324 +#define GR_PIVOT_CHROOT_MSG "denied pivot_root from chroot by "
79325 +#define GR_TRUNCATE_ACL_MSG "%s truncate of %.950s by "
79326 +#define GR_ATIME_ACL_MSG "%s access time change of %.950s by "
79327 +#define GR_ACCESS_ACL_MSG "%s access of %.950s for%s%s%s by "
79328 +#define GR_CHROOT_CHROOT_MSG "denied double chroot to %.950s by "
79329 +#define GR_CHMOD_CHROOT_MSG "denied chmod +s of %.950s by "
79330 +#define GR_CHMOD_ACL_MSG "%s chmod of %.950s by "
79331 +#define GR_CHROOT_FCHDIR_MSG "denied fchdir outside of chroot to %.950s by "
79332 +#define GR_CHROOT_FHANDLE_MSG "denied use of file handles inside chroot by "
79333 +#define GR_CHOWN_ACL_MSG "%s chown of %.950s by "
79334 +#define GR_SETXATTR_ACL_MSG "%s setting extended attribute of %.950s by "
79335 +#define GR_REMOVEXATTR_ACL_MSG "%s removing extended attribute of %.950s by "
79336 +#define GR_WRITLIB_ACL_MSG "denied load of writable library %.950s by "
79337 +#define GR_INITF_ACL_MSG "init_variables() failed %s by "
79338 +#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"
79339 +#define GR_DEV_ACL_MSG "/dev/grsec: %d bytes sent %d required, being fed garbage by "
79340 +#define GR_SHUTS_ACL_MSG "shutdown auth success for "
79341 +#define GR_SHUTF_ACL_MSG "shutdown auth failure for "
79342 +#define GR_SHUTI_ACL_MSG "ignoring shutdown for disabled RBAC system for "
79343 +#define GR_SEGVMODS_ACL_MSG "segvmod auth success for "
79344 +#define GR_SEGVMODF_ACL_MSG "segvmod auth failure for "
79345 +#define GR_SEGVMODI_ACL_MSG "ignoring segvmod for disabled RBAC system for "
79346 +#define GR_ENABLE_ACL_MSG "%s RBAC system loaded by "
79347 +#define GR_ENABLEF_ACL_MSG "unable to load %s for "
79348 +#define GR_RELOADI_ACL_MSG "ignoring reload request for disabled RBAC system"
79349 +#define GR_RELOAD_ACL_MSG "%s RBAC system reloaded by "
79350 +#define GR_RELOADF_ACL_MSG "failed reload of %s for "
79351 +#define GR_SPROLEI_ACL_MSG "ignoring change to special role for disabled RBAC system for "
79352 +#define GR_SPROLES_ACL_MSG "successful change to special role %s (id %d) by "
79353 +#define GR_SPROLEL_ACL_MSG "special role %s (id %d) exited by "
79354 +#define GR_SPROLEF_ACL_MSG "special role %s failure for "
79355 +#define GR_UNSPROLEI_ACL_MSG "ignoring unauth of special role for disabled RBAC system for "
79356 +#define GR_UNSPROLES_ACL_MSG "successful unauth of special role %s (id %d) by "
79357 +#define GR_INVMODE_ACL_MSG "invalid mode %d by "
79358 +#define GR_PRIORITY_CHROOT_MSG "denied priority change of process (%.16s:%d) by "
79359 +#define GR_FAILFORK_MSG "failed fork with errno %s by "
79360 +#define GR_NICE_CHROOT_MSG "denied priority change by "
79361 +#define GR_UNISIGLOG_MSG "%.32s occurred at %p in "
79362 +#define GR_DUALSIGLOG_MSG "signal %d sent to " DEFAULTSECMSG " by "
79363 +#define GR_SIG_ACL_MSG "denied send of signal %d to protected task " DEFAULTSECMSG " by "
79364 +#define GR_SYSCTL_MSG "denied modification of grsecurity sysctl value : %.32s by "
79365 +#define GR_SYSCTL_ACL_MSG "%s sysctl of %.950s for%s%s by "
79366 +#define GR_TIME_MSG "time set by "
79367 +#define GR_DEFACL_MSG "fatal: unable to find subject for (%.16s:%d), loaded by "
79368 +#define GR_MMAP_ACL_MSG "%s executable mmap of %.950s by "
79369 +#define GR_MPROTECT_ACL_MSG "%s executable mprotect of %.950s by "
79370 +#define GR_SOCK_MSG "denied socket(%.16s,%.16s,%.16s) by "
79371 +#define GR_SOCK_NOINET_MSG "denied socket(%.16s,%.16s,%d) by "
79372 +#define GR_BIND_MSG "denied bind() by "
79373 +#define GR_CONNECT_MSG "denied connect() by "
79374 +#define GR_BIND_ACL_MSG "denied bind() to %pI4 port %u sock type %.16s protocol %.16s by "
79375 +#define GR_CONNECT_ACL_MSG "denied connect() to %pI4 port %u sock type %.16s protocol %.16s by "
79376 +#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"
79377 +#define GR_EXEC_CHROOT_MSG "exec of %.980s within chroot by process "
79378 +#define GR_CAP_ACL_MSG "use of %s denied for "
79379 +#define GR_CAP_CHROOT_MSG "use of %s in chroot denied for "
79380 +#define GR_CAP_ACL_MSG2 "use of %s permitted for "
79381 +#define GR_USRCHANGE_ACL_MSG "change to uid %u denied for "
79382 +#define GR_GRPCHANGE_ACL_MSG "change to gid %u denied for "
79383 +#define GR_REMOUNT_AUDIT_MSG "remount of %.256s by "
79384 +#define GR_UNMOUNT_AUDIT_MSG "unmount of %.256s by "
79385 +#define GR_MOUNT_AUDIT_MSG "mount of %.256s to %.256s by "
79386 +#define GR_CHDIR_AUDIT_MSG "chdir to %.980s by "
79387 +#define GR_EXEC_AUDIT_MSG "exec of %.930s (%.128s) by "
79388 +#define GR_RESOURCE_MSG "denied resource overstep by requesting %lu for %.16s against limit %lu for "
79389 +#define GR_RWXMMAP_MSG "denied RWX mmap of %.950s by "
79390 +#define GR_RWXMPROTECT_MSG "denied RWX mprotect of %.950s by "
79391 +#define GR_TEXTREL_AUDIT_MSG "denied text relocation in %.950s, VMA:0x%08lx 0x%08lx by "
79392 +#define GR_PTGNUSTACK_MSG "denied marking stack executable as requested by PT_GNU_STACK marking in %.950s by "
79393 +#define GR_VM86_MSG "denied use of vm86 by "
79394 +#define GR_PTRACE_AUDIT_MSG "process %.950s(%.16s:%d) attached to via ptrace by "
79395 +#define GR_PTRACE_READEXEC_MSG "denied ptrace of unreadable binary %.950s by "
79396 +#define GR_INIT_TRANSFER_MSG "persistent special role transferred privilege to init by "
79397 +#define GR_BADPROCPID_MSG "denied read of sensitive /proc/pid/%s entry via fd passed across exec by "
79398 +#define GR_SYMLINKOWNER_MSG "denied following symlink %.950s since symlink owner %u does not match target owner %u, by "
79399 +#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 "
79400 +#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 "
79401 +#define GR_IPC_DENIED_MSG "denied %s of overly-permissive IPC object with creator uid %u by "
79402 +#define GR_MSRWRITE_MSG "denied write to CPU MSR by "
79403 diff --git a/include/linux/grsecurity.h b/include/linux/grsecurity.h
79404 new file mode 100644
79405 index 0000000..13ac2e2
79406 --- /dev/null
79407 +++ b/include/linux/grsecurity.h
79408 @@ -0,0 +1,249 @@
79409 +#ifndef GR_SECURITY_H
79410 +#define GR_SECURITY_H
79411 +#include <linux/fs.h>
79412 +#include <linux/fs_struct.h>
79413 +#include <linux/binfmts.h>
79414 +#include <linux/gracl.h>
79415 +
79416 +/* notify of brain-dead configs */
79417 +#if defined(CONFIG_GRKERNSEC_PROC_USER) && defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
79418 +#error "CONFIG_GRKERNSEC_PROC_USER and CONFIG_GRKERNSEC_PROC_USERGROUP cannot both be enabled."
79419 +#endif
79420 +#if defined(CONFIG_PAX_NOEXEC) && !defined(CONFIG_PAX_PAGEEXEC) && !defined(CONFIG_PAX_SEGMEXEC) && !defined(CONFIG_PAX_KERNEXEC)
79421 +#error "CONFIG_PAX_NOEXEC enabled, but PAGEEXEC, SEGMEXEC, and KERNEXEC are disabled."
79422 +#endif
79423 +#if defined(CONFIG_PAX_ASLR) && !defined(CONFIG_PAX_RANDKSTACK) && !defined(CONFIG_PAX_RANDUSTACK) && !defined(CONFIG_PAX_RANDMMAP)
79424 +#error "CONFIG_PAX_ASLR enabled, but RANDKSTACK, RANDUSTACK, and RANDMMAP are disabled."
79425 +#endif
79426 +#if defined(CONFIG_PAX) && !defined(CONFIG_PAX_NOEXEC) && !defined(CONFIG_PAX_ASLR)
79427 +#error "CONFIG_PAX enabled, but no PaX options are enabled."
79428 +#endif
79429 +
79430 +int gr_handle_new_usb(void);
79431 +
79432 +void gr_handle_brute_attach(int dumpable);
79433 +void gr_handle_brute_check(void);
79434 +void gr_handle_kernel_exploit(void);
79435 +
79436 +char gr_roletype_to_char(void);
79437 +
79438 +int gr_proc_is_restricted(void);
79439 +
79440 +int gr_acl_enable_at_secure(void);
79441 +
79442 +int gr_check_user_change(kuid_t real, kuid_t effective, kuid_t fs);
79443 +int gr_check_group_change(kgid_t real, kgid_t effective, kgid_t fs);
79444 +
79445 +void gr_del_task_from_ip_table(struct task_struct *p);
79446 +
79447 +int gr_pid_is_chrooted(struct task_struct *p);
79448 +int gr_handle_chroot_fowner(struct pid *pid, enum pid_type type);
79449 +int gr_handle_chroot_nice(void);
79450 +int gr_handle_chroot_sysctl(const int op);
79451 +int gr_handle_chroot_setpriority(struct task_struct *p,
79452 + const int niceval);
79453 +int gr_chroot_fchdir(struct dentry *u_dentry, struct vfsmount *u_mnt);
79454 +int gr_chroot_fhandle(void);
79455 +int gr_handle_chroot_chroot(const struct dentry *dentry,
79456 + const struct vfsmount *mnt);
79457 +void gr_handle_chroot_chdir(const struct path *path);
79458 +int gr_handle_chroot_chmod(const struct dentry *dentry,
79459 + const struct vfsmount *mnt, const int mode);
79460 +int gr_handle_chroot_mknod(const struct dentry *dentry,
79461 + const struct vfsmount *mnt, const int mode);
79462 +int gr_handle_chroot_mount(const struct dentry *dentry,
79463 + const struct vfsmount *mnt,
79464 + const char *dev_name);
79465 +int gr_handle_chroot_pivot(void);
79466 +int gr_handle_chroot_unix(const pid_t pid);
79467 +
79468 +int gr_handle_rawio(const struct inode *inode);
79469 +
79470 +void gr_handle_ioperm(void);
79471 +void gr_handle_iopl(void);
79472 +void gr_handle_msr_write(void);
79473 +
79474 +umode_t gr_acl_umask(void);
79475 +
79476 +int gr_tpe_allow(const struct file *file);
79477 +
79478 +void gr_set_chroot_entries(struct task_struct *task, const struct path *path);
79479 +void gr_clear_chroot_entries(struct task_struct *task);
79480 +
79481 +void gr_log_forkfail(const int retval);
79482 +void gr_log_timechange(void);
79483 +void gr_log_signal(const int sig, const void *addr, const struct task_struct *t);
79484 +void gr_log_chdir(const struct dentry *dentry,
79485 + const struct vfsmount *mnt);
79486 +void gr_log_chroot_exec(const struct dentry *dentry,
79487 + const struct vfsmount *mnt);
79488 +void gr_log_remount(const char *devname, const int retval);
79489 +void gr_log_unmount(const char *devname, const int retval);
79490 +void gr_log_mount(const char *from, const char *to, const int retval);
79491 +void gr_log_textrel(struct vm_area_struct *vma);
79492 +void gr_log_ptgnustack(struct file *file);
79493 +void gr_log_rwxmmap(struct file *file);
79494 +void gr_log_rwxmprotect(struct vm_area_struct *vma);
79495 +
79496 +int gr_handle_follow_link(const struct inode *parent,
79497 + const struct inode *inode,
79498 + const struct dentry *dentry,
79499 + const struct vfsmount *mnt);
79500 +int gr_handle_fifo(const struct dentry *dentry,
79501 + const struct vfsmount *mnt,
79502 + const struct dentry *dir, const int flag,
79503 + const int acc_mode);
79504 +int gr_handle_hardlink(const struct dentry *dentry,
79505 + const struct vfsmount *mnt,
79506 + struct inode *inode,
79507 + const int mode, const struct filename *to);
79508 +
79509 +int gr_is_capable(const int cap);
79510 +int gr_is_capable_nolog(const int cap);
79511 +int gr_task_is_capable(const struct task_struct *task, const struct cred *cred, const int cap);
79512 +int gr_task_is_capable_nolog(const struct task_struct *task, const int cap);
79513 +
79514 +void gr_copy_label(struct task_struct *tsk);
79515 +void gr_handle_crash(struct task_struct *task, const int sig);
79516 +int gr_handle_signal(const struct task_struct *p, const int sig);
79517 +int gr_check_crash_uid(const kuid_t uid);
79518 +int gr_check_protected_task(const struct task_struct *task);
79519 +int gr_check_protected_task_fowner(struct pid *pid, enum pid_type type);
79520 +int gr_acl_handle_mmap(const struct file *file,
79521 + const unsigned long prot);
79522 +int gr_acl_handle_mprotect(const struct file *file,
79523 + const unsigned long prot);
79524 +int gr_check_hidden_task(const struct task_struct *tsk);
79525 +__u32 gr_acl_handle_truncate(const struct dentry *dentry,
79526 + const struct vfsmount *mnt);
79527 +__u32 gr_acl_handle_utime(const struct dentry *dentry,
79528 + const struct vfsmount *mnt);
79529 +__u32 gr_acl_handle_access(const struct dentry *dentry,
79530 + const struct vfsmount *mnt, const int fmode);
79531 +__u32 gr_acl_handle_chmod(const struct dentry *dentry,
79532 + const struct vfsmount *mnt, umode_t *mode);
79533 +__u32 gr_acl_handle_chown(const struct dentry *dentry,
79534 + const struct vfsmount *mnt);
79535 +__u32 gr_acl_handle_setxattr(const struct dentry *dentry,
79536 + const struct vfsmount *mnt);
79537 +__u32 gr_acl_handle_removexattr(const struct dentry *dentry,
79538 + const struct vfsmount *mnt);
79539 +int gr_handle_ptrace(struct task_struct *task, const long request);
79540 +int gr_handle_proc_ptrace(struct task_struct *task);
79541 +__u32 gr_acl_handle_execve(const struct dentry *dentry,
79542 + const struct vfsmount *mnt);
79543 +int gr_check_crash_exec(const struct file *filp);
79544 +int gr_acl_is_enabled(void);
79545 +void gr_set_role_label(struct task_struct *task, const kuid_t uid,
79546 + const kgid_t gid);
79547 +int gr_set_proc_label(const struct dentry *dentry,
79548 + const struct vfsmount *mnt,
79549 + const int unsafe_flags);
79550 +__u32 gr_acl_handle_hidden_file(const struct dentry *dentry,
79551 + const struct vfsmount *mnt);
79552 +__u32 gr_acl_handle_open(const struct dentry *dentry,
79553 + const struct vfsmount *mnt, int acc_mode);
79554 +__u32 gr_acl_handle_creat(const struct dentry *dentry,
79555 + const struct dentry *p_dentry,
79556 + const struct vfsmount *p_mnt,
79557 + int open_flags, int acc_mode, const int imode);
79558 +void gr_handle_create(const struct dentry *dentry,
79559 + const struct vfsmount *mnt);
79560 +void gr_handle_proc_create(const struct dentry *dentry,
79561 + const struct inode *inode);
79562 +__u32 gr_acl_handle_mknod(const struct dentry *new_dentry,
79563 + const struct dentry *parent_dentry,
79564 + const struct vfsmount *parent_mnt,
79565 + const int mode);
79566 +__u32 gr_acl_handle_mkdir(const struct dentry *new_dentry,
79567 + const struct dentry *parent_dentry,
79568 + const struct vfsmount *parent_mnt);
79569 +__u32 gr_acl_handle_rmdir(const struct dentry *dentry,
79570 + const struct vfsmount *mnt);
79571 +void gr_handle_delete(const ino_t ino, const dev_t dev);
79572 +__u32 gr_acl_handle_unlink(const struct dentry *dentry,
79573 + const struct vfsmount *mnt);
79574 +__u32 gr_acl_handle_symlink(const struct dentry *new_dentry,
79575 + const struct dentry *parent_dentry,
79576 + const struct vfsmount *parent_mnt,
79577 + const struct filename *from);
79578 +__u32 gr_acl_handle_link(const struct dentry *new_dentry,
79579 + const struct dentry *parent_dentry,
79580 + const struct vfsmount *parent_mnt,
79581 + const struct dentry *old_dentry,
79582 + const struct vfsmount *old_mnt, const struct filename *to);
79583 +int gr_handle_symlink_owner(const struct path *link, const struct inode *target);
79584 +int gr_acl_handle_rename(struct dentry *new_dentry,
79585 + struct dentry *parent_dentry,
79586 + const struct vfsmount *parent_mnt,
79587 + struct dentry *old_dentry,
79588 + struct inode *old_parent_inode,
79589 + struct vfsmount *old_mnt, const struct filename *newname, unsigned int flags);
79590 +void gr_handle_rename(struct inode *old_dir, struct inode *new_dir,
79591 + struct dentry *old_dentry,
79592 + struct dentry *new_dentry,
79593 + struct vfsmount *mnt, const __u8 replace, unsigned int flags);
79594 +__u32 gr_check_link(const struct dentry *new_dentry,
79595 + const struct dentry *parent_dentry,
79596 + const struct vfsmount *parent_mnt,
79597 + const struct dentry *old_dentry,
79598 + const struct vfsmount *old_mnt);
79599 +int gr_acl_handle_filldir(const struct file *file, const char *name,
79600 + const unsigned int namelen, const ino_t ino);
79601 +
79602 +__u32 gr_acl_handle_unix(const struct dentry *dentry,
79603 + const struct vfsmount *mnt);
79604 +void gr_acl_handle_exit(void);
79605 +void gr_acl_handle_psacct(struct task_struct *task, const long code);
79606 +int gr_acl_handle_procpidmem(const struct task_struct *task);
79607 +int gr_handle_rofs_mount(struct dentry *dentry, struct vfsmount *mnt, int mnt_flags);
79608 +int gr_handle_rofs_blockwrite(struct dentry *dentry, struct vfsmount *mnt, int acc_mode);
79609 +void gr_audit_ptrace(struct task_struct *task);
79610 +dev_t gr_get_dev_from_dentry(struct dentry *dentry);
79611 +void gr_put_exec_file(struct task_struct *task);
79612 +
79613 +int gr_ptrace_readexec(struct file *file, int unsafe_flags);
79614 +
79615 +#if defined(CONFIG_GRKERNSEC) && (defined(CONFIG_GRKERNSEC_RESLOG) || !defined(CONFIG_GRKERNSEC_NO_RBAC))
79616 +extern void gr_learn_resource(const struct task_struct *task, const int res,
79617 + const unsigned long wanted, const int gt);
79618 +#else
79619 +static inline void gr_learn_resource(const struct task_struct *task, const int res,
79620 + const unsigned long wanted, const int gt)
79621 +{
79622 +}
79623 +#endif
79624 +
79625 +#ifdef CONFIG_GRKERNSEC_RESLOG
79626 +extern void gr_log_resource(const struct task_struct *task, const int res,
79627 + const unsigned long wanted, const int gt);
79628 +#else
79629 +static inline void gr_log_resource(const struct task_struct *task, const int res,
79630 + const unsigned long wanted, const int gt)
79631 +{
79632 +}
79633 +#endif
79634 +
79635 +#ifdef CONFIG_GRKERNSEC
79636 +void task_grsec_rbac(struct seq_file *m, struct task_struct *p);
79637 +void gr_handle_vm86(void);
79638 +void gr_handle_mem_readwrite(u64 from, u64 to);
79639 +
79640 +void gr_log_badprocpid(const char *entry);
79641 +
79642 +extern int grsec_enable_dmesg;
79643 +extern int grsec_disable_privio;
79644 +
79645 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
79646 +extern kgid_t grsec_proc_gid;
79647 +#endif
79648 +
79649 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
79650 +extern int grsec_enable_chroot_findtask;
79651 +#endif
79652 +#ifdef CONFIG_GRKERNSEC_SETXID
79653 +extern int grsec_enable_setxid;
79654 +#endif
79655 +#endif
79656 +
79657 +#endif
79658 diff --git a/include/linux/grsock.h b/include/linux/grsock.h
79659 new file mode 100644
79660 index 0000000..e7ffaaf
79661 --- /dev/null
79662 +++ b/include/linux/grsock.h
79663 @@ -0,0 +1,19 @@
79664 +#ifndef __GRSOCK_H
79665 +#define __GRSOCK_H
79666 +
79667 +extern void gr_attach_curr_ip(const struct sock *sk);
79668 +extern int gr_handle_sock_all(const int family, const int type,
79669 + const int protocol);
79670 +extern int gr_handle_sock_server(const struct sockaddr *sck);
79671 +extern int gr_handle_sock_server_other(const struct sock *sck);
79672 +extern int gr_handle_sock_client(const struct sockaddr *sck);
79673 +extern int gr_search_connect(struct socket * sock,
79674 + struct sockaddr_in * addr);
79675 +extern int gr_search_bind(struct socket * sock,
79676 + struct sockaddr_in * addr);
79677 +extern int gr_search_listen(struct socket * sock);
79678 +extern int gr_search_accept(struct socket * sock);
79679 +extern int gr_search_socket(const int domain, const int type,
79680 + const int protocol);
79681 +
79682 +#endif
79683 diff --git a/include/linux/hash.h b/include/linux/hash.h
79684 index bd1754c..8240892 100644
79685 --- a/include/linux/hash.h
79686 +++ b/include/linux/hash.h
79687 @@ -83,7 +83,7 @@ static inline u32 hash32_ptr(const void *ptr)
79688 struct fast_hash_ops {
79689 u32 (*hash)(const void *data, u32 len, u32 seed);
79690 u32 (*hash2)(const u32 *data, u32 len, u32 seed);
79691 -};
79692 +} __no_const;
79693
79694 /**
79695 * arch_fast_hash - Caclulates a hash over a given buffer that can have
79696 diff --git a/include/linux/highmem.h b/include/linux/highmem.h
79697 index 7fb31da..08b5114 100644
79698 --- a/include/linux/highmem.h
79699 +++ b/include/linux/highmem.h
79700 @@ -189,6 +189,18 @@ static inline void clear_highpage(struct page *page)
79701 kunmap_atomic(kaddr);
79702 }
79703
79704 +static inline void sanitize_highpage(struct page *page)
79705 +{
79706 + void *kaddr;
79707 + unsigned long flags;
79708 +
79709 + local_irq_save(flags);
79710 + kaddr = kmap_atomic(page);
79711 + clear_page(kaddr);
79712 + kunmap_atomic(kaddr);
79713 + local_irq_restore(flags);
79714 +}
79715 +
79716 static inline void zero_user_segments(struct page *page,
79717 unsigned start1, unsigned end1,
79718 unsigned start2, unsigned end2)
79719 diff --git a/include/linux/hwmon-sysfs.h b/include/linux/hwmon-sysfs.h
79720 index 1c7b89a..7dda400 100644
79721 --- a/include/linux/hwmon-sysfs.h
79722 +++ b/include/linux/hwmon-sysfs.h
79723 @@ -25,7 +25,8 @@
79724 struct sensor_device_attribute{
79725 struct device_attribute dev_attr;
79726 int index;
79727 -};
79728 +} __do_const;
79729 +typedef struct sensor_device_attribute __no_const sensor_device_attribute_no_const;
79730 #define to_sensor_dev_attr(_dev_attr) \
79731 container_of(_dev_attr, struct sensor_device_attribute, dev_attr)
79732
79733 @@ -41,7 +42,8 @@ struct sensor_device_attribute_2 {
79734 struct device_attribute dev_attr;
79735 u8 index;
79736 u8 nr;
79737 -};
79738 +} __do_const;
79739 +typedef struct sensor_device_attribute_2 __no_const sensor_device_attribute_2_no_const;
79740 #define to_sensor_dev_attr_2(_dev_attr) \
79741 container_of(_dev_attr, struct sensor_device_attribute_2, dev_attr)
79742
79743 diff --git a/include/linux/i2c.h b/include/linux/i2c.h
79744 index b556e0a..c10a515 100644
79745 --- a/include/linux/i2c.h
79746 +++ b/include/linux/i2c.h
79747 @@ -378,6 +378,7 @@ struct i2c_algorithm {
79748 /* To determine what the adapter supports */
79749 u32 (*functionality) (struct i2c_adapter *);
79750 };
79751 +typedef struct i2c_algorithm __no_const i2c_algorithm_no_const;
79752
79753 /**
79754 * struct i2c_bus_recovery_info - I2C bus recovery information
79755 diff --git a/include/linux/i2o.h b/include/linux/i2o.h
79756 index d23c3c2..eb63c81 100644
79757 --- a/include/linux/i2o.h
79758 +++ b/include/linux/i2o.h
79759 @@ -565,7 +565,7 @@ struct i2o_controller {
79760 struct i2o_device *exec; /* Executive */
79761 #if BITS_PER_LONG == 64
79762 spinlock_t context_list_lock; /* lock for context_list */
79763 - atomic_t context_list_counter; /* needed for unique contexts */
79764 + atomic_unchecked_t context_list_counter; /* needed for unique contexts */
79765 struct list_head context_list; /* list of context id's
79766 and pointers */
79767 #endif
79768 diff --git a/include/linux/if_pppox.h b/include/linux/if_pppox.h
79769 index aff7ad8..3942bbd 100644
79770 --- a/include/linux/if_pppox.h
79771 +++ b/include/linux/if_pppox.h
79772 @@ -76,7 +76,7 @@ struct pppox_proto {
79773 int (*ioctl)(struct socket *sock, unsigned int cmd,
79774 unsigned long arg);
79775 struct module *owner;
79776 -};
79777 +} __do_const;
79778
79779 extern int register_pppox_proto(int proto_num, const struct pppox_proto *pp);
79780 extern void unregister_pppox_proto(int proto_num);
79781 diff --git a/include/linux/init.h b/include/linux/init.h
79782 index a3ba270..a1b6604 100644
79783 --- a/include/linux/init.h
79784 +++ b/include/linux/init.h
79785 @@ -37,9 +37,17 @@
79786 * section.
79787 */
79788
79789 +#define add_init_latent_entropy __latent_entropy
79790 +
79791 +#ifdef CONFIG_MEMORY_HOTPLUG
79792 +#define add_meminit_latent_entropy
79793 +#else
79794 +#define add_meminit_latent_entropy __latent_entropy
79795 +#endif
79796 +
79797 /* These are for everybody (although not all archs will actually
79798 discard it in modules) */
79799 -#define __init __section(.init.text) __cold notrace
79800 +#define __init __section(.init.text) __cold notrace add_init_latent_entropy
79801 #define __initdata __section(.init.data)
79802 #define __initconst __constsection(.init.rodata)
79803 #define __exitdata __section(.exit.data)
79804 @@ -100,7 +108,7 @@
79805 #define __cpuexitconst
79806
79807 /* Used for MEMORY_HOTPLUG */
79808 -#define __meminit __section(.meminit.text) __cold notrace
79809 +#define __meminit __section(.meminit.text) __cold notrace add_meminit_latent_entropy
79810 #define __meminitdata __section(.meminit.data)
79811 #define __meminitconst __constsection(.meminit.rodata)
79812 #define __memexit __section(.memexit.text) __exitused __cold notrace
79813 diff --git a/include/linux/init_task.h b/include/linux/init_task.h
79814 index 6df7f9f..d0bf699 100644
79815 --- a/include/linux/init_task.h
79816 +++ b/include/linux/init_task.h
79817 @@ -156,6 +156,12 @@ extern struct task_group root_task_group;
79818
79819 #define INIT_TASK_COMM "swapper"
79820
79821 +#ifdef CONFIG_X86
79822 +#define INIT_TASK_THREAD_INFO .tinfo = INIT_THREAD_INFO,
79823 +#else
79824 +#define INIT_TASK_THREAD_INFO
79825 +#endif
79826 +
79827 #ifdef CONFIG_RT_MUTEXES
79828 # define INIT_RT_MUTEXES(tsk) \
79829 .pi_waiters = RB_ROOT, \
79830 @@ -203,6 +209,7 @@ extern struct task_group root_task_group;
79831 RCU_POINTER_INITIALIZER(cred, &init_cred), \
79832 .comm = INIT_TASK_COMM, \
79833 .thread = INIT_THREAD, \
79834 + INIT_TASK_THREAD_INFO \
79835 .fs = &init_fs, \
79836 .files = &init_files, \
79837 .signal = &init_signals, \
79838 diff --git a/include/linux/interrupt.h b/include/linux/interrupt.h
79839 index 051c850..431f83a 100644
79840 --- a/include/linux/interrupt.h
79841 +++ b/include/linux/interrupt.h
79842 @@ -412,8 +412,8 @@ extern const char * const softirq_to_name[NR_SOFTIRQS];
79843
79844 struct softirq_action
79845 {
79846 - void (*action)(struct softirq_action *);
79847 -};
79848 + void (*action)(void);
79849 +} __no_const;
79850
79851 asmlinkage void do_softirq(void);
79852 asmlinkage void __do_softirq(void);
79853 @@ -427,7 +427,7 @@ static inline void do_softirq_own_stack(void)
79854 }
79855 #endif
79856
79857 -extern void open_softirq(int nr, void (*action)(struct softirq_action *));
79858 +extern void open_softirq(int nr, void (*action)(void));
79859 extern void softirq_init(void);
79860 extern void __raise_softirq_irqoff(unsigned int nr);
79861
79862 diff --git a/include/linux/iommu.h b/include/linux/iommu.h
79863 index b96a5b2..2732d1c 100644
79864 --- a/include/linux/iommu.h
79865 +++ b/include/linux/iommu.h
79866 @@ -131,7 +131,7 @@ struct iommu_ops {
79867 u32 (*domain_get_windows)(struct iommu_domain *domain);
79868
79869 unsigned long pgsize_bitmap;
79870 -};
79871 +} __do_const;
79872
79873 #define IOMMU_GROUP_NOTIFY_ADD_DEVICE 1 /* Device added */
79874 #define IOMMU_GROUP_NOTIFY_DEL_DEVICE 2 /* Pre Device removed */
79875 diff --git a/include/linux/ioport.h b/include/linux/ioport.h
79876 index 5e3a906..3131d0f 100644
79877 --- a/include/linux/ioport.h
79878 +++ b/include/linux/ioport.h
79879 @@ -161,7 +161,7 @@ struct resource *lookup_resource(struct resource *root, resource_size_t start);
79880 int adjust_resource(struct resource *res, resource_size_t start,
79881 resource_size_t size);
79882 resource_size_t resource_alignment(struct resource *res);
79883 -static inline resource_size_t resource_size(const struct resource *res)
79884 +static inline resource_size_t __intentional_overflow(-1) resource_size(const struct resource *res)
79885 {
79886 return res->end - res->start + 1;
79887 }
79888 diff --git a/include/linux/ipc_namespace.h b/include/linux/ipc_namespace.h
79889 index 35e7eca..6afb7ad 100644
79890 --- a/include/linux/ipc_namespace.h
79891 +++ b/include/linux/ipc_namespace.h
79892 @@ -69,7 +69,7 @@ struct ipc_namespace {
79893 struct user_namespace *user_ns;
79894
79895 unsigned int proc_inum;
79896 -};
79897 +} __randomize_layout;
79898
79899 extern struct ipc_namespace init_ipc_ns;
79900 extern atomic_t nr_ipc_ns;
79901 diff --git a/include/linux/irq.h b/include/linux/irq.h
79902 index 5c57efb..965a62b 100644
79903 --- a/include/linux/irq.h
79904 +++ b/include/linux/irq.h
79905 @@ -344,7 +344,8 @@ struct irq_chip {
79906 void (*irq_release_resources)(struct irq_data *data);
79907
79908 unsigned long flags;
79909 -};
79910 +} __do_const;
79911 +typedef struct irq_chip __no_const irq_chip_no_const;
79912
79913 /*
79914 * irq_chip specific flags
79915 diff --git a/include/linux/irqchip/arm-gic.h b/include/linux/irqchip/arm-gic.h
79916 index 7ed92d0..589abf5 100644
79917 --- a/include/linux/irqchip/arm-gic.h
79918 +++ b/include/linux/irqchip/arm-gic.h
79919 @@ -73,9 +73,11 @@
79920
79921 #ifndef __ASSEMBLY__
79922
79923 +#include <linux/irq.h>
79924 +
79925 struct device_node;
79926
79927 -extern struct irq_chip gic_arch_extn;
79928 +extern irq_chip_no_const gic_arch_extn;
79929
79930 void gic_init_bases(unsigned int, int, void __iomem *, void __iomem *,
79931 u32 offset, struct device_node *);
79932 diff --git a/include/linux/jiffies.h b/include/linux/jiffies.h
79933 index 1f44466..b481806 100644
79934 --- a/include/linux/jiffies.h
79935 +++ b/include/linux/jiffies.h
79936 @@ -292,20 +292,20 @@ extern unsigned long preset_lpj;
79937 /*
79938 * Convert various time units to each other:
79939 */
79940 -extern unsigned int jiffies_to_msecs(const unsigned long j);
79941 -extern unsigned int jiffies_to_usecs(const unsigned long j);
79942 +extern unsigned int jiffies_to_msecs(const unsigned long j) __intentional_overflow(-1);
79943 +extern unsigned int jiffies_to_usecs(const unsigned long j) __intentional_overflow(-1);
79944
79945 -static inline u64 jiffies_to_nsecs(const unsigned long j)
79946 +static inline u64 __intentional_overflow(-1) jiffies_to_nsecs(const unsigned long j)
79947 {
79948 return (u64)jiffies_to_usecs(j) * NSEC_PER_USEC;
79949 }
79950
79951 -extern unsigned long msecs_to_jiffies(const unsigned int m);
79952 -extern unsigned long usecs_to_jiffies(const unsigned int u);
79953 +extern unsigned long msecs_to_jiffies(const unsigned int m) __intentional_overflow(-1);
79954 +extern unsigned long usecs_to_jiffies(const unsigned int u) __intentional_overflow(-1);
79955 extern unsigned long timespec_to_jiffies(const struct timespec *value);
79956 extern void jiffies_to_timespec(const unsigned long jiffies,
79957 - struct timespec *value);
79958 -extern unsigned long timeval_to_jiffies(const struct timeval *value);
79959 + struct timespec *value) __intentional_overflow(-1);
79960 +extern unsigned long timeval_to_jiffies(const struct timeval *value) __intentional_overflow(-1);
79961 extern void jiffies_to_timeval(const unsigned long jiffies,
79962 struct timeval *value);
79963
79964 diff --git a/include/linux/kallsyms.h b/include/linux/kallsyms.h
79965 index 6883e19..e854fcb 100644
79966 --- a/include/linux/kallsyms.h
79967 +++ b/include/linux/kallsyms.h
79968 @@ -15,7 +15,8 @@
79969
79970 struct module;
79971
79972 -#ifdef CONFIG_KALLSYMS
79973 +#if !defined(__INCLUDED_BY_HIDESYM) || !defined(CONFIG_KALLSYMS)
79974 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
79975 /* Lookup the address for a symbol. Returns 0 if not found. */
79976 unsigned long kallsyms_lookup_name(const char *name);
79977
79978 @@ -106,6 +107,21 @@ static inline int lookup_symbol_attrs(unsigned long addr, unsigned long *size, u
79979 /* Stupid that this does nothing, but I didn't create this mess. */
79980 #define __print_symbol(fmt, addr)
79981 #endif /*CONFIG_KALLSYMS*/
79982 +#else /* when included by kallsyms.c, vsnprintf.c, kprobes.c, or
79983 + arch/x86/kernel/dumpstack.c, with HIDESYM enabled */
79984 +extern unsigned long kallsyms_lookup_name(const char *name);
79985 +extern void __print_symbol(const char *fmt, unsigned long address);
79986 +extern int sprint_backtrace(char *buffer, unsigned long address);
79987 +extern int sprint_symbol(char *buffer, unsigned long address);
79988 +extern int sprint_symbol_no_offset(char *buffer, unsigned long address);
79989 +const char *kallsyms_lookup(unsigned long addr,
79990 + unsigned long *symbolsize,
79991 + unsigned long *offset,
79992 + char **modname, char *namebuf);
79993 +extern int kallsyms_lookup_size_offset(unsigned long addr,
79994 + unsigned long *symbolsize,
79995 + unsigned long *offset);
79996 +#endif
79997
79998 /* This macro allows us to keep printk typechecking */
79999 static __printf(1, 2)
80000 diff --git a/include/linux/key-type.h b/include/linux/key-type.h
80001 index a74c3a8..28d3f21 100644
80002 --- a/include/linux/key-type.h
80003 +++ b/include/linux/key-type.h
80004 @@ -131,7 +131,7 @@ struct key_type {
80005 /* internal fields */
80006 struct list_head link; /* link in types list */
80007 struct lock_class_key lock_class; /* key->sem lock class */
80008 -};
80009 +} __do_const;
80010
80011 extern struct key_type key_type_keyring;
80012
80013 diff --git a/include/linux/kgdb.h b/include/linux/kgdb.h
80014 index 6b06d37..c134867 100644
80015 --- a/include/linux/kgdb.h
80016 +++ b/include/linux/kgdb.h
80017 @@ -52,7 +52,7 @@ extern int kgdb_connected;
80018 extern int kgdb_io_module_registered;
80019
80020 extern atomic_t kgdb_setting_breakpoint;
80021 -extern atomic_t kgdb_cpu_doing_single_step;
80022 +extern atomic_unchecked_t kgdb_cpu_doing_single_step;
80023
80024 extern struct task_struct *kgdb_usethread;
80025 extern struct task_struct *kgdb_contthread;
80026 @@ -254,7 +254,7 @@ struct kgdb_arch {
80027 void (*correct_hw_break)(void);
80028
80029 void (*enable_nmi)(bool on);
80030 -};
80031 +} __do_const;
80032
80033 /**
80034 * struct kgdb_io - Describe the interface for an I/O driver to talk with KGDB.
80035 @@ -279,7 +279,7 @@ struct kgdb_io {
80036 void (*pre_exception) (void);
80037 void (*post_exception) (void);
80038 int is_console;
80039 -};
80040 +} __do_const;
80041
80042 extern struct kgdb_arch arch_kgdb_ops;
80043
80044 diff --git a/include/linux/kmod.h b/include/linux/kmod.h
80045 index 0555cc6..40116ce 100644
80046 --- a/include/linux/kmod.h
80047 +++ b/include/linux/kmod.h
80048 @@ -34,6 +34,8 @@ extern char modprobe_path[]; /* for sysctl */
80049 * usually useless though. */
80050 extern __printf(2, 3)
80051 int __request_module(bool wait, const char *name, ...);
80052 +extern __printf(3, 4)
80053 +int ___request_module(bool wait, char *param_name, const char *name, ...);
80054 #define request_module(mod...) __request_module(true, mod)
80055 #define request_module_nowait(mod...) __request_module(false, mod)
80056 #define try_then_request_module(x, mod...) \
80057 @@ -57,6 +59,9 @@ struct subprocess_info {
80058 struct work_struct work;
80059 struct completion *complete;
80060 char *path;
80061 +#ifdef CONFIG_GRKERNSEC
80062 + char *origpath;
80063 +#endif
80064 char **argv;
80065 char **envp;
80066 int wait;
80067 diff --git a/include/linux/kobject.h b/include/linux/kobject.h
80068 index f896a33..f2eb10f 100644
80069 --- a/include/linux/kobject.h
80070 +++ b/include/linux/kobject.h
80071 @@ -116,7 +116,7 @@ struct kobj_type {
80072 struct attribute **default_attrs;
80073 const struct kobj_ns_type_operations *(*child_ns_type)(struct kobject *kobj);
80074 const void *(*namespace)(struct kobject *kobj);
80075 -};
80076 +} __do_const;
80077
80078 struct kobj_uevent_env {
80079 char *argv[3];
80080 @@ -140,6 +140,7 @@ struct kobj_attribute {
80081 ssize_t (*store)(struct kobject *kobj, struct kobj_attribute *attr,
80082 const char *buf, size_t count);
80083 };
80084 +typedef struct kobj_attribute __no_const kobj_attribute_no_const;
80085
80086 extern const struct sysfs_ops kobj_sysfs_ops;
80087
80088 @@ -167,7 +168,7 @@ struct kset {
80089 spinlock_t list_lock;
80090 struct kobject kobj;
80091 const struct kset_uevent_ops *uevent_ops;
80092 -};
80093 +} __randomize_layout;
80094
80095 extern void kset_init(struct kset *kset);
80096 extern int __must_check kset_register(struct kset *kset);
80097 diff --git a/include/linux/kobject_ns.h b/include/linux/kobject_ns.h
80098 index df32d25..fb52e27 100644
80099 --- a/include/linux/kobject_ns.h
80100 +++ b/include/linux/kobject_ns.h
80101 @@ -44,7 +44,7 @@ struct kobj_ns_type_operations {
80102 const void *(*netlink_ns)(struct sock *sk);
80103 const void *(*initial_ns)(void);
80104 void (*drop_ns)(void *);
80105 -};
80106 +} __do_const;
80107
80108 int kobj_ns_type_register(const struct kobj_ns_type_operations *ops);
80109 int kobj_ns_type_registered(enum kobj_ns_type type);
80110 diff --git a/include/linux/kref.h b/include/linux/kref.h
80111 index 484604d..0f6c5b6 100644
80112 --- a/include/linux/kref.h
80113 +++ b/include/linux/kref.h
80114 @@ -68,7 +68,7 @@ static inline void kref_get(struct kref *kref)
80115 static inline int kref_sub(struct kref *kref, unsigned int count,
80116 void (*release)(struct kref *kref))
80117 {
80118 - WARN_ON(release == NULL);
80119 + BUG_ON(release == NULL);
80120
80121 if (atomic_sub_and_test((int) count, &kref->refcount)) {
80122 release(kref);
80123 diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
80124 index 7d21cf9..bc0c81f 100644
80125 --- a/include/linux/kvm_host.h
80126 +++ b/include/linux/kvm_host.h
80127 @@ -466,7 +466,7 @@ static inline void kvm_irqfd_exit(void)
80128 {
80129 }
80130 #endif
80131 -int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
80132 +int kvm_init(const void *opaque, unsigned vcpu_size, unsigned vcpu_align,
80133 struct module *module);
80134 void kvm_exit(void);
80135
80136 @@ -632,7 +632,7 @@ int kvm_arch_vcpu_ioctl_set_guest_debug(struct kvm_vcpu *vcpu,
80137 struct kvm_guest_debug *dbg);
80138 int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run);
80139
80140 -int kvm_arch_init(void *opaque);
80141 +int kvm_arch_init(const void *opaque);
80142 void kvm_arch_exit(void);
80143
80144 int kvm_arch_vcpu_init(struct kvm_vcpu *vcpu);
80145 diff --git a/include/linux/libata.h b/include/linux/libata.h
80146 index 5ab4e3a..2fe237b 100644
80147 --- a/include/linux/libata.h
80148 +++ b/include/linux/libata.h
80149 @@ -975,7 +975,7 @@ struct ata_port_operations {
80150 * fields must be pointers.
80151 */
80152 const struct ata_port_operations *inherits;
80153 -};
80154 +} __do_const;
80155
80156 struct ata_port_info {
80157 unsigned long flags;
80158 diff --git a/include/linux/linkage.h b/include/linux/linkage.h
80159 index a6a42dd..6c5ebce 100644
80160 --- a/include/linux/linkage.h
80161 +++ b/include/linux/linkage.h
80162 @@ -36,6 +36,7 @@
80163 #endif
80164
80165 #define __page_aligned_data __section(.data..page_aligned) __aligned(PAGE_SIZE)
80166 +#define __page_aligned_rodata __read_only __aligned(PAGE_SIZE)
80167 #define __page_aligned_bss __section(.bss..page_aligned) __aligned(PAGE_SIZE)
80168
80169 /*
80170 diff --git a/include/linux/list.h b/include/linux/list.h
80171 index ef95941..82db65a 100644
80172 --- a/include/linux/list.h
80173 +++ b/include/linux/list.h
80174 @@ -112,6 +112,19 @@ extern void __list_del_entry(struct list_head *entry);
80175 extern void list_del(struct list_head *entry);
80176 #endif
80177
80178 +extern void __pax_list_add(struct list_head *new,
80179 + struct list_head *prev,
80180 + struct list_head *next);
80181 +static inline void pax_list_add(struct list_head *new, struct list_head *head)
80182 +{
80183 + __pax_list_add(new, head, head->next);
80184 +}
80185 +static inline void pax_list_add_tail(struct list_head *new, struct list_head *head)
80186 +{
80187 + __pax_list_add(new, head->prev, head);
80188 +}
80189 +extern void pax_list_del(struct list_head *entry);
80190 +
80191 /**
80192 * list_replace - replace old entry by new one
80193 * @old : the element to be replaced
80194 @@ -145,6 +158,8 @@ static inline void list_del_init(struct list_head *entry)
80195 INIT_LIST_HEAD(entry);
80196 }
80197
80198 +extern void pax_list_del_init(struct list_head *entry);
80199 +
80200 /**
80201 * list_move - delete from one list and add as another's head
80202 * @list: the entry to move
80203 diff --git a/include/linux/math64.h b/include/linux/math64.h
80204 index c45c089..298841c 100644
80205 --- a/include/linux/math64.h
80206 +++ b/include/linux/math64.h
80207 @@ -15,7 +15,7 @@
80208 * This is commonly provided by 32bit archs to provide an optimized 64bit
80209 * divide.
80210 */
80211 -static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
80212 +static inline u64 __intentional_overflow(-1) div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
80213 {
80214 *remainder = dividend % divisor;
80215 return dividend / divisor;
80216 @@ -42,7 +42,7 @@ static inline u64 div64_u64_rem(u64 dividend, u64 divisor, u64 *remainder)
80217 /**
80218 * div64_u64 - unsigned 64bit divide with 64bit divisor
80219 */
80220 -static inline u64 div64_u64(u64 dividend, u64 divisor)
80221 +static inline u64 __intentional_overflow(-1) div64_u64(u64 dividend, u64 divisor)
80222 {
80223 return dividend / divisor;
80224 }
80225 @@ -61,7 +61,7 @@ static inline s64 div64_s64(s64 dividend, s64 divisor)
80226 #define div64_ul(x, y) div_u64((x), (y))
80227
80228 #ifndef div_u64_rem
80229 -static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
80230 +static inline u64 __intentional_overflow(-1) div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
80231 {
80232 *remainder = do_div(dividend, divisor);
80233 return dividend;
80234 @@ -77,7 +77,7 @@ extern u64 div64_u64_rem(u64 dividend, u64 divisor, u64 *remainder);
80235 #endif
80236
80237 #ifndef div64_u64
80238 -extern u64 div64_u64(u64 dividend, u64 divisor);
80239 +extern u64 __intentional_overflow(-1) div64_u64(u64 dividend, u64 divisor);
80240 #endif
80241
80242 #ifndef div64_s64
80243 @@ -94,7 +94,7 @@ extern s64 div64_s64(s64 dividend, s64 divisor);
80244 * divide.
80245 */
80246 #ifndef div_u64
80247 -static inline u64 div_u64(u64 dividend, u32 divisor)
80248 +static inline u64 __intentional_overflow(-1) div_u64(u64 dividend, u32 divisor)
80249 {
80250 u32 remainder;
80251 return div_u64_rem(dividend, divisor, &remainder);
80252 diff --git a/include/linux/mempolicy.h b/include/linux/mempolicy.h
80253 index 3c1b968..d5b5683 100644
80254 --- a/include/linux/mempolicy.h
80255 +++ b/include/linux/mempolicy.h
80256 @@ -91,6 +91,10 @@ static inline struct mempolicy *mpol_dup(struct mempolicy *pol)
80257 }
80258
80259 #define vma_policy(vma) ((vma)->vm_policy)
80260 +static inline void set_vma_policy(struct vm_area_struct *vma, struct mempolicy *pol)
80261 +{
80262 + vma->vm_policy = pol;
80263 +}
80264
80265 static inline void mpol_get(struct mempolicy *pol)
80266 {
80267 @@ -222,6 +226,9 @@ static inline void mpol_free_shared_policy(struct shared_policy *p)
80268 }
80269
80270 #define vma_policy(vma) NULL
80271 +static inline void set_vma_policy(struct vm_area_struct *vma, struct mempolicy *pol)
80272 +{
80273 +}
80274
80275 static inline int
80276 vma_dup_policy(struct vm_area_struct *src, struct vm_area_struct *dst)
80277 diff --git a/include/linux/mm.h b/include/linux/mm.h
80278 index d677706..673408c 100644
80279 --- a/include/linux/mm.h
80280 +++ b/include/linux/mm.h
80281 @@ -127,6 +127,11 @@ extern unsigned int kobjsize(const void *objp);
80282 #define VM_HUGETLB 0x00400000 /* Huge TLB Page VM */
80283 #define VM_NONLINEAR 0x00800000 /* Is non-linear (remap_file_pages) */
80284 #define VM_ARCH_1 0x01000000 /* Architecture-specific flag */
80285 +
80286 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
80287 +#define VM_PAGEEXEC 0x02000000 /* vma->vm_page_prot needs special handling */
80288 +#endif
80289 +
80290 #define VM_DONTDUMP 0x04000000 /* Do not include in the core dump */
80291
80292 #ifdef CONFIG_MEM_SOFT_DIRTY
80293 @@ -237,8 +242,8 @@ struct vm_operations_struct {
80294 /* called by access_process_vm when get_user_pages() fails, typically
80295 * for use by special VMAs that can switch between memory and hardware
80296 */
80297 - int (*access)(struct vm_area_struct *vma, unsigned long addr,
80298 - void *buf, int len, int write);
80299 + ssize_t (*access)(struct vm_area_struct *vma, unsigned long addr,
80300 + void *buf, size_t len, int write);
80301 #ifdef CONFIG_NUMA
80302 /*
80303 * set_policy() op must add a reference to any non-NULL @new mempolicy
80304 @@ -268,6 +273,7 @@ struct vm_operations_struct {
80305 int (*remap_pages)(struct vm_area_struct *vma, unsigned long addr,
80306 unsigned long size, pgoff_t pgoff);
80307 };
80308 +typedef struct vm_operations_struct __no_const vm_operations_struct_no_const;
80309
80310 struct mmu_gather;
80311 struct inode;
80312 @@ -1133,8 +1139,8 @@ int follow_pfn(struct vm_area_struct *vma, unsigned long address,
80313 unsigned long *pfn);
80314 int follow_phys(struct vm_area_struct *vma, unsigned long address,
80315 unsigned int flags, unsigned long *prot, resource_size_t *phys);
80316 -int generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
80317 - void *buf, int len, int write);
80318 +ssize_t generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
80319 + void *buf, size_t len, int write);
80320
80321 static inline void unmap_shared_mapping_range(struct address_space *mapping,
80322 loff_t const holebegin, loff_t const holelen)
80323 @@ -1173,9 +1179,9 @@ static inline int fixup_user_fault(struct task_struct *tsk,
80324 }
80325 #endif
80326
80327 -extern int access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, int len, int write);
80328 -extern int access_remote_vm(struct mm_struct *mm, unsigned long addr,
80329 - void *buf, int len, int write);
80330 +extern ssize_t access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, size_t len, int write);
80331 +extern ssize_t access_remote_vm(struct mm_struct *mm, unsigned long addr,
80332 + void *buf, size_t len, int write);
80333
80334 long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
80335 unsigned long start, unsigned long nr_pages,
80336 @@ -1208,34 +1214,6 @@ int set_page_dirty_lock(struct page *page);
80337 int clear_page_dirty_for_io(struct page *page);
80338 int get_cmdline(struct task_struct *task, char *buffer, int buflen);
80339
80340 -/* Is the vma a continuation of the stack vma above it? */
80341 -static inline int vma_growsdown(struct vm_area_struct *vma, unsigned long addr)
80342 -{
80343 - return vma && (vma->vm_end == addr) && (vma->vm_flags & VM_GROWSDOWN);
80344 -}
80345 -
80346 -static inline int stack_guard_page_start(struct vm_area_struct *vma,
80347 - unsigned long addr)
80348 -{
80349 - return (vma->vm_flags & VM_GROWSDOWN) &&
80350 - (vma->vm_start == addr) &&
80351 - !vma_growsdown(vma->vm_prev, addr);
80352 -}
80353 -
80354 -/* Is the vma a continuation of the stack vma below it? */
80355 -static inline int vma_growsup(struct vm_area_struct *vma, unsigned long addr)
80356 -{
80357 - return vma && (vma->vm_start == addr) && (vma->vm_flags & VM_GROWSUP);
80358 -}
80359 -
80360 -static inline int stack_guard_page_end(struct vm_area_struct *vma,
80361 - unsigned long addr)
80362 -{
80363 - return (vma->vm_flags & VM_GROWSUP) &&
80364 - (vma->vm_end == addr) &&
80365 - !vma_growsup(vma->vm_next, addr);
80366 -}
80367 -
80368 extern pid_t
80369 vm_is_stack(struct task_struct *task, struct vm_area_struct *vma, int in_group);
80370
80371 @@ -1335,6 +1313,15 @@ static inline void sync_mm_rss(struct mm_struct *mm)
80372 }
80373 #endif
80374
80375 +#ifdef CONFIG_MMU
80376 +pgprot_t vm_get_page_prot(vm_flags_t vm_flags);
80377 +#else
80378 +static inline pgprot_t vm_get_page_prot(vm_flags_t vm_flags)
80379 +{
80380 + return __pgprot(0);
80381 +}
80382 +#endif
80383 +
80384 int vma_wants_writenotify(struct vm_area_struct *vma);
80385
80386 extern pte_t *__get_locked_pte(struct mm_struct *mm, unsigned long addr,
80387 @@ -1353,8 +1340,15 @@ static inline int __pud_alloc(struct mm_struct *mm, pgd_t *pgd,
80388 {
80389 return 0;
80390 }
80391 +
80392 +static inline int __pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd,
80393 + unsigned long address)
80394 +{
80395 + return 0;
80396 +}
80397 #else
80398 int __pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long address);
80399 +int __pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd, unsigned long address);
80400 #endif
80401
80402 #ifdef __PAGETABLE_PMD_FOLDED
80403 @@ -1363,8 +1357,15 @@ static inline int __pmd_alloc(struct mm_struct *mm, pud_t *pud,
80404 {
80405 return 0;
80406 }
80407 +
80408 +static inline int __pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud,
80409 + unsigned long address)
80410 +{
80411 + return 0;
80412 +}
80413 #else
80414 int __pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address);
80415 +int __pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud, unsigned long address);
80416 #endif
80417
80418 int __pte_alloc(struct mm_struct *mm, struct vm_area_struct *vma,
80419 @@ -1382,11 +1383,23 @@ static inline pud_t *pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long a
80420 NULL: pud_offset(pgd, address);
80421 }
80422
80423 +static inline pud_t *pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
80424 +{
80425 + return (unlikely(pgd_none(*pgd)) && __pud_alloc_kernel(mm, pgd, address))?
80426 + NULL: pud_offset(pgd, address);
80427 +}
80428 +
80429 static inline pmd_t *pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address)
80430 {
80431 return (unlikely(pud_none(*pud)) && __pmd_alloc(mm, pud, address))?
80432 NULL: pmd_offset(pud, address);
80433 }
80434 +
80435 +static inline pmd_t *pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud, unsigned long address)
80436 +{
80437 + return (unlikely(pud_none(*pud)) && __pmd_alloc_kernel(mm, pud, address))?
80438 + NULL: pmd_offset(pud, address);
80439 +}
80440 #endif /* CONFIG_MMU && !__ARCH_HAS_4LEVEL_HACK */
80441
80442 #if USE_SPLIT_PTE_PTLOCKS
80443 @@ -1783,7 +1796,7 @@ extern int install_special_mapping(struct mm_struct *mm,
80444 unsigned long addr, unsigned long len,
80445 unsigned long flags, struct page **pages);
80446
80447 -extern unsigned long get_unmapped_area(struct file *, unsigned long, unsigned long, unsigned long, unsigned long);
80448 +extern unsigned long get_unmapped_area(struct file *, unsigned long, unsigned long, unsigned long, unsigned long) __intentional_overflow(-1);
80449
80450 extern unsigned long mmap_region(struct file *file, unsigned long addr,
80451 unsigned long len, vm_flags_t vm_flags, unsigned long pgoff);
80452 @@ -1791,6 +1804,7 @@ extern unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
80453 unsigned long len, unsigned long prot, unsigned long flags,
80454 unsigned long pgoff, unsigned long *populate);
80455 extern int do_munmap(struct mm_struct *, unsigned long, size_t);
80456 +extern int __do_munmap(struct mm_struct *, unsigned long, size_t);
80457
80458 #ifdef CONFIG_MMU
80459 extern int __mm_populate(unsigned long addr, unsigned long len,
80460 @@ -1819,10 +1833,11 @@ struct vm_unmapped_area_info {
80461 unsigned long high_limit;
80462 unsigned long align_mask;
80463 unsigned long align_offset;
80464 + unsigned long threadstack_offset;
80465 };
80466
80467 -extern unsigned long unmapped_area(struct vm_unmapped_area_info *info);
80468 -extern unsigned long unmapped_area_topdown(struct vm_unmapped_area_info *info);
80469 +extern unsigned long unmapped_area(const struct vm_unmapped_area_info *info);
80470 +extern unsigned long unmapped_area_topdown(const struct vm_unmapped_area_info *info);
80471
80472 /*
80473 * Search for an unmapped address range.
80474 @@ -1834,7 +1849,7 @@ extern unsigned long unmapped_area_topdown(struct vm_unmapped_area_info *info);
80475 * - satisfies (begin_addr & align_mask) == (align_offset & align_mask)
80476 */
80477 static inline unsigned long
80478 -vm_unmapped_area(struct vm_unmapped_area_info *info)
80479 +vm_unmapped_area(const struct vm_unmapped_area_info *info)
80480 {
80481 if (!(info->flags & VM_UNMAPPED_AREA_TOPDOWN))
80482 return unmapped_area(info);
80483 @@ -1896,6 +1911,10 @@ extern struct vm_area_struct * find_vma(struct mm_struct * mm, unsigned long add
80484 extern struct vm_area_struct * find_vma_prev(struct mm_struct * mm, unsigned long addr,
80485 struct vm_area_struct **pprev);
80486
80487 +extern struct vm_area_struct *pax_find_mirror_vma(struct vm_area_struct *vma);
80488 +extern __must_check long pax_mirror_vma(struct vm_area_struct *vma_m, struct vm_area_struct *vma);
80489 +extern void pax_mirror_file_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m, spinlock_t *ptl);
80490 +
80491 /* Look up the first VMA which intersects the interval start_addr..end_addr-1,
80492 NULL if none. Assume start_addr < end_addr. */
80493 static inline struct vm_area_struct * find_vma_intersection(struct mm_struct * mm, unsigned long start_addr, unsigned long end_addr)
80494 @@ -1924,15 +1943,6 @@ static inline struct vm_area_struct *find_exact_vma(struct mm_struct *mm,
80495 return vma;
80496 }
80497
80498 -#ifdef CONFIG_MMU
80499 -pgprot_t vm_get_page_prot(unsigned long vm_flags);
80500 -#else
80501 -static inline pgprot_t vm_get_page_prot(unsigned long vm_flags)
80502 -{
80503 - return __pgprot(0);
80504 -}
80505 -#endif
80506 -
80507 #ifdef CONFIG_NUMA_BALANCING
80508 unsigned long change_prot_numa(struct vm_area_struct *vma,
80509 unsigned long start, unsigned long end);
80510 @@ -1984,6 +1994,11 @@ void vm_stat_account(struct mm_struct *, unsigned long, struct file *, long);
80511 static inline void vm_stat_account(struct mm_struct *mm,
80512 unsigned long flags, struct file *file, long pages)
80513 {
80514 +
80515 +#ifdef CONFIG_PAX_RANDMMAP
80516 + if (!(mm->pax_flags & MF_PAX_RANDMMAP) || (flags & (VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)))
80517 +#endif
80518 +
80519 mm->total_vm += pages;
80520 }
80521 #endif /* CONFIG_PROC_FS */
80522 @@ -2065,7 +2080,7 @@ extern int unpoison_memory(unsigned long pfn);
80523 extern int sysctl_memory_failure_early_kill;
80524 extern int sysctl_memory_failure_recovery;
80525 extern void shake_page(struct page *p, int access);
80526 -extern atomic_long_t num_poisoned_pages;
80527 +extern atomic_long_unchecked_t num_poisoned_pages;
80528 extern int soft_offline_page(struct page *page, int flags);
80529
80530 #if defined(CONFIG_TRANSPARENT_HUGEPAGE) || defined(CONFIG_HUGETLBFS)
80531 @@ -2100,5 +2115,11 @@ void __init setup_nr_node_ids(void);
80532 static inline void setup_nr_node_ids(void) {}
80533 #endif
80534
80535 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
80536 +extern void track_exec_limit(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long prot);
80537 +#else
80538 +static inline void track_exec_limit(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long prot) {}
80539 +#endif
80540 +
80541 #endif /* __KERNEL__ */
80542 #endif /* _LINUX_MM_H */
80543 diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h
80544 index 8967e20..61f7900 100644
80545 --- a/include/linux/mm_types.h
80546 +++ b/include/linux/mm_types.h
80547 @@ -308,7 +308,9 @@ struct vm_area_struct {
80548 #ifdef CONFIG_NUMA
80549 struct mempolicy *vm_policy; /* NUMA policy for the VMA */
80550 #endif
80551 -};
80552 +
80553 + struct vm_area_struct *vm_mirror;/* PaX: mirror vma or NULL */
80554 +} __randomize_layout;
80555
80556 struct core_thread {
80557 struct task_struct *task;
80558 @@ -454,7 +456,25 @@ struct mm_struct {
80559 bool tlb_flush_pending;
80560 #endif
80561 struct uprobes_state uprobes_state;
80562 -};
80563 +
80564 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
80565 + unsigned long pax_flags;
80566 +#endif
80567 +
80568 +#ifdef CONFIG_PAX_DLRESOLVE
80569 + unsigned long call_dl_resolve;
80570 +#endif
80571 +
80572 +#if defined(CONFIG_PPC32) && defined(CONFIG_PAX_EMUSIGRT)
80573 + unsigned long call_syscall;
80574 +#endif
80575 +
80576 +#ifdef CONFIG_PAX_ASLR
80577 + unsigned long delta_mmap; /* randomized offset */
80578 + unsigned long delta_stack; /* randomized offset */
80579 +#endif
80580 +
80581 +} __randomize_layout;
80582
80583 static inline void mm_init_cpumask(struct mm_struct *mm)
80584 {
80585 diff --git a/include/linux/mmiotrace.h b/include/linux/mmiotrace.h
80586 index c5d5278..f0b68c8 100644
80587 --- a/include/linux/mmiotrace.h
80588 +++ b/include/linux/mmiotrace.h
80589 @@ -46,7 +46,7 @@ extern int kmmio_handler(struct pt_regs *regs, unsigned long addr);
80590 /* Called from ioremap.c */
80591 extern void mmiotrace_ioremap(resource_size_t offset, unsigned long size,
80592 void __iomem *addr);
80593 -extern void mmiotrace_iounmap(volatile void __iomem *addr);
80594 +extern void mmiotrace_iounmap(const volatile void __iomem *addr);
80595
80596 /* For anyone to insert markers. Remember trailing newline. */
80597 extern __printf(1, 2) int mmiotrace_printk(const char *fmt, ...);
80598 @@ -66,7 +66,7 @@ static inline void mmiotrace_ioremap(resource_size_t offset,
80599 {
80600 }
80601
80602 -static inline void mmiotrace_iounmap(volatile void __iomem *addr)
80603 +static inline void mmiotrace_iounmap(const volatile void __iomem *addr)
80604 {
80605 }
80606
80607 diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
80608 index fac5509..22a7710 100644
80609 --- a/include/linux/mmzone.h
80610 +++ b/include/linux/mmzone.h
80611 @@ -402,7 +402,7 @@ struct zone {
80612 unsigned long flags; /* zone flags, see below */
80613
80614 /* Zone statistics */
80615 - atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
80616 + atomic_long_unchecked_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
80617
80618 /*
80619 * The target ratio of ACTIVE_ANON to INACTIVE_ANON pages on
80620 diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h
80621 index 44eeef0..67ad116 100644
80622 --- a/include/linux/mod_devicetable.h
80623 +++ b/include/linux/mod_devicetable.h
80624 @@ -13,7 +13,7 @@
80625 typedef unsigned long kernel_ulong_t;
80626 #endif
80627
80628 -#define PCI_ANY_ID (~0)
80629 +#define PCI_ANY_ID ((__u16)~0)
80630
80631 struct pci_device_id {
80632 __u32 vendor, device; /* Vendor and device ID or PCI_ANY_ID*/
80633 @@ -139,7 +139,7 @@ struct usb_device_id {
80634 #define USB_DEVICE_ID_MATCH_INT_PROTOCOL 0x0200
80635 #define USB_DEVICE_ID_MATCH_INT_NUMBER 0x0400
80636
80637 -#define HID_ANY_ID (~0)
80638 +#define HID_ANY_ID (~0U)
80639 #define HID_BUS_ANY 0xffff
80640 #define HID_GROUP_ANY 0x0000
80641
80642 @@ -475,7 +475,7 @@ struct dmi_system_id {
80643 const char *ident;
80644 struct dmi_strmatch matches[4];
80645 void *driver_data;
80646 -};
80647 +} __do_const;
80648 /*
80649 * struct dmi_device_id appears during expansion of
80650 * "MODULE_DEVICE_TABLE(dmi, x)". Compiler doesn't look inside it
80651 diff --git a/include/linux/module.h b/include/linux/module.h
80652 index f520a76..5f898ef 100644
80653 --- a/include/linux/module.h
80654 +++ b/include/linux/module.h
80655 @@ -17,9 +17,11 @@
80656 #include <linux/moduleparam.h>
80657 #include <linux/jump_label.h>
80658 #include <linux/export.h>
80659 +#include <linux/fs.h>
80660
80661 #include <linux/percpu.h>
80662 #include <asm/module.h>
80663 +#include <asm/pgtable.h>
80664
80665 /* In stripped ARM and x86-64 modules, ~ is surprisingly rare. */
80666 #define MODULE_SIG_STRING "~Module signature appended~\n"
80667 @@ -42,7 +44,7 @@ struct module_kobject {
80668 struct kobject *drivers_dir;
80669 struct module_param_attrs *mp;
80670 struct completion *kobj_completion;
80671 -};
80672 +} __randomize_layout;
80673
80674 struct module_attribute {
80675 struct attribute attr;
80676 @@ -54,12 +56,13 @@ struct module_attribute {
80677 int (*test)(struct module *);
80678 void (*free)(struct module *);
80679 };
80680 +typedef struct module_attribute __no_const module_attribute_no_const;
80681
80682 struct module_version_attribute {
80683 struct module_attribute mattr;
80684 const char *module_name;
80685 const char *version;
80686 -} __attribute__ ((__aligned__(sizeof(void *))));
80687 +} __do_const __attribute__ ((__aligned__(sizeof(void *))));
80688
80689 extern ssize_t __modver_version_show(struct module_attribute *,
80690 struct module_kobject *, char *);
80691 @@ -235,7 +238,7 @@ struct module {
80692
80693 /* Sysfs stuff. */
80694 struct module_kobject mkobj;
80695 - struct module_attribute *modinfo_attrs;
80696 + module_attribute_no_const *modinfo_attrs;
80697 const char *version;
80698 const char *srcversion;
80699 struct kobject *holders_dir;
80700 @@ -284,19 +287,16 @@ struct module {
80701 int (*init)(void);
80702
80703 /* If this is non-NULL, vfree after init() returns */
80704 - void *module_init;
80705 + void *module_init_rx, *module_init_rw;
80706
80707 /* Here is the actual code + data, vfree'd on unload. */
80708 - void *module_core;
80709 + void *module_core_rx, *module_core_rw;
80710
80711 /* Here are the sizes of the init and core sections */
80712 - unsigned int init_size, core_size;
80713 + unsigned int init_size_rw, core_size_rw;
80714
80715 /* The size of the executable code in each section. */
80716 - unsigned int init_text_size, core_text_size;
80717 -
80718 - /* Size of RO sections of the module (text+rodata) */
80719 - unsigned int init_ro_size, core_ro_size;
80720 + unsigned int init_size_rx, core_size_rx;
80721
80722 /* Arch-specific module values */
80723 struct mod_arch_specific arch;
80724 @@ -352,6 +352,10 @@ struct module {
80725 #ifdef CONFIG_EVENT_TRACING
80726 struct ftrace_event_call **trace_events;
80727 unsigned int num_trace_events;
80728 + struct file_operations trace_id;
80729 + struct file_operations trace_enable;
80730 + struct file_operations trace_format;
80731 + struct file_operations trace_filter;
80732 #endif
80733 #ifdef CONFIG_FTRACE_MCOUNT_RECORD
80734 unsigned int num_ftrace_callsites;
80735 @@ -375,7 +379,7 @@ struct module {
80736 ctor_fn_t *ctors;
80737 unsigned int num_ctors;
80738 #endif
80739 -};
80740 +} __randomize_layout;
80741 #ifndef MODULE_ARCH_INIT
80742 #define MODULE_ARCH_INIT {}
80743 #endif
80744 @@ -396,16 +400,46 @@ bool is_module_address(unsigned long addr);
80745 bool is_module_percpu_address(unsigned long addr);
80746 bool is_module_text_address(unsigned long addr);
80747
80748 +static inline int within_module_range(unsigned long addr, void *start, unsigned long size)
80749 +{
80750 +
80751 +#ifdef CONFIG_PAX_KERNEXEC
80752 + if (ktla_ktva(addr) >= (unsigned long)start &&
80753 + ktla_ktva(addr) < (unsigned long)start + size)
80754 + return 1;
80755 +#endif
80756 +
80757 + return ((void *)addr >= start && (void *)addr < start + size);
80758 +}
80759 +
80760 +static inline int within_module_core_rx(unsigned long addr, const struct module *mod)
80761 +{
80762 + return within_module_range(addr, mod->module_core_rx, mod->core_size_rx);
80763 +}
80764 +
80765 +static inline int within_module_core_rw(unsigned long addr, const struct module *mod)
80766 +{
80767 + return within_module_range(addr, mod->module_core_rw, mod->core_size_rw);
80768 +}
80769 +
80770 +static inline int within_module_init_rx(unsigned long addr, const struct module *mod)
80771 +{
80772 + return within_module_range(addr, mod->module_init_rx, mod->init_size_rx);
80773 +}
80774 +
80775 +static inline int within_module_init_rw(unsigned long addr, const struct module *mod)
80776 +{
80777 + return within_module_range(addr, mod->module_init_rw, mod->init_size_rw);
80778 +}
80779 +
80780 static inline int within_module_core(unsigned long addr, const struct module *mod)
80781 {
80782 - return (unsigned long)mod->module_core <= addr &&
80783 - addr < (unsigned long)mod->module_core + mod->core_size;
80784 + return within_module_core_rx(addr, mod) || within_module_core_rw(addr, mod);
80785 }
80786
80787 static inline int within_module_init(unsigned long addr, const struct module *mod)
80788 {
80789 - return (unsigned long)mod->module_init <= addr &&
80790 - addr < (unsigned long)mod->module_init + mod->init_size;
80791 + return within_module_init_rx(addr, mod) || within_module_init_rw(addr, mod);
80792 }
80793
80794 /* Search for module by name: must hold module_mutex. */
80795 diff --git a/include/linux/moduleloader.h b/include/linux/moduleloader.h
80796 index 560ca53..ef621ef 100644
80797 --- a/include/linux/moduleloader.h
80798 +++ b/include/linux/moduleloader.h
80799 @@ -25,9 +25,21 @@ unsigned int arch_mod_section_prepend(struct module *mod, unsigned int section);
80800 sections. Returns NULL on failure. */
80801 void *module_alloc(unsigned long size);
80802
80803 +#ifdef CONFIG_PAX_KERNEXEC
80804 +void *module_alloc_exec(unsigned long size);
80805 +#else
80806 +#define module_alloc_exec(x) module_alloc(x)
80807 +#endif
80808 +
80809 /* Free memory returned from module_alloc. */
80810 void module_free(struct module *mod, void *module_region);
80811
80812 +#ifdef CONFIG_PAX_KERNEXEC
80813 +void module_free_exec(struct module *mod, void *module_region);
80814 +#else
80815 +#define module_free_exec(x, y) module_free((x), (y))
80816 +#endif
80817 +
80818 /*
80819 * Apply the given relocation to the (simplified) ELF. Return -error
80820 * or 0.
80821 @@ -45,7 +57,9 @@ static inline int apply_relocate(Elf_Shdr *sechdrs,
80822 unsigned int relsec,
80823 struct module *me)
80824 {
80825 +#ifdef CONFIG_MODULES
80826 printk(KERN_ERR "module %s: REL relocation unsupported\n", me->name);
80827 +#endif
80828 return -ENOEXEC;
80829 }
80830 #endif
80831 @@ -67,7 +81,9 @@ static inline int apply_relocate_add(Elf_Shdr *sechdrs,
80832 unsigned int relsec,
80833 struct module *me)
80834 {
80835 +#ifdef CONFIG_MODULES
80836 printk(KERN_ERR "module %s: REL relocation unsupported\n", me->name);
80837 +#endif
80838 return -ENOEXEC;
80839 }
80840 #endif
80841 diff --git a/include/linux/moduleparam.h b/include/linux/moduleparam.h
80842 index 204a677..e9b486a 100644
80843 --- a/include/linux/moduleparam.h
80844 +++ b/include/linux/moduleparam.h
80845 @@ -293,7 +293,7 @@ static inline void __kernel_param_unlock(void)
80846 * @len is usually just sizeof(string).
80847 */
80848 #define module_param_string(name, string, len, perm) \
80849 - static const struct kparam_string __param_string_##name \
80850 + static const struct kparam_string __param_string_##name __used \
80851 = { len, string }; \
80852 __module_param_call(MODULE_PARAM_PREFIX, name, \
80853 &param_ops_string, \
80854 @@ -432,7 +432,7 @@ extern int param_set_bint(const char *val, const struct kernel_param *kp);
80855 */
80856 #define module_param_array_named(name, array, type, nump, perm) \
80857 param_check_##type(name, &(array)[0]); \
80858 - static const struct kparam_array __param_arr_##name \
80859 + static const struct kparam_array __param_arr_##name __used \
80860 = { .max = ARRAY_SIZE(array), .num = nump, \
80861 .ops = &param_ops_##type, \
80862 .elemsize = sizeof(array[0]), .elem = array }; \
80863 diff --git a/include/linux/mount.h b/include/linux/mount.h
80864 index 839bac2..a96b37c 100644
80865 --- a/include/linux/mount.h
80866 +++ b/include/linux/mount.h
80867 @@ -59,7 +59,7 @@ struct vfsmount {
80868 struct dentry *mnt_root; /* root of the mounted tree */
80869 struct super_block *mnt_sb; /* pointer to superblock */
80870 int mnt_flags;
80871 -};
80872 +} __randomize_layout;
80873
80874 struct file; /* forward dec */
80875
80876 diff --git a/include/linux/namei.h b/include/linux/namei.h
80877 index 492de72..1bddcd4 100644
80878 --- a/include/linux/namei.h
80879 +++ b/include/linux/namei.h
80880 @@ -19,7 +19,7 @@ struct nameidata {
80881 unsigned seq, m_seq;
80882 int last_type;
80883 unsigned depth;
80884 - char *saved_names[MAX_NESTED_LINKS + 1];
80885 + const char *saved_names[MAX_NESTED_LINKS + 1];
80886 };
80887
80888 /*
80889 @@ -83,12 +83,12 @@ extern void unlock_rename(struct dentry *, struct dentry *);
80890
80891 extern void nd_jump_link(struct nameidata *nd, struct path *path);
80892
80893 -static inline void nd_set_link(struct nameidata *nd, char *path)
80894 +static inline void nd_set_link(struct nameidata *nd, const char *path)
80895 {
80896 nd->saved_names[nd->depth] = path;
80897 }
80898
80899 -static inline char *nd_get_link(struct nameidata *nd)
80900 +static inline const char *nd_get_link(const struct nameidata *nd)
80901 {
80902 return nd->saved_names[nd->depth];
80903 }
80904 diff --git a/include/linux/net.h b/include/linux/net.h
80905 index 17d8339..81656c0 100644
80906 --- a/include/linux/net.h
80907 +++ b/include/linux/net.h
80908 @@ -192,7 +192,7 @@ struct net_proto_family {
80909 int (*create)(struct net *net, struct socket *sock,
80910 int protocol, int kern);
80911 struct module *owner;
80912 -};
80913 +} __do_const;
80914
80915 struct iovec;
80916 struct kvec;
80917 diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
80918 index b42d07b..7f45ae2 100644
80919 --- a/include/linux/netdevice.h
80920 +++ b/include/linux/netdevice.h
80921 @@ -1146,6 +1146,7 @@ struct net_device_ops {
80922 void *priv);
80923 int (*ndo_get_lock_subclass)(struct net_device *dev);
80924 };
80925 +typedef struct net_device_ops __no_const net_device_ops_no_const;
80926
80927 /**
80928 * enum net_device_priv_flags - &struct net_device priv_flags
80929 @@ -1313,11 +1314,11 @@ struct net_device {
80930 struct net_device_stats stats;
80931
80932 /* dropped packets by core network, Do not use this in drivers */
80933 - atomic_long_t rx_dropped;
80934 - atomic_long_t tx_dropped;
80935 + atomic_long_unchecked_t rx_dropped;
80936 + atomic_long_unchecked_t tx_dropped;
80937
80938 /* Stats to monitor carrier on<->off transitions */
80939 - atomic_t carrier_changes;
80940 + atomic_unchecked_t carrier_changes;
80941
80942 #ifdef CONFIG_WIRELESS_EXT
80943 /* List of functions to handle Wireless Extensions (instead of ioctl).
80944 diff --git a/include/linux/netfilter.h b/include/linux/netfilter.h
80945 index 2077489..a15e561 100644
80946 --- a/include/linux/netfilter.h
80947 +++ b/include/linux/netfilter.h
80948 @@ -84,7 +84,7 @@ struct nf_sockopt_ops {
80949 #endif
80950 /* Use the module struct to lock set/get code in place */
80951 struct module *owner;
80952 -};
80953 +} __do_const;
80954
80955 /* Function to register/unregister hook points. */
80956 int nf_register_hook(struct nf_hook_ops *reg);
80957 diff --git a/include/linux/netfilter/nfnetlink.h b/include/linux/netfilter/nfnetlink.h
80958 index e955d47..04a5338 100644
80959 --- a/include/linux/netfilter/nfnetlink.h
80960 +++ b/include/linux/netfilter/nfnetlink.h
80961 @@ -19,7 +19,7 @@ struct nfnl_callback {
80962 const struct nlattr * const cda[]);
80963 const struct nla_policy *policy; /* netlink attribute policy */
80964 const u_int16_t attr_count; /* number of nlattr's */
80965 -};
80966 +} __do_const;
80967
80968 struct nfnetlink_subsystem {
80969 const char *name;
80970 diff --git a/include/linux/netfilter/xt_gradm.h b/include/linux/netfilter/xt_gradm.h
80971 new file mode 100644
80972 index 0000000..33f4af8
80973 --- /dev/null
80974 +++ b/include/linux/netfilter/xt_gradm.h
80975 @@ -0,0 +1,9 @@
80976 +#ifndef _LINUX_NETFILTER_XT_GRADM_H
80977 +#define _LINUX_NETFILTER_XT_GRADM_H 1
80978 +
80979 +struct xt_gradm_mtinfo {
80980 + __u16 flags;
80981 + __u16 invflags;
80982 +};
80983 +
80984 +#endif
80985 diff --git a/include/linux/nls.h b/include/linux/nls.h
80986 index 520681b..1d67ed2 100644
80987 --- a/include/linux/nls.h
80988 +++ b/include/linux/nls.h
80989 @@ -31,7 +31,7 @@ struct nls_table {
80990 const unsigned char *charset2upper;
80991 struct module *owner;
80992 struct nls_table *next;
80993 -};
80994 +} __do_const;
80995
80996 /* this value hold the maximum octet of charset */
80997 #define NLS_MAX_CHARSET_SIZE 6 /* for UTF-8 */
80998 diff --git a/include/linux/notifier.h b/include/linux/notifier.h
80999 index d14a4c3..a078786 100644
81000 --- a/include/linux/notifier.h
81001 +++ b/include/linux/notifier.h
81002 @@ -54,7 +54,8 @@ struct notifier_block {
81003 notifier_fn_t notifier_call;
81004 struct notifier_block __rcu *next;
81005 int priority;
81006 -};
81007 +} __do_const;
81008 +typedef struct notifier_block __no_const notifier_block_no_const;
81009
81010 struct atomic_notifier_head {
81011 spinlock_t lock;
81012 diff --git a/include/linux/oprofile.h b/include/linux/oprofile.h
81013 index b2a0f15..4d7da32 100644
81014 --- a/include/linux/oprofile.h
81015 +++ b/include/linux/oprofile.h
81016 @@ -138,9 +138,9 @@ int oprofilefs_create_ulong(struct dentry * root,
81017 int oprofilefs_create_ro_ulong(struct dentry * root,
81018 char const * name, ulong * val);
81019
81020 -/** Create a file for read-only access to an atomic_t. */
81021 +/** Create a file for read-only access to an atomic_unchecked_t. */
81022 int oprofilefs_create_ro_atomic(struct dentry * root,
81023 - char const * name, atomic_t * val);
81024 + char const * name, atomic_unchecked_t * val);
81025
81026 /** create a directory */
81027 struct dentry *oprofilefs_mkdir(struct dentry *parent, char const *name);
81028 diff --git a/include/linux/padata.h b/include/linux/padata.h
81029 index 4386946..f50c615 100644
81030 --- a/include/linux/padata.h
81031 +++ b/include/linux/padata.h
81032 @@ -129,7 +129,7 @@ struct parallel_data {
81033 struct padata_serial_queue __percpu *squeue;
81034 atomic_t reorder_objects;
81035 atomic_t refcnt;
81036 - atomic_t seq_nr;
81037 + atomic_unchecked_t seq_nr;
81038 struct padata_cpumask cpumask;
81039 spinlock_t lock ____cacheline_aligned;
81040 unsigned int processed;
81041 diff --git a/include/linux/path.h b/include/linux/path.h
81042 index d137218..be0c176 100644
81043 --- a/include/linux/path.h
81044 +++ b/include/linux/path.h
81045 @@ -1,13 +1,15 @@
81046 #ifndef _LINUX_PATH_H
81047 #define _LINUX_PATH_H
81048
81049 +#include <linux/compiler.h>
81050 +
81051 struct dentry;
81052 struct vfsmount;
81053
81054 struct path {
81055 struct vfsmount *mnt;
81056 struct dentry *dentry;
81057 -};
81058 +} __randomize_layout;
81059
81060 extern void path_get(const struct path *);
81061 extern void path_put(const struct path *);
81062 diff --git a/include/linux/pci_hotplug.h b/include/linux/pci_hotplug.h
81063 index 5f2e559..7d59314 100644
81064 --- a/include/linux/pci_hotplug.h
81065 +++ b/include/linux/pci_hotplug.h
81066 @@ -71,7 +71,8 @@ struct hotplug_slot_ops {
81067 int (*get_latch_status) (struct hotplug_slot *slot, u8 *value);
81068 int (*get_adapter_status) (struct hotplug_slot *slot, u8 *value);
81069 int (*reset_slot) (struct hotplug_slot *slot, int probe);
81070 -};
81071 +} __do_const;
81072 +typedef struct hotplug_slot_ops __no_const hotplug_slot_ops_no_const;
81073
81074 /**
81075 * struct hotplug_slot_info - used to notify the hotplug pci core of the state of the slot
81076 diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
81077 index 3ef6ea1..ed1a248 100644
81078 --- a/include/linux/perf_event.h
81079 +++ b/include/linux/perf_event.h
81080 @@ -328,8 +328,8 @@ struct perf_event {
81081
81082 enum perf_event_active_state state;
81083 unsigned int attach_state;
81084 - local64_t count;
81085 - atomic64_t child_count;
81086 + local64_t count; /* PaX: fix it one day */
81087 + atomic64_unchecked_t child_count;
81088
81089 /*
81090 * These are the total time in nanoseconds that the event
81091 @@ -380,8 +380,8 @@ struct perf_event {
81092 * These accumulate total time (in nanoseconds) that children
81093 * events have been enabled and running, respectively.
81094 */
81095 - atomic64_t child_total_time_enabled;
81096 - atomic64_t child_total_time_running;
81097 + atomic64_unchecked_t child_total_time_enabled;
81098 + atomic64_unchecked_t child_total_time_running;
81099
81100 /*
81101 * Protect attach/detach and child_list:
81102 @@ -710,7 +710,7 @@ static inline void perf_callchain_store(struct perf_callchain_entry *entry, u64
81103 entry->ip[entry->nr++] = ip;
81104 }
81105
81106 -extern int sysctl_perf_event_paranoid;
81107 +extern int sysctl_perf_event_legitimately_concerned;
81108 extern int sysctl_perf_event_mlock;
81109 extern int sysctl_perf_event_sample_rate;
81110 extern int sysctl_perf_cpu_time_max_percent;
81111 @@ -725,19 +725,24 @@ extern int perf_cpu_time_max_percent_handler(struct ctl_table *table, int write,
81112 loff_t *ppos);
81113
81114
81115 +static inline bool perf_paranoid_any(void)
81116 +{
81117 + return sysctl_perf_event_legitimately_concerned > 2;
81118 +}
81119 +
81120 static inline bool perf_paranoid_tracepoint_raw(void)
81121 {
81122 - return sysctl_perf_event_paranoid > -1;
81123 + return sysctl_perf_event_legitimately_concerned > -1;
81124 }
81125
81126 static inline bool perf_paranoid_cpu(void)
81127 {
81128 - return sysctl_perf_event_paranoid > 0;
81129 + return sysctl_perf_event_legitimately_concerned > 0;
81130 }
81131
81132 static inline bool perf_paranoid_kernel(void)
81133 {
81134 - return sysctl_perf_event_paranoid > 1;
81135 + return sysctl_perf_event_legitimately_concerned > 1;
81136 }
81137
81138 extern void perf_event_init(void);
81139 @@ -867,7 +872,7 @@ struct perf_pmu_events_attr {
81140 struct device_attribute attr;
81141 u64 id;
81142 const char *event_str;
81143 -};
81144 +} __do_const;
81145
81146 #define PMU_EVENT_ATTR(_name, _var, _id, _show) \
81147 static struct perf_pmu_events_attr _var = { \
81148 diff --git a/include/linux/pid_namespace.h b/include/linux/pid_namespace.h
81149 index 7246ef3..1539ea4 100644
81150 --- a/include/linux/pid_namespace.h
81151 +++ b/include/linux/pid_namespace.h
81152 @@ -43,7 +43,7 @@ struct pid_namespace {
81153 int hide_pid;
81154 int reboot; /* group exit code if this pidns was rebooted */
81155 unsigned int proc_inum;
81156 -};
81157 +} __randomize_layout;
81158
81159 extern struct pid_namespace init_pid_ns;
81160
81161 diff --git a/include/linux/pipe_fs_i.h b/include/linux/pipe_fs_i.h
81162 index eb8b8ac..62649e1 100644
81163 --- a/include/linux/pipe_fs_i.h
81164 +++ b/include/linux/pipe_fs_i.h
81165 @@ -47,10 +47,10 @@ struct pipe_inode_info {
81166 struct mutex mutex;
81167 wait_queue_head_t wait;
81168 unsigned int nrbufs, curbuf, buffers;
81169 - unsigned int readers;
81170 - unsigned int writers;
81171 - unsigned int files;
81172 - unsigned int waiting_writers;
81173 + atomic_t readers;
81174 + atomic_t writers;
81175 + atomic_t files;
81176 + atomic_t waiting_writers;
81177 unsigned int r_counter;
81178 unsigned int w_counter;
81179 struct page *tmp_page;
81180 diff --git a/include/linux/pm.h b/include/linux/pm.h
81181 index d915d03..0531037 100644
81182 --- a/include/linux/pm.h
81183 +++ b/include/linux/pm.h
81184 @@ -600,6 +600,7 @@ extern int dev_pm_put_subsys_data(struct device *dev);
81185 struct dev_pm_domain {
81186 struct dev_pm_ops ops;
81187 };
81188 +typedef struct dev_pm_domain __no_const dev_pm_domain_no_const;
81189
81190 /*
81191 * The PM_EVENT_ messages are also used by drivers implementing the legacy
81192 diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h
81193 index 7c1d252..0e7061d 100644
81194 --- a/include/linux/pm_domain.h
81195 +++ b/include/linux/pm_domain.h
81196 @@ -44,11 +44,11 @@ struct gpd_dev_ops {
81197 int (*thaw_early)(struct device *dev);
81198 int (*thaw)(struct device *dev);
81199 bool (*active_wakeup)(struct device *dev);
81200 -};
81201 +} __no_const;
81202
81203 struct gpd_cpu_data {
81204 unsigned int saved_exit_latency;
81205 - struct cpuidle_state *idle_state;
81206 + cpuidle_state_no_const *idle_state;
81207 };
81208
81209 struct generic_pm_domain {
81210 diff --git a/include/linux/pm_runtime.h b/include/linux/pm_runtime.h
81211 index 2a5897a..4f9af63 100644
81212 --- a/include/linux/pm_runtime.h
81213 +++ b/include/linux/pm_runtime.h
81214 @@ -113,7 +113,7 @@ static inline bool pm_runtime_callbacks_present(struct device *dev)
81215
81216 static inline void pm_runtime_mark_last_busy(struct device *dev)
81217 {
81218 - ACCESS_ONCE(dev->power.last_busy) = jiffies;
81219 + ACCESS_ONCE_RW(dev->power.last_busy) = jiffies;
81220 }
81221
81222 #else /* !CONFIG_PM_RUNTIME */
81223 diff --git a/include/linux/pnp.h b/include/linux/pnp.h
81224 index 195aafc..49a7bc2 100644
81225 --- a/include/linux/pnp.h
81226 +++ b/include/linux/pnp.h
81227 @@ -297,7 +297,7 @@ static inline void pnp_set_drvdata(struct pnp_dev *pdev, void *data)
81228 struct pnp_fixup {
81229 char id[7];
81230 void (*quirk_function) (struct pnp_dev * dev); /* fixup function */
81231 -};
81232 +} __do_const;
81233
81234 /* config parameters */
81235 #define PNP_CONFIG_NORMAL 0x0001
81236 diff --git a/include/linux/poison.h b/include/linux/poison.h
81237 index 2110a81..13a11bb 100644
81238 --- a/include/linux/poison.h
81239 +++ b/include/linux/poison.h
81240 @@ -19,8 +19,8 @@
81241 * under normal circumstances, used to verify that nobody uses
81242 * non-initialized list entries.
81243 */
81244 -#define LIST_POISON1 ((void *) 0x00100100 + POISON_POINTER_DELTA)
81245 -#define LIST_POISON2 ((void *) 0x00200200 + POISON_POINTER_DELTA)
81246 +#define LIST_POISON1 ((void *) (long)0xFFFFFF01)
81247 +#define LIST_POISON2 ((void *) (long)0xFFFFFF02)
81248
81249 /********** include/linux/timer.h **********/
81250 /*
81251 diff --git a/include/linux/power/smartreflex.h b/include/linux/power/smartreflex.h
81252 index d8b187c3..9a9257a 100644
81253 --- a/include/linux/power/smartreflex.h
81254 +++ b/include/linux/power/smartreflex.h
81255 @@ -238,7 +238,7 @@ struct omap_sr_class_data {
81256 int (*notify)(struct omap_sr *sr, u32 status);
81257 u8 notify_flags;
81258 u8 class_type;
81259 -};
81260 +} __do_const;
81261
81262 /**
81263 * struct omap_sr_nvalue_table - Smartreflex n-target value info
81264 diff --git a/include/linux/ppp-comp.h b/include/linux/ppp-comp.h
81265 index 4ea1d37..80f4b33 100644
81266 --- a/include/linux/ppp-comp.h
81267 +++ b/include/linux/ppp-comp.h
81268 @@ -84,7 +84,7 @@ struct compressor {
81269 struct module *owner;
81270 /* Extra skb space needed by the compressor algorithm */
81271 unsigned int comp_extra;
81272 -};
81273 +} __do_const;
81274
81275 /*
81276 * The return value from decompress routine is the length of the
81277 diff --git a/include/linux/preempt.h b/include/linux/preempt.h
81278 index de83b4e..c4b997d 100644
81279 --- a/include/linux/preempt.h
81280 +++ b/include/linux/preempt.h
81281 @@ -27,11 +27,16 @@ extern void preempt_count_sub(int val);
81282 #define preempt_count_dec_and_test() __preempt_count_dec_and_test()
81283 #endif
81284
81285 +#define raw_preempt_count_add(val) __preempt_count_add(val)
81286 +#define raw_preempt_count_sub(val) __preempt_count_sub(val)
81287 +
81288 #define __preempt_count_inc() __preempt_count_add(1)
81289 #define __preempt_count_dec() __preempt_count_sub(1)
81290
81291 #define preempt_count_inc() preempt_count_add(1)
81292 +#define raw_preempt_count_inc() raw_preempt_count_add(1)
81293 #define preempt_count_dec() preempt_count_sub(1)
81294 +#define raw_preempt_count_dec() raw_preempt_count_sub(1)
81295
81296 #ifdef CONFIG_PREEMPT_COUNT
81297
81298 @@ -41,6 +46,12 @@ do { \
81299 barrier(); \
81300 } while (0)
81301
81302 +#define raw_preempt_disable() \
81303 +do { \
81304 + raw_preempt_count_inc(); \
81305 + barrier(); \
81306 +} while (0)
81307 +
81308 #define sched_preempt_enable_no_resched() \
81309 do { \
81310 barrier(); \
81311 @@ -49,6 +60,12 @@ do { \
81312
81313 #define preempt_enable_no_resched() sched_preempt_enable_no_resched()
81314
81315 +#define raw_preempt_enable_no_resched() \
81316 +do { \
81317 + barrier(); \
81318 + raw_preempt_count_dec(); \
81319 +} while (0)
81320 +
81321 #ifdef CONFIG_PREEMPT
81322 #define preempt_enable() \
81323 do { \
81324 @@ -113,8 +130,10 @@ do { \
81325 * region.
81326 */
81327 #define preempt_disable() barrier()
81328 +#define raw_preempt_disable() barrier()
81329 #define sched_preempt_enable_no_resched() barrier()
81330 #define preempt_enable_no_resched() barrier()
81331 +#define raw_preempt_enable_no_resched() barrier()
81332 #define preempt_enable() barrier()
81333 #define preempt_check_resched() do { } while (0)
81334
81335 @@ -128,11 +147,13 @@ do { \
81336 /*
81337 * Modules have no business playing preemption tricks.
81338 */
81339 +#ifndef CONFIG_PAX_KERNEXEC
81340 #undef sched_preempt_enable_no_resched
81341 #undef preempt_enable_no_resched
81342 #undef preempt_enable_no_resched_notrace
81343 #undef preempt_check_resched
81344 #endif
81345 +#endif
81346
81347 #define preempt_set_need_resched() \
81348 do { \
81349 diff --git a/include/linux/printk.h b/include/linux/printk.h
81350 index 8752f75..2b80c0f 100644
81351 --- a/include/linux/printk.h
81352 +++ b/include/linux/printk.h
81353 @@ -110,6 +110,8 @@ static inline __printf(1, 2) __cold
81354 void early_printk(const char *s, ...) { }
81355 #endif
81356
81357 +extern int kptr_restrict;
81358 +
81359 #ifdef CONFIG_PRINTK
81360 asmlinkage __printf(5, 0)
81361 int vprintk_emit(int facility, int level,
81362 @@ -144,7 +146,6 @@ extern bool printk_timed_ratelimit(unsigned long *caller_jiffies,
81363
81364 extern int printk_delay_msec;
81365 extern int dmesg_restrict;
81366 -extern int kptr_restrict;
81367
81368 extern void wake_up_klogd(void);
81369
81370 diff --git a/include/linux/proc_fs.h b/include/linux/proc_fs.h
81371 index 608e60a..79cfb18 100644
81372 --- a/include/linux/proc_fs.h
81373 +++ b/include/linux/proc_fs.h
81374 @@ -17,8 +17,11 @@ extern void proc_flush_task(struct task_struct *);
81375 extern struct proc_dir_entry *proc_symlink(const char *,
81376 struct proc_dir_entry *, const char *);
81377 extern struct proc_dir_entry *proc_mkdir(const char *, struct proc_dir_entry *);
81378 +extern struct proc_dir_entry *proc_mkdir_restrict(const char *, struct proc_dir_entry *);
81379 extern struct proc_dir_entry *proc_mkdir_data(const char *, umode_t,
81380 struct proc_dir_entry *, void *);
81381 +extern struct proc_dir_entry *proc_mkdir_data_restrict(const char *, umode_t,
81382 + struct proc_dir_entry *, void *);
81383 extern struct proc_dir_entry *proc_mkdir_mode(const char *, umode_t,
81384 struct proc_dir_entry *);
81385
81386 @@ -34,6 +37,19 @@ static inline struct proc_dir_entry *proc_create(
81387 return proc_create_data(name, mode, parent, proc_fops, NULL);
81388 }
81389
81390 +static inline struct proc_dir_entry *proc_create_grsec(const char *name, umode_t mode,
81391 + struct proc_dir_entry *parent, const struct file_operations *proc_fops)
81392 +{
81393 +#ifdef CONFIG_GRKERNSEC_PROC_USER
81394 + return proc_create_data(name, S_IRUSR, parent, proc_fops, NULL);
81395 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
81396 + return proc_create_data(name, S_IRUSR | S_IRGRP, parent, proc_fops, NULL);
81397 +#else
81398 + return proc_create_data(name, mode, parent, proc_fops, NULL);
81399 +#endif
81400 +}
81401 +
81402 +
81403 extern void proc_set_size(struct proc_dir_entry *, loff_t);
81404 extern void proc_set_user(struct proc_dir_entry *, kuid_t, kgid_t);
81405 extern void *PDE_DATA(const struct inode *);
81406 @@ -52,8 +68,12 @@ static inline struct proc_dir_entry *proc_symlink(const char *name,
81407 struct proc_dir_entry *parent,const char *dest) { return NULL;}
81408 static inline struct proc_dir_entry *proc_mkdir(const char *name,
81409 struct proc_dir_entry *parent) {return NULL;}
81410 +static inline struct proc_dir_entry *proc_mkdir_restrict(const char *name,
81411 + struct proc_dir_entry *parent) { return NULL; }
81412 static inline struct proc_dir_entry *proc_mkdir_data(const char *name,
81413 umode_t mode, struct proc_dir_entry *parent, void *data) { return NULL; }
81414 +static inline struct proc_dir_entry *proc_mkdir_data_restrict(const char *name,
81415 + umode_t mode, struct proc_dir_entry *parent, void *data) { return NULL; }
81416 static inline struct proc_dir_entry *proc_mkdir_mode(const char *name,
81417 umode_t mode, struct proc_dir_entry *parent) { return NULL; }
81418 #define proc_create(name, mode, parent, proc_fops) ({NULL;})
81419 @@ -73,7 +93,7 @@ static inline int remove_proc_subtree(const char *name, struct proc_dir_entry *p
81420 static inline struct proc_dir_entry *proc_net_mkdir(
81421 struct net *net, const char *name, struct proc_dir_entry *parent)
81422 {
81423 - return proc_mkdir_data(name, 0, parent, net);
81424 + return proc_mkdir_data_restrict(name, 0, parent, net);
81425 }
81426
81427 #endif /* _LINUX_PROC_FS_H */
81428 diff --git a/include/linux/proc_ns.h b/include/linux/proc_ns.h
81429 index 34a1e10..70f6bde 100644
81430 --- a/include/linux/proc_ns.h
81431 +++ b/include/linux/proc_ns.h
81432 @@ -14,7 +14,7 @@ struct proc_ns_operations {
81433 void (*put)(void *ns);
81434 int (*install)(struct nsproxy *nsproxy, void *ns);
81435 unsigned int (*inum)(void *ns);
81436 -};
81437 +} __do_const __randomize_layout;
81438
81439 struct proc_ns {
81440 void *ns;
81441 diff --git a/include/linux/quota.h b/include/linux/quota.h
81442 index cc7494a..1e27036 100644
81443 --- a/include/linux/quota.h
81444 +++ b/include/linux/quota.h
81445 @@ -70,7 +70,7 @@ struct kqid { /* Type in which we store the quota identifier */
81446
81447 extern bool qid_eq(struct kqid left, struct kqid right);
81448 extern bool qid_lt(struct kqid left, struct kqid right);
81449 -extern qid_t from_kqid(struct user_namespace *to, struct kqid qid);
81450 +extern qid_t from_kqid(struct user_namespace *to, struct kqid qid) __intentional_overflow(-1);
81451 extern qid_t from_kqid_munged(struct user_namespace *to, struct kqid qid);
81452 extern bool qid_valid(struct kqid qid);
81453
81454 diff --git a/include/linux/random.h b/include/linux/random.h
81455 index 57fbbff..2331f3f 100644
81456 --- a/include/linux/random.h
81457 +++ b/include/linux/random.h
81458 @@ -9,9 +9,19 @@
81459 #include <uapi/linux/random.h>
81460
81461 extern void add_device_randomness(const void *, unsigned int);
81462 +
81463 +static inline void add_latent_entropy(void)
81464 +{
81465 +
81466 +#ifdef LATENT_ENTROPY_PLUGIN
81467 + add_device_randomness((const void *)&latent_entropy, sizeof(latent_entropy));
81468 +#endif
81469 +
81470 +}
81471 +
81472 extern void add_input_randomness(unsigned int type, unsigned int code,
81473 - unsigned int value);
81474 -extern void add_interrupt_randomness(int irq, int irq_flags);
81475 + unsigned int value) __latent_entropy;
81476 +extern void add_interrupt_randomness(int irq, int irq_flags) __latent_entropy;
81477
81478 extern void get_random_bytes(void *buf, int nbytes);
81479 extern void get_random_bytes_arch(void *buf, int nbytes);
81480 @@ -22,10 +32,10 @@ extern int random_int_secret_init(void);
81481 extern const struct file_operations random_fops, urandom_fops;
81482 #endif
81483
81484 -unsigned int get_random_int(void);
81485 +unsigned int __intentional_overflow(-1) get_random_int(void);
81486 unsigned long randomize_range(unsigned long start, unsigned long end, unsigned long len);
81487
81488 -u32 prandom_u32(void);
81489 +u32 prandom_u32(void) __intentional_overflow(-1);
81490 void prandom_bytes(void *buf, int nbytes);
81491 void prandom_seed(u32 seed);
81492 void prandom_reseed_late(void);
81493 @@ -37,6 +47,11 @@ struct rnd_state {
81494 u32 prandom_u32_state(struct rnd_state *state);
81495 void prandom_bytes_state(struct rnd_state *state, void *buf, int nbytes);
81496
81497 +static inline unsigned long __intentional_overflow(-1) pax_get_random_long(void)
81498 +{
81499 + return prandom_u32() + (sizeof(long) > 4 ? (unsigned long)prandom_u32() << 32 : 0);
81500 +}
81501 +
81502 /**
81503 * prandom_u32_max - returns a pseudo-random number in interval [0, ep_ro)
81504 * @ep_ro: right open interval endpoint
81505 diff --git a/include/linux/rbtree_augmented.h b/include/linux/rbtree_augmented.h
81506 index fea49b5..2ac22bb 100644
81507 --- a/include/linux/rbtree_augmented.h
81508 +++ b/include/linux/rbtree_augmented.h
81509 @@ -80,7 +80,9 @@ rbname ## _rotate(struct rb_node *rb_old, struct rb_node *rb_new) \
81510 old->rbaugmented = rbcompute(old); \
81511 } \
81512 rbstatic const struct rb_augment_callbacks rbname = { \
81513 - rbname ## _propagate, rbname ## _copy, rbname ## _rotate \
81514 + .propagate = rbname ## _propagate, \
81515 + .copy = rbname ## _copy, \
81516 + .rotate = rbname ## _rotate \
81517 };
81518
81519
81520 diff --git a/include/linux/rculist.h b/include/linux/rculist.h
81521 index 8183b46..a388711 100644
81522 --- a/include/linux/rculist.h
81523 +++ b/include/linux/rculist.h
81524 @@ -29,8 +29,8 @@
81525 */
81526 static inline void INIT_LIST_HEAD_RCU(struct list_head *list)
81527 {
81528 - ACCESS_ONCE(list->next) = list;
81529 - ACCESS_ONCE(list->prev) = list;
81530 + ACCESS_ONCE_RW(list->next) = list;
81531 + ACCESS_ONCE_RW(list->prev) = list;
81532 }
81533
81534 /*
81535 @@ -59,6 +59,9 @@ void __list_add_rcu(struct list_head *new,
81536 struct list_head *prev, struct list_head *next);
81537 #endif
81538
81539 +void __pax_list_add_rcu(struct list_head *new,
81540 + struct list_head *prev, struct list_head *next);
81541 +
81542 /**
81543 * list_add_rcu - add a new entry to rcu-protected list
81544 * @new: new entry to be added
81545 @@ -80,6 +83,11 @@ static inline void list_add_rcu(struct list_head *new, struct list_head *head)
81546 __list_add_rcu(new, head, head->next);
81547 }
81548
81549 +static inline void pax_list_add_rcu(struct list_head *new, struct list_head *head)
81550 +{
81551 + __pax_list_add_rcu(new, head, head->next);
81552 +}
81553 +
81554 /**
81555 * list_add_tail_rcu - add a new entry to rcu-protected list
81556 * @new: new entry to be added
81557 @@ -102,6 +110,12 @@ static inline void list_add_tail_rcu(struct list_head *new,
81558 __list_add_rcu(new, head->prev, head);
81559 }
81560
81561 +static inline void pax_list_add_tail_rcu(struct list_head *new,
81562 + struct list_head *head)
81563 +{
81564 + __pax_list_add_rcu(new, head->prev, head);
81565 +}
81566 +
81567 /**
81568 * list_del_rcu - deletes entry from list without re-initialization
81569 * @entry: the element to delete from the list.
81570 @@ -132,6 +146,8 @@ static inline void list_del_rcu(struct list_head *entry)
81571 entry->prev = LIST_POISON2;
81572 }
81573
81574 +extern void pax_list_del_rcu(struct list_head *entry);
81575 +
81576 /**
81577 * hlist_del_init_rcu - deletes entry from hash list with re-initialization
81578 * @n: the element to delete from the hash list.
81579 diff --git a/include/linux/reboot.h b/include/linux/reboot.h
81580 index 48bf152..d38b785 100644
81581 --- a/include/linux/reboot.h
81582 +++ b/include/linux/reboot.h
81583 @@ -44,9 +44,9 @@ extern int unregister_reboot_notifier(struct notifier_block *);
81584 */
81585
81586 extern void migrate_to_reboot_cpu(void);
81587 -extern void machine_restart(char *cmd);
81588 -extern void machine_halt(void);
81589 -extern void machine_power_off(void);
81590 +extern void machine_restart(char *cmd) __noreturn;
81591 +extern void machine_halt(void) __noreturn;
81592 +extern void machine_power_off(void) __noreturn;
81593
81594 extern void machine_shutdown(void);
81595 struct pt_regs;
81596 @@ -57,9 +57,9 @@ extern void machine_crash_shutdown(struct pt_regs *);
81597 */
81598
81599 extern void kernel_restart_prepare(char *cmd);
81600 -extern void kernel_restart(char *cmd);
81601 -extern void kernel_halt(void);
81602 -extern void kernel_power_off(void);
81603 +extern void kernel_restart(char *cmd) __noreturn;
81604 +extern void kernel_halt(void) __noreturn;
81605 +extern void kernel_power_off(void) __noreturn;
81606
81607 extern int C_A_D; /* for sysctl */
81608 void ctrl_alt_del(void);
81609 @@ -73,7 +73,7 @@ extern int orderly_poweroff(bool force);
81610 * Emergency restart, callable from an interrupt handler.
81611 */
81612
81613 -extern void emergency_restart(void);
81614 +extern void emergency_restart(void) __noreturn;
81615 #include <asm/emergency-restart.h>
81616
81617 #endif /* _LINUX_REBOOT_H */
81618 diff --git a/include/linux/regset.h b/include/linux/regset.h
81619 index 8e0c9fe..ac4d221 100644
81620 --- a/include/linux/regset.h
81621 +++ b/include/linux/regset.h
81622 @@ -161,7 +161,8 @@ struct user_regset {
81623 unsigned int align;
81624 unsigned int bias;
81625 unsigned int core_note_type;
81626 -};
81627 +} __do_const;
81628 +typedef struct user_regset __no_const user_regset_no_const;
81629
81630 /**
81631 * struct user_regset_view - available regsets
81632 diff --git a/include/linux/relay.h b/include/linux/relay.h
81633 index d7c8359..818daf5 100644
81634 --- a/include/linux/relay.h
81635 +++ b/include/linux/relay.h
81636 @@ -157,7 +157,7 @@ struct rchan_callbacks
81637 * The callback should return 0 if successful, negative if not.
81638 */
81639 int (*remove_buf_file)(struct dentry *dentry);
81640 -};
81641 +} __no_const;
81642
81643 /*
81644 * CONFIG_RELAY kernel API, kernel/relay.c
81645 diff --git a/include/linux/rio.h b/include/linux/rio.h
81646 index 6bda06f..bf39a9b 100644
81647 --- a/include/linux/rio.h
81648 +++ b/include/linux/rio.h
81649 @@ -358,7 +358,7 @@ struct rio_ops {
81650 int (*map_inb)(struct rio_mport *mport, dma_addr_t lstart,
81651 u64 rstart, u32 size, u32 flags);
81652 void (*unmap_inb)(struct rio_mport *mport, dma_addr_t lstart);
81653 -};
81654 +} __no_const;
81655
81656 #define RIO_RESOURCE_MEM 0x00000100
81657 #define RIO_RESOURCE_DOORBELL 0x00000200
81658 diff --git a/include/linux/rmap.h b/include/linux/rmap.h
81659 index b66c211..13d2915 100644
81660 --- a/include/linux/rmap.h
81661 +++ b/include/linux/rmap.h
81662 @@ -145,8 +145,8 @@ static inline void anon_vma_unlock_read(struct anon_vma *anon_vma)
81663 void anon_vma_init(void); /* create anon_vma_cachep */
81664 int anon_vma_prepare(struct vm_area_struct *);
81665 void unlink_anon_vmas(struct vm_area_struct *);
81666 -int anon_vma_clone(struct vm_area_struct *, struct vm_area_struct *);
81667 -int anon_vma_fork(struct vm_area_struct *, struct vm_area_struct *);
81668 +int anon_vma_clone(struct vm_area_struct *, const struct vm_area_struct *);
81669 +int anon_vma_fork(struct vm_area_struct *, const struct vm_area_struct *);
81670
81671 static inline void anon_vma_merge(struct vm_area_struct *vma,
81672 struct vm_area_struct *next)
81673 diff --git a/include/linux/scatterlist.h b/include/linux/scatterlist.h
81674 index a964f72..b475afb 100644
81675 --- a/include/linux/scatterlist.h
81676 +++ b/include/linux/scatterlist.h
81677 @@ -1,6 +1,7 @@
81678 #ifndef _LINUX_SCATTERLIST_H
81679 #define _LINUX_SCATTERLIST_H
81680
81681 +#include <linux/sched.h>
81682 #include <linux/string.h>
81683 #include <linux/bug.h>
81684 #include <linux/mm.h>
81685 @@ -114,6 +115,12 @@ static inline void sg_set_buf(struct scatterlist *sg, const void *buf,
81686 #ifdef CONFIG_DEBUG_SG
81687 BUG_ON(!virt_addr_valid(buf));
81688 #endif
81689 +#ifdef CONFIG_GRKERNSEC_KSTACKOVERFLOW
81690 + if (object_starts_on_stack(buf)) {
81691 + void *adjbuf = buf - current->stack + current->lowmem_stack;
81692 + sg_set_page(sg, virt_to_page(adjbuf), buflen, offset_in_page(adjbuf));
81693 + } else
81694 +#endif
81695 sg_set_page(sg, virt_to_page(buf), buflen, offset_in_page(buf));
81696 }
81697
81698 diff --git a/include/linux/sched.h b/include/linux/sched.h
81699 index 221b2bd..e2e5f82 100644
81700 --- a/include/linux/sched.h
81701 +++ b/include/linux/sched.h
81702 @@ -131,6 +131,7 @@ struct fs_struct;
81703 struct perf_event_context;
81704 struct blk_plug;
81705 struct filename;
81706 +struct linux_binprm;
81707
81708 #define VMACACHE_BITS 2
81709 #define VMACACHE_SIZE (1U << VMACACHE_BITS)
81710 @@ -380,7 +381,7 @@ extern char __sched_text_start[], __sched_text_end[];
81711 extern int in_sched_functions(unsigned long addr);
81712
81713 #define MAX_SCHEDULE_TIMEOUT LONG_MAX
81714 -extern signed long schedule_timeout(signed long timeout);
81715 +extern signed long schedule_timeout(signed long timeout) __intentional_overflow(-1);
81716 extern signed long schedule_timeout_interruptible(signed long timeout);
81717 extern signed long schedule_timeout_killable(signed long timeout);
81718 extern signed long schedule_timeout_uninterruptible(signed long timeout);
81719 @@ -391,6 +392,19 @@ struct nsproxy;
81720 struct user_namespace;
81721
81722 #ifdef CONFIG_MMU
81723 +
81724 +#ifdef CONFIG_GRKERNSEC_RAND_THREADSTACK
81725 +extern unsigned long gr_rand_threadstack_offset(const struct mm_struct *mm, const struct file *filp, unsigned long flags);
81726 +#else
81727 +static inline unsigned long gr_rand_threadstack_offset(const struct mm_struct *mm, const struct file *filp, unsigned long flags)
81728 +{
81729 + return 0;
81730 +}
81731 +#endif
81732 +
81733 +extern bool check_heap_stack_gap(const struct vm_area_struct *vma, unsigned long addr, unsigned long len, unsigned long offset);
81734 +extern unsigned long skip_heap_stack_gap(const struct vm_area_struct *vma, unsigned long len, unsigned long offset);
81735 +
81736 extern void arch_pick_mmap_layout(struct mm_struct *mm);
81737 extern unsigned long
81738 arch_get_unmapped_area(struct file *, unsigned long, unsigned long,
81739 @@ -688,6 +702,17 @@ struct signal_struct {
81740 #ifdef CONFIG_TASKSTATS
81741 struct taskstats *stats;
81742 #endif
81743 +
81744 +#ifdef CONFIG_GRKERNSEC
81745 + u32 curr_ip;
81746 + u32 saved_ip;
81747 + u32 gr_saddr;
81748 + u32 gr_daddr;
81749 + u16 gr_sport;
81750 + u16 gr_dport;
81751 + u8 used_accept:1;
81752 +#endif
81753 +
81754 #ifdef CONFIG_AUDIT
81755 unsigned audit_tty;
81756 unsigned audit_tty_log_passwd;
81757 @@ -714,7 +739,7 @@ struct signal_struct {
81758 struct mutex cred_guard_mutex; /* guard against foreign influences on
81759 * credential calculations
81760 * (notably. ptrace) */
81761 -};
81762 +} __randomize_layout;
81763
81764 /*
81765 * Bits in flags field of signal_struct.
81766 @@ -768,6 +793,14 @@ struct user_struct {
81767 struct key *session_keyring; /* UID's default session keyring */
81768 #endif
81769
81770 +#ifdef CONFIG_GRKERNSEC_KERN_LOCKOUT
81771 + unsigned char kernel_banned;
81772 +#endif
81773 +#ifdef CONFIG_GRKERNSEC_BRUTE
81774 + unsigned char suid_banned;
81775 + unsigned long suid_ban_expires;
81776 +#endif
81777 +
81778 /* Hash table maintenance information */
81779 struct hlist_node uidhash_node;
81780 kuid_t uid;
81781 @@ -775,7 +808,7 @@ struct user_struct {
81782 #ifdef CONFIG_PERF_EVENTS
81783 atomic_long_t locked_vm;
81784 #endif
81785 -};
81786 +} __randomize_layout;
81787
81788 extern int uids_sysfs_init(void);
81789
81790 @@ -1179,6 +1212,9 @@ enum perf_event_task_context {
81791 struct task_struct {
81792 volatile long state; /* -1 unrunnable, 0 runnable, >0 stopped */
81793 void *stack;
81794 +#ifdef CONFIG_GRKERNSEC_KSTACKOVERFLOW
81795 + void *lowmem_stack;
81796 +#endif
81797 atomic_t usage;
81798 unsigned int flags; /* per process flags, defined below */
81799 unsigned int ptrace;
81800 @@ -1304,8 +1340,8 @@ struct task_struct {
81801 struct list_head thread_node;
81802
81803 struct completion *vfork_done; /* for vfork() */
81804 - int __user *set_child_tid; /* CLONE_CHILD_SETTID */
81805 - int __user *clear_child_tid; /* CLONE_CHILD_CLEARTID */
81806 + pid_t __user *set_child_tid; /* CLONE_CHILD_SETTID */
81807 + pid_t __user *clear_child_tid; /* CLONE_CHILD_CLEARTID */
81808
81809 cputime_t utime, stime, utimescaled, stimescaled;
81810 cputime_t gtime;
81811 @@ -1330,11 +1366,6 @@ struct task_struct {
81812 struct task_cputime cputime_expires;
81813 struct list_head cpu_timers[3];
81814
81815 -/* process credentials */
81816 - const struct cred __rcu *real_cred; /* objective and real subjective task
81817 - * credentials (COW) */
81818 - const struct cred __rcu *cred; /* effective (overridable) subjective task
81819 - * credentials (COW) */
81820 char comm[TASK_COMM_LEN]; /* executable name excluding path
81821 - access with [gs]et_task_comm (which lock
81822 it with task_lock())
81823 @@ -1351,6 +1382,10 @@ struct task_struct {
81824 #endif
81825 /* CPU-specific state of this task */
81826 struct thread_struct thread;
81827 +/* thread_info moved to task_struct */
81828 +#ifdef CONFIG_X86
81829 + struct thread_info tinfo;
81830 +#endif
81831 /* filesystem information */
81832 struct fs_struct *fs;
81833 /* open file information */
81834 @@ -1427,6 +1462,10 @@ struct task_struct {
81835 gfp_t lockdep_reclaim_gfp;
81836 #endif
81837
81838 +/* process credentials */
81839 + const struct cred __rcu *real_cred; /* objective and real subjective task
81840 + * credentials (COW) */
81841 +
81842 /* journalling filesystem info */
81843 void *journal_info;
81844
81845 @@ -1465,6 +1504,10 @@ struct task_struct {
81846 /* cg_list protected by css_set_lock and tsk->alloc_lock */
81847 struct list_head cg_list;
81848 #endif
81849 +
81850 + const struct cred __rcu *cred; /* effective (overridable) subjective task
81851 + * credentials (COW) */
81852 +
81853 #ifdef CONFIG_FUTEX
81854 struct robust_list_head __user *robust_list;
81855 #ifdef CONFIG_COMPAT
81856 @@ -1610,7 +1653,78 @@ struct task_struct {
81857 unsigned int sequential_io;
81858 unsigned int sequential_io_avg;
81859 #endif
81860 -};
81861 +
81862 +#ifdef CONFIG_GRKERNSEC
81863 + /* grsecurity */
81864 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
81865 + u64 exec_id;
81866 +#endif
81867 +#ifdef CONFIG_GRKERNSEC_SETXID
81868 + const struct cred *delayed_cred;
81869 +#endif
81870 + struct dentry *gr_chroot_dentry;
81871 + struct acl_subject_label *acl;
81872 + struct acl_subject_label *tmpacl;
81873 + struct acl_role_label *role;
81874 + struct file *exec_file;
81875 + unsigned long brute_expires;
81876 + u16 acl_role_id;
81877 + u8 inherited;
81878 + /* is this the task that authenticated to the special role */
81879 + u8 acl_sp_role;
81880 + u8 is_writable;
81881 + u8 brute;
81882 + u8 gr_is_chrooted;
81883 +#endif
81884 +
81885 +} __randomize_layout;
81886 +
81887 +#define MF_PAX_PAGEEXEC 0x01000000 /* Paging based non-executable pages */
81888 +#define MF_PAX_EMUTRAMP 0x02000000 /* Emulate trampolines */
81889 +#define MF_PAX_MPROTECT 0x04000000 /* Restrict mprotect() */
81890 +#define MF_PAX_RANDMMAP 0x08000000 /* Randomize mmap() base */
81891 +/*#define MF_PAX_RANDEXEC 0x10000000*/ /* Randomize ET_EXEC base */
81892 +#define MF_PAX_SEGMEXEC 0x20000000 /* Segmentation based non-executable pages */
81893 +
81894 +#ifdef CONFIG_PAX_SOFTMODE
81895 +extern int pax_softmode;
81896 +#endif
81897 +
81898 +extern int pax_check_flags(unsigned long *);
81899 +#define PAX_PARSE_FLAGS_FALLBACK (~0UL)
81900 +
81901 +/* if tsk != current then task_lock must be held on it */
81902 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
81903 +static inline unsigned long pax_get_flags(struct task_struct *tsk)
81904 +{
81905 + if (likely(tsk->mm))
81906 + return tsk->mm->pax_flags;
81907 + else
81908 + return 0UL;
81909 +}
81910 +
81911 +/* if tsk != current then task_lock must be held on it */
81912 +static inline long pax_set_flags(struct task_struct *tsk, unsigned long flags)
81913 +{
81914 + if (likely(tsk->mm)) {
81915 + tsk->mm->pax_flags = flags;
81916 + return 0;
81917 + }
81918 + return -EINVAL;
81919 +}
81920 +#endif
81921 +
81922 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
81923 +extern void pax_set_initial_flags(struct linux_binprm *bprm);
81924 +#elif defined(CONFIG_PAX_HOOK_ACL_FLAGS)
81925 +extern void (*pax_set_initial_flags_func)(struct linux_binprm *bprm);
81926 +#endif
81927 +
81928 +struct path;
81929 +extern char *pax_get_path(const struct path *path, char *buf, int buflen);
81930 +extern void pax_report_fault(struct pt_regs *regs, void *pc, void *sp);
81931 +extern void pax_report_insns(struct pt_regs *regs, void *pc, void *sp);
81932 +extern void pax_report_refcount_overflow(struct pt_regs *regs);
81933
81934 /* Future-safe accessor for struct task_struct's cpus_allowed. */
81935 #define tsk_cpus_allowed(tsk) (&(tsk)->cpus_allowed)
81936 @@ -1692,7 +1806,7 @@ struct pid_namespace;
81937 pid_t __task_pid_nr_ns(struct task_struct *task, enum pid_type type,
81938 struct pid_namespace *ns);
81939
81940 -static inline pid_t task_pid_nr(struct task_struct *tsk)
81941 +static inline pid_t task_pid_nr(const struct task_struct *tsk)
81942 {
81943 return tsk->pid;
81944 }
81945 @@ -2039,6 +2153,25 @@ extern u64 sched_clock_cpu(int cpu);
81946
81947 extern void sched_clock_init(void);
81948
81949 +#ifdef CONFIG_GRKERNSEC_KSTACKOVERFLOW
81950 +static inline void populate_stack(void)
81951 +{
81952 + struct task_struct *curtask = current;
81953 + int c;
81954 + int *ptr = curtask->stack;
81955 + int *end = curtask->stack + THREAD_SIZE;
81956 +
81957 + while (ptr < end) {
81958 + c = *(volatile int *)ptr;
81959 + ptr += PAGE_SIZE/sizeof(int);
81960 + }
81961 +}
81962 +#else
81963 +static inline void populate_stack(void)
81964 +{
81965 +}
81966 +#endif
81967 +
81968 #ifndef CONFIG_HAVE_UNSTABLE_SCHED_CLOCK
81969 static inline void sched_clock_tick(void)
81970 {
81971 @@ -2172,7 +2305,9 @@ void yield(void);
81972 extern struct exec_domain default_exec_domain;
81973
81974 union thread_union {
81975 +#ifndef CONFIG_X86
81976 struct thread_info thread_info;
81977 +#endif
81978 unsigned long stack[THREAD_SIZE/sizeof(long)];
81979 };
81980
81981 @@ -2205,6 +2340,7 @@ extern struct pid_namespace init_pid_ns;
81982 */
81983
81984 extern struct task_struct *find_task_by_vpid(pid_t nr);
81985 +extern struct task_struct *find_task_by_vpid_unrestricted(pid_t nr);
81986 extern struct task_struct *find_task_by_pid_ns(pid_t nr,
81987 struct pid_namespace *ns);
81988
81989 @@ -2367,7 +2503,7 @@ extern void __cleanup_sighand(struct sighand_struct *);
81990 extern void exit_itimers(struct signal_struct *);
81991 extern void flush_itimer_signals(void);
81992
81993 -extern void do_group_exit(int);
81994 +extern __noreturn void do_group_exit(int);
81995
81996 extern int allow_signal(int);
81997 extern int disallow_signal(int);
81998 @@ -2568,9 +2704,9 @@ static inline unsigned long *end_of_stack(struct task_struct *p)
81999
82000 #endif
82001
82002 -static inline int object_is_on_stack(void *obj)
82003 +static inline int object_starts_on_stack(const void *obj)
82004 {
82005 - void *stack = task_stack_page(current);
82006 + const void *stack = task_stack_page(current);
82007
82008 return (obj >= stack) && (obj < (stack + THREAD_SIZE));
82009 }
82010 diff --git a/include/linux/sched/sysctl.h b/include/linux/sched/sysctl.h
82011 index 8045a55..c959cd5 100644
82012 --- a/include/linux/sched/sysctl.h
82013 +++ b/include/linux/sched/sysctl.h
82014 @@ -30,6 +30,7 @@ enum { sysctl_hung_task_timeout_secs = 0 };
82015 #define DEFAULT_MAX_MAP_COUNT (USHRT_MAX - MAPCOUNT_ELF_CORE_MARGIN)
82016
82017 extern int sysctl_max_map_count;
82018 +extern unsigned long sysctl_heap_stack_gap;
82019
82020 extern unsigned int sysctl_sched_latency;
82021 extern unsigned int sysctl_sched_min_granularity;
82022 diff --git a/include/linux/security.h b/include/linux/security.h
82023 index 6478ce3..5e6ad6e 100644
82024 --- a/include/linux/security.h
82025 +++ b/include/linux/security.h
82026 @@ -27,6 +27,7 @@
82027 #include <linux/slab.h>
82028 #include <linux/err.h>
82029 #include <linux/string.h>
82030 +#include <linux/grsecurity.h>
82031
82032 struct linux_binprm;
82033 struct cred;
82034 @@ -116,8 +117,6 @@ struct seq_file;
82035
82036 extern int cap_netlink_send(struct sock *sk, struct sk_buff *skb);
82037
82038 -void reset_security_ops(void);
82039 -
82040 #ifdef CONFIG_MMU
82041 extern unsigned long mmap_min_addr;
82042 extern unsigned long dac_mmap_min_addr;
82043 @@ -1719,7 +1718,7 @@ struct security_operations {
82044 struct audit_context *actx);
82045 void (*audit_rule_free) (void *lsmrule);
82046 #endif /* CONFIG_AUDIT */
82047 -};
82048 +} __randomize_layout;
82049
82050 /* prototypes */
82051 extern int security_init(void);
82052 diff --git a/include/linux/semaphore.h b/include/linux/semaphore.h
82053 index dc368b8..e895209 100644
82054 --- a/include/linux/semaphore.h
82055 +++ b/include/linux/semaphore.h
82056 @@ -37,7 +37,7 @@ static inline void sema_init(struct semaphore *sem, int val)
82057 }
82058
82059 extern void down(struct semaphore *sem);
82060 -extern int __must_check down_interruptible(struct semaphore *sem);
82061 +extern int __must_check down_interruptible(struct semaphore *sem) __intentional_overflow(-1);
82062 extern int __must_check down_killable(struct semaphore *sem);
82063 extern int __must_check down_trylock(struct semaphore *sem);
82064 extern int __must_check down_timeout(struct semaphore *sem, long jiffies);
82065 diff --git a/include/linux/seq_file.h b/include/linux/seq_file.h
82066 index 52e0097..383f21d 100644
82067 --- a/include/linux/seq_file.h
82068 +++ b/include/linux/seq_file.h
82069 @@ -27,6 +27,9 @@ struct seq_file {
82070 struct mutex lock;
82071 const struct seq_operations *op;
82072 int poll_event;
82073 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
82074 + u64 exec_id;
82075 +#endif
82076 #ifdef CONFIG_USER_NS
82077 struct user_namespace *user_ns;
82078 #endif
82079 @@ -39,6 +42,7 @@ struct seq_operations {
82080 void * (*next) (struct seq_file *m, void *v, loff_t *pos);
82081 int (*show) (struct seq_file *m, void *v);
82082 };
82083 +typedef struct seq_operations __no_const seq_operations_no_const;
82084
82085 #define SEQ_SKIP 1
82086
82087 @@ -96,6 +100,7 @@ void seq_pad(struct seq_file *m, char c);
82088
82089 char *mangle_path(char *s, const char *p, const char *esc);
82090 int seq_open(struct file *, const struct seq_operations *);
82091 +int seq_open_restrict(struct file *, const struct seq_operations *);
82092 ssize_t seq_read(struct file *, char __user *, size_t, loff_t *);
82093 loff_t seq_lseek(struct file *, loff_t, int);
82094 int seq_release(struct inode *, struct file *);
82095 @@ -138,6 +143,7 @@ static inline int seq_nodemask_list(struct seq_file *m, nodemask_t *mask)
82096 }
82097
82098 int single_open(struct file *, int (*)(struct seq_file *, void *), void *);
82099 +int single_open_restrict(struct file *, int (*)(struct seq_file *, void *), void *);
82100 int single_open_size(struct file *, int (*)(struct seq_file *, void *), void *, size_t);
82101 int single_release(struct inode *, struct file *);
82102 void *__seq_open_private(struct file *, const struct seq_operations *, int);
82103 diff --git a/include/linux/shm.h b/include/linux/shm.h
82104 index 1e2cd2e..0288750 100644
82105 --- a/include/linux/shm.h
82106 +++ b/include/linux/shm.h
82107 @@ -21,6 +21,10 @@ struct shmid_kernel /* private to the kernel */
82108
82109 /* The task created the shm object. NULL if the task is dead. */
82110 struct task_struct *shm_creator;
82111 +#ifdef CONFIG_GRKERNSEC
82112 + time_t shm_createtime;
82113 + pid_t shm_lapid;
82114 +#endif
82115 };
82116
82117 /* shm_mode upper byte flags */
82118 diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
82119 index 08074a8..e2ae280 100644
82120 --- a/include/linux/skbuff.h
82121 +++ b/include/linux/skbuff.h
82122 @@ -717,7 +717,7 @@ bool skb_try_coalesce(struct sk_buff *to, struct sk_buff *from,
82123 struct sk_buff *__alloc_skb(unsigned int size, gfp_t priority, int flags,
82124 int node);
82125 struct sk_buff *build_skb(void *data, unsigned int frag_size);
82126 -static inline struct sk_buff *alloc_skb(unsigned int size,
82127 +static inline struct sk_buff * __intentional_overflow(0) alloc_skb(unsigned int size,
82128 gfp_t priority)
82129 {
82130 return __alloc_skb(size, priority, 0, NUMA_NO_NODE);
82131 @@ -1825,7 +1825,7 @@ static inline u32 skb_inner_network_header_len(const struct sk_buff *skb)
82132 return skb->inner_transport_header - skb->inner_network_header;
82133 }
82134
82135 -static inline int skb_network_offset(const struct sk_buff *skb)
82136 +static inline int __intentional_overflow(0) skb_network_offset(const struct sk_buff *skb)
82137 {
82138 return skb_network_header(skb) - skb->data;
82139 }
82140 @@ -1885,7 +1885,7 @@ static inline int pskb_network_may_pull(struct sk_buff *skb, unsigned int len)
82141 * NET_IP_ALIGN(2) + ethernet_header(14) + IP_header(20/40) + ports(8)
82142 */
82143 #ifndef NET_SKB_PAD
82144 -#define NET_SKB_PAD max(32, L1_CACHE_BYTES)
82145 +#define NET_SKB_PAD max(_AC(32,UL), L1_CACHE_BYTES)
82146 #endif
82147
82148 int ___pskb_trim(struct sk_buff *skb, unsigned int len);
82149 @@ -2484,7 +2484,7 @@ struct sk_buff *skb_recv_datagram(struct sock *sk, unsigned flags, int noblock,
82150 int *err);
82151 unsigned int datagram_poll(struct file *file, struct socket *sock,
82152 struct poll_table_struct *wait);
82153 -int skb_copy_datagram_iovec(const struct sk_buff *from, int offset,
82154 +int __intentional_overflow(0) skb_copy_datagram_iovec(const struct sk_buff *from, int offset,
82155 struct iovec *to, int size);
82156 int skb_copy_and_csum_datagram_iovec(struct sk_buff *skb, int hlen,
82157 struct iovec *iov);
82158 @@ -2776,6 +2776,9 @@ static inline void nf_reset(struct sk_buff *skb)
82159 nf_bridge_put(skb->nf_bridge);
82160 skb->nf_bridge = NULL;
82161 #endif
82162 +#if IS_ENABLED(CONFIG_NETFILTER_XT_TARGET_TRACE)
82163 + skb->nf_trace = 0;
82164 +#endif
82165 }
82166
82167 static inline void nf_reset_trace(struct sk_buff *skb)
82168 diff --git a/include/linux/slab.h b/include/linux/slab.h
82169 index 307bfbe..a999cf3 100644
82170 --- a/include/linux/slab.h
82171 +++ b/include/linux/slab.h
82172 @@ -14,15 +14,29 @@
82173 #include <linux/gfp.h>
82174 #include <linux/types.h>
82175 #include <linux/workqueue.h>
82176 -
82177 +#include <linux/err.h>
82178
82179 /*
82180 * Flags to pass to kmem_cache_create().
82181 * The ones marked DEBUG are only valid if CONFIG_SLAB_DEBUG is set.
82182 */
82183 #define SLAB_DEBUG_FREE 0x00000100UL /* DEBUG: Perform (expensive) checks on free */
82184 +
82185 +#ifdef CONFIG_PAX_USERCOPY_SLABS
82186 +#define SLAB_USERCOPY 0x00000200UL /* PaX: Allow copying objs to/from userland */
82187 +#else
82188 +#define SLAB_USERCOPY 0x00000000UL
82189 +#endif
82190 +
82191 #define SLAB_RED_ZONE 0x00000400UL /* DEBUG: Red zone objs in a cache */
82192 #define SLAB_POISON 0x00000800UL /* DEBUG: Poison objects */
82193 +
82194 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
82195 +#define SLAB_NO_SANITIZE 0x00001000UL /* PaX: Do not sanitize objs on free */
82196 +#else
82197 +#define SLAB_NO_SANITIZE 0x00000000UL
82198 +#endif
82199 +
82200 #define SLAB_HWCACHE_ALIGN 0x00002000UL /* Align objs on cache lines */
82201 #define SLAB_CACHE_DMA 0x00004000UL /* Use GFP_DMA memory */
82202 #define SLAB_STORE_USER 0x00010000UL /* DEBUG: Store the last owner for bug hunting */
82203 @@ -98,10 +112,13 @@
82204 * ZERO_SIZE_PTR can be passed to kfree though in the same way that NULL can.
82205 * Both make kfree a no-op.
82206 */
82207 -#define ZERO_SIZE_PTR ((void *)16)
82208 +#define ZERO_SIZE_PTR \
82209 +({ \
82210 + BUILD_BUG_ON(!(MAX_ERRNO & ~PAGE_MASK));\
82211 + (void *)(-MAX_ERRNO-1L); \
82212 +})
82213
82214 -#define ZERO_OR_NULL_PTR(x) ((unsigned long)(x) <= \
82215 - (unsigned long)ZERO_SIZE_PTR)
82216 +#define ZERO_OR_NULL_PTR(x) ((unsigned long)(x) - 1 >= (unsigned long)ZERO_SIZE_PTR - 1)
82217
82218 #include <linux/kmemleak.h>
82219
82220 @@ -142,6 +159,8 @@ void * __must_check krealloc(const void *, size_t, gfp_t);
82221 void kfree(const void *);
82222 void kzfree(const void *);
82223 size_t ksize(const void *);
82224 +const char *check_heap_object(const void *ptr, unsigned long n);
82225 +bool is_usercopy_object(const void *ptr);
82226
82227 /*
82228 * Some archs want to perform DMA into kmalloc caches and need a guaranteed
82229 @@ -174,7 +193,7 @@ struct kmem_cache {
82230 unsigned int align; /* Alignment as calculated */
82231 unsigned long flags; /* Active flags on the slab */
82232 const char *name; /* Slab name for sysfs */
82233 - int refcount; /* Use counter */
82234 + atomic_t refcount; /* Use counter */
82235 void (*ctor)(void *); /* Called on object slot creation */
82236 struct list_head list; /* List of all slab caches on the system */
82237 };
82238 @@ -259,6 +278,10 @@ extern struct kmem_cache *kmalloc_caches[KMALLOC_SHIFT_HIGH + 1];
82239 extern struct kmem_cache *kmalloc_dma_caches[KMALLOC_SHIFT_HIGH + 1];
82240 #endif
82241
82242 +#ifdef CONFIG_PAX_USERCOPY_SLABS
82243 +extern struct kmem_cache *kmalloc_usercopy_caches[KMALLOC_SHIFT_HIGH + 1];
82244 +#endif
82245 +
82246 /*
82247 * Figure out which kmalloc slab an allocation of a certain size
82248 * belongs to.
82249 @@ -267,7 +290,7 @@ extern struct kmem_cache *kmalloc_dma_caches[KMALLOC_SHIFT_HIGH + 1];
82250 * 2 = 120 .. 192 bytes
82251 * n = 2^(n-1) .. 2^n -1
82252 */
82253 -static __always_inline int kmalloc_index(size_t size)
82254 +static __always_inline __size_overflow(1) int kmalloc_index(size_t size)
82255 {
82256 if (!size)
82257 return 0;
82258 @@ -310,11 +333,11 @@ static __always_inline int kmalloc_index(size_t size)
82259 }
82260 #endif /* !CONFIG_SLOB */
82261
82262 -void *__kmalloc(size_t size, gfp_t flags);
82263 +void *__kmalloc(size_t size, gfp_t flags) __alloc_size(1);
82264 void *kmem_cache_alloc(struct kmem_cache *, gfp_t flags);
82265
82266 #ifdef CONFIG_NUMA
82267 -void *__kmalloc_node(size_t size, gfp_t flags, int node);
82268 +void *__kmalloc_node(size_t size, gfp_t flags, int node) __alloc_size(1);
82269 void *kmem_cache_alloc_node(struct kmem_cache *, gfp_t flags, int node);
82270 #else
82271 static __always_inline void *__kmalloc_node(size_t size, gfp_t flags, int node)
82272 diff --git a/include/linux/slab_def.h b/include/linux/slab_def.h
82273 index 8235dfb..47ce586 100644
82274 --- a/include/linux/slab_def.h
82275 +++ b/include/linux/slab_def.h
82276 @@ -38,7 +38,7 @@ struct kmem_cache {
82277 /* 4) cache creation/removal */
82278 const char *name;
82279 struct list_head list;
82280 - int refcount;
82281 + atomic_t refcount;
82282 int object_size;
82283 int align;
82284
82285 @@ -54,10 +54,14 @@ struct kmem_cache {
82286 unsigned long node_allocs;
82287 unsigned long node_frees;
82288 unsigned long node_overflow;
82289 - atomic_t allochit;
82290 - atomic_t allocmiss;
82291 - atomic_t freehit;
82292 - atomic_t freemiss;
82293 + atomic_unchecked_t allochit;
82294 + atomic_unchecked_t allocmiss;
82295 + atomic_unchecked_t freehit;
82296 + atomic_unchecked_t freemiss;
82297 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
82298 + atomic_unchecked_t sanitized;
82299 + atomic_unchecked_t not_sanitized;
82300 +#endif
82301
82302 /*
82303 * If debugging is enabled, then the allocator can add additional
82304 diff --git a/include/linux/slub_def.h b/include/linux/slub_def.h
82305 index d82abd4..408c3a0 100644
82306 --- a/include/linux/slub_def.h
82307 +++ b/include/linux/slub_def.h
82308 @@ -74,7 +74,7 @@ struct kmem_cache {
82309 struct kmem_cache_order_objects max;
82310 struct kmem_cache_order_objects min;
82311 gfp_t allocflags; /* gfp flags to use on each alloc */
82312 - int refcount; /* Refcount for slab cache destroy */
82313 + atomic_t refcount; /* Refcount for slab cache destroy */
82314 void (*ctor)(void *);
82315 int inuse; /* Offset to metadata */
82316 int align; /* Alignment */
82317 diff --git a/include/linux/smp.h b/include/linux/smp.h
82318 index 633f5ed..6c3dc3f 100644
82319 --- a/include/linux/smp.h
82320 +++ b/include/linux/smp.h
82321 @@ -176,7 +176,9 @@ static inline void kick_all_cpus_sync(void) { }
82322 #endif
82323
82324 #define get_cpu() ({ preempt_disable(); smp_processor_id(); })
82325 +#define raw_get_cpu() ({ raw_preempt_disable(); raw_smp_processor_id(); })
82326 #define put_cpu() preempt_enable()
82327 +#define raw_put_cpu_no_resched() raw_preempt_enable_no_resched()
82328
82329 /*
82330 * Callback to arch code if there's nosmp or maxcpus=0 on the
82331 diff --git a/include/linux/sock_diag.h b/include/linux/sock_diag.h
82332 index 46cca4c..3323536 100644
82333 --- a/include/linux/sock_diag.h
82334 +++ b/include/linux/sock_diag.h
82335 @@ -11,7 +11,7 @@ struct sock;
82336 struct sock_diag_handler {
82337 __u8 family;
82338 int (*dump)(struct sk_buff *skb, struct nlmsghdr *nlh);
82339 -};
82340 +} __do_const;
82341
82342 int sock_diag_register(const struct sock_diag_handler *h);
82343 void sock_diag_unregister(const struct sock_diag_handler *h);
82344 diff --git a/include/linux/sonet.h b/include/linux/sonet.h
82345 index 680f9a3..f13aeb0 100644
82346 --- a/include/linux/sonet.h
82347 +++ b/include/linux/sonet.h
82348 @@ -7,7 +7,7 @@
82349 #include <uapi/linux/sonet.h>
82350
82351 struct k_sonet_stats {
82352 -#define __HANDLE_ITEM(i) atomic_t i
82353 +#define __HANDLE_ITEM(i) atomic_unchecked_t i
82354 __SONET_ITEMS
82355 #undef __HANDLE_ITEM
82356 };
82357 diff --git a/include/linux/sunrpc/addr.h b/include/linux/sunrpc/addr.h
82358 index 07d8e53..dc934c9 100644
82359 --- a/include/linux/sunrpc/addr.h
82360 +++ b/include/linux/sunrpc/addr.h
82361 @@ -23,9 +23,9 @@ static inline unsigned short rpc_get_port(const struct sockaddr *sap)
82362 {
82363 switch (sap->sa_family) {
82364 case AF_INET:
82365 - return ntohs(((struct sockaddr_in *)sap)->sin_port);
82366 + return ntohs(((const struct sockaddr_in *)sap)->sin_port);
82367 case AF_INET6:
82368 - return ntohs(((struct sockaddr_in6 *)sap)->sin6_port);
82369 + return ntohs(((const struct sockaddr_in6 *)sap)->sin6_port);
82370 }
82371 return 0;
82372 }
82373 @@ -58,7 +58,7 @@ static inline bool __rpc_cmp_addr4(const struct sockaddr *sap1,
82374 static inline bool __rpc_copy_addr4(struct sockaddr *dst,
82375 const struct sockaddr *src)
82376 {
82377 - const struct sockaddr_in *ssin = (struct sockaddr_in *) src;
82378 + const struct sockaddr_in *ssin = (const struct sockaddr_in *) src;
82379 struct sockaddr_in *dsin = (struct sockaddr_in *) dst;
82380
82381 dsin->sin_family = ssin->sin_family;
82382 @@ -164,7 +164,7 @@ static inline u32 rpc_get_scope_id(const struct sockaddr *sa)
82383 if (sa->sa_family != AF_INET6)
82384 return 0;
82385
82386 - return ((struct sockaddr_in6 *) sa)->sin6_scope_id;
82387 + return ((const struct sockaddr_in6 *) sa)->sin6_scope_id;
82388 }
82389
82390 #endif /* _LINUX_SUNRPC_ADDR_H */
82391 diff --git a/include/linux/sunrpc/clnt.h b/include/linux/sunrpc/clnt.h
82392 index 70736b9..37f33db 100644
82393 --- a/include/linux/sunrpc/clnt.h
82394 +++ b/include/linux/sunrpc/clnt.h
82395 @@ -97,7 +97,7 @@ struct rpc_procinfo {
82396 unsigned int p_timer; /* Which RTT timer to use */
82397 u32 p_statidx; /* Which procedure to account */
82398 const char * p_name; /* name of procedure */
82399 -};
82400 +} __do_const;
82401
82402 #ifdef __KERNEL__
82403
82404 diff --git a/include/linux/sunrpc/svc.h b/include/linux/sunrpc/svc.h
82405 index 04e7632..2e2a8a3 100644
82406 --- a/include/linux/sunrpc/svc.h
82407 +++ b/include/linux/sunrpc/svc.h
82408 @@ -412,7 +412,7 @@ struct svc_procedure {
82409 unsigned int pc_count; /* call count */
82410 unsigned int pc_cachetype; /* cache info (NFS) */
82411 unsigned int pc_xdrressize; /* maximum size of XDR reply */
82412 -};
82413 +} __do_const;
82414
82415 /*
82416 * Function prototypes.
82417 diff --git a/include/linux/sunrpc/svc_rdma.h b/include/linux/sunrpc/svc_rdma.h
82418 index 0b8e3e6..33e0a01 100644
82419 --- a/include/linux/sunrpc/svc_rdma.h
82420 +++ b/include/linux/sunrpc/svc_rdma.h
82421 @@ -53,15 +53,15 @@ extern unsigned int svcrdma_ord;
82422 extern unsigned int svcrdma_max_requests;
82423 extern unsigned int svcrdma_max_req_size;
82424
82425 -extern atomic_t rdma_stat_recv;
82426 -extern atomic_t rdma_stat_read;
82427 -extern atomic_t rdma_stat_write;
82428 -extern atomic_t rdma_stat_sq_starve;
82429 -extern atomic_t rdma_stat_rq_starve;
82430 -extern atomic_t rdma_stat_rq_poll;
82431 -extern atomic_t rdma_stat_rq_prod;
82432 -extern atomic_t rdma_stat_sq_poll;
82433 -extern atomic_t rdma_stat_sq_prod;
82434 +extern atomic_unchecked_t rdma_stat_recv;
82435 +extern atomic_unchecked_t rdma_stat_read;
82436 +extern atomic_unchecked_t rdma_stat_write;
82437 +extern atomic_unchecked_t rdma_stat_sq_starve;
82438 +extern atomic_unchecked_t rdma_stat_rq_starve;
82439 +extern atomic_unchecked_t rdma_stat_rq_poll;
82440 +extern atomic_unchecked_t rdma_stat_rq_prod;
82441 +extern atomic_unchecked_t rdma_stat_sq_poll;
82442 +extern atomic_unchecked_t rdma_stat_sq_prod;
82443
82444 #define RPCRDMA_VERSION 1
82445
82446 diff --git a/include/linux/sunrpc/svcauth.h b/include/linux/sunrpc/svcauth.h
82447 index 8d71d65..f79586e 100644
82448 --- a/include/linux/sunrpc/svcauth.h
82449 +++ b/include/linux/sunrpc/svcauth.h
82450 @@ -120,7 +120,7 @@ struct auth_ops {
82451 int (*release)(struct svc_rqst *rq);
82452 void (*domain_release)(struct auth_domain *);
82453 int (*set_client)(struct svc_rqst *rq);
82454 -};
82455 +} __do_const;
82456
82457 #define SVC_GARBAGE 1
82458 #define SVC_SYSERR 2
82459 diff --git a/include/linux/swiotlb.h b/include/linux/swiotlb.h
82460 index a5ffd32..0935dea 100644
82461 --- a/include/linux/swiotlb.h
82462 +++ b/include/linux/swiotlb.h
82463 @@ -60,7 +60,8 @@ extern void
82464
82465 extern void
82466 swiotlb_free_coherent(struct device *hwdev, size_t size,
82467 - void *vaddr, dma_addr_t dma_handle);
82468 + void *vaddr, dma_addr_t dma_handle,
82469 + struct dma_attrs *attrs);
82470
82471 extern dma_addr_t swiotlb_map_page(struct device *dev, struct page *page,
82472 unsigned long offset, size_t size,
82473 diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
82474 index a4a0588..752870e 100644
82475 --- a/include/linux/syscalls.h
82476 +++ b/include/linux/syscalls.h
82477 @@ -98,10 +98,16 @@ struct sigaltstack;
82478 #define __MAP(n,...) __MAP##n(__VA_ARGS__)
82479
82480 #define __SC_DECL(t, a) t a
82481 +#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))
82482 #define __TYPE_IS_L(t) (__same_type((t)0, 0L))
82483 #define __TYPE_IS_UL(t) (__same_type((t)0, 0UL))
82484 #define __TYPE_IS_LL(t) (__same_type((t)0, 0LL) || __same_type((t)0, 0ULL))
82485 -#define __SC_LONG(t, a) __typeof(__builtin_choose_expr(__TYPE_IS_LL(t), 0LL, 0L)) a
82486 +#define __SC_LONG(t, a) __typeof( \
82487 + __builtin_choose_expr( \
82488 + sizeof(t) > sizeof(int), \
82489 + (t) 0, \
82490 + __builtin_choose_expr(__TYPE_IS_U(t), 0UL, 0L) \
82491 + )) a
82492 #define __SC_CAST(t, a) (t) a
82493 #define __SC_ARGS(t, a) a
82494 #define __SC_TEST(t, a) (void)BUILD_BUG_ON_ZERO(!__TYPE_IS_LL(t) && sizeof(t) > sizeof(long))
82495 @@ -379,11 +385,11 @@ asmlinkage long sys_sync(void);
82496 asmlinkage long sys_fsync(unsigned int fd);
82497 asmlinkage long sys_fdatasync(unsigned int fd);
82498 asmlinkage long sys_bdflush(int func, long data);
82499 -asmlinkage long sys_mount(char __user *dev_name, char __user *dir_name,
82500 - char __user *type, unsigned long flags,
82501 +asmlinkage long sys_mount(const char __user *dev_name, const char __user *dir_name,
82502 + const char __user *type, unsigned long flags,
82503 void __user *data);
82504 -asmlinkage long sys_umount(char __user *name, int flags);
82505 -asmlinkage long sys_oldumount(char __user *name);
82506 +asmlinkage long sys_umount(const char __user *name, int flags);
82507 +asmlinkage long sys_oldumount(const char __user *name);
82508 asmlinkage long sys_truncate(const char __user *path, long length);
82509 asmlinkage long sys_ftruncate(unsigned int fd, unsigned long length);
82510 asmlinkage long sys_stat(const char __user *filename,
82511 @@ -595,7 +601,7 @@ asmlinkage long sys_getsockname(int, struct sockaddr __user *, int __user *);
82512 asmlinkage long sys_getpeername(int, struct sockaddr __user *, int __user *);
82513 asmlinkage long sys_send(int, void __user *, size_t, unsigned);
82514 asmlinkage long sys_sendto(int, void __user *, size_t, unsigned,
82515 - struct sockaddr __user *, int);
82516 + struct sockaddr __user *, int) __intentional_overflow(0);
82517 asmlinkage long sys_sendmsg(int fd, struct msghdr __user *msg, unsigned flags);
82518 asmlinkage long sys_sendmmsg(int fd, struct mmsghdr __user *msg,
82519 unsigned int vlen, unsigned flags);
82520 diff --git a/include/linux/syscore_ops.h b/include/linux/syscore_ops.h
82521 index 27b3b0b..e093dd9 100644
82522 --- a/include/linux/syscore_ops.h
82523 +++ b/include/linux/syscore_ops.h
82524 @@ -16,7 +16,7 @@ struct syscore_ops {
82525 int (*suspend)(void);
82526 void (*resume)(void);
82527 void (*shutdown)(void);
82528 -};
82529 +} __do_const;
82530
82531 extern void register_syscore_ops(struct syscore_ops *ops);
82532 extern void unregister_syscore_ops(struct syscore_ops *ops);
82533 diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h
82534 index 14a8ff2..fa95f3a 100644
82535 --- a/include/linux/sysctl.h
82536 +++ b/include/linux/sysctl.h
82537 @@ -34,13 +34,13 @@ struct ctl_table_root;
82538 struct ctl_table_header;
82539 struct ctl_dir;
82540
82541 -typedef struct ctl_table ctl_table;
82542 -
82543 typedef int proc_handler (struct ctl_table *ctl, int write,
82544 void __user *buffer, size_t *lenp, loff_t *ppos);
82545
82546 extern int proc_dostring(struct ctl_table *, int,
82547 void __user *, size_t *, loff_t *);
82548 +extern int proc_dostring_modpriv(struct ctl_table *, int,
82549 + void __user *, size_t *, loff_t *);
82550 extern int proc_dointvec(struct ctl_table *, int,
82551 void __user *, size_t *, loff_t *);
82552 extern int proc_dointvec_minmax(struct ctl_table *, int,
82553 @@ -115,7 +115,9 @@ struct ctl_table
82554 struct ctl_table_poll *poll;
82555 void *extra1;
82556 void *extra2;
82557 -};
82558 +} __do_const __randomize_layout;
82559 +typedef struct ctl_table __no_const ctl_table_no_const;
82560 +typedef struct ctl_table ctl_table;
82561
82562 struct ctl_node {
82563 struct rb_node node;
82564 diff --git a/include/linux/sysfs.h b/include/linux/sysfs.h
82565 index 5ffaa34..fe3e31c 100644
82566 --- a/include/linux/sysfs.h
82567 +++ b/include/linux/sysfs.h
82568 @@ -34,7 +34,8 @@ struct attribute {
82569 struct lock_class_key *key;
82570 struct lock_class_key skey;
82571 #endif
82572 -};
82573 +} __do_const;
82574 +typedef struct attribute __no_const attribute_no_const;
82575
82576 /**
82577 * sysfs_attr_init - initialize a dynamically allocated sysfs attribute
82578 @@ -63,7 +64,8 @@ struct attribute_group {
82579 struct attribute *, int);
82580 struct attribute **attrs;
82581 struct bin_attribute **bin_attrs;
82582 -};
82583 +} __do_const;
82584 +typedef struct attribute_group __no_const attribute_group_no_const;
82585
82586 /**
82587 * Use these macros to make defining attributes easier. See include/linux/device.h
82588 @@ -128,7 +130,8 @@ struct bin_attribute {
82589 char *, loff_t, size_t);
82590 int (*mmap)(struct file *, struct kobject *, struct bin_attribute *attr,
82591 struct vm_area_struct *vma);
82592 -};
82593 +} __do_const;
82594 +typedef struct bin_attribute __no_const bin_attribute_no_const;
82595
82596 /**
82597 * sysfs_bin_attr_init - initialize a dynamically allocated bin_attribute
82598 diff --git a/include/linux/sysrq.h b/include/linux/sysrq.h
82599 index 387fa7d..3fcde6b 100644
82600 --- a/include/linux/sysrq.h
82601 +++ b/include/linux/sysrq.h
82602 @@ -16,6 +16,7 @@
82603
82604 #include <linux/errno.h>
82605 #include <linux/types.h>
82606 +#include <linux/compiler.h>
82607
82608 /* Possible values of bitmask for enabling sysrq functions */
82609 /* 0x0001 is reserved for enable everything */
82610 @@ -33,7 +34,7 @@ struct sysrq_key_op {
82611 char *help_msg;
82612 char *action_msg;
82613 int enable_mask;
82614 -};
82615 +} __do_const;
82616
82617 #ifdef CONFIG_MAGIC_SYSRQ
82618
82619 diff --git a/include/linux/thread_info.h b/include/linux/thread_info.h
82620 index fddbe20..a0e76ab 100644
82621 --- a/include/linux/thread_info.h
82622 +++ b/include/linux/thread_info.h
82623 @@ -161,6 +161,13 @@ static inline bool test_and_clear_restore_sigmask(void)
82624 #error "no set_restore_sigmask() provided and default one won't work"
82625 #endif
82626
82627 +extern void __check_object_size(const void *ptr, unsigned long n, bool to_user, bool const_size);
82628 +
82629 +static inline void check_object_size(const void *ptr, unsigned long n, bool to_user)
82630 +{
82631 + __check_object_size(ptr, n, to_user, __builtin_constant_p(n));
82632 +}
82633 +
82634 #endif /* __KERNEL__ */
82635
82636 #endif /* _LINUX_THREAD_INFO_H */
82637 diff --git a/include/linux/tty.h b/include/linux/tty.h
82638 index 1c3316a..ae83b9f 100644
82639 --- a/include/linux/tty.h
82640 +++ b/include/linux/tty.h
82641 @@ -202,7 +202,7 @@ struct tty_port {
82642 const struct tty_port_operations *ops; /* Port operations */
82643 spinlock_t lock; /* Lock protecting tty field */
82644 int blocked_open; /* Waiting to open */
82645 - int count; /* Usage count */
82646 + atomic_t count; /* Usage count */
82647 wait_queue_head_t open_wait; /* Open waiters */
82648 wait_queue_head_t close_wait; /* Close waiters */
82649 wait_queue_head_t delta_msr_wait; /* Modem status change */
82650 @@ -284,7 +284,7 @@ struct tty_struct {
82651 /* If the tty has a pending do_SAK, queue it here - akpm */
82652 struct work_struct SAK_work;
82653 struct tty_port *port;
82654 -};
82655 +} __randomize_layout;
82656
82657 /* Each of a tty's open files has private_data pointing to tty_file_private */
82658 struct tty_file_private {
82659 @@ -550,7 +550,7 @@ extern int tty_port_open(struct tty_port *port,
82660 struct tty_struct *tty, struct file *filp);
82661 static inline int tty_port_users(struct tty_port *port)
82662 {
82663 - return port->count + port->blocked_open;
82664 + return atomic_read(&port->count) + port->blocked_open;
82665 }
82666
82667 extern int tty_register_ldisc(int disc, struct tty_ldisc_ops *new_ldisc);
82668 diff --git a/include/linux/tty_driver.h b/include/linux/tty_driver.h
82669 index 756a609..89db85e 100644
82670 --- a/include/linux/tty_driver.h
82671 +++ b/include/linux/tty_driver.h
82672 @@ -285,7 +285,7 @@ struct tty_operations {
82673 void (*poll_put_char)(struct tty_driver *driver, int line, char ch);
82674 #endif
82675 const struct file_operations *proc_fops;
82676 -};
82677 +} __do_const __randomize_layout;
82678
82679 struct tty_driver {
82680 int magic; /* magic number for this structure */
82681 @@ -319,7 +319,7 @@ struct tty_driver {
82682
82683 const struct tty_operations *ops;
82684 struct list_head tty_drivers;
82685 -};
82686 +} __randomize_layout;
82687
82688 extern struct list_head tty_drivers;
82689
82690 diff --git a/include/linux/tty_ldisc.h b/include/linux/tty_ldisc.h
82691 index add26da..22c00bef 100644
82692 --- a/include/linux/tty_ldisc.h
82693 +++ b/include/linux/tty_ldisc.h
82694 @@ -212,7 +212,7 @@ struct tty_ldisc_ops {
82695
82696 struct module *owner;
82697
82698 - int refcount;
82699 + atomic_t refcount;
82700 };
82701
82702 struct tty_ldisc {
82703 diff --git a/include/linux/types.h b/include/linux/types.h
82704 index 4d118ba..c3ee9bf 100644
82705 --- a/include/linux/types.h
82706 +++ b/include/linux/types.h
82707 @@ -176,10 +176,26 @@ typedef struct {
82708 int counter;
82709 } atomic_t;
82710
82711 +#ifdef CONFIG_PAX_REFCOUNT
82712 +typedef struct {
82713 + int counter;
82714 +} atomic_unchecked_t;
82715 +#else
82716 +typedef atomic_t atomic_unchecked_t;
82717 +#endif
82718 +
82719 #ifdef CONFIG_64BIT
82720 typedef struct {
82721 long counter;
82722 } atomic64_t;
82723 +
82724 +#ifdef CONFIG_PAX_REFCOUNT
82725 +typedef struct {
82726 + long counter;
82727 +} atomic64_unchecked_t;
82728 +#else
82729 +typedef atomic64_t atomic64_unchecked_t;
82730 +#endif
82731 #endif
82732
82733 struct list_head {
82734 diff --git a/include/linux/uaccess.h b/include/linux/uaccess.h
82735 index ecd3319..8a36ded 100644
82736 --- a/include/linux/uaccess.h
82737 +++ b/include/linux/uaccess.h
82738 @@ -75,11 +75,11 @@ static inline unsigned long __copy_from_user_nocache(void *to,
82739 long ret; \
82740 mm_segment_t old_fs = get_fs(); \
82741 \
82742 - set_fs(KERNEL_DS); \
82743 pagefault_disable(); \
82744 - ret = __copy_from_user_inatomic(&(retval), (__force typeof(retval) __user *)(addr), sizeof(retval)); \
82745 - pagefault_enable(); \
82746 + set_fs(KERNEL_DS); \
82747 + ret = __copy_from_user_inatomic(&(retval), (typeof(retval) __force_user *)(addr), sizeof(retval)); \
82748 set_fs(old_fs); \
82749 + pagefault_enable(); \
82750 ret; \
82751 })
82752
82753 diff --git a/include/linux/uidgid.h b/include/linux/uidgid.h
82754 index 2d1f9b6..d7a9fce 100644
82755 --- a/include/linux/uidgid.h
82756 +++ b/include/linux/uidgid.h
82757 @@ -175,4 +175,9 @@ static inline bool kgid_has_mapping(struct user_namespace *ns, kgid_t gid)
82758
82759 #endif /* CONFIG_USER_NS */
82760
82761 +#define GR_GLOBAL_UID(x) from_kuid_munged(&init_user_ns, (x))
82762 +#define GR_GLOBAL_GID(x) from_kgid_munged(&init_user_ns, (x))
82763 +#define gr_is_global_root(x) uid_eq((x), GLOBAL_ROOT_UID)
82764 +#define gr_is_global_nonroot(x) (!uid_eq((x), GLOBAL_ROOT_UID))
82765 +
82766 #endif /* _LINUX_UIDGID_H */
82767 diff --git a/include/linux/unaligned/access_ok.h b/include/linux/unaligned/access_ok.h
82768 index 99c1b4d..562e6f3 100644
82769 --- a/include/linux/unaligned/access_ok.h
82770 +++ b/include/linux/unaligned/access_ok.h
82771 @@ -4,34 +4,34 @@
82772 #include <linux/kernel.h>
82773 #include <asm/byteorder.h>
82774
82775 -static inline u16 get_unaligned_le16(const void *p)
82776 +static inline u16 __intentional_overflow(-1) get_unaligned_le16(const void *p)
82777 {
82778 - return le16_to_cpup((__le16 *)p);
82779 + return le16_to_cpup((const __le16 *)p);
82780 }
82781
82782 -static inline u32 get_unaligned_le32(const void *p)
82783 +static inline u32 __intentional_overflow(-1) get_unaligned_le32(const void *p)
82784 {
82785 - return le32_to_cpup((__le32 *)p);
82786 + return le32_to_cpup((const __le32 *)p);
82787 }
82788
82789 -static inline u64 get_unaligned_le64(const void *p)
82790 +static inline u64 __intentional_overflow(-1) get_unaligned_le64(const void *p)
82791 {
82792 - return le64_to_cpup((__le64 *)p);
82793 + return le64_to_cpup((const __le64 *)p);
82794 }
82795
82796 -static inline u16 get_unaligned_be16(const void *p)
82797 +static inline u16 __intentional_overflow(-1) get_unaligned_be16(const void *p)
82798 {
82799 - return be16_to_cpup((__be16 *)p);
82800 + return be16_to_cpup((const __be16 *)p);
82801 }
82802
82803 -static inline u32 get_unaligned_be32(const void *p)
82804 +static inline u32 __intentional_overflow(-1) get_unaligned_be32(const void *p)
82805 {
82806 - return be32_to_cpup((__be32 *)p);
82807 + return be32_to_cpup((const __be32 *)p);
82808 }
82809
82810 -static inline u64 get_unaligned_be64(const void *p)
82811 +static inline u64 __intentional_overflow(-1) get_unaligned_be64(const void *p)
82812 {
82813 - return be64_to_cpup((__be64 *)p);
82814 + return be64_to_cpup((const __be64 *)p);
82815 }
82816
82817 static inline void put_unaligned_le16(u16 val, void *p)
82818 diff --git a/include/linux/usb.h b/include/linux/usb.h
82819 index 6b7ec37..4428419 100644
82820 --- a/include/linux/usb.h
82821 +++ b/include/linux/usb.h
82822 @@ -569,7 +569,7 @@ struct usb_device {
82823 int maxchild;
82824
82825 u32 quirks;
82826 - atomic_t urbnum;
82827 + atomic_unchecked_t urbnum;
82828
82829 unsigned long active_duration;
82830
82831 @@ -1653,7 +1653,7 @@ void usb_buffer_unmap_sg(const struct usb_device *dev, int is_in,
82832
82833 extern int usb_control_msg(struct usb_device *dev, unsigned int pipe,
82834 __u8 request, __u8 requesttype, __u16 value, __u16 index,
82835 - void *data, __u16 size, int timeout);
82836 + void *data, __u16 size, int timeout) __intentional_overflow(-1);
82837 extern int usb_interrupt_msg(struct usb_device *usb_dev, unsigned int pipe,
82838 void *data, int len, int *actual_length, int timeout);
82839 extern int usb_bulk_msg(struct usb_device *usb_dev, unsigned int pipe,
82840 diff --git a/include/linux/usb/renesas_usbhs.h b/include/linux/usb/renesas_usbhs.h
82841 index e452ba6..78f8e80 100644
82842 --- a/include/linux/usb/renesas_usbhs.h
82843 +++ b/include/linux/usb/renesas_usbhs.h
82844 @@ -39,7 +39,7 @@ enum {
82845 */
82846 struct renesas_usbhs_driver_callback {
82847 int (*notify_hotplug)(struct platform_device *pdev);
82848 -};
82849 +} __no_const;
82850
82851 /*
82852 * callback functions for platform
82853 diff --git a/include/linux/user_namespace.h b/include/linux/user_namespace.h
82854 index 4836ba3..603f6ee 100644
82855 --- a/include/linux/user_namespace.h
82856 +++ b/include/linux/user_namespace.h
82857 @@ -33,7 +33,7 @@ struct user_namespace {
82858 struct key *persistent_keyring_register;
82859 struct rw_semaphore persistent_keyring_register_sem;
82860 #endif
82861 -};
82862 +} __randomize_layout;
82863
82864 extern struct user_namespace init_user_ns;
82865
82866 diff --git a/include/linux/utsname.h b/include/linux/utsname.h
82867 index 239e277..22a5cf5 100644
82868 --- a/include/linux/utsname.h
82869 +++ b/include/linux/utsname.h
82870 @@ -24,7 +24,7 @@ struct uts_namespace {
82871 struct new_utsname name;
82872 struct user_namespace *user_ns;
82873 unsigned int proc_inum;
82874 -};
82875 +} __randomize_layout;
82876 extern struct uts_namespace init_uts_ns;
82877
82878 #ifdef CONFIG_UTS_NS
82879 diff --git a/include/linux/vermagic.h b/include/linux/vermagic.h
82880 index 6f8fbcf..4efc177 100644
82881 --- a/include/linux/vermagic.h
82882 +++ b/include/linux/vermagic.h
82883 @@ -25,9 +25,42 @@
82884 #define MODULE_ARCH_VERMAGIC ""
82885 #endif
82886
82887 +#ifdef CONFIG_PAX_REFCOUNT
82888 +#define MODULE_PAX_REFCOUNT "REFCOUNT "
82889 +#else
82890 +#define MODULE_PAX_REFCOUNT ""
82891 +#endif
82892 +
82893 +#ifdef CONSTIFY_PLUGIN
82894 +#define MODULE_CONSTIFY_PLUGIN "CONSTIFY_PLUGIN "
82895 +#else
82896 +#define MODULE_CONSTIFY_PLUGIN ""
82897 +#endif
82898 +
82899 +#ifdef STACKLEAK_PLUGIN
82900 +#define MODULE_STACKLEAK_PLUGIN "STACKLEAK_PLUGIN "
82901 +#else
82902 +#define MODULE_STACKLEAK_PLUGIN ""
82903 +#endif
82904 +
82905 +#ifdef RANDSTRUCT_PLUGIN
82906 +#include <generated/randomize_layout_hash.h>
82907 +#define MODULE_RANDSTRUCT_PLUGIN "RANDSTRUCT_PLUGIN_" RANDSTRUCT_HASHED_SEED
82908 +#else
82909 +#define MODULE_RANDSTRUCT_PLUGIN
82910 +#endif
82911 +
82912 +#ifdef CONFIG_GRKERNSEC
82913 +#define MODULE_GRSEC "GRSEC "
82914 +#else
82915 +#define MODULE_GRSEC ""
82916 +#endif
82917 +
82918 #define VERMAGIC_STRING \
82919 UTS_RELEASE " " \
82920 MODULE_VERMAGIC_SMP MODULE_VERMAGIC_PREEMPT \
82921 MODULE_VERMAGIC_MODULE_UNLOAD MODULE_VERMAGIC_MODVERSIONS \
82922 - MODULE_ARCH_VERMAGIC
82923 + MODULE_ARCH_VERMAGIC \
82924 + MODULE_PAX_REFCOUNT MODULE_CONSTIFY_PLUGIN MODULE_STACKLEAK_PLUGIN \
82925 + MODULE_GRSEC MODULE_RANDSTRUCT_PLUGIN
82926
82927 diff --git a/include/linux/vga_switcheroo.h b/include/linux/vga_switcheroo.h
82928 index 502073a..a7de024 100644
82929 --- a/include/linux/vga_switcheroo.h
82930 +++ b/include/linux/vga_switcheroo.h
82931 @@ -63,8 +63,8 @@ int vga_switcheroo_get_client_state(struct pci_dev *dev);
82932
82933 void vga_switcheroo_set_dynamic_switch(struct pci_dev *pdev, enum vga_switcheroo_state dynamic);
82934
82935 -int vga_switcheroo_init_domain_pm_ops(struct device *dev, struct dev_pm_domain *domain);
82936 -int vga_switcheroo_init_domain_pm_optimus_hdmi_audio(struct device *dev, struct dev_pm_domain *domain);
82937 +int vga_switcheroo_init_domain_pm_ops(struct device *dev, dev_pm_domain_no_const *domain);
82938 +int vga_switcheroo_init_domain_pm_optimus_hdmi_audio(struct device *dev, dev_pm_domain_no_const *domain);
82939 #else
82940
82941 static inline void vga_switcheroo_unregister_client(struct pci_dev *dev) {}
82942 @@ -81,8 +81,8 @@ static inline int vga_switcheroo_get_client_state(struct pci_dev *dev) { return
82943
82944 static inline void vga_switcheroo_set_dynamic_switch(struct pci_dev *pdev, enum vga_switcheroo_state dynamic) {}
82945
82946 -static inline int vga_switcheroo_init_domain_pm_ops(struct device *dev, struct dev_pm_domain *domain) { return -EINVAL; }
82947 -static inline int vga_switcheroo_init_domain_pm_optimus_hdmi_audio(struct device *dev, struct dev_pm_domain *domain) { return -EINVAL; }
82948 +static inline int vga_switcheroo_init_domain_pm_ops(struct device *dev, dev_pm_domain_no_const *domain) { return -EINVAL; }
82949 +static inline int vga_switcheroo_init_domain_pm_optimus_hdmi_audio(struct device *dev, dev_pm_domain_no_const *domain) { return -EINVAL; }
82950
82951 #endif
82952 #endif /* _LINUX_VGA_SWITCHEROO_H_ */
82953 diff --git a/include/linux/vmalloc.h b/include/linux/vmalloc.h
82954 index 4b8a891..e9a2863 100644
82955 --- a/include/linux/vmalloc.h
82956 +++ b/include/linux/vmalloc.h
82957 @@ -16,6 +16,11 @@ struct vm_area_struct; /* vma defining user mapping in mm_types.h */
82958 #define VM_USERMAP 0x00000008 /* suitable for remap_vmalloc_range */
82959 #define VM_VPAGES 0x00000010 /* buffer for pages was vmalloc'ed */
82960 #define VM_UNINITIALIZED 0x00000020 /* vm_struct is not fully initialized */
82961 +
82962 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
82963 +#define VM_KERNEXEC 0x00000040 /* allocate from executable kernel memory range */
82964 +#endif
82965 +
82966 /* bits [20..32] reserved for arch specific ioremap internals */
82967
82968 /*
82969 @@ -82,6 +87,10 @@ extern void *vmap(struct page **pages, unsigned int count,
82970 unsigned long flags, pgprot_t prot);
82971 extern void vunmap(const void *addr);
82972
82973 +#ifdef CONFIG_GRKERNSEC_KSTACKOVERFLOW
82974 +extern void unmap_process_stacks(struct task_struct *task);
82975 +#endif
82976 +
82977 extern int remap_vmalloc_range_partial(struct vm_area_struct *vma,
82978 unsigned long uaddr, void *kaddr,
82979 unsigned long size);
82980 @@ -142,7 +151,7 @@ extern void free_vm_area(struct vm_struct *area);
82981
82982 /* for /dev/kmem */
82983 extern long vread(char *buf, char *addr, unsigned long count);
82984 -extern long vwrite(char *buf, char *addr, unsigned long count);
82985 +extern long vwrite(char *buf, char *addr, unsigned long count) __size_overflow(3);
82986
82987 /*
82988 * Internals. Dont't use..
82989 diff --git a/include/linux/vmstat.h b/include/linux/vmstat.h
82990 index 45c9cd1..20bd0bf 100644
82991 --- a/include/linux/vmstat.h
82992 +++ b/include/linux/vmstat.h
82993 @@ -102,18 +102,18 @@ static inline void vm_events_fold_cpu(int cpu)
82994 /*
82995 * Zone based page accounting with per cpu differentials.
82996 */
82997 -extern atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
82998 +extern atomic_long_unchecked_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
82999
83000 static inline void zone_page_state_add(long x, struct zone *zone,
83001 enum zone_stat_item item)
83002 {
83003 - atomic_long_add(x, &zone->vm_stat[item]);
83004 - atomic_long_add(x, &vm_stat[item]);
83005 + atomic_long_add_unchecked(x, &zone->vm_stat[item]);
83006 + atomic_long_add_unchecked(x, &vm_stat[item]);
83007 }
83008
83009 -static inline unsigned long global_page_state(enum zone_stat_item item)
83010 +static inline unsigned long __intentional_overflow(-1) global_page_state(enum zone_stat_item item)
83011 {
83012 - long x = atomic_long_read(&vm_stat[item]);
83013 + long x = atomic_long_read_unchecked(&vm_stat[item]);
83014 #ifdef CONFIG_SMP
83015 if (x < 0)
83016 x = 0;
83017 @@ -121,10 +121,10 @@ static inline unsigned long global_page_state(enum zone_stat_item item)
83018 return x;
83019 }
83020
83021 -static inline unsigned long zone_page_state(struct zone *zone,
83022 +static inline unsigned long __intentional_overflow(-1) zone_page_state(struct zone *zone,
83023 enum zone_stat_item item)
83024 {
83025 - long x = atomic_long_read(&zone->vm_stat[item]);
83026 + long x = atomic_long_read_unchecked(&zone->vm_stat[item]);
83027 #ifdef CONFIG_SMP
83028 if (x < 0)
83029 x = 0;
83030 @@ -141,7 +141,7 @@ static inline unsigned long zone_page_state(struct zone *zone,
83031 static inline unsigned long zone_page_state_snapshot(struct zone *zone,
83032 enum zone_stat_item item)
83033 {
83034 - long x = atomic_long_read(&zone->vm_stat[item]);
83035 + long x = atomic_long_read_unchecked(&zone->vm_stat[item]);
83036
83037 #ifdef CONFIG_SMP
83038 int cpu;
83039 @@ -228,14 +228,14 @@ static inline void __mod_zone_page_state(struct zone *zone,
83040
83041 static inline void __inc_zone_state(struct zone *zone, enum zone_stat_item item)
83042 {
83043 - atomic_long_inc(&zone->vm_stat[item]);
83044 - atomic_long_inc(&vm_stat[item]);
83045 + atomic_long_inc_unchecked(&zone->vm_stat[item]);
83046 + atomic_long_inc_unchecked(&vm_stat[item]);
83047 }
83048
83049 static inline void __dec_zone_state(struct zone *zone, enum zone_stat_item item)
83050 {
83051 - atomic_long_dec(&zone->vm_stat[item]);
83052 - atomic_long_dec(&vm_stat[item]);
83053 + atomic_long_dec_unchecked(&zone->vm_stat[item]);
83054 + atomic_long_dec_unchecked(&vm_stat[item]);
83055 }
83056
83057 static inline void __inc_zone_page_state(struct page *page,
83058 diff --git a/include/linux/xattr.h b/include/linux/xattr.h
83059 index 91b0a68..0e9adf6 100644
83060 --- a/include/linux/xattr.h
83061 +++ b/include/linux/xattr.h
83062 @@ -28,7 +28,7 @@ struct xattr_handler {
83063 size_t size, int handler_flags);
83064 int (*set)(struct dentry *dentry, const char *name, const void *buffer,
83065 size_t size, int flags, int handler_flags);
83066 -};
83067 +} __do_const;
83068
83069 struct xattr {
83070 const char *name;
83071 @@ -37,6 +37,9 @@ struct xattr {
83072 };
83073
83074 ssize_t xattr_getsecurity(struct inode *, const char *, void *, size_t);
83075 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
83076 +ssize_t pax_getxattr(struct dentry *, void *, size_t);
83077 +#endif
83078 ssize_t vfs_getxattr(struct dentry *, const char *, void *, size_t);
83079 ssize_t vfs_listxattr(struct dentry *d, char *list, size_t size);
83080 int __vfs_setxattr_noperm(struct dentry *, const char *, const void *, size_t, int);
83081 diff --git a/include/linux/zlib.h b/include/linux/zlib.h
83082 index 9c5a6b4..09c9438 100644
83083 --- a/include/linux/zlib.h
83084 +++ b/include/linux/zlib.h
83085 @@ -31,6 +31,7 @@
83086 #define _ZLIB_H
83087
83088 #include <linux/zconf.h>
83089 +#include <linux/compiler.h>
83090
83091 /* zlib deflate based on ZLIB_VERSION "1.1.3" */
83092 /* zlib inflate based on ZLIB_VERSION "1.2.3" */
83093 @@ -179,7 +180,7 @@ typedef z_stream *z_streamp;
83094
83095 /* basic functions */
83096
83097 -extern int zlib_deflate_workspacesize (int windowBits, int memLevel);
83098 +extern int zlib_deflate_workspacesize (int windowBits, int memLevel) __intentional_overflow(0);
83099 /*
83100 Returns the number of bytes that needs to be allocated for a per-
83101 stream workspace with the specified parameters. A pointer to this
83102 diff --git a/include/media/v4l2-dev.h b/include/media/v4l2-dev.h
83103 index eec6e46..82d5641 100644
83104 --- a/include/media/v4l2-dev.h
83105 +++ b/include/media/v4l2-dev.h
83106 @@ -77,7 +77,7 @@ struct v4l2_file_operations {
83107 int (*mmap) (struct file *, struct vm_area_struct *);
83108 int (*open) (struct file *);
83109 int (*release) (struct file *);
83110 -};
83111 +} __do_const;
83112
83113 /*
83114 * Newer version of video_device, handled by videodev2.c
83115 diff --git a/include/media/v4l2-device.h b/include/media/v4l2-device.h
83116 index c9b1593..a572459 100644
83117 --- a/include/media/v4l2-device.h
83118 +++ b/include/media/v4l2-device.h
83119 @@ -95,7 +95,7 @@ int __must_check v4l2_device_register(struct device *dev, struct v4l2_device *v4
83120 this function returns 0. If the name ends with a digit (e.g. cx18),
83121 then the name will be set to cx18-0 since cx180 looks really odd. */
83122 int v4l2_device_set_name(struct v4l2_device *v4l2_dev, const char *basename,
83123 - atomic_t *instance);
83124 + atomic_unchecked_t *instance);
83125
83126 /* Set v4l2_dev->dev to NULL. Call when the USB parent disconnects.
83127 Since the parent disappears this ensures that v4l2_dev doesn't have an
83128 diff --git a/include/net/9p/transport.h b/include/net/9p/transport.h
83129 index d9fa68f..45c88d1 100644
83130 --- a/include/net/9p/transport.h
83131 +++ b/include/net/9p/transport.h
83132 @@ -63,7 +63,7 @@ struct p9_trans_module {
83133 int (*cancelled)(struct p9_client *, struct p9_req_t *req);
83134 int (*zc_request)(struct p9_client *, struct p9_req_t *,
83135 char *, char *, int , int, int, int);
83136 -};
83137 +} __do_const;
83138
83139 void v9fs_register_trans(struct p9_trans_module *m);
83140 void v9fs_unregister_trans(struct p9_trans_module *m);
83141 diff --git a/include/net/af_unix.h b/include/net/af_unix.h
83142 index a175ba4..196eb82 100644
83143 --- a/include/net/af_unix.h
83144 +++ b/include/net/af_unix.h
83145 @@ -36,7 +36,7 @@ struct unix_skb_parms {
83146 u32 secid; /* Security ID */
83147 #endif
83148 u32 consumed;
83149 -};
83150 +} __randomize_layout;
83151
83152 #define UNIXCB(skb) (*(struct unix_skb_parms *)&((skb)->cb))
83153 #define UNIXSID(skb) (&UNIXCB((skb)).secid)
83154 diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h
83155 index 4abdcb2..945c5cc 100644
83156 --- a/include/net/bluetooth/l2cap.h
83157 +++ b/include/net/bluetooth/l2cap.h
83158 @@ -601,7 +601,7 @@ struct l2cap_ops {
83159 long (*get_sndtimeo) (struct l2cap_chan *chan);
83160 struct sk_buff *(*alloc_skb) (struct l2cap_chan *chan,
83161 unsigned long len, int nb);
83162 -};
83163 +} __do_const;
83164
83165 struct l2cap_conn {
83166 struct hci_conn *hcon;
83167 diff --git a/include/net/caif/cfctrl.h b/include/net/caif/cfctrl.h
83168 index f2ae33d..c457cf0 100644
83169 --- a/include/net/caif/cfctrl.h
83170 +++ b/include/net/caif/cfctrl.h
83171 @@ -52,7 +52,7 @@ struct cfctrl_rsp {
83172 void (*radioset_rsp)(void);
83173 void (*reject_rsp)(struct cflayer *layer, u8 linkid,
83174 struct cflayer *client_layer);
83175 -};
83176 +} __no_const;
83177
83178 /* Link Setup Parameters for CAIF-Links. */
83179 struct cfctrl_link_param {
83180 @@ -101,8 +101,8 @@ struct cfctrl_request_info {
83181 struct cfctrl {
83182 struct cfsrvl serv;
83183 struct cfctrl_rsp res;
83184 - atomic_t req_seq_no;
83185 - atomic_t rsp_seq_no;
83186 + atomic_unchecked_t req_seq_no;
83187 + atomic_unchecked_t rsp_seq_no;
83188 struct list_head list;
83189 /* Protects from simultaneous access to first_req list */
83190 spinlock_t info_list_lock;
83191 diff --git a/include/net/flow.h b/include/net/flow.h
83192 index 8109a15..504466d 100644
83193 --- a/include/net/flow.h
83194 +++ b/include/net/flow.h
83195 @@ -231,6 +231,6 @@ void flow_cache_fini(struct net *net);
83196
83197 void flow_cache_flush(struct net *net);
83198 void flow_cache_flush_deferred(struct net *net);
83199 -extern atomic_t flow_cache_genid;
83200 +extern atomic_unchecked_t flow_cache_genid;
83201
83202 #endif
83203 diff --git a/include/net/genetlink.h b/include/net/genetlink.h
83204 index 93695f0..766d71c 100644
83205 --- a/include/net/genetlink.h
83206 +++ b/include/net/genetlink.h
83207 @@ -120,7 +120,7 @@ struct genl_ops {
83208 u8 cmd;
83209 u8 internal_flags;
83210 u8 flags;
83211 -};
83212 +} __do_const;
83213
83214 int __genl_register_family(struct genl_family *family);
83215
83216 diff --git a/include/net/gro_cells.h b/include/net/gro_cells.h
83217 index 734d9b5..48a9a4b 100644
83218 --- a/include/net/gro_cells.h
83219 +++ b/include/net/gro_cells.h
83220 @@ -29,7 +29,7 @@ static inline void gro_cells_receive(struct gro_cells *gcells, struct sk_buff *s
83221 cell += skb_get_rx_queue(skb) & gcells->gro_cells_mask;
83222
83223 if (skb_queue_len(&cell->napi_skbs) > netdev_max_backlog) {
83224 - atomic_long_inc(&dev->rx_dropped);
83225 + atomic_long_inc_unchecked(&dev->rx_dropped);
83226 kfree_skb(skb);
83227 return;
83228 }
83229 diff --git a/include/net/inet_connection_sock.h b/include/net/inet_connection_sock.h
83230 index 7a43138..bc76865 100644
83231 --- a/include/net/inet_connection_sock.h
83232 +++ b/include/net/inet_connection_sock.h
83233 @@ -62,7 +62,7 @@ struct inet_connection_sock_af_ops {
83234 void (*addr2sockaddr)(struct sock *sk, struct sockaddr *);
83235 int (*bind_conflict)(const struct sock *sk,
83236 const struct inet_bind_bucket *tb, bool relax);
83237 -};
83238 +} __do_const;
83239
83240 /** inet_connection_sock - INET connection oriented sock
83241 *
83242 diff --git a/include/net/inetpeer.h b/include/net/inetpeer.h
83243 index 058271b..1a44af7 100644
83244 --- a/include/net/inetpeer.h
83245 +++ b/include/net/inetpeer.h
83246 @@ -47,8 +47,8 @@ struct inet_peer {
83247 */
83248 union {
83249 struct {
83250 - atomic_t rid; /* Frag reception counter */
83251 - atomic_t ip_id_count; /* IP ID for the next packet */
83252 + atomic_unchecked_t rid; /* Frag reception counter */
83253 + atomic_unchecked_t ip_id_count; /* IP ID for the next packet */
83254 };
83255 struct rcu_head rcu;
83256 struct inet_peer *gc_next;
83257 @@ -179,7 +179,7 @@ static inline int inet_getid(struct inet_peer *p, int more)
83258 {
83259 more++;
83260 inet_peer_refcheck(p);
83261 - return atomic_add_return(more, &p->ip_id_count) - more;
83262 + return atomic_add_return_unchecked(more, &p->ip_id_count) - more;
83263 }
83264
83265 #endif /* _NET_INETPEER_H */
83266 diff --git a/include/net/ip.h b/include/net/ip.h
83267 index 3ec2b0f..72435b6 100644
83268 --- a/include/net/ip.h
83269 +++ b/include/net/ip.h
83270 @@ -220,7 +220,7 @@ static inline void snmp_mib_free(void __percpu *ptr[SNMP_ARRAY_SZ])
83271
83272 void inet_get_local_port_range(struct net *net, int *low, int *high);
83273
83274 -extern unsigned long *sysctl_local_reserved_ports;
83275 +extern unsigned long sysctl_local_reserved_ports[65536 / 8 / sizeof(unsigned long)];
83276 static inline int inet_is_reserved_local_port(int port)
83277 {
83278 return test_bit(port, sysctl_local_reserved_ports);
83279 diff --git a/include/net/ip_fib.h b/include/net/ip_fib.h
83280 index 9922093..a1755d6 100644
83281 --- a/include/net/ip_fib.h
83282 +++ b/include/net/ip_fib.h
83283 @@ -169,7 +169,7 @@ __be32 fib_info_update_nh_saddr(struct net *net, struct fib_nh *nh);
83284
83285 #define FIB_RES_SADDR(net, res) \
83286 ((FIB_RES_NH(res).nh_saddr_genid == \
83287 - atomic_read(&(net)->ipv4.dev_addr_genid)) ? \
83288 + atomic_read_unchecked(&(net)->ipv4.dev_addr_genid)) ? \
83289 FIB_RES_NH(res).nh_saddr : \
83290 fib_info_update_nh_saddr((net), &FIB_RES_NH(res)))
83291 #define FIB_RES_GW(res) (FIB_RES_NH(res).nh_gw)
83292 diff --git a/include/net/ip_vs.h b/include/net/ip_vs.h
83293 index 5679d92..2e7a690 100644
83294 --- a/include/net/ip_vs.h
83295 +++ b/include/net/ip_vs.h
83296 @@ -558,7 +558,7 @@ struct ip_vs_conn {
83297 struct ip_vs_conn *control; /* Master control connection */
83298 atomic_t n_control; /* Number of controlled ones */
83299 struct ip_vs_dest *dest; /* real server */
83300 - atomic_t in_pkts; /* incoming packet counter */
83301 + atomic_unchecked_t in_pkts; /* incoming packet counter */
83302
83303 /* packet transmitter for different forwarding methods. If it
83304 mangles the packet, it must return NF_DROP or better NF_STOLEN,
83305 @@ -705,7 +705,7 @@ struct ip_vs_dest {
83306 __be16 port; /* port number of the server */
83307 union nf_inet_addr addr; /* IP address of the server */
83308 volatile unsigned int flags; /* dest status flags */
83309 - atomic_t conn_flags; /* flags to copy to conn */
83310 + atomic_unchecked_t conn_flags; /* flags to copy to conn */
83311 atomic_t weight; /* server weight */
83312
83313 atomic_t refcnt; /* reference counter */
83314 @@ -960,11 +960,11 @@ struct netns_ipvs {
83315 /* ip_vs_lblc */
83316 int sysctl_lblc_expiration;
83317 struct ctl_table_header *lblc_ctl_header;
83318 - struct ctl_table *lblc_ctl_table;
83319 + ctl_table_no_const *lblc_ctl_table;
83320 /* ip_vs_lblcr */
83321 int sysctl_lblcr_expiration;
83322 struct ctl_table_header *lblcr_ctl_header;
83323 - struct ctl_table *lblcr_ctl_table;
83324 + ctl_table_no_const *lblcr_ctl_table;
83325 /* ip_vs_est */
83326 struct list_head est_list; /* estimator list */
83327 spinlock_t est_lock;
83328 diff --git a/include/net/irda/ircomm_tty.h b/include/net/irda/ircomm_tty.h
83329 index 8d4f588..2e37ad2 100644
83330 --- a/include/net/irda/ircomm_tty.h
83331 +++ b/include/net/irda/ircomm_tty.h
83332 @@ -33,6 +33,7 @@
83333 #include <linux/termios.h>
83334 #include <linux/timer.h>
83335 #include <linux/tty.h> /* struct tty_struct */
83336 +#include <asm/local.h>
83337
83338 #include <net/irda/irias_object.h>
83339 #include <net/irda/ircomm_core.h>
83340 diff --git a/include/net/iucv/af_iucv.h b/include/net/iucv/af_iucv.h
83341 index 714cc9a..ea05f3e 100644
83342 --- a/include/net/iucv/af_iucv.h
83343 +++ b/include/net/iucv/af_iucv.h
83344 @@ -149,7 +149,7 @@ struct iucv_skb_cb {
83345 struct iucv_sock_list {
83346 struct hlist_head head;
83347 rwlock_t lock;
83348 - atomic_t autobind_name;
83349 + atomic_unchecked_t autobind_name;
83350 };
83351
83352 unsigned int iucv_sock_poll(struct file *file, struct socket *sock,
83353 diff --git a/include/net/llc_c_ac.h b/include/net/llc_c_ac.h
83354 index f3be818..bf46196 100644
83355 --- a/include/net/llc_c_ac.h
83356 +++ b/include/net/llc_c_ac.h
83357 @@ -87,7 +87,7 @@
83358 #define LLC_CONN_AC_STOP_SENDACK_TMR 70
83359 #define LLC_CONN_AC_START_SENDACK_TMR_IF_NOT_RUNNING 71
83360
83361 -typedef int (*llc_conn_action_t)(struct sock *sk, struct sk_buff *skb);
83362 +typedef int (* const llc_conn_action_t)(struct sock *sk, struct sk_buff *skb);
83363
83364 int llc_conn_ac_clear_remote_busy(struct sock *sk, struct sk_buff *skb);
83365 int llc_conn_ac_conn_ind(struct sock *sk, struct sk_buff *skb);
83366 diff --git a/include/net/llc_c_ev.h b/include/net/llc_c_ev.h
83367 index 3948cf1..83b28c4 100644
83368 --- a/include/net/llc_c_ev.h
83369 +++ b/include/net/llc_c_ev.h
83370 @@ -125,8 +125,8 @@ static __inline__ struct llc_conn_state_ev *llc_conn_ev(struct sk_buff *skb)
83371 return (struct llc_conn_state_ev *)skb->cb;
83372 }
83373
83374 -typedef int (*llc_conn_ev_t)(struct sock *sk, struct sk_buff *skb);
83375 -typedef int (*llc_conn_ev_qfyr_t)(struct sock *sk, struct sk_buff *skb);
83376 +typedef int (* const llc_conn_ev_t)(struct sock *sk, struct sk_buff *skb);
83377 +typedef int (* const llc_conn_ev_qfyr_t)(struct sock *sk, struct sk_buff *skb);
83378
83379 int llc_conn_ev_conn_req(struct sock *sk, struct sk_buff *skb);
83380 int llc_conn_ev_data_req(struct sock *sk, struct sk_buff *skb);
83381 diff --git a/include/net/llc_c_st.h b/include/net/llc_c_st.h
83382 index 0e79cfb..f46db31 100644
83383 --- a/include/net/llc_c_st.h
83384 +++ b/include/net/llc_c_st.h
83385 @@ -37,7 +37,7 @@ struct llc_conn_state_trans {
83386 u8 next_state;
83387 llc_conn_ev_qfyr_t *ev_qualifiers;
83388 llc_conn_action_t *ev_actions;
83389 -};
83390 +} __do_const;
83391
83392 struct llc_conn_state {
83393 u8 current_state;
83394 diff --git a/include/net/llc_s_ac.h b/include/net/llc_s_ac.h
83395 index a61b98c..aade1eb 100644
83396 --- a/include/net/llc_s_ac.h
83397 +++ b/include/net/llc_s_ac.h
83398 @@ -23,7 +23,7 @@
83399 #define SAP_ACT_TEST_IND 9
83400
83401 /* All action functions must look like this */
83402 -typedef int (*llc_sap_action_t)(struct llc_sap *sap, struct sk_buff *skb);
83403 +typedef int (* const llc_sap_action_t)(struct llc_sap *sap, struct sk_buff *skb);
83404
83405 int llc_sap_action_unitdata_ind(struct llc_sap *sap, struct sk_buff *skb);
83406 int llc_sap_action_send_ui(struct llc_sap *sap, struct sk_buff *skb);
83407 diff --git a/include/net/llc_s_st.h b/include/net/llc_s_st.h
83408 index 567c681..cd73ac02 100644
83409 --- a/include/net/llc_s_st.h
83410 +++ b/include/net/llc_s_st.h
83411 @@ -20,7 +20,7 @@ struct llc_sap_state_trans {
83412 llc_sap_ev_t ev;
83413 u8 next_state;
83414 llc_sap_action_t *ev_actions;
83415 -};
83416 +} __do_const;
83417
83418 struct llc_sap_state {
83419 u8 curr_state;
83420 diff --git a/include/net/mac80211.h b/include/net/mac80211.h
83421 index 8248e39..7610eec 100644
83422 --- a/include/net/mac80211.h
83423 +++ b/include/net/mac80211.h
83424 @@ -4467,7 +4467,7 @@ struct rate_control_ops {
83425 void (*add_sta_debugfs)(void *priv, void *priv_sta,
83426 struct dentry *dir);
83427 void (*remove_sta_debugfs)(void *priv, void *priv_sta);
83428 -};
83429 +} __do_const;
83430
83431 static inline int rate_supported(struct ieee80211_sta *sta,
83432 enum ieee80211_band band,
83433 diff --git a/include/net/neighbour.h b/include/net/neighbour.h
83434 index 7277caf..fd095bc 100644
83435 --- a/include/net/neighbour.h
83436 +++ b/include/net/neighbour.h
83437 @@ -163,7 +163,7 @@ struct neigh_ops {
83438 void (*error_report)(struct neighbour *, struct sk_buff *);
83439 int (*output)(struct neighbour *, struct sk_buff *);
83440 int (*connected_output)(struct neighbour *, struct sk_buff *);
83441 -};
83442 +} __do_const;
83443
83444 struct pneigh_entry {
83445 struct pneigh_entry *next;
83446 @@ -203,7 +203,6 @@ struct neigh_table {
83447 void (*proxy_redo)(struct sk_buff *skb);
83448 char *id;
83449 struct neigh_parms parms;
83450 - /* HACK. gc_* should follow parms without a gap! */
83451 int gc_interval;
83452 int gc_thresh1;
83453 int gc_thresh2;
83454 @@ -218,7 +217,7 @@ struct neigh_table {
83455 struct neigh_statistics __percpu *stats;
83456 struct neigh_hash_table __rcu *nht;
83457 struct pneigh_entry **phash_buckets;
83458 -};
83459 +} __randomize_layout;
83460
83461 static inline int neigh_parms_family(struct neigh_parms *p)
83462 {
83463 diff --git a/include/net/net_namespace.h b/include/net/net_namespace.h
83464 index 5f9eb26..85699c4 100644
83465 --- a/include/net/net_namespace.h
83466 +++ b/include/net/net_namespace.h
83467 @@ -129,8 +129,8 @@ struct net {
83468 struct netns_ipvs *ipvs;
83469 #endif
83470 struct sock *diag_nlsk;
83471 - atomic_t fnhe_genid;
83472 -};
83473 + atomic_unchecked_t fnhe_genid;
83474 +} __randomize_layout;
83475
83476 #include <linux/seq_file_net.h>
83477
83478 @@ -286,7 +286,11 @@ static inline struct net *read_pnet(struct net * const *pnet)
83479 #define __net_init __init
83480 #define __net_exit __exit_refok
83481 #define __net_initdata __initdata
83482 +#ifdef CONSTIFY_PLUGIN
83483 #define __net_initconst __initconst
83484 +#else
83485 +#define __net_initconst __initdata
83486 +#endif
83487 #endif
83488
83489 struct pernet_operations {
83490 @@ -296,7 +300,7 @@ struct pernet_operations {
83491 void (*exit_batch)(struct list_head *net_exit_list);
83492 int *id;
83493 size_t size;
83494 -};
83495 +} __do_const;
83496
83497 /*
83498 * Use these carefully. If you implement a network device and it
83499 @@ -344,23 +348,23 @@ static inline void unregister_net_sysctl_table(struct ctl_table_header *header)
83500
83501 static inline int rt_genid_ipv4(struct net *net)
83502 {
83503 - return atomic_read(&net->ipv4.rt_genid);
83504 + return atomic_read_unchecked(&net->ipv4.rt_genid);
83505 }
83506
83507 static inline void rt_genid_bump_ipv4(struct net *net)
83508 {
83509 - atomic_inc(&net->ipv4.rt_genid);
83510 + atomic_inc_unchecked(&net->ipv4.rt_genid);
83511 }
83512
83513 #if IS_ENABLED(CONFIG_IPV6)
83514 static inline int rt_genid_ipv6(struct net *net)
83515 {
83516 - return atomic_read(&net->ipv6.rt_genid);
83517 + return atomic_read_unchecked(&net->ipv6.rt_genid);
83518 }
83519
83520 static inline void rt_genid_bump_ipv6(struct net *net)
83521 {
83522 - atomic_inc(&net->ipv6.rt_genid);
83523 + atomic_inc_unchecked(&net->ipv6.rt_genid);
83524 }
83525 #else
83526 static inline int rt_genid_ipv6(struct net *net)
83527 @@ -382,12 +386,12 @@ static inline void rt_genid_bump_all(struct net *net)
83528
83529 static inline int fnhe_genid(struct net *net)
83530 {
83531 - return atomic_read(&net->fnhe_genid);
83532 + return atomic_read_unchecked(&net->fnhe_genid);
83533 }
83534
83535 static inline void fnhe_genid_bump(struct net *net)
83536 {
83537 - atomic_inc(&net->fnhe_genid);
83538 + atomic_inc_unchecked(&net->fnhe_genid);
83539 }
83540
83541 #endif /* __NET_NET_NAMESPACE_H */
83542 diff --git a/include/net/netdma.h b/include/net/netdma.h
83543 index 8ba8ce2..99b7fff 100644
83544 --- a/include/net/netdma.h
83545 +++ b/include/net/netdma.h
83546 @@ -24,7 +24,7 @@
83547 #include <linux/dmaengine.h>
83548 #include <linux/skbuff.h>
83549
83550 -int dma_skb_copy_datagram_iovec(struct dma_chan* chan,
83551 +int __intentional_overflow(3,5) dma_skb_copy_datagram_iovec(struct dma_chan* chan,
83552 struct sk_buff *skb, int offset, struct iovec *to,
83553 size_t len, struct dma_pinned_list *pinned_list);
83554
83555 diff --git a/include/net/netlink.h b/include/net/netlink.h
83556 index 2b47eaa..6d5bcc2 100644
83557 --- a/include/net/netlink.h
83558 +++ b/include/net/netlink.h
83559 @@ -521,7 +521,7 @@ static inline void *nlmsg_get_pos(struct sk_buff *skb)
83560 static inline void nlmsg_trim(struct sk_buff *skb, const void *mark)
83561 {
83562 if (mark)
83563 - skb_trim(skb, (unsigned char *) mark - skb->data);
83564 + skb_trim(skb, (const unsigned char *) mark - skb->data);
83565 }
83566
83567 /**
83568 diff --git a/include/net/netns/conntrack.h b/include/net/netns/conntrack.h
83569 index 773cce3..6a11852 100644
83570 --- a/include/net/netns/conntrack.h
83571 +++ b/include/net/netns/conntrack.h
83572 @@ -13,10 +13,10 @@ struct nf_conntrack_ecache;
83573 struct nf_proto_net {
83574 #ifdef CONFIG_SYSCTL
83575 struct ctl_table_header *ctl_table_header;
83576 - struct ctl_table *ctl_table;
83577 + ctl_table_no_const *ctl_table;
83578 #ifdef CONFIG_NF_CONNTRACK_PROC_COMPAT
83579 struct ctl_table_header *ctl_compat_header;
83580 - struct ctl_table *ctl_compat_table;
83581 + ctl_table_no_const *ctl_compat_table;
83582 #endif
83583 #endif
83584 unsigned int users;
83585 @@ -59,7 +59,7 @@ struct nf_ip_net {
83586 struct nf_icmp_net icmpv6;
83587 #if defined(CONFIG_SYSCTL) && defined(CONFIG_NF_CONNTRACK_PROC_COMPAT)
83588 struct ctl_table_header *ctl_table_header;
83589 - struct ctl_table *ctl_table;
83590 + ctl_table_no_const *ctl_table;
83591 #endif
83592 };
83593
83594 diff --git a/include/net/netns/ipv4.h b/include/net/netns/ipv4.h
83595 index b2704fd0..421d717 100644
83596 --- a/include/net/netns/ipv4.h
83597 +++ b/include/net/netns/ipv4.h
83598 @@ -79,7 +79,7 @@ struct netns_ipv4 {
83599
83600 struct ping_group_range ping_group_range;
83601
83602 - atomic_t dev_addr_genid;
83603 + atomic_unchecked_t dev_addr_genid;
83604
83605 #ifdef CONFIG_IP_MROUTE
83606 #ifndef CONFIG_IP_MROUTE_MULTIPLE_TABLES
83607 @@ -89,6 +89,6 @@ struct netns_ipv4 {
83608 struct fib_rules_ops *mr_rules_ops;
83609 #endif
83610 #endif
83611 - atomic_t rt_genid;
83612 + atomic_unchecked_t rt_genid;
83613 };
83614 #endif
83615 diff --git a/include/net/netns/ipv6.h b/include/net/netns/ipv6.h
83616 index 21edaf1..4c5faae 100644
83617 --- a/include/net/netns/ipv6.h
83618 +++ b/include/net/netns/ipv6.h
83619 @@ -73,8 +73,8 @@ struct netns_ipv6 {
83620 struct fib_rules_ops *mr6_rules_ops;
83621 #endif
83622 #endif
83623 - atomic_t dev_addr_genid;
83624 - atomic_t rt_genid;
83625 + atomic_unchecked_t dev_addr_genid;
83626 + atomic_unchecked_t rt_genid;
83627 };
83628
83629 #if IS_ENABLED(CONFIG_NF_DEFRAG_IPV6)
83630 diff --git a/include/net/netns/xfrm.h b/include/net/netns/xfrm.h
83631 index 3492434..209f58c 100644
83632 --- a/include/net/netns/xfrm.h
83633 +++ b/include/net/netns/xfrm.h
83634 @@ -64,7 +64,7 @@ struct netns_xfrm {
83635
83636 /* flow cache part */
83637 struct flow_cache flow_cache_global;
83638 - atomic_t flow_cache_genid;
83639 + atomic_unchecked_t flow_cache_genid;
83640 struct list_head flow_cache_gc_list;
83641 spinlock_t flow_cache_gc_lock;
83642 struct work_struct flow_cache_gc_work;
83643 diff --git a/include/net/ping.h b/include/net/ping.h
83644 index 026479b..d9b2829 100644
83645 --- a/include/net/ping.h
83646 +++ b/include/net/ping.h
83647 @@ -54,7 +54,7 @@ struct ping_iter_state {
83648
83649 extern struct proto ping_prot;
83650 #if IS_ENABLED(CONFIG_IPV6)
83651 -extern struct pingv6_ops pingv6_ops;
83652 +extern struct pingv6_ops *pingv6_ops;
83653 #endif
83654
83655 struct pingfakehdr {
83656 diff --git a/include/net/protocol.h b/include/net/protocol.h
83657 index a7e986b..dc67bce 100644
83658 --- a/include/net/protocol.h
83659 +++ b/include/net/protocol.h
83660 @@ -49,7 +49,7 @@ struct net_protocol {
83661 * socket lookup?
83662 */
83663 icmp_strict_tag_validation:1;
83664 -};
83665 +} __do_const;
83666
83667 #if IS_ENABLED(CONFIG_IPV6)
83668 struct inet6_protocol {
83669 @@ -62,7 +62,7 @@ struct inet6_protocol {
83670 u8 type, u8 code, int offset,
83671 __be32 info);
83672 unsigned int flags; /* INET6_PROTO_xxx */
83673 -};
83674 +} __do_const;
83675
83676 #define INET6_PROTO_NOPOLICY 0x1
83677 #define INET6_PROTO_FINAL 0x2
83678 diff --git a/include/net/rtnetlink.h b/include/net/rtnetlink.h
83679 index 72240e5..8c14bef 100644
83680 --- a/include/net/rtnetlink.h
83681 +++ b/include/net/rtnetlink.h
83682 @@ -93,7 +93,7 @@ struct rtnl_link_ops {
83683 int (*fill_slave_info)(struct sk_buff *skb,
83684 const struct net_device *dev,
83685 const struct net_device *slave_dev);
83686 -};
83687 +} __do_const;
83688
83689 int __rtnl_link_register(struct rtnl_link_ops *ops);
83690 void __rtnl_link_unregister(struct rtnl_link_ops *ops);
83691 diff --git a/include/net/sctp/checksum.h b/include/net/sctp/checksum.h
83692 index 4a5b9a3..ca27d73 100644
83693 --- a/include/net/sctp/checksum.h
83694 +++ b/include/net/sctp/checksum.h
83695 @@ -61,8 +61,8 @@ static inline __le32 sctp_compute_cksum(const struct sk_buff *skb,
83696 unsigned int offset)
83697 {
83698 struct sctphdr *sh = sctp_hdr(skb);
83699 - __le32 ret, old = sh->checksum;
83700 - const struct skb_checksum_ops ops = {
83701 + __le32 ret, old = sh->checksum;
83702 + static const struct skb_checksum_ops ops = {
83703 .update = sctp_csum_update,
83704 .combine = sctp_csum_combine,
83705 };
83706 diff --git a/include/net/sctp/sm.h b/include/net/sctp/sm.h
83707 index 7f4eeb3..37e8fe1 100644
83708 --- a/include/net/sctp/sm.h
83709 +++ b/include/net/sctp/sm.h
83710 @@ -80,7 +80,7 @@ typedef void (sctp_timer_event_t) (unsigned long);
83711 typedef struct {
83712 sctp_state_fn_t *fn;
83713 const char *name;
83714 -} sctp_sm_table_entry_t;
83715 +} __do_const sctp_sm_table_entry_t;
83716
83717 /* A naming convention of "sctp_sf_xxx" applies to all the state functions
83718 * currently in use.
83719 @@ -292,7 +292,7 @@ __u32 sctp_generate_tag(const struct sctp_endpoint *);
83720 __u32 sctp_generate_tsn(const struct sctp_endpoint *);
83721
83722 /* Extern declarations for major data structures. */
83723 -extern sctp_timer_event_t *sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES];
83724 +extern sctp_timer_event_t * const sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES];
83725
83726
83727 /* Get the size of a DATA chunk payload. */
83728 diff --git a/include/net/sctp/structs.h b/include/net/sctp/structs.h
83729 index 0dfcc92..7967849 100644
83730 --- a/include/net/sctp/structs.h
83731 +++ b/include/net/sctp/structs.h
83732 @@ -507,7 +507,7 @@ struct sctp_pf {
83733 struct sctp_association *asoc);
83734 void (*addr_v4map) (struct sctp_sock *, union sctp_addr *);
83735 struct sctp_af *af;
83736 -};
83737 +} __do_const;
83738
83739
83740 /* Structure to track chunk fragments that have been acked, but peer
83741 diff --git a/include/net/sock.h b/include/net/sock.h
83742 index 21569cf..fc25c8e 100644
83743 --- a/include/net/sock.h
83744 +++ b/include/net/sock.h
83745 @@ -348,7 +348,7 @@ struct sock {
83746 unsigned int sk_napi_id;
83747 unsigned int sk_ll_usec;
83748 #endif
83749 - atomic_t sk_drops;
83750 + atomic_unchecked_t sk_drops;
83751 int sk_rcvbuf;
83752
83753 struct sk_filter __rcu *sk_filter;
83754 @@ -1036,7 +1036,7 @@ struct proto {
83755 void (*destroy_cgroup)(struct mem_cgroup *memcg);
83756 struct cg_proto *(*proto_cgroup)(struct mem_cgroup *memcg);
83757 #endif
83758 -};
83759 +} __randomize_layout;
83760
83761 /*
83762 * Bits in struct cg_proto.flags
83763 @@ -1223,7 +1223,7 @@ static inline u64 memcg_memory_allocated_read(struct cg_proto *prot)
83764 return ret >> PAGE_SHIFT;
83765 }
83766
83767 -static inline long
83768 +static inline long __intentional_overflow(-1)
83769 sk_memory_allocated(const struct sock *sk)
83770 {
83771 struct proto *prot = sk->sk_prot;
83772 @@ -1368,7 +1368,7 @@ struct sock_iocb {
83773 struct scm_cookie *scm;
83774 struct msghdr *msg, async_msg;
83775 struct kiocb *kiocb;
83776 -};
83777 +} __randomize_layout;
83778
83779 static inline struct sock_iocb *kiocb_to_siocb(struct kiocb *iocb)
83780 {
83781 @@ -1803,7 +1803,7 @@ static inline void sk_nocaps_add(struct sock *sk, netdev_features_t flags)
83782 }
83783
83784 static inline int skb_do_copy_data_nocache(struct sock *sk, struct sk_buff *skb,
83785 - char __user *from, char *to,
83786 + char __user *from, unsigned char *to,
83787 int copy, int offset)
83788 {
83789 if (skb->ip_summed == CHECKSUM_NONE) {
83790 @@ -2065,7 +2065,7 @@ static inline void sk_stream_moderate_sndbuf(struct sock *sk)
83791 }
83792 }
83793
83794 -struct sk_buff *sk_stream_alloc_skb(struct sock *sk, int size, gfp_t gfp);
83795 +struct sk_buff * __intentional_overflow(0) sk_stream_alloc_skb(struct sock *sk, int size, gfp_t gfp);
83796
83797 /**
83798 * sk_page_frag - return an appropriate page_frag
83799 diff --git a/include/net/tcp.h b/include/net/tcp.h
83800 index 87d8774..cf214f8 100644
83801 --- a/include/net/tcp.h
83802 +++ b/include/net/tcp.h
83803 @@ -541,7 +541,7 @@ void tcp_retransmit_timer(struct sock *sk);
83804 void tcp_xmit_retransmit_queue(struct sock *);
83805 void tcp_simple_retransmit(struct sock *);
83806 int tcp_trim_head(struct sock *, struct sk_buff *, u32);
83807 -int tcp_fragment(struct sock *, struct sk_buff *, u32, unsigned int);
83808 +int __intentional_overflow(3) tcp_fragment(struct sock *, struct sk_buff *, u32, unsigned int);
83809
83810 void tcp_send_probe0(struct sock *);
83811 void tcp_send_partial(struct sock *);
83812 @@ -715,8 +715,8 @@ struct tcp_skb_cb {
83813 struct inet6_skb_parm h6;
83814 #endif
83815 } header; /* For incoming frames */
83816 - __u32 seq; /* Starting sequence number */
83817 - __u32 end_seq; /* SEQ + FIN + SYN + datalen */
83818 + __u32 seq __intentional_overflow(0); /* Starting sequence number */
83819 + __u32 end_seq __intentional_overflow(0); /* SEQ + FIN + SYN + datalen */
83820 __u32 when; /* used to compute rtt's */
83821 __u8 tcp_flags; /* TCP header flags. (tcp[13]) */
83822
83823 @@ -730,7 +730,7 @@ struct tcp_skb_cb {
83824
83825 __u8 ip_dsfield; /* IPv4 tos or IPv6 dsfield */
83826 /* 1 byte hole */
83827 - __u32 ack_seq; /* Sequence number ACK'd */
83828 + __u32 ack_seq __intentional_overflow(0); /* Sequence number ACK'd */
83829 };
83830
83831 #define TCP_SKB_CB(__skb) ((struct tcp_skb_cb *)&((__skb)->cb[0]))
83832 diff --git a/include/net/xfrm.h b/include/net/xfrm.h
83833 index 116e9c7..3070537 100644
83834 --- a/include/net/xfrm.h
83835 +++ b/include/net/xfrm.h
83836 @@ -285,7 +285,6 @@ struct xfrm_dst;
83837 struct xfrm_policy_afinfo {
83838 unsigned short family;
83839 struct dst_ops *dst_ops;
83840 - void (*garbage_collect)(struct net *net);
83841 struct dst_entry *(*dst_lookup)(struct net *net, int tos,
83842 const xfrm_address_t *saddr,
83843 const xfrm_address_t *daddr);
83844 @@ -303,7 +302,7 @@ struct xfrm_policy_afinfo {
83845 struct net_device *dev,
83846 const struct flowi *fl);
83847 struct dst_entry *(*blackhole_route)(struct net *net, struct dst_entry *orig);
83848 -};
83849 +} __do_const;
83850
83851 int xfrm_policy_register_afinfo(struct xfrm_policy_afinfo *afinfo);
83852 int xfrm_policy_unregister_afinfo(struct xfrm_policy_afinfo *afinfo);
83853 @@ -342,7 +341,7 @@ struct xfrm_state_afinfo {
83854 int (*transport_finish)(struct sk_buff *skb,
83855 int async);
83856 void (*local_error)(struct sk_buff *skb, u32 mtu);
83857 -};
83858 +} __do_const;
83859
83860 int xfrm_state_register_afinfo(struct xfrm_state_afinfo *afinfo);
83861 int xfrm_state_unregister_afinfo(struct xfrm_state_afinfo *afinfo);
83862 @@ -437,7 +436,7 @@ struct xfrm_mode {
83863 struct module *owner;
83864 unsigned int encap;
83865 int flags;
83866 -};
83867 +} __do_const;
83868
83869 /* Flags for xfrm_mode. */
83870 enum {
83871 @@ -534,7 +533,7 @@ struct xfrm_policy {
83872 struct timer_list timer;
83873
83874 struct flow_cache_object flo;
83875 - atomic_t genid;
83876 + atomic_unchecked_t genid;
83877 u32 priority;
83878 u32 index;
83879 struct xfrm_mark mark;
83880 @@ -1180,6 +1179,7 @@ static inline void xfrm_sk_free_policy(struct sock *sk)
83881 }
83882
83883 void xfrm_garbage_collect(struct net *net);
83884 +void xfrm_garbage_collect_deferred(struct net *net);
83885
83886 #else
83887
83888 @@ -1218,6 +1218,9 @@ static inline int xfrm6_policy_check_reverse(struct sock *sk, int dir,
83889 static inline void xfrm_garbage_collect(struct net *net)
83890 {
83891 }
83892 +static inline void xfrm_garbage_collect_deferred(struct net *net)
83893 +{
83894 +}
83895 #endif
83896
83897 static __inline__
83898 diff --git a/include/rdma/iw_cm.h b/include/rdma/iw_cm.h
83899 index 1017e0b..227aa4d 100644
83900 --- a/include/rdma/iw_cm.h
83901 +++ b/include/rdma/iw_cm.h
83902 @@ -122,7 +122,7 @@ struct iw_cm_verbs {
83903 int backlog);
83904
83905 int (*destroy_listen)(struct iw_cm_id *cm_id);
83906 -};
83907 +} __no_const;
83908
83909 /**
83910 * iw_create_cm_id - Create an IW CM identifier.
83911 diff --git a/include/scsi/libfc.h b/include/scsi/libfc.h
83912 index 52beadf..598734c 100644
83913 --- a/include/scsi/libfc.h
83914 +++ b/include/scsi/libfc.h
83915 @@ -771,6 +771,7 @@ struct libfc_function_template {
83916 */
83917 void (*disc_stop_final) (struct fc_lport *);
83918 };
83919 +typedef struct libfc_function_template __no_const libfc_function_template_no_const;
83920
83921 /**
83922 * struct fc_disc - Discovery context
83923 @@ -875,7 +876,7 @@ struct fc_lport {
83924 struct fc_vport *vport;
83925
83926 /* Operational Information */
83927 - struct libfc_function_template tt;
83928 + libfc_function_template_no_const tt;
83929 u8 link_up;
83930 u8 qfull;
83931 enum fc_lport_state state;
83932 diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h
83933 index 5853c91..1e355a8 100644
83934 --- a/include/scsi/scsi_device.h
83935 +++ b/include/scsi/scsi_device.h
83936 @@ -186,9 +186,9 @@ struct scsi_device {
83937 unsigned int max_device_blocked; /* what device_blocked counts down from */
83938 #define SCSI_DEFAULT_DEVICE_BLOCKED 3
83939
83940 - atomic_t iorequest_cnt;
83941 - atomic_t iodone_cnt;
83942 - atomic_t ioerr_cnt;
83943 + atomic_unchecked_t iorequest_cnt;
83944 + atomic_unchecked_t iodone_cnt;
83945 + atomic_unchecked_t ioerr_cnt;
83946
83947 struct device sdev_gendev,
83948 sdev_dev;
83949 diff --git a/include/scsi/scsi_transport_fc.h b/include/scsi/scsi_transport_fc.h
83950 index 8c79980..723f6f9 100644
83951 --- a/include/scsi/scsi_transport_fc.h
83952 +++ b/include/scsi/scsi_transport_fc.h
83953 @@ -752,7 +752,8 @@ struct fc_function_template {
83954 unsigned long show_host_system_hostname:1;
83955
83956 unsigned long disable_target_scan:1;
83957 -};
83958 +} __do_const;
83959 +typedef struct fc_function_template __no_const fc_function_template_no_const;
83960
83961
83962 /**
83963 diff --git a/include/sound/compress_driver.h b/include/sound/compress_driver.h
83964 index ae6c3b8..fd748ac 100644
83965 --- a/include/sound/compress_driver.h
83966 +++ b/include/sound/compress_driver.h
83967 @@ -128,7 +128,7 @@ struct snd_compr_ops {
83968 struct snd_compr_caps *caps);
83969 int (*get_codec_caps) (struct snd_compr_stream *stream,
83970 struct snd_compr_codec_caps *codec);
83971 -};
83972 +} __no_const;
83973
83974 /**
83975 * struct snd_compr: Compressed device
83976 diff --git a/include/sound/soc.h b/include/sound/soc.h
83977 index 0b83168..d67280a 100644
83978 --- a/include/sound/soc.h
83979 +++ b/include/sound/soc.h
83980 @@ -782,7 +782,7 @@ struct snd_soc_codec_driver {
83981 /* probe ordering - for components with runtime dependencies */
83982 int probe_order;
83983 int remove_order;
83984 -};
83985 +} __do_const;
83986
83987 /* SoC platform interface */
83988 struct snd_soc_platform_driver {
83989 @@ -828,7 +828,7 @@ struct snd_soc_platform_driver {
83990 unsigned int (*read)(struct snd_soc_platform *, unsigned int);
83991 int (*write)(struct snd_soc_platform *, unsigned int, unsigned int);
83992 int (*bespoke_trigger)(struct snd_pcm_substream *, int);
83993 -};
83994 +} __do_const;
83995
83996 struct snd_soc_platform {
83997 const char *name;
83998 diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h
83999 index 9ec9864..e2ee1ee 100644
84000 --- a/include/target/target_core_base.h
84001 +++ b/include/target/target_core_base.h
84002 @@ -761,7 +761,7 @@ struct se_device {
84003 atomic_long_t write_bytes;
84004 /* Active commands on this virtual SE device */
84005 atomic_t simple_cmds;
84006 - atomic_t dev_ordered_id;
84007 + atomic_unchecked_t dev_ordered_id;
84008 atomic_t dev_ordered_sync;
84009 atomic_t dev_qf_count;
84010 int export_count;
84011 diff --git a/include/trace/events/fs.h b/include/trace/events/fs.h
84012 new file mode 100644
84013 index 0000000..fb634b7
84014 --- /dev/null
84015 +++ b/include/trace/events/fs.h
84016 @@ -0,0 +1,53 @@
84017 +#undef TRACE_SYSTEM
84018 +#define TRACE_SYSTEM fs
84019 +
84020 +#if !defined(_TRACE_FS_H) || defined(TRACE_HEADER_MULTI_READ)
84021 +#define _TRACE_FS_H
84022 +
84023 +#include <linux/fs.h>
84024 +#include <linux/tracepoint.h>
84025 +
84026 +TRACE_EVENT(do_sys_open,
84027 +
84028 + TP_PROTO(const char *filename, int flags, int mode),
84029 +
84030 + TP_ARGS(filename, flags, mode),
84031 +
84032 + TP_STRUCT__entry(
84033 + __string( filename, filename )
84034 + __field( int, flags )
84035 + __field( int, mode )
84036 + ),
84037 +
84038 + TP_fast_assign(
84039 + __assign_str(filename, filename);
84040 + __entry->flags = flags;
84041 + __entry->mode = mode;
84042 + ),
84043 +
84044 + TP_printk("\"%s\" %x %o",
84045 + __get_str(filename), __entry->flags, __entry->mode)
84046 +);
84047 +
84048 +TRACE_EVENT(open_exec,
84049 +
84050 + TP_PROTO(const char *filename),
84051 +
84052 + TP_ARGS(filename),
84053 +
84054 + TP_STRUCT__entry(
84055 + __string( filename, filename )
84056 + ),
84057 +
84058 + TP_fast_assign(
84059 + __assign_str(filename, filename);
84060 + ),
84061 +
84062 + TP_printk("\"%s\"",
84063 + __get_str(filename))
84064 +);
84065 +
84066 +#endif /* _TRACE_FS_H */
84067 +
84068 +/* This part must be outside protection */
84069 +#include <trace/define_trace.h>
84070 diff --git a/include/trace/events/irq.h b/include/trace/events/irq.h
84071 index 1c09820..7f5ec79 100644
84072 --- a/include/trace/events/irq.h
84073 +++ b/include/trace/events/irq.h
84074 @@ -36,7 +36,7 @@ struct softirq_action;
84075 */
84076 TRACE_EVENT(irq_handler_entry,
84077
84078 - TP_PROTO(int irq, struct irqaction *action),
84079 + TP_PROTO(int irq, const struct irqaction *action),
84080
84081 TP_ARGS(irq, action),
84082
84083 @@ -66,7 +66,7 @@ TRACE_EVENT(irq_handler_entry,
84084 */
84085 TRACE_EVENT(irq_handler_exit,
84086
84087 - TP_PROTO(int irq, struct irqaction *action, int ret),
84088 + TP_PROTO(int irq, const struct irqaction *action, int ret),
84089
84090 TP_ARGS(irq, action, ret),
84091
84092 diff --git a/include/uapi/linux/a.out.h b/include/uapi/linux/a.out.h
84093 index 7caf44c..23c6f27 100644
84094 --- a/include/uapi/linux/a.out.h
84095 +++ b/include/uapi/linux/a.out.h
84096 @@ -39,6 +39,14 @@ enum machine_type {
84097 M_MIPS2 = 152 /* MIPS R6000/R4000 binary */
84098 };
84099
84100 +/* Constants for the N_FLAGS field */
84101 +#define F_PAX_PAGEEXEC 1 /* Paging based non-executable pages */
84102 +#define F_PAX_EMUTRAMP 2 /* Emulate trampolines */
84103 +#define F_PAX_MPROTECT 4 /* Restrict mprotect() */
84104 +#define F_PAX_RANDMMAP 8 /* Randomize mmap() base */
84105 +/*#define F_PAX_RANDEXEC 16*/ /* Randomize ET_EXEC base */
84106 +#define F_PAX_SEGMEXEC 32 /* Segmentation based non-executable pages */
84107 +
84108 #if !defined (N_MAGIC)
84109 #define N_MAGIC(exec) ((exec).a_info & 0xffff)
84110 #endif
84111 diff --git a/include/uapi/linux/bcache.h b/include/uapi/linux/bcache.h
84112 index 22b6ad3..aeba37e 100644
84113 --- a/include/uapi/linux/bcache.h
84114 +++ b/include/uapi/linux/bcache.h
84115 @@ -5,6 +5,7 @@
84116 * Bcache on disk data structures
84117 */
84118
84119 +#include <linux/compiler.h>
84120 #include <asm/types.h>
84121
84122 #define BITMASK(name, type, field, offset, size) \
84123 @@ -20,8 +21,8 @@ static inline void SET_##name(type *k, __u64 v) \
84124 /* Btree keys - all units are in sectors */
84125
84126 struct bkey {
84127 - __u64 high;
84128 - __u64 low;
84129 + __u64 high __intentional_overflow(-1);
84130 + __u64 low __intentional_overflow(-1);
84131 __u64 ptr[];
84132 };
84133
84134 diff --git a/include/uapi/linux/byteorder/little_endian.h b/include/uapi/linux/byteorder/little_endian.h
84135 index d876736..ccce5c0 100644
84136 --- a/include/uapi/linux/byteorder/little_endian.h
84137 +++ b/include/uapi/linux/byteorder/little_endian.h
84138 @@ -42,51 +42,51 @@
84139
84140 static inline __le64 __cpu_to_le64p(const __u64 *p)
84141 {
84142 - return (__force __le64)*p;
84143 + return (__force const __le64)*p;
84144 }
84145 -static inline __u64 __le64_to_cpup(const __le64 *p)
84146 +static inline __u64 __intentional_overflow(-1) __le64_to_cpup(const __le64 *p)
84147 {
84148 - return (__force __u64)*p;
84149 + return (__force const __u64)*p;
84150 }
84151 static inline __le32 __cpu_to_le32p(const __u32 *p)
84152 {
84153 - return (__force __le32)*p;
84154 + return (__force const __le32)*p;
84155 }
84156 static inline __u32 __le32_to_cpup(const __le32 *p)
84157 {
84158 - return (__force __u32)*p;
84159 + return (__force const __u32)*p;
84160 }
84161 static inline __le16 __cpu_to_le16p(const __u16 *p)
84162 {
84163 - return (__force __le16)*p;
84164 + return (__force const __le16)*p;
84165 }
84166 static inline __u16 __le16_to_cpup(const __le16 *p)
84167 {
84168 - return (__force __u16)*p;
84169 + return (__force const __u16)*p;
84170 }
84171 static inline __be64 __cpu_to_be64p(const __u64 *p)
84172 {
84173 - return (__force __be64)__swab64p(p);
84174 + return (__force const __be64)__swab64p(p);
84175 }
84176 static inline __u64 __be64_to_cpup(const __be64 *p)
84177 {
84178 - return __swab64p((__u64 *)p);
84179 + return __swab64p((const __u64 *)p);
84180 }
84181 static inline __be32 __cpu_to_be32p(const __u32 *p)
84182 {
84183 - return (__force __be32)__swab32p(p);
84184 + return (__force const __be32)__swab32p(p);
84185 }
84186 -static inline __u32 __be32_to_cpup(const __be32 *p)
84187 +static inline __u32 __intentional_overflow(-1) __be32_to_cpup(const __be32 *p)
84188 {
84189 - return __swab32p((__u32 *)p);
84190 + return __swab32p((const __u32 *)p);
84191 }
84192 static inline __be16 __cpu_to_be16p(const __u16 *p)
84193 {
84194 - return (__force __be16)__swab16p(p);
84195 + return (__force const __be16)__swab16p(p);
84196 }
84197 static inline __u16 __be16_to_cpup(const __be16 *p)
84198 {
84199 - return __swab16p((__u16 *)p);
84200 + return __swab16p((const __u16 *)p);
84201 }
84202 #define __cpu_to_le64s(x) do { (void)(x); } while (0)
84203 #define __le64_to_cpus(x) do { (void)(x); } while (0)
84204 diff --git a/include/uapi/linux/elf.h b/include/uapi/linux/elf.h
84205 index ef6103b..d4e65dd 100644
84206 --- a/include/uapi/linux/elf.h
84207 +++ b/include/uapi/linux/elf.h
84208 @@ -37,6 +37,17 @@ typedef __s64 Elf64_Sxword;
84209 #define PT_GNU_EH_FRAME 0x6474e550
84210
84211 #define PT_GNU_STACK (PT_LOOS + 0x474e551)
84212 +#define PT_GNU_RELRO (PT_LOOS + 0x474e552)
84213 +
84214 +#define PT_PAX_FLAGS (PT_LOOS + 0x5041580)
84215 +
84216 +/* Constants for the e_flags field */
84217 +#define EF_PAX_PAGEEXEC 1 /* Paging based non-executable pages */
84218 +#define EF_PAX_EMUTRAMP 2 /* Emulate trampolines */
84219 +#define EF_PAX_MPROTECT 4 /* Restrict mprotect() */
84220 +#define EF_PAX_RANDMMAP 8 /* Randomize mmap() base */
84221 +/*#define EF_PAX_RANDEXEC 16*/ /* Randomize ET_EXEC base */
84222 +#define EF_PAX_SEGMEXEC 32 /* Segmentation based non-executable pages */
84223
84224 /*
84225 * Extended Numbering
84226 @@ -94,6 +105,8 @@ typedef __s64 Elf64_Sxword;
84227 #define DT_DEBUG 21
84228 #define DT_TEXTREL 22
84229 #define DT_JMPREL 23
84230 +#define DT_FLAGS 30
84231 + #define DF_TEXTREL 0x00000004
84232 #define DT_ENCODING 32
84233 #define OLD_DT_LOOS 0x60000000
84234 #define DT_LOOS 0x6000000d
84235 @@ -240,6 +253,19 @@ typedef struct elf64_hdr {
84236 #define PF_W 0x2
84237 #define PF_X 0x1
84238
84239 +#define PF_PAGEEXEC (1U << 4) /* Enable PAGEEXEC */
84240 +#define PF_NOPAGEEXEC (1U << 5) /* Disable PAGEEXEC */
84241 +#define PF_SEGMEXEC (1U << 6) /* Enable SEGMEXEC */
84242 +#define PF_NOSEGMEXEC (1U << 7) /* Disable SEGMEXEC */
84243 +#define PF_MPROTECT (1U << 8) /* Enable MPROTECT */
84244 +#define PF_NOMPROTECT (1U << 9) /* Disable MPROTECT */
84245 +/*#define PF_RANDEXEC (1U << 10)*/ /* Enable RANDEXEC */
84246 +/*#define PF_NORANDEXEC (1U << 11)*/ /* Disable RANDEXEC */
84247 +#define PF_EMUTRAMP (1U << 12) /* Enable EMUTRAMP */
84248 +#define PF_NOEMUTRAMP (1U << 13) /* Disable EMUTRAMP */
84249 +#define PF_RANDMMAP (1U << 14) /* Enable RANDMMAP */
84250 +#define PF_NORANDMMAP (1U << 15) /* Disable RANDMMAP */
84251 +
84252 typedef struct elf32_phdr{
84253 Elf32_Word p_type;
84254 Elf32_Off p_offset;
84255 @@ -332,6 +358,8 @@ typedef struct elf64_shdr {
84256 #define EI_OSABI 7
84257 #define EI_PAD 8
84258
84259 +#define EI_PAX 14
84260 +
84261 #define ELFMAG0 0x7f /* EI_MAG */
84262 #define ELFMAG1 'E'
84263 #define ELFMAG2 'L'
84264 diff --git a/include/uapi/linux/personality.h b/include/uapi/linux/personality.h
84265 index aa169c4..6a2771d 100644
84266 --- a/include/uapi/linux/personality.h
84267 +++ b/include/uapi/linux/personality.h
84268 @@ -30,6 +30,7 @@ enum {
84269 #define PER_CLEAR_ON_SETID (READ_IMPLIES_EXEC | \
84270 ADDR_NO_RANDOMIZE | \
84271 ADDR_COMPAT_LAYOUT | \
84272 + ADDR_LIMIT_3GB | \
84273 MMAP_PAGE_ZERO)
84274
84275 /*
84276 diff --git a/include/uapi/linux/screen_info.h b/include/uapi/linux/screen_info.h
84277 index 7530e74..e714828 100644
84278 --- a/include/uapi/linux/screen_info.h
84279 +++ b/include/uapi/linux/screen_info.h
84280 @@ -43,7 +43,8 @@ struct screen_info {
84281 __u16 pages; /* 0x32 */
84282 __u16 vesa_attributes; /* 0x34 */
84283 __u32 capabilities; /* 0x36 */
84284 - __u8 _reserved[6]; /* 0x3a */
84285 + __u16 vesapm_size; /* 0x3a */
84286 + __u8 _reserved[4]; /* 0x3c */
84287 } __attribute__((packed));
84288
84289 #define VIDEO_TYPE_MDA 0x10 /* Monochrome Text Display */
84290 diff --git a/include/uapi/linux/swab.h b/include/uapi/linux/swab.h
84291 index 0e011eb..82681b1 100644
84292 --- a/include/uapi/linux/swab.h
84293 +++ b/include/uapi/linux/swab.h
84294 @@ -43,7 +43,7 @@
84295 * ___swab16, ___swab32, ___swab64, ___swahw32, ___swahb32
84296 */
84297
84298 -static inline __attribute_const__ __u16 __fswab16(__u16 val)
84299 +static inline __intentional_overflow(-1) __attribute_const__ __u16 __fswab16(__u16 val)
84300 {
84301 #ifdef __HAVE_BUILTIN_BSWAP16__
84302 return __builtin_bswap16(val);
84303 @@ -54,7 +54,7 @@ static inline __attribute_const__ __u16 __fswab16(__u16 val)
84304 #endif
84305 }
84306
84307 -static inline __attribute_const__ __u32 __fswab32(__u32 val)
84308 +static inline __intentional_overflow(-1) __attribute_const__ __u32 __fswab32(__u32 val)
84309 {
84310 #ifdef __HAVE_BUILTIN_BSWAP32__
84311 return __builtin_bswap32(val);
84312 @@ -65,7 +65,7 @@ static inline __attribute_const__ __u32 __fswab32(__u32 val)
84313 #endif
84314 }
84315
84316 -static inline __attribute_const__ __u64 __fswab64(__u64 val)
84317 +static inline __intentional_overflow(-1) __attribute_const__ __u64 __fswab64(__u64 val)
84318 {
84319 #ifdef __HAVE_BUILTIN_BSWAP64__
84320 return __builtin_bswap64(val);
84321 diff --git a/include/uapi/linux/sysctl.h b/include/uapi/linux/sysctl.h
84322 index 6d67213..552fdd9 100644
84323 --- a/include/uapi/linux/sysctl.h
84324 +++ b/include/uapi/linux/sysctl.h
84325 @@ -155,8 +155,6 @@ enum
84326 KERN_PANIC_ON_NMI=76, /* int: whether we will panic on an unrecovered */
84327 };
84328
84329 -
84330 -
84331 /* CTL_VM names: */
84332 enum
84333 {
84334 diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h
84335 index ea468ee..4d367a5 100644
84336 --- a/include/uapi/linux/videodev2.h
84337 +++ b/include/uapi/linux/videodev2.h
84338 @@ -1248,7 +1248,7 @@ struct v4l2_ext_control {
84339 union {
84340 __s32 value;
84341 __s64 value64;
84342 - char *string;
84343 + char __user *string;
84344 };
84345 } __attribute__ ((packed));
84346
84347 diff --git a/include/uapi/linux/xattr.h b/include/uapi/linux/xattr.h
84348 index c38355c..17a57bc 100644
84349 --- a/include/uapi/linux/xattr.h
84350 +++ b/include/uapi/linux/xattr.h
84351 @@ -73,5 +73,9 @@
84352 #define XATTR_POSIX_ACL_DEFAULT "posix_acl_default"
84353 #define XATTR_NAME_POSIX_ACL_DEFAULT XATTR_SYSTEM_PREFIX XATTR_POSIX_ACL_DEFAULT
84354
84355 +/* User namespace */
84356 +#define XATTR_PAX_PREFIX XATTR_USER_PREFIX "pax."
84357 +#define XATTR_PAX_FLAGS_SUFFIX "flags"
84358 +#define XATTR_NAME_PAX_FLAGS XATTR_PAX_PREFIX XATTR_PAX_FLAGS_SUFFIX
84359
84360 #endif /* _UAPI_LINUX_XATTR_H */
84361 diff --git a/include/video/udlfb.h b/include/video/udlfb.h
84362 index f9466fa..f4e2b81 100644
84363 --- a/include/video/udlfb.h
84364 +++ b/include/video/udlfb.h
84365 @@ -53,10 +53,10 @@ struct dlfb_data {
84366 u32 pseudo_palette[256];
84367 int blank_mode; /*one of FB_BLANK_ */
84368 /* blit-only rendering path metrics, exposed through sysfs */
84369 - atomic_t bytes_rendered; /* raw pixel-bytes driver asked to render */
84370 - atomic_t bytes_identical; /* saved effort with backbuffer comparison */
84371 - atomic_t bytes_sent; /* to usb, after compression including overhead */
84372 - atomic_t cpu_kcycles_used; /* transpired during pixel processing */
84373 + atomic_unchecked_t bytes_rendered; /* raw pixel-bytes driver asked to render */
84374 + atomic_unchecked_t bytes_identical; /* saved effort with backbuffer comparison */
84375 + atomic_unchecked_t bytes_sent; /* to usb, after compression including overhead */
84376 + atomic_unchecked_t cpu_kcycles_used; /* transpired during pixel processing */
84377 };
84378
84379 #define NR_USB_REQUEST_I2C_SUB_IO 0x02
84380 diff --git a/include/video/uvesafb.h b/include/video/uvesafb.h
84381 index 30f5362..8ed8ac9 100644
84382 --- a/include/video/uvesafb.h
84383 +++ b/include/video/uvesafb.h
84384 @@ -122,6 +122,7 @@ struct uvesafb_par {
84385 u8 ypan; /* 0 - nothing, 1 - ypan, 2 - ywrap */
84386 u8 pmi_setpal; /* PMI for palette changes */
84387 u16 *pmi_base; /* protected mode interface location */
84388 + u8 *pmi_code; /* protected mode code location */
84389 void *pmi_start;
84390 void *pmi_pal;
84391 u8 *vbe_state_orig; /*
84392 diff --git a/init/Kconfig b/init/Kconfig
84393 index 9d3585b..ad45d34 100644
84394 --- a/init/Kconfig
84395 +++ b/init/Kconfig
84396 @@ -1093,6 +1093,7 @@ endif # CGROUPS
84397
84398 config CHECKPOINT_RESTORE
84399 bool "Checkpoint/restore support" if EXPERT
84400 + depends on !GRKERNSEC
84401 default n
84402 help
84403 Enables additional kernel features in a sake of checkpoint/restore.
84404 @@ -1570,7 +1571,7 @@ config SLUB_DEBUG
84405
84406 config COMPAT_BRK
84407 bool "Disable heap randomization"
84408 - default y
84409 + default n
84410 help
84411 Randomizing heap placement makes heap exploits harder, but it
84412 also breaks ancient binaries (including anything libc5 based).
84413 @@ -1858,7 +1859,7 @@ config INIT_ALL_POSSIBLE
84414 config STOP_MACHINE
84415 bool
84416 default y
84417 - depends on (SMP && MODULE_UNLOAD) || HOTPLUG_CPU
84418 + depends on (SMP && MODULE_UNLOAD) || HOTPLUG_CPU || GRKERNSEC
84419 help
84420 Need stop_machine() primitive.
84421
84422 diff --git a/init/Makefile b/init/Makefile
84423 index 7bc47ee..6da2dc7 100644
84424 --- a/init/Makefile
84425 +++ b/init/Makefile
84426 @@ -2,6 +2,9 @@
84427 # Makefile for the linux kernel.
84428 #
84429
84430 +ccflags-y := $(GCC_PLUGINS_CFLAGS)
84431 +asflags-y := $(GCC_PLUGINS_AFLAGS)
84432 +
84433 obj-y := main.o version.o mounts.o
84434 ifneq ($(CONFIG_BLK_DEV_INITRD),y)
84435 obj-y += noinitramfs.o
84436 diff --git a/init/do_mounts.c b/init/do_mounts.c
84437 index 82f2288..ea1430a 100644
84438 --- a/init/do_mounts.c
84439 +++ b/init/do_mounts.c
84440 @@ -359,11 +359,11 @@ static void __init get_fs_names(char *page)
84441 static int __init do_mount_root(char *name, char *fs, int flags, void *data)
84442 {
84443 struct super_block *s;
84444 - int err = sys_mount(name, "/root", fs, flags, data);
84445 + int err = sys_mount((char __force_user *)name, (char __force_user *)"/root", (char __force_user *)fs, flags, (void __force_user *)data);
84446 if (err)
84447 return err;
84448
84449 - sys_chdir("/root");
84450 + sys_chdir((const char __force_user *)"/root");
84451 s = current->fs->pwd.dentry->d_sb;
84452 ROOT_DEV = s->s_dev;
84453 printk(KERN_INFO
84454 @@ -484,18 +484,18 @@ void __init change_floppy(char *fmt, ...)
84455 va_start(args, fmt);
84456 vsprintf(buf, fmt, args);
84457 va_end(args);
84458 - fd = sys_open("/dev/root", O_RDWR | O_NDELAY, 0);
84459 + fd = sys_open((char __user *)"/dev/root", O_RDWR | O_NDELAY, 0);
84460 if (fd >= 0) {
84461 sys_ioctl(fd, FDEJECT, 0);
84462 sys_close(fd);
84463 }
84464 printk(KERN_NOTICE "VFS: Insert %s and press ENTER\n", buf);
84465 - fd = sys_open("/dev/console", O_RDWR, 0);
84466 + fd = sys_open((__force const char __user *)"/dev/console", O_RDWR, 0);
84467 if (fd >= 0) {
84468 sys_ioctl(fd, TCGETS, (long)&termios);
84469 termios.c_lflag &= ~ICANON;
84470 sys_ioctl(fd, TCSETSF, (long)&termios);
84471 - sys_read(fd, &c, 1);
84472 + sys_read(fd, (char __user *)&c, 1);
84473 termios.c_lflag |= ICANON;
84474 sys_ioctl(fd, TCSETSF, (long)&termios);
84475 sys_close(fd);
84476 @@ -589,8 +589,8 @@ void __init prepare_namespace(void)
84477 mount_root();
84478 out:
84479 devtmpfs_mount("dev");
84480 - sys_mount(".", "/", NULL, MS_MOVE, NULL);
84481 - sys_chroot(".");
84482 + sys_mount((char __force_user *)".", (char __force_user *)"/", NULL, MS_MOVE, NULL);
84483 + sys_chroot((const char __force_user *)".");
84484 }
84485
84486 static bool is_tmpfs;
84487 diff --git a/init/do_mounts.h b/init/do_mounts.h
84488 index f5b978a..69dbfe8 100644
84489 --- a/init/do_mounts.h
84490 +++ b/init/do_mounts.h
84491 @@ -15,15 +15,15 @@ extern int root_mountflags;
84492
84493 static inline int create_dev(char *name, dev_t dev)
84494 {
84495 - sys_unlink(name);
84496 - return sys_mknod(name, S_IFBLK|0600, new_encode_dev(dev));
84497 + sys_unlink((char __force_user *)name);
84498 + return sys_mknod((char __force_user *)name, S_IFBLK|0600, new_encode_dev(dev));
84499 }
84500
84501 #if BITS_PER_LONG == 32
84502 static inline u32 bstat(char *name)
84503 {
84504 struct stat64 stat;
84505 - if (sys_stat64(name, &stat) != 0)
84506 + if (sys_stat64((char __force_user *)name, (struct stat64 __force_user *)&stat) != 0)
84507 return 0;
84508 if (!S_ISBLK(stat.st_mode))
84509 return 0;
84510 @@ -35,7 +35,7 @@ static inline u32 bstat(char *name)
84511 static inline u32 bstat(char *name)
84512 {
84513 struct stat stat;
84514 - if (sys_newstat(name, &stat) != 0)
84515 + if (sys_newstat((const char __force_user *)name, (struct stat __force_user *)&stat) != 0)
84516 return 0;
84517 if (!S_ISBLK(stat.st_mode))
84518 return 0;
84519 diff --git a/init/do_mounts_initrd.c b/init/do_mounts_initrd.c
84520 index 3e0878e..8a9d7a0 100644
84521 --- a/init/do_mounts_initrd.c
84522 +++ b/init/do_mounts_initrd.c
84523 @@ -37,13 +37,13 @@ static int init_linuxrc(struct subprocess_info *info, struct cred *new)
84524 {
84525 sys_unshare(CLONE_FS | CLONE_FILES);
84526 /* stdin/stdout/stderr for /linuxrc */
84527 - sys_open("/dev/console", O_RDWR, 0);
84528 + sys_open((const char __force_user *)"/dev/console", O_RDWR, 0);
84529 sys_dup(0);
84530 sys_dup(0);
84531 /* move initrd over / and chdir/chroot in initrd root */
84532 - sys_chdir("/root");
84533 - sys_mount(".", "/", NULL, MS_MOVE, NULL);
84534 - sys_chroot(".");
84535 + sys_chdir((const char __force_user *)"/root");
84536 + sys_mount((char __force_user *)".", (char __force_user *)"/", NULL, MS_MOVE, NULL);
84537 + sys_chroot((const char __force_user *)".");
84538 sys_setsid();
84539 return 0;
84540 }
84541 @@ -59,8 +59,8 @@ static void __init handle_initrd(void)
84542 create_dev("/dev/root.old", Root_RAM0);
84543 /* mount initrd on rootfs' /root */
84544 mount_block_root("/dev/root.old", root_mountflags & ~MS_RDONLY);
84545 - sys_mkdir("/old", 0700);
84546 - sys_chdir("/old");
84547 + sys_mkdir((const char __force_user *)"/old", 0700);
84548 + sys_chdir((const char __force_user *)"/old");
84549
84550 /* try loading default modules from initrd */
84551 load_default_modules();
84552 @@ -80,31 +80,31 @@ static void __init handle_initrd(void)
84553 current->flags &= ~PF_FREEZER_SKIP;
84554
84555 /* move initrd to rootfs' /old */
84556 - sys_mount("..", ".", NULL, MS_MOVE, NULL);
84557 + sys_mount((char __force_user *)"..", (char __force_user *)".", NULL, MS_MOVE, NULL);
84558 /* switch root and cwd back to / of rootfs */
84559 - sys_chroot("..");
84560 + sys_chroot((const char __force_user *)"..");
84561
84562 if (new_decode_dev(real_root_dev) == Root_RAM0) {
84563 - sys_chdir("/old");
84564 + sys_chdir((const char __force_user *)"/old");
84565 return;
84566 }
84567
84568 - sys_chdir("/");
84569 + sys_chdir((const char __force_user *)"/");
84570 ROOT_DEV = new_decode_dev(real_root_dev);
84571 mount_root();
84572
84573 printk(KERN_NOTICE "Trying to move old root to /initrd ... ");
84574 - error = sys_mount("/old", "/root/initrd", NULL, MS_MOVE, NULL);
84575 + error = sys_mount((char __force_user *)"/old", (char __force_user *)"/root/initrd", NULL, MS_MOVE, NULL);
84576 if (!error)
84577 printk("okay\n");
84578 else {
84579 - int fd = sys_open("/dev/root.old", O_RDWR, 0);
84580 + int fd = sys_open((const char __force_user *)"/dev/root.old", O_RDWR, 0);
84581 if (error == -ENOENT)
84582 printk("/initrd does not exist. Ignored.\n");
84583 else
84584 printk("failed\n");
84585 printk(KERN_NOTICE "Unmounting old root\n");
84586 - sys_umount("/old", MNT_DETACH);
84587 + sys_umount((char __force_user *)"/old", MNT_DETACH);
84588 printk(KERN_NOTICE "Trying to free ramdisk memory ... ");
84589 if (fd < 0) {
84590 error = fd;
84591 @@ -127,11 +127,11 @@ int __init initrd_load(void)
84592 * mounted in the normal path.
84593 */
84594 if (rd_load_image("/initrd.image") && ROOT_DEV != Root_RAM0) {
84595 - sys_unlink("/initrd.image");
84596 + sys_unlink((const char __force_user *)"/initrd.image");
84597 handle_initrd();
84598 return 1;
84599 }
84600 }
84601 - sys_unlink("/initrd.image");
84602 + sys_unlink((const char __force_user *)"/initrd.image");
84603 return 0;
84604 }
84605 diff --git a/init/do_mounts_md.c b/init/do_mounts_md.c
84606 index 8cb6db5..d729f50 100644
84607 --- a/init/do_mounts_md.c
84608 +++ b/init/do_mounts_md.c
84609 @@ -180,7 +180,7 @@ static void __init md_setup_drive(void)
84610 partitioned ? "_d" : "", minor,
84611 md_setup_args[ent].device_names);
84612
84613 - fd = sys_open(name, 0, 0);
84614 + fd = sys_open((char __force_user *)name, 0, 0);
84615 if (fd < 0) {
84616 printk(KERN_ERR "md: open failed - cannot start "
84617 "array %s\n", name);
84618 @@ -243,7 +243,7 @@ static void __init md_setup_drive(void)
84619 * array without it
84620 */
84621 sys_close(fd);
84622 - fd = sys_open(name, 0, 0);
84623 + fd = sys_open((char __force_user *)name, 0, 0);
84624 sys_ioctl(fd, BLKRRPART, 0);
84625 }
84626 sys_close(fd);
84627 @@ -293,7 +293,7 @@ static void __init autodetect_raid(void)
84628
84629 wait_for_device_probe();
84630
84631 - fd = sys_open("/dev/md0", 0, 0);
84632 + fd = sys_open((const char __force_user *) "/dev/md0", 0, 0);
84633 if (fd >= 0) {
84634 sys_ioctl(fd, RAID_AUTORUN, raid_autopart);
84635 sys_close(fd);
84636 diff --git a/init/init_task.c b/init/init_task.c
84637 index ba0a7f36..2bcf1d5 100644
84638 --- a/init/init_task.c
84639 +++ b/init/init_task.c
84640 @@ -22,5 +22,9 @@ EXPORT_SYMBOL(init_task);
84641 * Initial thread structure. Alignment of this is handled by a special
84642 * linker map entry.
84643 */
84644 +#ifdef CONFIG_X86
84645 +union thread_union init_thread_union __init_task_data;
84646 +#else
84647 union thread_union init_thread_union __init_task_data =
84648 { INIT_THREAD_INFO(init_task) };
84649 +#endif
84650 diff --git a/init/initramfs.c b/init/initramfs.c
84651 index a8497fa..35b3c90 100644
84652 --- a/init/initramfs.c
84653 +++ b/init/initramfs.c
84654 @@ -84,7 +84,7 @@ static void __init free_hash(void)
84655 }
84656 }
84657
84658 -static long __init do_utime(char *filename, time_t mtime)
84659 +static long __init do_utime(char __force_user *filename, time_t mtime)
84660 {
84661 struct timespec t[2];
84662
84663 @@ -119,7 +119,7 @@ static void __init dir_utime(void)
84664 struct dir_entry *de, *tmp;
84665 list_for_each_entry_safe(de, tmp, &dir_list, list) {
84666 list_del(&de->list);
84667 - do_utime(de->name, de->mtime);
84668 + do_utime((char __force_user *)de->name, de->mtime);
84669 kfree(de->name);
84670 kfree(de);
84671 }
84672 @@ -281,7 +281,7 @@ static int __init maybe_link(void)
84673 if (nlink >= 2) {
84674 char *old = find_link(major, minor, ino, mode, collected);
84675 if (old)
84676 - return (sys_link(old, collected) < 0) ? -1 : 1;
84677 + return (sys_link((char __force_user *)old, (char __force_user *)collected) < 0) ? -1 : 1;
84678 }
84679 return 0;
84680 }
84681 @@ -290,11 +290,11 @@ static void __init clean_path(char *path, umode_t mode)
84682 {
84683 struct stat st;
84684
84685 - if (!sys_newlstat(path, &st) && (st.st_mode^mode) & S_IFMT) {
84686 + if (!sys_newlstat((char __force_user *)path, (struct stat __force_user *)&st) && (st.st_mode^mode) & S_IFMT) {
84687 if (S_ISDIR(st.st_mode))
84688 - sys_rmdir(path);
84689 + sys_rmdir((char __force_user *)path);
84690 else
84691 - sys_unlink(path);
84692 + sys_unlink((char __force_user *)path);
84693 }
84694 }
84695
84696 @@ -315,7 +315,7 @@ static int __init do_name(void)
84697 int openflags = O_WRONLY|O_CREAT;
84698 if (ml != 1)
84699 openflags |= O_TRUNC;
84700 - wfd = sys_open(collected, openflags, mode);
84701 + wfd = sys_open((char __force_user *)collected, openflags, mode);
84702
84703 if (wfd >= 0) {
84704 sys_fchown(wfd, uid, gid);
84705 @@ -327,17 +327,17 @@ static int __init do_name(void)
84706 }
84707 }
84708 } else if (S_ISDIR(mode)) {
84709 - sys_mkdir(collected, mode);
84710 - sys_chown(collected, uid, gid);
84711 - sys_chmod(collected, mode);
84712 + sys_mkdir((char __force_user *)collected, mode);
84713 + sys_chown((char __force_user *)collected, uid, gid);
84714 + sys_chmod((char __force_user *)collected, mode);
84715 dir_add(collected, mtime);
84716 } else if (S_ISBLK(mode) || S_ISCHR(mode) ||
84717 S_ISFIFO(mode) || S_ISSOCK(mode)) {
84718 if (maybe_link() == 0) {
84719 - sys_mknod(collected, mode, rdev);
84720 - sys_chown(collected, uid, gid);
84721 - sys_chmod(collected, mode);
84722 - do_utime(collected, mtime);
84723 + sys_mknod((char __force_user *)collected, mode, rdev);
84724 + sys_chown((char __force_user *)collected, uid, gid);
84725 + sys_chmod((char __force_user *)collected, mode);
84726 + do_utime((char __force_user *)collected, mtime);
84727 }
84728 }
84729 return 0;
84730 @@ -346,15 +346,15 @@ static int __init do_name(void)
84731 static int __init do_copy(void)
84732 {
84733 if (count >= body_len) {
84734 - sys_write(wfd, victim, body_len);
84735 + sys_write(wfd, (char __force_user *)victim, body_len);
84736 sys_close(wfd);
84737 - do_utime(vcollected, mtime);
84738 + do_utime((char __force_user *)vcollected, mtime);
84739 kfree(vcollected);
84740 eat(body_len);
84741 state = SkipIt;
84742 return 0;
84743 } else {
84744 - sys_write(wfd, victim, count);
84745 + sys_write(wfd, (char __force_user *)victim, count);
84746 body_len -= count;
84747 eat(count);
84748 return 1;
84749 @@ -365,9 +365,9 @@ static int __init do_symlink(void)
84750 {
84751 collected[N_ALIGN(name_len) + body_len] = '\0';
84752 clean_path(collected, 0);
84753 - sys_symlink(collected + N_ALIGN(name_len), collected);
84754 - sys_lchown(collected, uid, gid);
84755 - do_utime(collected, mtime);
84756 + sys_symlink((char __force_user *)collected + N_ALIGN(name_len), (char __force_user *)collected);
84757 + sys_lchown((char __force_user *)collected, uid, gid);
84758 + do_utime((char __force_user *)collected, mtime);
84759 state = SkipIt;
84760 next_state = Reset;
84761 return 0;
84762 diff --git a/init/main.c b/init/main.c
84763 index 48655ce..d0113e4 100644
84764 --- a/init/main.c
84765 +++ b/init/main.c
84766 @@ -97,6 +97,8 @@ extern void radix_tree_init(void);
84767 static inline void mark_rodata_ro(void) { }
84768 #endif
84769
84770 +extern void grsecurity_init(void);
84771 +
84772 /*
84773 * Debug helper: via this flag we know that we are in 'early bootup code'
84774 * where only the boot processor is running with IRQ disabled. This means
84775 @@ -158,6 +160,75 @@ static int __init set_reset_devices(char *str)
84776
84777 __setup("reset_devices", set_reset_devices);
84778
84779 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
84780 +kgid_t grsec_proc_gid = KGIDT_INIT(CONFIG_GRKERNSEC_PROC_GID);
84781 +static int __init setup_grsec_proc_gid(char *str)
84782 +{
84783 + grsec_proc_gid = KGIDT_INIT(simple_strtol(str, NULL, 0));
84784 + return 1;
84785 +}
84786 +__setup("grsec_proc_gid=", setup_grsec_proc_gid);
84787 +#endif
84788 +
84789 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
84790 +unsigned long pax_user_shadow_base __read_only;
84791 +EXPORT_SYMBOL(pax_user_shadow_base);
84792 +extern char pax_enter_kernel_user[];
84793 +extern char pax_exit_kernel_user[];
84794 +#endif
84795 +
84796 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_MEMORY_UDEREF)
84797 +static int __init setup_pax_nouderef(char *str)
84798 +{
84799 +#ifdef CONFIG_X86_32
84800 + unsigned int cpu;
84801 + struct desc_struct *gdt;
84802 +
84803 + for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
84804 + gdt = get_cpu_gdt_table(cpu);
84805 + gdt[GDT_ENTRY_KERNEL_DS].type = 3;
84806 + gdt[GDT_ENTRY_KERNEL_DS].limit = 0xf;
84807 + gdt[GDT_ENTRY_DEFAULT_USER_CS].limit = 0xf;
84808 + gdt[GDT_ENTRY_DEFAULT_USER_DS].limit = 0xf;
84809 + }
84810 + loadsegment(ds, __KERNEL_DS);
84811 + loadsegment(es, __KERNEL_DS);
84812 + loadsegment(ss, __KERNEL_DS);
84813 +#else
84814 + memcpy(pax_enter_kernel_user, (unsigned char []){0xc3}, 1);
84815 + memcpy(pax_exit_kernel_user, (unsigned char []){0xc3}, 1);
84816 + clone_pgd_mask = ~(pgdval_t)0UL;
84817 + pax_user_shadow_base = 0UL;
84818 + setup_clear_cpu_cap(X86_FEATURE_PCID);
84819 + setup_clear_cpu_cap(X86_FEATURE_INVPCID);
84820 +#endif
84821 +
84822 + return 0;
84823 +}
84824 +early_param("pax_nouderef", setup_pax_nouderef);
84825 +
84826 +#ifdef CONFIG_X86_64
84827 +static int __init setup_pax_weakuderef(char *str)
84828 +{
84829 + if (clone_pgd_mask != ~(pgdval_t)0UL)
84830 + pax_user_shadow_base = 1UL << TASK_SIZE_MAX_SHIFT;
84831 + return 1;
84832 +}
84833 +__setup("pax_weakuderef", setup_pax_weakuderef);
84834 +#endif
84835 +#endif
84836 +
84837 +#ifdef CONFIG_PAX_SOFTMODE
84838 +int pax_softmode;
84839 +
84840 +static int __init setup_pax_softmode(char *str)
84841 +{
84842 + get_option(&str, &pax_softmode);
84843 + return 1;
84844 +}
84845 +__setup("pax_softmode=", setup_pax_softmode);
84846 +#endif
84847 +
84848 static const char * argv_init[MAX_INIT_ARGS+2] = { "init", NULL, };
84849 const char * envp_init[MAX_INIT_ENVS+2] = { "HOME=/", "TERM=linux", NULL, };
84850 static const char *panic_later, *panic_param;
84851 @@ -688,25 +759,24 @@ int __init_or_module do_one_initcall(initcall_t fn)
84852 {
84853 int count = preempt_count();
84854 int ret;
84855 - char msgbuf[64];
84856 + const char *msg1 = "", *msg2 = "";
84857
84858 if (initcall_debug)
84859 ret = do_one_initcall_debug(fn);
84860 else
84861 ret = fn();
84862
84863 - msgbuf[0] = 0;
84864 -
84865 if (preempt_count() != count) {
84866 - sprintf(msgbuf, "preemption imbalance ");
84867 + msg1 = " preemption imbalance";
84868 preempt_count_set(count);
84869 }
84870 if (irqs_disabled()) {
84871 - strlcat(msgbuf, "disabled interrupts ", sizeof(msgbuf));
84872 + msg2 = " disabled interrupts";
84873 local_irq_enable();
84874 }
84875 - WARN(msgbuf[0], "initcall %pF returned with %s\n", fn, msgbuf);
84876 + WARN(*msg1 || *msg2, "initcall %pF returned with%s%s\n", fn, msg1, msg2);
84877
84878 + add_latent_entropy();
84879 return ret;
84880 }
84881
84882 @@ -813,8 +883,8 @@ static int run_init_process(const char *init_filename)
84883 {
84884 argv_init[0] = init_filename;
84885 return do_execve(getname_kernel(init_filename),
84886 - (const char __user *const __user *)argv_init,
84887 - (const char __user *const __user *)envp_init);
84888 + (const char __user *const __force_user *)argv_init,
84889 + (const char __user *const __force_user *)envp_init);
84890 }
84891
84892 static int try_to_run_init_process(const char *init_filename)
84893 @@ -831,6 +901,10 @@ static int try_to_run_init_process(const char *init_filename)
84894 return ret;
84895 }
84896
84897 +#ifdef CONFIG_GRKERNSEC_CHROOT_INITRD
84898 +extern int gr_init_ran;
84899 +#endif
84900 +
84901 static noinline void __init kernel_init_freeable(void);
84902
84903 static int __ref kernel_init(void *unused)
84904 @@ -855,6 +929,11 @@ static int __ref kernel_init(void *unused)
84905 ramdisk_execute_command, ret);
84906 }
84907
84908 +#ifdef CONFIG_GRKERNSEC_CHROOT_INITRD
84909 + /* if no initrd was used, be extra sure we enforce chroot restrictions */
84910 + gr_init_ran = 1;
84911 +#endif
84912 +
84913 /*
84914 * We try each of these until one succeeds.
84915 *
84916 @@ -910,7 +989,7 @@ static noinline void __init kernel_init_freeable(void)
84917 do_basic_setup();
84918
84919 /* Open the /dev/console on the rootfs, this should never fail */
84920 - if (sys_open((const char __user *) "/dev/console", O_RDWR, 0) < 0)
84921 + if (sys_open((const char __force_user *) "/dev/console", O_RDWR, 0) < 0)
84922 pr_err("Warning: unable to open an initial console.\n");
84923
84924 (void) sys_dup(0);
84925 @@ -923,11 +1002,13 @@ static noinline void __init kernel_init_freeable(void)
84926 if (!ramdisk_execute_command)
84927 ramdisk_execute_command = "/init";
84928
84929 - if (sys_access((const char __user *) ramdisk_execute_command, 0) != 0) {
84930 + if (sys_access((const char __force_user *) ramdisk_execute_command, 0) != 0) {
84931 ramdisk_execute_command = NULL;
84932 prepare_namespace();
84933 }
84934
84935 + grsecurity_init();
84936 +
84937 /*
84938 * Ok, we have completed the initial bootup, and
84939 * we're essentially up and running. Get rid of the
84940 diff --git a/ipc/compat.c b/ipc/compat.c
84941 index 45d035d..e4a7f99 100644
84942 --- a/ipc/compat.c
84943 +++ b/ipc/compat.c
84944 @@ -396,7 +396,7 @@ COMPAT_SYSCALL_DEFINE6(ipc, u32, call, int, first, int, second,
84945 COMPAT_SHMLBA);
84946 if (err < 0)
84947 return err;
84948 - return put_user(raddr, (compat_ulong_t *)compat_ptr(third));
84949 + return put_user(raddr, (compat_ulong_t __user *)compat_ptr(third));
84950 }
84951 case SHMDT:
84952 return sys_shmdt(compat_ptr(ptr));
84953 diff --git a/ipc/ipc_sysctl.c b/ipc/ipc_sysctl.c
84954 index 998d31b..30c24df 100644
84955 --- a/ipc/ipc_sysctl.c
84956 +++ b/ipc/ipc_sysctl.c
84957 @@ -30,7 +30,7 @@ static void *get_ipc(ctl_table *table)
84958 static int proc_ipc_dointvec(ctl_table *table, int write,
84959 void __user *buffer, size_t *lenp, loff_t *ppos)
84960 {
84961 - struct ctl_table ipc_table;
84962 + ctl_table_no_const ipc_table;
84963
84964 memcpy(&ipc_table, table, sizeof(ipc_table));
84965 ipc_table.data = get_ipc(table);
84966 @@ -41,7 +41,7 @@ static int proc_ipc_dointvec(ctl_table *table, int write,
84967 static int proc_ipc_dointvec_minmax(ctl_table *table, int write,
84968 void __user *buffer, size_t *lenp, loff_t *ppos)
84969 {
84970 - struct ctl_table ipc_table;
84971 + ctl_table_no_const ipc_table;
84972
84973 memcpy(&ipc_table, table, sizeof(ipc_table));
84974 ipc_table.data = get_ipc(table);
84975 @@ -65,7 +65,7 @@ static int proc_ipc_dointvec_minmax_orphans(ctl_table *table, int write,
84976 static int proc_ipc_callback_dointvec_minmax(ctl_table *table, int write,
84977 void __user *buffer, size_t *lenp, loff_t *ppos)
84978 {
84979 - struct ctl_table ipc_table;
84980 + ctl_table_no_const ipc_table;
84981 size_t lenp_bef = *lenp;
84982 int rc;
84983
84984 @@ -88,7 +88,7 @@ static int proc_ipc_callback_dointvec_minmax(ctl_table *table, int write,
84985 static int proc_ipc_doulongvec_minmax(ctl_table *table, int write,
84986 void __user *buffer, size_t *lenp, loff_t *ppos)
84987 {
84988 - struct ctl_table ipc_table;
84989 + ctl_table_no_const ipc_table;
84990 memcpy(&ipc_table, table, sizeof(ipc_table));
84991 ipc_table.data = get_ipc(table);
84992
84993 @@ -122,7 +122,7 @@ static void ipc_auto_callback(int val)
84994 static int proc_ipcauto_dointvec_minmax(ctl_table *table, int write,
84995 void __user *buffer, size_t *lenp, loff_t *ppos)
84996 {
84997 - struct ctl_table ipc_table;
84998 + ctl_table_no_const ipc_table;
84999 size_t lenp_bef = *lenp;
85000 int oldval;
85001 int rc;
85002 diff --git a/ipc/mq_sysctl.c b/ipc/mq_sysctl.c
85003 index 5bb8bfe..a38ec05 100644
85004 --- a/ipc/mq_sysctl.c
85005 +++ b/ipc/mq_sysctl.c
85006 @@ -25,7 +25,7 @@ static void *get_mq(ctl_table *table)
85007 static int proc_mq_dointvec(ctl_table *table, int write,
85008 void __user *buffer, size_t *lenp, loff_t *ppos)
85009 {
85010 - struct ctl_table mq_table;
85011 + ctl_table_no_const mq_table;
85012 memcpy(&mq_table, table, sizeof(mq_table));
85013 mq_table.data = get_mq(table);
85014
85015 @@ -35,7 +35,7 @@ static int proc_mq_dointvec(ctl_table *table, int write,
85016 static int proc_mq_dointvec_minmax(ctl_table *table, int write,
85017 void __user *buffer, size_t *lenp, loff_t *ppos)
85018 {
85019 - struct ctl_table mq_table;
85020 + ctl_table_no_const mq_table;
85021 memcpy(&mq_table, table, sizeof(mq_table));
85022 mq_table.data = get_mq(table);
85023
85024 diff --git a/ipc/mqueue.c b/ipc/mqueue.c
85025 index 4fcf39a..d3cc2ec 100644
85026 --- a/ipc/mqueue.c
85027 +++ b/ipc/mqueue.c
85028 @@ -278,6 +278,7 @@ static struct inode *mqueue_get_inode(struct super_block *sb,
85029 mq_bytes = mq_treesize + (info->attr.mq_maxmsg *
85030 info->attr.mq_msgsize);
85031
85032 + gr_learn_resource(current, RLIMIT_MSGQUEUE, u->mq_bytes + mq_bytes, 1);
85033 spin_lock(&mq_lock);
85034 if (u->mq_bytes + mq_bytes < u->mq_bytes ||
85035 u->mq_bytes + mq_bytes > rlimit(RLIMIT_MSGQUEUE)) {
85036 diff --git a/ipc/msg.c b/ipc/msg.c
85037 index 6498531..b0ff3c8 100644
85038 --- a/ipc/msg.c
85039 +++ b/ipc/msg.c
85040 @@ -303,18 +303,19 @@ static inline int msg_security(struct kern_ipc_perm *ipcp, int msgflg)
85041 return security_msg_queue_associate(msq, msgflg);
85042 }
85043
85044 +static struct ipc_ops msg_ops = {
85045 + .getnew = newque,
85046 + .associate = msg_security,
85047 + .more_checks = NULL
85048 +};
85049 +
85050 SYSCALL_DEFINE2(msgget, key_t, key, int, msgflg)
85051 {
85052 struct ipc_namespace *ns;
85053 - struct ipc_ops msg_ops;
85054 struct ipc_params msg_params;
85055
85056 ns = current->nsproxy->ipc_ns;
85057
85058 - msg_ops.getnew = newque;
85059 - msg_ops.associate = msg_security;
85060 - msg_ops.more_checks = NULL;
85061 -
85062 msg_params.key = key;
85063 msg_params.flg = msgflg;
85064
85065 diff --git a/ipc/sem.c b/ipc/sem.c
85066 index bee5554..e9af81dd 100644
85067 --- a/ipc/sem.c
85068 +++ b/ipc/sem.c
85069 @@ -561,10 +561,15 @@ static inline int sem_more_checks(struct kern_ipc_perm *ipcp,
85070 return 0;
85071 }
85072
85073 +static struct ipc_ops sem_ops = {
85074 + .getnew = newary,
85075 + .associate = sem_security,
85076 + .more_checks = sem_more_checks
85077 +};
85078 +
85079 SYSCALL_DEFINE3(semget, key_t, key, int, nsems, int, semflg)
85080 {
85081 struct ipc_namespace *ns;
85082 - struct ipc_ops sem_ops;
85083 struct ipc_params sem_params;
85084
85085 ns = current->nsproxy->ipc_ns;
85086 @@ -572,10 +577,6 @@ SYSCALL_DEFINE3(semget, key_t, key, int, nsems, int, semflg)
85087 if (nsems < 0 || nsems > ns->sc_semmsl)
85088 return -EINVAL;
85089
85090 - sem_ops.getnew = newary;
85091 - sem_ops.associate = sem_security;
85092 - sem_ops.more_checks = sem_more_checks;
85093 -
85094 sem_params.key = key;
85095 sem_params.flg = semflg;
85096 sem_params.u.nsems = nsems;
85097 diff --git a/ipc/shm.c b/ipc/shm.c
85098 index 7645961..afc7f02 100644
85099 --- a/ipc/shm.c
85100 +++ b/ipc/shm.c
85101 @@ -72,6 +72,14 @@ static void shm_destroy(struct ipc_namespace *ns, struct shmid_kernel *shp);
85102 static int sysvipc_shm_proc_show(struct seq_file *s, void *it);
85103 #endif
85104
85105 +#ifdef CONFIG_GRKERNSEC
85106 +extern int gr_handle_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
85107 + const time_t shm_createtime, const kuid_t cuid,
85108 + const int shmid);
85109 +extern int gr_chroot_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
85110 + const time_t shm_createtime);
85111 +#endif
85112 +
85113 void shm_init_ns(struct ipc_namespace *ns)
85114 {
85115 ns->shm_ctlmax = SHMMAX;
85116 @@ -553,6 +561,14 @@ static int newseg(struct ipc_namespace *ns, struct ipc_params *params)
85117 shp->shm_lprid = 0;
85118 shp->shm_atim = shp->shm_dtim = 0;
85119 shp->shm_ctim = get_seconds();
85120 +#ifdef CONFIG_GRKERNSEC
85121 + {
85122 + struct timespec timeval;
85123 + do_posix_clock_monotonic_gettime(&timeval);
85124 +
85125 + shp->shm_createtime = timeval.tv_sec;
85126 + }
85127 +#endif
85128 shp->shm_segsz = size;
85129 shp->shm_nattch = 0;
85130 shp->shm_file = file;
85131 @@ -606,18 +622,19 @@ static inline int shm_more_checks(struct kern_ipc_perm *ipcp,
85132 return 0;
85133 }
85134
85135 +static struct ipc_ops shm_ops = {
85136 + .getnew = newseg,
85137 + .associate = shm_security,
85138 + .more_checks = shm_more_checks
85139 +};
85140 +
85141 SYSCALL_DEFINE3(shmget, key_t, key, size_t, size, int, shmflg)
85142 {
85143 struct ipc_namespace *ns;
85144 - struct ipc_ops shm_ops;
85145 struct ipc_params shm_params;
85146
85147 ns = current->nsproxy->ipc_ns;
85148
85149 - shm_ops.getnew = newseg;
85150 - shm_ops.associate = shm_security;
85151 - shm_ops.more_checks = shm_more_checks;
85152 -
85153 shm_params.key = key;
85154 shm_params.flg = shmflg;
85155 shm_params.u.size = size;
85156 @@ -1088,6 +1105,12 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg, ulong *raddr,
85157 f_mode = FMODE_READ | FMODE_WRITE;
85158 }
85159 if (shmflg & SHM_EXEC) {
85160 +
85161 +#ifdef CONFIG_PAX_MPROTECT
85162 + if (current->mm->pax_flags & MF_PAX_MPROTECT)
85163 + goto out;
85164 +#endif
85165 +
85166 prot |= PROT_EXEC;
85167 acc_mode |= S_IXUGO;
85168 }
85169 @@ -1112,6 +1135,15 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg, ulong *raddr,
85170 if (err)
85171 goto out_unlock;
85172
85173 +#ifdef CONFIG_GRKERNSEC
85174 + if (!gr_handle_shmat(shp->shm_cprid, shp->shm_lapid, shp->shm_createtime,
85175 + shp->shm_perm.cuid, shmid) ||
85176 + !gr_chroot_shmat(shp->shm_cprid, shp->shm_lapid, shp->shm_createtime)) {
85177 + err = -EACCES;
85178 + goto out_unlock;
85179 + }
85180 +#endif
85181 +
85182 ipc_lock_object(&shp->shm_perm);
85183
85184 /* check if shm_destroy() is tearing down shp */
85185 @@ -1124,6 +1156,9 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg, ulong *raddr,
85186 path = shp->shm_file->f_path;
85187 path_get(&path);
85188 shp->shm_nattch++;
85189 +#ifdef CONFIG_GRKERNSEC
85190 + shp->shm_lapid = current->pid;
85191 +#endif
85192 size = i_size_read(path.dentry->d_inode);
85193 ipc_unlock_object(&shp->shm_perm);
85194 rcu_read_unlock();
85195 diff --git a/ipc/util.c b/ipc/util.c
85196 index 2eb0d1e..0308564 100644
85197 --- a/ipc/util.c
85198 +++ b/ipc/util.c
85199 @@ -71,6 +71,8 @@ struct ipc_proc_iface {
85200 int (*show)(struct seq_file *, void *);
85201 };
85202
85203 +extern int gr_ipc_permitted(struct ipc_namespace *ns, struct kern_ipc_perm *ipcp, int requested_mode, int granted_mode);
85204 +
85205 static void ipc_memory_notifier(struct work_struct *work)
85206 {
85207 ipcns_notify(IPCNS_MEMCHANGED);
85208 @@ -537,6 +539,10 @@ int ipcperms(struct ipc_namespace *ns, struct kern_ipc_perm *ipcp, short flag)
85209 granted_mode >>= 6;
85210 else if (in_group_p(ipcp->cgid) || in_group_p(ipcp->gid))
85211 granted_mode >>= 3;
85212 +
85213 + if (!gr_ipc_permitted(ns, ipcp, requested_mode, granted_mode))
85214 + return -1;
85215 +
85216 /* is there some bit set in requested_mode but not in granted_mode? */
85217 if ((requested_mode & ~granted_mode & 0007) &&
85218 !ns_capable(ns->user_ns, CAP_IPC_OWNER))
85219 diff --git a/kernel/acct.c b/kernel/acct.c
85220 index 8d6e145..33e0b1e 100644
85221 --- a/kernel/acct.c
85222 +++ b/kernel/acct.c
85223 @@ -556,7 +556,7 @@ static void do_acct_process(struct bsd_acct_struct *acct,
85224 */
85225 flim = current->signal->rlim[RLIMIT_FSIZE].rlim_cur;
85226 current->signal->rlim[RLIMIT_FSIZE].rlim_cur = RLIM_INFINITY;
85227 - file->f_op->write(file, (char *)&ac,
85228 + file->f_op->write(file, (char __force_user *)&ac,
85229 sizeof(acct_t), &file->f_pos);
85230 current->signal->rlim[RLIMIT_FSIZE].rlim_cur = flim;
85231 set_fs(fs);
85232 diff --git a/kernel/audit.c b/kernel/audit.c
85233 index 47845c5..bd9dd5b 100644
85234 --- a/kernel/audit.c
85235 +++ b/kernel/audit.c
85236 @@ -122,7 +122,7 @@ u32 audit_sig_sid = 0;
85237 3) suppressed due to audit_rate_limit
85238 4) suppressed due to audit_backlog_limit
85239 */
85240 -static atomic_t audit_lost = ATOMIC_INIT(0);
85241 +static atomic_unchecked_t audit_lost = ATOMIC_INIT(0);
85242
85243 /* The netlink socket. */
85244 static struct sock *audit_sock;
85245 @@ -256,7 +256,7 @@ void audit_log_lost(const char *message)
85246 unsigned long now;
85247 int print;
85248
85249 - atomic_inc(&audit_lost);
85250 + atomic_inc_unchecked(&audit_lost);
85251
85252 print = (audit_failure == AUDIT_FAIL_PANIC || !audit_rate_limit);
85253
85254 @@ -273,7 +273,7 @@ void audit_log_lost(const char *message)
85255 if (print) {
85256 if (printk_ratelimit())
85257 pr_warn("audit_lost=%u audit_rate_limit=%u audit_backlog_limit=%u\n",
85258 - atomic_read(&audit_lost),
85259 + atomic_read_unchecked(&audit_lost),
85260 audit_rate_limit,
85261 audit_backlog_limit);
85262 audit_panic(message);
85263 @@ -808,7 +808,7 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
85264 s.pid = audit_pid;
85265 s.rate_limit = audit_rate_limit;
85266 s.backlog_limit = audit_backlog_limit;
85267 - s.lost = atomic_read(&audit_lost);
85268 + s.lost = atomic_read_unchecked(&audit_lost);
85269 s.backlog = skb_queue_len(&audit_skb_queue);
85270 s.version = AUDIT_VERSION_LATEST;
85271 s.backlog_wait_time = audit_backlog_wait_time;
85272 diff --git a/kernel/auditsc.c b/kernel/auditsc.c
85273 index 21eae3c..66db239 100644
85274 --- a/kernel/auditsc.c
85275 +++ b/kernel/auditsc.c
85276 @@ -2023,7 +2023,7 @@ int auditsc_get_stamp(struct audit_context *ctx,
85277 }
85278
85279 /* global counter which is incremented every time something logs in */
85280 -static atomic_t session_id = ATOMIC_INIT(0);
85281 +static atomic_unchecked_t session_id = ATOMIC_INIT(0);
85282
85283 static int audit_set_loginuid_perm(kuid_t loginuid)
85284 {
85285 @@ -2090,7 +2090,7 @@ int audit_set_loginuid(kuid_t loginuid)
85286
85287 /* are we setting or clearing? */
85288 if (uid_valid(loginuid))
85289 - sessionid = (unsigned int)atomic_inc_return(&session_id);
85290 + sessionid = (unsigned int)atomic_inc_return_unchecked(&session_id);
85291
85292 task->sessionid = sessionid;
85293 task->loginuid = loginuid;
85294 diff --git a/kernel/capability.c b/kernel/capability.c
85295 index 24663b3..b926ae1 100644
85296 --- a/kernel/capability.c
85297 +++ b/kernel/capability.c
85298 @@ -193,6 +193,9 @@ SYSCALL_DEFINE2(capget, cap_user_header_t, header, cap_user_data_t, dataptr)
85299 * before modification is attempted and the application
85300 * fails.
85301 */
85302 + if (tocopy > ARRAY_SIZE(kdata))
85303 + return -EFAULT;
85304 +
85305 if (copy_to_user(dataptr, kdata, tocopy
85306 * sizeof(struct __user_cap_data_struct))) {
85307 return -EFAULT;
85308 @@ -294,10 +297,11 @@ bool has_ns_capability(struct task_struct *t,
85309 int ret;
85310
85311 rcu_read_lock();
85312 - ret = security_capable(__task_cred(t), ns, cap);
85313 + ret = security_capable(__task_cred(t), ns, cap) == 0 &&
85314 + gr_task_is_capable(t, __task_cred(t), cap);
85315 rcu_read_unlock();
85316
85317 - return (ret == 0);
85318 + return ret;
85319 }
85320
85321 /**
85322 @@ -334,10 +338,10 @@ bool has_ns_capability_noaudit(struct task_struct *t,
85323 int ret;
85324
85325 rcu_read_lock();
85326 - ret = security_capable_noaudit(__task_cred(t), ns, cap);
85327 + ret = security_capable_noaudit(__task_cred(t), ns, cap) == 0 && gr_task_is_capable_nolog(t, cap);
85328 rcu_read_unlock();
85329
85330 - return (ret == 0);
85331 + return ret;
85332 }
85333
85334 /**
85335 @@ -375,7 +379,7 @@ bool ns_capable(struct user_namespace *ns, int cap)
85336 BUG();
85337 }
85338
85339 - if (security_capable(current_cred(), ns, cap) == 0) {
85340 + if (security_capable(current_cred(), ns, cap) == 0 && gr_is_capable(cap)) {
85341 current->flags |= PF_SUPERPRIV;
85342 return true;
85343 }
85344 @@ -383,6 +387,21 @@ bool ns_capable(struct user_namespace *ns, int cap)
85345 }
85346 EXPORT_SYMBOL(ns_capable);
85347
85348 +bool ns_capable_nolog(struct user_namespace *ns, int cap)
85349 +{
85350 + if (unlikely(!cap_valid(cap))) {
85351 + printk(KERN_CRIT "capable_nolog() called with invalid cap=%u\n", cap);
85352 + BUG();
85353 + }
85354 +
85355 + if (security_capable_noaudit(current_cred(), ns, cap) == 0 && gr_is_capable_nolog(cap)) {
85356 + current->flags |= PF_SUPERPRIV;
85357 + return true;
85358 + }
85359 + return false;
85360 +}
85361 +EXPORT_SYMBOL(ns_capable_nolog);
85362 +
85363 /**
85364 * file_ns_capable - Determine if the file's opener had a capability in effect
85365 * @file: The file we want to check
85366 @@ -423,6 +442,12 @@ bool capable(int cap)
85367 }
85368 EXPORT_SYMBOL(capable);
85369
85370 +bool capable_nolog(int cap)
85371 +{
85372 + return ns_capable_nolog(&init_user_ns, cap);
85373 +}
85374 +EXPORT_SYMBOL(capable_nolog);
85375 +
85376 /**
85377 * capable_wrt_inode_uidgid - Check nsown_capable and uid and gid mapped
85378 * @inode: The inode in question
85379 @@ -440,3 +465,12 @@ bool capable_wrt_inode_uidgid(const struct inode *inode, int cap)
85380 kgid_has_mapping(ns, inode->i_gid);
85381 }
85382 EXPORT_SYMBOL(capable_wrt_inode_uidgid);
85383 +
85384 +bool capable_wrt_inode_uidgid_nolog(const struct inode *inode, int cap)
85385 +{
85386 + struct user_namespace *ns = current_user_ns();
85387 +
85388 + return ns_capable_nolog(ns, cap) && kuid_has_mapping(ns, inode->i_uid) &&
85389 + kgid_has_mapping(ns, inode->i_gid);
85390 +}
85391 +EXPORT_SYMBOL(capable_wrt_inode_uidgid_nolog);
85392 diff --git a/kernel/cgroup.c b/kernel/cgroup.c
85393 index ceee0c5..d6f81dd 100644
85394 --- a/kernel/cgroup.c
85395 +++ b/kernel/cgroup.c
85396 @@ -4757,7 +4757,7 @@ static int cgroup_css_links_read(struct seq_file *seq, void *v)
85397 struct task_struct *task;
85398 int count = 0;
85399
85400 - seq_printf(seq, "css_set %p\n", cset);
85401 + seq_printf(seq, "css_set %pK\n", cset);
85402
85403 list_for_each_entry(task, &cset->tasks, cg_list) {
85404 if (count++ > MAX_TASKS_SHOWN_PER_CSS)
85405 diff --git a/kernel/compat.c b/kernel/compat.c
85406 index e40b043..3da8f51 100644
85407 --- a/kernel/compat.c
85408 +++ b/kernel/compat.c
85409 @@ -13,6 +13,7 @@
85410
85411 #include <linux/linkage.h>
85412 #include <linux/compat.h>
85413 +#include <linux/module.h>
85414 #include <linux/errno.h>
85415 #include <linux/time.h>
85416 #include <linux/signal.h>
85417 @@ -220,7 +221,7 @@ static long compat_nanosleep_restart(struct restart_block *restart)
85418 mm_segment_t oldfs;
85419 long ret;
85420
85421 - restart->nanosleep.rmtp = (struct timespec __user *) &rmt;
85422 + restart->nanosleep.rmtp = (struct timespec __force_user *) &rmt;
85423 oldfs = get_fs();
85424 set_fs(KERNEL_DS);
85425 ret = hrtimer_nanosleep_restart(restart);
85426 @@ -252,7 +253,7 @@ COMPAT_SYSCALL_DEFINE2(nanosleep, struct compat_timespec __user *, rqtp,
85427 oldfs = get_fs();
85428 set_fs(KERNEL_DS);
85429 ret = hrtimer_nanosleep(&tu,
85430 - rmtp ? (struct timespec __user *)&rmt : NULL,
85431 + rmtp ? (struct timespec __force_user *)&rmt : NULL,
85432 HRTIMER_MODE_REL, CLOCK_MONOTONIC);
85433 set_fs(oldfs);
85434
85435 @@ -361,7 +362,7 @@ COMPAT_SYSCALL_DEFINE1(sigpending, compat_old_sigset_t __user *, set)
85436 mm_segment_t old_fs = get_fs();
85437
85438 set_fs(KERNEL_DS);
85439 - ret = sys_sigpending((old_sigset_t __user *) &s);
85440 + ret = sys_sigpending((old_sigset_t __force_user *) &s);
85441 set_fs(old_fs);
85442 if (ret == 0)
85443 ret = put_user(s, set);
85444 @@ -451,7 +452,7 @@ COMPAT_SYSCALL_DEFINE2(old_getrlimit, unsigned int, resource,
85445 mm_segment_t old_fs = get_fs();
85446
85447 set_fs(KERNEL_DS);
85448 - ret = sys_old_getrlimit(resource, (struct rlimit __user *)&r);
85449 + ret = sys_old_getrlimit(resource, (struct rlimit __force_user *)&r);
85450 set_fs(old_fs);
85451
85452 if (!ret) {
85453 @@ -533,8 +534,8 @@ COMPAT_SYSCALL_DEFINE4(wait4,
85454 set_fs (KERNEL_DS);
85455 ret = sys_wait4(pid,
85456 (stat_addr ?
85457 - (unsigned int __user *) &status : NULL),
85458 - options, (struct rusage __user *) &r);
85459 + (unsigned int __force_user *) &status : NULL),
85460 + options, (struct rusage __force_user *) &r);
85461 set_fs (old_fs);
85462
85463 if (ret > 0) {
85464 @@ -560,8 +561,8 @@ COMPAT_SYSCALL_DEFINE5(waitid,
85465 memset(&info, 0, sizeof(info));
85466
85467 set_fs(KERNEL_DS);
85468 - ret = sys_waitid(which, pid, (siginfo_t __user *)&info, options,
85469 - uru ? (struct rusage __user *)&ru : NULL);
85470 + ret = sys_waitid(which, pid, (siginfo_t __force_user *)&info, options,
85471 + uru ? (struct rusage __force_user *)&ru : NULL);
85472 set_fs(old_fs);
85473
85474 if ((ret < 0) || (info.si_signo == 0))
85475 @@ -695,8 +696,8 @@ COMPAT_SYSCALL_DEFINE4(timer_settime, timer_t, timer_id, int, flags,
85476 oldfs = get_fs();
85477 set_fs(KERNEL_DS);
85478 err = sys_timer_settime(timer_id, flags,
85479 - (struct itimerspec __user *) &newts,
85480 - (struct itimerspec __user *) &oldts);
85481 + (struct itimerspec __force_user *) &newts,
85482 + (struct itimerspec __force_user *) &oldts);
85483 set_fs(oldfs);
85484 if (!err && old && put_compat_itimerspec(old, &oldts))
85485 return -EFAULT;
85486 @@ -713,7 +714,7 @@ COMPAT_SYSCALL_DEFINE2(timer_gettime, timer_t, timer_id,
85487 oldfs = get_fs();
85488 set_fs(KERNEL_DS);
85489 err = sys_timer_gettime(timer_id,
85490 - (struct itimerspec __user *) &ts);
85491 + (struct itimerspec __force_user *) &ts);
85492 set_fs(oldfs);
85493 if (!err && put_compat_itimerspec(setting, &ts))
85494 return -EFAULT;
85495 @@ -732,7 +733,7 @@ COMPAT_SYSCALL_DEFINE2(clock_settime, clockid_t, which_clock,
85496 oldfs = get_fs();
85497 set_fs(KERNEL_DS);
85498 err = sys_clock_settime(which_clock,
85499 - (struct timespec __user *) &ts);
85500 + (struct timespec __force_user *) &ts);
85501 set_fs(oldfs);
85502 return err;
85503 }
85504 @@ -747,7 +748,7 @@ COMPAT_SYSCALL_DEFINE2(clock_gettime, clockid_t, which_clock,
85505 oldfs = get_fs();
85506 set_fs(KERNEL_DS);
85507 err = sys_clock_gettime(which_clock,
85508 - (struct timespec __user *) &ts);
85509 + (struct timespec __force_user *) &ts);
85510 set_fs(oldfs);
85511 if (!err && compat_put_timespec(&ts, tp))
85512 return -EFAULT;
85513 @@ -767,7 +768,7 @@ COMPAT_SYSCALL_DEFINE2(clock_adjtime, clockid_t, which_clock,
85514
85515 oldfs = get_fs();
85516 set_fs(KERNEL_DS);
85517 - ret = sys_clock_adjtime(which_clock, (struct timex __user *) &txc);
85518 + ret = sys_clock_adjtime(which_clock, (struct timex __force_user *) &txc);
85519 set_fs(oldfs);
85520
85521 err = compat_put_timex(utp, &txc);
85522 @@ -787,7 +788,7 @@ COMPAT_SYSCALL_DEFINE2(clock_getres, clockid_t, which_clock,
85523 oldfs = get_fs();
85524 set_fs(KERNEL_DS);
85525 err = sys_clock_getres(which_clock,
85526 - (struct timespec __user *) &ts);
85527 + (struct timespec __force_user *) &ts);
85528 set_fs(oldfs);
85529 if (!err && tp && compat_put_timespec(&ts, tp))
85530 return -EFAULT;
85531 @@ -801,7 +802,7 @@ static long compat_clock_nanosleep_restart(struct restart_block *restart)
85532 struct timespec tu;
85533 struct compat_timespec __user *rmtp = restart->nanosleep.compat_rmtp;
85534
85535 - restart->nanosleep.rmtp = (struct timespec __user *) &tu;
85536 + restart->nanosleep.rmtp = (struct timespec __force_user *) &tu;
85537 oldfs = get_fs();
85538 set_fs(KERNEL_DS);
85539 err = clock_nanosleep_restart(restart);
85540 @@ -833,8 +834,8 @@ COMPAT_SYSCALL_DEFINE4(clock_nanosleep, clockid_t, which_clock, int, flags,
85541 oldfs = get_fs();
85542 set_fs(KERNEL_DS);
85543 err = sys_clock_nanosleep(which_clock, flags,
85544 - (struct timespec __user *) &in,
85545 - (struct timespec __user *) &out);
85546 + (struct timespec __force_user *) &in,
85547 + (struct timespec __force_user *) &out);
85548 set_fs(oldfs);
85549
85550 if ((err == -ERESTART_RESTARTBLOCK) && rmtp &&
85551 @@ -1128,7 +1129,7 @@ COMPAT_SYSCALL_DEFINE2(sched_rr_get_interval,
85552 mm_segment_t old_fs = get_fs();
85553
85554 set_fs(KERNEL_DS);
85555 - ret = sys_sched_rr_get_interval(pid, (struct timespec __user *)&t);
85556 + ret = sys_sched_rr_get_interval(pid, (struct timespec __force_user *)&t);
85557 set_fs(old_fs);
85558 if (compat_put_timespec(&t, interval))
85559 return -EFAULT;
85560 diff --git a/kernel/configs.c b/kernel/configs.c
85561 index c18b1f1..b9a0132 100644
85562 --- a/kernel/configs.c
85563 +++ b/kernel/configs.c
85564 @@ -74,8 +74,19 @@ static int __init ikconfig_init(void)
85565 struct proc_dir_entry *entry;
85566
85567 /* create the current config file */
85568 +#if defined(CONFIG_GRKERNSEC_PROC_ADD) || defined(CONFIG_GRKERNSEC_HIDESYM)
85569 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_HIDESYM)
85570 + entry = proc_create("config.gz", S_IFREG | S_IRUSR, NULL,
85571 + &ikconfig_file_ops);
85572 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
85573 + entry = proc_create("config.gz", S_IFREG | S_IRUSR | S_IRGRP, NULL,
85574 + &ikconfig_file_ops);
85575 +#endif
85576 +#else
85577 entry = proc_create("config.gz", S_IFREG | S_IRUGO, NULL,
85578 &ikconfig_file_ops);
85579 +#endif
85580 +
85581 if (!entry)
85582 return -ENOMEM;
85583
85584 diff --git a/kernel/cred.c b/kernel/cred.c
85585 index e0573a4..26c0fd3 100644
85586 --- a/kernel/cred.c
85587 +++ b/kernel/cred.c
85588 @@ -164,6 +164,16 @@ void exit_creds(struct task_struct *tsk)
85589 validate_creds(cred);
85590 alter_cred_subscribers(cred, -1);
85591 put_cred(cred);
85592 +
85593 +#ifdef CONFIG_GRKERNSEC_SETXID
85594 + cred = (struct cred *) tsk->delayed_cred;
85595 + if (cred != NULL) {
85596 + tsk->delayed_cred = NULL;
85597 + validate_creds(cred);
85598 + alter_cred_subscribers(cred, -1);
85599 + put_cred(cred);
85600 + }
85601 +#endif
85602 }
85603
85604 /**
85605 @@ -411,7 +421,7 @@ static bool cred_cap_issubset(const struct cred *set, const struct cred *subset)
85606 * Always returns 0 thus allowing this function to be tail-called at the end
85607 * of, say, sys_setgid().
85608 */
85609 -int commit_creds(struct cred *new)
85610 +static int __commit_creds(struct cred *new)
85611 {
85612 struct task_struct *task = current;
85613 const struct cred *old = task->real_cred;
85614 @@ -430,6 +440,8 @@ int commit_creds(struct cred *new)
85615
85616 get_cred(new); /* we will require a ref for the subj creds too */
85617
85618 + gr_set_role_label(task, new->uid, new->gid);
85619 +
85620 /* dumpability changes */
85621 if (!uid_eq(old->euid, new->euid) ||
85622 !gid_eq(old->egid, new->egid) ||
85623 @@ -479,6 +491,105 @@ int commit_creds(struct cred *new)
85624 put_cred(old);
85625 return 0;
85626 }
85627 +#ifdef CONFIG_GRKERNSEC_SETXID
85628 +extern int set_user(struct cred *new);
85629 +
85630 +void gr_delayed_cred_worker(void)
85631 +{
85632 + const struct cred *new = current->delayed_cred;
85633 + struct cred *ncred;
85634 +
85635 + current->delayed_cred = NULL;
85636 +
85637 + if (!uid_eq(current_uid(), GLOBAL_ROOT_UID) && new != NULL) {
85638 + // from doing get_cred on it when queueing this
85639 + put_cred(new);
85640 + return;
85641 + } else if (new == NULL)
85642 + return;
85643 +
85644 + ncred = prepare_creds();
85645 + if (!ncred)
85646 + goto die;
85647 + // uids
85648 + ncred->uid = new->uid;
85649 + ncred->euid = new->euid;
85650 + ncred->suid = new->suid;
85651 + ncred->fsuid = new->fsuid;
85652 + // gids
85653 + ncred->gid = new->gid;
85654 + ncred->egid = new->egid;
85655 + ncred->sgid = new->sgid;
85656 + ncred->fsgid = new->fsgid;
85657 + // groups
85658 + set_groups(ncred, new->group_info);
85659 + // caps
85660 + ncred->securebits = new->securebits;
85661 + ncred->cap_inheritable = new->cap_inheritable;
85662 + ncred->cap_permitted = new->cap_permitted;
85663 + ncred->cap_effective = new->cap_effective;
85664 + ncred->cap_bset = new->cap_bset;
85665 +
85666 + if (set_user(ncred)) {
85667 + abort_creds(ncred);
85668 + goto die;
85669 + }
85670 +
85671 + // from doing get_cred on it when queueing this
85672 + put_cred(new);
85673 +
85674 + __commit_creds(ncred);
85675 + return;
85676 +die:
85677 + // from doing get_cred on it when queueing this
85678 + put_cred(new);
85679 + do_group_exit(SIGKILL);
85680 +}
85681 +#endif
85682 +
85683 +int commit_creds(struct cred *new)
85684 +{
85685 +#ifdef CONFIG_GRKERNSEC_SETXID
85686 + int ret;
85687 + int schedule_it = 0;
85688 + struct task_struct *t;
85689 + unsigned oldsecurebits = current_cred()->securebits;
85690 +
85691 + /* we won't get called with tasklist_lock held for writing
85692 + and interrupts disabled as the cred struct in that case is
85693 + init_cred
85694 + */
85695 + if (grsec_enable_setxid && !current_is_single_threaded() &&
85696 + uid_eq(current_uid(), GLOBAL_ROOT_UID) &&
85697 + !uid_eq(new->uid, GLOBAL_ROOT_UID)) {
85698 + schedule_it = 1;
85699 + }
85700 + ret = __commit_creds(new);
85701 + if (schedule_it) {
85702 + rcu_read_lock();
85703 + read_lock(&tasklist_lock);
85704 + for (t = next_thread(current); t != current;
85705 + t = next_thread(t)) {
85706 + /* we'll check if the thread has uid 0 in
85707 + * the delayed worker routine
85708 + */
85709 + if (task_securebits(t) == oldsecurebits &&
85710 + t->delayed_cred == NULL) {
85711 + t->delayed_cred = get_cred(new);
85712 + set_tsk_thread_flag(t, TIF_GRSEC_SETXID);
85713 + set_tsk_need_resched(t);
85714 + }
85715 + }
85716 + read_unlock(&tasklist_lock);
85717 + rcu_read_unlock();
85718 + }
85719 +
85720 + return ret;
85721 +#else
85722 + return __commit_creds(new);
85723 +#endif
85724 +}
85725 +
85726 EXPORT_SYMBOL(commit_creds);
85727
85728 /**
85729 diff --git a/kernel/debug/debug_core.c b/kernel/debug/debug_core.c
85730 index 2956c8d..cfe1e2e 100644
85731 --- a/kernel/debug/debug_core.c
85732 +++ b/kernel/debug/debug_core.c
85733 @@ -124,7 +124,7 @@ static DEFINE_RAW_SPINLOCK(dbg_slave_lock);
85734 */
85735 static atomic_t masters_in_kgdb;
85736 static atomic_t slaves_in_kgdb;
85737 -static atomic_t kgdb_break_tasklet_var;
85738 +static atomic_unchecked_t kgdb_break_tasklet_var;
85739 atomic_t kgdb_setting_breakpoint;
85740
85741 struct task_struct *kgdb_usethread;
85742 @@ -134,7 +134,7 @@ int kgdb_single_step;
85743 static pid_t kgdb_sstep_pid;
85744
85745 /* to keep track of the CPU which is doing the single stepping*/
85746 -atomic_t kgdb_cpu_doing_single_step = ATOMIC_INIT(-1);
85747 +atomic_unchecked_t kgdb_cpu_doing_single_step = ATOMIC_INIT(-1);
85748
85749 /*
85750 * If you are debugging a problem where roundup (the collection of
85751 @@ -549,7 +549,7 @@ return_normal:
85752 * kernel will only try for the value of sstep_tries before
85753 * giving up and continuing on.
85754 */
85755 - if (atomic_read(&kgdb_cpu_doing_single_step) != -1 &&
85756 + if (atomic_read_unchecked(&kgdb_cpu_doing_single_step) != -1 &&
85757 (kgdb_info[cpu].task &&
85758 kgdb_info[cpu].task->pid != kgdb_sstep_pid) && --sstep_tries) {
85759 atomic_set(&kgdb_active, -1);
85760 @@ -647,8 +647,8 @@ cpu_master_loop:
85761 }
85762
85763 kgdb_restore:
85764 - if (atomic_read(&kgdb_cpu_doing_single_step) != -1) {
85765 - int sstep_cpu = atomic_read(&kgdb_cpu_doing_single_step);
85766 + if (atomic_read_unchecked(&kgdb_cpu_doing_single_step) != -1) {
85767 + int sstep_cpu = atomic_read_unchecked(&kgdb_cpu_doing_single_step);
85768 if (kgdb_info[sstep_cpu].task)
85769 kgdb_sstep_pid = kgdb_info[sstep_cpu].task->pid;
85770 else
85771 @@ -925,18 +925,18 @@ static void kgdb_unregister_callbacks(void)
85772 static void kgdb_tasklet_bpt(unsigned long ing)
85773 {
85774 kgdb_breakpoint();
85775 - atomic_set(&kgdb_break_tasklet_var, 0);
85776 + atomic_set_unchecked(&kgdb_break_tasklet_var, 0);
85777 }
85778
85779 static DECLARE_TASKLET(kgdb_tasklet_breakpoint, kgdb_tasklet_bpt, 0);
85780
85781 void kgdb_schedule_breakpoint(void)
85782 {
85783 - if (atomic_read(&kgdb_break_tasklet_var) ||
85784 + if (atomic_read_unchecked(&kgdb_break_tasklet_var) ||
85785 atomic_read(&kgdb_active) != -1 ||
85786 atomic_read(&kgdb_setting_breakpoint))
85787 return;
85788 - atomic_inc(&kgdb_break_tasklet_var);
85789 + atomic_inc_unchecked(&kgdb_break_tasklet_var);
85790 tasklet_schedule(&kgdb_tasklet_breakpoint);
85791 }
85792 EXPORT_SYMBOL_GPL(kgdb_schedule_breakpoint);
85793 diff --git a/kernel/debug/kdb/kdb_main.c b/kernel/debug/kdb/kdb_main.c
85794 index 0b097c8..11dd5c5 100644
85795 --- a/kernel/debug/kdb/kdb_main.c
85796 +++ b/kernel/debug/kdb/kdb_main.c
85797 @@ -1977,7 +1977,7 @@ static int kdb_lsmod(int argc, const char **argv)
85798 continue;
85799
85800 kdb_printf("%-20s%8u 0x%p ", mod->name,
85801 - mod->core_size, (void *)mod);
85802 + mod->core_size_rx + mod->core_size_rw, (void *)mod);
85803 #ifdef CONFIG_MODULE_UNLOAD
85804 kdb_printf("%4ld ", module_refcount(mod));
85805 #endif
85806 @@ -1987,7 +1987,7 @@ static int kdb_lsmod(int argc, const char **argv)
85807 kdb_printf(" (Loading)");
85808 else
85809 kdb_printf(" (Live)");
85810 - kdb_printf(" 0x%p", mod->module_core);
85811 + kdb_printf(" 0x%p 0x%p", mod->module_core_rx, mod->module_core_rw);
85812
85813 #ifdef CONFIG_MODULE_UNLOAD
85814 {
85815 diff --git a/kernel/events/core.c b/kernel/events/core.c
85816 index 440eefc..0909f02 100644
85817 --- a/kernel/events/core.c
85818 +++ b/kernel/events/core.c
85819 @@ -158,8 +158,15 @@ static struct srcu_struct pmus_srcu;
85820 * 0 - disallow raw tracepoint access for unpriv
85821 * 1 - disallow cpu events for unpriv
85822 * 2 - disallow kernel profiling for unpriv
85823 + * 3 - disallow all unpriv perf event use
85824 */
85825 -int sysctl_perf_event_paranoid __read_mostly = 1;
85826 +#ifdef CONFIG_GRKERNSEC_PERF_HARDEN
85827 +int sysctl_perf_event_legitimately_concerned __read_mostly = 3;
85828 +#elif defined(CONFIG_GRKERNSEC_HIDESYM)
85829 +int sysctl_perf_event_legitimately_concerned __read_mostly = 2;
85830 +#else
85831 +int sysctl_perf_event_legitimately_concerned __read_mostly = 1;
85832 +#endif
85833
85834 /* Minimum for 512 kiB + 1 user control page */
85835 int sysctl_perf_event_mlock __read_mostly = 512 + (PAGE_SIZE / 1024); /* 'free' kiB per user */
85836 @@ -185,7 +192,7 @@ void update_perf_cpu_limits(void)
85837
85838 tmp *= sysctl_perf_cpu_time_max_percent;
85839 do_div(tmp, 100);
85840 - ACCESS_ONCE(perf_sample_allowed_ns) = tmp;
85841 + ACCESS_ONCE_RW(perf_sample_allowed_ns) = tmp;
85842 }
85843
85844 static int perf_rotate_context(struct perf_cpu_context *cpuctx);
85845 @@ -291,7 +298,7 @@ void perf_sample_event_took(u64 sample_len_ns)
85846 }
85847 }
85848
85849 -static atomic64_t perf_event_id;
85850 +static atomic64_unchecked_t perf_event_id;
85851
85852 static void cpu_ctx_sched_out(struct perf_cpu_context *cpuctx,
85853 enum event_type_t event_type);
85854 @@ -3002,7 +3009,7 @@ static void __perf_event_read(void *info)
85855
85856 static inline u64 perf_event_count(struct perf_event *event)
85857 {
85858 - return local64_read(&event->count) + atomic64_read(&event->child_count);
85859 + return local64_read(&event->count) + atomic64_read_unchecked(&event->child_count);
85860 }
85861
85862 static u64 perf_event_read(struct perf_event *event)
85863 @@ -3361,9 +3368,9 @@ u64 perf_event_read_value(struct perf_event *event, u64 *enabled, u64 *running)
85864 mutex_lock(&event->child_mutex);
85865 total += perf_event_read(event);
85866 *enabled += event->total_time_enabled +
85867 - atomic64_read(&event->child_total_time_enabled);
85868 + atomic64_read_unchecked(&event->child_total_time_enabled);
85869 *running += event->total_time_running +
85870 - atomic64_read(&event->child_total_time_running);
85871 + atomic64_read_unchecked(&event->child_total_time_running);
85872
85873 list_for_each_entry(child, &event->child_list, child_list) {
85874 total += perf_event_read(child);
85875 @@ -3792,10 +3799,10 @@ void perf_event_update_userpage(struct perf_event *event)
85876 userpg->offset -= local64_read(&event->hw.prev_count);
85877
85878 userpg->time_enabled = enabled +
85879 - atomic64_read(&event->child_total_time_enabled);
85880 + atomic64_read_unchecked(&event->child_total_time_enabled);
85881
85882 userpg->time_running = running +
85883 - atomic64_read(&event->child_total_time_running);
85884 + atomic64_read_unchecked(&event->child_total_time_running);
85885
85886 arch_perf_update_userpage(userpg, now);
85887
85888 @@ -4359,7 +4366,7 @@ perf_output_sample_ustack(struct perf_output_handle *handle, u64 dump_size,
85889
85890 /* Data. */
85891 sp = perf_user_stack_pointer(regs);
85892 - rem = __output_copy_user(handle, (void *) sp, dump_size);
85893 + rem = __output_copy_user(handle, (void __user *) sp, dump_size);
85894 dyn_size = dump_size - rem;
85895
85896 perf_output_skip(handle, rem);
85897 @@ -4450,11 +4457,11 @@ static void perf_output_read_one(struct perf_output_handle *handle,
85898 values[n++] = perf_event_count(event);
85899 if (read_format & PERF_FORMAT_TOTAL_TIME_ENABLED) {
85900 values[n++] = enabled +
85901 - atomic64_read(&event->child_total_time_enabled);
85902 + atomic64_read_unchecked(&event->child_total_time_enabled);
85903 }
85904 if (read_format & PERF_FORMAT_TOTAL_TIME_RUNNING) {
85905 values[n++] = running +
85906 - atomic64_read(&event->child_total_time_running);
85907 + atomic64_read_unchecked(&event->child_total_time_running);
85908 }
85909 if (read_format & PERF_FORMAT_ID)
85910 values[n++] = primary_event_id(event);
85911 @@ -6733,7 +6740,7 @@ perf_event_alloc(struct perf_event_attr *attr, int cpu,
85912 event->parent = parent_event;
85913
85914 event->ns = get_pid_ns(task_active_pid_ns(current));
85915 - event->id = atomic64_inc_return(&perf_event_id);
85916 + event->id = atomic64_inc_return_unchecked(&perf_event_id);
85917
85918 event->state = PERF_EVENT_STATE_INACTIVE;
85919
85920 @@ -7015,6 +7022,11 @@ SYSCALL_DEFINE5(perf_event_open,
85921 if (flags & ~PERF_FLAG_ALL)
85922 return -EINVAL;
85923
85924 +#ifdef CONFIG_GRKERNSEC_PERF_HARDEN
85925 + if (perf_paranoid_any() && !capable(CAP_SYS_ADMIN))
85926 + return -EACCES;
85927 +#endif
85928 +
85929 err = perf_copy_attr(attr_uptr, &attr);
85930 if (err)
85931 return err;
85932 @@ -7353,10 +7365,10 @@ static void sync_child_event(struct perf_event *child_event,
85933 /*
85934 * Add back the child's count to the parent's count:
85935 */
85936 - atomic64_add(child_val, &parent_event->child_count);
85937 - atomic64_add(child_event->total_time_enabled,
85938 + atomic64_add_unchecked(child_val, &parent_event->child_count);
85939 + atomic64_add_unchecked(child_event->total_time_enabled,
85940 &parent_event->child_total_time_enabled);
85941 - atomic64_add(child_event->total_time_running,
85942 + atomic64_add_unchecked(child_event->total_time_running,
85943 &parent_event->child_total_time_running);
85944
85945 /*
85946 diff --git a/kernel/events/internal.h b/kernel/events/internal.h
85947 index 569b2187..19940d9 100644
85948 --- a/kernel/events/internal.h
85949 +++ b/kernel/events/internal.h
85950 @@ -81,10 +81,10 @@ static inline unsigned long perf_data_size(struct ring_buffer *rb)
85951 return rb->nr_pages << (PAGE_SHIFT + page_order(rb));
85952 }
85953
85954 -#define DEFINE_OUTPUT_COPY(func_name, memcpy_func) \
85955 +#define DEFINE_OUTPUT_COPY(func_name, memcpy_func, user) \
85956 static inline unsigned long \
85957 func_name(struct perf_output_handle *handle, \
85958 - const void *buf, unsigned long len) \
85959 + const void user *buf, unsigned long len) \
85960 { \
85961 unsigned long size, written; \
85962 \
85963 @@ -117,7 +117,7 @@ memcpy_common(void *dst, const void *src, unsigned long n)
85964 return 0;
85965 }
85966
85967 -DEFINE_OUTPUT_COPY(__output_copy, memcpy_common)
85968 +DEFINE_OUTPUT_COPY(__output_copy, memcpy_common, )
85969
85970 static inline unsigned long
85971 memcpy_skip(void *dst, const void *src, unsigned long n)
85972 @@ -125,7 +125,7 @@ memcpy_skip(void *dst, const void *src, unsigned long n)
85973 return 0;
85974 }
85975
85976 -DEFINE_OUTPUT_COPY(__output_skip, memcpy_skip)
85977 +DEFINE_OUTPUT_COPY(__output_skip, memcpy_skip, )
85978
85979 #ifndef arch_perf_out_copy_user
85980 #define arch_perf_out_copy_user arch_perf_out_copy_user
85981 @@ -143,7 +143,7 @@ arch_perf_out_copy_user(void *dst, const void *src, unsigned long n)
85982 }
85983 #endif
85984
85985 -DEFINE_OUTPUT_COPY(__output_copy_user, arch_perf_out_copy_user)
85986 +DEFINE_OUTPUT_COPY(__output_copy_user, arch_perf_out_copy_user, __user)
85987
85988 /* Callchain handling */
85989 extern struct perf_callchain_entry *
85990 diff --git a/kernel/events/uprobes.c b/kernel/events/uprobes.c
85991 index 04709b6..d330828 100644
85992 --- a/kernel/events/uprobes.c
85993 +++ b/kernel/events/uprobes.c
85994 @@ -1666,7 +1666,7 @@ static int is_trap_at_addr(struct mm_struct *mm, unsigned long vaddr)
85995 {
85996 struct page *page;
85997 uprobe_opcode_t opcode;
85998 - int result;
85999 + long result;
86000
86001 pagefault_disable();
86002 result = __copy_from_user_inatomic(&opcode, (void __user*)vaddr,
86003 diff --git a/kernel/exit.c b/kernel/exit.c
86004 index 6ed6a1d..edecb0e 100644
86005 --- a/kernel/exit.c
86006 +++ b/kernel/exit.c
86007 @@ -173,6 +173,10 @@ void release_task(struct task_struct * p)
86008 struct task_struct *leader;
86009 int zap_leader;
86010 repeat:
86011 +#ifdef CONFIG_NET
86012 + gr_del_task_from_ip_table(p);
86013 +#endif
86014 +
86015 /* don't need to get the RCU readlock here - the process is dead and
86016 * can't be modifying its own credentials. But shut RCU-lockdep up */
86017 rcu_read_lock();
86018 @@ -330,7 +334,7 @@ int allow_signal(int sig)
86019 * know it'll be handled, so that they don't get converted to
86020 * SIGKILL or just silently dropped.
86021 */
86022 - current->sighand->action[(sig)-1].sa.sa_handler = (void __user *)2;
86023 + current->sighand->action[(sig)-1].sa.sa_handler = (__force void __user *)2;
86024 recalc_sigpending();
86025 spin_unlock_irq(&current->sighand->siglock);
86026 return 0;
86027 @@ -699,6 +703,8 @@ void do_exit(long code)
86028 struct task_struct *tsk = current;
86029 int group_dead;
86030
86031 + set_fs(USER_DS);
86032 +
86033 profile_task_exit(tsk);
86034
86035 WARN_ON(blk_needs_flush_plug(tsk));
86036 @@ -715,7 +721,6 @@ void do_exit(long code)
86037 * mm_release()->clear_child_tid() from writing to a user-controlled
86038 * kernel address.
86039 */
86040 - set_fs(USER_DS);
86041
86042 ptrace_event(PTRACE_EVENT_EXIT, code);
86043
86044 @@ -774,6 +779,9 @@ void do_exit(long code)
86045 tsk->exit_code = code;
86046 taskstats_exit(tsk, group_dead);
86047
86048 + gr_acl_handle_psacct(tsk, code);
86049 + gr_acl_handle_exit();
86050 +
86051 exit_mm(tsk);
86052
86053 if (group_dead)
86054 @@ -893,7 +901,7 @@ SYSCALL_DEFINE1(exit, int, error_code)
86055 * Take down every thread in the group. This is called by fatal signals
86056 * as well as by sys_exit_group (below).
86057 */
86058 -void
86059 +__noreturn void
86060 do_group_exit(int exit_code)
86061 {
86062 struct signal_struct *sig = current->signal;
86063 diff --git a/kernel/fork.c b/kernel/fork.c
86064 index 54a8d26..9a24446 100644
86065 --- a/kernel/fork.c
86066 +++ b/kernel/fork.c
86067 @@ -183,6 +183,48 @@ void thread_info_cache_init(void)
86068 # endif
86069 #endif
86070
86071 +#ifdef CONFIG_GRKERNSEC_KSTACKOVERFLOW
86072 +static inline struct thread_info *gr_alloc_thread_info_node(struct task_struct *tsk,
86073 + int node, void **lowmem_stack)
86074 +{
86075 + struct page *pages[THREAD_SIZE / PAGE_SIZE];
86076 + void *ret = NULL;
86077 + unsigned int i;
86078 +
86079 + *lowmem_stack = alloc_thread_info_node(tsk, node);
86080 + if (*lowmem_stack == NULL)
86081 + goto out;
86082 +
86083 + for (i = 0; i < THREAD_SIZE / PAGE_SIZE; i++)
86084 + pages[i] = virt_to_page(*lowmem_stack + (i * PAGE_SIZE));
86085 +
86086 + /* use VM_IOREMAP to gain THREAD_SIZE alignment */
86087 + ret = vmap(pages, THREAD_SIZE / PAGE_SIZE, VM_IOREMAP, PAGE_KERNEL);
86088 + if (ret == NULL) {
86089 + free_thread_info(*lowmem_stack);
86090 + *lowmem_stack = NULL;
86091 + }
86092 +
86093 +out:
86094 + return ret;
86095 +}
86096 +
86097 +static inline void gr_free_thread_info(struct task_struct *tsk, struct thread_info *ti)
86098 +{
86099 + unmap_process_stacks(tsk);
86100 +}
86101 +#else
86102 +static inline struct thread_info *gr_alloc_thread_info_node(struct task_struct *tsk,
86103 + int node, void **lowmem_stack)
86104 +{
86105 + return alloc_thread_info_node(tsk, node);
86106 +}
86107 +static inline void gr_free_thread_info(struct task_struct *tsk, struct thread_info *ti)
86108 +{
86109 + free_thread_info(ti);
86110 +}
86111 +#endif
86112 +
86113 /* SLAB cache for signal_struct structures (tsk->signal) */
86114 static struct kmem_cache *signal_cachep;
86115
86116 @@ -201,18 +243,22 @@ struct kmem_cache *vm_area_cachep;
86117 /* SLAB cache for mm_struct structures (tsk->mm) */
86118 static struct kmem_cache *mm_cachep;
86119
86120 -static void account_kernel_stack(struct thread_info *ti, int account)
86121 +static void account_kernel_stack(struct task_struct *tsk, struct thread_info *ti, int account)
86122 {
86123 +#ifdef CONFIG_GRKERNSEC_KSTACKOVERFLOW
86124 + struct zone *zone = page_zone(virt_to_page(tsk->lowmem_stack));
86125 +#else
86126 struct zone *zone = page_zone(virt_to_page(ti));
86127 +#endif
86128
86129 mod_zone_page_state(zone, NR_KERNEL_STACK, account);
86130 }
86131
86132 void free_task(struct task_struct *tsk)
86133 {
86134 - account_kernel_stack(tsk->stack, -1);
86135 + account_kernel_stack(tsk, tsk->stack, -1);
86136 arch_release_thread_info(tsk->stack);
86137 - free_thread_info(tsk->stack);
86138 + gr_free_thread_info(tsk, tsk->stack);
86139 rt_mutex_debug_task_free(tsk);
86140 ftrace_graph_exit_task(tsk);
86141 put_seccomp_filter(tsk);
86142 @@ -299,6 +345,7 @@ static struct task_struct *dup_task_struct(struct task_struct *orig)
86143 struct task_struct *tsk;
86144 struct thread_info *ti;
86145 unsigned long *stackend;
86146 + void *lowmem_stack;
86147 int node = tsk_fork_get_node(orig);
86148 int err;
86149
86150 @@ -306,7 +353,7 @@ static struct task_struct *dup_task_struct(struct task_struct *orig)
86151 if (!tsk)
86152 return NULL;
86153
86154 - ti = alloc_thread_info_node(tsk, node);
86155 + ti = gr_alloc_thread_info_node(tsk, node, &lowmem_stack);
86156 if (!ti)
86157 goto free_tsk;
86158
86159 @@ -315,6 +362,9 @@ static struct task_struct *dup_task_struct(struct task_struct *orig)
86160 goto free_ti;
86161
86162 tsk->stack = ti;
86163 +#ifdef CONFIG_GRKERNSEC_KSTACKOVERFLOW
86164 + tsk->lowmem_stack = lowmem_stack;
86165 +#endif
86166
86167 setup_thread_stack(tsk, orig);
86168 clear_user_return_notifier(tsk);
86169 @@ -323,7 +373,7 @@ static struct task_struct *dup_task_struct(struct task_struct *orig)
86170 *stackend = STACK_END_MAGIC; /* for overflow detection */
86171
86172 #ifdef CONFIG_CC_STACKPROTECTOR
86173 - tsk->stack_canary = get_random_int();
86174 + tsk->stack_canary = pax_get_random_long();
86175 #endif
86176
86177 /*
86178 @@ -337,24 +387,92 @@ static struct task_struct *dup_task_struct(struct task_struct *orig)
86179 tsk->splice_pipe = NULL;
86180 tsk->task_frag.page = NULL;
86181
86182 - account_kernel_stack(ti, 1);
86183 + account_kernel_stack(tsk, ti, 1);
86184
86185 return tsk;
86186
86187 free_ti:
86188 - free_thread_info(ti);
86189 + gr_free_thread_info(tsk, ti);
86190 free_tsk:
86191 free_task_struct(tsk);
86192 return NULL;
86193 }
86194
86195 #ifdef CONFIG_MMU
86196 -static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
86197 +static struct vm_area_struct *dup_vma(struct mm_struct *mm, struct mm_struct *oldmm, struct vm_area_struct *mpnt)
86198 +{
86199 + struct vm_area_struct *tmp;
86200 + unsigned long charge;
86201 + struct file *file;
86202 + int retval;
86203 +
86204 + charge = 0;
86205 + if (mpnt->vm_flags & VM_ACCOUNT) {
86206 + unsigned long len = vma_pages(mpnt);
86207 +
86208 + if (security_vm_enough_memory_mm(oldmm, len)) /* sic */
86209 + goto fail_nomem;
86210 + charge = len;
86211 + }
86212 + tmp = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
86213 + if (!tmp)
86214 + goto fail_nomem;
86215 + *tmp = *mpnt;
86216 + tmp->vm_mm = mm;
86217 + INIT_LIST_HEAD(&tmp->anon_vma_chain);
86218 + retval = vma_dup_policy(mpnt, tmp);
86219 + if (retval)
86220 + goto fail_nomem_policy;
86221 + if (anon_vma_fork(tmp, mpnt))
86222 + goto fail_nomem_anon_vma_fork;
86223 + tmp->vm_flags &= ~VM_LOCKED;
86224 + tmp->vm_next = tmp->vm_prev = NULL;
86225 + tmp->vm_mirror = NULL;
86226 + file = tmp->vm_file;
86227 + if (file) {
86228 + struct inode *inode = file_inode(file);
86229 + struct address_space *mapping = file->f_mapping;
86230 +
86231 + get_file(file);
86232 + if (tmp->vm_flags & VM_DENYWRITE)
86233 + atomic_dec(&inode->i_writecount);
86234 + mutex_lock(&mapping->i_mmap_mutex);
86235 + if (tmp->vm_flags & VM_SHARED)
86236 + mapping->i_mmap_writable++;
86237 + flush_dcache_mmap_lock(mapping);
86238 + /* insert tmp into the share list, just after mpnt */
86239 + if (unlikely(tmp->vm_flags & VM_NONLINEAR))
86240 + vma_nonlinear_insert(tmp, &mapping->i_mmap_nonlinear);
86241 + else
86242 + vma_interval_tree_insert_after(tmp, mpnt, &mapping->i_mmap);
86243 + flush_dcache_mmap_unlock(mapping);
86244 + mutex_unlock(&mapping->i_mmap_mutex);
86245 + }
86246 +
86247 + /*
86248 + * Clear hugetlb-related page reserves for children. This only
86249 + * affects MAP_PRIVATE mappings. Faults generated by the child
86250 + * are not guaranteed to succeed, even if read-only
86251 + */
86252 + if (is_vm_hugetlb_page(tmp))
86253 + reset_vma_resv_huge_pages(tmp);
86254 +
86255 + return tmp;
86256 +
86257 +fail_nomem_anon_vma_fork:
86258 + mpol_put(vma_policy(tmp));
86259 +fail_nomem_policy:
86260 + kmem_cache_free(vm_area_cachep, tmp);
86261 +fail_nomem:
86262 + vm_unacct_memory(charge);
86263 + return NULL;
86264 +}
86265 +
86266 +static __latent_entropy int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
86267 {
86268 struct vm_area_struct *mpnt, *tmp, *prev, **pprev;
86269 struct rb_node **rb_link, *rb_parent;
86270 int retval;
86271 - unsigned long charge;
86272
86273 uprobe_start_dup_mmap();
86274 down_write(&oldmm->mmap_sem);
86275 @@ -383,55 +501,15 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
86276
86277 prev = NULL;
86278 for (mpnt = oldmm->mmap; mpnt; mpnt = mpnt->vm_next) {
86279 - struct file *file;
86280 -
86281 if (mpnt->vm_flags & VM_DONTCOPY) {
86282 vm_stat_account(mm, mpnt->vm_flags, mpnt->vm_file,
86283 -vma_pages(mpnt));
86284 continue;
86285 }
86286 - charge = 0;
86287 - if (mpnt->vm_flags & VM_ACCOUNT) {
86288 - unsigned long len = vma_pages(mpnt);
86289 -
86290 - if (security_vm_enough_memory_mm(oldmm, len)) /* sic */
86291 - goto fail_nomem;
86292 - charge = len;
86293 - }
86294 - tmp = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
86295 - if (!tmp)
86296 - goto fail_nomem;
86297 - *tmp = *mpnt;
86298 - INIT_LIST_HEAD(&tmp->anon_vma_chain);
86299 - retval = vma_dup_policy(mpnt, tmp);
86300 - if (retval)
86301 - goto fail_nomem_policy;
86302 - tmp->vm_mm = mm;
86303 - if (anon_vma_fork(tmp, mpnt))
86304 - goto fail_nomem_anon_vma_fork;
86305 - tmp->vm_flags &= ~VM_LOCKED;
86306 - tmp->vm_next = tmp->vm_prev = NULL;
86307 - file = tmp->vm_file;
86308 - if (file) {
86309 - struct inode *inode = file_inode(file);
86310 - struct address_space *mapping = file->f_mapping;
86311 -
86312 - get_file(file);
86313 - if (tmp->vm_flags & VM_DENYWRITE)
86314 - atomic_dec(&inode->i_writecount);
86315 - mutex_lock(&mapping->i_mmap_mutex);
86316 - if (tmp->vm_flags & VM_SHARED)
86317 - mapping->i_mmap_writable++;
86318 - flush_dcache_mmap_lock(mapping);
86319 - /* insert tmp into the share list, just after mpnt */
86320 - if (unlikely(tmp->vm_flags & VM_NONLINEAR))
86321 - vma_nonlinear_insert(tmp,
86322 - &mapping->i_mmap_nonlinear);
86323 - else
86324 - vma_interval_tree_insert_after(tmp, mpnt,
86325 - &mapping->i_mmap);
86326 - flush_dcache_mmap_unlock(mapping);
86327 - mutex_unlock(&mapping->i_mmap_mutex);
86328 + tmp = dup_vma(mm, oldmm, mpnt);
86329 + if (!tmp) {
86330 + retval = -ENOMEM;
86331 + goto out;
86332 }
86333
86334 /*
86335 @@ -463,6 +541,31 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
86336 if (retval)
86337 goto out;
86338 }
86339 +
86340 +#ifdef CONFIG_PAX_SEGMEXEC
86341 + if (oldmm->pax_flags & MF_PAX_SEGMEXEC) {
86342 + struct vm_area_struct *mpnt_m;
86343 +
86344 + for (mpnt = oldmm->mmap, mpnt_m = mm->mmap; mpnt; mpnt = mpnt->vm_next, mpnt_m = mpnt_m->vm_next) {
86345 + BUG_ON(!mpnt_m || mpnt_m->vm_mirror || mpnt->vm_mm != oldmm || mpnt_m->vm_mm != mm);
86346 +
86347 + if (!mpnt->vm_mirror)
86348 + continue;
86349 +
86350 + if (mpnt->vm_end <= SEGMEXEC_TASK_SIZE) {
86351 + BUG_ON(mpnt->vm_mirror->vm_mirror != mpnt);
86352 + mpnt->vm_mirror = mpnt_m;
86353 + } else {
86354 + BUG_ON(mpnt->vm_mirror->vm_mirror == mpnt || mpnt->vm_mirror->vm_mirror->vm_mm != mm);
86355 + mpnt_m->vm_mirror = mpnt->vm_mirror->vm_mirror;
86356 + mpnt_m->vm_mirror->vm_mirror = mpnt_m;
86357 + mpnt->vm_mirror->vm_mirror = mpnt;
86358 + }
86359 + }
86360 + BUG_ON(mpnt_m);
86361 + }
86362 +#endif
86363 +
86364 /* a new mm has just been created */
86365 arch_dup_mmap(oldmm, mm);
86366 retval = 0;
86367 @@ -472,14 +575,6 @@ out:
86368 up_write(&oldmm->mmap_sem);
86369 uprobe_end_dup_mmap();
86370 return retval;
86371 -fail_nomem_anon_vma_fork:
86372 - mpol_put(vma_policy(tmp));
86373 -fail_nomem_policy:
86374 - kmem_cache_free(vm_area_cachep, tmp);
86375 -fail_nomem:
86376 - retval = -ENOMEM;
86377 - vm_unacct_memory(charge);
86378 - goto out;
86379 }
86380
86381 static inline int mm_alloc_pgd(struct mm_struct *mm)
86382 @@ -698,8 +793,8 @@ struct mm_struct *mm_access(struct task_struct *task, unsigned int mode)
86383 return ERR_PTR(err);
86384
86385 mm = get_task_mm(task);
86386 - if (mm && mm != current->mm &&
86387 - !ptrace_may_access(task, mode)) {
86388 + if (mm && ((mm != current->mm && !ptrace_may_access(task, mode)) ||
86389 + (mode == PTRACE_MODE_ATTACH && (gr_handle_proc_ptrace(task) || gr_acl_handle_procpidmem(task))))) {
86390 mmput(mm);
86391 mm = ERR_PTR(-EACCES);
86392 }
86393 @@ -918,13 +1013,20 @@ static int copy_fs(unsigned long clone_flags, struct task_struct *tsk)
86394 spin_unlock(&fs->lock);
86395 return -EAGAIN;
86396 }
86397 - fs->users++;
86398 + atomic_inc(&fs->users);
86399 spin_unlock(&fs->lock);
86400 return 0;
86401 }
86402 tsk->fs = copy_fs_struct(fs);
86403 if (!tsk->fs)
86404 return -ENOMEM;
86405 + /* Carry through gr_chroot_dentry and is_chrooted instead
86406 + of recomputing it here. Already copied when the task struct
86407 + is duplicated. This allows pivot_root to not be treated as
86408 + a chroot
86409 + */
86410 + //gr_set_chroot_entries(tsk, &tsk->fs->root);
86411 +
86412 return 0;
86413 }
86414
86415 @@ -1133,7 +1235,7 @@ init_task_pid(struct task_struct *task, enum pid_type type, struct pid *pid)
86416 * parts of the process environment (as per the clone
86417 * flags). The actual kick-off is left to the caller.
86418 */
86419 -static struct task_struct *copy_process(unsigned long clone_flags,
86420 +static __latent_entropy struct task_struct *copy_process(unsigned long clone_flags,
86421 unsigned long stack_start,
86422 unsigned long stack_size,
86423 int __user *child_tidptr,
86424 @@ -1205,6 +1307,9 @@ static struct task_struct *copy_process(unsigned long clone_flags,
86425 DEBUG_LOCKS_WARN_ON(!p->softirqs_enabled);
86426 #endif
86427 retval = -EAGAIN;
86428 +
86429 + gr_learn_resource(p, RLIMIT_NPROC, atomic_read(&p->real_cred->user->processes), 0);
86430 +
86431 if (atomic_read(&p->real_cred->user->processes) >=
86432 task_rlimit(p, RLIMIT_NPROC)) {
86433 if (p->real_cred->user != INIT_USER &&
86434 @@ -1452,6 +1557,11 @@ static struct task_struct *copy_process(unsigned long clone_flags,
86435 goto bad_fork_free_pid;
86436 }
86437
86438 + /* synchronizes with gr_set_acls()
86439 + we need to call this past the point of no return for fork()
86440 + */
86441 + gr_copy_label(p);
86442 +
86443 if (likely(p->pid)) {
86444 ptrace_init_task(p, (clone_flags & CLONE_PTRACE) || trace);
86445
86446 @@ -1539,6 +1649,8 @@ bad_fork_cleanup_count:
86447 bad_fork_free:
86448 free_task(p);
86449 fork_out:
86450 + gr_log_forkfail(retval);
86451 +
86452 return ERR_PTR(retval);
86453 }
86454
86455 @@ -1600,6 +1712,7 @@ long do_fork(unsigned long clone_flags,
86456
86457 p = copy_process(clone_flags, stack_start, stack_size,
86458 child_tidptr, NULL, trace);
86459 + add_latent_entropy();
86460 /*
86461 * Do this prior waking up the new thread - the thread pointer
86462 * might get invalid after that point, if the thread exits quickly.
86463 @@ -1614,6 +1727,8 @@ long do_fork(unsigned long clone_flags,
86464 if (clone_flags & CLONE_PARENT_SETTID)
86465 put_user(nr, parent_tidptr);
86466
86467 + gr_handle_brute_check();
86468 +
86469 if (clone_flags & CLONE_VFORK) {
86470 p->vfork_done = &vfork;
86471 init_completion(&vfork);
86472 @@ -1730,7 +1845,7 @@ void __init proc_caches_init(void)
86473 mm_cachep = kmem_cache_create("mm_struct",
86474 sizeof(struct mm_struct), ARCH_MIN_MMSTRUCT_ALIGN,
86475 SLAB_HWCACHE_ALIGN|SLAB_PANIC|SLAB_NOTRACK, NULL);
86476 - vm_area_cachep = KMEM_CACHE(vm_area_struct, SLAB_PANIC);
86477 + vm_area_cachep = KMEM_CACHE(vm_area_struct, SLAB_PANIC | SLAB_NO_SANITIZE);
86478 mmap_init();
86479 nsproxy_cache_init();
86480 }
86481 @@ -1770,7 +1885,7 @@ static int unshare_fs(unsigned long unshare_flags, struct fs_struct **new_fsp)
86482 return 0;
86483
86484 /* don't need lock here; in the worst case we'll do useless copy */
86485 - if (fs->users == 1)
86486 + if (atomic_read(&fs->users) == 1)
86487 return 0;
86488
86489 *new_fsp = copy_fs_struct(fs);
86490 @@ -1877,7 +1992,8 @@ SYSCALL_DEFINE1(unshare, unsigned long, unshare_flags)
86491 fs = current->fs;
86492 spin_lock(&fs->lock);
86493 current->fs = new_fs;
86494 - if (--fs->users)
86495 + gr_set_chroot_entries(current, &current->fs->root);
86496 + if (atomic_dec_return(&fs->users))
86497 new_fs = NULL;
86498 else
86499 new_fs = fs;
86500 diff --git a/kernel/futex.c b/kernel/futex.c
86501 index de938d2..c566038 100644
86502 --- a/kernel/futex.c
86503 +++ b/kernel/futex.c
86504 @@ -202,7 +202,7 @@ struct futex_pi_state {
86505 atomic_t refcount;
86506
86507 union futex_key key;
86508 -};
86509 +} __randomize_layout;
86510
86511 /**
86512 * struct futex_q - The hashed futex queue entry, one per waiting task
86513 @@ -236,7 +236,7 @@ struct futex_q {
86514 struct rt_mutex_waiter *rt_waiter;
86515 union futex_key *requeue_pi_key;
86516 u32 bitset;
86517 -};
86518 +} __randomize_layout;
86519
86520 static const struct futex_q futex_q_init = {
86521 /* list gets initialized in queue_me()*/
86522 @@ -394,6 +394,11 @@ get_futex_key(u32 __user *uaddr, int fshared, union futex_key *key, int rw)
86523 struct page *page, *page_head;
86524 int err, ro = 0;
86525
86526 +#ifdef CONFIG_PAX_SEGMEXEC
86527 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && address >= SEGMEXEC_TASK_SIZE)
86528 + return -EFAULT;
86529 +#endif
86530 +
86531 /*
86532 * The futex address must be "naturally" aligned.
86533 */
86534 @@ -593,7 +598,7 @@ static int cmpxchg_futex_value_locked(u32 *curval, u32 __user *uaddr,
86535
86536 static int get_futex_value_locked(u32 *dest, u32 __user *from)
86537 {
86538 - int ret;
86539 + unsigned long ret;
86540
86541 pagefault_disable();
86542 ret = __copy_from_user_inatomic(dest, from, sizeof(u32));
86543 @@ -3033,6 +3038,7 @@ static void __init futex_detect_cmpxchg(void)
86544 {
86545 #ifndef CONFIG_HAVE_FUTEX_CMPXCHG
86546 u32 curval;
86547 + mm_segment_t oldfs;
86548
86549 /*
86550 * This will fail and we want it. Some arch implementations do
86551 @@ -3044,8 +3050,11 @@ static void __init futex_detect_cmpxchg(void)
86552 * implementation, the non-functional ones will return
86553 * -ENOSYS.
86554 */
86555 + oldfs = get_fs();
86556 + set_fs(USER_DS);
86557 if (cmpxchg_futex_value_locked(&curval, NULL, 0, 0) == -EFAULT)
86558 futex_cmpxchg_enabled = 1;
86559 + set_fs(oldfs);
86560 #endif
86561 }
86562
86563 diff --git a/kernel/futex_compat.c b/kernel/futex_compat.c
86564 index 55c8c93..9ba7ad6 100644
86565 --- a/kernel/futex_compat.c
86566 +++ b/kernel/futex_compat.c
86567 @@ -32,7 +32,7 @@ fetch_robust_entry(compat_uptr_t *uentry, struct robust_list __user **entry,
86568 return 0;
86569 }
86570
86571 -static void __user *futex_uaddr(struct robust_list __user *entry,
86572 +static void __user __intentional_overflow(-1) *futex_uaddr(struct robust_list __user *entry,
86573 compat_long_t futex_offset)
86574 {
86575 compat_uptr_t base = ptr_to_compat(entry);
86576 diff --git a/kernel/gcov/base.c b/kernel/gcov/base.c
86577 index f45b75b..bfac6d5 100644
86578 --- a/kernel/gcov/base.c
86579 +++ b/kernel/gcov/base.c
86580 @@ -108,11 +108,6 @@ void gcov_enable_events(void)
86581 }
86582
86583 #ifdef CONFIG_MODULES
86584 -static inline int within(void *addr, void *start, unsigned long size)
86585 -{
86586 - return ((addr >= start) && (addr < start + size));
86587 -}
86588 -
86589 /* Update list and generate events when modules are unloaded. */
86590 static int gcov_module_notifier(struct notifier_block *nb, unsigned long event,
86591 void *data)
86592 @@ -127,7 +122,7 @@ static int gcov_module_notifier(struct notifier_block *nb, unsigned long event,
86593
86594 /* Remove entries located in module from linked list. */
86595 while ((info = gcov_info_next(info))) {
86596 - if (within(info, mod->module_core, mod->core_size)) {
86597 + if (within_module_core_rw((unsigned long)info, mod)) {
86598 gcov_info_unlink(prev, info);
86599 if (gcov_events_enabled)
86600 gcov_event(GCOV_REMOVE, info);
86601 diff --git a/kernel/hrtimer.c b/kernel/hrtimer.c
86602 index e0501fe..312edd6 100644
86603 --- a/kernel/hrtimer.c
86604 +++ b/kernel/hrtimer.c
86605 @@ -1448,7 +1448,7 @@ void hrtimer_peek_ahead_timers(void)
86606 local_irq_restore(flags);
86607 }
86608
86609 -static void run_hrtimer_softirq(struct softirq_action *h)
86610 +static __latent_entropy void run_hrtimer_softirq(void)
86611 {
86612 hrtimer_peek_ahead_timers();
86613 }
86614 diff --git a/kernel/irq_work.c b/kernel/irq_work.c
86615 index a82170e..5b01e7f 100644
86616 --- a/kernel/irq_work.c
86617 +++ b/kernel/irq_work.c
86618 @@ -191,12 +191,13 @@ static int irq_work_cpu_notify(struct notifier_block *self,
86619 return NOTIFY_OK;
86620 }
86621
86622 -static struct notifier_block cpu_notify;
86623 +static struct notifier_block cpu_notify = {
86624 + .notifier_call = irq_work_cpu_notify,
86625 + .priority = 0,
86626 +};
86627
86628 static __init int irq_work_init_cpu_notifier(void)
86629 {
86630 - cpu_notify.notifier_call = irq_work_cpu_notify;
86631 - cpu_notify.priority = 0;
86632 register_cpu_notifier(&cpu_notify);
86633 return 0;
86634 }
86635 diff --git a/kernel/jump_label.c b/kernel/jump_label.c
86636 index 9019f15..9a3c42e 100644
86637 --- a/kernel/jump_label.c
86638 +++ b/kernel/jump_label.c
86639 @@ -14,6 +14,7 @@
86640 #include <linux/err.h>
86641 #include <linux/static_key.h>
86642 #include <linux/jump_label_ratelimit.h>
86643 +#include <linux/mm.h>
86644
86645 #ifdef HAVE_JUMP_LABEL
86646
86647 @@ -51,7 +52,9 @@ jump_label_sort_entries(struct jump_entry *start, struct jump_entry *stop)
86648
86649 size = (((unsigned long)stop - (unsigned long)start)
86650 / sizeof(struct jump_entry));
86651 + pax_open_kernel();
86652 sort(start, size, sizeof(struct jump_entry), jump_label_cmp, NULL);
86653 + pax_close_kernel();
86654 }
86655
86656 static void jump_label_update(struct static_key *key, int enable);
86657 @@ -363,10 +366,12 @@ static void jump_label_invalidate_module_init(struct module *mod)
86658 struct jump_entry *iter_stop = iter_start + mod->num_jump_entries;
86659 struct jump_entry *iter;
86660
86661 + pax_open_kernel();
86662 for (iter = iter_start; iter < iter_stop; iter++) {
86663 if (within_module_init(iter->code, mod))
86664 iter->code = 0;
86665 }
86666 + pax_close_kernel();
86667 }
86668
86669 static int
86670 diff --git a/kernel/kallsyms.c b/kernel/kallsyms.c
86671 index cb0cf37..b69e161 100644
86672 --- a/kernel/kallsyms.c
86673 +++ b/kernel/kallsyms.c
86674 @@ -11,6 +11,9 @@
86675 * Changed the compression method from stem compression to "table lookup"
86676 * compression (see scripts/kallsyms.c for a more complete description)
86677 */
86678 +#ifdef CONFIG_GRKERNSEC_HIDESYM
86679 +#define __INCLUDED_BY_HIDESYM 1
86680 +#endif
86681 #include <linux/kallsyms.h>
86682 #include <linux/module.h>
86683 #include <linux/init.h>
86684 @@ -54,12 +57,33 @@ extern const unsigned long kallsyms_markers[] __weak;
86685
86686 static inline int is_kernel_inittext(unsigned long addr)
86687 {
86688 + if (system_state != SYSTEM_BOOTING)
86689 + return 0;
86690 +
86691 if (addr >= (unsigned long)_sinittext
86692 && addr <= (unsigned long)_einittext)
86693 return 1;
86694 return 0;
86695 }
86696
86697 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
86698 +#ifdef CONFIG_MODULES
86699 +static inline int is_module_text(unsigned long addr)
86700 +{
86701 + if ((unsigned long)MODULES_EXEC_VADDR <= addr && addr <= (unsigned long)MODULES_EXEC_END)
86702 + return 1;
86703 +
86704 + addr = ktla_ktva(addr);
86705 + return (unsigned long)MODULES_EXEC_VADDR <= addr && addr <= (unsigned long)MODULES_EXEC_END;
86706 +}
86707 +#else
86708 +static inline int is_module_text(unsigned long addr)
86709 +{
86710 + return 0;
86711 +}
86712 +#endif
86713 +#endif
86714 +
86715 static inline int is_kernel_text(unsigned long addr)
86716 {
86717 if ((addr >= (unsigned long)_stext && addr <= (unsigned long)_etext) ||
86718 @@ -70,13 +94,28 @@ static inline int is_kernel_text(unsigned long addr)
86719
86720 static inline int is_kernel(unsigned long addr)
86721 {
86722 +
86723 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
86724 + if (is_kernel_text(addr) || is_kernel_inittext(addr))
86725 + return 1;
86726 +
86727 + if (ktla_ktva((unsigned long)_text) <= addr && addr < (unsigned long)_end)
86728 +#else
86729 if (addr >= (unsigned long)_stext && addr <= (unsigned long)_end)
86730 +#endif
86731 +
86732 return 1;
86733 return in_gate_area_no_mm(addr);
86734 }
86735
86736 static int is_ksym_addr(unsigned long addr)
86737 {
86738 +
86739 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
86740 + if (is_module_text(addr))
86741 + return 0;
86742 +#endif
86743 +
86744 if (all_var)
86745 return is_kernel(addr);
86746
86747 @@ -481,7 +520,6 @@ static unsigned long get_ksymbol_core(struct kallsym_iter *iter)
86748
86749 static void reset_iter(struct kallsym_iter *iter, loff_t new_pos)
86750 {
86751 - iter->name[0] = '\0';
86752 iter->nameoff = get_symbol_offset(new_pos);
86753 iter->pos = new_pos;
86754 }
86755 @@ -529,6 +567,11 @@ static int s_show(struct seq_file *m, void *p)
86756 {
86757 struct kallsym_iter *iter = m->private;
86758
86759 +#ifdef CONFIG_GRKERNSEC_HIDESYM
86760 + if (!uid_eq(current_uid(), GLOBAL_ROOT_UID))
86761 + return 0;
86762 +#endif
86763 +
86764 /* Some debugging symbols have no name. Ignore them. */
86765 if (!iter->name[0])
86766 return 0;
86767 @@ -542,6 +585,7 @@ static int s_show(struct seq_file *m, void *p)
86768 */
86769 type = iter->exported ? toupper(iter->type) :
86770 tolower(iter->type);
86771 +
86772 seq_printf(m, "%pK %c %s\t[%s]\n", (void *)iter->value,
86773 type, iter->name, iter->module_name);
86774 } else
86775 @@ -567,7 +611,7 @@ static int kallsyms_open(struct inode *inode, struct file *file)
86776 struct kallsym_iter *iter;
86777 int ret;
86778
86779 - iter = kmalloc(sizeof(*iter), GFP_KERNEL);
86780 + iter = kzalloc(sizeof(*iter), GFP_KERNEL);
86781 if (!iter)
86782 return -ENOMEM;
86783 reset_iter(iter, 0);
86784 diff --git a/kernel/kcmp.c b/kernel/kcmp.c
86785 index e30ac0f..3528cac 100644
86786 --- a/kernel/kcmp.c
86787 +++ b/kernel/kcmp.c
86788 @@ -99,6 +99,10 @@ SYSCALL_DEFINE5(kcmp, pid_t, pid1, pid_t, pid2, int, type,
86789 struct task_struct *task1, *task2;
86790 int ret;
86791
86792 +#ifdef CONFIG_GRKERNSEC
86793 + return -ENOSYS;
86794 +#endif
86795 +
86796 rcu_read_lock();
86797
86798 /*
86799 diff --git a/kernel/kexec.c b/kernel/kexec.c
86800 index 28c5706..bfc8388 100644
86801 --- a/kernel/kexec.c
86802 +++ b/kernel/kexec.c
86803 @@ -1046,7 +1046,8 @@ COMPAT_SYSCALL_DEFINE4(kexec_load, compat_ulong_t, entry,
86804 compat_ulong_t, flags)
86805 {
86806 struct compat_kexec_segment in;
86807 - struct kexec_segment out, __user *ksegments;
86808 + struct kexec_segment out;
86809 + struct kexec_segment __user *ksegments;
86810 unsigned long i, result;
86811
86812 /* Don't allow clients that don't understand the native
86813 diff --git a/kernel/kmod.c b/kernel/kmod.c
86814 index 6b375af..eaff670 100644
86815 --- a/kernel/kmod.c
86816 +++ b/kernel/kmod.c
86817 @@ -75,7 +75,7 @@ static void free_modprobe_argv(struct subprocess_info *info)
86818 kfree(info->argv);
86819 }
86820
86821 -static int call_modprobe(char *module_name, int wait)
86822 +static int call_modprobe(char *module_name, char *module_param, int wait)
86823 {
86824 struct subprocess_info *info;
86825 static char *envp[] = {
86826 @@ -85,7 +85,7 @@ static int call_modprobe(char *module_name, int wait)
86827 NULL
86828 };
86829
86830 - char **argv = kmalloc(sizeof(char *[5]), GFP_KERNEL);
86831 + char **argv = kmalloc(sizeof(char *[6]), GFP_KERNEL);
86832 if (!argv)
86833 goto out;
86834
86835 @@ -97,7 +97,8 @@ static int call_modprobe(char *module_name, int wait)
86836 argv[1] = "-q";
86837 argv[2] = "--";
86838 argv[3] = module_name; /* check free_modprobe_argv() */
86839 - argv[4] = NULL;
86840 + argv[4] = module_param;
86841 + argv[5] = NULL;
86842
86843 info = call_usermodehelper_setup(modprobe_path, argv, envp, GFP_KERNEL,
86844 NULL, free_modprobe_argv, NULL);
86845 @@ -129,9 +130,8 @@ out:
86846 * If module auto-loading support is disabled then this function
86847 * becomes a no-operation.
86848 */
86849 -int __request_module(bool wait, const char *fmt, ...)
86850 +static int ____request_module(bool wait, char *module_param, const char *fmt, va_list ap)
86851 {
86852 - va_list args;
86853 char module_name[MODULE_NAME_LEN];
86854 unsigned int max_modprobes;
86855 int ret;
86856 @@ -150,9 +150,7 @@ int __request_module(bool wait, const char *fmt, ...)
86857 if (!modprobe_path[0])
86858 return 0;
86859
86860 - va_start(args, fmt);
86861 - ret = vsnprintf(module_name, MODULE_NAME_LEN, fmt, args);
86862 - va_end(args);
86863 + ret = vsnprintf(module_name, MODULE_NAME_LEN, fmt, ap);
86864 if (ret >= MODULE_NAME_LEN)
86865 return -ENAMETOOLONG;
86866
86867 @@ -160,6 +158,20 @@ int __request_module(bool wait, const char *fmt, ...)
86868 if (ret)
86869 return ret;
86870
86871 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
86872 + if (uid_eq(current_uid(), GLOBAL_ROOT_UID)) {
86873 + /* hack to workaround consolekit/udisks stupidity */
86874 + read_lock(&tasklist_lock);
86875 + if (!strcmp(current->comm, "mount") &&
86876 + current->real_parent && !strncmp(current->real_parent->comm, "udisk", 5)) {
86877 + read_unlock(&tasklist_lock);
86878 + printk(KERN_ALERT "grsec: denied attempt to auto-load fs module %.64s by udisks\n", module_name);
86879 + return -EPERM;
86880 + }
86881 + read_unlock(&tasklist_lock);
86882 + }
86883 +#endif
86884 +
86885 /* If modprobe needs a service that is in a module, we get a recursive
86886 * loop. Limit the number of running kmod threads to max_threads/2 or
86887 * MAX_KMOD_CONCURRENT, whichever is the smaller. A cleaner method
86888 @@ -188,11 +200,52 @@ int __request_module(bool wait, const char *fmt, ...)
86889
86890 trace_module_request(module_name, wait, _RET_IP_);
86891
86892 - ret = call_modprobe(module_name, wait ? UMH_WAIT_PROC : UMH_WAIT_EXEC);
86893 + ret = call_modprobe(module_name, module_param, wait ? UMH_WAIT_PROC : UMH_WAIT_EXEC);
86894
86895 atomic_dec(&kmod_concurrent);
86896 return ret;
86897 }
86898 +
86899 +int ___request_module(bool wait, char *module_param, const char *fmt, ...)
86900 +{
86901 + va_list args;
86902 + int ret;
86903 +
86904 + va_start(args, fmt);
86905 + ret = ____request_module(wait, module_param, fmt, args);
86906 + va_end(args);
86907 +
86908 + return ret;
86909 +}
86910 +
86911 +int __request_module(bool wait, const char *fmt, ...)
86912 +{
86913 + va_list args;
86914 + int ret;
86915 +
86916 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
86917 + if (!uid_eq(current_uid(), GLOBAL_ROOT_UID)) {
86918 + char module_param[MODULE_NAME_LEN];
86919 +
86920 + memset(module_param, 0, sizeof(module_param));
86921 +
86922 + snprintf(module_param, sizeof(module_param) - 1, "grsec_modharden_normal%u_", GR_GLOBAL_UID(current_uid()));
86923 +
86924 + va_start(args, fmt);
86925 + ret = ____request_module(wait, module_param, fmt, args);
86926 + va_end(args);
86927 +
86928 + return ret;
86929 + }
86930 +#endif
86931 +
86932 + va_start(args, fmt);
86933 + ret = ____request_module(wait, NULL, fmt, args);
86934 + va_end(args);
86935 +
86936 + return ret;
86937 +}
86938 +
86939 EXPORT_SYMBOL(__request_module);
86940 #endif /* CONFIG_MODULES */
86941
86942 @@ -218,6 +271,20 @@ static int ____call_usermodehelper(void *data)
86943 */
86944 set_user_nice(current, 0);
86945
86946 +#ifdef CONFIG_GRKERNSEC
86947 + /* this is race-free as far as userland is concerned as we copied
86948 + out the path to be used prior to this point and are now operating
86949 + on that copy
86950 + */
86951 + if ((strncmp(sub_info->path, "/sbin/", 6) && strncmp(sub_info->path, "/usr/lib/", 9) &&
86952 + strncmp(sub_info->path, "/lib/", 5) && strncmp(sub_info->path, "/lib64/", 7) &&
86953 + strcmp(sub_info->path, "/usr/share/apport/apport")) || strstr(sub_info->path, "..")) {
86954 + printk(KERN_ALERT "grsec: denied exec of usermode helper binary %.950s located outside of /sbin and system library paths\n", sub_info->path);
86955 + retval = -EPERM;
86956 + goto fail;
86957 + }
86958 +#endif
86959 +
86960 retval = -ENOMEM;
86961 new = prepare_kernel_cred(current);
86962 if (!new)
86963 @@ -240,8 +307,8 @@ static int ____call_usermodehelper(void *data)
86964 commit_creds(new);
86965
86966 retval = do_execve(getname_kernel(sub_info->path),
86967 - (const char __user *const __user *)sub_info->argv,
86968 - (const char __user *const __user *)sub_info->envp);
86969 + (const char __user *const __force_user *)sub_info->argv,
86970 + (const char __user *const __force_user *)sub_info->envp);
86971 if (!retval)
86972 return 0;
86973
86974 @@ -260,6 +327,10 @@ static int call_helper(void *data)
86975
86976 static void call_usermodehelper_freeinfo(struct subprocess_info *info)
86977 {
86978 +#ifdef CONFIG_GRKERNSEC
86979 + kfree(info->path);
86980 + info->path = info->origpath;
86981 +#endif
86982 if (info->cleanup)
86983 (*info->cleanup)(info);
86984 kfree(info);
86985 @@ -303,7 +374,7 @@ static int wait_for_helper(void *data)
86986 *
86987 * Thus the __user pointer cast is valid here.
86988 */
86989 - sys_wait4(pid, (int __user *)&ret, 0, NULL);
86990 + sys_wait4(pid, (int __force_user *)&ret, 0, NULL);
86991
86992 /*
86993 * If ret is 0, either ____call_usermodehelper failed and the
86994 @@ -542,7 +613,12 @@ struct subprocess_info *call_usermodehelper_setup(char *path, char **argv,
86995 goto out;
86996
86997 INIT_WORK(&sub_info->work, __call_usermodehelper);
86998 +#ifdef CONFIG_GRKERNSEC
86999 + sub_info->origpath = path;
87000 + sub_info->path = kstrdup(path, gfp_mask);
87001 +#else
87002 sub_info->path = path;
87003 +#endif
87004 sub_info->argv = argv;
87005 sub_info->envp = envp;
87006
87007 @@ -650,7 +726,7 @@ EXPORT_SYMBOL(call_usermodehelper);
87008 static int proc_cap_handler(struct ctl_table *table, int write,
87009 void __user *buffer, size_t *lenp, loff_t *ppos)
87010 {
87011 - struct ctl_table t;
87012 + ctl_table_no_const t;
87013 unsigned long cap_array[_KERNEL_CAPABILITY_U32S];
87014 kernel_cap_t new_cap;
87015 int err, i;
87016 diff --git a/kernel/kprobes.c b/kernel/kprobes.c
87017 index ceeadfc..11c18b6 100644
87018 --- a/kernel/kprobes.c
87019 +++ b/kernel/kprobes.c
87020 @@ -31,6 +31,9 @@
87021 * <jkenisto@us.ibm.com> and Prasanna S Panchamukhi
87022 * <prasanna@in.ibm.com> added function-return probes.
87023 */
87024 +#ifdef CONFIG_GRKERNSEC_HIDESYM
87025 +#define __INCLUDED_BY_HIDESYM 1
87026 +#endif
87027 #include <linux/kprobes.h>
87028 #include <linux/hash.h>
87029 #include <linux/init.h>
87030 @@ -135,12 +138,12 @@ enum kprobe_slot_state {
87031
87032 static void *alloc_insn_page(void)
87033 {
87034 - return module_alloc(PAGE_SIZE);
87035 + return module_alloc_exec(PAGE_SIZE);
87036 }
87037
87038 static void free_insn_page(void *page)
87039 {
87040 - module_free(NULL, page);
87041 + module_free_exec(NULL, page);
87042 }
87043
87044 struct kprobe_insn_cache kprobe_insn_slots = {
87045 @@ -2151,11 +2154,11 @@ static void __kprobes report_probe(struct seq_file *pi, struct kprobe *p,
87046 kprobe_type = "k";
87047
87048 if (sym)
87049 - seq_printf(pi, "%p %s %s+0x%x %s ",
87050 + seq_printf(pi, "%pK %s %s+0x%x %s ",
87051 p->addr, kprobe_type, sym, offset,
87052 (modname ? modname : " "));
87053 else
87054 - seq_printf(pi, "%p %s %p ",
87055 + seq_printf(pi, "%pK %s %pK ",
87056 p->addr, kprobe_type, p->addr);
87057
87058 if (!pp)
87059 diff --git a/kernel/ksysfs.c b/kernel/ksysfs.c
87060 index 2495a9b..071b906 100644
87061 --- a/kernel/ksysfs.c
87062 +++ b/kernel/ksysfs.c
87063 @@ -49,6 +49,8 @@ static ssize_t uevent_helper_store(struct kobject *kobj,
87064 {
87065 if (count+1 > UEVENT_HELPER_PATH_LEN)
87066 return -ENOENT;
87067 + if (!capable(CAP_SYS_ADMIN))
87068 + return -EPERM;
87069 memcpy(uevent_helper, buf, count);
87070 uevent_helper[count] = '\0';
87071 if (count && uevent_helper[count-1] == '\n')
87072 @@ -175,7 +177,7 @@ static ssize_t notes_read(struct file *filp, struct kobject *kobj,
87073 return count;
87074 }
87075
87076 -static struct bin_attribute notes_attr = {
87077 +static bin_attribute_no_const notes_attr __read_only = {
87078 .attr = {
87079 .name = "notes",
87080 .mode = S_IRUGO,
87081 diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c
87082 index d24e433..fa04fb8 100644
87083 --- a/kernel/locking/lockdep.c
87084 +++ b/kernel/locking/lockdep.c
87085 @@ -597,6 +597,10 @@ static int static_obj(void *obj)
87086 end = (unsigned long) &_end,
87087 addr = (unsigned long) obj;
87088
87089 +#ifdef CONFIG_PAX_KERNEXEC
87090 + start = ktla_ktva(start);
87091 +#endif
87092 +
87093 /*
87094 * static variable?
87095 */
87096 @@ -738,6 +742,7 @@ register_lock_class(struct lockdep_map *lock, unsigned int subclass, int force)
87097 if (!static_obj(lock->key)) {
87098 debug_locks_off();
87099 printk("INFO: trying to register non-static key.\n");
87100 + printk("lock:%pS key:%pS.\n", lock, lock->key);
87101 printk("the code is fine but needs lockdep annotation.\n");
87102 printk("turning off the locking correctness validator.\n");
87103 dump_stack();
87104 @@ -3079,7 +3084,7 @@ static int __lock_acquire(struct lockdep_map *lock, unsigned int subclass,
87105 if (!class)
87106 return 0;
87107 }
87108 - atomic_inc((atomic_t *)&class->ops);
87109 + atomic_long_inc_unchecked((atomic_long_unchecked_t *)&class->ops);
87110 if (very_verbose(class)) {
87111 printk("\nacquire class [%p] %s", class->key, class->name);
87112 if (class->name_version > 1)
87113 diff --git a/kernel/locking/lockdep_proc.c b/kernel/locking/lockdep_proc.c
87114 index ef43ac4..2720dfa 100644
87115 --- a/kernel/locking/lockdep_proc.c
87116 +++ b/kernel/locking/lockdep_proc.c
87117 @@ -65,7 +65,7 @@ static int l_show(struct seq_file *m, void *v)
87118 return 0;
87119 }
87120
87121 - seq_printf(m, "%p", class->key);
87122 + seq_printf(m, "%pK", class->key);
87123 #ifdef CONFIG_DEBUG_LOCKDEP
87124 seq_printf(m, " OPS:%8ld", class->ops);
87125 #endif
87126 @@ -83,7 +83,7 @@ static int l_show(struct seq_file *m, void *v)
87127
87128 list_for_each_entry(entry, &class->locks_after, entry) {
87129 if (entry->distance == 1) {
87130 - seq_printf(m, " -> [%p] ", entry->class->key);
87131 + seq_printf(m, " -> [%pK] ", entry->class->key);
87132 print_name(m, entry->class);
87133 seq_puts(m, "\n");
87134 }
87135 @@ -152,7 +152,7 @@ static int lc_show(struct seq_file *m, void *v)
87136 if (!class->key)
87137 continue;
87138
87139 - seq_printf(m, "[%p] ", class->key);
87140 + seq_printf(m, "[%pK] ", class->key);
87141 print_name(m, class);
87142 seq_puts(m, "\n");
87143 }
87144 @@ -496,7 +496,7 @@ static void seq_stats(struct seq_file *m, struct lock_stat_data *data)
87145 if (!i)
87146 seq_line(m, '-', 40-namelen, namelen);
87147
87148 - snprintf(ip, sizeof(ip), "[<%p>]",
87149 + snprintf(ip, sizeof(ip), "[<%pK>]",
87150 (void *)class->contention_point[i]);
87151 seq_printf(m, "%40s %14lu %29s %pS\n",
87152 name, stats->contention_point[i],
87153 @@ -511,7 +511,7 @@ static void seq_stats(struct seq_file *m, struct lock_stat_data *data)
87154 if (!i)
87155 seq_line(m, '-', 40-namelen, namelen);
87156
87157 - snprintf(ip, sizeof(ip), "[<%p>]",
87158 + snprintf(ip, sizeof(ip), "[<%pK>]",
87159 (void *)class->contending_point[i]);
87160 seq_printf(m, "%40s %14lu %29s %pS\n",
87161 name, stats->contending_point[i],
87162 diff --git a/kernel/locking/mcs_spinlock.c b/kernel/locking/mcs_spinlock.c
87163 index 838dc9e..760e158 100644
87164 --- a/kernel/locking/mcs_spinlock.c
87165 +++ b/kernel/locking/mcs_spinlock.c
87166 @@ -71,7 +71,7 @@ bool osq_lock(struct optimistic_spin_queue **lock)
87167 if (likely(prev == NULL))
87168 return true;
87169
87170 - ACCESS_ONCE(prev->next) = node;
87171 + ACCESS_ONCE_RW(prev->next) = node;
87172
87173 /*
87174 * Normally @prev is untouchable after the above store; because at that
87175 @@ -143,8 +143,8 @@ unqueue:
87176 * it will wait in Step-A.
87177 */
87178
87179 - ACCESS_ONCE(next->prev) = prev;
87180 - ACCESS_ONCE(prev->next) = next;
87181 + ACCESS_ONCE_RW(next->prev) = prev;
87182 + ACCESS_ONCE_RW(prev->next) = next;
87183
87184 return false;
87185 }
87186 @@ -165,13 +165,13 @@ void osq_unlock(struct optimistic_spin_queue **lock)
87187 */
87188 next = xchg(&node->next, NULL);
87189 if (next) {
87190 - ACCESS_ONCE(next->locked) = 1;
87191 + ACCESS_ONCE_RW(next->locked) = 1;
87192 return;
87193 }
87194
87195 next = osq_wait_next(lock, node, NULL);
87196 if (next)
87197 - ACCESS_ONCE(next->locked) = 1;
87198 + ACCESS_ONCE_RW(next->locked) = 1;
87199 }
87200
87201 #endif
87202 diff --git a/kernel/locking/mcs_spinlock.h b/kernel/locking/mcs_spinlock.h
87203 index a2dbac4..e02a34a 100644
87204 --- a/kernel/locking/mcs_spinlock.h
87205 +++ b/kernel/locking/mcs_spinlock.h
87206 @@ -81,7 +81,7 @@ void mcs_spin_lock(struct mcs_spinlock **lock, struct mcs_spinlock *node)
87207 */
87208 return;
87209 }
87210 - ACCESS_ONCE(prev->next) = node;
87211 + ACCESS_ONCE_RW(prev->next) = node;
87212
87213 /* Wait until the lock holder passes the lock down. */
87214 arch_mcs_spin_lock_contended(&node->locked);
87215 diff --git a/kernel/locking/mutex-debug.c b/kernel/locking/mutex-debug.c
87216 index 5cf6731..ce3bc5a 100644
87217 --- a/kernel/locking/mutex-debug.c
87218 +++ b/kernel/locking/mutex-debug.c
87219 @@ -49,21 +49,21 @@ void debug_mutex_free_waiter(struct mutex_waiter *waiter)
87220 }
87221
87222 void debug_mutex_add_waiter(struct mutex *lock, struct mutex_waiter *waiter,
87223 - struct thread_info *ti)
87224 + struct task_struct *task)
87225 {
87226 SMP_DEBUG_LOCKS_WARN_ON(!spin_is_locked(&lock->wait_lock));
87227
87228 /* Mark the current thread as blocked on the lock: */
87229 - ti->task->blocked_on = waiter;
87230 + task->blocked_on = waiter;
87231 }
87232
87233 void mutex_remove_waiter(struct mutex *lock, struct mutex_waiter *waiter,
87234 - struct thread_info *ti)
87235 + struct task_struct *task)
87236 {
87237 DEBUG_LOCKS_WARN_ON(list_empty(&waiter->list));
87238 - DEBUG_LOCKS_WARN_ON(waiter->task != ti->task);
87239 - DEBUG_LOCKS_WARN_ON(ti->task->blocked_on != waiter);
87240 - ti->task->blocked_on = NULL;
87241 + DEBUG_LOCKS_WARN_ON(waiter->task != task);
87242 + DEBUG_LOCKS_WARN_ON(task->blocked_on != waiter);
87243 + task->blocked_on = NULL;
87244
87245 list_del_init(&waiter->list);
87246 waiter->task = NULL;
87247 diff --git a/kernel/locking/mutex-debug.h b/kernel/locking/mutex-debug.h
87248 index 0799fd3..d06ae3b 100644
87249 --- a/kernel/locking/mutex-debug.h
87250 +++ b/kernel/locking/mutex-debug.h
87251 @@ -20,9 +20,9 @@ extern void debug_mutex_wake_waiter(struct mutex *lock,
87252 extern void debug_mutex_free_waiter(struct mutex_waiter *waiter);
87253 extern void debug_mutex_add_waiter(struct mutex *lock,
87254 struct mutex_waiter *waiter,
87255 - struct thread_info *ti);
87256 + struct task_struct *task);
87257 extern void mutex_remove_waiter(struct mutex *lock, struct mutex_waiter *waiter,
87258 - struct thread_info *ti);
87259 + struct task_struct *task);
87260 extern void debug_mutex_unlock(struct mutex *lock);
87261 extern void debug_mutex_init(struct mutex *lock, const char *name,
87262 struct lock_class_key *key);
87263 diff --git a/kernel/locking/mutex.c b/kernel/locking/mutex.c
87264 index bc73d33..6f308aa 100644
87265 --- a/kernel/locking/mutex.c
87266 +++ b/kernel/locking/mutex.c
87267 @@ -490,7 +490,7 @@ slowpath:
87268 goto skip_wait;
87269
87270 debug_mutex_lock_common(lock, &waiter);
87271 - debug_mutex_add_waiter(lock, &waiter, task_thread_info(task));
87272 + debug_mutex_add_waiter(lock, &waiter, task);
87273
87274 /* add waiting tasks to the end of the waitqueue (FIFO): */
87275 list_add_tail(&waiter.list, &lock->wait_list);
87276 @@ -534,7 +534,7 @@ slowpath:
87277 schedule_preempt_disabled();
87278 spin_lock_mutex(&lock->wait_lock, flags);
87279 }
87280 - mutex_remove_waiter(lock, &waiter, current_thread_info());
87281 + mutex_remove_waiter(lock, &waiter, task);
87282 /* set it to 0 if there are no waiters left: */
87283 if (likely(list_empty(&lock->wait_list)))
87284 atomic_set(&lock->count, 0);
87285 @@ -571,7 +571,7 @@ skip_wait:
87286 return 0;
87287
87288 err:
87289 - mutex_remove_waiter(lock, &waiter, task_thread_info(task));
87290 + mutex_remove_waiter(lock, &waiter, task);
87291 spin_unlock_mutex(&lock->wait_lock, flags);
87292 debug_mutex_free_waiter(&waiter);
87293 mutex_release(&lock->dep_map, 1, ip);
87294 diff --git a/kernel/locking/rtmutex-tester.c b/kernel/locking/rtmutex-tester.c
87295 index 1d96dd0..994ff19 100644
87296 --- a/kernel/locking/rtmutex-tester.c
87297 +++ b/kernel/locking/rtmutex-tester.c
87298 @@ -22,7 +22,7 @@
87299 #define MAX_RT_TEST_MUTEXES 8
87300
87301 static spinlock_t rttest_lock;
87302 -static atomic_t rttest_event;
87303 +static atomic_unchecked_t rttest_event;
87304
87305 struct test_thread_data {
87306 int opcode;
87307 @@ -63,7 +63,7 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
87308
87309 case RTTEST_LOCKCONT:
87310 td->mutexes[td->opdata] = 1;
87311 - td->event = atomic_add_return(1, &rttest_event);
87312 + td->event = atomic_add_return_unchecked(1, &rttest_event);
87313 return 0;
87314
87315 case RTTEST_RESET:
87316 @@ -76,7 +76,7 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
87317 return 0;
87318
87319 case RTTEST_RESETEVENT:
87320 - atomic_set(&rttest_event, 0);
87321 + atomic_set_unchecked(&rttest_event, 0);
87322 return 0;
87323
87324 default:
87325 @@ -93,9 +93,9 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
87326 return ret;
87327
87328 td->mutexes[id] = 1;
87329 - td->event = atomic_add_return(1, &rttest_event);
87330 + td->event = atomic_add_return_unchecked(1, &rttest_event);
87331 rt_mutex_lock(&mutexes[id]);
87332 - td->event = atomic_add_return(1, &rttest_event);
87333 + td->event = atomic_add_return_unchecked(1, &rttest_event);
87334 td->mutexes[id] = 4;
87335 return 0;
87336
87337 @@ -106,9 +106,9 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
87338 return ret;
87339
87340 td->mutexes[id] = 1;
87341 - td->event = atomic_add_return(1, &rttest_event);
87342 + td->event = atomic_add_return_unchecked(1, &rttest_event);
87343 ret = rt_mutex_lock_interruptible(&mutexes[id], 0);
87344 - td->event = atomic_add_return(1, &rttest_event);
87345 + td->event = atomic_add_return_unchecked(1, &rttest_event);
87346 td->mutexes[id] = ret ? 0 : 4;
87347 return ret ? -EINTR : 0;
87348
87349 @@ -117,9 +117,9 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
87350 if (id < 0 || id >= MAX_RT_TEST_MUTEXES || td->mutexes[id] != 4)
87351 return ret;
87352
87353 - td->event = atomic_add_return(1, &rttest_event);
87354 + td->event = atomic_add_return_unchecked(1, &rttest_event);
87355 rt_mutex_unlock(&mutexes[id]);
87356 - td->event = atomic_add_return(1, &rttest_event);
87357 + td->event = atomic_add_return_unchecked(1, &rttest_event);
87358 td->mutexes[id] = 0;
87359 return 0;
87360
87361 @@ -166,7 +166,7 @@ void schedule_rt_mutex_test(struct rt_mutex *mutex)
87362 break;
87363
87364 td->mutexes[dat] = 2;
87365 - td->event = atomic_add_return(1, &rttest_event);
87366 + td->event = atomic_add_return_unchecked(1, &rttest_event);
87367 break;
87368
87369 default:
87370 @@ -186,7 +186,7 @@ void schedule_rt_mutex_test(struct rt_mutex *mutex)
87371 return;
87372
87373 td->mutexes[dat] = 3;
87374 - td->event = atomic_add_return(1, &rttest_event);
87375 + td->event = atomic_add_return_unchecked(1, &rttest_event);
87376 break;
87377
87378 case RTTEST_LOCKNOWAIT:
87379 @@ -198,7 +198,7 @@ void schedule_rt_mutex_test(struct rt_mutex *mutex)
87380 return;
87381
87382 td->mutexes[dat] = 1;
87383 - td->event = atomic_add_return(1, &rttest_event);
87384 + td->event = atomic_add_return_unchecked(1, &rttest_event);
87385 return;
87386
87387 default:
87388 diff --git a/kernel/module.c b/kernel/module.c
87389 index 079c461..741f79c 100644
87390 --- a/kernel/module.c
87391 +++ b/kernel/module.c
87392 @@ -61,6 +61,7 @@
87393 #include <linux/pfn.h>
87394 #include <linux/bsearch.h>
87395 #include <linux/fips.h>
87396 +#include <linux/grsecurity.h>
87397 #include <uapi/linux/module.h>
87398 #include "module-internal.h"
87399
87400 @@ -157,7 +158,8 @@ static BLOCKING_NOTIFIER_HEAD(module_notify_list);
87401
87402 /* Bounds of module allocation, for speeding __module_address.
87403 * Protected by module_mutex. */
87404 -static unsigned long module_addr_min = -1UL, module_addr_max = 0;
87405 +static unsigned long module_addr_min_rw = -1UL, module_addr_max_rw = 0;
87406 +static unsigned long module_addr_min_rx = -1UL, module_addr_max_rx = 0;
87407
87408 int register_module_notifier(struct notifier_block * nb)
87409 {
87410 @@ -324,7 +326,7 @@ bool each_symbol_section(bool (*fn)(const struct symsearch *arr,
87411 return true;
87412
87413 list_for_each_entry_rcu(mod, &modules, list) {
87414 - struct symsearch arr[] = {
87415 + struct symsearch modarr[] = {
87416 { mod->syms, mod->syms + mod->num_syms, mod->crcs,
87417 NOT_GPL_ONLY, false },
87418 { mod->gpl_syms, mod->gpl_syms + mod->num_gpl_syms,
87419 @@ -349,7 +351,7 @@ bool each_symbol_section(bool (*fn)(const struct symsearch *arr,
87420 if (mod->state == MODULE_STATE_UNFORMED)
87421 continue;
87422
87423 - if (each_symbol_in_section(arr, ARRAY_SIZE(arr), mod, fn, data))
87424 + if (each_symbol_in_section(modarr, ARRAY_SIZE(modarr), mod, fn, data))
87425 return true;
87426 }
87427 return false;
87428 @@ -489,7 +491,7 @@ static int percpu_modalloc(struct module *mod, struct load_info *info)
87429 if (!pcpusec->sh_size)
87430 return 0;
87431
87432 - if (align > PAGE_SIZE) {
87433 + if (align-1 >= PAGE_SIZE) {
87434 pr_warn("%s: per-cpu alignment %li > %li\n",
87435 mod->name, align, PAGE_SIZE);
87436 align = PAGE_SIZE;
87437 @@ -1061,7 +1063,7 @@ struct module_attribute module_uevent =
87438 static ssize_t show_coresize(struct module_attribute *mattr,
87439 struct module_kobject *mk, char *buffer)
87440 {
87441 - return sprintf(buffer, "%u\n", mk->mod->core_size);
87442 + return sprintf(buffer, "%u\n", mk->mod->core_size_rx + mk->mod->core_size_rw);
87443 }
87444
87445 static struct module_attribute modinfo_coresize =
87446 @@ -1070,7 +1072,7 @@ static struct module_attribute modinfo_coresize =
87447 static ssize_t show_initsize(struct module_attribute *mattr,
87448 struct module_kobject *mk, char *buffer)
87449 {
87450 - return sprintf(buffer, "%u\n", mk->mod->init_size);
87451 + return sprintf(buffer, "%u\n", mk->mod->init_size_rx + mk->mod->init_size_rw);
87452 }
87453
87454 static struct module_attribute modinfo_initsize =
87455 @@ -1162,12 +1164,29 @@ static int check_version(Elf_Shdr *sechdrs,
87456 goto bad_version;
87457 }
87458
87459 +#ifdef CONFIG_GRKERNSEC_RANDSTRUCT
87460 + /*
87461 + * avoid potentially printing jibberish on attempted load
87462 + * of a module randomized with a different seed
87463 + */
87464 + pr_warn("no symbol version for %s\n", symname);
87465 +#else
87466 pr_warn("%s: no symbol version for %s\n", mod->name, symname);
87467 +#endif
87468 return 0;
87469
87470 bad_version:
87471 +#ifdef CONFIG_GRKERNSEC_RANDSTRUCT
87472 + /*
87473 + * avoid potentially printing jibberish on attempted load
87474 + * of a module randomized with a different seed
87475 + */
87476 + printk("attempted module disagrees about version of symbol %s\n",
87477 + symname);
87478 +#else
87479 printk("%s: disagrees about version of symbol %s\n",
87480 mod->name, symname);
87481 +#endif
87482 return 0;
87483 }
87484
87485 @@ -1283,7 +1302,7 @@ resolve_symbol_wait(struct module *mod,
87486 */
87487 #ifdef CONFIG_SYSFS
87488
87489 -#ifdef CONFIG_KALLSYMS
87490 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
87491 static inline bool sect_empty(const Elf_Shdr *sect)
87492 {
87493 return !(sect->sh_flags & SHF_ALLOC) || sect->sh_size == 0;
87494 @@ -1423,7 +1442,7 @@ static void add_notes_attrs(struct module *mod, const struct load_info *info)
87495 {
87496 unsigned int notes, loaded, i;
87497 struct module_notes_attrs *notes_attrs;
87498 - struct bin_attribute *nattr;
87499 + bin_attribute_no_const *nattr;
87500
87501 /* failed to create section attributes, so can't create notes */
87502 if (!mod->sect_attrs)
87503 @@ -1535,7 +1554,7 @@ static void del_usage_links(struct module *mod)
87504 static int module_add_modinfo_attrs(struct module *mod)
87505 {
87506 struct module_attribute *attr;
87507 - struct module_attribute *temp_attr;
87508 + module_attribute_no_const *temp_attr;
87509 int error = 0;
87510 int i;
87511
87512 @@ -1756,21 +1775,21 @@ static void set_section_ro_nx(void *base,
87513
87514 static void unset_module_core_ro_nx(struct module *mod)
87515 {
87516 - set_page_attributes(mod->module_core + mod->core_text_size,
87517 - mod->module_core + mod->core_size,
87518 + set_page_attributes(mod->module_core_rw,
87519 + mod->module_core_rw + mod->core_size_rw,
87520 set_memory_x);
87521 - set_page_attributes(mod->module_core,
87522 - mod->module_core + mod->core_ro_size,
87523 + set_page_attributes(mod->module_core_rx,
87524 + mod->module_core_rx + mod->core_size_rx,
87525 set_memory_rw);
87526 }
87527
87528 static void unset_module_init_ro_nx(struct module *mod)
87529 {
87530 - set_page_attributes(mod->module_init + mod->init_text_size,
87531 - mod->module_init + mod->init_size,
87532 + set_page_attributes(mod->module_init_rw,
87533 + mod->module_init_rw + mod->init_size_rw,
87534 set_memory_x);
87535 - set_page_attributes(mod->module_init,
87536 - mod->module_init + mod->init_ro_size,
87537 + set_page_attributes(mod->module_init_rx,
87538 + mod->module_init_rx + mod->init_size_rx,
87539 set_memory_rw);
87540 }
87541
87542 @@ -1783,14 +1802,14 @@ void set_all_modules_text_rw(void)
87543 list_for_each_entry_rcu(mod, &modules, list) {
87544 if (mod->state == MODULE_STATE_UNFORMED)
87545 continue;
87546 - if ((mod->module_core) && (mod->core_text_size)) {
87547 - set_page_attributes(mod->module_core,
87548 - mod->module_core + mod->core_text_size,
87549 + if ((mod->module_core_rx) && (mod->core_size_rx)) {
87550 + set_page_attributes(mod->module_core_rx,
87551 + mod->module_core_rx + mod->core_size_rx,
87552 set_memory_rw);
87553 }
87554 - if ((mod->module_init) && (mod->init_text_size)) {
87555 - set_page_attributes(mod->module_init,
87556 - mod->module_init + mod->init_text_size,
87557 + if ((mod->module_init_rx) && (mod->init_size_rx)) {
87558 + set_page_attributes(mod->module_init_rx,
87559 + mod->module_init_rx + mod->init_size_rx,
87560 set_memory_rw);
87561 }
87562 }
87563 @@ -1806,14 +1825,14 @@ void set_all_modules_text_ro(void)
87564 list_for_each_entry_rcu(mod, &modules, list) {
87565 if (mod->state == MODULE_STATE_UNFORMED)
87566 continue;
87567 - if ((mod->module_core) && (mod->core_text_size)) {
87568 - set_page_attributes(mod->module_core,
87569 - mod->module_core + mod->core_text_size,
87570 + if ((mod->module_core_rx) && (mod->core_size_rx)) {
87571 + set_page_attributes(mod->module_core_rx,
87572 + mod->module_core_rx + mod->core_size_rx,
87573 set_memory_ro);
87574 }
87575 - if ((mod->module_init) && (mod->init_text_size)) {
87576 - set_page_attributes(mod->module_init,
87577 - mod->module_init + mod->init_text_size,
87578 + if ((mod->module_init_rx) && (mod->init_size_rx)) {
87579 + set_page_attributes(mod->module_init_rx,
87580 + mod->module_init_rx + mod->init_size_rx,
87581 set_memory_ro);
87582 }
87583 }
87584 @@ -1864,16 +1883,19 @@ static void free_module(struct module *mod)
87585
87586 /* This may be NULL, but that's OK */
87587 unset_module_init_ro_nx(mod);
87588 - module_free(mod, mod->module_init);
87589 + module_free(mod, mod->module_init_rw);
87590 + module_free_exec(mod, mod->module_init_rx);
87591 kfree(mod->args);
87592 percpu_modfree(mod);
87593
87594 /* Free lock-classes: */
87595 - lockdep_free_key_range(mod->module_core, mod->core_size);
87596 + lockdep_free_key_range(mod->module_core_rx, mod->core_size_rx);
87597 + lockdep_free_key_range(mod->module_core_rw, mod->core_size_rw);
87598
87599 /* Finally, free the core (containing the module structure) */
87600 unset_module_core_ro_nx(mod);
87601 - module_free(mod, mod->module_core);
87602 + module_free_exec(mod, mod->module_core_rx);
87603 + module_free(mod, mod->module_core_rw);
87604
87605 #ifdef CONFIG_MPU
87606 update_protections(current->mm);
87607 @@ -1942,9 +1964,31 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
87608 int ret = 0;
87609 const struct kernel_symbol *ksym;
87610
87611 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
87612 + int is_fs_load = 0;
87613 + int register_filesystem_found = 0;
87614 + char *p;
87615 +
87616 + p = strstr(mod->args, "grsec_modharden_fs");
87617 + if (p) {
87618 + char *endptr = p + sizeof("grsec_modharden_fs") - 1;
87619 + /* copy \0 as well */
87620 + memmove(p, endptr, strlen(mod->args) - (unsigned int)(endptr - mod->args) + 1);
87621 + is_fs_load = 1;
87622 + }
87623 +#endif
87624 +
87625 for (i = 1; i < symsec->sh_size / sizeof(Elf_Sym); i++) {
87626 const char *name = info->strtab + sym[i].st_name;
87627
87628 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
87629 + /* it's a real shame this will never get ripped and copied
87630 + upstream! ;(
87631 + */
87632 + if (is_fs_load && !strcmp(name, "register_filesystem"))
87633 + register_filesystem_found = 1;
87634 +#endif
87635 +
87636 switch (sym[i].st_shndx) {
87637 case SHN_COMMON:
87638 /* Ignore common symbols */
87639 @@ -1969,7 +2013,9 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
87640 ksym = resolve_symbol_wait(mod, info, name);
87641 /* Ok if resolved. */
87642 if (ksym && !IS_ERR(ksym)) {
87643 + pax_open_kernel();
87644 sym[i].st_value = ksym->value;
87645 + pax_close_kernel();
87646 break;
87647 }
87648
87649 @@ -1988,11 +2034,20 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
87650 secbase = (unsigned long)mod_percpu(mod);
87651 else
87652 secbase = info->sechdrs[sym[i].st_shndx].sh_addr;
87653 + pax_open_kernel();
87654 sym[i].st_value += secbase;
87655 + pax_close_kernel();
87656 break;
87657 }
87658 }
87659
87660 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
87661 + if (is_fs_load && !register_filesystem_found) {
87662 + printk(KERN_ALERT "grsec: Denied attempt to load non-fs module %.64s through mount\n", mod->name);
87663 + ret = -EPERM;
87664 + }
87665 +#endif
87666 +
87667 return ret;
87668 }
87669
87670 @@ -2076,22 +2131,12 @@ static void layout_sections(struct module *mod, struct load_info *info)
87671 || s->sh_entsize != ~0UL
87672 || strstarts(sname, ".init"))
87673 continue;
87674 - s->sh_entsize = get_offset(mod, &mod->core_size, s, i);
87675 + if ((s->sh_flags & SHF_WRITE) || !(s->sh_flags & SHF_ALLOC))
87676 + s->sh_entsize = get_offset(mod, &mod->core_size_rw, s, i);
87677 + else
87678 + s->sh_entsize = get_offset(mod, &mod->core_size_rx, s, i);
87679 pr_debug("\t%s\n", sname);
87680 }
87681 - switch (m) {
87682 - case 0: /* executable */
87683 - mod->core_size = debug_align(mod->core_size);
87684 - mod->core_text_size = mod->core_size;
87685 - break;
87686 - case 1: /* RO: text and ro-data */
87687 - mod->core_size = debug_align(mod->core_size);
87688 - mod->core_ro_size = mod->core_size;
87689 - break;
87690 - case 3: /* whole core */
87691 - mod->core_size = debug_align(mod->core_size);
87692 - break;
87693 - }
87694 }
87695
87696 pr_debug("Init section allocation order:\n");
87697 @@ -2105,23 +2150,13 @@ static void layout_sections(struct module *mod, struct load_info *info)
87698 || s->sh_entsize != ~0UL
87699 || !strstarts(sname, ".init"))
87700 continue;
87701 - s->sh_entsize = (get_offset(mod, &mod->init_size, s, i)
87702 - | INIT_OFFSET_MASK);
87703 + if ((s->sh_flags & SHF_WRITE) || !(s->sh_flags & SHF_ALLOC))
87704 + s->sh_entsize = get_offset(mod, &mod->init_size_rw, s, i);
87705 + else
87706 + s->sh_entsize = get_offset(mod, &mod->init_size_rx, s, i);
87707 + s->sh_entsize |= INIT_OFFSET_MASK;
87708 pr_debug("\t%s\n", sname);
87709 }
87710 - switch (m) {
87711 - case 0: /* executable */
87712 - mod->init_size = debug_align(mod->init_size);
87713 - mod->init_text_size = mod->init_size;
87714 - break;
87715 - case 1: /* RO: text and ro-data */
87716 - mod->init_size = debug_align(mod->init_size);
87717 - mod->init_ro_size = mod->init_size;
87718 - break;
87719 - case 3: /* whole init */
87720 - mod->init_size = debug_align(mod->init_size);
87721 - break;
87722 - }
87723 }
87724 }
87725
87726 @@ -2294,7 +2329,7 @@ static void layout_symtab(struct module *mod, struct load_info *info)
87727
87728 /* Put symbol section at end of init part of module. */
87729 symsect->sh_flags |= SHF_ALLOC;
87730 - symsect->sh_entsize = get_offset(mod, &mod->init_size, symsect,
87731 + symsect->sh_entsize = get_offset(mod, &mod->init_size_rx, symsect,
87732 info->index.sym) | INIT_OFFSET_MASK;
87733 pr_debug("\t%s\n", info->secstrings + symsect->sh_name);
87734
87735 @@ -2311,13 +2346,13 @@ static void layout_symtab(struct module *mod, struct load_info *info)
87736 }
87737
87738 /* Append room for core symbols at end of core part. */
87739 - info->symoffs = ALIGN(mod->core_size, symsect->sh_addralign ?: 1);
87740 - info->stroffs = mod->core_size = info->symoffs + ndst * sizeof(Elf_Sym);
87741 - mod->core_size += strtab_size;
87742 + info->symoffs = ALIGN(mod->core_size_rx, symsect->sh_addralign ?: 1);
87743 + info->stroffs = mod->core_size_rx = info->symoffs + ndst * sizeof(Elf_Sym);
87744 + mod->core_size_rx += strtab_size;
87745
87746 /* Put string table section at end of init part of module. */
87747 strsect->sh_flags |= SHF_ALLOC;
87748 - strsect->sh_entsize = get_offset(mod, &mod->init_size, strsect,
87749 + strsect->sh_entsize = get_offset(mod, &mod->init_size_rx, strsect,
87750 info->index.str) | INIT_OFFSET_MASK;
87751 pr_debug("\t%s\n", info->secstrings + strsect->sh_name);
87752 }
87753 @@ -2335,12 +2370,14 @@ static void add_kallsyms(struct module *mod, const struct load_info *info)
87754 /* Make sure we get permanent strtab: don't use info->strtab. */
87755 mod->strtab = (void *)info->sechdrs[info->index.str].sh_addr;
87756
87757 + pax_open_kernel();
87758 +
87759 /* Set types up while we still have access to sections. */
87760 for (i = 0; i < mod->num_symtab; i++)
87761 mod->symtab[i].st_info = elf_type(&mod->symtab[i], info);
87762
87763 - mod->core_symtab = dst = mod->module_core + info->symoffs;
87764 - mod->core_strtab = s = mod->module_core + info->stroffs;
87765 + mod->core_symtab = dst = mod->module_core_rx + info->symoffs;
87766 + mod->core_strtab = s = mod->module_core_rx + info->stroffs;
87767 src = mod->symtab;
87768 for (ndst = i = 0; i < mod->num_symtab; i++) {
87769 if (i == 0 ||
87770 @@ -2352,6 +2389,8 @@ static void add_kallsyms(struct module *mod, const struct load_info *info)
87771 }
87772 }
87773 mod->core_num_syms = ndst;
87774 +
87775 + pax_close_kernel();
87776 }
87777 #else
87778 static inline void layout_symtab(struct module *mod, struct load_info *info)
87779 @@ -2385,17 +2424,33 @@ void * __weak module_alloc(unsigned long size)
87780 return vmalloc_exec(size);
87781 }
87782
87783 -static void *module_alloc_update_bounds(unsigned long size)
87784 +static void *module_alloc_update_bounds_rw(unsigned long size)
87785 {
87786 void *ret = module_alloc(size);
87787
87788 if (ret) {
87789 mutex_lock(&module_mutex);
87790 /* Update module bounds. */
87791 - if ((unsigned long)ret < module_addr_min)
87792 - module_addr_min = (unsigned long)ret;
87793 - if ((unsigned long)ret + size > module_addr_max)
87794 - module_addr_max = (unsigned long)ret + size;
87795 + if ((unsigned long)ret < module_addr_min_rw)
87796 + module_addr_min_rw = (unsigned long)ret;
87797 + if ((unsigned long)ret + size > module_addr_max_rw)
87798 + module_addr_max_rw = (unsigned long)ret + size;
87799 + mutex_unlock(&module_mutex);
87800 + }
87801 + return ret;
87802 +}
87803 +
87804 +static void *module_alloc_update_bounds_rx(unsigned long size)
87805 +{
87806 + void *ret = module_alloc_exec(size);
87807 +
87808 + if (ret) {
87809 + mutex_lock(&module_mutex);
87810 + /* Update module bounds. */
87811 + if ((unsigned long)ret < module_addr_min_rx)
87812 + module_addr_min_rx = (unsigned long)ret;
87813 + if ((unsigned long)ret + size > module_addr_max_rx)
87814 + module_addr_max_rx = (unsigned long)ret + size;
87815 mutex_unlock(&module_mutex);
87816 }
87817 return ret;
87818 @@ -2652,7 +2707,15 @@ static struct module *setup_load_info(struct load_info *info, int flags)
87819 mod = (void *)info->sechdrs[info->index.mod].sh_addr;
87820
87821 if (info->index.sym == 0) {
87822 +#ifdef CONFIG_GRKERNSEC_RANDSTRUCT
87823 + /*
87824 + * avoid potentially printing jibberish on attempted load
87825 + * of a module randomized with a different seed
87826 + */
87827 + pr_warn("module has no symbols (stripped?)\n");
87828 +#else
87829 pr_warn("%s: module has no symbols (stripped?)\n", mod->name);
87830 +#endif
87831 return ERR_PTR(-ENOEXEC);
87832 }
87833
87834 @@ -2668,8 +2731,14 @@ static struct module *setup_load_info(struct load_info *info, int flags)
87835 static int check_modinfo(struct module *mod, struct load_info *info, int flags)
87836 {
87837 const char *modmagic = get_modinfo(info, "vermagic");
87838 + const char *license = get_modinfo(info, "license");
87839 int err;
87840
87841 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR
87842 + if (!license || !license_is_gpl_compatible(license))
87843 + return -ENOEXEC;
87844 +#endif
87845 +
87846 if (flags & MODULE_INIT_IGNORE_VERMAGIC)
87847 modmagic = NULL;
87848
87849 @@ -2694,7 +2763,7 @@ static int check_modinfo(struct module *mod, struct load_info *info, int flags)
87850 }
87851
87852 /* Set up license info based on the info section */
87853 - set_license(mod, get_modinfo(info, "license"));
87854 + set_license(mod, license);
87855
87856 return 0;
87857 }
87858 @@ -2788,7 +2857,7 @@ static int move_module(struct module *mod, struct load_info *info)
87859 void *ptr;
87860
87861 /* Do the allocs. */
87862 - ptr = module_alloc_update_bounds(mod->core_size);
87863 + ptr = module_alloc_update_bounds_rw(mod->core_size_rw);
87864 /*
87865 * The pointer to this block is stored in the module structure
87866 * which is inside the block. Just mark it as not being a
87867 @@ -2798,11 +2867,11 @@ static int move_module(struct module *mod, struct load_info *info)
87868 if (!ptr)
87869 return -ENOMEM;
87870
87871 - memset(ptr, 0, mod->core_size);
87872 - mod->module_core = ptr;
87873 + memset(ptr, 0, mod->core_size_rw);
87874 + mod->module_core_rw = ptr;
87875
87876 - if (mod->init_size) {
87877 - ptr = module_alloc_update_bounds(mod->init_size);
87878 + if (mod->init_size_rw) {
87879 + ptr = module_alloc_update_bounds_rw(mod->init_size_rw);
87880 /*
87881 * The pointer to this block is stored in the module structure
87882 * which is inside the block. This block doesn't need to be
87883 @@ -2811,13 +2880,45 @@ static int move_module(struct module *mod, struct load_info *info)
87884 */
87885 kmemleak_ignore(ptr);
87886 if (!ptr) {
87887 - module_free(mod, mod->module_core);
87888 + module_free(mod, mod->module_core_rw);
87889 return -ENOMEM;
87890 }
87891 - memset(ptr, 0, mod->init_size);
87892 - mod->module_init = ptr;
87893 + memset(ptr, 0, mod->init_size_rw);
87894 + mod->module_init_rw = ptr;
87895 } else
87896 - mod->module_init = NULL;
87897 + mod->module_init_rw = NULL;
87898 +
87899 + ptr = module_alloc_update_bounds_rx(mod->core_size_rx);
87900 + kmemleak_not_leak(ptr);
87901 + if (!ptr) {
87902 + if (mod->module_init_rw)
87903 + module_free(mod, mod->module_init_rw);
87904 + module_free(mod, mod->module_core_rw);
87905 + return -ENOMEM;
87906 + }
87907 +
87908 + pax_open_kernel();
87909 + memset(ptr, 0, mod->core_size_rx);
87910 + pax_close_kernel();
87911 + mod->module_core_rx = ptr;
87912 +
87913 + if (mod->init_size_rx) {
87914 + ptr = module_alloc_update_bounds_rx(mod->init_size_rx);
87915 + kmemleak_ignore(ptr);
87916 + if (!ptr && mod->init_size_rx) {
87917 + module_free_exec(mod, mod->module_core_rx);
87918 + if (mod->module_init_rw)
87919 + module_free(mod, mod->module_init_rw);
87920 + module_free(mod, mod->module_core_rw);
87921 + return -ENOMEM;
87922 + }
87923 +
87924 + pax_open_kernel();
87925 + memset(ptr, 0, mod->init_size_rx);
87926 + pax_close_kernel();
87927 + mod->module_init_rx = ptr;
87928 + } else
87929 + mod->module_init_rx = NULL;
87930
87931 /* Transfer each section which specifies SHF_ALLOC */
87932 pr_debug("final section addresses:\n");
87933 @@ -2828,16 +2929,45 @@ static int move_module(struct module *mod, struct load_info *info)
87934 if (!(shdr->sh_flags & SHF_ALLOC))
87935 continue;
87936
87937 - if (shdr->sh_entsize & INIT_OFFSET_MASK)
87938 - dest = mod->module_init
87939 - + (shdr->sh_entsize & ~INIT_OFFSET_MASK);
87940 - else
87941 - dest = mod->module_core + shdr->sh_entsize;
87942 + if (shdr->sh_entsize & INIT_OFFSET_MASK) {
87943 + if ((shdr->sh_flags & SHF_WRITE) || !(shdr->sh_flags & SHF_ALLOC))
87944 + dest = mod->module_init_rw
87945 + + (shdr->sh_entsize & ~INIT_OFFSET_MASK);
87946 + else
87947 + dest = mod->module_init_rx
87948 + + (shdr->sh_entsize & ~INIT_OFFSET_MASK);
87949 + } else {
87950 + if ((shdr->sh_flags & SHF_WRITE) || !(shdr->sh_flags & SHF_ALLOC))
87951 + dest = mod->module_core_rw + shdr->sh_entsize;
87952 + else
87953 + dest = mod->module_core_rx + shdr->sh_entsize;
87954 + }
87955 +
87956 + if (shdr->sh_type != SHT_NOBITS) {
87957 +
87958 +#ifdef CONFIG_PAX_KERNEXEC
87959 +#ifdef CONFIG_X86_64
87960 + if ((shdr->sh_flags & SHF_WRITE) && (shdr->sh_flags & SHF_EXECINSTR))
87961 + set_memory_x((unsigned long)dest, (shdr->sh_size + PAGE_SIZE) >> PAGE_SHIFT);
87962 +#endif
87963 + if (!(shdr->sh_flags & SHF_WRITE) && (shdr->sh_flags & SHF_ALLOC)) {
87964 + pax_open_kernel();
87965 + memcpy(dest, (void *)shdr->sh_addr, shdr->sh_size);
87966 + pax_close_kernel();
87967 + } else
87968 +#endif
87969
87970 - if (shdr->sh_type != SHT_NOBITS)
87971 memcpy(dest, (void *)shdr->sh_addr, shdr->sh_size);
87972 + }
87973 /* Update sh_addr to point to copy in image. */
87974 - shdr->sh_addr = (unsigned long)dest;
87975 +
87976 +#ifdef CONFIG_PAX_KERNEXEC
87977 + if (shdr->sh_flags & SHF_EXECINSTR)
87978 + shdr->sh_addr = ktva_ktla((unsigned long)dest);
87979 + else
87980 +#endif
87981 +
87982 + shdr->sh_addr = (unsigned long)dest;
87983 pr_debug("\t0x%lx %s\n",
87984 (long)shdr->sh_addr, info->secstrings + shdr->sh_name);
87985 }
87986 @@ -2894,12 +3024,12 @@ static void flush_module_icache(const struct module *mod)
87987 * Do it before processing of module parameters, so the module
87988 * can provide parameter accessor functions of its own.
87989 */
87990 - if (mod->module_init)
87991 - flush_icache_range((unsigned long)mod->module_init,
87992 - (unsigned long)mod->module_init
87993 - + mod->init_size);
87994 - flush_icache_range((unsigned long)mod->module_core,
87995 - (unsigned long)mod->module_core + mod->core_size);
87996 + if (mod->module_init_rx)
87997 + flush_icache_range((unsigned long)mod->module_init_rx,
87998 + (unsigned long)mod->module_init_rx
87999 + + mod->init_size_rx);
88000 + flush_icache_range((unsigned long)mod->module_core_rx,
88001 + (unsigned long)mod->module_core_rx + mod->core_size_rx);
88002
88003 set_fs(old_fs);
88004 }
88005 @@ -2956,8 +3086,10 @@ static struct module *layout_and_allocate(struct load_info *info, int flags)
88006 static void module_deallocate(struct module *mod, struct load_info *info)
88007 {
88008 percpu_modfree(mod);
88009 - module_free(mod, mod->module_init);
88010 - module_free(mod, mod->module_core);
88011 + module_free_exec(mod, mod->module_init_rx);
88012 + module_free_exec(mod, mod->module_core_rx);
88013 + module_free(mod, mod->module_init_rw);
88014 + module_free(mod, mod->module_core_rw);
88015 }
88016
88017 int __weak module_finalize(const Elf_Ehdr *hdr,
88018 @@ -2970,7 +3102,9 @@ int __weak module_finalize(const Elf_Ehdr *hdr,
88019 static int post_relocation(struct module *mod, const struct load_info *info)
88020 {
88021 /* Sort exception table now relocations are done. */
88022 + pax_open_kernel();
88023 sort_extable(mod->extable, mod->extable + mod->num_exentries);
88024 + pax_close_kernel();
88025
88026 /* Copy relocated percpu area over. */
88027 percpu_modcopy(mod, (void *)info->sechdrs[info->index.pcpu].sh_addr,
88028 @@ -3024,16 +3158,16 @@ static int do_init_module(struct module *mod)
88029 MODULE_STATE_COMING, mod);
88030
88031 /* Set RO and NX regions for core */
88032 - set_section_ro_nx(mod->module_core,
88033 - mod->core_text_size,
88034 - mod->core_ro_size,
88035 - mod->core_size);
88036 + set_section_ro_nx(mod->module_core_rx,
88037 + mod->core_size_rx,
88038 + mod->core_size_rx,
88039 + mod->core_size_rx);
88040
88041 /* Set RO and NX regions for init */
88042 - set_section_ro_nx(mod->module_init,
88043 - mod->init_text_size,
88044 - mod->init_ro_size,
88045 - mod->init_size);
88046 + set_section_ro_nx(mod->module_init_rx,
88047 + mod->init_size_rx,
88048 + mod->init_size_rx,
88049 + mod->init_size_rx);
88050
88051 do_mod_ctors(mod);
88052 /* Start the module */
88053 @@ -3094,11 +3228,12 @@ static int do_init_module(struct module *mod)
88054 mod->strtab = mod->core_strtab;
88055 #endif
88056 unset_module_init_ro_nx(mod);
88057 - module_free(mod, mod->module_init);
88058 - mod->module_init = NULL;
88059 - mod->init_size = 0;
88060 - mod->init_ro_size = 0;
88061 - mod->init_text_size = 0;
88062 + module_free(mod, mod->module_init_rw);
88063 + module_free_exec(mod, mod->module_init_rx);
88064 + mod->module_init_rw = NULL;
88065 + mod->module_init_rx = NULL;
88066 + mod->init_size_rw = 0;
88067 + mod->init_size_rx = 0;
88068 mutex_unlock(&module_mutex);
88069 wake_up_all(&module_wq);
88070
88071 @@ -3241,9 +3376,38 @@ static int load_module(struct load_info *info, const char __user *uargs,
88072 if (err)
88073 goto free_unload;
88074
88075 + /* Now copy in args */
88076 + mod->args = strndup_user(uargs, ~0UL >> 1);
88077 + if (IS_ERR(mod->args)) {
88078 + err = PTR_ERR(mod->args);
88079 + goto free_unload;
88080 + }
88081 +
88082 /* Set up MODINFO_ATTR fields */
88083 setup_modinfo(mod, info);
88084
88085 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
88086 + {
88087 + char *p, *p2;
88088 +
88089 + if (strstr(mod->args, "grsec_modharden_netdev")) {
88090 + 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);
88091 + err = -EPERM;
88092 + goto free_modinfo;
88093 + } else if ((p = strstr(mod->args, "grsec_modharden_normal"))) {
88094 + p += sizeof("grsec_modharden_normal") - 1;
88095 + p2 = strstr(p, "_");
88096 + if (p2) {
88097 + *p2 = '\0';
88098 + printk(KERN_ALERT "grsec: denied kernel module auto-load of %.64s by uid %.9s\n", mod->name, p);
88099 + *p2 = '_';
88100 + }
88101 + err = -EPERM;
88102 + goto free_modinfo;
88103 + }
88104 + }
88105 +#endif
88106 +
88107 /* Fix up syms, so that st_value is a pointer to location. */
88108 err = simplify_symbols(mod, info);
88109 if (err < 0)
88110 @@ -3259,13 +3423,6 @@ static int load_module(struct load_info *info, const char __user *uargs,
88111
88112 flush_module_icache(mod);
88113
88114 - /* Now copy in args */
88115 - mod->args = strndup_user(uargs, ~0UL >> 1);
88116 - if (IS_ERR(mod->args)) {
88117 - err = PTR_ERR(mod->args);
88118 - goto free_arch_cleanup;
88119 - }
88120 -
88121 dynamic_debug_setup(info->debug, info->num_debug);
88122
88123 /* Ftrace init must be called in the MODULE_STATE_UNFORMED state */
88124 @@ -3303,11 +3460,10 @@ static int load_module(struct load_info *info, const char __user *uargs,
88125 ddebug_cleanup:
88126 dynamic_debug_remove(info->debug);
88127 synchronize_sched();
88128 - kfree(mod->args);
88129 - free_arch_cleanup:
88130 module_arch_cleanup(mod);
88131 free_modinfo:
88132 free_modinfo(mod);
88133 + kfree(mod->args);
88134 free_unload:
88135 module_unload_free(mod);
88136 unlink_mod:
88137 @@ -3390,10 +3546,16 @@ static const char *get_ksymbol(struct module *mod,
88138 unsigned long nextval;
88139
88140 /* At worse, next value is at end of module */
88141 - if (within_module_init(addr, mod))
88142 - nextval = (unsigned long)mod->module_init+mod->init_text_size;
88143 + if (within_module_init_rx(addr, mod))
88144 + nextval = (unsigned long)mod->module_init_rx+mod->init_size_rx;
88145 + else if (within_module_init_rw(addr, mod))
88146 + nextval = (unsigned long)mod->module_init_rw+mod->init_size_rw;
88147 + else if (within_module_core_rx(addr, mod))
88148 + nextval = (unsigned long)mod->module_core_rx+mod->core_size_rx;
88149 + else if (within_module_core_rw(addr, mod))
88150 + nextval = (unsigned long)mod->module_core_rw+mod->core_size_rw;
88151 else
88152 - nextval = (unsigned long)mod->module_core+mod->core_text_size;
88153 + return NULL;
88154
88155 /* Scan for closest preceding symbol, and next symbol. (ELF
88156 starts real symbols at 1). */
88157 @@ -3644,7 +3806,7 @@ static int m_show(struct seq_file *m, void *p)
88158 return 0;
88159
88160 seq_printf(m, "%s %u",
88161 - mod->name, mod->init_size + mod->core_size);
88162 + mod->name, mod->init_size_rx + mod->init_size_rw + mod->core_size_rx + mod->core_size_rw);
88163 print_unload_info(m, mod);
88164
88165 /* Informative for users. */
88166 @@ -3653,7 +3815,7 @@ static int m_show(struct seq_file *m, void *p)
88167 mod->state == MODULE_STATE_COMING ? "Loading":
88168 "Live");
88169 /* Used by oprofile and other similar tools. */
88170 - seq_printf(m, " 0x%pK", mod->module_core);
88171 + seq_printf(m, " 0x%pK 0x%pK", mod->module_core_rx, mod->module_core_rw);
88172
88173 /* Taints info */
88174 if (mod->taints)
88175 @@ -3689,7 +3851,17 @@ static const struct file_operations proc_modules_operations = {
88176
88177 static int __init proc_modules_init(void)
88178 {
88179 +#ifndef CONFIG_GRKERNSEC_HIDESYM
88180 +#ifdef CONFIG_GRKERNSEC_PROC_USER
88181 + proc_create("modules", S_IRUSR, NULL, &proc_modules_operations);
88182 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
88183 + proc_create("modules", S_IRUSR | S_IRGRP, NULL, &proc_modules_operations);
88184 +#else
88185 proc_create("modules", 0, NULL, &proc_modules_operations);
88186 +#endif
88187 +#else
88188 + proc_create("modules", S_IRUSR, NULL, &proc_modules_operations);
88189 +#endif
88190 return 0;
88191 }
88192 module_init(proc_modules_init);
88193 @@ -3750,14 +3922,14 @@ struct module *__module_address(unsigned long addr)
88194 {
88195 struct module *mod;
88196
88197 - if (addr < module_addr_min || addr > module_addr_max)
88198 + if ((addr < module_addr_min_rx || addr > module_addr_max_rx) &&
88199 + (addr < module_addr_min_rw || addr > module_addr_max_rw))
88200 return NULL;
88201
88202 list_for_each_entry_rcu(mod, &modules, list) {
88203 if (mod->state == MODULE_STATE_UNFORMED)
88204 continue;
88205 - if (within_module_core(addr, mod)
88206 - || within_module_init(addr, mod))
88207 + if (within_module_init(addr, mod) || within_module_core(addr, mod))
88208 return mod;
88209 }
88210 return NULL;
88211 @@ -3792,11 +3964,20 @@ bool is_module_text_address(unsigned long addr)
88212 */
88213 struct module *__module_text_address(unsigned long addr)
88214 {
88215 - struct module *mod = __module_address(addr);
88216 + struct module *mod;
88217 +
88218 +#ifdef CONFIG_X86_32
88219 + addr = ktla_ktva(addr);
88220 +#endif
88221 +
88222 + if (addr < module_addr_min_rx || addr > module_addr_max_rx)
88223 + return NULL;
88224 +
88225 + mod = __module_address(addr);
88226 +
88227 if (mod) {
88228 /* Make sure it's within the text section. */
88229 - if (!within(addr, mod->module_init, mod->init_text_size)
88230 - && !within(addr, mod->module_core, mod->core_text_size))
88231 + if (!within_module_init_rx(addr, mod) && !within_module_core_rx(addr, mod))
88232 mod = NULL;
88233 }
88234 return mod;
88235 diff --git a/kernel/notifier.c b/kernel/notifier.c
88236 index db4c8b0..ad011c5 100644
88237 --- a/kernel/notifier.c
88238 +++ b/kernel/notifier.c
88239 @@ -5,6 +5,7 @@
88240 #include <linux/rcupdate.h>
88241 #include <linux/vmalloc.h>
88242 #include <linux/reboot.h>
88243 +#include <linux/mm.h>
88244
88245 /*
88246 * Notifier list for kernel code which wants to be called
88247 @@ -24,10 +25,12 @@ static int notifier_chain_register(struct notifier_block **nl,
88248 while ((*nl) != NULL) {
88249 if (n->priority > (*nl)->priority)
88250 break;
88251 - nl = &((*nl)->next);
88252 + nl = (struct notifier_block **)&((*nl)->next);
88253 }
88254 - n->next = *nl;
88255 + pax_open_kernel();
88256 + *(const void **)&n->next = *nl;
88257 rcu_assign_pointer(*nl, n);
88258 + pax_close_kernel();
88259 return 0;
88260 }
88261
88262 @@ -39,10 +42,12 @@ static int notifier_chain_cond_register(struct notifier_block **nl,
88263 return 0;
88264 if (n->priority > (*nl)->priority)
88265 break;
88266 - nl = &((*nl)->next);
88267 + nl = (struct notifier_block **)&((*nl)->next);
88268 }
88269 - n->next = *nl;
88270 + pax_open_kernel();
88271 + *(const void **)&n->next = *nl;
88272 rcu_assign_pointer(*nl, n);
88273 + pax_close_kernel();
88274 return 0;
88275 }
88276
88277 @@ -51,10 +56,12 @@ static int notifier_chain_unregister(struct notifier_block **nl,
88278 {
88279 while ((*nl) != NULL) {
88280 if ((*nl) == n) {
88281 + pax_open_kernel();
88282 rcu_assign_pointer(*nl, n->next);
88283 + pax_close_kernel();
88284 return 0;
88285 }
88286 - nl = &((*nl)->next);
88287 + nl = (struct notifier_block **)&((*nl)->next);
88288 }
88289 return -ENOENT;
88290 }
88291 diff --git a/kernel/padata.c b/kernel/padata.c
88292 index 161402f..598814c 100644
88293 --- a/kernel/padata.c
88294 +++ b/kernel/padata.c
88295 @@ -54,7 +54,7 @@ static int padata_cpu_hash(struct parallel_data *pd)
88296 * seq_nr mod. number of cpus in use.
88297 */
88298
88299 - seq_nr = atomic_inc_return(&pd->seq_nr);
88300 + seq_nr = atomic_inc_return_unchecked(&pd->seq_nr);
88301 cpu_index = seq_nr % cpumask_weight(pd->cpumask.pcpu);
88302
88303 return padata_index_to_cpu(pd, cpu_index);
88304 @@ -428,7 +428,7 @@ static struct parallel_data *padata_alloc_pd(struct padata_instance *pinst,
88305 padata_init_pqueues(pd);
88306 padata_init_squeues(pd);
88307 setup_timer(&pd->timer, padata_reorder_timer, (unsigned long)pd);
88308 - atomic_set(&pd->seq_nr, -1);
88309 + atomic_set_unchecked(&pd->seq_nr, -1);
88310 atomic_set(&pd->reorder_objects, 0);
88311 atomic_set(&pd->refcnt, 0);
88312 pd->pinst = pinst;
88313 diff --git a/kernel/panic.c b/kernel/panic.c
88314 index d02fa9f..9faec0a 100644
88315 --- a/kernel/panic.c
88316 +++ b/kernel/panic.c
88317 @@ -52,7 +52,7 @@ EXPORT_SYMBOL(panic_blink);
88318 /*
88319 * Stop ourself in panic -- architecture code may override this
88320 */
88321 -void __weak panic_smp_self_stop(void)
88322 +void __weak __noreturn panic_smp_self_stop(void)
88323 {
88324 while (1)
88325 cpu_relax();
88326 @@ -408,7 +408,7 @@ static void warn_slowpath_common(const char *file, int line, void *caller,
88327 disable_trace_on_warning();
88328
88329 pr_warn("------------[ cut here ]------------\n");
88330 - pr_warn("WARNING: CPU: %d PID: %d at %s:%d %pS()\n",
88331 + pr_warn("WARNING: CPU: %d PID: %d at %s:%d %pA()\n",
88332 raw_smp_processor_id(), current->pid, file, line, caller);
88333
88334 if (args)
88335 @@ -462,7 +462,8 @@ EXPORT_SYMBOL(warn_slowpath_null);
88336 */
88337 __visible void __stack_chk_fail(void)
88338 {
88339 - panic("stack-protector: Kernel stack is corrupted in: %p\n",
88340 + dump_stack();
88341 + panic("stack-protector: Kernel stack is corrupted in: %pA\n",
88342 __builtin_return_address(0));
88343 }
88344 EXPORT_SYMBOL(__stack_chk_fail);
88345 diff --git a/kernel/pid.c b/kernel/pid.c
88346 index 9b9a266..c20ef80 100644
88347 --- a/kernel/pid.c
88348 +++ b/kernel/pid.c
88349 @@ -33,6 +33,7 @@
88350 #include <linux/rculist.h>
88351 #include <linux/bootmem.h>
88352 #include <linux/hash.h>
88353 +#include <linux/security.h>
88354 #include <linux/pid_namespace.h>
88355 #include <linux/init_task.h>
88356 #include <linux/syscalls.h>
88357 @@ -47,7 +48,7 @@ struct pid init_struct_pid = INIT_STRUCT_PID;
88358
88359 int pid_max = PID_MAX_DEFAULT;
88360
88361 -#define RESERVED_PIDS 300
88362 +#define RESERVED_PIDS 500
88363
88364 int pid_max_min = RESERVED_PIDS + 1;
88365 int pid_max_max = PID_MAX_LIMIT;
88366 @@ -445,10 +446,18 @@ EXPORT_SYMBOL(pid_task);
88367 */
88368 struct task_struct *find_task_by_pid_ns(pid_t nr, struct pid_namespace *ns)
88369 {
88370 + struct task_struct *task;
88371 +
88372 rcu_lockdep_assert(rcu_read_lock_held(),
88373 "find_task_by_pid_ns() needs rcu_read_lock()"
88374 " protection");
88375 - return pid_task(find_pid_ns(nr, ns), PIDTYPE_PID);
88376 +
88377 + task = pid_task(find_pid_ns(nr, ns), PIDTYPE_PID);
88378 +
88379 + if (gr_pid_is_chrooted(task))
88380 + return NULL;
88381 +
88382 + return task;
88383 }
88384
88385 struct task_struct *find_task_by_vpid(pid_t vnr)
88386 @@ -456,6 +465,14 @@ struct task_struct *find_task_by_vpid(pid_t vnr)
88387 return find_task_by_pid_ns(vnr, task_active_pid_ns(current));
88388 }
88389
88390 +struct task_struct *find_task_by_vpid_unrestricted(pid_t vnr)
88391 +{
88392 + rcu_lockdep_assert(rcu_read_lock_held(),
88393 + "find_task_by_pid_ns() needs rcu_read_lock()"
88394 + " protection");
88395 + return pid_task(find_pid_ns(vnr, task_active_pid_ns(current)), PIDTYPE_PID);
88396 +}
88397 +
88398 struct pid *get_task_pid(struct task_struct *task, enum pid_type type)
88399 {
88400 struct pid *pid;
88401 diff --git a/kernel/pid_namespace.c b/kernel/pid_namespace.c
88402 index db95d8e..a0ca23f 100644
88403 --- a/kernel/pid_namespace.c
88404 +++ b/kernel/pid_namespace.c
88405 @@ -253,7 +253,7 @@ static int pid_ns_ctl_handler(struct ctl_table *table, int write,
88406 void __user *buffer, size_t *lenp, loff_t *ppos)
88407 {
88408 struct pid_namespace *pid_ns = task_active_pid_ns(current);
88409 - struct ctl_table tmp = *table;
88410 + ctl_table_no_const tmp = *table;
88411
88412 if (write && !ns_capable(pid_ns->user_ns, CAP_SYS_ADMIN))
88413 return -EPERM;
88414 diff --git a/kernel/posix-cpu-timers.c b/kernel/posix-cpu-timers.c
88415 index 3b89464..5e38379 100644
88416 --- a/kernel/posix-cpu-timers.c
88417 +++ b/kernel/posix-cpu-timers.c
88418 @@ -1464,14 +1464,14 @@ struct k_clock clock_posix_cpu = {
88419
88420 static __init int init_posix_cpu_timers(void)
88421 {
88422 - struct k_clock process = {
88423 + static struct k_clock process = {
88424 .clock_getres = process_cpu_clock_getres,
88425 .clock_get = process_cpu_clock_get,
88426 .timer_create = process_cpu_timer_create,
88427 .nsleep = process_cpu_nsleep,
88428 .nsleep_restart = process_cpu_nsleep_restart,
88429 };
88430 - struct k_clock thread = {
88431 + static struct k_clock thread = {
88432 .clock_getres = thread_cpu_clock_getres,
88433 .clock_get = thread_cpu_clock_get,
88434 .timer_create = thread_cpu_timer_create,
88435 diff --git a/kernel/posix-timers.c b/kernel/posix-timers.c
88436 index 424c2d4..679242f 100644
88437 --- a/kernel/posix-timers.c
88438 +++ b/kernel/posix-timers.c
88439 @@ -43,6 +43,7 @@
88440 #include <linux/hash.h>
88441 #include <linux/posix-clock.h>
88442 #include <linux/posix-timers.h>
88443 +#include <linux/grsecurity.h>
88444 #include <linux/syscalls.h>
88445 #include <linux/wait.h>
88446 #include <linux/workqueue.h>
88447 @@ -122,7 +123,7 @@ static DEFINE_SPINLOCK(hash_lock);
88448 * which we beg off on and pass to do_sys_settimeofday().
88449 */
88450
88451 -static struct k_clock posix_clocks[MAX_CLOCKS];
88452 +static struct k_clock *posix_clocks[MAX_CLOCKS];
88453
88454 /*
88455 * These ones are defined below.
88456 @@ -275,7 +276,7 @@ static int posix_get_tai(clockid_t which_clock, struct timespec *tp)
88457 */
88458 static __init int init_posix_timers(void)
88459 {
88460 - struct k_clock clock_realtime = {
88461 + static struct k_clock clock_realtime = {
88462 .clock_getres = hrtimer_get_res,
88463 .clock_get = posix_clock_realtime_get,
88464 .clock_set = posix_clock_realtime_set,
88465 @@ -287,7 +288,7 @@ static __init int init_posix_timers(void)
88466 .timer_get = common_timer_get,
88467 .timer_del = common_timer_del,
88468 };
88469 - struct k_clock clock_monotonic = {
88470 + static struct k_clock clock_monotonic = {
88471 .clock_getres = hrtimer_get_res,
88472 .clock_get = posix_ktime_get_ts,
88473 .nsleep = common_nsleep,
88474 @@ -297,19 +298,19 @@ static __init int init_posix_timers(void)
88475 .timer_get = common_timer_get,
88476 .timer_del = common_timer_del,
88477 };
88478 - struct k_clock clock_monotonic_raw = {
88479 + static struct k_clock clock_monotonic_raw = {
88480 .clock_getres = hrtimer_get_res,
88481 .clock_get = posix_get_monotonic_raw,
88482 };
88483 - struct k_clock clock_realtime_coarse = {
88484 + static struct k_clock clock_realtime_coarse = {
88485 .clock_getres = posix_get_coarse_res,
88486 .clock_get = posix_get_realtime_coarse,
88487 };
88488 - struct k_clock clock_monotonic_coarse = {
88489 + static struct k_clock clock_monotonic_coarse = {
88490 .clock_getres = posix_get_coarse_res,
88491 .clock_get = posix_get_monotonic_coarse,
88492 };
88493 - struct k_clock clock_tai = {
88494 + static struct k_clock clock_tai = {
88495 .clock_getres = hrtimer_get_res,
88496 .clock_get = posix_get_tai,
88497 .nsleep = common_nsleep,
88498 @@ -319,7 +320,7 @@ static __init int init_posix_timers(void)
88499 .timer_get = common_timer_get,
88500 .timer_del = common_timer_del,
88501 };
88502 - struct k_clock clock_boottime = {
88503 + static struct k_clock clock_boottime = {
88504 .clock_getres = hrtimer_get_res,
88505 .clock_get = posix_get_boottime,
88506 .nsleep = common_nsleep,
88507 @@ -531,7 +532,7 @@ void posix_timers_register_clock(const clockid_t clock_id,
88508 return;
88509 }
88510
88511 - posix_clocks[clock_id] = *new_clock;
88512 + posix_clocks[clock_id] = new_clock;
88513 }
88514 EXPORT_SYMBOL_GPL(posix_timers_register_clock);
88515
88516 @@ -577,9 +578,9 @@ static struct k_clock *clockid_to_kclock(const clockid_t id)
88517 return (id & CLOCKFD_MASK) == CLOCKFD ?
88518 &clock_posix_dynamic : &clock_posix_cpu;
88519
88520 - if (id >= MAX_CLOCKS || !posix_clocks[id].clock_getres)
88521 + if (id >= MAX_CLOCKS || !posix_clocks[id] || !posix_clocks[id]->clock_getres)
88522 return NULL;
88523 - return &posix_clocks[id];
88524 + return posix_clocks[id];
88525 }
88526
88527 static int common_timer_create(struct k_itimer *new_timer)
88528 @@ -597,7 +598,7 @@ SYSCALL_DEFINE3(timer_create, const clockid_t, which_clock,
88529 struct k_clock *kc = clockid_to_kclock(which_clock);
88530 struct k_itimer *new_timer;
88531 int error, new_timer_id;
88532 - sigevent_t event;
88533 + sigevent_t event = { };
88534 int it_id_set = IT_ID_NOT_SET;
88535
88536 if (!kc)
88537 @@ -1011,6 +1012,13 @@ SYSCALL_DEFINE2(clock_settime, const clockid_t, which_clock,
88538 if (copy_from_user(&new_tp, tp, sizeof (*tp)))
88539 return -EFAULT;
88540
88541 + /* only the CLOCK_REALTIME clock can be set, all other clocks
88542 + have their clock_set fptr set to a nosettime dummy function
88543 + CLOCK_REALTIME has a NULL clock_set fptr which causes it to
88544 + call common_clock_set, which calls do_sys_settimeofday, which
88545 + we hook
88546 + */
88547 +
88548 return kc->clock_set(which_clock, &new_tp);
88549 }
88550
88551 diff --git a/kernel/power/Kconfig b/kernel/power/Kconfig
88552 index 2fac9cc..56fef29 100644
88553 --- a/kernel/power/Kconfig
88554 +++ b/kernel/power/Kconfig
88555 @@ -24,6 +24,8 @@ config HIBERNATE_CALLBACKS
88556 config HIBERNATION
88557 bool "Hibernation (aka 'suspend to disk')"
88558 depends on SWAP && ARCH_HIBERNATION_POSSIBLE
88559 + depends on !GRKERNSEC_KMEM
88560 + depends on !PAX_MEMORY_SANITIZE
88561 select HIBERNATE_CALLBACKS
88562 select LZO_COMPRESS
88563 select LZO_DECOMPRESS
88564 diff --git a/kernel/power/process.c b/kernel/power/process.c
88565 index 06ec886..9dba35e 100644
88566 --- a/kernel/power/process.c
88567 +++ b/kernel/power/process.c
88568 @@ -34,6 +34,7 @@ static int try_to_freeze_tasks(bool user_only)
88569 unsigned int elapsed_msecs;
88570 bool wakeup = false;
88571 int sleep_usecs = USEC_PER_MSEC;
88572 + bool timedout = false;
88573
88574 do_gettimeofday(&start);
88575
88576 @@ -44,13 +45,20 @@ static int try_to_freeze_tasks(bool user_only)
88577
88578 while (true) {
88579 todo = 0;
88580 + if (time_after(jiffies, end_time))
88581 + timedout = true;
88582 read_lock(&tasklist_lock);
88583 do_each_thread(g, p) {
88584 if (p == current || !freeze_task(p))
88585 continue;
88586
88587 - if (!freezer_should_skip(p))
88588 + if (!freezer_should_skip(p)) {
88589 todo++;
88590 + if (timedout) {
88591 + printk(KERN_ERR "Task refusing to freeze:\n");
88592 + sched_show_task(p);
88593 + }
88594 + }
88595 } while_each_thread(g, p);
88596 read_unlock(&tasklist_lock);
88597
88598 @@ -59,7 +67,7 @@ static int try_to_freeze_tasks(bool user_only)
88599 todo += wq_busy;
88600 }
88601
88602 - if (!todo || time_after(jiffies, end_time))
88603 + if (!todo || timedout)
88604 break;
88605
88606 if (pm_wakeup_pending()) {
88607 diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
88608 index 7228258..e8ae7c9 100644
88609 --- a/kernel/printk/printk.c
88610 +++ b/kernel/printk/printk.c
88611 @@ -385,6 +385,11 @@ static int check_syslog_permissions(int type, bool from_file)
88612 if (from_file && type != SYSLOG_ACTION_OPEN)
88613 return 0;
88614
88615 +#ifdef CONFIG_GRKERNSEC_DMESG
88616 + if (grsec_enable_dmesg && !capable(CAP_SYSLOG) && !capable_nolog(CAP_SYS_ADMIN))
88617 + return -EPERM;
88618 +#endif
88619 +
88620 if (syslog_action_restricted(type)) {
88621 if (capable(CAP_SYSLOG))
88622 return 0;
88623 diff --git a/kernel/profile.c b/kernel/profile.c
88624 index cb980f0..ccd8782 100644
88625 --- a/kernel/profile.c
88626 +++ b/kernel/profile.c
88627 @@ -37,7 +37,7 @@ struct profile_hit {
88628 #define NR_PROFILE_HIT (PAGE_SIZE/sizeof(struct profile_hit))
88629 #define NR_PROFILE_GRP (NR_PROFILE_HIT/PROFILE_GRPSZ)
88630
88631 -static atomic_t *prof_buffer;
88632 +static atomic_unchecked_t *prof_buffer;
88633 static unsigned long prof_len, prof_shift;
88634
88635 int prof_on __read_mostly;
88636 @@ -260,7 +260,7 @@ static void profile_flip_buffers(void)
88637 hits[i].pc = 0;
88638 continue;
88639 }
88640 - atomic_add(hits[i].hits, &prof_buffer[hits[i].pc]);
88641 + atomic_add_unchecked(hits[i].hits, &prof_buffer[hits[i].pc]);
88642 hits[i].hits = hits[i].pc = 0;
88643 }
88644 }
88645 @@ -321,9 +321,9 @@ static void do_profile_hits(int type, void *__pc, unsigned int nr_hits)
88646 * Add the current hit(s) and flush the write-queue out
88647 * to the global buffer:
88648 */
88649 - atomic_add(nr_hits, &prof_buffer[pc]);
88650 + atomic_add_unchecked(nr_hits, &prof_buffer[pc]);
88651 for (i = 0; i < NR_PROFILE_HIT; ++i) {
88652 - atomic_add(hits[i].hits, &prof_buffer[hits[i].pc]);
88653 + atomic_add_unchecked(hits[i].hits, &prof_buffer[hits[i].pc]);
88654 hits[i].pc = hits[i].hits = 0;
88655 }
88656 out:
88657 @@ -398,7 +398,7 @@ static void do_profile_hits(int type, void *__pc, unsigned int nr_hits)
88658 {
88659 unsigned long pc;
88660 pc = ((unsigned long)__pc - (unsigned long)_stext) >> prof_shift;
88661 - atomic_add(nr_hits, &prof_buffer[min(pc, prof_len - 1)]);
88662 + atomic_add_unchecked(nr_hits, &prof_buffer[min(pc, prof_len - 1)]);
88663 }
88664 #endif /* !CONFIG_SMP */
88665
88666 @@ -494,7 +494,7 @@ read_profile(struct file *file, char __user *buf, size_t count, loff_t *ppos)
88667 return -EFAULT;
88668 buf++; p++; count--; read++;
88669 }
88670 - pnt = (char *)prof_buffer + p - sizeof(atomic_t);
88671 + pnt = (char *)prof_buffer + p - sizeof(atomic_unchecked_t);
88672 if (copy_to_user(buf, (void *)pnt, count))
88673 return -EFAULT;
88674 read += count;
88675 @@ -525,7 +525,7 @@ static ssize_t write_profile(struct file *file, const char __user *buf,
88676 }
88677 #endif
88678 profile_discard_flip_buffers();
88679 - memset(prof_buffer, 0, prof_len * sizeof(atomic_t));
88680 + memset(prof_buffer, 0, prof_len * sizeof(atomic_unchecked_t));
88681 return count;
88682 }
88683
88684 diff --git a/kernel/ptrace.c b/kernel/ptrace.c
88685 index adf9862..9d86345 100644
88686 --- a/kernel/ptrace.c
88687 +++ b/kernel/ptrace.c
88688 @@ -327,7 +327,7 @@ static int ptrace_attach(struct task_struct *task, long request,
88689 if (seize)
88690 flags |= PT_SEIZED;
88691 rcu_read_lock();
88692 - if (ns_capable(__task_cred(task)->user_ns, CAP_SYS_PTRACE))
88693 + if (ns_capable_nolog(__task_cred(task)->user_ns, CAP_SYS_PTRACE))
88694 flags |= PT_PTRACE_CAP;
88695 rcu_read_unlock();
88696 task->ptrace = flags;
88697 @@ -538,7 +538,7 @@ int ptrace_readdata(struct task_struct *tsk, unsigned long src, char __user *dst
88698 break;
88699 return -EIO;
88700 }
88701 - if (copy_to_user(dst, buf, retval))
88702 + if (retval > sizeof(buf) || copy_to_user(dst, buf, retval))
88703 return -EFAULT;
88704 copied += retval;
88705 src += retval;
88706 @@ -806,7 +806,7 @@ int ptrace_request(struct task_struct *child, long request,
88707 bool seized = child->ptrace & PT_SEIZED;
88708 int ret = -EIO;
88709 siginfo_t siginfo, *si;
88710 - void __user *datavp = (void __user *) data;
88711 + void __user *datavp = (__force void __user *) data;
88712 unsigned long __user *datalp = datavp;
88713 unsigned long flags;
88714
88715 @@ -1052,14 +1052,21 @@ SYSCALL_DEFINE4(ptrace, long, request, long, pid, unsigned long, addr,
88716 goto out;
88717 }
88718
88719 + if (gr_handle_ptrace(child, request)) {
88720 + ret = -EPERM;
88721 + goto out_put_task_struct;
88722 + }
88723 +
88724 if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) {
88725 ret = ptrace_attach(child, request, addr, data);
88726 /*
88727 * Some architectures need to do book-keeping after
88728 * a ptrace attach.
88729 */
88730 - if (!ret)
88731 + if (!ret) {
88732 arch_ptrace_attach(child);
88733 + gr_audit_ptrace(child);
88734 + }
88735 goto out_put_task_struct;
88736 }
88737
88738 @@ -1087,7 +1094,7 @@ int generic_ptrace_peekdata(struct task_struct *tsk, unsigned long addr,
88739 copied = access_process_vm(tsk, addr, &tmp, sizeof(tmp), 0);
88740 if (copied != sizeof(tmp))
88741 return -EIO;
88742 - return put_user(tmp, (unsigned long __user *)data);
88743 + return put_user(tmp, (__force unsigned long __user *)data);
88744 }
88745
88746 int generic_ptrace_pokedata(struct task_struct *tsk, unsigned long addr,
88747 @@ -1181,7 +1188,7 @@ int compat_ptrace_request(struct task_struct *child, compat_long_t request,
88748 }
88749
88750 COMPAT_SYSCALL_DEFINE4(ptrace, compat_long_t, request, compat_long_t, pid,
88751 - compat_long_t, addr, compat_long_t, data)
88752 + compat_ulong_t, addr, compat_ulong_t, data)
88753 {
88754 struct task_struct *child;
88755 long ret;
88756 @@ -1197,14 +1204,21 @@ COMPAT_SYSCALL_DEFINE4(ptrace, compat_long_t, request, compat_long_t, pid,
88757 goto out;
88758 }
88759
88760 + if (gr_handle_ptrace(child, request)) {
88761 + ret = -EPERM;
88762 + goto out_put_task_struct;
88763 + }
88764 +
88765 if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) {
88766 ret = ptrace_attach(child, request, addr, data);
88767 /*
88768 * Some architectures need to do book-keeping after
88769 * a ptrace attach.
88770 */
88771 - if (!ret)
88772 + if (!ret) {
88773 arch_ptrace_attach(child);
88774 + gr_audit_ptrace(child);
88775 + }
88776 goto out_put_task_struct;
88777 }
88778
88779 diff --git a/kernel/rcu/rcutorture.c b/kernel/rcu/rcutorture.c
88780 index bd30bc6..dce23da 100644
88781 --- a/kernel/rcu/rcutorture.c
88782 +++ b/kernel/rcu/rcutorture.c
88783 @@ -122,12 +122,12 @@ static DEFINE_PER_CPU(long [RCU_TORTURE_PIPE_LEN + 1],
88784 rcu_torture_count) = { 0 };
88785 static DEFINE_PER_CPU(long [RCU_TORTURE_PIPE_LEN + 1],
88786 rcu_torture_batch) = { 0 };
88787 -static atomic_t rcu_torture_wcount[RCU_TORTURE_PIPE_LEN + 1];
88788 -static atomic_t n_rcu_torture_alloc;
88789 -static atomic_t n_rcu_torture_alloc_fail;
88790 -static atomic_t n_rcu_torture_free;
88791 -static atomic_t n_rcu_torture_mberror;
88792 -static atomic_t n_rcu_torture_error;
88793 +static atomic_unchecked_t rcu_torture_wcount[RCU_TORTURE_PIPE_LEN + 1];
88794 +static atomic_unchecked_t n_rcu_torture_alloc;
88795 +static atomic_unchecked_t n_rcu_torture_alloc_fail;
88796 +static atomic_unchecked_t n_rcu_torture_free;
88797 +static atomic_unchecked_t n_rcu_torture_mberror;
88798 +static atomic_unchecked_t n_rcu_torture_error;
88799 static long n_rcu_torture_barrier_error;
88800 static long n_rcu_torture_boost_ktrerror;
88801 static long n_rcu_torture_boost_rterror;
88802 @@ -186,11 +186,11 @@ rcu_torture_alloc(void)
88803
88804 spin_lock_bh(&rcu_torture_lock);
88805 if (list_empty(&rcu_torture_freelist)) {
88806 - atomic_inc(&n_rcu_torture_alloc_fail);
88807 + atomic_inc_unchecked(&n_rcu_torture_alloc_fail);
88808 spin_unlock_bh(&rcu_torture_lock);
88809 return NULL;
88810 }
88811 - atomic_inc(&n_rcu_torture_alloc);
88812 + atomic_inc_unchecked(&n_rcu_torture_alloc);
88813 p = rcu_torture_freelist.next;
88814 list_del_init(p);
88815 spin_unlock_bh(&rcu_torture_lock);
88816 @@ -203,7 +203,7 @@ rcu_torture_alloc(void)
88817 static void
88818 rcu_torture_free(struct rcu_torture *p)
88819 {
88820 - atomic_inc(&n_rcu_torture_free);
88821 + atomic_inc_unchecked(&n_rcu_torture_free);
88822 spin_lock_bh(&rcu_torture_lock);
88823 list_add_tail(&p->rtort_free, &rcu_torture_freelist);
88824 spin_unlock_bh(&rcu_torture_lock);
88825 @@ -287,7 +287,7 @@ rcu_torture_cb(struct rcu_head *p)
88826 i = rp->rtort_pipe_count;
88827 if (i > RCU_TORTURE_PIPE_LEN)
88828 i = RCU_TORTURE_PIPE_LEN;
88829 - atomic_inc(&rcu_torture_wcount[i]);
88830 + atomic_inc_unchecked(&rcu_torture_wcount[i]);
88831 if (++rp->rtort_pipe_count >= RCU_TORTURE_PIPE_LEN) {
88832 rp->rtort_mbtest = 0;
88833 rcu_torture_free(rp);
88834 @@ -714,7 +714,7 @@ rcu_torture_writer(void *arg)
88835 i = old_rp->rtort_pipe_count;
88836 if (i > RCU_TORTURE_PIPE_LEN)
88837 i = RCU_TORTURE_PIPE_LEN;
88838 - atomic_inc(&rcu_torture_wcount[i]);
88839 + atomic_inc_unchecked(&rcu_torture_wcount[i]);
88840 old_rp->rtort_pipe_count++;
88841 if (gp_normal == gp_exp)
88842 exp = !!(torture_random(&rand) & 0x80);
88843 @@ -732,7 +732,7 @@ rcu_torture_writer(void *arg)
88844 i = rp->rtort_pipe_count;
88845 if (i > RCU_TORTURE_PIPE_LEN)
88846 i = RCU_TORTURE_PIPE_LEN;
88847 - atomic_inc(&rcu_torture_wcount[i]);
88848 + atomic_inc_unchecked(&rcu_torture_wcount[i]);
88849 if (++rp->rtort_pipe_count >=
88850 RCU_TORTURE_PIPE_LEN) {
88851 rp->rtort_mbtest = 0;
88852 @@ -825,7 +825,7 @@ static void rcu_torture_timer(unsigned long unused)
88853 return;
88854 }
88855 if (p->rtort_mbtest == 0)
88856 - atomic_inc(&n_rcu_torture_mberror);
88857 + atomic_inc_unchecked(&n_rcu_torture_mberror);
88858 spin_lock(&rand_lock);
88859 cur_ops->read_delay(&rand);
88860 n_rcu_torture_timers++;
88861 @@ -895,7 +895,7 @@ rcu_torture_reader(void *arg)
88862 continue;
88863 }
88864 if (p->rtort_mbtest == 0)
88865 - atomic_inc(&n_rcu_torture_mberror);
88866 + atomic_inc_unchecked(&n_rcu_torture_mberror);
88867 cur_ops->read_delay(&rand);
88868 preempt_disable();
88869 pipe_count = p->rtort_pipe_count;
88870 @@ -950,15 +950,15 @@ rcu_torture_printk(char *page)
88871 }
88872 page += sprintf(page, "%s%s ", torture_type, TORTURE_FLAG);
88873 page += sprintf(page,
88874 - "rtc: %p ver: %lu tfle: %d rta: %d rtaf: %d rtf: %d ",
88875 + "rtc: %pP ver: %lu tfle: %d rta: %d rtaf: %d rtf: %d ",
88876 rcu_torture_current,
88877 rcu_torture_current_version,
88878 list_empty(&rcu_torture_freelist),
88879 - atomic_read(&n_rcu_torture_alloc),
88880 - atomic_read(&n_rcu_torture_alloc_fail),
88881 - atomic_read(&n_rcu_torture_free));
88882 + atomic_read_unchecked(&n_rcu_torture_alloc),
88883 + atomic_read_unchecked(&n_rcu_torture_alloc_fail),
88884 + atomic_read_unchecked(&n_rcu_torture_free));
88885 page += sprintf(page, "rtmbe: %d rtbke: %ld rtbre: %ld ",
88886 - atomic_read(&n_rcu_torture_mberror),
88887 + atomic_read_unchecked(&n_rcu_torture_mberror),
88888 n_rcu_torture_boost_ktrerror,
88889 n_rcu_torture_boost_rterror);
88890 page += sprintf(page, "rtbf: %ld rtb: %ld nt: %ld ",
88891 @@ -971,14 +971,14 @@ rcu_torture_printk(char *page)
88892 n_barrier_attempts,
88893 n_rcu_torture_barrier_error);
88894 page += sprintf(page, "\n%s%s ", torture_type, TORTURE_FLAG);
88895 - if (atomic_read(&n_rcu_torture_mberror) != 0 ||
88896 + if (atomic_read_unchecked(&n_rcu_torture_mberror) != 0 ||
88897 n_rcu_torture_barrier_error != 0 ||
88898 n_rcu_torture_boost_ktrerror != 0 ||
88899 n_rcu_torture_boost_rterror != 0 ||
88900 n_rcu_torture_boost_failure != 0 ||
88901 i > 1) {
88902 page += sprintf(page, "!!! ");
88903 - atomic_inc(&n_rcu_torture_error);
88904 + atomic_inc_unchecked(&n_rcu_torture_error);
88905 WARN_ON_ONCE(1);
88906 }
88907 page += sprintf(page, "Reader Pipe: ");
88908 @@ -992,7 +992,7 @@ rcu_torture_printk(char *page)
88909 page += sprintf(page, "Free-Block Circulation: ");
88910 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++) {
88911 page += sprintf(page, " %d",
88912 - atomic_read(&rcu_torture_wcount[i]));
88913 + atomic_read_unchecked(&rcu_torture_wcount[i]));
88914 }
88915 page += sprintf(page, "\n");
88916 if (cur_ops->stats)
88917 @@ -1341,7 +1341,7 @@ rcu_torture_cleanup(void)
88918
88919 rcu_torture_stats_print(); /* -After- the stats thread is stopped! */
88920
88921 - if (atomic_read(&n_rcu_torture_error) || n_rcu_torture_barrier_error)
88922 + if (atomic_read_unchecked(&n_rcu_torture_error) || n_rcu_torture_barrier_error)
88923 rcu_torture_print_module_parms(cur_ops, "End of test: FAILURE");
88924 else if (torture_onoff_failures())
88925 rcu_torture_print_module_parms(cur_ops,
88926 @@ -1460,18 +1460,18 @@ rcu_torture_init(void)
88927
88928 rcu_torture_current = NULL;
88929 rcu_torture_current_version = 0;
88930 - atomic_set(&n_rcu_torture_alloc, 0);
88931 - atomic_set(&n_rcu_torture_alloc_fail, 0);
88932 - atomic_set(&n_rcu_torture_free, 0);
88933 - atomic_set(&n_rcu_torture_mberror, 0);
88934 - atomic_set(&n_rcu_torture_error, 0);
88935 + atomic_set_unchecked(&n_rcu_torture_alloc, 0);
88936 + atomic_set_unchecked(&n_rcu_torture_alloc_fail, 0);
88937 + atomic_set_unchecked(&n_rcu_torture_free, 0);
88938 + atomic_set_unchecked(&n_rcu_torture_mberror, 0);
88939 + atomic_set_unchecked(&n_rcu_torture_error, 0);
88940 n_rcu_torture_barrier_error = 0;
88941 n_rcu_torture_boost_ktrerror = 0;
88942 n_rcu_torture_boost_rterror = 0;
88943 n_rcu_torture_boost_failure = 0;
88944 n_rcu_torture_boosts = 0;
88945 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++)
88946 - atomic_set(&rcu_torture_wcount[i], 0);
88947 + atomic_set_unchecked(&rcu_torture_wcount[i], 0);
88948 for_each_possible_cpu(cpu) {
88949 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++) {
88950 per_cpu(rcu_torture_count, cpu)[i] = 0;
88951 diff --git a/kernel/rcu/srcu.c b/kernel/rcu/srcu.c
88952 index c639556..cf0a0d5 100644
88953 --- a/kernel/rcu/srcu.c
88954 +++ b/kernel/rcu/srcu.c
88955 @@ -298,9 +298,9 @@ int __srcu_read_lock(struct srcu_struct *sp)
88956
88957 idx = ACCESS_ONCE(sp->completed) & 0x1;
88958 preempt_disable();
88959 - ACCESS_ONCE(this_cpu_ptr(sp->per_cpu_ref)->c[idx]) += 1;
88960 + ACCESS_ONCE_RW(this_cpu_ptr(sp->per_cpu_ref)->c[idx]) += 1;
88961 smp_mb(); /* B */ /* Avoid leaking the critical section. */
88962 - ACCESS_ONCE(this_cpu_ptr(sp->per_cpu_ref)->seq[idx]) += 1;
88963 + ACCESS_ONCE_RW(this_cpu_ptr(sp->per_cpu_ref)->seq[idx]) += 1;
88964 preempt_enable();
88965 return idx;
88966 }
88967 diff --git a/kernel/rcu/tiny.c b/kernel/rcu/tiny.c
88968 index d9efcc1..ea543e9 100644
88969 --- a/kernel/rcu/tiny.c
88970 +++ b/kernel/rcu/tiny.c
88971 @@ -42,7 +42,7 @@
88972 /* Forward declarations for tiny_plugin.h. */
88973 struct rcu_ctrlblk;
88974 static void __rcu_process_callbacks(struct rcu_ctrlblk *rcp);
88975 -static void rcu_process_callbacks(struct softirq_action *unused);
88976 +static void rcu_process_callbacks(void);
88977 static void __call_rcu(struct rcu_head *head,
88978 void (*func)(struct rcu_head *rcu),
88979 struct rcu_ctrlblk *rcp);
88980 @@ -308,7 +308,7 @@ static void __rcu_process_callbacks(struct rcu_ctrlblk *rcp)
88981 false));
88982 }
88983
88984 -static void rcu_process_callbacks(struct softirq_action *unused)
88985 +static __latent_entropy void rcu_process_callbacks(void)
88986 {
88987 __rcu_process_callbacks(&rcu_sched_ctrlblk);
88988 __rcu_process_callbacks(&rcu_bh_ctrlblk);
88989 diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c
88990 index 0c47e30..a084591 100644
88991 --- a/kernel/rcu/tree.c
88992 +++ b/kernel/rcu/tree.c
88993 @@ -388,9 +388,9 @@ static void rcu_eqs_enter_common(struct rcu_dynticks *rdtp, long long oldval,
88994 rcu_prepare_for_idle(smp_processor_id());
88995 /* CPUs seeing atomic_inc() must see prior RCU read-side crit sects */
88996 smp_mb__before_atomic_inc(); /* See above. */
88997 - atomic_inc(&rdtp->dynticks);
88998 + atomic_inc_unchecked(&rdtp->dynticks);
88999 smp_mb__after_atomic_inc(); /* Force ordering with next sojourn. */
89000 - WARN_ON_ONCE(atomic_read(&rdtp->dynticks) & 0x1);
89001 + WARN_ON_ONCE(atomic_read_unchecked(&rdtp->dynticks) & 0x1);
89002
89003 /*
89004 * It is illegal to enter an extended quiescent state while
89005 @@ -508,10 +508,10 @@ static void rcu_eqs_exit_common(struct rcu_dynticks *rdtp, long long oldval,
89006 int user)
89007 {
89008 smp_mb__before_atomic_inc(); /* Force ordering w/previous sojourn. */
89009 - atomic_inc(&rdtp->dynticks);
89010 + atomic_inc_unchecked(&rdtp->dynticks);
89011 /* CPUs seeing atomic_inc() must see later RCU read-side crit sects */
89012 smp_mb__after_atomic_inc(); /* See above. */
89013 - WARN_ON_ONCE(!(atomic_read(&rdtp->dynticks) & 0x1));
89014 + WARN_ON_ONCE(!(atomic_read_unchecked(&rdtp->dynticks) & 0x1));
89015 rcu_cleanup_after_idle(smp_processor_id());
89016 trace_rcu_dyntick(TPS("End"), oldval, rdtp->dynticks_nesting);
89017 if (!user && !is_idle_task(current)) {
89018 @@ -632,14 +632,14 @@ void rcu_nmi_enter(void)
89019 struct rcu_dynticks *rdtp = this_cpu_ptr(&rcu_dynticks);
89020
89021 if (rdtp->dynticks_nmi_nesting == 0 &&
89022 - (atomic_read(&rdtp->dynticks) & 0x1))
89023 + (atomic_read_unchecked(&rdtp->dynticks) & 0x1))
89024 return;
89025 rdtp->dynticks_nmi_nesting++;
89026 smp_mb__before_atomic_inc(); /* Force delay from prior write. */
89027 - atomic_inc(&rdtp->dynticks);
89028 + atomic_inc_unchecked(&rdtp->dynticks);
89029 /* CPUs seeing atomic_inc() must see later RCU read-side crit sects */
89030 smp_mb__after_atomic_inc(); /* See above. */
89031 - WARN_ON_ONCE(!(atomic_read(&rdtp->dynticks) & 0x1));
89032 + WARN_ON_ONCE(!(atomic_read_unchecked(&rdtp->dynticks) & 0x1));
89033 }
89034
89035 /**
89036 @@ -658,9 +658,9 @@ void rcu_nmi_exit(void)
89037 return;
89038 /* CPUs seeing atomic_inc() must see prior RCU read-side crit sects */
89039 smp_mb__before_atomic_inc(); /* See above. */
89040 - atomic_inc(&rdtp->dynticks);
89041 + atomic_inc_unchecked(&rdtp->dynticks);
89042 smp_mb__after_atomic_inc(); /* Force delay to next write. */
89043 - WARN_ON_ONCE(atomic_read(&rdtp->dynticks) & 0x1);
89044 + WARN_ON_ONCE(atomic_read_unchecked(&rdtp->dynticks) & 0x1);
89045 }
89046
89047 /**
89048 @@ -673,7 +673,7 @@ void rcu_nmi_exit(void)
89049 */
89050 bool notrace __rcu_is_watching(void)
89051 {
89052 - return atomic_read(this_cpu_ptr(&rcu_dynticks.dynticks)) & 0x1;
89053 + return atomic_read_unchecked(this_cpu_ptr(&rcu_dynticks.dynticks)) & 0x1;
89054 }
89055
89056 /**
89057 @@ -756,7 +756,7 @@ static int rcu_is_cpu_rrupt_from_idle(void)
89058 static int dyntick_save_progress_counter(struct rcu_data *rdp,
89059 bool *isidle, unsigned long *maxj)
89060 {
89061 - rdp->dynticks_snap = atomic_add_return(0, &rdp->dynticks->dynticks);
89062 + rdp->dynticks_snap = atomic_add_return_unchecked(0, &rdp->dynticks->dynticks);
89063 rcu_sysidle_check_cpu(rdp, isidle, maxj);
89064 return (rdp->dynticks_snap & 0x1) == 0;
89065 }
89066 @@ -779,7 +779,7 @@ static int rcu_implicit_dynticks_qs(struct rcu_data *rdp,
89067 unsigned int curr;
89068 unsigned int snap;
89069
89070 - curr = (unsigned int)atomic_add_return(0, &rdp->dynticks->dynticks);
89071 + curr = (unsigned int)atomic_add_return_unchecked(0, &rdp->dynticks->dynticks);
89072 snap = (unsigned int)rdp->dynticks_snap;
89073
89074 /*
89075 @@ -1449,9 +1449,9 @@ static int rcu_gp_init(struct rcu_state *rsp)
89076 rdp = this_cpu_ptr(rsp->rda);
89077 rcu_preempt_check_blocked_tasks(rnp);
89078 rnp->qsmask = rnp->qsmaskinit;
89079 - ACCESS_ONCE(rnp->gpnum) = rsp->gpnum;
89080 + ACCESS_ONCE_RW(rnp->gpnum) = rsp->gpnum;
89081 WARN_ON_ONCE(rnp->completed != rsp->completed);
89082 - ACCESS_ONCE(rnp->completed) = rsp->completed;
89083 + ACCESS_ONCE_RW(rnp->completed) = rsp->completed;
89084 if (rnp == rdp->mynode)
89085 __note_gp_changes(rsp, rnp, rdp);
89086 rcu_preempt_boost_start_gp(rnp);
89087 @@ -1545,7 +1545,7 @@ static void rcu_gp_cleanup(struct rcu_state *rsp)
89088 rcu_for_each_node_breadth_first(rsp, rnp) {
89089 raw_spin_lock_irq(&rnp->lock);
89090 smp_mb__after_unlock_lock();
89091 - ACCESS_ONCE(rnp->completed) = rsp->gpnum;
89092 + ACCESS_ONCE_RW(rnp->completed) = rsp->gpnum;
89093 rdp = this_cpu_ptr(rsp->rda);
89094 if (rnp == rdp->mynode)
89095 __note_gp_changes(rsp, rnp, rdp);
89096 @@ -1560,7 +1560,7 @@ static void rcu_gp_cleanup(struct rcu_state *rsp)
89097 rcu_nocb_gp_set(rnp, nocb);
89098
89099 /* Declare grace period done. */
89100 - ACCESS_ONCE(rsp->completed) = rsp->gpnum;
89101 + ACCESS_ONCE_RW(rsp->completed) = rsp->gpnum;
89102 trace_rcu_grace_period(rsp->name, rsp->completed, TPS("end"));
89103 rsp->fqs_state = RCU_GP_IDLE;
89104 rdp = this_cpu_ptr(rsp->rda);
89105 @@ -1912,7 +1912,7 @@ rcu_send_cbs_to_orphanage(int cpu, struct rcu_state *rsp,
89106 rsp->qlen += rdp->qlen;
89107 rdp->n_cbs_orphaned += rdp->qlen;
89108 rdp->qlen_lazy = 0;
89109 - ACCESS_ONCE(rdp->qlen) = 0;
89110 + ACCESS_ONCE_RW(rdp->qlen) = 0;
89111 }
89112
89113 /*
89114 @@ -2159,7 +2159,7 @@ static void rcu_do_batch(struct rcu_state *rsp, struct rcu_data *rdp)
89115 }
89116 smp_mb(); /* List handling before counting for rcu_barrier(). */
89117 rdp->qlen_lazy -= count_lazy;
89118 - ACCESS_ONCE(rdp->qlen) -= count;
89119 + ACCESS_ONCE_RW(rdp->qlen) -= count;
89120 rdp->n_cbs_invoked += count;
89121
89122 /* Reinstate batch limit if we have worked down the excess. */
89123 @@ -2304,7 +2304,7 @@ static void force_quiescent_state(struct rcu_state *rsp)
89124 if (rnp_old != NULL)
89125 raw_spin_unlock(&rnp_old->fqslock);
89126 if (ret) {
89127 - ACCESS_ONCE(rsp->n_force_qs_lh)++;
89128 + ACCESS_ONCE_RW(rsp->n_force_qs_lh)++;
89129 return;
89130 }
89131 rnp_old = rnp;
89132 @@ -2316,7 +2316,7 @@ static void force_quiescent_state(struct rcu_state *rsp)
89133 smp_mb__after_unlock_lock();
89134 raw_spin_unlock(&rnp_old->fqslock);
89135 if (ACCESS_ONCE(rsp->gp_flags) & RCU_GP_FLAG_FQS) {
89136 - ACCESS_ONCE(rsp->n_force_qs_lh)++;
89137 + ACCESS_ONCE_RW(rsp->n_force_qs_lh)++;
89138 raw_spin_unlock_irqrestore(&rnp_old->lock, flags);
89139 return; /* Someone beat us to it. */
89140 }
89141 @@ -2362,7 +2362,7 @@ __rcu_process_callbacks(struct rcu_state *rsp)
89142 /*
89143 * Do RCU core processing for the current CPU.
89144 */
89145 -static void rcu_process_callbacks(struct softirq_action *unused)
89146 +static void rcu_process_callbacks(void)
89147 {
89148 struct rcu_state *rsp;
89149
89150 @@ -2470,7 +2470,7 @@ __call_rcu(struct rcu_head *head, void (*func)(struct rcu_head *rcu),
89151 WARN_ON_ONCE((unsigned long)head & 0x3); /* Misaligned rcu_head! */
89152 if (debug_rcu_head_queue(head)) {
89153 /* Probable double call_rcu(), so leak the callback. */
89154 - ACCESS_ONCE(head->func) = rcu_leak_callback;
89155 + ACCESS_ONCE_RW(head->func) = rcu_leak_callback;
89156 WARN_ONCE(1, "__call_rcu(): Leaked duplicate callback\n");
89157 return;
89158 }
89159 @@ -2498,7 +2498,7 @@ __call_rcu(struct rcu_head *head, void (*func)(struct rcu_head *rcu),
89160 local_irq_restore(flags);
89161 return;
89162 }
89163 - ACCESS_ONCE(rdp->qlen)++;
89164 + ACCESS_ONCE_RW(rdp->qlen)++;
89165 if (lazy)
89166 rdp->qlen_lazy++;
89167 else
89168 @@ -2759,11 +2759,11 @@ void synchronize_sched_expedited(void)
89169 * counter wrap on a 32-bit system. Quite a few more CPUs would of
89170 * course be required on a 64-bit system.
89171 */
89172 - if (ULONG_CMP_GE((ulong)atomic_long_read(&rsp->expedited_start),
89173 + if (ULONG_CMP_GE((ulong)atomic_long_read_unchecked(&rsp->expedited_start),
89174 (ulong)atomic_long_read(&rsp->expedited_done) +
89175 ULONG_MAX / 8)) {
89176 synchronize_sched();
89177 - atomic_long_inc(&rsp->expedited_wrap);
89178 + atomic_long_inc_unchecked(&rsp->expedited_wrap);
89179 return;
89180 }
89181
89182 @@ -2771,7 +2771,7 @@ void synchronize_sched_expedited(void)
89183 * Take a ticket. Note that atomic_inc_return() implies a
89184 * full memory barrier.
89185 */
89186 - snap = atomic_long_inc_return(&rsp->expedited_start);
89187 + snap = atomic_long_inc_return_unchecked(&rsp->expedited_start);
89188 firstsnap = snap;
89189 get_online_cpus();
89190 WARN_ON_ONCE(cpu_is_offline(raw_smp_processor_id()));
89191 @@ -2784,14 +2784,14 @@ void synchronize_sched_expedited(void)
89192 synchronize_sched_expedited_cpu_stop,
89193 NULL) == -EAGAIN) {
89194 put_online_cpus();
89195 - atomic_long_inc(&rsp->expedited_tryfail);
89196 + atomic_long_inc_unchecked(&rsp->expedited_tryfail);
89197
89198 /* Check to see if someone else did our work for us. */
89199 s = atomic_long_read(&rsp->expedited_done);
89200 if (ULONG_CMP_GE((ulong)s, (ulong)firstsnap)) {
89201 /* ensure test happens before caller kfree */
89202 smp_mb__before_atomic_inc(); /* ^^^ */
89203 - atomic_long_inc(&rsp->expedited_workdone1);
89204 + atomic_long_inc_unchecked(&rsp->expedited_workdone1);
89205 return;
89206 }
89207
89208 @@ -2800,7 +2800,7 @@ void synchronize_sched_expedited(void)
89209 udelay(trycount * num_online_cpus());
89210 } else {
89211 wait_rcu_gp(call_rcu_sched);
89212 - atomic_long_inc(&rsp->expedited_normal);
89213 + atomic_long_inc_unchecked(&rsp->expedited_normal);
89214 return;
89215 }
89216
89217 @@ -2809,7 +2809,7 @@ void synchronize_sched_expedited(void)
89218 if (ULONG_CMP_GE((ulong)s, (ulong)firstsnap)) {
89219 /* ensure test happens before caller kfree */
89220 smp_mb__before_atomic_inc(); /* ^^^ */
89221 - atomic_long_inc(&rsp->expedited_workdone2);
89222 + atomic_long_inc_unchecked(&rsp->expedited_workdone2);
89223 return;
89224 }
89225
89226 @@ -2821,10 +2821,10 @@ void synchronize_sched_expedited(void)
89227 * period works for us.
89228 */
89229 get_online_cpus();
89230 - snap = atomic_long_read(&rsp->expedited_start);
89231 + snap = atomic_long_read_unchecked(&rsp->expedited_start);
89232 smp_mb(); /* ensure read is before try_stop_cpus(). */
89233 }
89234 - atomic_long_inc(&rsp->expedited_stoppedcpus);
89235 + atomic_long_inc_unchecked(&rsp->expedited_stoppedcpus);
89236
89237 /*
89238 * Everyone up to our most recent fetch is covered by our grace
89239 @@ -2833,16 +2833,16 @@ void synchronize_sched_expedited(void)
89240 * than we did already did their update.
89241 */
89242 do {
89243 - atomic_long_inc(&rsp->expedited_done_tries);
89244 + atomic_long_inc_unchecked(&rsp->expedited_done_tries);
89245 s = atomic_long_read(&rsp->expedited_done);
89246 if (ULONG_CMP_GE((ulong)s, (ulong)snap)) {
89247 /* ensure test happens before caller kfree */
89248 smp_mb__before_atomic_inc(); /* ^^^ */
89249 - atomic_long_inc(&rsp->expedited_done_lost);
89250 + atomic_long_inc_unchecked(&rsp->expedited_done_lost);
89251 break;
89252 }
89253 } while (atomic_long_cmpxchg(&rsp->expedited_done, s, snap) != s);
89254 - atomic_long_inc(&rsp->expedited_done_exit);
89255 + atomic_long_inc_unchecked(&rsp->expedited_done_exit);
89256
89257 put_online_cpus();
89258 }
89259 @@ -3048,7 +3048,7 @@ static void _rcu_barrier(struct rcu_state *rsp)
89260 * ACCESS_ONCE() to prevent the compiler from speculating
89261 * the increment to precede the early-exit check.
89262 */
89263 - ACCESS_ONCE(rsp->n_barrier_done)++;
89264 + ACCESS_ONCE_RW(rsp->n_barrier_done)++;
89265 WARN_ON_ONCE((rsp->n_barrier_done & 0x1) != 1);
89266 _rcu_barrier_trace(rsp, "Inc1", -1, rsp->n_barrier_done);
89267 smp_mb(); /* Order ->n_barrier_done increment with below mechanism. */
89268 @@ -3098,7 +3098,7 @@ static void _rcu_barrier(struct rcu_state *rsp)
89269
89270 /* Increment ->n_barrier_done to prevent duplicate work. */
89271 smp_mb(); /* Keep increment after above mechanism. */
89272 - ACCESS_ONCE(rsp->n_barrier_done)++;
89273 + ACCESS_ONCE_RW(rsp->n_barrier_done)++;
89274 WARN_ON_ONCE((rsp->n_barrier_done & 0x1) != 0);
89275 _rcu_barrier_trace(rsp, "Inc2", -1, rsp->n_barrier_done);
89276 smp_mb(); /* Keep increment before caller's subsequent code. */
89277 @@ -3143,10 +3143,10 @@ rcu_boot_init_percpu_data(int cpu, struct rcu_state *rsp)
89278 rdp->grpmask = 1UL << (cpu - rdp->mynode->grplo);
89279 init_callback_list(rdp);
89280 rdp->qlen_lazy = 0;
89281 - ACCESS_ONCE(rdp->qlen) = 0;
89282 + ACCESS_ONCE_RW(rdp->qlen) = 0;
89283 rdp->dynticks = &per_cpu(rcu_dynticks, cpu);
89284 WARN_ON_ONCE(rdp->dynticks->dynticks_nesting != DYNTICK_TASK_EXIT_IDLE);
89285 - WARN_ON_ONCE(atomic_read(&rdp->dynticks->dynticks) != 1);
89286 + WARN_ON_ONCE(atomic_read_unchecked(&rdp->dynticks->dynticks) != 1);
89287 rdp->cpu = cpu;
89288 rdp->rsp = rsp;
89289 rcu_boot_init_nocb_percpu_data(rdp);
89290 @@ -3180,8 +3180,8 @@ rcu_init_percpu_data(int cpu, struct rcu_state *rsp, int preemptible)
89291 init_callback_list(rdp); /* Re-enable callbacks on this CPU. */
89292 rdp->dynticks->dynticks_nesting = DYNTICK_TASK_EXIT_IDLE;
89293 rcu_sysidle_init_percpu_data(rdp->dynticks);
89294 - atomic_set(&rdp->dynticks->dynticks,
89295 - (atomic_read(&rdp->dynticks->dynticks) & ~0x1) + 1);
89296 + atomic_set_unchecked(&rdp->dynticks->dynticks,
89297 + (atomic_read_unchecked(&rdp->dynticks->dynticks) & ~0x1) + 1);
89298 raw_spin_unlock(&rnp->lock); /* irqs remain disabled. */
89299
89300 /* Add CPU to rcu_node bitmasks. */
89301 diff --git a/kernel/rcu/tree.h b/kernel/rcu/tree.h
89302 index 75dc3c3..b95d624 100644
89303 --- a/kernel/rcu/tree.h
89304 +++ b/kernel/rcu/tree.h
89305 @@ -87,11 +87,11 @@ struct rcu_dynticks {
89306 long long dynticks_nesting; /* Track irq/process nesting level. */
89307 /* Process level is worth LLONG_MAX/2. */
89308 int dynticks_nmi_nesting; /* Track NMI nesting level. */
89309 - atomic_t dynticks; /* Even value for idle, else odd. */
89310 + atomic_unchecked_t dynticks;/* Even value for idle, else odd. */
89311 #ifdef CONFIG_NO_HZ_FULL_SYSIDLE
89312 long long dynticks_idle_nesting;
89313 /* irq/process nesting level from idle. */
89314 - atomic_t dynticks_idle; /* Even value for idle, else odd. */
89315 + atomic_unchecked_t dynticks_idle;/* Even value for idle, else odd. */
89316 /* "Idle" excludes userspace execution. */
89317 unsigned long dynticks_idle_jiffies;
89318 /* End of last non-NMI non-idle period. */
89319 @@ -431,17 +431,17 @@ struct rcu_state {
89320 /* _rcu_barrier(). */
89321 /* End of fields guarded by barrier_mutex. */
89322
89323 - atomic_long_t expedited_start; /* Starting ticket. */
89324 - atomic_long_t expedited_done; /* Done ticket. */
89325 - atomic_long_t expedited_wrap; /* # near-wrap incidents. */
89326 - atomic_long_t expedited_tryfail; /* # acquisition failures. */
89327 - atomic_long_t expedited_workdone1; /* # done by others #1. */
89328 - atomic_long_t expedited_workdone2; /* # done by others #2. */
89329 - atomic_long_t expedited_normal; /* # fallbacks to normal. */
89330 - atomic_long_t expedited_stoppedcpus; /* # successful stop_cpus. */
89331 - atomic_long_t expedited_done_tries; /* # tries to update _done. */
89332 - atomic_long_t expedited_done_lost; /* # times beaten to _done. */
89333 - atomic_long_t expedited_done_exit; /* # times exited _done loop. */
89334 + atomic_long_unchecked_t expedited_start; /* Starting ticket. */
89335 + atomic_long_t expedited_done; /* Done ticket. */
89336 + atomic_long_unchecked_t expedited_wrap; /* # near-wrap incidents. */
89337 + atomic_long_unchecked_t expedited_tryfail; /* # acquisition failures. */
89338 + atomic_long_unchecked_t expedited_workdone1; /* # done by others #1. */
89339 + atomic_long_unchecked_t expedited_workdone2; /* # done by others #2. */
89340 + atomic_long_unchecked_t expedited_normal; /* # fallbacks to normal. */
89341 + atomic_long_unchecked_t expedited_stoppedcpus; /* # successful stop_cpus. */
89342 + atomic_long_unchecked_t expedited_done_tries; /* # tries to update _done. */
89343 + atomic_long_unchecked_t expedited_done_lost; /* # times beaten to _done. */
89344 + atomic_long_unchecked_t expedited_done_exit; /* # times exited _done loop. */
89345
89346 unsigned long jiffies_force_qs; /* Time at which to invoke */
89347 /* force_quiescent_state(). */
89348 diff --git a/kernel/rcu/tree_plugin.h b/kernel/rcu/tree_plugin.h
89349 index 962d1d5..c6c62d12d 100644
89350 --- a/kernel/rcu/tree_plugin.h
89351 +++ b/kernel/rcu/tree_plugin.h
89352 @@ -758,7 +758,7 @@ static int rcu_preempted_readers_exp(struct rcu_node *rnp)
89353 static int sync_rcu_preempt_exp_done(struct rcu_node *rnp)
89354 {
89355 return !rcu_preempted_readers_exp(rnp) &&
89356 - ACCESS_ONCE(rnp->expmask) == 0;
89357 + ACCESS_ONCE_RW(rnp->expmask) == 0;
89358 }
89359
89360 /*
89361 @@ -920,7 +920,7 @@ void synchronize_rcu_expedited(void)
89362
89363 /* Clean up and exit. */
89364 smp_mb(); /* ensure expedited GP seen before counter increment. */
89365 - ACCESS_ONCE(sync_rcu_preempt_exp_count)++;
89366 + ACCESS_ONCE_RW(sync_rcu_preempt_exp_count)++;
89367 unlock_mb_ret:
89368 mutex_unlock(&sync_rcu_preempt_exp_mutex);
89369 mb_ret:
89370 @@ -1496,7 +1496,7 @@ static void rcu_boost_kthread_setaffinity(struct rcu_node *rnp, int outgoingcpu)
89371 free_cpumask_var(cm);
89372 }
89373
89374 -static struct smp_hotplug_thread rcu_cpu_thread_spec = {
89375 +static struct smp_hotplug_thread rcu_cpu_thread_spec __read_only = {
89376 .store = &rcu_cpu_kthread_task,
89377 .thread_should_run = rcu_cpu_kthread_should_run,
89378 .thread_fn = rcu_cpu_kthread,
89379 @@ -1972,7 +1972,7 @@ static void print_cpu_stall_info(struct rcu_state *rsp, int cpu)
89380 print_cpu_stall_fast_no_hz(fast_no_hz, cpu);
89381 pr_err("\t%d: (%lu %s) idle=%03x/%llx/%d softirq=%u/%u %s\n",
89382 cpu, ticks_value, ticks_title,
89383 - atomic_read(&rdtp->dynticks) & 0xfff,
89384 + atomic_read_unchecked(&rdtp->dynticks) & 0xfff,
89385 rdtp->dynticks_nesting, rdtp->dynticks_nmi_nesting,
89386 rdp->softirq_snap, kstat_softirqs_cpu(RCU_SOFTIRQ, cpu),
89387 fast_no_hz);
89388 @@ -2138,7 +2138,7 @@ static void __call_rcu_nocb_enqueue(struct rcu_data *rdp,
89389
89390 /* Enqueue the callback on the nocb list and update counts. */
89391 old_rhpp = xchg(&rdp->nocb_tail, rhtp);
89392 - ACCESS_ONCE(*old_rhpp) = rhp;
89393 + ACCESS_ONCE_RW(*old_rhpp) = rhp;
89394 atomic_long_add(rhcount, &rdp->nocb_q_count);
89395 atomic_long_add(rhcount_lazy, &rdp->nocb_q_count_lazy);
89396
89397 @@ -2311,12 +2311,12 @@ static int rcu_nocb_kthread(void *arg)
89398 * Extract queued callbacks, update counts, and wait
89399 * for a grace period to elapse.
89400 */
89401 - ACCESS_ONCE(rdp->nocb_head) = NULL;
89402 + ACCESS_ONCE_RW(rdp->nocb_head) = NULL;
89403 tail = xchg(&rdp->nocb_tail, &rdp->nocb_head);
89404 c = atomic_long_xchg(&rdp->nocb_q_count, 0);
89405 cl = atomic_long_xchg(&rdp->nocb_q_count_lazy, 0);
89406 - ACCESS_ONCE(rdp->nocb_p_count) += c;
89407 - ACCESS_ONCE(rdp->nocb_p_count_lazy) += cl;
89408 + ACCESS_ONCE_RW(rdp->nocb_p_count) += c;
89409 + ACCESS_ONCE_RW(rdp->nocb_p_count_lazy) += cl;
89410 rcu_nocb_wait_gp(rdp);
89411
89412 /* Each pass through the following loop invokes a callback. */
89413 @@ -2342,8 +2342,8 @@ static int rcu_nocb_kthread(void *arg)
89414 list = next;
89415 }
89416 trace_rcu_batch_end(rdp->rsp->name, c, !!list, 0, 0, 1);
89417 - ACCESS_ONCE(rdp->nocb_p_count) -= c;
89418 - ACCESS_ONCE(rdp->nocb_p_count_lazy) -= cl;
89419 + ACCESS_ONCE_RW(rdp->nocb_p_count) -= c;
89420 + ACCESS_ONCE_RW(rdp->nocb_p_count_lazy) -= cl;
89421 rdp->n_nocbs_invoked += c;
89422 }
89423 return 0;
89424 @@ -2360,7 +2360,7 @@ static void do_nocb_deferred_wakeup(struct rcu_data *rdp)
89425 {
89426 if (!rcu_nocb_need_deferred_wakeup(rdp))
89427 return;
89428 - ACCESS_ONCE(rdp->nocb_defer_wakeup) = false;
89429 + ACCESS_ONCE_RW(rdp->nocb_defer_wakeup) = false;
89430 wake_up(&rdp->nocb_wq);
89431 trace_rcu_nocb_wake(rdp->rsp->name, rdp->cpu, TPS("DeferredWakeEmpty"));
89432 }
89433 @@ -2386,7 +2386,7 @@ static void __init rcu_spawn_nocb_kthreads(struct rcu_state *rsp)
89434 t = kthread_run(rcu_nocb_kthread, rdp,
89435 "rcuo%c/%d", rsp->abbr, cpu);
89436 BUG_ON(IS_ERR(t));
89437 - ACCESS_ONCE(rdp->nocb_kthread) = t;
89438 + ACCESS_ONCE_RW(rdp->nocb_kthread) = t;
89439 }
89440 }
89441
89442 @@ -2522,11 +2522,11 @@ static void rcu_sysidle_enter(struct rcu_dynticks *rdtp, int irq)
89443
89444 /* Record start of fully idle period. */
89445 j = jiffies;
89446 - ACCESS_ONCE(rdtp->dynticks_idle_jiffies) = j;
89447 + ACCESS_ONCE_RW(rdtp->dynticks_idle_jiffies) = j;
89448 smp_mb__before_atomic_inc();
89449 - atomic_inc(&rdtp->dynticks_idle);
89450 + atomic_inc_unchecked(&rdtp->dynticks_idle);
89451 smp_mb__after_atomic_inc();
89452 - WARN_ON_ONCE(atomic_read(&rdtp->dynticks_idle) & 0x1);
89453 + WARN_ON_ONCE(atomic_read_unchecked(&rdtp->dynticks_idle) & 0x1);
89454 }
89455
89456 /*
89457 @@ -2591,9 +2591,9 @@ static void rcu_sysidle_exit(struct rcu_dynticks *rdtp, int irq)
89458
89459 /* Record end of idle period. */
89460 smp_mb__before_atomic_inc();
89461 - atomic_inc(&rdtp->dynticks_idle);
89462 + atomic_inc_unchecked(&rdtp->dynticks_idle);
89463 smp_mb__after_atomic_inc();
89464 - WARN_ON_ONCE(!(atomic_read(&rdtp->dynticks_idle) & 0x1));
89465 + WARN_ON_ONCE(!(atomic_read_unchecked(&rdtp->dynticks_idle) & 0x1));
89466
89467 /*
89468 * If we are the timekeeping CPU, we are permitted to be non-idle
89469 @@ -2634,7 +2634,7 @@ static void rcu_sysidle_check_cpu(struct rcu_data *rdp, bool *isidle,
89470 WARN_ON_ONCE(smp_processor_id() != tick_do_timer_cpu);
89471
89472 /* Pick up current idle and NMI-nesting counter and check. */
89473 - cur = atomic_read(&rdtp->dynticks_idle);
89474 + cur = atomic_read_unchecked(&rdtp->dynticks_idle);
89475 if (cur & 0x1) {
89476 *isidle = false; /* We are not idle! */
89477 return;
89478 @@ -2697,7 +2697,7 @@ static void rcu_sysidle(unsigned long j)
89479 case RCU_SYSIDLE_NOT:
89480
89481 /* First time all are idle, so note a short idle period. */
89482 - ACCESS_ONCE(full_sysidle_state) = RCU_SYSIDLE_SHORT;
89483 + ACCESS_ONCE_RW(full_sysidle_state) = RCU_SYSIDLE_SHORT;
89484 break;
89485
89486 case RCU_SYSIDLE_SHORT:
89487 @@ -2734,7 +2734,7 @@ static void rcu_sysidle(unsigned long j)
89488 static void rcu_sysidle_cancel(void)
89489 {
89490 smp_mb();
89491 - ACCESS_ONCE(full_sysidle_state) = RCU_SYSIDLE_NOT;
89492 + ACCESS_ONCE_RW(full_sysidle_state) = RCU_SYSIDLE_NOT;
89493 }
89494
89495 /*
89496 @@ -2782,7 +2782,7 @@ static void rcu_sysidle_cb(struct rcu_head *rhp)
89497 smp_mb(); /* grace period precedes setting inuse. */
89498
89499 rshp = container_of(rhp, struct rcu_sysidle_head, rh);
89500 - ACCESS_ONCE(rshp->inuse) = 0;
89501 + ACCESS_ONCE_RW(rshp->inuse) = 0;
89502 }
89503
89504 /*
89505 diff --git a/kernel/rcu/tree_trace.c b/kernel/rcu/tree_trace.c
89506 index 5cdc62e..cc52e88 100644
89507 --- a/kernel/rcu/tree_trace.c
89508 +++ b/kernel/rcu/tree_trace.c
89509 @@ -121,7 +121,7 @@ static void print_one_rcu_data(struct seq_file *m, struct rcu_data *rdp)
89510 ulong2long(rdp->completed), ulong2long(rdp->gpnum),
89511 rdp->passed_quiesce, rdp->qs_pending);
89512 seq_printf(m, " dt=%d/%llx/%d df=%lu",
89513 - atomic_read(&rdp->dynticks->dynticks),
89514 + atomic_read_unchecked(&rdp->dynticks->dynticks),
89515 rdp->dynticks->dynticks_nesting,
89516 rdp->dynticks->dynticks_nmi_nesting,
89517 rdp->dynticks_fqs);
89518 @@ -182,17 +182,17 @@ static int show_rcuexp(struct seq_file *m, void *v)
89519 struct rcu_state *rsp = (struct rcu_state *)m->private;
89520
89521 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",
89522 - atomic_long_read(&rsp->expedited_start),
89523 + atomic_long_read_unchecked(&rsp->expedited_start),
89524 atomic_long_read(&rsp->expedited_done),
89525 - atomic_long_read(&rsp->expedited_wrap),
89526 - atomic_long_read(&rsp->expedited_tryfail),
89527 - atomic_long_read(&rsp->expedited_workdone1),
89528 - atomic_long_read(&rsp->expedited_workdone2),
89529 - atomic_long_read(&rsp->expedited_normal),
89530 - atomic_long_read(&rsp->expedited_stoppedcpus),
89531 - atomic_long_read(&rsp->expedited_done_tries),
89532 - atomic_long_read(&rsp->expedited_done_lost),
89533 - atomic_long_read(&rsp->expedited_done_exit));
89534 + atomic_long_read_unchecked(&rsp->expedited_wrap),
89535 + atomic_long_read_unchecked(&rsp->expedited_tryfail),
89536 + atomic_long_read_unchecked(&rsp->expedited_workdone1),
89537 + atomic_long_read_unchecked(&rsp->expedited_workdone2),
89538 + atomic_long_read_unchecked(&rsp->expedited_normal),
89539 + atomic_long_read_unchecked(&rsp->expedited_stoppedcpus),
89540 + atomic_long_read_unchecked(&rsp->expedited_done_tries),
89541 + atomic_long_read_unchecked(&rsp->expedited_done_lost),
89542 + atomic_long_read_unchecked(&rsp->expedited_done_exit));
89543 return 0;
89544 }
89545
89546 diff --git a/kernel/rcu/update.c b/kernel/rcu/update.c
89547 index 4c0a9b0..7e81362 100644
89548 --- a/kernel/rcu/update.c
89549 +++ b/kernel/rcu/update.c
89550 @@ -311,10 +311,10 @@ int rcu_jiffies_till_stall_check(void)
89551 * for CONFIG_RCU_CPU_STALL_TIMEOUT.
89552 */
89553 if (till_stall_check < 3) {
89554 - ACCESS_ONCE(rcu_cpu_stall_timeout) = 3;
89555 + ACCESS_ONCE_RW(rcu_cpu_stall_timeout) = 3;
89556 till_stall_check = 3;
89557 } else if (till_stall_check > 300) {
89558 - ACCESS_ONCE(rcu_cpu_stall_timeout) = 300;
89559 + ACCESS_ONCE_RW(rcu_cpu_stall_timeout) = 300;
89560 till_stall_check = 300;
89561 }
89562 return till_stall_check * HZ + RCU_STALL_DELAY_DELTA;
89563 diff --git a/kernel/resource.c b/kernel/resource.c
89564 index 8957d68..770cbe4 100644
89565 --- a/kernel/resource.c
89566 +++ b/kernel/resource.c
89567 @@ -152,8 +152,18 @@ static const struct file_operations proc_iomem_operations = {
89568
89569 static int __init ioresources_init(void)
89570 {
89571 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
89572 +#ifdef CONFIG_GRKERNSEC_PROC_USER
89573 + proc_create("ioports", S_IRUSR, NULL, &proc_ioports_operations);
89574 + proc_create("iomem", S_IRUSR, NULL, &proc_iomem_operations);
89575 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
89576 + proc_create("ioports", S_IRUSR | S_IRGRP, NULL, &proc_ioports_operations);
89577 + proc_create("iomem", S_IRUSR | S_IRGRP, NULL, &proc_iomem_operations);
89578 +#endif
89579 +#else
89580 proc_create("ioports", 0, NULL, &proc_ioports_operations);
89581 proc_create("iomem", 0, NULL, &proc_iomem_operations);
89582 +#endif
89583 return 0;
89584 }
89585 __initcall(ioresources_init);
89586 diff --git a/kernel/sched/auto_group.c b/kernel/sched/auto_group.c
89587 index e73efba..c9bfbd4 100644
89588 --- a/kernel/sched/auto_group.c
89589 +++ b/kernel/sched/auto_group.c
89590 @@ -11,7 +11,7 @@
89591
89592 unsigned int __read_mostly sysctl_sched_autogroup_enabled = 1;
89593 static struct autogroup autogroup_default;
89594 -static atomic_t autogroup_seq_nr;
89595 +static atomic_unchecked_t autogroup_seq_nr;
89596
89597 void __init autogroup_init(struct task_struct *init_task)
89598 {
89599 @@ -79,7 +79,7 @@ static inline struct autogroup *autogroup_create(void)
89600
89601 kref_init(&ag->kref);
89602 init_rwsem(&ag->lock);
89603 - ag->id = atomic_inc_return(&autogroup_seq_nr);
89604 + ag->id = atomic_inc_return_unchecked(&autogroup_seq_nr);
89605 ag->tg = tg;
89606 #ifdef CONFIG_RT_GROUP_SCHED
89607 /*
89608 diff --git a/kernel/sched/completion.c b/kernel/sched/completion.c
89609 index a63f4dc..349bbb0 100644
89610 --- a/kernel/sched/completion.c
89611 +++ b/kernel/sched/completion.c
89612 @@ -204,7 +204,7 @@ EXPORT_SYMBOL(wait_for_completion_interruptible);
89613 * Return: -ERESTARTSYS if interrupted, 0 if timed out, positive (at least 1,
89614 * or number of jiffies left till timeout) if completed.
89615 */
89616 -long __sched
89617 +long __sched __intentional_overflow(-1)
89618 wait_for_completion_interruptible_timeout(struct completion *x,
89619 unsigned long timeout)
89620 {
89621 @@ -221,7 +221,7 @@ EXPORT_SYMBOL(wait_for_completion_interruptible_timeout);
89622 *
89623 * Return: -ERESTARTSYS if interrupted, 0 if completed.
89624 */
89625 -int __sched wait_for_completion_killable(struct completion *x)
89626 +int __sched __intentional_overflow(-1) wait_for_completion_killable(struct completion *x)
89627 {
89628 long t = wait_for_common(x, MAX_SCHEDULE_TIMEOUT, TASK_KILLABLE);
89629 if (t == -ERESTARTSYS)
89630 @@ -242,7 +242,7 @@ EXPORT_SYMBOL(wait_for_completion_killable);
89631 * Return: -ERESTARTSYS if interrupted, 0 if timed out, positive (at least 1,
89632 * or number of jiffies left till timeout) if completed.
89633 */
89634 -long __sched
89635 +long __sched __intentional_overflow(-1)
89636 wait_for_completion_killable_timeout(struct completion *x,
89637 unsigned long timeout)
89638 {
89639 diff --git a/kernel/sched/core.c b/kernel/sched/core.c
89640 index 084d17f..e416b9f 100644
89641 --- a/kernel/sched/core.c
89642 +++ b/kernel/sched/core.c
89643 @@ -1775,7 +1775,7 @@ void set_numabalancing_state(bool enabled)
89644 int sysctl_numa_balancing(struct ctl_table *table, int write,
89645 void __user *buffer, size_t *lenp, loff_t *ppos)
89646 {
89647 - struct ctl_table t;
89648 + ctl_table_no_const t;
89649 int err;
89650 int state = numabalancing_enabled;
89651
89652 @@ -2238,8 +2238,10 @@ context_switch(struct rq *rq, struct task_struct *prev,
89653 next->active_mm = oldmm;
89654 atomic_inc(&oldmm->mm_count);
89655 enter_lazy_tlb(oldmm, next);
89656 - } else
89657 + } else {
89658 switch_mm(oldmm, mm, next);
89659 + populate_stack();
89660 + }
89661
89662 if (!prev->mm) {
89663 prev->active_mm = NULL;
89664 @@ -3004,6 +3006,8 @@ int can_nice(const struct task_struct *p, const int nice)
89665 /* convert nice value [19,-20] to rlimit style value [1,40] */
89666 int nice_rlim = 20 - nice;
89667
89668 + gr_learn_resource(p, RLIMIT_NICE, nice_rlim, 1);
89669 +
89670 return (nice_rlim <= task_rlimit(p, RLIMIT_NICE) ||
89671 capable(CAP_SYS_NICE));
89672 }
89673 @@ -3037,7 +3041,8 @@ SYSCALL_DEFINE1(nice, int, increment)
89674 if (nice > MAX_NICE)
89675 nice = MAX_NICE;
89676
89677 - if (increment < 0 && !can_nice(current, nice))
89678 + if (increment < 0 && (!can_nice(current, nice) ||
89679 + gr_handle_chroot_nice()))
89680 return -EPERM;
89681
89682 retval = security_task_setnice(current, nice);
89683 @@ -3310,6 +3315,7 @@ recheck:
89684 if (policy != p->policy && !rlim_rtprio)
89685 return -EPERM;
89686
89687 + gr_learn_resource(p, RLIMIT_RTPRIO, attr->sched_priority, 1);
89688 /* can't increase priority */
89689 if (attr->sched_priority > p->rt_priority &&
89690 attr->sched_priority > rlim_rtprio)
89691 @@ -4708,6 +4714,7 @@ void idle_task_exit(void)
89692
89693 if (mm != &init_mm) {
89694 switch_mm(mm, &init_mm, current);
89695 + populate_stack();
89696 finish_arch_post_lock_switch();
89697 }
89698 mmdrop(mm);
89699 @@ -4803,7 +4810,7 @@ static void migrate_tasks(unsigned int dead_cpu)
89700
89701 #if defined(CONFIG_SCHED_DEBUG) && defined(CONFIG_SYSCTL)
89702
89703 -static struct ctl_table sd_ctl_dir[] = {
89704 +static ctl_table_no_const sd_ctl_dir[] __read_only = {
89705 {
89706 .procname = "sched_domain",
89707 .mode = 0555,
89708 @@ -4820,17 +4827,17 @@ static struct ctl_table sd_ctl_root[] = {
89709 {}
89710 };
89711
89712 -static struct ctl_table *sd_alloc_ctl_entry(int n)
89713 +static ctl_table_no_const *sd_alloc_ctl_entry(int n)
89714 {
89715 - struct ctl_table *entry =
89716 + ctl_table_no_const *entry =
89717 kcalloc(n, sizeof(struct ctl_table), GFP_KERNEL);
89718
89719 return entry;
89720 }
89721
89722 -static void sd_free_ctl_entry(struct ctl_table **tablep)
89723 +static void sd_free_ctl_entry(ctl_table_no_const *tablep)
89724 {
89725 - struct ctl_table *entry;
89726 + ctl_table_no_const *entry;
89727
89728 /*
89729 * In the intermediate directories, both the child directory and
89730 @@ -4838,22 +4845,25 @@ static void sd_free_ctl_entry(struct ctl_table **tablep)
89731 * will always be set. In the lowest directory the names are
89732 * static strings and all have proc handlers.
89733 */
89734 - for (entry = *tablep; entry->mode; entry++) {
89735 - if (entry->child)
89736 - sd_free_ctl_entry(&entry->child);
89737 + for (entry = tablep; entry->mode; entry++) {
89738 + if (entry->child) {
89739 + sd_free_ctl_entry(entry->child);
89740 + pax_open_kernel();
89741 + entry->child = NULL;
89742 + pax_close_kernel();
89743 + }
89744 if (entry->proc_handler == NULL)
89745 kfree(entry->procname);
89746 }
89747
89748 - kfree(*tablep);
89749 - *tablep = NULL;
89750 + kfree(tablep);
89751 }
89752
89753 static int min_load_idx = 0;
89754 static int max_load_idx = CPU_LOAD_IDX_MAX-1;
89755
89756 static void
89757 -set_table_entry(struct ctl_table *entry,
89758 +set_table_entry(ctl_table_no_const *entry,
89759 const char *procname, void *data, int maxlen,
89760 umode_t mode, proc_handler *proc_handler,
89761 bool load_idx)
89762 @@ -4873,7 +4883,7 @@ set_table_entry(struct ctl_table *entry,
89763 static struct ctl_table *
89764 sd_alloc_ctl_domain_table(struct sched_domain *sd)
89765 {
89766 - struct ctl_table *table = sd_alloc_ctl_entry(14);
89767 + ctl_table_no_const *table = sd_alloc_ctl_entry(14);
89768
89769 if (table == NULL)
89770 return NULL;
89771 @@ -4911,9 +4921,9 @@ sd_alloc_ctl_domain_table(struct sched_domain *sd)
89772 return table;
89773 }
89774
89775 -static struct ctl_table *sd_alloc_ctl_cpu_table(int cpu)
89776 +static ctl_table_no_const *sd_alloc_ctl_cpu_table(int cpu)
89777 {
89778 - struct ctl_table *entry, *table;
89779 + ctl_table_no_const *entry, *table;
89780 struct sched_domain *sd;
89781 int domain_num = 0, i;
89782 char buf[32];
89783 @@ -4940,11 +4950,13 @@ static struct ctl_table_header *sd_sysctl_header;
89784 static void register_sched_domain_sysctl(void)
89785 {
89786 int i, cpu_num = num_possible_cpus();
89787 - struct ctl_table *entry = sd_alloc_ctl_entry(cpu_num + 1);
89788 + ctl_table_no_const *entry = sd_alloc_ctl_entry(cpu_num + 1);
89789 char buf[32];
89790
89791 WARN_ON(sd_ctl_dir[0].child);
89792 + pax_open_kernel();
89793 sd_ctl_dir[0].child = entry;
89794 + pax_close_kernel();
89795
89796 if (entry == NULL)
89797 return;
89798 @@ -4967,8 +4979,12 @@ static void unregister_sched_domain_sysctl(void)
89799 if (sd_sysctl_header)
89800 unregister_sysctl_table(sd_sysctl_header);
89801 sd_sysctl_header = NULL;
89802 - if (sd_ctl_dir[0].child)
89803 - sd_free_ctl_entry(&sd_ctl_dir[0].child);
89804 + if (sd_ctl_dir[0].child) {
89805 + sd_free_ctl_entry(sd_ctl_dir[0].child);
89806 + pax_open_kernel();
89807 + sd_ctl_dir[0].child = NULL;
89808 + pax_close_kernel();
89809 + }
89810 }
89811 #else
89812 static void register_sched_domain_sysctl(void)
89813 diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
89814 index 8cbe2d2..61f20a1 100644
89815 --- a/kernel/sched/fair.c
89816 +++ b/kernel/sched/fair.c
89817 @@ -1806,7 +1806,7 @@ void task_numa_fault(int last_cpupid, int mem_node, int pages, int flags)
89818
89819 static void reset_ptenuma_scan(struct task_struct *p)
89820 {
89821 - ACCESS_ONCE(p->mm->numa_scan_seq)++;
89822 + ACCESS_ONCE_RW(p->mm->numa_scan_seq)++;
89823 p->mm->numa_scan_offset = 0;
89824 }
89825
89826 @@ -7181,7 +7181,7 @@ static void nohz_idle_balance(struct rq *this_rq, enum cpu_idle_type idle) { }
89827 * run_rebalance_domains is triggered when needed from the scheduler tick.
89828 * Also triggered for nohz idle balancing (with nohz_balancing_kick set).
89829 */
89830 -static void run_rebalance_domains(struct softirq_action *h)
89831 +static __latent_entropy void run_rebalance_domains(void)
89832 {
89833 struct rq *this_rq = this_rq();
89834 enum cpu_idle_type idle = this_rq->idle_balance ?
89835 diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
89836 index 369b4d6..fa4eb3b 100644
89837 --- a/kernel/sched/sched.h
89838 +++ b/kernel/sched/sched.h
89839 @@ -1157,7 +1157,7 @@ struct sched_class {
89840 #ifdef CONFIG_FAIR_GROUP_SCHED
89841 void (*task_move_group) (struct task_struct *p, int on_rq);
89842 #endif
89843 -};
89844 +} __do_const;
89845
89846 static inline void put_prev_task(struct rq *rq, struct task_struct *prev)
89847 {
89848 diff --git a/kernel/signal.c b/kernel/signal.c
89849 index 6ea13c0..31e3b25 100644
89850 --- a/kernel/signal.c
89851 +++ b/kernel/signal.c
89852 @@ -53,12 +53,12 @@ static struct kmem_cache *sigqueue_cachep;
89853
89854 int print_fatal_signals __read_mostly;
89855
89856 -static void __user *sig_handler(struct task_struct *t, int sig)
89857 +static __sighandler_t sig_handler(struct task_struct *t, int sig)
89858 {
89859 return t->sighand->action[sig - 1].sa.sa_handler;
89860 }
89861
89862 -static int sig_handler_ignored(void __user *handler, int sig)
89863 +static int sig_handler_ignored(__sighandler_t handler, int sig)
89864 {
89865 /* Is it explicitly or implicitly ignored? */
89866 return handler == SIG_IGN ||
89867 @@ -67,7 +67,7 @@ static int sig_handler_ignored(void __user *handler, int sig)
89868
89869 static int sig_task_ignored(struct task_struct *t, int sig, bool force)
89870 {
89871 - void __user *handler;
89872 + __sighandler_t handler;
89873
89874 handler = sig_handler(t, sig);
89875
89876 @@ -371,6 +371,9 @@ __sigqueue_alloc(int sig, struct task_struct *t, gfp_t flags, int override_rlimi
89877 atomic_inc(&user->sigpending);
89878 rcu_read_unlock();
89879
89880 + if (!override_rlimit)
89881 + gr_learn_resource(t, RLIMIT_SIGPENDING, atomic_read(&user->sigpending), 1);
89882 +
89883 if (override_rlimit ||
89884 atomic_read(&user->sigpending) <=
89885 task_rlimit(t, RLIMIT_SIGPENDING)) {
89886 @@ -498,7 +501,7 @@ flush_signal_handlers(struct task_struct *t, int force_default)
89887
89888 int unhandled_signal(struct task_struct *tsk, int sig)
89889 {
89890 - void __user *handler = tsk->sighand->action[sig-1].sa.sa_handler;
89891 + __sighandler_t handler = tsk->sighand->action[sig-1].sa.sa_handler;
89892 if (is_global_init(tsk))
89893 return 1;
89894 if (handler != SIG_IGN && handler != SIG_DFL)
89895 @@ -818,6 +821,13 @@ static int check_kill_permission(int sig, struct siginfo *info,
89896 }
89897 }
89898
89899 + /* allow glibc communication via tgkill to other threads in our
89900 + thread group */
89901 + if ((info == SEND_SIG_NOINFO || info->si_code != SI_TKILL ||
89902 + sig != (SIGRTMIN+1) || task_tgid_vnr(t) != info->si_pid)
89903 + && gr_handle_signal(t, sig))
89904 + return -EPERM;
89905 +
89906 return security_task_kill(t, info, sig, 0);
89907 }
89908
89909 @@ -1201,7 +1211,7 @@ __group_send_sig_info(int sig, struct siginfo *info, struct task_struct *p)
89910 return send_signal(sig, info, p, 1);
89911 }
89912
89913 -static int
89914 +int
89915 specific_send_sig_info(int sig, struct siginfo *info, struct task_struct *t)
89916 {
89917 return send_signal(sig, info, t, 0);
89918 @@ -1238,6 +1248,7 @@ force_sig_info(int sig, struct siginfo *info, struct task_struct *t)
89919 unsigned long int flags;
89920 int ret, blocked, ignored;
89921 struct k_sigaction *action;
89922 + int is_unhandled = 0;
89923
89924 spin_lock_irqsave(&t->sighand->siglock, flags);
89925 action = &t->sighand->action[sig-1];
89926 @@ -1252,9 +1263,18 @@ force_sig_info(int sig, struct siginfo *info, struct task_struct *t)
89927 }
89928 if (action->sa.sa_handler == SIG_DFL)
89929 t->signal->flags &= ~SIGNAL_UNKILLABLE;
89930 + if (action->sa.sa_handler == SIG_IGN || action->sa.sa_handler == SIG_DFL)
89931 + is_unhandled = 1;
89932 ret = specific_send_sig_info(sig, info, t);
89933 spin_unlock_irqrestore(&t->sighand->siglock, flags);
89934
89935 + /* only deal with unhandled signals, java etc trigger SIGSEGV during
89936 + normal operation */
89937 + if (is_unhandled) {
89938 + gr_log_signal(sig, !is_si_special(info) ? info->si_addr : NULL, t);
89939 + gr_handle_crash(t, sig);
89940 + }
89941 +
89942 return ret;
89943 }
89944
89945 @@ -1321,8 +1341,11 @@ int group_send_sig_info(int sig, struct siginfo *info, struct task_struct *p)
89946 ret = check_kill_permission(sig, info, p);
89947 rcu_read_unlock();
89948
89949 - if (!ret && sig)
89950 + if (!ret && sig) {
89951 ret = do_send_sig_info(sig, info, p, true);
89952 + if (!ret)
89953 + gr_log_signal(sig, !is_si_special(info) ? info->si_addr : NULL, p);
89954 + }
89955
89956 return ret;
89957 }
89958 @@ -2928,7 +2951,15 @@ do_send_specific(pid_t tgid, pid_t pid, int sig, struct siginfo *info)
89959 int error = -ESRCH;
89960
89961 rcu_read_lock();
89962 - p = find_task_by_vpid(pid);
89963 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
89964 + /* allow glibc communication via tgkill to other threads in our
89965 + thread group */
89966 + if (grsec_enable_chroot_findtask && info->si_code == SI_TKILL &&
89967 + sig == (SIGRTMIN+1) && tgid == info->si_pid)
89968 + p = find_task_by_vpid_unrestricted(pid);
89969 + else
89970 +#endif
89971 + p = find_task_by_vpid(pid);
89972 if (p && (tgid <= 0 || task_tgid_vnr(p) == tgid)) {
89973 error = check_kill_permission(sig, info, p);
89974 /*
89975 @@ -3241,8 +3272,8 @@ COMPAT_SYSCALL_DEFINE2(sigaltstack,
89976 }
89977 seg = get_fs();
89978 set_fs(KERNEL_DS);
89979 - ret = do_sigaltstack((stack_t __force __user *) (uss_ptr ? &uss : NULL),
89980 - (stack_t __force __user *) &uoss,
89981 + ret = do_sigaltstack((stack_t __force_user *) (uss_ptr ? &uss : NULL),
89982 + (stack_t __force_user *) &uoss,
89983 compat_user_stack_pointer());
89984 set_fs(seg);
89985 if (ret >= 0 && uoss_ptr) {
89986 diff --git a/kernel/smpboot.c b/kernel/smpboot.c
89987 index eb89e18..a4e6792 100644
89988 --- a/kernel/smpboot.c
89989 +++ b/kernel/smpboot.c
89990 @@ -288,7 +288,7 @@ int smpboot_register_percpu_thread(struct smp_hotplug_thread *plug_thread)
89991 }
89992 smpboot_unpark_thread(plug_thread, cpu);
89993 }
89994 - list_add(&plug_thread->list, &hotplug_threads);
89995 + pax_list_add(&plug_thread->list, &hotplug_threads);
89996 out:
89997 mutex_unlock(&smpboot_threads_lock);
89998 return ret;
89999 @@ -305,7 +305,7 @@ void smpboot_unregister_percpu_thread(struct smp_hotplug_thread *plug_thread)
90000 {
90001 get_online_cpus();
90002 mutex_lock(&smpboot_threads_lock);
90003 - list_del(&plug_thread->list);
90004 + pax_list_del(&plug_thread->list);
90005 smpboot_destroy_threads(plug_thread);
90006 mutex_unlock(&smpboot_threads_lock);
90007 put_online_cpus();
90008 diff --git a/kernel/softirq.c b/kernel/softirq.c
90009 index 92f24f5..db41501 100644
90010 --- a/kernel/softirq.c
90011 +++ b/kernel/softirq.c
90012 @@ -53,7 +53,7 @@ irq_cpustat_t irq_stat[NR_CPUS] ____cacheline_aligned;
90013 EXPORT_SYMBOL(irq_stat);
90014 #endif
90015
90016 -static struct softirq_action softirq_vec[NR_SOFTIRQS] __cacheline_aligned_in_smp;
90017 +static struct softirq_action softirq_vec[NR_SOFTIRQS] __read_only __aligned(PAGE_SIZE);
90018
90019 DEFINE_PER_CPU(struct task_struct *, ksoftirqd);
90020
90021 @@ -268,7 +268,7 @@ restart:
90022 kstat_incr_softirqs_this_cpu(vec_nr);
90023
90024 trace_softirq_entry(vec_nr);
90025 - h->action(h);
90026 + h->action();
90027 trace_softirq_exit(vec_nr);
90028 if (unlikely(prev_count != preempt_count())) {
90029 pr_err("huh, entered softirq %u %s %p with preempt_count %08x, exited with %08x?\n",
90030 @@ -428,7 +428,7 @@ void __raise_softirq_irqoff(unsigned int nr)
90031 or_softirq_pending(1UL << nr);
90032 }
90033
90034 -void open_softirq(int nr, void (*action)(struct softirq_action *))
90035 +void __init open_softirq(int nr, void (*action)(void))
90036 {
90037 softirq_vec[nr].action = action;
90038 }
90039 @@ -480,7 +480,7 @@ void __tasklet_hi_schedule_first(struct tasklet_struct *t)
90040 }
90041 EXPORT_SYMBOL(__tasklet_hi_schedule_first);
90042
90043 -static void tasklet_action(struct softirq_action *a)
90044 +static void tasklet_action(void)
90045 {
90046 struct tasklet_struct *list;
90047
90048 @@ -516,7 +516,7 @@ static void tasklet_action(struct softirq_action *a)
90049 }
90050 }
90051
90052 -static void tasklet_hi_action(struct softirq_action *a)
90053 +static __latent_entropy void tasklet_hi_action(void)
90054 {
90055 struct tasklet_struct *list;
90056
90057 @@ -743,7 +743,7 @@ static struct notifier_block cpu_nfb = {
90058 .notifier_call = cpu_callback
90059 };
90060
90061 -static struct smp_hotplug_thread softirq_threads = {
90062 +static struct smp_hotplug_thread softirq_threads __read_only = {
90063 .store = &ksoftirqd,
90064 .thread_should_run = ksoftirqd_should_run,
90065 .thread_fn = run_ksoftirqd,
90066 diff --git a/kernel/sys.c b/kernel/sys.c
90067 index fba0f29..84400e2 100644
90068 --- a/kernel/sys.c
90069 +++ b/kernel/sys.c
90070 @@ -148,6 +148,12 @@ static int set_one_prio(struct task_struct *p, int niceval, int error)
90071 error = -EACCES;
90072 goto out;
90073 }
90074 +
90075 + if (gr_handle_chroot_setpriority(p, niceval)) {
90076 + error = -EACCES;
90077 + goto out;
90078 + }
90079 +
90080 no_nice = security_task_setnice(p, niceval);
90081 if (no_nice) {
90082 error = no_nice;
90083 @@ -351,6 +357,9 @@ SYSCALL_DEFINE2(setregid, gid_t, rgid, gid_t, egid)
90084 goto error;
90085 }
90086
90087 + if (gr_check_group_change(new->gid, new->egid, INVALID_GID))
90088 + goto error;
90089 +
90090 if (rgid != (gid_t) -1 ||
90091 (egid != (gid_t) -1 && !gid_eq(kegid, old->gid)))
90092 new->sgid = new->egid;
90093 @@ -386,6 +395,10 @@ SYSCALL_DEFINE1(setgid, gid_t, gid)
90094 old = current_cred();
90095
90096 retval = -EPERM;
90097 +
90098 + if (gr_check_group_change(kgid, kgid, kgid))
90099 + goto error;
90100 +
90101 if (ns_capable(old->user_ns, CAP_SETGID))
90102 new->gid = new->egid = new->sgid = new->fsgid = kgid;
90103 else if (gid_eq(kgid, old->gid) || gid_eq(kgid, old->sgid))
90104 @@ -403,7 +416,7 @@ error:
90105 /*
90106 * change the user struct in a credentials set to match the new UID
90107 */
90108 -static int set_user(struct cred *new)
90109 +int set_user(struct cred *new)
90110 {
90111 struct user_struct *new_user;
90112
90113 @@ -483,6 +496,9 @@ SYSCALL_DEFINE2(setreuid, uid_t, ruid, uid_t, euid)
90114 goto error;
90115 }
90116
90117 + if (gr_check_user_change(new->uid, new->euid, INVALID_UID))
90118 + goto error;
90119 +
90120 if (!uid_eq(new->uid, old->uid)) {
90121 retval = set_user(new);
90122 if (retval < 0)
90123 @@ -533,6 +549,12 @@ SYSCALL_DEFINE1(setuid, uid_t, uid)
90124 old = current_cred();
90125
90126 retval = -EPERM;
90127 +
90128 + if (gr_check_crash_uid(kuid))
90129 + goto error;
90130 + if (gr_check_user_change(kuid, kuid, kuid))
90131 + goto error;
90132 +
90133 if (ns_capable(old->user_ns, CAP_SETUID)) {
90134 new->suid = new->uid = kuid;
90135 if (!uid_eq(kuid, old->uid)) {
90136 @@ -602,6 +624,9 @@ SYSCALL_DEFINE3(setresuid, uid_t, ruid, uid_t, euid, uid_t, suid)
90137 goto error;
90138 }
90139
90140 + if (gr_check_user_change(kruid, keuid, INVALID_UID))
90141 + goto error;
90142 +
90143 if (ruid != (uid_t) -1) {
90144 new->uid = kruid;
90145 if (!uid_eq(kruid, old->uid)) {
90146 @@ -684,6 +709,9 @@ SYSCALL_DEFINE3(setresgid, gid_t, rgid, gid_t, egid, gid_t, sgid)
90147 goto error;
90148 }
90149
90150 + if (gr_check_group_change(krgid, kegid, INVALID_GID))
90151 + goto error;
90152 +
90153 if (rgid != (gid_t) -1)
90154 new->gid = krgid;
90155 if (egid != (gid_t) -1)
90156 @@ -745,12 +773,16 @@ SYSCALL_DEFINE1(setfsuid, uid_t, uid)
90157 uid_eq(kuid, old->suid) || uid_eq(kuid, old->fsuid) ||
90158 ns_capable(old->user_ns, CAP_SETUID)) {
90159 if (!uid_eq(kuid, old->fsuid)) {
90160 + if (gr_check_user_change(INVALID_UID, INVALID_UID, kuid))
90161 + goto error;
90162 +
90163 new->fsuid = kuid;
90164 if (security_task_fix_setuid(new, old, LSM_SETID_FS) == 0)
90165 goto change_okay;
90166 }
90167 }
90168
90169 +error:
90170 abort_creds(new);
90171 return old_fsuid;
90172
90173 @@ -783,12 +815,16 @@ SYSCALL_DEFINE1(setfsgid, gid_t, gid)
90174 if (gid_eq(kgid, old->gid) || gid_eq(kgid, old->egid) ||
90175 gid_eq(kgid, old->sgid) || gid_eq(kgid, old->fsgid) ||
90176 ns_capable(old->user_ns, CAP_SETGID)) {
90177 + if (gr_check_group_change(INVALID_GID, INVALID_GID, kgid))
90178 + goto error;
90179 +
90180 if (!gid_eq(kgid, old->fsgid)) {
90181 new->fsgid = kgid;
90182 goto change_okay;
90183 }
90184 }
90185
90186 +error:
90187 abort_creds(new);
90188 return old_fsgid;
90189
90190 @@ -1167,19 +1203,19 @@ SYSCALL_DEFINE1(olduname, struct oldold_utsname __user *, name)
90191 return -EFAULT;
90192
90193 down_read(&uts_sem);
90194 - error = __copy_to_user(&name->sysname, &utsname()->sysname,
90195 + error = __copy_to_user(name->sysname, &utsname()->sysname,
90196 __OLD_UTS_LEN);
90197 error |= __put_user(0, name->sysname + __OLD_UTS_LEN);
90198 - error |= __copy_to_user(&name->nodename, &utsname()->nodename,
90199 + error |= __copy_to_user(name->nodename, &utsname()->nodename,
90200 __OLD_UTS_LEN);
90201 error |= __put_user(0, name->nodename + __OLD_UTS_LEN);
90202 - error |= __copy_to_user(&name->release, &utsname()->release,
90203 + error |= __copy_to_user(name->release, &utsname()->release,
90204 __OLD_UTS_LEN);
90205 error |= __put_user(0, name->release + __OLD_UTS_LEN);
90206 - error |= __copy_to_user(&name->version, &utsname()->version,
90207 + error |= __copy_to_user(name->version, &utsname()->version,
90208 __OLD_UTS_LEN);
90209 error |= __put_user(0, name->version + __OLD_UTS_LEN);
90210 - error |= __copy_to_user(&name->machine, &utsname()->machine,
90211 + error |= __copy_to_user(name->machine, &utsname()->machine,
90212 __OLD_UTS_LEN);
90213 error |= __put_user(0, name->machine + __OLD_UTS_LEN);
90214 up_read(&uts_sem);
90215 @@ -1381,6 +1417,13 @@ int do_prlimit(struct task_struct *tsk, unsigned int resource,
90216 */
90217 new_rlim->rlim_cur = 1;
90218 }
90219 + /* Handle the case where a fork and setuid occur and then RLIMIT_NPROC
90220 + is changed to a lower value. Since tasks can be created by the same
90221 + user in between this limit change and an execve by this task, force
90222 + a recheck only for this task by setting PF_NPROC_EXCEEDED
90223 + */
90224 + if (resource == RLIMIT_NPROC && tsk->real_cred->user != INIT_USER)
90225 + tsk->flags |= PF_NPROC_EXCEEDED;
90226 }
90227 if (!retval) {
90228 if (old_rlim)
90229 diff --git a/kernel/sysctl.c b/kernel/sysctl.c
90230 index 74f5b58..65ba165 100644
90231 --- a/kernel/sysctl.c
90232 +++ b/kernel/sysctl.c
90233 @@ -94,7 +94,6 @@
90234
90235
90236 #if defined(CONFIG_SYSCTL)
90237 -
90238 /* External variables not in a header file. */
90239 extern int max_threads;
90240 extern int suid_dumpable;
90241 @@ -115,19 +114,20 @@ extern int sysctl_nr_trim_pages;
90242
90243 /* Constants used for minimum and maximum */
90244 #ifdef CONFIG_LOCKUP_DETECTOR
90245 -static int sixty = 60;
90246 +static int sixty __read_only = 60;
90247 #endif
90248
90249 -static int __maybe_unused neg_one = -1;
90250 +static int __maybe_unused neg_one __read_only = -1;
90251
90252 -static int zero;
90253 -static int __maybe_unused one = 1;
90254 -static int __maybe_unused two = 2;
90255 -static int __maybe_unused four = 4;
90256 -static unsigned long one_ul = 1;
90257 -static int one_hundred = 100;
90258 +static int zero __read_only = 0;
90259 +static int __maybe_unused one __read_only = 1;
90260 +static int __maybe_unused two __read_only = 2;
90261 +static int __maybe_unused three __read_only = 3;
90262 +static int __maybe_unused four __read_only = 4;
90263 +static unsigned long one_ul __read_only = 1;
90264 +static int one_hundred __read_only = 100;
90265 #ifdef CONFIG_PRINTK
90266 -static int ten_thousand = 10000;
90267 +static int ten_thousand __read_only = 10000;
90268 #endif
90269
90270 /* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */
90271 @@ -179,10 +179,8 @@ static int proc_taint(struct ctl_table *table, int write,
90272 void __user *buffer, size_t *lenp, loff_t *ppos);
90273 #endif
90274
90275 -#ifdef CONFIG_PRINTK
90276 static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
90277 void __user *buffer, size_t *lenp, loff_t *ppos);
90278 -#endif
90279
90280 static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
90281 void __user *buffer, size_t *lenp, loff_t *ppos);
90282 @@ -213,6 +211,8 @@ static int sysrq_sysctl_handler(ctl_table *table, int write,
90283
90284 #endif
90285
90286 +extern struct ctl_table grsecurity_table[];
90287 +
90288 static struct ctl_table kern_table[];
90289 static struct ctl_table vm_table[];
90290 static struct ctl_table fs_table[];
90291 @@ -227,6 +227,20 @@ extern struct ctl_table epoll_table[];
90292 int sysctl_legacy_va_layout;
90293 #endif
90294
90295 +#ifdef CONFIG_PAX_SOFTMODE
90296 +static ctl_table pax_table[] = {
90297 + {
90298 + .procname = "softmode",
90299 + .data = &pax_softmode,
90300 + .maxlen = sizeof(unsigned int),
90301 + .mode = 0600,
90302 + .proc_handler = &proc_dointvec,
90303 + },
90304 +
90305 + { }
90306 +};
90307 +#endif
90308 +
90309 /* The default sysctl tables: */
90310
90311 static struct ctl_table sysctl_base_table[] = {
90312 @@ -275,6 +289,22 @@ static int max_extfrag_threshold = 1000;
90313 #endif
90314
90315 static struct ctl_table kern_table[] = {
90316 +#if defined(CONFIG_GRKERNSEC_SYSCTL) || defined(CONFIG_GRKERNSEC_ROFS)
90317 + {
90318 + .procname = "grsecurity",
90319 + .mode = 0500,
90320 + .child = grsecurity_table,
90321 + },
90322 +#endif
90323 +
90324 +#ifdef CONFIG_PAX_SOFTMODE
90325 + {
90326 + .procname = "pax",
90327 + .mode = 0500,
90328 + .child = pax_table,
90329 + },
90330 +#endif
90331 +
90332 {
90333 .procname = "sched_child_runs_first",
90334 .data = &sysctl_sched_child_runs_first,
90335 @@ -630,7 +660,7 @@ static struct ctl_table kern_table[] = {
90336 .data = &modprobe_path,
90337 .maxlen = KMOD_PATH_LEN,
90338 .mode = 0644,
90339 - .proc_handler = proc_dostring,
90340 + .proc_handler = proc_dostring_modpriv,
90341 },
90342 {
90343 .procname = "modules_disabled",
90344 @@ -797,16 +827,20 @@ static struct ctl_table kern_table[] = {
90345 .extra1 = &zero,
90346 .extra2 = &one,
90347 },
90348 +#endif
90349 {
90350 .procname = "kptr_restrict",
90351 .data = &kptr_restrict,
90352 .maxlen = sizeof(int),
90353 .mode = 0644,
90354 .proc_handler = proc_dointvec_minmax_sysadmin,
90355 +#ifdef CONFIG_GRKERNSEC_HIDESYM
90356 + .extra1 = &two,
90357 +#else
90358 .extra1 = &zero,
90359 +#endif
90360 .extra2 = &two,
90361 },
90362 -#endif
90363 {
90364 .procname = "ngroups_max",
90365 .data = &ngroups_max,
90366 @@ -1051,10 +1085,17 @@ static struct ctl_table kern_table[] = {
90367 */
90368 {
90369 .procname = "perf_event_paranoid",
90370 - .data = &sysctl_perf_event_paranoid,
90371 - .maxlen = sizeof(sysctl_perf_event_paranoid),
90372 + .data = &sysctl_perf_event_legitimately_concerned,
90373 + .maxlen = sizeof(sysctl_perf_event_legitimately_concerned),
90374 .mode = 0644,
90375 - .proc_handler = proc_dointvec,
90376 + /* go ahead, be a hero */
90377 + .proc_handler = proc_dointvec_minmax_sysadmin,
90378 + .extra1 = &neg_one,
90379 +#ifdef CONFIG_GRKERNSEC_PERF_HARDEN
90380 + .extra2 = &three,
90381 +#else
90382 + .extra2 = &two,
90383 +#endif
90384 },
90385 {
90386 .procname = "perf_event_mlock_kb",
90387 @@ -1316,6 +1357,13 @@ static struct ctl_table vm_table[] = {
90388 .proc_handler = proc_dointvec_minmax,
90389 .extra1 = &zero,
90390 },
90391 + {
90392 + .procname = "heap_stack_gap",
90393 + .data = &sysctl_heap_stack_gap,
90394 + .maxlen = sizeof(sysctl_heap_stack_gap),
90395 + .mode = 0644,
90396 + .proc_handler = proc_doulongvec_minmax,
90397 + },
90398 #else
90399 {
90400 .procname = "nr_trim_pages",
90401 @@ -1780,6 +1828,16 @@ int proc_dostring(struct ctl_table *table, int write,
90402 buffer, lenp, ppos);
90403 }
90404
90405 +int proc_dostring_modpriv(struct ctl_table *table, int write,
90406 + void __user *buffer, size_t *lenp, loff_t *ppos)
90407 +{
90408 + if (write && !capable(CAP_SYS_MODULE))
90409 + return -EPERM;
90410 +
90411 + return _proc_do_string(table->data, table->maxlen, write,
90412 + buffer, lenp, ppos);
90413 +}
90414 +
90415 static size_t proc_skip_spaces(char **buf)
90416 {
90417 size_t ret;
90418 @@ -1885,6 +1943,8 @@ static int proc_put_long(void __user **buf, size_t *size, unsigned long val,
90419 len = strlen(tmp);
90420 if (len > *size)
90421 len = *size;
90422 + if (len > sizeof(tmp))
90423 + len = sizeof(tmp);
90424 if (copy_to_user(*buf, tmp, len))
90425 return -EFAULT;
90426 *size -= len;
90427 @@ -2049,7 +2109,7 @@ int proc_dointvec(struct ctl_table *table, int write,
90428 static int proc_taint(struct ctl_table *table, int write,
90429 void __user *buffer, size_t *lenp, loff_t *ppos)
90430 {
90431 - struct ctl_table t;
90432 + ctl_table_no_const t;
90433 unsigned long tmptaint = get_taint();
90434 int err;
90435
90436 @@ -2077,7 +2137,6 @@ static int proc_taint(struct ctl_table *table, int write,
90437 return err;
90438 }
90439
90440 -#ifdef CONFIG_PRINTK
90441 static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
90442 void __user *buffer, size_t *lenp, loff_t *ppos)
90443 {
90444 @@ -2086,7 +2145,6 @@ static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
90445
90446 return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
90447 }
90448 -#endif
90449
90450 struct do_proc_dointvec_minmax_conv_param {
90451 int *min;
90452 @@ -2633,6 +2691,12 @@ int proc_dostring(struct ctl_table *table, int write,
90453 return -ENOSYS;
90454 }
90455
90456 +int proc_dostring_modpriv(struct ctl_table *table, int write,
90457 + void __user *buffer, size_t *lenp, loff_t *ppos)
90458 +{
90459 + return -ENOSYS;
90460 +}
90461 +
90462 int proc_dointvec(struct ctl_table *table, int write,
90463 void __user *buffer, size_t *lenp, loff_t *ppos)
90464 {
90465 @@ -2689,5 +2753,6 @@ EXPORT_SYMBOL(proc_dointvec_minmax);
90466 EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
90467 EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
90468 EXPORT_SYMBOL(proc_dostring);
90469 +EXPORT_SYMBOL(proc_dostring_modpriv);
90470 EXPORT_SYMBOL(proc_doulongvec_minmax);
90471 EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);
90472 diff --git a/kernel/taskstats.c b/kernel/taskstats.c
90473 index 13d2f7c..c93d0b0 100644
90474 --- a/kernel/taskstats.c
90475 +++ b/kernel/taskstats.c
90476 @@ -28,9 +28,12 @@
90477 #include <linux/fs.h>
90478 #include <linux/file.h>
90479 #include <linux/pid_namespace.h>
90480 +#include <linux/grsecurity.h>
90481 #include <net/genetlink.h>
90482 #include <linux/atomic.h>
90483
90484 +extern int gr_is_taskstats_denied(int pid);
90485 +
90486 /*
90487 * Maximum length of a cpumask that can be specified in
90488 * the TASKSTATS_CMD_ATTR_REGISTER/DEREGISTER_CPUMASK attribute
90489 @@ -576,6 +579,9 @@ err:
90490
90491 static int taskstats_user_cmd(struct sk_buff *skb, struct genl_info *info)
90492 {
90493 + if (gr_is_taskstats_denied(current->pid))
90494 + return -EACCES;
90495 +
90496 if (info->attrs[TASKSTATS_CMD_ATTR_REGISTER_CPUMASK])
90497 return cmd_attr_register_cpumask(info);
90498 else if (info->attrs[TASKSTATS_CMD_ATTR_DEREGISTER_CPUMASK])
90499 diff --git a/kernel/time.c b/kernel/time.c
90500 index 7c7964c..2a0d412 100644
90501 --- a/kernel/time.c
90502 +++ b/kernel/time.c
90503 @@ -172,6 +172,11 @@ int do_sys_settimeofday(const struct timespec *tv, const struct timezone *tz)
90504 return error;
90505
90506 if (tz) {
90507 + /* we log in do_settimeofday called below, so don't log twice
90508 + */
90509 + if (!tv)
90510 + gr_log_timechange();
90511 +
90512 sys_tz = *tz;
90513 update_vsyscall_tz();
90514 if (firsttime) {
90515 diff --git a/kernel/time/alarmtimer.c b/kernel/time/alarmtimer.c
90516 index 88c9c65..7497ebc 100644
90517 --- a/kernel/time/alarmtimer.c
90518 +++ b/kernel/time/alarmtimer.c
90519 @@ -795,7 +795,7 @@ static int __init alarmtimer_init(void)
90520 struct platform_device *pdev;
90521 int error = 0;
90522 int i;
90523 - struct k_clock alarm_clock = {
90524 + static struct k_clock alarm_clock = {
90525 .clock_getres = alarm_clock_getres,
90526 .clock_get = alarm_clock_get,
90527 .timer_create = alarm_timer_create,
90528 diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
90529 index f7df8ea..0810193 100644
90530 --- a/kernel/time/timekeeping.c
90531 +++ b/kernel/time/timekeeping.c
90532 @@ -15,6 +15,7 @@
90533 #include <linux/init.h>
90534 #include <linux/mm.h>
90535 #include <linux/sched.h>
90536 +#include <linux/grsecurity.h>
90537 #include <linux/syscore_ops.h>
90538 #include <linux/clocksource.h>
90539 #include <linux/jiffies.h>
90540 @@ -502,6 +503,8 @@ int do_settimeofday(const struct timespec *tv)
90541 if (!timespec_valid_strict(tv))
90542 return -EINVAL;
90543
90544 + gr_log_timechange();
90545 +
90546 raw_spin_lock_irqsave(&timekeeper_lock, flags);
90547 write_seqcount_begin(&timekeeper_seq);
90548
90549 diff --git a/kernel/time/timer_list.c b/kernel/time/timer_list.c
90550 index 61ed862..3b52c65 100644
90551 --- a/kernel/time/timer_list.c
90552 +++ b/kernel/time/timer_list.c
90553 @@ -45,12 +45,16 @@ DECLARE_PER_CPU(struct hrtimer_cpu_base, hrtimer_bases);
90554
90555 static void print_name_offset(struct seq_file *m, void *sym)
90556 {
90557 +#ifdef CONFIG_GRKERNSEC_HIDESYM
90558 + SEQ_printf(m, "<%p>", NULL);
90559 +#else
90560 char symname[KSYM_NAME_LEN];
90561
90562 if (lookup_symbol_name((unsigned long)sym, symname) < 0)
90563 SEQ_printf(m, "<%pK>", sym);
90564 else
90565 SEQ_printf(m, "%s", symname);
90566 +#endif
90567 }
90568
90569 static void
90570 @@ -119,7 +123,11 @@ next_one:
90571 static void
90572 print_base(struct seq_file *m, struct hrtimer_clock_base *base, u64 now)
90573 {
90574 +#ifdef CONFIG_GRKERNSEC_HIDESYM
90575 + SEQ_printf(m, " .base: %p\n", NULL);
90576 +#else
90577 SEQ_printf(m, " .base: %pK\n", base);
90578 +#endif
90579 SEQ_printf(m, " .index: %d\n",
90580 base->index);
90581 SEQ_printf(m, " .resolution: %Lu nsecs\n",
90582 @@ -362,7 +370,11 @@ static int __init init_timer_list_procfs(void)
90583 {
90584 struct proc_dir_entry *pe;
90585
90586 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
90587 + pe = proc_create("timer_list", 0400, NULL, &timer_list_fops);
90588 +#else
90589 pe = proc_create("timer_list", 0444, NULL, &timer_list_fops);
90590 +#endif
90591 if (!pe)
90592 return -ENOMEM;
90593 return 0;
90594 diff --git a/kernel/time/timer_stats.c b/kernel/time/timer_stats.c
90595 index 1fb08f2..ca4bb1e 100644
90596 --- a/kernel/time/timer_stats.c
90597 +++ b/kernel/time/timer_stats.c
90598 @@ -116,7 +116,7 @@ static ktime_t time_start, time_stop;
90599 static unsigned long nr_entries;
90600 static struct entry entries[MAX_ENTRIES];
90601
90602 -static atomic_t overflow_count;
90603 +static atomic_unchecked_t overflow_count;
90604
90605 /*
90606 * The entries are in a hash-table, for fast lookup:
90607 @@ -140,7 +140,7 @@ static void reset_entries(void)
90608 nr_entries = 0;
90609 memset(entries, 0, sizeof(entries));
90610 memset(tstat_hash_table, 0, sizeof(tstat_hash_table));
90611 - atomic_set(&overflow_count, 0);
90612 + atomic_set_unchecked(&overflow_count, 0);
90613 }
90614
90615 static struct entry *alloc_entry(void)
90616 @@ -261,7 +261,7 @@ void timer_stats_update_stats(void *timer, pid_t pid, void *startf,
90617 if (likely(entry))
90618 entry->count++;
90619 else
90620 - atomic_inc(&overflow_count);
90621 + atomic_inc_unchecked(&overflow_count);
90622
90623 out_unlock:
90624 raw_spin_unlock_irqrestore(lock, flags);
90625 @@ -269,12 +269,16 @@ void timer_stats_update_stats(void *timer, pid_t pid, void *startf,
90626
90627 static void print_name_offset(struct seq_file *m, unsigned long addr)
90628 {
90629 +#ifdef CONFIG_GRKERNSEC_HIDESYM
90630 + seq_printf(m, "<%p>", NULL);
90631 +#else
90632 char symname[KSYM_NAME_LEN];
90633
90634 if (lookup_symbol_name(addr, symname) < 0)
90635 - seq_printf(m, "<%p>", (void *)addr);
90636 + seq_printf(m, "<%pK>", (void *)addr);
90637 else
90638 seq_printf(m, "%s", symname);
90639 +#endif
90640 }
90641
90642 static int tstats_show(struct seq_file *m, void *v)
90643 @@ -300,8 +304,8 @@ static int tstats_show(struct seq_file *m, void *v)
90644
90645 seq_puts(m, "Timer Stats Version: v0.3\n");
90646 seq_printf(m, "Sample period: %ld.%03ld s\n", period.tv_sec, ms);
90647 - if (atomic_read(&overflow_count))
90648 - seq_printf(m, "Overflow: %d entries\n", atomic_read(&overflow_count));
90649 + if (atomic_read_unchecked(&overflow_count))
90650 + seq_printf(m, "Overflow: %d entries\n", atomic_read_unchecked(&overflow_count));
90651 seq_printf(m, "Collection: %s\n", timer_stats_active ? "active" : "inactive");
90652
90653 for (i = 0; i < nr_entries; i++) {
90654 @@ -417,7 +421,11 @@ static int __init init_tstats_procfs(void)
90655 {
90656 struct proc_dir_entry *pe;
90657
90658 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
90659 + pe = proc_create("timer_stats", 0600, NULL, &tstats_fops);
90660 +#else
90661 pe = proc_create("timer_stats", 0644, NULL, &tstats_fops);
90662 +#endif
90663 if (!pe)
90664 return -ENOMEM;
90665 return 0;
90666 diff --git a/kernel/timer.c b/kernel/timer.c
90667 index 3bb01a3..0e7760e 100644
90668 --- a/kernel/timer.c
90669 +++ b/kernel/timer.c
90670 @@ -1393,7 +1393,7 @@ void update_process_times(int user_tick)
90671 /*
90672 * This function runs timers and the timer-tq in bottom half context.
90673 */
90674 -static void run_timer_softirq(struct softirq_action *h)
90675 +static __latent_entropy void run_timer_softirq(void)
90676 {
90677 struct tvec_base *base = __this_cpu_read(tvec_bases);
90678
90679 @@ -1456,7 +1456,7 @@ static void process_timeout(unsigned long __data)
90680 *
90681 * In all cases the return value is guaranteed to be non-negative.
90682 */
90683 -signed long __sched schedule_timeout(signed long timeout)
90684 +signed long __sched __intentional_overflow(-1) schedule_timeout(signed long timeout)
90685 {
90686 struct timer_list timer;
90687 unsigned long expire;
90688 diff --git a/kernel/torture.c b/kernel/torture.c
90689 index acc9afc..4f9eb49 100644
90690 --- a/kernel/torture.c
90691 +++ b/kernel/torture.c
90692 @@ -489,7 +489,7 @@ static int torture_shutdown_notify(struct notifier_block *unused1,
90693 mutex_lock(&fullstop_mutex);
90694 if (ACCESS_ONCE(fullstop) == FULLSTOP_DONTSTOP) {
90695 VERBOSE_TOROUT_STRING("Unscheduled system shutdown detected");
90696 - ACCESS_ONCE(fullstop) = FULLSTOP_SHUTDOWN;
90697 + ACCESS_ONCE_RW(fullstop) = FULLSTOP_SHUTDOWN;
90698 } else {
90699 pr_warn("Concurrent rmmod and shutdown illegal!\n");
90700 }
90701 @@ -551,11 +551,11 @@ static int torture_stutter(void *arg)
90702 do {
90703 if (!torture_must_stop()) {
90704 schedule_timeout_interruptible(stutter);
90705 - ACCESS_ONCE(stutter_pause_test) = 1;
90706 + ACCESS_ONCE_RW(stutter_pause_test) = 1;
90707 }
90708 if (!torture_must_stop())
90709 schedule_timeout_interruptible(stutter);
90710 - ACCESS_ONCE(stutter_pause_test) = 0;
90711 + ACCESS_ONCE_RW(stutter_pause_test) = 0;
90712 torture_shutdown_absorb("torture_stutter");
90713 } while (!torture_must_stop());
90714 torture_kthread_stopping("torture_stutter");
90715 @@ -636,7 +636,7 @@ bool torture_cleanup(void)
90716 schedule_timeout_uninterruptible(10);
90717 return true;
90718 }
90719 - ACCESS_ONCE(fullstop) = FULLSTOP_RMMOD;
90720 + ACCESS_ONCE_RW(fullstop) = FULLSTOP_RMMOD;
90721 mutex_unlock(&fullstop_mutex);
90722 torture_shutdown_cleanup();
90723 torture_shuffle_cleanup();
90724 diff --git a/kernel/trace/blktrace.c b/kernel/trace/blktrace.c
90725 index c1bd4ad..4b861dc 100644
90726 --- a/kernel/trace/blktrace.c
90727 +++ b/kernel/trace/blktrace.c
90728 @@ -328,7 +328,7 @@ static ssize_t blk_dropped_read(struct file *filp, char __user *buffer,
90729 struct blk_trace *bt = filp->private_data;
90730 char buf[16];
90731
90732 - snprintf(buf, sizeof(buf), "%u\n", atomic_read(&bt->dropped));
90733 + snprintf(buf, sizeof(buf), "%u\n", atomic_read_unchecked(&bt->dropped));
90734
90735 return simple_read_from_buffer(buffer, count, ppos, buf, strlen(buf));
90736 }
90737 @@ -386,7 +386,7 @@ static int blk_subbuf_start_callback(struct rchan_buf *buf, void *subbuf,
90738 return 1;
90739
90740 bt = buf->chan->private_data;
90741 - atomic_inc(&bt->dropped);
90742 + atomic_inc_unchecked(&bt->dropped);
90743 return 0;
90744 }
90745
90746 @@ -487,7 +487,7 @@ int do_blk_trace_setup(struct request_queue *q, char *name, dev_t dev,
90747
90748 bt->dir = dir;
90749 bt->dev = dev;
90750 - atomic_set(&bt->dropped, 0);
90751 + atomic_set_unchecked(&bt->dropped, 0);
90752 INIT_LIST_HEAD(&bt->running_list);
90753
90754 ret = -EIO;
90755 diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
90756 index 4a54a25..7ca9c89 100644
90757 --- a/kernel/trace/ftrace.c
90758 +++ b/kernel/trace/ftrace.c
90759 @@ -1960,12 +1960,17 @@ ftrace_code_disable(struct module *mod, struct dyn_ftrace *rec)
90760 if (unlikely(ftrace_disabled))
90761 return 0;
90762
90763 + ret = ftrace_arch_code_modify_prepare();
90764 + FTRACE_WARN_ON(ret);
90765 + if (ret)
90766 + return 0;
90767 +
90768 ret = ftrace_make_nop(mod, rec, MCOUNT_ADDR);
90769 + FTRACE_WARN_ON(ftrace_arch_code_modify_post_process());
90770 if (ret) {
90771 ftrace_bug(ret, ip);
90772 - return 0;
90773 }
90774 - return 1;
90775 + return ret ? 0 : 1;
90776 }
90777
90778 /*
90779 @@ -4195,8 +4200,10 @@ static int ftrace_process_locs(struct module *mod,
90780 if (!count)
90781 return 0;
90782
90783 + pax_open_kernel();
90784 sort(start, count, sizeof(*start),
90785 ftrace_cmp_ips, ftrace_swap_ips);
90786 + pax_close_kernel();
90787
90788 start_pg = ftrace_allocate_pages(count);
90789 if (!start_pg)
90790 @@ -4908,8 +4915,6 @@ ftrace_enable_sysctl(struct ctl_table *table, int write,
90791 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
90792
90793 static int ftrace_graph_active;
90794 -static struct notifier_block ftrace_suspend_notifier;
90795 -
90796 int ftrace_graph_entry_stub(struct ftrace_graph_ent *trace)
90797 {
90798 return 0;
90799 @@ -5085,6 +5090,10 @@ static void update_function_graph_func(void)
90800 ftrace_graph_entry = ftrace_graph_entry_test;
90801 }
90802
90803 +static struct notifier_block ftrace_suspend_notifier = {
90804 + .notifier_call = ftrace_suspend_notifier_call
90805 +};
90806 +
90807 int register_ftrace_graph(trace_func_graph_ret_t retfunc,
90808 trace_func_graph_ent_t entryfunc)
90809 {
90810 @@ -5098,7 +5107,6 @@ int register_ftrace_graph(trace_func_graph_ret_t retfunc,
90811 goto out;
90812 }
90813
90814 - ftrace_suspend_notifier.notifier_call = ftrace_suspend_notifier_call;
90815 register_pm_notifier(&ftrace_suspend_notifier);
90816
90817 ftrace_graph_active++;
90818 diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
90819 index c634868..00d0d19 100644
90820 --- a/kernel/trace/ring_buffer.c
90821 +++ b/kernel/trace/ring_buffer.c
90822 @@ -352,9 +352,9 @@ struct buffer_data_page {
90823 */
90824 struct buffer_page {
90825 struct list_head list; /* list of buffer pages */
90826 - local_t write; /* index for next write */
90827 + local_unchecked_t write; /* index for next write */
90828 unsigned read; /* index for next read */
90829 - local_t entries; /* entries on this page */
90830 + local_unchecked_t entries; /* entries on this page */
90831 unsigned long real_end; /* real end of data */
90832 struct buffer_data_page *page; /* Actual data page */
90833 };
90834 @@ -473,8 +473,8 @@ struct ring_buffer_per_cpu {
90835 unsigned long last_overrun;
90836 local_t entries_bytes;
90837 local_t entries;
90838 - local_t overrun;
90839 - local_t commit_overrun;
90840 + local_unchecked_t overrun;
90841 + local_unchecked_t commit_overrun;
90842 local_t dropped_events;
90843 local_t committing;
90844 local_t commits;
90845 @@ -992,8 +992,8 @@ static int rb_tail_page_update(struct ring_buffer_per_cpu *cpu_buffer,
90846 *
90847 * We add a counter to the write field to denote this.
90848 */
90849 - old_write = local_add_return(RB_WRITE_INTCNT, &next_page->write);
90850 - old_entries = local_add_return(RB_WRITE_INTCNT, &next_page->entries);
90851 + old_write = local_add_return_unchecked(RB_WRITE_INTCNT, &next_page->write);
90852 + old_entries = local_add_return_unchecked(RB_WRITE_INTCNT, &next_page->entries);
90853
90854 /*
90855 * Just make sure we have seen our old_write and synchronize
90856 @@ -1021,8 +1021,8 @@ static int rb_tail_page_update(struct ring_buffer_per_cpu *cpu_buffer,
90857 * cmpxchg to only update if an interrupt did not already
90858 * do it for us. If the cmpxchg fails, we don't care.
90859 */
90860 - (void)local_cmpxchg(&next_page->write, old_write, val);
90861 - (void)local_cmpxchg(&next_page->entries, old_entries, eval);
90862 + (void)local_cmpxchg_unchecked(&next_page->write, old_write, val);
90863 + (void)local_cmpxchg_unchecked(&next_page->entries, old_entries, eval);
90864
90865 /*
90866 * No need to worry about races with clearing out the commit.
90867 @@ -1389,12 +1389,12 @@ static void rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer);
90868
90869 static inline unsigned long rb_page_entries(struct buffer_page *bpage)
90870 {
90871 - return local_read(&bpage->entries) & RB_WRITE_MASK;
90872 + return local_read_unchecked(&bpage->entries) & RB_WRITE_MASK;
90873 }
90874
90875 static inline unsigned long rb_page_write(struct buffer_page *bpage)
90876 {
90877 - return local_read(&bpage->write) & RB_WRITE_MASK;
90878 + return local_read_unchecked(&bpage->write) & RB_WRITE_MASK;
90879 }
90880
90881 static int
90882 @@ -1489,7 +1489,7 @@ rb_remove_pages(struct ring_buffer_per_cpu *cpu_buffer, unsigned int nr_pages)
90883 * bytes consumed in ring buffer from here.
90884 * Increment overrun to account for the lost events.
90885 */
90886 - local_add(page_entries, &cpu_buffer->overrun);
90887 + local_add_unchecked(page_entries, &cpu_buffer->overrun);
90888 local_sub(BUF_PAGE_SIZE, &cpu_buffer->entries_bytes);
90889 }
90890
90891 @@ -2067,7 +2067,7 @@ rb_handle_head_page(struct ring_buffer_per_cpu *cpu_buffer,
90892 * it is our responsibility to update
90893 * the counters.
90894 */
90895 - local_add(entries, &cpu_buffer->overrun);
90896 + local_add_unchecked(entries, &cpu_buffer->overrun);
90897 local_sub(BUF_PAGE_SIZE, &cpu_buffer->entries_bytes);
90898
90899 /*
90900 @@ -2217,7 +2217,7 @@ rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer,
90901 if (tail == BUF_PAGE_SIZE)
90902 tail_page->real_end = 0;
90903
90904 - local_sub(length, &tail_page->write);
90905 + local_sub_unchecked(length, &tail_page->write);
90906 return;
90907 }
90908
90909 @@ -2252,7 +2252,7 @@ rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer,
90910 rb_event_set_padding(event);
90911
90912 /* Set the write back to the previous setting */
90913 - local_sub(length, &tail_page->write);
90914 + local_sub_unchecked(length, &tail_page->write);
90915 return;
90916 }
90917
90918 @@ -2264,7 +2264,7 @@ rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer,
90919
90920 /* Set write to end of buffer */
90921 length = (tail + length) - BUF_PAGE_SIZE;
90922 - local_sub(length, &tail_page->write);
90923 + local_sub_unchecked(length, &tail_page->write);
90924 }
90925
90926 /*
90927 @@ -2290,7 +2290,7 @@ rb_move_tail(struct ring_buffer_per_cpu *cpu_buffer,
90928 * about it.
90929 */
90930 if (unlikely(next_page == commit_page)) {
90931 - local_inc(&cpu_buffer->commit_overrun);
90932 + local_inc_unchecked(&cpu_buffer->commit_overrun);
90933 goto out_reset;
90934 }
90935
90936 @@ -2346,7 +2346,7 @@ rb_move_tail(struct ring_buffer_per_cpu *cpu_buffer,
90937 cpu_buffer->tail_page) &&
90938 (cpu_buffer->commit_page ==
90939 cpu_buffer->reader_page))) {
90940 - local_inc(&cpu_buffer->commit_overrun);
90941 + local_inc_unchecked(&cpu_buffer->commit_overrun);
90942 goto out_reset;
90943 }
90944 }
90945 @@ -2394,7 +2394,7 @@ __rb_reserve_next(struct ring_buffer_per_cpu *cpu_buffer,
90946 length += RB_LEN_TIME_EXTEND;
90947
90948 tail_page = cpu_buffer->tail_page;
90949 - write = local_add_return(length, &tail_page->write);
90950 + write = local_add_return_unchecked(length, &tail_page->write);
90951
90952 /* set write to only the index of the write */
90953 write &= RB_WRITE_MASK;
90954 @@ -2418,7 +2418,7 @@ __rb_reserve_next(struct ring_buffer_per_cpu *cpu_buffer,
90955 kmemcheck_annotate_bitfield(event, bitfield);
90956 rb_update_event(cpu_buffer, event, length, add_timestamp, delta);
90957
90958 - local_inc(&tail_page->entries);
90959 + local_inc_unchecked(&tail_page->entries);
90960
90961 /*
90962 * If this is the first commit on the page, then update
90963 @@ -2451,7 +2451,7 @@ rb_try_to_discard(struct ring_buffer_per_cpu *cpu_buffer,
90964
90965 if (bpage->page == (void *)addr && rb_page_write(bpage) == old_index) {
90966 unsigned long write_mask =
90967 - local_read(&bpage->write) & ~RB_WRITE_MASK;
90968 + local_read_unchecked(&bpage->write) & ~RB_WRITE_MASK;
90969 unsigned long event_length = rb_event_length(event);
90970 /*
90971 * This is on the tail page. It is possible that
90972 @@ -2461,7 +2461,7 @@ rb_try_to_discard(struct ring_buffer_per_cpu *cpu_buffer,
90973 */
90974 old_index += write_mask;
90975 new_index += write_mask;
90976 - index = local_cmpxchg(&bpage->write, old_index, new_index);
90977 + index = local_cmpxchg_unchecked(&bpage->write, old_index, new_index);
90978 if (index == old_index) {
90979 /* update counters */
90980 local_sub(event_length, &cpu_buffer->entries_bytes);
90981 @@ -2853,7 +2853,7 @@ rb_decrement_entry(struct ring_buffer_per_cpu *cpu_buffer,
90982
90983 /* Do the likely case first */
90984 if (likely(bpage->page == (void *)addr)) {
90985 - local_dec(&bpage->entries);
90986 + local_dec_unchecked(&bpage->entries);
90987 return;
90988 }
90989
90990 @@ -2865,7 +2865,7 @@ rb_decrement_entry(struct ring_buffer_per_cpu *cpu_buffer,
90991 start = bpage;
90992 do {
90993 if (bpage->page == (void *)addr) {
90994 - local_dec(&bpage->entries);
90995 + local_dec_unchecked(&bpage->entries);
90996 return;
90997 }
90998 rb_inc_page(cpu_buffer, &bpage);
90999 @@ -3149,7 +3149,7 @@ static inline unsigned long
91000 rb_num_of_entries(struct ring_buffer_per_cpu *cpu_buffer)
91001 {
91002 return local_read(&cpu_buffer->entries) -
91003 - (local_read(&cpu_buffer->overrun) + cpu_buffer->read);
91004 + (local_read_unchecked(&cpu_buffer->overrun) + cpu_buffer->read);
91005 }
91006
91007 /**
91008 @@ -3238,7 +3238,7 @@ unsigned long ring_buffer_overrun_cpu(struct ring_buffer *buffer, int cpu)
91009 return 0;
91010
91011 cpu_buffer = buffer->buffers[cpu];
91012 - ret = local_read(&cpu_buffer->overrun);
91013 + ret = local_read_unchecked(&cpu_buffer->overrun);
91014
91015 return ret;
91016 }
91017 @@ -3261,7 +3261,7 @@ ring_buffer_commit_overrun_cpu(struct ring_buffer *buffer, int cpu)
91018 return 0;
91019
91020 cpu_buffer = buffer->buffers[cpu];
91021 - ret = local_read(&cpu_buffer->commit_overrun);
91022 + ret = local_read_unchecked(&cpu_buffer->commit_overrun);
91023
91024 return ret;
91025 }
91026 @@ -3346,7 +3346,7 @@ unsigned long ring_buffer_overruns(struct ring_buffer *buffer)
91027 /* if you care about this being correct, lock the buffer */
91028 for_each_buffer_cpu(buffer, cpu) {
91029 cpu_buffer = buffer->buffers[cpu];
91030 - overruns += local_read(&cpu_buffer->overrun);
91031 + overruns += local_read_unchecked(&cpu_buffer->overrun);
91032 }
91033
91034 return overruns;
91035 @@ -3522,8 +3522,8 @@ rb_get_reader_page(struct ring_buffer_per_cpu *cpu_buffer)
91036 /*
91037 * Reset the reader page to size zero.
91038 */
91039 - local_set(&cpu_buffer->reader_page->write, 0);
91040 - local_set(&cpu_buffer->reader_page->entries, 0);
91041 + local_set_unchecked(&cpu_buffer->reader_page->write, 0);
91042 + local_set_unchecked(&cpu_buffer->reader_page->entries, 0);
91043 local_set(&cpu_buffer->reader_page->page->commit, 0);
91044 cpu_buffer->reader_page->real_end = 0;
91045
91046 @@ -3557,7 +3557,7 @@ rb_get_reader_page(struct ring_buffer_per_cpu *cpu_buffer)
91047 * want to compare with the last_overrun.
91048 */
91049 smp_mb();
91050 - overwrite = local_read(&(cpu_buffer->overrun));
91051 + overwrite = local_read_unchecked(&(cpu_buffer->overrun));
91052
91053 /*
91054 * Here's the tricky part.
91055 @@ -4127,8 +4127,8 @@ rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer)
91056
91057 cpu_buffer->head_page
91058 = list_entry(cpu_buffer->pages, struct buffer_page, list);
91059 - local_set(&cpu_buffer->head_page->write, 0);
91060 - local_set(&cpu_buffer->head_page->entries, 0);
91061 + local_set_unchecked(&cpu_buffer->head_page->write, 0);
91062 + local_set_unchecked(&cpu_buffer->head_page->entries, 0);
91063 local_set(&cpu_buffer->head_page->page->commit, 0);
91064
91065 cpu_buffer->head_page->read = 0;
91066 @@ -4138,14 +4138,14 @@ rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer)
91067
91068 INIT_LIST_HEAD(&cpu_buffer->reader_page->list);
91069 INIT_LIST_HEAD(&cpu_buffer->new_pages);
91070 - local_set(&cpu_buffer->reader_page->write, 0);
91071 - local_set(&cpu_buffer->reader_page->entries, 0);
91072 + local_set_unchecked(&cpu_buffer->reader_page->write, 0);
91073 + local_set_unchecked(&cpu_buffer->reader_page->entries, 0);
91074 local_set(&cpu_buffer->reader_page->page->commit, 0);
91075 cpu_buffer->reader_page->read = 0;
91076
91077 local_set(&cpu_buffer->entries_bytes, 0);
91078 - local_set(&cpu_buffer->overrun, 0);
91079 - local_set(&cpu_buffer->commit_overrun, 0);
91080 + local_set_unchecked(&cpu_buffer->overrun, 0);
91081 + local_set_unchecked(&cpu_buffer->commit_overrun, 0);
91082 local_set(&cpu_buffer->dropped_events, 0);
91083 local_set(&cpu_buffer->entries, 0);
91084 local_set(&cpu_buffer->committing, 0);
91085 @@ -4550,8 +4550,8 @@ int ring_buffer_read_page(struct ring_buffer *buffer,
91086 rb_init_page(bpage);
91087 bpage = reader->page;
91088 reader->page = *data_page;
91089 - local_set(&reader->write, 0);
91090 - local_set(&reader->entries, 0);
91091 + local_set_unchecked(&reader->write, 0);
91092 + local_set_unchecked(&reader->entries, 0);
91093 reader->read = 0;
91094 *data_page = bpage;
91095
91096 diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
91097 index 737b0ef..bd21ea6 100644
91098 --- a/kernel/trace/trace.c
91099 +++ b/kernel/trace/trace.c
91100 @@ -3448,7 +3448,7 @@ int trace_keep_overwrite(struct tracer *tracer, u32 mask, int set)
91101 return 0;
91102 }
91103
91104 -int set_tracer_flag(struct trace_array *tr, unsigned int mask, int enabled)
91105 +int set_tracer_flag(struct trace_array *tr, unsigned long mask, int enabled)
91106 {
91107 /* do nothing if flag is already set */
91108 if (!!(trace_flags & mask) == !!enabled)
91109 diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h
91110 index 2e29d7b..61367d7 100644
91111 --- a/kernel/trace/trace.h
91112 +++ b/kernel/trace/trace.h
91113 @@ -1264,7 +1264,7 @@ extern const char *__stop___tracepoint_str[];
91114 void trace_printk_init_buffers(void);
91115 void trace_printk_start_comm(void);
91116 int trace_keep_overwrite(struct tracer *tracer, u32 mask, int set);
91117 -int set_tracer_flag(struct trace_array *tr, unsigned int mask, int enabled);
91118 +int set_tracer_flag(struct trace_array *tr, unsigned long mask, int enabled);
91119
91120 /*
91121 * Normal trace_printk() and friends allocates special buffers
91122 diff --git a/kernel/trace/trace_clock.c b/kernel/trace/trace_clock.c
91123 index 26dc348..8708ca7 100644
91124 --- a/kernel/trace/trace_clock.c
91125 +++ b/kernel/trace/trace_clock.c
91126 @@ -123,7 +123,7 @@ u64 notrace trace_clock_global(void)
91127 return now;
91128 }
91129
91130 -static atomic64_t trace_counter;
91131 +static atomic64_unchecked_t trace_counter;
91132
91133 /*
91134 * trace_clock_counter(): simply an atomic counter.
91135 @@ -132,5 +132,5 @@ static atomic64_t trace_counter;
91136 */
91137 u64 notrace trace_clock_counter(void)
91138 {
91139 - return atomic64_add_return(1, &trace_counter);
91140 + return atomic64_inc_return_unchecked(&trace_counter);
91141 }
91142 diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
91143 index 3ddfd8f..41a10fe 100644
91144 --- a/kernel/trace/trace_events.c
91145 +++ b/kernel/trace/trace_events.c
91146 @@ -1718,7 +1718,6 @@ __trace_early_add_new_event(struct ftrace_event_call *call,
91147 return 0;
91148 }
91149
91150 -struct ftrace_module_file_ops;
91151 static void __add_event_to_tracers(struct ftrace_event_call *call);
91152
91153 /* Add an additional event_call dynamically */
91154 diff --git a/kernel/trace/trace_mmiotrace.c b/kernel/trace/trace_mmiotrace.c
91155 index 0abd9b8..6a663a2 100644
91156 --- a/kernel/trace/trace_mmiotrace.c
91157 +++ b/kernel/trace/trace_mmiotrace.c
91158 @@ -24,7 +24,7 @@ struct header_iter {
91159 static struct trace_array *mmio_trace_array;
91160 static bool overrun_detected;
91161 static unsigned long prev_overruns;
91162 -static atomic_t dropped_count;
91163 +static atomic_unchecked_t dropped_count;
91164
91165 static void mmio_reset_data(struct trace_array *tr)
91166 {
91167 @@ -127,7 +127,7 @@ static void mmio_close(struct trace_iterator *iter)
91168
91169 static unsigned long count_overruns(struct trace_iterator *iter)
91170 {
91171 - unsigned long cnt = atomic_xchg(&dropped_count, 0);
91172 + unsigned long cnt = atomic_xchg_unchecked(&dropped_count, 0);
91173 unsigned long over = ring_buffer_overruns(iter->trace_buffer->buffer);
91174
91175 if (over > prev_overruns)
91176 @@ -317,7 +317,7 @@ static void __trace_mmiotrace_rw(struct trace_array *tr,
91177 event = trace_buffer_lock_reserve(buffer, TRACE_MMIO_RW,
91178 sizeof(*entry), 0, pc);
91179 if (!event) {
91180 - atomic_inc(&dropped_count);
91181 + atomic_inc_unchecked(&dropped_count);
91182 return;
91183 }
91184 entry = ring_buffer_event_data(event);
91185 @@ -347,7 +347,7 @@ static void __trace_mmiotrace_map(struct trace_array *tr,
91186 event = trace_buffer_lock_reserve(buffer, TRACE_MMIO_MAP,
91187 sizeof(*entry), 0, pc);
91188 if (!event) {
91189 - atomic_inc(&dropped_count);
91190 + atomic_inc_unchecked(&dropped_count);
91191 return;
91192 }
91193 entry = ring_buffer_event_data(event);
91194 diff --git a/kernel/trace/trace_output.c b/kernel/trace/trace_output.c
91195 index a436de1..f64dde2 100644
91196 --- a/kernel/trace/trace_output.c
91197 +++ b/kernel/trace/trace_output.c
91198 @@ -294,7 +294,7 @@ int trace_seq_path(struct trace_seq *s, const struct path *path)
91199
91200 p = d_path(path, s->buffer + s->len, PAGE_SIZE - s->len);
91201 if (!IS_ERR(p)) {
91202 - p = mangle_path(s->buffer + s->len, p, "\n");
91203 + p = mangle_path(s->buffer + s->len, p, "\n\\");
91204 if (p) {
91205 s->len = p - s->buffer;
91206 return 1;
91207 @@ -939,14 +939,16 @@ int register_ftrace_event(struct trace_event *event)
91208 goto out;
91209 }
91210
91211 + pax_open_kernel();
91212 if (event->funcs->trace == NULL)
91213 - event->funcs->trace = trace_nop_print;
91214 + *(void **)&event->funcs->trace = trace_nop_print;
91215 if (event->funcs->raw == NULL)
91216 - event->funcs->raw = trace_nop_print;
91217 + *(void **)&event->funcs->raw = trace_nop_print;
91218 if (event->funcs->hex == NULL)
91219 - event->funcs->hex = trace_nop_print;
91220 + *(void **)&event->funcs->hex = trace_nop_print;
91221 if (event->funcs->binary == NULL)
91222 - event->funcs->binary = trace_nop_print;
91223 + *(void **)&event->funcs->binary = trace_nop_print;
91224 + pax_close_kernel();
91225
91226 key = event->type & (EVENT_HASHSIZE - 1);
91227
91228 diff --git a/kernel/trace/trace_stack.c b/kernel/trace/trace_stack.c
91229 index 21b320e..40607bc 100644
91230 --- a/kernel/trace/trace_stack.c
91231 +++ b/kernel/trace/trace_stack.c
91232 @@ -69,7 +69,7 @@ check_stack(unsigned long ip, unsigned long *stack)
91233 return;
91234
91235 /* we do not handle interrupt stacks yet */
91236 - if (!object_is_on_stack(stack))
91237 + if (!object_starts_on_stack(stack))
91238 return;
91239
91240 local_irq_save(flags);
91241 diff --git a/kernel/user_namespace.c b/kernel/user_namespace.c
91242 index bf71b4b..04dee68 100644
91243 --- a/kernel/user_namespace.c
91244 +++ b/kernel/user_namespace.c
91245 @@ -82,6 +82,21 @@ int create_user_ns(struct cred *new)
91246 !kgid_has_mapping(parent_ns, group))
91247 return -EPERM;
91248
91249 +#ifdef CONFIG_GRKERNSEC
91250 + /*
91251 + * This doesn't really inspire confidence:
91252 + * http://marc.info/?l=linux-kernel&m=135543612731939&w=2
91253 + * http://marc.info/?l=linux-kernel&m=135545831607095&w=2
91254 + * Increases kernel attack surface in areas developers
91255 + * previously cared little about ("low importance due
91256 + * to requiring "root" capability")
91257 + * To be removed when this code receives *proper* review
91258 + */
91259 + if (!capable(CAP_SYS_ADMIN) || !capable(CAP_SETUID) ||
91260 + !capable(CAP_SETGID))
91261 + return -EPERM;
91262 +#endif
91263 +
91264 ns = kmem_cache_zalloc(user_ns_cachep, GFP_KERNEL);
91265 if (!ns)
91266 return -ENOMEM;
91267 @@ -865,7 +880,7 @@ static int userns_install(struct nsproxy *nsproxy, void *ns)
91268 if (atomic_read(&current->mm->mm_users) > 1)
91269 return -EINVAL;
91270
91271 - if (current->fs->users != 1)
91272 + if (atomic_read(&current->fs->users) != 1)
91273 return -EINVAL;
91274
91275 if (!ns_capable(user_ns, CAP_SYS_ADMIN))
91276 diff --git a/kernel/utsname_sysctl.c b/kernel/utsname_sysctl.c
91277 index 4f69f9a..7c6f8f8 100644
91278 --- a/kernel/utsname_sysctl.c
91279 +++ b/kernel/utsname_sysctl.c
91280 @@ -47,7 +47,7 @@ static void put_uts(ctl_table *table, int write, void *which)
91281 static int proc_do_uts_string(ctl_table *table, int write,
91282 void __user *buffer, size_t *lenp, loff_t *ppos)
91283 {
91284 - struct ctl_table uts_table;
91285 + ctl_table_no_const uts_table;
91286 int r;
91287 memcpy(&uts_table, table, sizeof(uts_table));
91288 uts_table.data = get_uts(table, write);
91289 diff --git a/kernel/watchdog.c b/kernel/watchdog.c
91290 index 516203e..ecc58d1 100644
91291 --- a/kernel/watchdog.c
91292 +++ b/kernel/watchdog.c
91293 @@ -479,7 +479,7 @@ static int watchdog_nmi_enable(unsigned int cpu) { return 0; }
91294 static void watchdog_nmi_disable(unsigned int cpu) { return; }
91295 #endif /* CONFIG_HARDLOCKUP_DETECTOR */
91296
91297 -static struct smp_hotplug_thread watchdog_threads = {
91298 +static struct smp_hotplug_thread watchdog_threads __read_only = {
91299 .store = &softlockup_watchdog,
91300 .thread_should_run = watchdog_should_run,
91301 .thread_fn = watchdog,
91302 diff --git a/kernel/workqueue.c b/kernel/workqueue.c
91303 index 8edc8718..b6a70b9 100644
91304 --- a/kernel/workqueue.c
91305 +++ b/kernel/workqueue.c
91306 @@ -4709,7 +4709,7 @@ static void rebind_workers(struct worker_pool *pool)
91307 WARN_ON_ONCE(!(worker_flags & WORKER_UNBOUND));
91308 worker_flags |= WORKER_REBOUND;
91309 worker_flags &= ~WORKER_UNBOUND;
91310 - ACCESS_ONCE(worker->flags) = worker_flags;
91311 + ACCESS_ONCE_RW(worker->flags) = worker_flags;
91312 }
91313
91314 spin_unlock_irq(&pool->lock);
91315 diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
91316 index 819ac51..1c8a65e 100644
91317 --- a/lib/Kconfig.debug
91318 +++ b/lib/Kconfig.debug
91319 @@ -853,7 +853,7 @@ config DEBUG_MUTEXES
91320
91321 config DEBUG_WW_MUTEX_SLOWPATH
91322 bool "Wait/wound mutex debugging: Slowpath testing"
91323 - depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
91324 + depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
91325 select DEBUG_LOCK_ALLOC
91326 select DEBUG_SPINLOCK
91327 select DEBUG_MUTEXES
91328 @@ -866,7 +866,7 @@ config DEBUG_WW_MUTEX_SLOWPATH
91329
91330 config DEBUG_LOCK_ALLOC
91331 bool "Lock debugging: detect incorrect freeing of live locks"
91332 - depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
91333 + depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
91334 select DEBUG_SPINLOCK
91335 select DEBUG_MUTEXES
91336 select LOCKDEP
91337 @@ -880,7 +880,7 @@ config DEBUG_LOCK_ALLOC
91338
91339 config PROVE_LOCKING
91340 bool "Lock debugging: prove locking correctness"
91341 - depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
91342 + depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
91343 select LOCKDEP
91344 select DEBUG_SPINLOCK
91345 select DEBUG_MUTEXES
91346 @@ -931,7 +931,7 @@ config LOCKDEP
91347
91348 config LOCK_STAT
91349 bool "Lock usage statistics"
91350 - depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
91351 + depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
91352 select LOCKDEP
91353 select DEBUG_SPINLOCK
91354 select DEBUG_MUTEXES
91355 @@ -1403,6 +1403,7 @@ config LATENCYTOP
91356 depends on DEBUG_KERNEL
91357 depends on STACKTRACE_SUPPORT
91358 depends on PROC_FS
91359 + depends on !GRKERNSEC_HIDESYM
91360 select FRAME_POINTER if !MIPS && !PPC && !S390 && !MICROBLAZE && !ARM_UNWIND && !ARC
91361 select KALLSYMS
91362 select KALLSYMS_ALL
91363 @@ -1419,7 +1420,7 @@ config ARCH_HAS_DEBUG_STRICT_USER_COPY_CHECKS
91364 config DEBUG_STRICT_USER_COPY_CHECKS
91365 bool "Strict user copy size checks"
91366 depends on ARCH_HAS_DEBUG_STRICT_USER_COPY_CHECKS
91367 - depends on DEBUG_KERNEL && !TRACE_BRANCH_PROFILING
91368 + depends on DEBUG_KERNEL && !TRACE_BRANCH_PROFILING && !PAX_SIZE_OVERFLOW
91369 help
91370 Enabling this option turns a certain set of sanity checks for user
91371 copy operations into compile time failures.
91372 @@ -1538,7 +1539,7 @@ endmenu # runtime tests
91373
91374 config PROVIDE_OHCI1394_DMA_INIT
91375 bool "Remote debugging over FireWire early on boot"
91376 - depends on PCI && X86
91377 + depends on PCI && X86 && !GRKERNSEC
91378 help
91379 If you want to debug problems which hang or crash the kernel early
91380 on boot and the crashing machine has a FireWire port, you can use
91381 diff --git a/lib/Makefile b/lib/Makefile
91382 index 0cd7b68..e149e37 100644
91383 --- a/lib/Makefile
91384 +++ b/lib/Makefile
91385 @@ -52,7 +52,7 @@ obj-$(CONFIG_GENERIC_HWEIGHT) += hweight.o
91386 obj-$(CONFIG_BTREE) += btree.o
91387 obj-$(CONFIG_ASSOCIATIVE_ARRAY) += assoc_array.o
91388 obj-$(CONFIG_DEBUG_PREEMPT) += smp_processor_id.o
91389 -obj-$(CONFIG_DEBUG_LIST) += list_debug.o
91390 +obj-y += list_debug.o
91391 obj-$(CONFIG_DEBUG_OBJECTS) += debugobjects.o
91392
91393 ifneq ($(CONFIG_HAVE_DEC_LOCK),y)
91394 diff --git a/lib/average.c b/lib/average.c
91395 index 114d1be..ab0350c 100644
91396 --- a/lib/average.c
91397 +++ b/lib/average.c
91398 @@ -55,7 +55,7 @@ struct ewma *ewma_add(struct ewma *avg, unsigned long val)
91399 {
91400 unsigned long internal = ACCESS_ONCE(avg->internal);
91401
91402 - ACCESS_ONCE(avg->internal) = internal ?
91403 + ACCESS_ONCE_RW(avg->internal) = internal ?
91404 (((internal << avg->weight) - internal) +
91405 (val << avg->factor)) >> avg->weight :
91406 (val << avg->factor);
91407 diff --git a/lib/bitmap.c b/lib/bitmap.c
91408 index 06f7e4f..f3cf2b0 100644
91409 --- a/lib/bitmap.c
91410 +++ b/lib/bitmap.c
91411 @@ -422,7 +422,7 @@ int __bitmap_parse(const char *buf, unsigned int buflen,
91412 {
91413 int c, old_c, totaldigits, ndigits, nchunks, nbits;
91414 u32 chunk;
91415 - const char __user __force *ubuf = (const char __user __force *)buf;
91416 + const char __user *ubuf = (const char __force_user *)buf;
91417
91418 bitmap_zero(maskp, nmaskbits);
91419
91420 @@ -507,7 +507,7 @@ int bitmap_parse_user(const char __user *ubuf,
91421 {
91422 if (!access_ok(VERIFY_READ, ubuf, ulen))
91423 return -EFAULT;
91424 - return __bitmap_parse((const char __force *)ubuf,
91425 + return __bitmap_parse((const char __force_kernel *)ubuf,
91426 ulen, 1, maskp, nmaskbits);
91427
91428 }
91429 @@ -598,7 +598,7 @@ static int __bitmap_parselist(const char *buf, unsigned int buflen,
91430 {
91431 unsigned a, b;
91432 int c, old_c, totaldigits;
91433 - const char __user __force *ubuf = (const char __user __force *)buf;
91434 + const char __user *ubuf = (const char __force_user *)buf;
91435 int exp_digit, in_range;
91436
91437 totaldigits = c = 0;
91438 @@ -698,7 +698,7 @@ int bitmap_parselist_user(const char __user *ubuf,
91439 {
91440 if (!access_ok(VERIFY_READ, ubuf, ulen))
91441 return -EFAULT;
91442 - return __bitmap_parselist((const char __force *)ubuf,
91443 + return __bitmap_parselist((const char __force_kernel *)ubuf,
91444 ulen, 1, maskp, nmaskbits);
91445 }
91446 EXPORT_SYMBOL(bitmap_parselist_user);
91447 diff --git a/lib/bug.c b/lib/bug.c
91448 index 1686034..a9c00c8 100644
91449 --- a/lib/bug.c
91450 +++ b/lib/bug.c
91451 @@ -134,6 +134,8 @@ enum bug_trap_type report_bug(unsigned long bugaddr, struct pt_regs *regs)
91452 return BUG_TRAP_TYPE_NONE;
91453
91454 bug = find_bug(bugaddr);
91455 + if (!bug)
91456 + return BUG_TRAP_TYPE_NONE;
91457
91458 file = NULL;
91459 line = 0;
91460 diff --git a/lib/debugobjects.c b/lib/debugobjects.c
91461 index e0731c3..ad66444 100644
91462 --- a/lib/debugobjects.c
91463 +++ b/lib/debugobjects.c
91464 @@ -286,7 +286,7 @@ static void debug_object_is_on_stack(void *addr, int onstack)
91465 if (limit > 4)
91466 return;
91467
91468 - is_on_stack = object_is_on_stack(addr);
91469 + is_on_stack = object_starts_on_stack(addr);
91470 if (is_on_stack == onstack)
91471 return;
91472
91473 diff --git a/lib/div64.c b/lib/div64.c
91474 index 4382ad7..08aa558 100644
91475 --- a/lib/div64.c
91476 +++ b/lib/div64.c
91477 @@ -59,7 +59,7 @@ uint32_t __attribute__((weak)) __div64_32(uint64_t *n, uint32_t base)
91478 EXPORT_SYMBOL(__div64_32);
91479
91480 #ifndef div_s64_rem
91481 -s64 div_s64_rem(s64 dividend, s32 divisor, s32 *remainder)
91482 +s64 __intentional_overflow(-1) div_s64_rem(s64 dividend, s32 divisor, s32 *remainder)
91483 {
91484 u64 quotient;
91485
91486 @@ -130,7 +130,7 @@ EXPORT_SYMBOL(div64_u64_rem);
91487 * 'http://www.hackersdelight.org/HDcode/newCode/divDouble.c.txt'
91488 */
91489 #ifndef div64_u64
91490 -u64 div64_u64(u64 dividend, u64 divisor)
91491 +u64 __intentional_overflow(-1) div64_u64(u64 dividend, u64 divisor)
91492 {
91493 u32 high = divisor >> 32;
91494 u64 quot;
91495 diff --git a/lib/dma-debug.c b/lib/dma-debug.c
91496 index 98f2d7e..899da5c 100644
91497 --- a/lib/dma-debug.c
91498 +++ b/lib/dma-debug.c
91499 @@ -971,7 +971,7 @@ static int dma_debug_device_change(struct notifier_block *nb, unsigned long acti
91500
91501 void dma_debug_add_bus(struct bus_type *bus)
91502 {
91503 - struct notifier_block *nb;
91504 + notifier_block_no_const *nb;
91505
91506 if (global_disable)
91507 return;
91508 @@ -1148,7 +1148,7 @@ static void check_unmap(struct dma_debug_entry *ref)
91509
91510 static void check_for_stack(struct device *dev, void *addr)
91511 {
91512 - if (object_is_on_stack(addr))
91513 + if (object_starts_on_stack(addr))
91514 err_printk(dev, NULL, "DMA-API: device driver maps memory from"
91515 "stack [addr=%p]\n", addr);
91516 }
91517 diff --git a/lib/hash.c b/lib/hash.c
91518 index fea973f..386626f 100644
91519 --- a/lib/hash.c
91520 +++ b/lib/hash.c
91521 @@ -14,7 +14,7 @@
91522 #include <linux/hash.h>
91523 #include <linux/cache.h>
91524
91525 -static struct fast_hash_ops arch_hash_ops __read_mostly = {
91526 +static struct fast_hash_ops arch_hash_ops __read_only = {
91527 .hash = jhash,
91528 .hash2 = jhash2,
91529 };
91530 diff --git a/lib/inflate.c b/lib/inflate.c
91531 index 013a761..c28f3fc 100644
91532 --- a/lib/inflate.c
91533 +++ b/lib/inflate.c
91534 @@ -269,7 +269,7 @@ static void free(void *where)
91535 malloc_ptr = free_mem_ptr;
91536 }
91537 #else
91538 -#define malloc(a) kmalloc(a, GFP_KERNEL)
91539 +#define malloc(a) kmalloc((a), GFP_KERNEL)
91540 #define free(a) kfree(a)
91541 #endif
91542
91543 diff --git a/lib/ioremap.c b/lib/ioremap.c
91544 index 0c9216c..863bd89 100644
91545 --- a/lib/ioremap.c
91546 +++ b/lib/ioremap.c
91547 @@ -38,7 +38,7 @@ static inline int ioremap_pmd_range(pud_t *pud, unsigned long addr,
91548 unsigned long next;
91549
91550 phys_addr -= addr;
91551 - pmd = pmd_alloc(&init_mm, pud, addr);
91552 + pmd = pmd_alloc_kernel(&init_mm, pud, addr);
91553 if (!pmd)
91554 return -ENOMEM;
91555 do {
91556 @@ -56,7 +56,7 @@ static inline int ioremap_pud_range(pgd_t *pgd, unsigned long addr,
91557 unsigned long next;
91558
91559 phys_addr -= addr;
91560 - pud = pud_alloc(&init_mm, pgd, addr);
91561 + pud = pud_alloc_kernel(&init_mm, pgd, addr);
91562 if (!pud)
91563 return -ENOMEM;
91564 do {
91565 diff --git a/lib/is_single_threaded.c b/lib/is_single_threaded.c
91566 index bd2bea9..6b3c95e 100644
91567 --- a/lib/is_single_threaded.c
91568 +++ b/lib/is_single_threaded.c
91569 @@ -22,6 +22,9 @@ bool current_is_single_threaded(void)
91570 struct task_struct *p, *t;
91571 bool ret;
91572
91573 + if (!mm)
91574 + return true;
91575 +
91576 if (atomic_read(&task->signal->live) != 1)
91577 return false;
91578
91579 diff --git a/lib/kobject.c b/lib/kobject.c
91580 index 58751bb..93a1853 100644
91581 --- a/lib/kobject.c
91582 +++ b/lib/kobject.c
91583 @@ -931,9 +931,9 @@ EXPORT_SYMBOL_GPL(kset_create_and_add);
91584
91585
91586 static DEFINE_SPINLOCK(kobj_ns_type_lock);
91587 -static const struct kobj_ns_type_operations *kobj_ns_ops_tbl[KOBJ_NS_TYPES];
91588 +static const struct kobj_ns_type_operations *kobj_ns_ops_tbl[KOBJ_NS_TYPES] __read_only;
91589
91590 -int kobj_ns_type_register(const struct kobj_ns_type_operations *ops)
91591 +int __init kobj_ns_type_register(const struct kobj_ns_type_operations *ops)
91592 {
91593 enum kobj_ns_type type = ops->type;
91594 int error;
91595 diff --git a/lib/list_debug.c b/lib/list_debug.c
91596 index c24c2f7..f0296f4 100644
91597 --- a/lib/list_debug.c
91598 +++ b/lib/list_debug.c
91599 @@ -11,7 +11,9 @@
91600 #include <linux/bug.h>
91601 #include <linux/kernel.h>
91602 #include <linux/rculist.h>
91603 +#include <linux/mm.h>
91604
91605 +#ifdef CONFIG_DEBUG_LIST
91606 /*
91607 * Insert a new entry between two known consecutive entries.
91608 *
91609 @@ -19,21 +21,40 @@
91610 * the prev/next entries already!
91611 */
91612
91613 +static bool __list_add_debug(struct list_head *new,
91614 + struct list_head *prev,
91615 + struct list_head *next)
91616 +{
91617 + if (unlikely(next->prev != prev)) {
91618 + printk(KERN_ERR "list_add corruption. next->prev should be "
91619 + "prev (%p), but was %p. (next=%p).\n",
91620 + prev, next->prev, next);
91621 + BUG();
91622 + return false;
91623 + }
91624 + if (unlikely(prev->next != next)) {
91625 + printk(KERN_ERR "list_add corruption. prev->next should be "
91626 + "next (%p), but was %p. (prev=%p).\n",
91627 + next, prev->next, prev);
91628 + BUG();
91629 + return false;
91630 + }
91631 + if (unlikely(new == prev || new == next)) {
91632 + printk(KERN_ERR "list_add double add: new=%p, prev=%p, next=%p.\n",
91633 + new, prev, next);
91634 + BUG();
91635 + return false;
91636 + }
91637 + return true;
91638 +}
91639 +
91640 void __list_add(struct list_head *new,
91641 - struct list_head *prev,
91642 - struct list_head *next)
91643 + struct list_head *prev,
91644 + struct list_head *next)
91645 {
91646 - WARN(next->prev != prev,
91647 - "list_add corruption. next->prev should be "
91648 - "prev (%p), but was %p. (next=%p).\n",
91649 - prev, next->prev, next);
91650 - WARN(prev->next != next,
91651 - "list_add corruption. prev->next should be "
91652 - "next (%p), but was %p. (prev=%p).\n",
91653 - next, prev->next, prev);
91654 - WARN(new == prev || new == next,
91655 - "list_add double add: new=%p, prev=%p, next=%p.\n",
91656 - new, prev, next);
91657 + if (!__list_add_debug(new, prev, next))
91658 + return;
91659 +
91660 next->prev = new;
91661 new->next = next;
91662 new->prev = prev;
91663 @@ -41,28 +62,46 @@ void __list_add(struct list_head *new,
91664 }
91665 EXPORT_SYMBOL(__list_add);
91666
91667 -void __list_del_entry(struct list_head *entry)
91668 +static bool __list_del_entry_debug(struct list_head *entry)
91669 {
91670 struct list_head *prev, *next;
91671
91672 prev = entry->prev;
91673 next = entry->next;
91674
91675 - if (WARN(next == LIST_POISON1,
91676 - "list_del corruption, %p->next is LIST_POISON1 (%p)\n",
91677 - entry, LIST_POISON1) ||
91678 - WARN(prev == LIST_POISON2,
91679 - "list_del corruption, %p->prev is LIST_POISON2 (%p)\n",
91680 - entry, LIST_POISON2) ||
91681 - WARN(prev->next != entry,
91682 - "list_del corruption. prev->next should be %p, "
91683 - "but was %p\n", entry, prev->next) ||
91684 - WARN(next->prev != entry,
91685 - "list_del corruption. next->prev should be %p, "
91686 - "but was %p\n", entry, next->prev))
91687 + if (unlikely(next == LIST_POISON1)) {
91688 + printk(KERN_ERR "list_del corruption, %p->next is LIST_POISON1 (%p)\n",
91689 + entry, LIST_POISON1);
91690 + BUG();
91691 + return false;
91692 + }
91693 + if (unlikely(prev == LIST_POISON2)) {
91694 + printk(KERN_ERR "list_del corruption, %p->prev is LIST_POISON2 (%p)\n",
91695 + entry, LIST_POISON2);
91696 + BUG();
91697 + return false;
91698 + }
91699 + if (unlikely(entry->prev->next != entry)) {
91700 + printk(KERN_ERR "list_del corruption. prev->next should be %p, "
91701 + "but was %p\n", entry, prev->next);
91702 + BUG();
91703 + return false;
91704 + }
91705 + if (unlikely(entry->next->prev != entry)) {
91706 + printk(KERN_ERR "list_del corruption. next->prev should be %p, "
91707 + "but was %p\n", entry, next->prev);
91708 + BUG();
91709 + return false;
91710 + }
91711 + return true;
91712 +}
91713 +
91714 +void __list_del_entry(struct list_head *entry)
91715 +{
91716 + if (!__list_del_entry_debug(entry))
91717 return;
91718
91719 - __list_del(prev, next);
91720 + __list_del(entry->prev, entry->next);
91721 }
91722 EXPORT_SYMBOL(__list_del_entry);
91723
91724 @@ -86,15 +125,85 @@ EXPORT_SYMBOL(list_del);
91725 void __list_add_rcu(struct list_head *new,
91726 struct list_head *prev, struct list_head *next)
91727 {
91728 - WARN(next->prev != prev,
91729 - "list_add_rcu corruption. next->prev should be prev (%p), but was %p. (next=%p).\n",
91730 - prev, next->prev, next);
91731 - WARN(prev->next != next,
91732 - "list_add_rcu corruption. prev->next should be next (%p), but was %p. (prev=%p).\n",
91733 - next, prev->next, prev);
91734 + if (!__list_add_debug(new, prev, next))
91735 + return;
91736 +
91737 new->next = next;
91738 new->prev = prev;
91739 rcu_assign_pointer(list_next_rcu(prev), new);
91740 next->prev = new;
91741 }
91742 EXPORT_SYMBOL(__list_add_rcu);
91743 +#endif
91744 +
91745 +void __pax_list_add(struct list_head *new, struct list_head *prev, struct list_head *next)
91746 +{
91747 +#ifdef CONFIG_DEBUG_LIST
91748 + if (!__list_add_debug(new, prev, next))
91749 + return;
91750 +#endif
91751 +
91752 + pax_open_kernel();
91753 + next->prev = new;
91754 + new->next = next;
91755 + new->prev = prev;
91756 + prev->next = new;
91757 + pax_close_kernel();
91758 +}
91759 +EXPORT_SYMBOL(__pax_list_add);
91760 +
91761 +void pax_list_del(struct list_head *entry)
91762 +{
91763 +#ifdef CONFIG_DEBUG_LIST
91764 + if (!__list_del_entry_debug(entry))
91765 + return;
91766 +#endif
91767 +
91768 + pax_open_kernel();
91769 + __list_del(entry->prev, entry->next);
91770 + entry->next = LIST_POISON1;
91771 + entry->prev = LIST_POISON2;
91772 + pax_close_kernel();
91773 +}
91774 +EXPORT_SYMBOL(pax_list_del);
91775 +
91776 +void pax_list_del_init(struct list_head *entry)
91777 +{
91778 + pax_open_kernel();
91779 + __list_del(entry->prev, entry->next);
91780 + INIT_LIST_HEAD(entry);
91781 + pax_close_kernel();
91782 +}
91783 +EXPORT_SYMBOL(pax_list_del_init);
91784 +
91785 +void __pax_list_add_rcu(struct list_head *new,
91786 + struct list_head *prev, struct list_head *next)
91787 +{
91788 +#ifdef CONFIG_DEBUG_LIST
91789 + if (!__list_add_debug(new, prev, next))
91790 + return;
91791 +#endif
91792 +
91793 + pax_open_kernel();
91794 + new->next = next;
91795 + new->prev = prev;
91796 + rcu_assign_pointer(list_next_rcu(prev), new);
91797 + next->prev = new;
91798 + pax_close_kernel();
91799 +}
91800 +EXPORT_SYMBOL(__pax_list_add_rcu);
91801 +
91802 +void pax_list_del_rcu(struct list_head *entry)
91803 +{
91804 +#ifdef CONFIG_DEBUG_LIST
91805 + if (!__list_del_entry_debug(entry))
91806 + return;
91807 +#endif
91808 +
91809 + pax_open_kernel();
91810 + __list_del(entry->prev, entry->next);
91811 + entry->next = LIST_POISON1;
91812 + entry->prev = LIST_POISON2;
91813 + pax_close_kernel();
91814 +}
91815 +EXPORT_SYMBOL(pax_list_del_rcu);
91816 diff --git a/lib/percpu-refcount.c b/lib/percpu-refcount.c
91817 index 963b703..438bc51 100644
91818 --- a/lib/percpu-refcount.c
91819 +++ b/lib/percpu-refcount.c
91820 @@ -29,7 +29,7 @@
91821 * can't hit 0 before we've added up all the percpu refs.
91822 */
91823
91824 -#define PCPU_COUNT_BIAS (1U << 31)
91825 +#define PCPU_COUNT_BIAS (1U << 30)
91826
91827 /**
91828 * percpu_ref_init - initialize a percpu refcount
91829 diff --git a/lib/radix-tree.c b/lib/radix-tree.c
91830 index 9599aa7..9cf6c72 100644
91831 --- a/lib/radix-tree.c
91832 +++ b/lib/radix-tree.c
91833 @@ -66,7 +66,7 @@ struct radix_tree_preload {
91834 int nr;
91835 struct radix_tree_node *nodes[RADIX_TREE_PRELOAD_SIZE];
91836 };
91837 -static DEFINE_PER_CPU(struct radix_tree_preload, radix_tree_preloads) = { 0, };
91838 +static DEFINE_PER_CPU(struct radix_tree_preload, radix_tree_preloads);
91839
91840 static inline void *ptr_to_indirect(void *ptr)
91841 {
91842 diff --git a/lib/random32.c b/lib/random32.c
91843 index fa5da61..35fe9af 100644
91844 --- a/lib/random32.c
91845 +++ b/lib/random32.c
91846 @@ -42,7 +42,7 @@
91847 static void __init prandom_state_selftest(void);
91848 #endif
91849
91850 -static DEFINE_PER_CPU(struct rnd_state, net_rand_state);
91851 +static DEFINE_PER_CPU(struct rnd_state, net_rand_state) __latent_entropy;
91852
91853 /**
91854 * prandom_u32_state - seeded pseudo-random number generator.
91855 diff --git a/lib/rbtree.c b/lib/rbtree.c
91856 index 65f4eff..2cfa167 100644
91857 --- a/lib/rbtree.c
91858 +++ b/lib/rbtree.c
91859 @@ -380,7 +380,9 @@ static inline void dummy_copy(struct rb_node *old, struct rb_node *new) {}
91860 static inline void dummy_rotate(struct rb_node *old, struct rb_node *new) {}
91861
91862 static const struct rb_augment_callbacks dummy_callbacks = {
91863 - dummy_propagate, dummy_copy, dummy_rotate
91864 + .propagate = dummy_propagate,
91865 + .copy = dummy_copy,
91866 + .rotate = dummy_rotate
91867 };
91868
91869 void rb_insert_color(struct rb_node *node, struct rb_root *root)
91870 diff --git a/lib/show_mem.c b/lib/show_mem.c
91871 index 0922579..9d7adb9 100644
91872 --- a/lib/show_mem.c
91873 +++ b/lib/show_mem.c
91874 @@ -44,6 +44,6 @@ void show_mem(unsigned int filter)
91875 quicklist_total_size());
91876 #endif
91877 #ifdef CONFIG_MEMORY_FAILURE
91878 - printk("%lu pages hwpoisoned\n", atomic_long_read(&num_poisoned_pages));
91879 + printk("%lu pages hwpoisoned\n", atomic_long_read_unchecked(&num_poisoned_pages));
91880 #endif
91881 }
91882 diff --git a/lib/strncpy_from_user.c b/lib/strncpy_from_user.c
91883 index bb2b201..46abaf9 100644
91884 --- a/lib/strncpy_from_user.c
91885 +++ b/lib/strncpy_from_user.c
91886 @@ -21,7 +21,7 @@
91887 */
91888 static inline long do_strncpy_from_user(char *dst, const char __user *src, long count, unsigned long max)
91889 {
91890 - const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
91891 + static const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
91892 long res = 0;
91893
91894 /*
91895 diff --git a/lib/strnlen_user.c b/lib/strnlen_user.c
91896 index a28df52..3d55877 100644
91897 --- a/lib/strnlen_user.c
91898 +++ b/lib/strnlen_user.c
91899 @@ -26,7 +26,7 @@
91900 */
91901 static inline long do_strnlen_user(const char __user *src, unsigned long count, unsigned long max)
91902 {
91903 - const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
91904 + static const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
91905 long align, res = 0;
91906 unsigned long c;
91907
91908 diff --git a/lib/swiotlb.c b/lib/swiotlb.c
91909 index b604b83..c0547f6 100644
91910 --- a/lib/swiotlb.c
91911 +++ b/lib/swiotlb.c
91912 @@ -674,7 +674,7 @@ EXPORT_SYMBOL(swiotlb_alloc_coherent);
91913
91914 void
91915 swiotlb_free_coherent(struct device *hwdev, size_t size, void *vaddr,
91916 - dma_addr_t dev_addr)
91917 + dma_addr_t dev_addr, struct dma_attrs *attrs)
91918 {
91919 phys_addr_t paddr = dma_to_phys(hwdev, dev_addr);
91920
91921 diff --git a/lib/usercopy.c b/lib/usercopy.c
91922 index 4f5b1dd..7cab418 100644
91923 --- a/lib/usercopy.c
91924 +++ b/lib/usercopy.c
91925 @@ -7,3 +7,9 @@ void copy_from_user_overflow(void)
91926 WARN(1, "Buffer overflow detected!\n");
91927 }
91928 EXPORT_SYMBOL(copy_from_user_overflow);
91929 +
91930 +void copy_to_user_overflow(void)
91931 +{
91932 + WARN(1, "Buffer overflow detected!\n");
91933 +}
91934 +EXPORT_SYMBOL(copy_to_user_overflow);
91935 diff --git a/lib/vsprintf.c b/lib/vsprintf.c
91936 index 0648291..42bf42b 100644
91937 --- a/lib/vsprintf.c
91938 +++ b/lib/vsprintf.c
91939 @@ -16,6 +16,9 @@
91940 * - scnprintf and vscnprintf
91941 */
91942
91943 +#ifdef CONFIG_GRKERNSEC_HIDESYM
91944 +#define __INCLUDED_BY_HIDESYM 1
91945 +#endif
91946 #include <stdarg.h>
91947 #include <linux/module.h> /* for KSYM_SYMBOL_LEN */
91948 #include <linux/types.h>
91949 @@ -1183,7 +1186,11 @@ char *address_val(char *buf, char *end, const void *addr,
91950 return number(buf, end, num, spec);
91951 }
91952
91953 +#ifdef CONFIG_GRKERNSEC_HIDESYM
91954 +int kptr_restrict __read_mostly = 2;
91955 +#else
91956 int kptr_restrict __read_mostly;
91957 +#endif
91958
91959 /*
91960 * Show a '%p' thing. A kernel extension is that the '%p' is followed
91961 @@ -1196,6 +1203,7 @@ int kptr_restrict __read_mostly;
91962 * - 'f' For simple symbolic function names without offset
91963 * - 'S' For symbolic direct pointers with offset
91964 * - 's' For symbolic direct pointers without offset
91965 + * - 'A' For symbolic direct pointers with offset approved for use with GRKERNSEC_HIDESYM
91966 * - '[FfSs]R' as above with __builtin_extract_return_addr() translation
91967 * - 'B' For backtraced symbolic direct pointers with offset
91968 * - 'R' For decoded struct resource, e.g., [mem 0x0-0x1f 64bit pref]
91969 @@ -1263,12 +1271,12 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
91970
91971 if (!ptr && *fmt != 'K') {
91972 /*
91973 - * Print (null) with the same width as a pointer so it makes
91974 + * Print (nil) with the same width as a pointer so it makes
91975 * tabular output look nice.
91976 */
91977 if (spec.field_width == -1)
91978 spec.field_width = default_width;
91979 - return string(buf, end, "(null)", spec);
91980 + return string(buf, end, "(nil)", spec);
91981 }
91982
91983 switch (*fmt) {
91984 @@ -1278,6 +1286,12 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
91985 /* Fallthrough */
91986 case 'S':
91987 case 's':
91988 +#ifdef CONFIG_GRKERNSEC_HIDESYM
91989 + break;
91990 +#else
91991 + return symbol_string(buf, end, ptr, spec, fmt);
91992 +#endif
91993 + case 'A':
91994 case 'B':
91995 return symbol_string(buf, end, ptr, spec, fmt);
91996 case 'R':
91997 @@ -1333,6 +1347,8 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
91998 va_end(va);
91999 return buf;
92000 }
92001 + case 'P':
92002 + break;
92003 case 'K':
92004 /*
92005 * %pK cannot be used in IRQ context because its test
92006 @@ -1390,6 +1406,21 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
92007 ((const struct file *)ptr)->f_path.dentry,
92008 spec, fmt);
92009 }
92010 +
92011 +#ifdef CONFIG_GRKERNSEC_HIDESYM
92012 + /* 'P' = approved pointers to copy to userland,
92013 + as in the /proc/kallsyms case, as we make it display nothing
92014 + for non-root users, and the real contents for root users
92015 + Also ignore 'K' pointers, since we force their NULLing for non-root users
92016 + above
92017 + */
92018 + if ((unsigned long)ptr > TASK_SIZE && *fmt != 'P' && *fmt != 'K' && is_usercopy_object(buf)) {
92019 + printk(KERN_ALERT "grsec: kernel infoleak detected! Please report this log to spender@grsecurity.net.\n");
92020 + dump_stack();
92021 + ptr = NULL;
92022 + }
92023 +#endif
92024 +
92025 spec.flags |= SMALL;
92026 if (spec.field_width == -1) {
92027 spec.field_width = default_width;
92028 @@ -2089,11 +2120,11 @@ int bstr_printf(char *buf, size_t size, const char *fmt, const u32 *bin_buf)
92029 typeof(type) value; \
92030 if (sizeof(type) == 8) { \
92031 args = PTR_ALIGN(args, sizeof(u32)); \
92032 - *(u32 *)&value = *(u32 *)args; \
92033 - *((u32 *)&value + 1) = *(u32 *)(args + 4); \
92034 + *(u32 *)&value = *(const u32 *)args; \
92035 + *((u32 *)&value + 1) = *(const u32 *)(args + 4); \
92036 } else { \
92037 args = PTR_ALIGN(args, sizeof(type)); \
92038 - value = *(typeof(type) *)args; \
92039 + value = *(const typeof(type) *)args; \
92040 } \
92041 args += sizeof(type); \
92042 value; \
92043 @@ -2156,7 +2187,7 @@ int bstr_printf(char *buf, size_t size, const char *fmt, const u32 *bin_buf)
92044 case FORMAT_TYPE_STR: {
92045 const char *str_arg = args;
92046 args += strlen(str_arg) + 1;
92047 - str = string(str, end, (char *)str_arg, spec);
92048 + str = string(str, end, str_arg, spec);
92049 break;
92050 }
92051
92052 diff --git a/localversion-grsec b/localversion-grsec
92053 new file mode 100644
92054 index 0000000..7cd6065
92055 --- /dev/null
92056 +++ b/localversion-grsec
92057 @@ -0,0 +1 @@
92058 +-grsec
92059 diff --git a/mm/Kconfig b/mm/Kconfig
92060 index 1b5a95f..e8068bf 100644
92061 --- a/mm/Kconfig
92062 +++ b/mm/Kconfig
92063 @@ -327,10 +327,11 @@ config KSM
92064 root has set /sys/kernel/mm/ksm/run to 1 (if CONFIG_SYSFS is set).
92065
92066 config DEFAULT_MMAP_MIN_ADDR
92067 - int "Low address space to protect from user allocation"
92068 + int "Low address space to protect from user allocation"
92069 depends on MMU
92070 - default 4096
92071 - help
92072 + default 32768 if ALPHA || ARM || PARISC || SPARC32
92073 + default 65536
92074 + help
92075 This is the portion of low virtual memory which should be protected
92076 from userspace allocation. Keeping a user from writing to low pages
92077 can help reduce the impact of kernel NULL pointer bugs.
92078 @@ -361,7 +362,7 @@ config MEMORY_FAILURE
92079
92080 config HWPOISON_INJECT
92081 tristate "HWPoison pages injector"
92082 - depends on MEMORY_FAILURE && DEBUG_KERNEL && PROC_FS
92083 + depends on MEMORY_FAILURE && DEBUG_KERNEL && PROC_FS && !GRKERNSEC
92084 select PROC_PAGE_MONITOR
92085
92086 config NOMMU_INITIAL_TRIM_EXCESS
92087 diff --git a/mm/backing-dev.c b/mm/backing-dev.c
92088 index 09d9591..165bb75 100644
92089 --- a/mm/backing-dev.c
92090 +++ b/mm/backing-dev.c
92091 @@ -12,7 +12,7 @@
92092 #include <linux/device.h>
92093 #include <trace/events/writeback.h>
92094
92095 -static atomic_long_t bdi_seq = ATOMIC_LONG_INIT(0);
92096 +static atomic_long_unchecked_t bdi_seq = ATOMIC_LONG_INIT(0);
92097
92098 struct backing_dev_info default_backing_dev_info = {
92099 .name = "default",
92100 @@ -533,7 +533,7 @@ int bdi_setup_and_register(struct backing_dev_info *bdi, char *name,
92101 return err;
92102
92103 err = bdi_register(bdi, NULL, "%.28s-%ld", name,
92104 - atomic_long_inc_return(&bdi_seq));
92105 + atomic_long_inc_return_unchecked(&bdi_seq));
92106 if (err) {
92107 bdi_destroy(bdi);
92108 return err;
92109 diff --git a/mm/filemap.c b/mm/filemap.c
92110 index 088358c..bb415bf 100644
92111 --- a/mm/filemap.c
92112 +++ b/mm/filemap.c
92113 @@ -2125,7 +2125,7 @@ int generic_file_mmap(struct file * file, struct vm_area_struct * vma)
92114 struct address_space *mapping = file->f_mapping;
92115
92116 if (!mapping->a_ops->readpage)
92117 - return -ENOEXEC;
92118 + return -ENODEV;
92119 file_accessed(file);
92120 vma->vm_ops = &generic_file_vm_ops;
92121 return 0;
92122 @@ -2303,6 +2303,7 @@ inline int generic_write_checks(struct file *file, loff_t *pos, size_t *count, i
92123 *pos = i_size_read(inode);
92124
92125 if (limit != RLIM_INFINITY) {
92126 + gr_learn_resource(current, RLIMIT_FSIZE,*pos, 0);
92127 if (*pos >= limit) {
92128 send_sig(SIGXFSZ, current, 0);
92129 return -EFBIG;
92130 diff --git a/mm/fremap.c b/mm/fremap.c
92131 index 34feba6..315fe78 100644
92132 --- a/mm/fremap.c
92133 +++ b/mm/fremap.c
92134 @@ -179,6 +179,11 @@ SYSCALL_DEFINE5(remap_file_pages, unsigned long, start, unsigned long, size,
92135 retry:
92136 vma = find_vma(mm, start);
92137
92138 +#ifdef CONFIG_PAX_SEGMEXEC
92139 + if (vma && (mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_flags & VM_MAYEXEC))
92140 + goto out;
92141 +#endif
92142 +
92143 /*
92144 * Make sure the vma is shared, that it supports prefaulting,
92145 * and that the remapped range is valid and fully within
92146 diff --git a/mm/highmem.c b/mm/highmem.c
92147 index b32b70c..e512eb0 100644
92148 --- a/mm/highmem.c
92149 +++ b/mm/highmem.c
92150 @@ -138,8 +138,9 @@ static void flush_all_zero_pkmaps(void)
92151 * So no dangers, even with speculative execution.
92152 */
92153 page = pte_page(pkmap_page_table[i]);
92154 + pax_open_kernel();
92155 pte_clear(&init_mm, PKMAP_ADDR(i), &pkmap_page_table[i]);
92156 -
92157 + pax_close_kernel();
92158 set_page_address(page, NULL);
92159 need_flush = 1;
92160 }
92161 @@ -198,9 +199,11 @@ start:
92162 }
92163 }
92164 vaddr = PKMAP_ADDR(last_pkmap_nr);
92165 +
92166 + pax_open_kernel();
92167 set_pte_at(&init_mm, vaddr,
92168 &(pkmap_page_table[last_pkmap_nr]), mk_pte(page, kmap_prot));
92169 -
92170 + pax_close_kernel();
92171 pkmap_count[last_pkmap_nr] = 1;
92172 set_page_address(page, (void *)vaddr);
92173
92174 diff --git a/mm/hugetlb.c b/mm/hugetlb.c
92175 index c82290b..863d466 100644
92176 --- a/mm/hugetlb.c
92177 +++ b/mm/hugetlb.c
92178 @@ -2107,6 +2107,7 @@ static int hugetlb_sysctl_handler_common(bool obey_mempolicy,
92179 struct hstate *h = &default_hstate;
92180 unsigned long tmp;
92181 int ret;
92182 + ctl_table_no_const hugetlb_table;
92183
92184 if (!hugepages_supported())
92185 return -ENOTSUPP;
92186 @@ -2116,9 +2117,10 @@ static int hugetlb_sysctl_handler_common(bool obey_mempolicy,
92187 if (write && h->order >= MAX_ORDER)
92188 return -EINVAL;
92189
92190 - table->data = &tmp;
92191 - table->maxlen = sizeof(unsigned long);
92192 - ret = proc_doulongvec_minmax(table, write, buffer, length, ppos);
92193 + hugetlb_table = *table;
92194 + hugetlb_table.data = &tmp;
92195 + hugetlb_table.maxlen = sizeof(unsigned long);
92196 + ret = proc_doulongvec_minmax(&hugetlb_table, write, buffer, length, ppos);
92197 if (ret)
92198 goto out;
92199
92200 @@ -2163,6 +2165,7 @@ int hugetlb_overcommit_handler(struct ctl_table *table, int write,
92201 struct hstate *h = &default_hstate;
92202 unsigned long tmp;
92203 int ret;
92204 + ctl_table_no_const hugetlb_table;
92205
92206 if (!hugepages_supported())
92207 return -ENOTSUPP;
92208 @@ -2172,9 +2175,10 @@ int hugetlb_overcommit_handler(struct ctl_table *table, int write,
92209 if (write && h->order >= MAX_ORDER)
92210 return -EINVAL;
92211
92212 - table->data = &tmp;
92213 - table->maxlen = sizeof(unsigned long);
92214 - ret = proc_doulongvec_minmax(table, write, buffer, length, ppos);
92215 + hugetlb_table = *table;
92216 + hugetlb_table.data = &tmp;
92217 + hugetlb_table.maxlen = sizeof(unsigned long);
92218 + ret = proc_doulongvec_minmax(&hugetlb_table, write, buffer, length, ppos);
92219 if (ret)
92220 goto out;
92221
92222 @@ -2639,6 +2643,27 @@ static int unmap_ref_private(struct mm_struct *mm, struct vm_area_struct *vma,
92223 return 1;
92224 }
92225
92226 +#ifdef CONFIG_PAX_SEGMEXEC
92227 +static void pax_mirror_huge_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m)
92228 +{
92229 + struct mm_struct *mm = vma->vm_mm;
92230 + struct vm_area_struct *vma_m;
92231 + unsigned long address_m;
92232 + pte_t *ptep_m;
92233 +
92234 + vma_m = pax_find_mirror_vma(vma);
92235 + if (!vma_m)
92236 + return;
92237 +
92238 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
92239 + address_m = address + SEGMEXEC_TASK_SIZE;
92240 + ptep_m = huge_pte_offset(mm, address_m & HPAGE_MASK);
92241 + get_page(page_m);
92242 + hugepage_add_anon_rmap(page_m, vma_m, address_m);
92243 + set_huge_pte_at(mm, address_m, ptep_m, make_huge_pte(vma_m, page_m, 0));
92244 +}
92245 +#endif
92246 +
92247 /*
92248 * Hugetlb_cow() should be called with page lock of the original hugepage held.
92249 * Called with hugetlb_instantiation_mutex held and pte_page locked so we
92250 @@ -2756,6 +2781,11 @@ retry_avoidcopy:
92251 make_huge_pte(vma, new_page, 1));
92252 page_remove_rmap(old_page);
92253 hugepage_add_new_anon_rmap(new_page, vma, address);
92254 +
92255 +#ifdef CONFIG_PAX_SEGMEXEC
92256 + pax_mirror_huge_pte(vma, address, new_page);
92257 +#endif
92258 +
92259 /* Make the old page be freed below */
92260 new_page = old_page;
92261 }
92262 @@ -2915,6 +2945,10 @@ retry:
92263 && (vma->vm_flags & VM_SHARED)));
92264 set_huge_pte_at(mm, address, ptep, new_pte);
92265
92266 +#ifdef CONFIG_PAX_SEGMEXEC
92267 + pax_mirror_huge_pte(vma, address, page);
92268 +#endif
92269 +
92270 if ((flags & FAULT_FLAG_WRITE) && !(vma->vm_flags & VM_SHARED)) {
92271 /* Optimization, do the COW without a second fault */
92272 ret = hugetlb_cow(mm, vma, address, ptep, new_pte, page, ptl);
92273 @@ -2981,6 +3015,10 @@ int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma,
92274 struct hstate *h = hstate_vma(vma);
92275 struct address_space *mapping;
92276
92277 +#ifdef CONFIG_PAX_SEGMEXEC
92278 + struct vm_area_struct *vma_m;
92279 +#endif
92280 +
92281 address &= huge_page_mask(h);
92282
92283 ptep = huge_pte_offset(mm, address);
92284 @@ -2994,6 +3032,26 @@ int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma,
92285 VM_FAULT_SET_HINDEX(hstate_index(h));
92286 }
92287
92288 +#ifdef CONFIG_PAX_SEGMEXEC
92289 + vma_m = pax_find_mirror_vma(vma);
92290 + if (vma_m) {
92291 + unsigned long address_m;
92292 +
92293 + if (vma->vm_start > vma_m->vm_start) {
92294 + address_m = address;
92295 + address -= SEGMEXEC_TASK_SIZE;
92296 + vma = vma_m;
92297 + h = hstate_vma(vma);
92298 + } else
92299 + address_m = address + SEGMEXEC_TASK_SIZE;
92300 +
92301 + if (!huge_pte_alloc(mm, address_m, huge_page_size(h)))
92302 + return VM_FAULT_OOM;
92303 + address_m &= HPAGE_MASK;
92304 + unmap_hugepage_range(vma, address_m, address_m + HPAGE_SIZE, NULL);
92305 + }
92306 +#endif
92307 +
92308 ptep = huge_pte_alloc(mm, address, huge_page_size(h));
92309 if (!ptep)
92310 return VM_FAULT_OOM;
92311 diff --git a/mm/internal.h b/mm/internal.h
92312 index 07b6736..ae8da20 100644
92313 --- a/mm/internal.h
92314 +++ b/mm/internal.h
92315 @@ -109,6 +109,7 @@ extern pmd_t *mm_find_pmd(struct mm_struct *mm, unsigned long address);
92316 * in mm/page_alloc.c
92317 */
92318 extern void __free_pages_bootmem(struct page *page, unsigned int order);
92319 +extern void free_compound_page(struct page *page);
92320 extern void prep_compound_page(struct page *page, unsigned long order);
92321 #ifdef CONFIG_MEMORY_FAILURE
92322 extern bool is_free_buddy_page(struct page *page);
92323 @@ -367,7 +368,7 @@ extern u32 hwpoison_filter_enable;
92324
92325 extern unsigned long vm_mmap_pgoff(struct file *, unsigned long,
92326 unsigned long, unsigned long,
92327 - unsigned long, unsigned long);
92328 + unsigned long, unsigned long) __intentional_overflow(-1);
92329
92330 extern void set_pageblock_order(void);
92331 unsigned long reclaim_clean_pages_from_list(struct zone *zone,
92332 diff --git a/mm/iov_iter.c b/mm/iov_iter.c
92333 index 10e46cd..e3052f6 100644
92334 --- a/mm/iov_iter.c
92335 +++ b/mm/iov_iter.c
92336 @@ -87,7 +87,7 @@ static size_t __iovec_copy_from_user_inatomic(char *vaddr,
92337
92338 while (bytes) {
92339 char __user *buf = iov->iov_base + base;
92340 - int copy = min(bytes, iov->iov_len - base);
92341 + size_t copy = min(bytes, iov->iov_len - base);
92342
92343 base = 0;
92344 left = __copy_from_user_inatomic(vaddr, buf, copy);
92345 @@ -115,7 +115,7 @@ size_t iov_iter_copy_from_user_atomic(struct page *page,
92346
92347 kaddr = kmap_atomic(page);
92348 if (likely(i->nr_segs == 1)) {
92349 - int left;
92350 + size_t left;
92351 char __user *buf = i->iov->iov_base + i->iov_offset;
92352 left = __copy_from_user_inatomic(kaddr + offset, buf, bytes);
92353 copied = bytes - left;
92354 @@ -143,7 +143,7 @@ size_t iov_iter_copy_from_user(struct page *page,
92355
92356 kaddr = kmap(page);
92357 if (likely(i->nr_segs == 1)) {
92358 - int left;
92359 + size_t left;
92360 char __user *buf = i->iov->iov_base + i->iov_offset;
92361 left = __copy_from_user(kaddr + offset, buf, bytes);
92362 copied = bytes - left;
92363 @@ -173,7 +173,7 @@ void iov_iter_advance(struct iov_iter *i, size_t bytes)
92364 * zero-length segments (without overruning the iovec).
92365 */
92366 while (bytes || unlikely(i->count && !iov->iov_len)) {
92367 - int copy;
92368 + size_t copy;
92369
92370 copy = min(bytes, iov->iov_len - base);
92371 BUG_ON(!i->count || i->count < copy);
92372 diff --git a/mm/kmemleak.c b/mm/kmemleak.c
92373 index 8d2fcdf..6dd9f1a 100644
92374 --- a/mm/kmemleak.c
92375 +++ b/mm/kmemleak.c
92376 @@ -364,7 +364,7 @@ static void print_unreferenced(struct seq_file *seq,
92377
92378 for (i = 0; i < object->trace_len; i++) {
92379 void *ptr = (void *)object->trace[i];
92380 - seq_printf(seq, " [<%p>] %pS\n", ptr, ptr);
92381 + seq_printf(seq, " [<%pP>] %pA\n", ptr, ptr);
92382 }
92383 }
92384
92385 @@ -1871,7 +1871,7 @@ static int __init kmemleak_late_init(void)
92386 return -ENOMEM;
92387 }
92388
92389 - dentry = debugfs_create_file("kmemleak", S_IRUGO, NULL, NULL,
92390 + dentry = debugfs_create_file("kmemleak", S_IRUSR, NULL, NULL,
92391 &kmemleak_fops);
92392 if (!dentry)
92393 pr_warning("Failed to create the debugfs kmemleak file\n");
92394 diff --git a/mm/maccess.c b/mm/maccess.c
92395 index d53adf9..03a24bf 100644
92396 --- a/mm/maccess.c
92397 +++ b/mm/maccess.c
92398 @@ -26,7 +26,7 @@ long __probe_kernel_read(void *dst, const void *src, size_t size)
92399 set_fs(KERNEL_DS);
92400 pagefault_disable();
92401 ret = __copy_from_user_inatomic(dst,
92402 - (__force const void __user *)src, size);
92403 + (const void __force_user *)src, size);
92404 pagefault_enable();
92405 set_fs(old_fs);
92406
92407 @@ -53,7 +53,7 @@ long __probe_kernel_write(void *dst, const void *src, size_t size)
92408
92409 set_fs(KERNEL_DS);
92410 pagefault_disable();
92411 - ret = __copy_to_user_inatomic((__force void __user *)dst, src, size);
92412 + ret = __copy_to_user_inatomic((void __force_user *)dst, src, size);
92413 pagefault_enable();
92414 set_fs(old_fs);
92415
92416 diff --git a/mm/madvise.c b/mm/madvise.c
92417 index a402f8f..f5e5daa 100644
92418 --- a/mm/madvise.c
92419 +++ b/mm/madvise.c
92420 @@ -51,6 +51,10 @@ static long madvise_behavior(struct vm_area_struct *vma,
92421 pgoff_t pgoff;
92422 unsigned long new_flags = vma->vm_flags;
92423
92424 +#ifdef CONFIG_PAX_SEGMEXEC
92425 + struct vm_area_struct *vma_m;
92426 +#endif
92427 +
92428 switch (behavior) {
92429 case MADV_NORMAL:
92430 new_flags = new_flags & ~VM_RAND_READ & ~VM_SEQ_READ;
92431 @@ -126,6 +130,13 @@ success:
92432 /*
92433 * vm_flags is protected by the mmap_sem held in write mode.
92434 */
92435 +
92436 +#ifdef CONFIG_PAX_SEGMEXEC
92437 + vma_m = pax_find_mirror_vma(vma);
92438 + if (vma_m)
92439 + vma_m->vm_flags = new_flags & ~(VM_WRITE | VM_MAYWRITE | VM_ACCOUNT);
92440 +#endif
92441 +
92442 vma->vm_flags = new_flags;
92443
92444 out:
92445 @@ -274,6 +285,11 @@ static long madvise_dontneed(struct vm_area_struct *vma,
92446 struct vm_area_struct **prev,
92447 unsigned long start, unsigned long end)
92448 {
92449 +
92450 +#ifdef CONFIG_PAX_SEGMEXEC
92451 + struct vm_area_struct *vma_m;
92452 +#endif
92453 +
92454 *prev = vma;
92455 if (vma->vm_flags & (VM_LOCKED|VM_HUGETLB|VM_PFNMAP))
92456 return -EINVAL;
92457 @@ -286,6 +302,21 @@ static long madvise_dontneed(struct vm_area_struct *vma,
92458 zap_page_range(vma, start, end - start, &details);
92459 } else
92460 zap_page_range(vma, start, end - start, NULL);
92461 +
92462 +#ifdef CONFIG_PAX_SEGMEXEC
92463 + vma_m = pax_find_mirror_vma(vma);
92464 + if (vma_m) {
92465 + if (unlikely(vma->vm_flags & VM_NONLINEAR)) {
92466 + struct zap_details details = {
92467 + .nonlinear_vma = vma_m,
92468 + .last_index = ULONG_MAX,
92469 + };
92470 + zap_page_range(vma, start + SEGMEXEC_TASK_SIZE, end - start, &details);
92471 + } else
92472 + zap_page_range(vma, start + SEGMEXEC_TASK_SIZE, end - start, NULL);
92473 + }
92474 +#endif
92475 +
92476 return 0;
92477 }
92478
92479 @@ -491,6 +522,16 @@ SYSCALL_DEFINE3(madvise, unsigned long, start, size_t, len_in, int, behavior)
92480 if (end < start)
92481 return error;
92482
92483 +#ifdef CONFIG_PAX_SEGMEXEC
92484 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC) {
92485 + if (end > SEGMEXEC_TASK_SIZE)
92486 + return error;
92487 + } else
92488 +#endif
92489 +
92490 + if (end > TASK_SIZE)
92491 + return error;
92492 +
92493 error = 0;
92494 if (end == start)
92495 return error;
92496 diff --git a/mm/memory-failure.c b/mm/memory-failure.c
92497 index 9ccef39..d3320da 100644
92498 --- a/mm/memory-failure.c
92499 +++ b/mm/memory-failure.c
92500 @@ -61,7 +61,7 @@ int sysctl_memory_failure_early_kill __read_mostly = 0;
92501
92502 int sysctl_memory_failure_recovery __read_mostly = 1;
92503
92504 -atomic_long_t num_poisoned_pages __read_mostly = ATOMIC_LONG_INIT(0);
92505 +atomic_long_unchecked_t num_poisoned_pages __read_mostly = ATOMIC_LONG_INIT(0);
92506
92507 #if defined(CONFIG_HWPOISON_INJECT) || defined(CONFIG_HWPOISON_INJECT_MODULE)
92508
92509 @@ -198,7 +198,7 @@ static int kill_proc(struct task_struct *t, unsigned long addr, int trapno,
92510 pfn, t->comm, t->pid);
92511 si.si_signo = SIGBUS;
92512 si.si_errno = 0;
92513 - si.si_addr = (void *)addr;
92514 + si.si_addr = (void __user *)addr;
92515 #ifdef __ARCH_SI_TRAPNO
92516 si.si_trapno = trapno;
92517 #endif
92518 @@ -758,7 +758,7 @@ static struct page_state {
92519 unsigned long res;
92520 char *msg;
92521 int (*action)(struct page *p, unsigned long pfn);
92522 -} error_states[] = {
92523 +} __do_const error_states[] = {
92524 { reserved, reserved, "reserved kernel", me_kernel },
92525 /*
92526 * free pages are specially detected outside this table:
92527 @@ -1058,7 +1058,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
92528 nr_pages = 1 << compound_order(hpage);
92529 else /* normal page or thp */
92530 nr_pages = 1;
92531 - atomic_long_add(nr_pages, &num_poisoned_pages);
92532 + atomic_long_add_unchecked(nr_pages, &num_poisoned_pages);
92533
92534 /*
92535 * We need/can do nothing about count=0 pages.
92536 @@ -1087,7 +1087,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
92537 if (PageHWPoison(hpage)) {
92538 if ((hwpoison_filter(p) && TestClearPageHWPoison(p))
92539 || (p != hpage && TestSetPageHWPoison(hpage))) {
92540 - atomic_long_sub(nr_pages, &num_poisoned_pages);
92541 + atomic_long_sub_unchecked(nr_pages, &num_poisoned_pages);
92542 unlock_page(hpage);
92543 return 0;
92544 }
92545 @@ -1153,14 +1153,14 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
92546 */
92547 if (!PageHWPoison(p)) {
92548 printk(KERN_ERR "MCE %#lx: just unpoisoned\n", pfn);
92549 - atomic_long_sub(nr_pages, &num_poisoned_pages);
92550 + atomic_long_sub_unchecked(nr_pages, &num_poisoned_pages);
92551 put_page(hpage);
92552 res = 0;
92553 goto out;
92554 }
92555 if (hwpoison_filter(p)) {
92556 if (TestClearPageHWPoison(p))
92557 - atomic_long_sub(nr_pages, &num_poisoned_pages);
92558 + atomic_long_sub_unchecked(nr_pages, &num_poisoned_pages);
92559 unlock_page(hpage);
92560 put_page(hpage);
92561 return 0;
92562 @@ -1382,7 +1382,7 @@ int unpoison_memory(unsigned long pfn)
92563 return 0;
92564 }
92565 if (TestClearPageHWPoison(p))
92566 - atomic_long_dec(&num_poisoned_pages);
92567 + atomic_long_dec_unchecked(&num_poisoned_pages);
92568 pr_info("MCE: Software-unpoisoned free page %#lx\n", pfn);
92569 return 0;
92570 }
92571 @@ -1396,7 +1396,7 @@ int unpoison_memory(unsigned long pfn)
92572 */
92573 if (TestClearPageHWPoison(page)) {
92574 pr_info("MCE: Software-unpoisoned page %#lx\n", pfn);
92575 - atomic_long_sub(nr_pages, &num_poisoned_pages);
92576 + atomic_long_sub_unchecked(nr_pages, &num_poisoned_pages);
92577 freeit = 1;
92578 if (PageHuge(page))
92579 clear_page_hwpoison_huge_page(page);
92580 @@ -1521,11 +1521,11 @@ static int soft_offline_huge_page(struct page *page, int flags)
92581 if (PageHuge(page)) {
92582 set_page_hwpoison_huge_page(hpage);
92583 dequeue_hwpoisoned_huge_page(hpage);
92584 - atomic_long_add(1 << compound_order(hpage),
92585 + atomic_long_add_unchecked(1 << compound_order(hpage),
92586 &num_poisoned_pages);
92587 } else {
92588 SetPageHWPoison(page);
92589 - atomic_long_inc(&num_poisoned_pages);
92590 + atomic_long_inc_unchecked(&num_poisoned_pages);
92591 }
92592 }
92593 return ret;
92594 @@ -1564,7 +1564,7 @@ static int __soft_offline_page(struct page *page, int flags)
92595 put_page(page);
92596 pr_info("soft_offline: %#lx: invalidated\n", pfn);
92597 SetPageHWPoison(page);
92598 - atomic_long_inc(&num_poisoned_pages);
92599 + atomic_long_inc_unchecked(&num_poisoned_pages);
92600 return 0;
92601 }
92602
92603 @@ -1615,7 +1615,7 @@ static int __soft_offline_page(struct page *page, int flags)
92604 if (!is_free_buddy_page(page))
92605 pr_info("soft offline: %#lx: page leaked\n",
92606 pfn);
92607 - atomic_long_inc(&num_poisoned_pages);
92608 + atomic_long_inc_unchecked(&num_poisoned_pages);
92609 }
92610 } else {
92611 pr_info("soft offline: %#lx: isolation failed: %d, page count %d, type %lx\n",
92612 @@ -1689,11 +1689,11 @@ int soft_offline_page(struct page *page, int flags)
92613 if (PageHuge(page)) {
92614 set_page_hwpoison_huge_page(hpage);
92615 dequeue_hwpoisoned_huge_page(hpage);
92616 - atomic_long_add(1 << compound_order(hpage),
92617 + atomic_long_add_unchecked(1 << compound_order(hpage),
92618 &num_poisoned_pages);
92619 } else {
92620 SetPageHWPoison(page);
92621 - atomic_long_inc(&num_poisoned_pages);
92622 + atomic_long_inc_unchecked(&num_poisoned_pages);
92623 }
92624 }
92625 unset_migratetype_isolate(page, MIGRATE_MOVABLE);
92626 diff --git a/mm/memory.c b/mm/memory.c
92627 index 037b812..948123c 100644
92628 --- a/mm/memory.c
92629 +++ b/mm/memory.c
92630 @@ -413,6 +413,7 @@ static inline void free_pmd_range(struct mmu_gather *tlb, pud_t *pud,
92631 free_pte_range(tlb, pmd, addr);
92632 } while (pmd++, addr = next, addr != end);
92633
92634 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_PER_CPU_PGD)
92635 start &= PUD_MASK;
92636 if (start < floor)
92637 return;
92638 @@ -427,6 +428,8 @@ static inline void free_pmd_range(struct mmu_gather *tlb, pud_t *pud,
92639 pmd = pmd_offset(pud, start);
92640 pud_clear(pud);
92641 pmd_free_tlb(tlb, pmd, start);
92642 +#endif
92643 +
92644 }
92645
92646 static inline void free_pud_range(struct mmu_gather *tlb, pgd_t *pgd,
92647 @@ -446,6 +449,7 @@ static inline void free_pud_range(struct mmu_gather *tlb, pgd_t *pgd,
92648 free_pmd_range(tlb, pud, addr, next, floor, ceiling);
92649 } while (pud++, addr = next, addr != end);
92650
92651 +#if !defined(CONFIG_X86_64) || !defined(CONFIG_PAX_PER_CPU_PGD)
92652 start &= PGDIR_MASK;
92653 if (start < floor)
92654 return;
92655 @@ -460,6 +464,8 @@ static inline void free_pud_range(struct mmu_gather *tlb, pgd_t *pgd,
92656 pud = pud_offset(pgd, start);
92657 pgd_clear(pgd);
92658 pud_free_tlb(tlb, pud, start);
92659 +#endif
92660 +
92661 }
92662
92663 /*
92664 @@ -1652,12 +1658,6 @@ no_page_table:
92665 return page;
92666 }
92667
92668 -static inline int stack_guard_page(struct vm_area_struct *vma, unsigned long addr)
92669 -{
92670 - return stack_guard_page_start(vma, addr) ||
92671 - stack_guard_page_end(vma, addr+PAGE_SIZE);
92672 -}
92673 -
92674 /**
92675 * __get_user_pages() - pin user pages in memory
92676 * @tsk: task_struct of target task
92677 @@ -1735,10 +1735,10 @@ long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
92678
92679 i = 0;
92680
92681 - do {
92682 + while (nr_pages) {
92683 struct vm_area_struct *vma;
92684
92685 - vma = find_extend_vma(mm, start);
92686 + vma = find_vma(mm, start);
92687 if (!vma && in_gate_area(mm, start)) {
92688 unsigned long pg = start & PAGE_MASK;
92689 pgd_t *pgd;
92690 @@ -1787,7 +1787,7 @@ long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
92691 goto next_page;
92692 }
92693
92694 - if (!vma)
92695 + if (!vma || start < vma->vm_start)
92696 goto efault;
92697 vm_flags = vma->vm_flags;
92698 if (vm_flags & (VM_IO | VM_PFNMAP))
92699 @@ -1848,11 +1848,6 @@ long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
92700 int ret;
92701 unsigned int fault_flags = 0;
92702
92703 - /* For mlock, just skip the stack guard page. */
92704 - if (foll_flags & FOLL_MLOCK) {
92705 - if (stack_guard_page(vma, start))
92706 - goto next_page;
92707 - }
92708 if (foll_flags & FOLL_WRITE)
92709 fault_flags |= FAULT_FLAG_WRITE;
92710 if (nonblocking)
92711 @@ -1932,7 +1927,7 @@ next_page:
92712 start += page_increm * PAGE_SIZE;
92713 nr_pages -= page_increm;
92714 } while (nr_pages && start < vma->vm_end);
92715 - } while (nr_pages);
92716 + }
92717 return i;
92718 efault:
92719 return i ? : -EFAULT;
92720 @@ -2145,6 +2140,10 @@ static int insert_page(struct vm_area_struct *vma, unsigned long addr,
92721 page_add_file_rmap(page);
92722 set_pte_at(mm, addr, pte, mk_pte(page, prot));
92723
92724 +#ifdef CONFIG_PAX_SEGMEXEC
92725 + pax_mirror_file_pte(vma, addr, page, ptl);
92726 +#endif
92727 +
92728 retval = 0;
92729 pte_unmap_unlock(pte, ptl);
92730 return retval;
92731 @@ -2189,9 +2188,21 @@ int vm_insert_page(struct vm_area_struct *vma, unsigned long addr,
92732 if (!page_count(page))
92733 return -EINVAL;
92734 if (!(vma->vm_flags & VM_MIXEDMAP)) {
92735 +
92736 +#ifdef CONFIG_PAX_SEGMEXEC
92737 + struct vm_area_struct *vma_m;
92738 +#endif
92739 +
92740 BUG_ON(down_read_trylock(&vma->vm_mm->mmap_sem));
92741 BUG_ON(vma->vm_flags & VM_PFNMAP);
92742 vma->vm_flags |= VM_MIXEDMAP;
92743 +
92744 +#ifdef CONFIG_PAX_SEGMEXEC
92745 + vma_m = pax_find_mirror_vma(vma);
92746 + if (vma_m)
92747 + vma_m->vm_flags |= VM_MIXEDMAP;
92748 +#endif
92749 +
92750 }
92751 return insert_page(vma, addr, page, vma->vm_page_prot);
92752 }
92753 @@ -2274,6 +2285,7 @@ int vm_insert_mixed(struct vm_area_struct *vma, unsigned long addr,
92754 unsigned long pfn)
92755 {
92756 BUG_ON(!(vma->vm_flags & VM_MIXEDMAP));
92757 + BUG_ON(vma->vm_mirror);
92758
92759 if (addr < vma->vm_start || addr >= vma->vm_end)
92760 return -EFAULT;
92761 @@ -2521,7 +2533,9 @@ static int apply_to_pmd_range(struct mm_struct *mm, pud_t *pud,
92762
92763 BUG_ON(pud_huge(*pud));
92764
92765 - pmd = pmd_alloc(mm, pud, addr);
92766 + pmd = (mm == &init_mm) ?
92767 + pmd_alloc_kernel(mm, pud, addr) :
92768 + pmd_alloc(mm, pud, addr);
92769 if (!pmd)
92770 return -ENOMEM;
92771 do {
92772 @@ -2541,7 +2555,9 @@ static int apply_to_pud_range(struct mm_struct *mm, pgd_t *pgd,
92773 unsigned long next;
92774 int err;
92775
92776 - pud = pud_alloc(mm, pgd, addr);
92777 + pud = (mm == &init_mm) ?
92778 + pud_alloc_kernel(mm, pgd, addr) :
92779 + pud_alloc(mm, pgd, addr);
92780 if (!pud)
92781 return -ENOMEM;
92782 do {
92783 @@ -2663,6 +2679,186 @@ static int do_page_mkwrite(struct vm_area_struct *vma, struct page *page,
92784 return ret;
92785 }
92786
92787 +#ifdef CONFIG_PAX_SEGMEXEC
92788 +static void pax_unmap_mirror_pte(struct vm_area_struct *vma, unsigned long address, pmd_t *pmd)
92789 +{
92790 + struct mm_struct *mm = vma->vm_mm;
92791 + spinlock_t *ptl;
92792 + pte_t *pte, entry;
92793 +
92794 + pte = pte_offset_map_lock(mm, pmd, address, &ptl);
92795 + entry = *pte;
92796 + if (!pte_present(entry)) {
92797 + if (!pte_none(entry)) {
92798 + BUG_ON(pte_file(entry));
92799 + free_swap_and_cache(pte_to_swp_entry(entry));
92800 + pte_clear_not_present_full(mm, address, pte, 0);
92801 + }
92802 + } else {
92803 + struct page *page;
92804 +
92805 + flush_cache_page(vma, address, pte_pfn(entry));
92806 + entry = ptep_clear_flush(vma, address, pte);
92807 + BUG_ON(pte_dirty(entry));
92808 + page = vm_normal_page(vma, address, entry);
92809 + if (page) {
92810 + update_hiwater_rss(mm);
92811 + if (PageAnon(page))
92812 + dec_mm_counter_fast(mm, MM_ANONPAGES);
92813 + else
92814 + dec_mm_counter_fast(mm, MM_FILEPAGES);
92815 + page_remove_rmap(page);
92816 + page_cache_release(page);
92817 + }
92818 + }
92819 + pte_unmap_unlock(pte, ptl);
92820 +}
92821 +
92822 +/* PaX: if vma is mirrored, synchronize the mirror's PTE
92823 + *
92824 + * the ptl of the lower mapped page is held on entry and is not released on exit
92825 + * or inside to ensure atomic changes to the PTE states (swapout, mremap, munmap, etc)
92826 + */
92827 +static void pax_mirror_anon_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m, spinlock_t *ptl)
92828 +{
92829 + struct mm_struct *mm = vma->vm_mm;
92830 + unsigned long address_m;
92831 + spinlock_t *ptl_m;
92832 + struct vm_area_struct *vma_m;
92833 + pmd_t *pmd_m;
92834 + pte_t *pte_m, entry_m;
92835 +
92836 + BUG_ON(!page_m || !PageAnon(page_m));
92837 +
92838 + vma_m = pax_find_mirror_vma(vma);
92839 + if (!vma_m)
92840 + return;
92841 +
92842 + BUG_ON(!PageLocked(page_m));
92843 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
92844 + address_m = address + SEGMEXEC_TASK_SIZE;
92845 + pmd_m = pmd_offset(pud_offset(pgd_offset(mm, address_m), address_m), address_m);
92846 + pte_m = pte_offset_map(pmd_m, address_m);
92847 + ptl_m = pte_lockptr(mm, pmd_m);
92848 + if (ptl != ptl_m) {
92849 + spin_lock_nested(ptl_m, SINGLE_DEPTH_NESTING);
92850 + if (!pte_none(*pte_m))
92851 + goto out;
92852 + }
92853 +
92854 + entry_m = pfn_pte(page_to_pfn(page_m), vma_m->vm_page_prot);
92855 + page_cache_get(page_m);
92856 + page_add_anon_rmap(page_m, vma_m, address_m);
92857 + inc_mm_counter_fast(mm, MM_ANONPAGES);
92858 + set_pte_at(mm, address_m, pte_m, entry_m);
92859 + update_mmu_cache(vma_m, address_m, pte_m);
92860 +out:
92861 + if (ptl != ptl_m)
92862 + spin_unlock(ptl_m);
92863 + pte_unmap(pte_m);
92864 + unlock_page(page_m);
92865 +}
92866 +
92867 +void pax_mirror_file_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m, spinlock_t *ptl)
92868 +{
92869 + struct mm_struct *mm = vma->vm_mm;
92870 + unsigned long address_m;
92871 + spinlock_t *ptl_m;
92872 + struct vm_area_struct *vma_m;
92873 + pmd_t *pmd_m;
92874 + pte_t *pte_m, entry_m;
92875 +
92876 + BUG_ON(!page_m || PageAnon(page_m));
92877 +
92878 + vma_m = pax_find_mirror_vma(vma);
92879 + if (!vma_m)
92880 + return;
92881 +
92882 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
92883 + address_m = address + SEGMEXEC_TASK_SIZE;
92884 + pmd_m = pmd_offset(pud_offset(pgd_offset(mm, address_m), address_m), address_m);
92885 + pte_m = pte_offset_map(pmd_m, address_m);
92886 + ptl_m = pte_lockptr(mm, pmd_m);
92887 + if (ptl != ptl_m) {
92888 + spin_lock_nested(ptl_m, SINGLE_DEPTH_NESTING);
92889 + if (!pte_none(*pte_m))
92890 + goto out;
92891 + }
92892 +
92893 + entry_m = pfn_pte(page_to_pfn(page_m), vma_m->vm_page_prot);
92894 + page_cache_get(page_m);
92895 + page_add_file_rmap(page_m);
92896 + inc_mm_counter_fast(mm, MM_FILEPAGES);
92897 + set_pte_at(mm, address_m, pte_m, entry_m);
92898 + update_mmu_cache(vma_m, address_m, pte_m);
92899 +out:
92900 + if (ptl != ptl_m)
92901 + spin_unlock(ptl_m);
92902 + pte_unmap(pte_m);
92903 +}
92904 +
92905 +static void pax_mirror_pfn_pte(struct vm_area_struct *vma, unsigned long address, unsigned long pfn_m, spinlock_t *ptl)
92906 +{
92907 + struct mm_struct *mm = vma->vm_mm;
92908 + unsigned long address_m;
92909 + spinlock_t *ptl_m;
92910 + struct vm_area_struct *vma_m;
92911 + pmd_t *pmd_m;
92912 + pte_t *pte_m, entry_m;
92913 +
92914 + vma_m = pax_find_mirror_vma(vma);
92915 + if (!vma_m)
92916 + return;
92917 +
92918 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
92919 + address_m = address + SEGMEXEC_TASK_SIZE;
92920 + pmd_m = pmd_offset(pud_offset(pgd_offset(mm, address_m), address_m), address_m);
92921 + pte_m = pte_offset_map(pmd_m, address_m);
92922 + ptl_m = pte_lockptr(mm, pmd_m);
92923 + if (ptl != ptl_m) {
92924 + spin_lock_nested(ptl_m, SINGLE_DEPTH_NESTING);
92925 + if (!pte_none(*pte_m))
92926 + goto out;
92927 + }
92928 +
92929 + entry_m = pfn_pte(pfn_m, vma_m->vm_page_prot);
92930 + set_pte_at(mm, address_m, pte_m, entry_m);
92931 +out:
92932 + if (ptl != ptl_m)
92933 + spin_unlock(ptl_m);
92934 + pte_unmap(pte_m);
92935 +}
92936 +
92937 +static void pax_mirror_pte(struct vm_area_struct *vma, unsigned long address, pte_t *pte, pmd_t *pmd, spinlock_t *ptl)
92938 +{
92939 + struct page *page_m;
92940 + pte_t entry;
92941 +
92942 + if (!(vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC))
92943 + goto out;
92944 +
92945 + entry = *pte;
92946 + page_m = vm_normal_page(vma, address, entry);
92947 + if (!page_m)
92948 + pax_mirror_pfn_pte(vma, address, pte_pfn(entry), ptl);
92949 + else if (PageAnon(page_m)) {
92950 + if (pax_find_mirror_vma(vma)) {
92951 + pte_unmap_unlock(pte, ptl);
92952 + lock_page(page_m);
92953 + pte = pte_offset_map_lock(vma->vm_mm, pmd, address, &ptl);
92954 + if (pte_same(entry, *pte))
92955 + pax_mirror_anon_pte(vma, address, page_m, ptl);
92956 + else
92957 + unlock_page(page_m);
92958 + }
92959 + } else
92960 + pax_mirror_file_pte(vma, address, page_m, ptl);
92961 +
92962 +out:
92963 + pte_unmap_unlock(pte, ptl);
92964 +}
92965 +#endif
92966 +
92967 /*
92968 * This routine handles present pages, when users try to write
92969 * to a shared page. It is done by copying the page to a new address
92970 @@ -2860,6 +3056,12 @@ gotten:
92971 */
92972 page_table = pte_offset_map_lock(mm, pmd, address, &ptl);
92973 if (likely(pte_same(*page_table, orig_pte))) {
92974 +
92975 +#ifdef CONFIG_PAX_SEGMEXEC
92976 + if (pax_find_mirror_vma(vma))
92977 + BUG_ON(!trylock_page(new_page));
92978 +#endif
92979 +
92980 if (old_page) {
92981 if (!PageAnon(old_page)) {
92982 dec_mm_counter_fast(mm, MM_FILEPAGES);
92983 @@ -2911,6 +3113,10 @@ gotten:
92984 page_remove_rmap(old_page);
92985 }
92986
92987 +#ifdef CONFIG_PAX_SEGMEXEC
92988 + pax_mirror_anon_pte(vma, address, new_page, ptl);
92989 +#endif
92990 +
92991 /* Free the old page.. */
92992 new_page = old_page;
92993 ret |= VM_FAULT_WRITE;
92994 @@ -3184,6 +3390,11 @@ static int do_swap_page(struct mm_struct *mm, struct vm_area_struct *vma,
92995 swap_free(entry);
92996 if (vm_swap_full() || (vma->vm_flags & VM_LOCKED) || PageMlocked(page))
92997 try_to_free_swap(page);
92998 +
92999 +#ifdef CONFIG_PAX_SEGMEXEC
93000 + if ((flags & FAULT_FLAG_WRITE) || !pax_find_mirror_vma(vma))
93001 +#endif
93002 +
93003 unlock_page(page);
93004 if (page != swapcache) {
93005 /*
93006 @@ -3207,6 +3418,11 @@ static int do_swap_page(struct mm_struct *mm, struct vm_area_struct *vma,
93007
93008 /* No need to invalidate - it was non-present before */
93009 update_mmu_cache(vma, address, page_table);
93010 +
93011 +#ifdef CONFIG_PAX_SEGMEXEC
93012 + pax_mirror_anon_pte(vma, address, page, ptl);
93013 +#endif
93014 +
93015 unlock:
93016 pte_unmap_unlock(page_table, ptl);
93017 out:
93018 @@ -3226,40 +3442,6 @@ out_release:
93019 }
93020
93021 /*
93022 - * This is like a special single-page "expand_{down|up}wards()",
93023 - * except we must first make sure that 'address{-|+}PAGE_SIZE'
93024 - * doesn't hit another vma.
93025 - */
93026 -static inline int check_stack_guard_page(struct vm_area_struct *vma, unsigned long address)
93027 -{
93028 - address &= PAGE_MASK;
93029 - if ((vma->vm_flags & VM_GROWSDOWN) && address == vma->vm_start) {
93030 - struct vm_area_struct *prev = vma->vm_prev;
93031 -
93032 - /*
93033 - * Is there a mapping abutting this one below?
93034 - *
93035 - * That's only ok if it's the same stack mapping
93036 - * that has gotten split..
93037 - */
93038 - if (prev && prev->vm_end == address)
93039 - return prev->vm_flags & VM_GROWSDOWN ? 0 : -ENOMEM;
93040 -
93041 - expand_downwards(vma, address - PAGE_SIZE);
93042 - }
93043 - if ((vma->vm_flags & VM_GROWSUP) && address + PAGE_SIZE == vma->vm_end) {
93044 - struct vm_area_struct *next = vma->vm_next;
93045 -
93046 - /* As VM_GROWSDOWN but s/below/above/ */
93047 - if (next && next->vm_start == address + PAGE_SIZE)
93048 - return next->vm_flags & VM_GROWSUP ? 0 : -ENOMEM;
93049 -
93050 - expand_upwards(vma, address + PAGE_SIZE);
93051 - }
93052 - return 0;
93053 -}
93054 -
93055 -/*
93056 * We enter with non-exclusive mmap_sem (to exclude vma changes,
93057 * but allow concurrent faults), and pte mapped but not yet locked.
93058 * We return with mmap_sem still held, but pte unmapped and unlocked.
93059 @@ -3268,27 +3450,23 @@ static int do_anonymous_page(struct mm_struct *mm, struct vm_area_struct *vma,
93060 unsigned long address, pte_t *page_table, pmd_t *pmd,
93061 unsigned int flags)
93062 {
93063 - struct page *page;
93064 + struct page *page = NULL;
93065 spinlock_t *ptl;
93066 pte_t entry;
93067
93068 - pte_unmap(page_table);
93069 -
93070 - /* Check if we need to add a guard page to the stack */
93071 - if (check_stack_guard_page(vma, address) < 0)
93072 - return VM_FAULT_SIGBUS;
93073 -
93074 - /* Use the zero-page for reads */
93075 if (!(flags & FAULT_FLAG_WRITE)) {
93076 entry = pte_mkspecial(pfn_pte(my_zero_pfn(address),
93077 vma->vm_page_prot));
93078 - page_table = pte_offset_map_lock(mm, pmd, address, &ptl);
93079 + ptl = pte_lockptr(mm, pmd);
93080 + spin_lock(ptl);
93081 if (!pte_none(*page_table))
93082 goto unlock;
93083 goto setpte;
93084 }
93085
93086 /* Allocate our own private page. */
93087 + pte_unmap(page_table);
93088 +
93089 if (unlikely(anon_vma_prepare(vma)))
93090 goto oom;
93091 page = alloc_zeroed_user_highpage_movable(vma, address);
93092 @@ -3312,6 +3490,11 @@ static int do_anonymous_page(struct mm_struct *mm, struct vm_area_struct *vma,
93093 if (!pte_none(*page_table))
93094 goto release;
93095
93096 +#ifdef CONFIG_PAX_SEGMEXEC
93097 + if (pax_find_mirror_vma(vma))
93098 + BUG_ON(!trylock_page(page));
93099 +#endif
93100 +
93101 inc_mm_counter_fast(mm, MM_ANONPAGES);
93102 page_add_new_anon_rmap(page, vma, address);
93103 setpte:
93104 @@ -3319,6 +3502,12 @@ setpte:
93105
93106 /* No need to invalidate - it was non-present before */
93107 update_mmu_cache(vma, address, page_table);
93108 +
93109 +#ifdef CONFIG_PAX_SEGMEXEC
93110 + if (page)
93111 + pax_mirror_anon_pte(vma, address, page, ptl);
93112 +#endif
93113 +
93114 unlock:
93115 pte_unmap_unlock(page_table, ptl);
93116 return 0;
93117 @@ -3535,6 +3724,11 @@ static int do_read_fault(struct mm_struct *mm, struct vm_area_struct *vma,
93118 return ret;
93119 }
93120 do_set_pte(vma, address, fault_page, pte, false, false);
93121 +
93122 +#ifdef CONFIG_PAX_SEGMEXEC
93123 + pax_mirror_file_pte(vma, address, fault_page, ptl);
93124 +#endif
93125 +
93126 unlock_page(fault_page);
93127 unlock_out:
93128 pte_unmap_unlock(pte, ptl);
93129 @@ -3576,7 +3770,18 @@ static int do_cow_fault(struct mm_struct *mm, struct vm_area_struct *vma,
93130 page_cache_release(fault_page);
93131 goto uncharge_out;
93132 }
93133 +
93134 +#ifdef CONFIG_PAX_SEGMEXEC
93135 + if (pax_find_mirror_vma(vma))
93136 + BUG_ON(!trylock_page(new_page));
93137 +#endif
93138 +
93139 do_set_pte(vma, address, new_page, pte, true, true);
93140 +
93141 +#ifdef CONFIG_PAX_SEGMEXEC
93142 + pax_mirror_anon_pte(vma, address, new_page, ptl);
93143 +#endif
93144 +
93145 pte_unmap_unlock(pte, ptl);
93146 unlock_page(fault_page);
93147 page_cache_release(fault_page);
93148 @@ -3624,6 +3829,11 @@ static int do_shared_fault(struct mm_struct *mm, struct vm_area_struct *vma,
93149 return ret;
93150 }
93151 do_set_pte(vma, address, fault_page, pte, true, false);
93152 +
93153 +#ifdef CONFIG_PAX_SEGMEXEC
93154 + pax_mirror_file_pte(vma, address, fault_page, ptl);
93155 +#endif
93156 +
93157 pte_unmap_unlock(pte, ptl);
93158
93159 if (set_page_dirty(fault_page))
93160 @@ -3854,6 +4064,12 @@ static int handle_pte_fault(struct mm_struct *mm,
93161 if (flags & FAULT_FLAG_WRITE)
93162 flush_tlb_fix_spurious_fault(vma, address);
93163 }
93164 +
93165 +#ifdef CONFIG_PAX_SEGMEXEC
93166 + pax_mirror_pte(vma, address, pte, pmd, ptl);
93167 + return 0;
93168 +#endif
93169 +
93170 unlock:
93171 pte_unmap_unlock(pte, ptl);
93172 return 0;
93173 @@ -3870,9 +4086,41 @@ static int __handle_mm_fault(struct mm_struct *mm, struct vm_area_struct *vma,
93174 pmd_t *pmd;
93175 pte_t *pte;
93176
93177 +#ifdef CONFIG_PAX_SEGMEXEC
93178 + struct vm_area_struct *vma_m;
93179 +#endif
93180 +
93181 if (unlikely(is_vm_hugetlb_page(vma)))
93182 return hugetlb_fault(mm, vma, address, flags);
93183
93184 +#ifdef CONFIG_PAX_SEGMEXEC
93185 + vma_m = pax_find_mirror_vma(vma);
93186 + if (vma_m) {
93187 + unsigned long address_m;
93188 + pgd_t *pgd_m;
93189 + pud_t *pud_m;
93190 + pmd_t *pmd_m;
93191 +
93192 + if (vma->vm_start > vma_m->vm_start) {
93193 + address_m = address;
93194 + address -= SEGMEXEC_TASK_SIZE;
93195 + vma = vma_m;
93196 + } else
93197 + address_m = address + SEGMEXEC_TASK_SIZE;
93198 +
93199 + pgd_m = pgd_offset(mm, address_m);
93200 + pud_m = pud_alloc(mm, pgd_m, address_m);
93201 + if (!pud_m)
93202 + return VM_FAULT_OOM;
93203 + pmd_m = pmd_alloc(mm, pud_m, address_m);
93204 + if (!pmd_m)
93205 + return VM_FAULT_OOM;
93206 + if (!pmd_present(*pmd_m) && __pte_alloc(mm, vma_m, pmd_m, address_m))
93207 + return VM_FAULT_OOM;
93208 + pax_unmap_mirror_pte(vma_m, address_m, pmd_m);
93209 + }
93210 +#endif
93211 +
93212 pgd = pgd_offset(mm, address);
93213 pud = pud_alloc(mm, pgd, address);
93214 if (!pud)
93215 @@ -4003,6 +4251,23 @@ int __pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
93216 spin_unlock(&mm->page_table_lock);
93217 return 0;
93218 }
93219 +
93220 +int __pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
93221 +{
93222 + pud_t *new = pud_alloc_one(mm, address);
93223 + if (!new)
93224 + return -ENOMEM;
93225 +
93226 + smp_wmb(); /* See comment in __pte_alloc */
93227 +
93228 + spin_lock(&mm->page_table_lock);
93229 + if (pgd_present(*pgd)) /* Another has populated it */
93230 + pud_free(mm, new);
93231 + else
93232 + pgd_populate_kernel(mm, pgd, new);
93233 + spin_unlock(&mm->page_table_lock);
93234 + return 0;
93235 +}
93236 #endif /* __PAGETABLE_PUD_FOLDED */
93237
93238 #ifndef __PAGETABLE_PMD_FOLDED
93239 @@ -4033,6 +4298,30 @@ int __pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address)
93240 spin_unlock(&mm->page_table_lock);
93241 return 0;
93242 }
93243 +
93244 +int __pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud, unsigned long address)
93245 +{
93246 + pmd_t *new = pmd_alloc_one(mm, address);
93247 + if (!new)
93248 + return -ENOMEM;
93249 +
93250 + smp_wmb(); /* See comment in __pte_alloc */
93251 +
93252 + spin_lock(&mm->page_table_lock);
93253 +#ifndef __ARCH_HAS_4LEVEL_HACK
93254 + if (pud_present(*pud)) /* Another has populated it */
93255 + pmd_free(mm, new);
93256 + else
93257 + pud_populate_kernel(mm, pud, new);
93258 +#else
93259 + if (pgd_present(*pud)) /* Another has populated it */
93260 + pmd_free(mm, new);
93261 + else
93262 + pgd_populate_kernel(mm, pud, new);
93263 +#endif /* __ARCH_HAS_4LEVEL_HACK */
93264 + spin_unlock(&mm->page_table_lock);
93265 + return 0;
93266 +}
93267 #endif /* __PAGETABLE_PMD_FOLDED */
93268
93269 #if !defined(__HAVE_ARCH_GATE_AREA)
93270 @@ -4046,7 +4335,7 @@ static int __init gate_vma_init(void)
93271 gate_vma.vm_start = FIXADDR_USER_START;
93272 gate_vma.vm_end = FIXADDR_USER_END;
93273 gate_vma.vm_flags = VM_READ | VM_MAYREAD | VM_EXEC | VM_MAYEXEC;
93274 - gate_vma.vm_page_prot = __P101;
93275 + gate_vma.vm_page_prot = vm_get_page_prot(gate_vma.vm_flags);
93276
93277 return 0;
93278 }
93279 @@ -4180,8 +4469,8 @@ out:
93280 return ret;
93281 }
93282
93283 -int generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
93284 - void *buf, int len, int write)
93285 +ssize_t generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
93286 + void *buf, size_t len, int write)
93287 {
93288 resource_size_t phys_addr;
93289 unsigned long prot = 0;
93290 @@ -4207,8 +4496,8 @@ EXPORT_SYMBOL_GPL(generic_access_phys);
93291 * Access another process' address space as given in mm. If non-NULL, use the
93292 * given task for page fault accounting.
93293 */
93294 -static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
93295 - unsigned long addr, void *buf, int len, int write)
93296 +static ssize_t __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
93297 + unsigned long addr, void *buf, size_t len, int write)
93298 {
93299 struct vm_area_struct *vma;
93300 void *old_buf = buf;
93301 @@ -4216,7 +4505,7 @@ static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
93302 down_read(&mm->mmap_sem);
93303 /* ignore errors, just check how much was successfully transferred */
93304 while (len) {
93305 - int bytes, ret, offset;
93306 + ssize_t bytes, ret, offset;
93307 void *maddr;
93308 struct page *page = NULL;
93309
93310 @@ -4275,8 +4564,8 @@ static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
93311 *
93312 * The caller must hold a reference on @mm.
93313 */
93314 -int access_remote_vm(struct mm_struct *mm, unsigned long addr,
93315 - void *buf, int len, int write)
93316 +ssize_t access_remote_vm(struct mm_struct *mm, unsigned long addr,
93317 + void *buf, size_t len, int write)
93318 {
93319 return __access_remote_vm(NULL, mm, addr, buf, len, write);
93320 }
93321 @@ -4286,11 +4575,11 @@ int access_remote_vm(struct mm_struct *mm, unsigned long addr,
93322 * Source/target buffer must be kernel space,
93323 * Do not walk the page table directly, use get_user_pages
93324 */
93325 -int access_process_vm(struct task_struct *tsk, unsigned long addr,
93326 - void *buf, int len, int write)
93327 +ssize_t access_process_vm(struct task_struct *tsk, unsigned long addr,
93328 + void *buf, size_t len, int write)
93329 {
93330 struct mm_struct *mm;
93331 - int ret;
93332 + ssize_t ret;
93333
93334 mm = get_task_mm(tsk);
93335 if (!mm)
93336 diff --git a/mm/mempolicy.c b/mm/mempolicy.c
93337 index 30cc47f8..c12ef34 100644
93338 --- a/mm/mempolicy.c
93339 +++ b/mm/mempolicy.c
93340 @@ -750,6 +750,10 @@ static int mbind_range(struct mm_struct *mm, unsigned long start,
93341 unsigned long vmstart;
93342 unsigned long vmend;
93343
93344 +#ifdef CONFIG_PAX_SEGMEXEC
93345 + struct vm_area_struct *vma_m;
93346 +#endif
93347 +
93348 vma = find_vma(mm, start);
93349 if (!vma || vma->vm_start > start)
93350 return -EFAULT;
93351 @@ -793,6 +797,16 @@ static int mbind_range(struct mm_struct *mm, unsigned long start,
93352 err = vma_replace_policy(vma, new_pol);
93353 if (err)
93354 goto out;
93355 +
93356 +#ifdef CONFIG_PAX_SEGMEXEC
93357 + vma_m = pax_find_mirror_vma(vma);
93358 + if (vma_m) {
93359 + err = vma_replace_policy(vma_m, new_pol);
93360 + if (err)
93361 + goto out;
93362 + }
93363 +#endif
93364 +
93365 }
93366
93367 out:
93368 @@ -1225,6 +1239,17 @@ static long do_mbind(unsigned long start, unsigned long len,
93369
93370 if (end < start)
93371 return -EINVAL;
93372 +
93373 +#ifdef CONFIG_PAX_SEGMEXEC
93374 + if (mm->pax_flags & MF_PAX_SEGMEXEC) {
93375 + if (end > SEGMEXEC_TASK_SIZE)
93376 + return -EINVAL;
93377 + } else
93378 +#endif
93379 +
93380 + if (end > TASK_SIZE)
93381 + return -EINVAL;
93382 +
93383 if (end == start)
93384 return 0;
93385
93386 @@ -1453,8 +1478,7 @@ SYSCALL_DEFINE4(migrate_pages, pid_t, pid, unsigned long, maxnode,
93387 */
93388 tcred = __task_cred(task);
93389 if (!uid_eq(cred->euid, tcred->suid) && !uid_eq(cred->euid, tcred->uid) &&
93390 - !uid_eq(cred->uid, tcred->suid) && !uid_eq(cred->uid, tcred->uid) &&
93391 - !capable(CAP_SYS_NICE)) {
93392 + !uid_eq(cred->uid, tcred->suid) && !capable(CAP_SYS_NICE)) {
93393 rcu_read_unlock();
93394 err = -EPERM;
93395 goto out_put;
93396 @@ -1485,6 +1509,15 @@ SYSCALL_DEFINE4(migrate_pages, pid_t, pid, unsigned long, maxnode,
93397 goto out;
93398 }
93399
93400 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
93401 + if (mm != current->mm &&
93402 + (mm->pax_flags & MF_PAX_RANDMMAP || mm->pax_flags & MF_PAX_SEGMEXEC)) {
93403 + mmput(mm);
93404 + err = -EPERM;
93405 + goto out;
93406 + }
93407 +#endif
93408 +
93409 err = do_migrate_pages(mm, old, new,
93410 capable(CAP_SYS_NICE) ? MPOL_MF_MOVE_ALL : MPOL_MF_MOVE);
93411
93412 diff --git a/mm/migrate.c b/mm/migrate.c
93413 index bed4880..a493f67 100644
93414 --- a/mm/migrate.c
93415 +++ b/mm/migrate.c
93416 @@ -1485,8 +1485,7 @@ SYSCALL_DEFINE6(move_pages, pid_t, pid, unsigned long, nr_pages,
93417 */
93418 tcred = __task_cred(task);
93419 if (!uid_eq(cred->euid, tcred->suid) && !uid_eq(cred->euid, tcred->uid) &&
93420 - !uid_eq(cred->uid, tcred->suid) && !uid_eq(cred->uid, tcred->uid) &&
93421 - !capable(CAP_SYS_NICE)) {
93422 + !uid_eq(cred->uid, tcred->suid) && !capable(CAP_SYS_NICE)) {
93423 rcu_read_unlock();
93424 err = -EPERM;
93425 goto out;
93426 diff --git a/mm/mlock.c b/mm/mlock.c
93427 index b1eb536..091d154 100644
93428 --- a/mm/mlock.c
93429 +++ b/mm/mlock.c
93430 @@ -14,6 +14,7 @@
93431 #include <linux/pagevec.h>
93432 #include <linux/mempolicy.h>
93433 #include <linux/syscalls.h>
93434 +#include <linux/security.h>
93435 #include <linux/sched.h>
93436 #include <linux/export.h>
93437 #include <linux/rmap.h>
93438 @@ -606,7 +607,7 @@ static int do_mlock(unsigned long start, size_t len, int on)
93439 {
93440 unsigned long nstart, end, tmp;
93441 struct vm_area_struct * vma, * prev;
93442 - int error;
93443 + int error = 0;
93444
93445 VM_BUG_ON(start & ~PAGE_MASK);
93446 VM_BUG_ON(len != PAGE_ALIGN(len));
93447 @@ -615,6 +616,9 @@ static int do_mlock(unsigned long start, size_t len, int on)
93448 return -EINVAL;
93449 if (end == start)
93450 return 0;
93451 + if (end > TASK_SIZE)
93452 + return -EINVAL;
93453 +
93454 vma = find_vma(current->mm, start);
93455 if (!vma || vma->vm_start > start)
93456 return -ENOMEM;
93457 @@ -626,6 +630,11 @@ static int do_mlock(unsigned long start, size_t len, int on)
93458 for (nstart = start ; ; ) {
93459 vm_flags_t newflags;
93460
93461 +#ifdef CONFIG_PAX_SEGMEXEC
93462 + if ((current->mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_start >= SEGMEXEC_TASK_SIZE))
93463 + break;
93464 +#endif
93465 +
93466 /* Here we know that vma->vm_start <= nstart < vma->vm_end. */
93467
93468 newflags = vma->vm_flags & ~VM_LOCKED;
93469 @@ -739,6 +748,7 @@ SYSCALL_DEFINE2(mlock, unsigned long, start, size_t, len)
93470 locked += current->mm->locked_vm;
93471
93472 /* check against resource limits */
93473 + gr_learn_resource(current, RLIMIT_MEMLOCK, (current->mm->locked_vm << PAGE_SHIFT) + len, 1);
93474 if ((locked <= lock_limit) || capable(CAP_IPC_LOCK))
93475 error = do_mlock(start, len, 1);
93476
93477 @@ -776,6 +786,11 @@ static int do_mlockall(int flags)
93478 for (vma = current->mm->mmap; vma ; vma = prev->vm_next) {
93479 vm_flags_t newflags;
93480
93481 +#ifdef CONFIG_PAX_SEGMEXEC
93482 + if ((current->mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_start >= SEGMEXEC_TASK_SIZE))
93483 + break;
93484 +#endif
93485 +
93486 newflags = vma->vm_flags & ~VM_LOCKED;
93487 if (flags & MCL_CURRENT)
93488 newflags |= VM_LOCKED;
93489 @@ -807,8 +822,10 @@ SYSCALL_DEFINE1(mlockall, int, flags)
93490 lock_limit >>= PAGE_SHIFT;
93491
93492 ret = -ENOMEM;
93493 +
93494 + gr_learn_resource(current, RLIMIT_MEMLOCK, current->mm->total_vm << PAGE_SHIFT, 1);
93495 +
93496 down_write(&current->mm->mmap_sem);
93497 -
93498 if (!(flags & MCL_CURRENT) || (current->mm->total_vm <= lock_limit) ||
93499 capable(CAP_IPC_LOCK))
93500 ret = do_mlockall(flags);
93501 diff --git a/mm/mmap.c b/mm/mmap.c
93502 index b1202cf..ee487f8 100644
93503 --- a/mm/mmap.c
93504 +++ b/mm/mmap.c
93505 @@ -37,6 +37,7 @@
93506 #include <linux/sched/sysctl.h>
93507 #include <linux/notifier.h>
93508 #include <linux/memory.h>
93509 +#include <linux/random.h>
93510
93511 #include <asm/uaccess.h>
93512 #include <asm/cacheflush.h>
93513 @@ -53,6 +54,16 @@
93514 #define arch_rebalance_pgtables(addr, len) (addr)
93515 #endif
93516
93517 +static inline void verify_mm_writelocked(struct mm_struct *mm)
93518 +{
93519 +#if defined(CONFIG_DEBUG_VM) || defined(CONFIG_PAX)
93520 + if (unlikely(down_read_trylock(&mm->mmap_sem))) {
93521 + up_read(&mm->mmap_sem);
93522 + BUG();
93523 + }
93524 +#endif
93525 +}
93526 +
93527 static void unmap_region(struct mm_struct *mm,
93528 struct vm_area_struct *vma, struct vm_area_struct *prev,
93529 unsigned long start, unsigned long end);
93530 @@ -72,16 +83,25 @@ static void unmap_region(struct mm_struct *mm,
93531 * x: (no) no x: (no) yes x: (no) yes x: (yes) yes
93532 *
93533 */
93534 -pgprot_t protection_map[16] = {
93535 +pgprot_t protection_map[16] __read_only = {
93536 __P000, __P001, __P010, __P011, __P100, __P101, __P110, __P111,
93537 __S000, __S001, __S010, __S011, __S100, __S101, __S110, __S111
93538 };
93539
93540 -pgprot_t vm_get_page_prot(unsigned long vm_flags)
93541 +pgprot_t vm_get_page_prot(vm_flags_t vm_flags)
93542 {
93543 - return __pgprot(pgprot_val(protection_map[vm_flags &
93544 + pgprot_t prot = __pgprot(pgprot_val(protection_map[vm_flags &
93545 (VM_READ|VM_WRITE|VM_EXEC|VM_SHARED)]) |
93546 pgprot_val(arch_vm_get_page_prot(vm_flags)));
93547 +
93548 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
93549 + if (!(__supported_pte_mask & _PAGE_NX) &&
93550 + (vm_flags & (VM_PAGEEXEC | VM_EXEC)) == VM_PAGEEXEC &&
93551 + (vm_flags & (VM_READ | VM_WRITE)))
93552 + prot = __pgprot(pte_val(pte_exprotect(__pte(pgprot_val(prot)))));
93553 +#endif
93554 +
93555 + return prot;
93556 }
93557 EXPORT_SYMBOL(vm_get_page_prot);
93558
93559 @@ -91,6 +111,7 @@ unsigned long sysctl_overcommit_kbytes __read_mostly;
93560 int sysctl_max_map_count __read_mostly = DEFAULT_MAX_MAP_COUNT;
93561 unsigned long sysctl_user_reserve_kbytes __read_mostly = 1UL << 17; /* 128MB */
93562 unsigned long sysctl_admin_reserve_kbytes __read_mostly = 1UL << 13; /* 8MB */
93563 +unsigned long sysctl_heap_stack_gap __read_mostly = 64*1024;
93564 /*
93565 * Make sure vm_committed_as in one cacheline and not cacheline shared with
93566 * other variables. It can be updated by several CPUs frequently.
93567 @@ -247,6 +268,7 @@ static struct vm_area_struct *remove_vma(struct vm_area_struct *vma)
93568 struct vm_area_struct *next = vma->vm_next;
93569
93570 might_sleep();
93571 + BUG_ON(vma->vm_mirror);
93572 if (vma->vm_ops && vma->vm_ops->close)
93573 vma->vm_ops->close(vma);
93574 if (vma->vm_file)
93575 @@ -291,6 +313,7 @@ SYSCALL_DEFINE1(brk, unsigned long, brk)
93576 * not page aligned -Ram Gupta
93577 */
93578 rlim = rlimit(RLIMIT_DATA);
93579 + gr_learn_resource(current, RLIMIT_DATA, (brk - mm->start_brk) + (mm->end_data - mm->start_data), 1);
93580 if (rlim < RLIM_INFINITY && (brk - mm->start_brk) +
93581 (mm->end_data - mm->start_data) > rlim)
93582 goto out;
93583 @@ -942,6 +965,12 @@ static int
93584 can_vma_merge_before(struct vm_area_struct *vma, unsigned long vm_flags,
93585 struct anon_vma *anon_vma, struct file *file, pgoff_t vm_pgoff)
93586 {
93587 +
93588 +#ifdef CONFIG_PAX_SEGMEXEC
93589 + if ((vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) && vma->vm_start == SEGMEXEC_TASK_SIZE)
93590 + return 0;
93591 +#endif
93592 +
93593 if (is_mergeable_vma(vma, file, vm_flags) &&
93594 is_mergeable_anon_vma(anon_vma, vma->anon_vma, vma)) {
93595 if (vma->vm_pgoff == vm_pgoff)
93596 @@ -961,6 +990,12 @@ static int
93597 can_vma_merge_after(struct vm_area_struct *vma, unsigned long vm_flags,
93598 struct anon_vma *anon_vma, struct file *file, pgoff_t vm_pgoff)
93599 {
93600 +
93601 +#ifdef CONFIG_PAX_SEGMEXEC
93602 + if ((vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) && vma->vm_end == SEGMEXEC_TASK_SIZE)
93603 + return 0;
93604 +#endif
93605 +
93606 if (is_mergeable_vma(vma, file, vm_flags) &&
93607 is_mergeable_anon_vma(anon_vma, vma->anon_vma, vma)) {
93608 pgoff_t vm_pglen;
93609 @@ -1003,13 +1038,20 @@ can_vma_merge_after(struct vm_area_struct *vma, unsigned long vm_flags,
93610 struct vm_area_struct *vma_merge(struct mm_struct *mm,
93611 struct vm_area_struct *prev, unsigned long addr,
93612 unsigned long end, unsigned long vm_flags,
93613 - struct anon_vma *anon_vma, struct file *file,
93614 + struct anon_vma *anon_vma, struct file *file,
93615 pgoff_t pgoff, struct mempolicy *policy)
93616 {
93617 pgoff_t pglen = (end - addr) >> PAGE_SHIFT;
93618 struct vm_area_struct *area, *next;
93619 int err;
93620
93621 +#ifdef CONFIG_PAX_SEGMEXEC
93622 + unsigned long addr_m = addr + SEGMEXEC_TASK_SIZE, end_m = end + SEGMEXEC_TASK_SIZE;
93623 + struct vm_area_struct *area_m = NULL, *next_m = NULL, *prev_m = NULL;
93624 +
93625 + BUG_ON((mm->pax_flags & MF_PAX_SEGMEXEC) && SEGMEXEC_TASK_SIZE < end);
93626 +#endif
93627 +
93628 /*
93629 * We later require that vma->vm_flags == vm_flags,
93630 * so this tests vma->vm_flags & VM_SPECIAL, too.
93631 @@ -1025,6 +1067,15 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
93632 if (next && next->vm_end == end) /* cases 6, 7, 8 */
93633 next = next->vm_next;
93634
93635 +#ifdef CONFIG_PAX_SEGMEXEC
93636 + if (prev)
93637 + prev_m = pax_find_mirror_vma(prev);
93638 + if (area)
93639 + area_m = pax_find_mirror_vma(area);
93640 + if (next)
93641 + next_m = pax_find_mirror_vma(next);
93642 +#endif
93643 +
93644 /*
93645 * Can it merge with the predecessor?
93646 */
93647 @@ -1044,9 +1095,24 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
93648 /* cases 1, 6 */
93649 err = vma_adjust(prev, prev->vm_start,
93650 next->vm_end, prev->vm_pgoff, NULL);
93651 - } else /* cases 2, 5, 7 */
93652 +
93653 +#ifdef CONFIG_PAX_SEGMEXEC
93654 + if (!err && prev_m)
93655 + err = vma_adjust(prev_m, prev_m->vm_start,
93656 + next_m->vm_end, prev_m->vm_pgoff, NULL);
93657 +#endif
93658 +
93659 + } else { /* cases 2, 5, 7 */
93660 err = vma_adjust(prev, prev->vm_start,
93661 end, prev->vm_pgoff, NULL);
93662 +
93663 +#ifdef CONFIG_PAX_SEGMEXEC
93664 + if (!err && prev_m)
93665 + err = vma_adjust(prev_m, prev_m->vm_start,
93666 + end_m, prev_m->vm_pgoff, NULL);
93667 +#endif
93668 +
93669 + }
93670 if (err)
93671 return NULL;
93672 khugepaged_enter_vma_merge(prev);
93673 @@ -1060,12 +1126,27 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
93674 mpol_equal(policy, vma_policy(next)) &&
93675 can_vma_merge_before(next, vm_flags,
93676 anon_vma, file, pgoff+pglen)) {
93677 - if (prev && addr < prev->vm_end) /* case 4 */
93678 + if (prev && addr < prev->vm_end) { /* case 4 */
93679 err = vma_adjust(prev, prev->vm_start,
93680 addr, prev->vm_pgoff, NULL);
93681 - else /* cases 3, 8 */
93682 +
93683 +#ifdef CONFIG_PAX_SEGMEXEC
93684 + if (!err && prev_m)
93685 + err = vma_adjust(prev_m, prev_m->vm_start,
93686 + addr_m, prev_m->vm_pgoff, NULL);
93687 +#endif
93688 +
93689 + } else { /* cases 3, 8 */
93690 err = vma_adjust(area, addr, next->vm_end,
93691 next->vm_pgoff - pglen, NULL);
93692 +
93693 +#ifdef CONFIG_PAX_SEGMEXEC
93694 + if (!err && area_m)
93695 + err = vma_adjust(area_m, addr_m, next_m->vm_end,
93696 + next_m->vm_pgoff - pglen, NULL);
93697 +#endif
93698 +
93699 + }
93700 if (err)
93701 return NULL;
93702 khugepaged_enter_vma_merge(area);
93703 @@ -1174,8 +1255,10 @@ none:
93704 void vm_stat_account(struct mm_struct *mm, unsigned long flags,
93705 struct file *file, long pages)
93706 {
93707 - const unsigned long stack_flags
93708 - = VM_STACK_FLAGS & (VM_GROWSUP|VM_GROWSDOWN);
93709 +
93710 +#ifdef CONFIG_PAX_RANDMMAP
93711 + if (!(mm->pax_flags & MF_PAX_RANDMMAP) || (flags & (VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)))
93712 +#endif
93713
93714 mm->total_vm += pages;
93715
93716 @@ -1183,7 +1266,7 @@ void vm_stat_account(struct mm_struct *mm, unsigned long flags,
93717 mm->shared_vm += pages;
93718 if ((flags & (VM_EXEC|VM_WRITE)) == VM_EXEC)
93719 mm->exec_vm += pages;
93720 - } else if (flags & stack_flags)
93721 + } else if (flags & (VM_GROWSUP|VM_GROWSDOWN))
93722 mm->stack_vm += pages;
93723 }
93724 #endif /* CONFIG_PROC_FS */
93725 @@ -1213,6 +1296,7 @@ static inline int mlock_future_check(struct mm_struct *mm,
93726 locked += mm->locked_vm;
93727 lock_limit = rlimit(RLIMIT_MEMLOCK);
93728 lock_limit >>= PAGE_SHIFT;
93729 + gr_learn_resource(current, RLIMIT_MEMLOCK, locked << PAGE_SHIFT, 1);
93730 if (locked > lock_limit && !capable(CAP_IPC_LOCK))
93731 return -EAGAIN;
93732 }
93733 @@ -1239,7 +1323,7 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
93734 * (the exception is when the underlying filesystem is noexec
93735 * mounted, in which case we dont add PROT_EXEC.)
93736 */
93737 - if ((prot & PROT_READ) && (current->personality & READ_IMPLIES_EXEC))
93738 + if ((prot & (PROT_READ | PROT_WRITE)) && (current->personality & READ_IMPLIES_EXEC))
93739 if (!(file && (file->f_path.mnt->mnt_flags & MNT_NOEXEC)))
93740 prot |= PROT_EXEC;
93741
93742 @@ -1265,7 +1349,7 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
93743 /* Obtain the address to map to. we verify (or select) it and ensure
93744 * that it represents a valid section of the address space.
93745 */
93746 - addr = get_unmapped_area(file, addr, len, pgoff, flags);
93747 + addr = get_unmapped_area(file, addr, len, pgoff, flags | ((prot & PROT_EXEC) ? MAP_EXECUTABLE : 0));
93748 if (addr & ~PAGE_MASK)
93749 return addr;
93750
93751 @@ -1276,6 +1360,43 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
93752 vm_flags = calc_vm_prot_bits(prot) | calc_vm_flag_bits(flags) |
93753 mm->def_flags | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC;
93754
93755 +#ifdef CONFIG_PAX_MPROTECT
93756 + if (mm->pax_flags & MF_PAX_MPROTECT) {
93757 +
93758 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
93759 + if (file && !pgoff && (vm_flags & VM_EXEC) && mm->binfmt &&
93760 + mm->binfmt->handle_mmap)
93761 + mm->binfmt->handle_mmap(file);
93762 +#endif
93763 +
93764 +#ifndef CONFIG_PAX_MPROTECT_COMPAT
93765 + if ((vm_flags & (VM_WRITE | VM_EXEC)) == (VM_WRITE | VM_EXEC)) {
93766 + gr_log_rwxmmap(file);
93767 +
93768 +#ifdef CONFIG_PAX_EMUPLT
93769 + vm_flags &= ~VM_EXEC;
93770 +#else
93771 + return -EPERM;
93772 +#endif
93773 +
93774 + }
93775 +
93776 + if (!(vm_flags & VM_EXEC))
93777 + vm_flags &= ~VM_MAYEXEC;
93778 +#else
93779 + if ((vm_flags & (VM_WRITE | VM_EXEC)) != VM_EXEC)
93780 + vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
93781 +#endif
93782 + else
93783 + vm_flags &= ~VM_MAYWRITE;
93784 + }
93785 +#endif
93786 +
93787 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
93788 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && file)
93789 + vm_flags &= ~VM_PAGEEXEC;
93790 +#endif
93791 +
93792 if (flags & MAP_LOCKED)
93793 if (!can_do_mlock())
93794 return -EPERM;
93795 @@ -1363,6 +1484,9 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
93796 vm_flags |= VM_NORESERVE;
93797 }
93798
93799 + if (!gr_acl_handle_mmap(file, prot))
93800 + return -EACCES;
93801 +
93802 addr = mmap_region(file, addr, len, vm_flags, pgoff);
93803 if (!IS_ERR_VALUE(addr) &&
93804 ((vm_flags & VM_LOCKED) ||
93805 @@ -1456,7 +1580,7 @@ int vma_wants_writenotify(struct vm_area_struct *vma)
93806 vm_flags_t vm_flags = vma->vm_flags;
93807
93808 /* If it was private or non-writable, the write bit is already clear */
93809 - if ((vm_flags & (VM_WRITE|VM_SHARED)) != ((VM_WRITE|VM_SHARED)))
93810 + if ((vm_flags & (VM_WRITE|VM_SHARED)) != (VM_WRITE|VM_SHARED))
93811 return 0;
93812
93813 /* The backer wishes to know when pages are first written to? */
93814 @@ -1502,7 +1626,22 @@ unsigned long mmap_region(struct file *file, unsigned long addr,
93815 struct rb_node **rb_link, *rb_parent;
93816 unsigned long charged = 0;
93817
93818 +#ifdef CONFIG_PAX_SEGMEXEC
93819 + struct vm_area_struct *vma_m = NULL;
93820 +#endif
93821 +
93822 + /*
93823 + * mm->mmap_sem is required to protect against another thread
93824 + * changing the mappings in case we sleep.
93825 + */
93826 + verify_mm_writelocked(mm);
93827 +
93828 /* Check against address space limit. */
93829 +
93830 +#ifdef CONFIG_PAX_RANDMMAP
93831 + if (!(mm->pax_flags & MF_PAX_RANDMMAP) || (vm_flags & (VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)))
93832 +#endif
93833 +
93834 if (!may_expand_vm(mm, len >> PAGE_SHIFT)) {
93835 unsigned long nr_pages;
93836
93837 @@ -1521,11 +1660,10 @@ unsigned long mmap_region(struct file *file, unsigned long addr,
93838
93839 /* Clear old maps */
93840 error = -ENOMEM;
93841 -munmap_back:
93842 if (find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent)) {
93843 if (do_munmap(mm, addr, len))
93844 return -ENOMEM;
93845 - goto munmap_back;
93846 + BUG_ON(find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent));
93847 }
93848
93849 /*
93850 @@ -1556,6 +1694,16 @@ munmap_back:
93851 goto unacct_error;
93852 }
93853
93854 +#ifdef CONFIG_PAX_SEGMEXEC
93855 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (vm_flags & VM_EXEC)) {
93856 + vma_m = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
93857 + if (!vma_m) {
93858 + error = -ENOMEM;
93859 + goto free_vma;
93860 + }
93861 + }
93862 +#endif
93863 +
93864 vma->vm_mm = mm;
93865 vma->vm_start = addr;
93866 vma->vm_end = addr + len;
93867 @@ -1575,6 +1723,13 @@ munmap_back:
93868 if (error)
93869 goto unmap_and_free_vma;
93870
93871 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
93872 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && !(vma->vm_flags & VM_SPECIAL)) {
93873 + vma->vm_flags |= VM_PAGEEXEC;
93874 + vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
93875 + }
93876 +#endif
93877 +
93878 /* Can addr have changed??
93879 *
93880 * Answer: Yes, several device drivers can do it in their
93881 @@ -1608,6 +1763,12 @@ munmap_back:
93882 }
93883
93884 vma_link(mm, vma, prev, rb_link, rb_parent);
93885 +
93886 +#ifdef CONFIG_PAX_SEGMEXEC
93887 + if (vma_m)
93888 + BUG_ON(pax_mirror_vma(vma_m, vma));
93889 +#endif
93890 +
93891 /* Once vma denies write, undo our temporary denial count */
93892 if (vm_flags & VM_DENYWRITE)
93893 allow_write_access(file);
93894 @@ -1616,6 +1777,7 @@ out:
93895 perf_event_mmap(vma);
93896
93897 vm_stat_account(mm, vm_flags, file, len >> PAGE_SHIFT);
93898 + track_exec_limit(mm, addr, addr + len, vm_flags);
93899 if (vm_flags & VM_LOCKED) {
93900 if (!((vm_flags & VM_SPECIAL) || is_vm_hugetlb_page(vma) ||
93901 vma == get_gate_vma(current->mm)))
93902 @@ -1648,6 +1810,12 @@ unmap_and_free_vma:
93903 unmap_region(mm, vma, prev, vma->vm_start, vma->vm_end);
93904 charged = 0;
93905 free_vma:
93906 +
93907 +#ifdef CONFIG_PAX_SEGMEXEC
93908 + if (vma_m)
93909 + kmem_cache_free(vm_area_cachep, vma_m);
93910 +#endif
93911 +
93912 kmem_cache_free(vm_area_cachep, vma);
93913 unacct_error:
93914 if (charged)
93915 @@ -1655,7 +1823,63 @@ unacct_error:
93916 return error;
93917 }
93918
93919 -unsigned long unmapped_area(struct vm_unmapped_area_info *info)
93920 +#ifdef CONFIG_GRKERNSEC_RAND_THREADSTACK
93921 +unsigned long gr_rand_threadstack_offset(const struct mm_struct *mm, const struct file *filp, unsigned long flags)
93922 +{
93923 + if ((mm->pax_flags & MF_PAX_RANDMMAP) && !filp && (flags & MAP_STACK))
93924 + return ((prandom_u32() & 0xFF) + 1) << PAGE_SHIFT;
93925 +
93926 + return 0;
93927 +}
93928 +#endif
93929 +
93930 +bool check_heap_stack_gap(const struct vm_area_struct *vma, unsigned long addr, unsigned long len, unsigned long offset)
93931 +{
93932 + if (!vma) {
93933 +#ifdef CONFIG_STACK_GROWSUP
93934 + if (addr > sysctl_heap_stack_gap)
93935 + vma = find_vma(current->mm, addr - sysctl_heap_stack_gap);
93936 + else
93937 + vma = find_vma(current->mm, 0);
93938 + if (vma && (vma->vm_flags & VM_GROWSUP))
93939 + return false;
93940 +#endif
93941 + return true;
93942 + }
93943 +
93944 + if (addr + len > vma->vm_start)
93945 + return false;
93946 +
93947 + if (vma->vm_flags & VM_GROWSDOWN)
93948 + return sysctl_heap_stack_gap <= vma->vm_start - addr - len;
93949 +#ifdef CONFIG_STACK_GROWSUP
93950 + else if (vma->vm_prev && (vma->vm_prev->vm_flags & VM_GROWSUP))
93951 + return addr - vma->vm_prev->vm_end >= sysctl_heap_stack_gap;
93952 +#endif
93953 + else if (offset)
93954 + return offset <= vma->vm_start - addr - len;
93955 +
93956 + return true;
93957 +}
93958 +
93959 +unsigned long skip_heap_stack_gap(const struct vm_area_struct *vma, unsigned long len, unsigned long offset)
93960 +{
93961 + if (vma->vm_start < len)
93962 + return -ENOMEM;
93963 +
93964 + if (!(vma->vm_flags & VM_GROWSDOWN)) {
93965 + if (offset <= vma->vm_start - len)
93966 + return vma->vm_start - len - offset;
93967 + else
93968 + return -ENOMEM;
93969 + }
93970 +
93971 + if (sysctl_heap_stack_gap <= vma->vm_start - len)
93972 + return vma->vm_start - len - sysctl_heap_stack_gap;
93973 + return -ENOMEM;
93974 +}
93975 +
93976 +unsigned long unmapped_area(const struct vm_unmapped_area_info *info)
93977 {
93978 /*
93979 * We implement the search by looking for an rbtree node that
93980 @@ -1703,11 +1927,29 @@ unsigned long unmapped_area(struct vm_unmapped_area_info *info)
93981 }
93982 }
93983
93984 - gap_start = vma->vm_prev ? vma->vm_prev->vm_end : 0;
93985 + gap_start = vma->vm_prev ? vma->vm_prev->vm_end: 0;
93986 check_current:
93987 /* Check if current node has a suitable gap */
93988 if (gap_start > high_limit)
93989 return -ENOMEM;
93990 +
93991 + if (gap_end - gap_start > info->threadstack_offset)
93992 + gap_start += info->threadstack_offset;
93993 + else
93994 + gap_start = gap_end;
93995 +
93996 + if (vma->vm_prev && (vma->vm_prev->vm_flags & VM_GROWSUP)) {
93997 + if (gap_end - gap_start > sysctl_heap_stack_gap)
93998 + gap_start += sysctl_heap_stack_gap;
93999 + else
94000 + gap_start = gap_end;
94001 + }
94002 + if (vma->vm_flags & VM_GROWSDOWN) {
94003 + if (gap_end - gap_start > sysctl_heap_stack_gap)
94004 + gap_end -= sysctl_heap_stack_gap;
94005 + else
94006 + gap_end = gap_start;
94007 + }
94008 if (gap_end >= low_limit && gap_end - gap_start >= length)
94009 goto found;
94010
94011 @@ -1757,7 +1999,7 @@ found:
94012 return gap_start;
94013 }
94014
94015 -unsigned long unmapped_area_topdown(struct vm_unmapped_area_info *info)
94016 +unsigned long unmapped_area_topdown(const struct vm_unmapped_area_info *info)
94017 {
94018 struct mm_struct *mm = current->mm;
94019 struct vm_area_struct *vma;
94020 @@ -1811,6 +2053,24 @@ check_current:
94021 gap_end = vma->vm_start;
94022 if (gap_end < low_limit)
94023 return -ENOMEM;
94024 +
94025 + if (gap_end - gap_start > info->threadstack_offset)
94026 + gap_end -= info->threadstack_offset;
94027 + else
94028 + gap_end = gap_start;
94029 +
94030 + if (vma->vm_prev && (vma->vm_prev->vm_flags & VM_GROWSUP)) {
94031 + if (gap_end - gap_start > sysctl_heap_stack_gap)
94032 + gap_start += sysctl_heap_stack_gap;
94033 + else
94034 + gap_start = gap_end;
94035 + }
94036 + if (vma->vm_flags & VM_GROWSDOWN) {
94037 + if (gap_end - gap_start > sysctl_heap_stack_gap)
94038 + gap_end -= sysctl_heap_stack_gap;
94039 + else
94040 + gap_end = gap_start;
94041 + }
94042 if (gap_start <= high_limit && gap_end - gap_start >= length)
94043 goto found;
94044
94045 @@ -1874,6 +2134,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
94046 struct mm_struct *mm = current->mm;
94047 struct vm_area_struct *vma;
94048 struct vm_unmapped_area_info info;
94049 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
94050
94051 if (len > TASK_SIZE - mmap_min_addr)
94052 return -ENOMEM;
94053 @@ -1881,11 +2142,15 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
94054 if (flags & MAP_FIXED)
94055 return addr;
94056
94057 +#ifdef CONFIG_PAX_RANDMMAP
94058 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
94059 +#endif
94060 +
94061 if (addr) {
94062 addr = PAGE_ALIGN(addr);
94063 vma = find_vma(mm, addr);
94064 if (TASK_SIZE - len >= addr && addr >= mmap_min_addr &&
94065 - (!vma || addr + len <= vma->vm_start))
94066 + check_heap_stack_gap(vma, addr, len, offset))
94067 return addr;
94068 }
94069
94070 @@ -1894,6 +2159,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
94071 info.low_limit = mm->mmap_base;
94072 info.high_limit = TASK_SIZE;
94073 info.align_mask = 0;
94074 + info.threadstack_offset = offset;
94075 return vm_unmapped_area(&info);
94076 }
94077 #endif
94078 @@ -1912,6 +2178,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
94079 struct mm_struct *mm = current->mm;
94080 unsigned long addr = addr0;
94081 struct vm_unmapped_area_info info;
94082 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
94083
94084 /* requested length too big for entire address space */
94085 if (len > TASK_SIZE - mmap_min_addr)
94086 @@ -1920,12 +2187,16 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
94087 if (flags & MAP_FIXED)
94088 return addr;
94089
94090 +#ifdef CONFIG_PAX_RANDMMAP
94091 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
94092 +#endif
94093 +
94094 /* requesting a specific address */
94095 if (addr) {
94096 addr = PAGE_ALIGN(addr);
94097 vma = find_vma(mm, addr);
94098 if (TASK_SIZE - len >= addr && addr >= mmap_min_addr &&
94099 - (!vma || addr + len <= vma->vm_start))
94100 + check_heap_stack_gap(vma, addr, len, offset))
94101 return addr;
94102 }
94103
94104 @@ -1934,6 +2205,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
94105 info.low_limit = max(PAGE_SIZE, mmap_min_addr);
94106 info.high_limit = mm->mmap_base;
94107 info.align_mask = 0;
94108 + info.threadstack_offset = offset;
94109 addr = vm_unmapped_area(&info);
94110
94111 /*
94112 @@ -1946,6 +2218,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
94113 VM_BUG_ON(addr != -ENOMEM);
94114 info.flags = 0;
94115 info.low_limit = TASK_UNMAPPED_BASE;
94116 +
94117 +#ifdef CONFIG_PAX_RANDMMAP
94118 + if (mm->pax_flags & MF_PAX_RANDMMAP)
94119 + info.low_limit += mm->delta_mmap;
94120 +#endif
94121 +
94122 info.high_limit = TASK_SIZE;
94123 addr = vm_unmapped_area(&info);
94124 }
94125 @@ -2046,6 +2324,28 @@ find_vma_prev(struct mm_struct *mm, unsigned long addr,
94126 return vma;
94127 }
94128
94129 +#ifdef CONFIG_PAX_SEGMEXEC
94130 +struct vm_area_struct *pax_find_mirror_vma(struct vm_area_struct *vma)
94131 +{
94132 + struct vm_area_struct *vma_m;
94133 +
94134 + BUG_ON(!vma || vma->vm_start >= vma->vm_end);
94135 + if (!(vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) || !(vma->vm_flags & VM_EXEC)) {
94136 + BUG_ON(vma->vm_mirror);
94137 + return NULL;
94138 + }
94139 + BUG_ON(vma->vm_start < SEGMEXEC_TASK_SIZE && SEGMEXEC_TASK_SIZE < vma->vm_end);
94140 + vma_m = vma->vm_mirror;
94141 + BUG_ON(!vma_m || vma_m->vm_mirror != vma);
94142 + BUG_ON(vma->vm_file != vma_m->vm_file);
94143 + BUG_ON(vma->vm_end - vma->vm_start != vma_m->vm_end - vma_m->vm_start);
94144 + BUG_ON(vma->vm_pgoff != vma_m->vm_pgoff);
94145 + BUG_ON(vma->anon_vma != vma_m->anon_vma && vma->anon_vma->root != vma_m->anon_vma->root);
94146 + BUG_ON((vma->vm_flags ^ vma_m->vm_flags) & ~(VM_WRITE | VM_MAYWRITE | VM_ACCOUNT | VM_LOCKED));
94147 + return vma_m;
94148 +}
94149 +#endif
94150 +
94151 /*
94152 * Verify that the stack growth is acceptable and
94153 * update accounting. This is shared with both the
94154 @@ -2062,6 +2362,7 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
94155 return -ENOMEM;
94156
94157 /* Stack limit test */
94158 + gr_learn_resource(current, RLIMIT_STACK, size, 1);
94159 if (size > ACCESS_ONCE(rlim[RLIMIT_STACK].rlim_cur))
94160 return -ENOMEM;
94161
94162 @@ -2072,6 +2373,7 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
94163 locked = mm->locked_vm + grow;
94164 limit = ACCESS_ONCE(rlim[RLIMIT_MEMLOCK].rlim_cur);
94165 limit >>= PAGE_SHIFT;
94166 + gr_learn_resource(current, RLIMIT_MEMLOCK, locked << PAGE_SHIFT, 1);
94167 if (locked > limit && !capable(CAP_IPC_LOCK))
94168 return -ENOMEM;
94169 }
94170 @@ -2101,37 +2403,48 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
94171 * PA-RISC uses this for its stack; IA64 for its Register Backing Store.
94172 * vma is the last one with address > vma->vm_end. Have to extend vma.
94173 */
94174 +#ifndef CONFIG_IA64
94175 +static
94176 +#endif
94177 int expand_upwards(struct vm_area_struct *vma, unsigned long address)
94178 {
94179 int error;
94180 + bool locknext;
94181
94182 if (!(vma->vm_flags & VM_GROWSUP))
94183 return -EFAULT;
94184
94185 + /* Also guard against wrapping around to address 0. */
94186 + if (address < PAGE_ALIGN(address+1))
94187 + address = PAGE_ALIGN(address+1);
94188 + else
94189 + return -ENOMEM;
94190 +
94191 /*
94192 * We must make sure the anon_vma is allocated
94193 * so that the anon_vma locking is not a noop.
94194 */
94195 if (unlikely(anon_vma_prepare(vma)))
94196 return -ENOMEM;
94197 + locknext = vma->vm_next && (vma->vm_next->vm_flags & VM_GROWSDOWN);
94198 + if (locknext && anon_vma_prepare(vma->vm_next))
94199 + return -ENOMEM;
94200 vma_lock_anon_vma(vma);
94201 + if (locknext)
94202 + vma_lock_anon_vma(vma->vm_next);
94203
94204 /*
94205 * vma->vm_start/vm_end cannot change under us because the caller
94206 * is required to hold the mmap_sem in read mode. We need the
94207 - * anon_vma lock to serialize against concurrent expand_stacks.
94208 - * Also guard against wrapping around to address 0.
94209 + * anon_vma locks to serialize against concurrent expand_stacks
94210 + * and expand_upwards.
94211 */
94212 - if (address < PAGE_ALIGN(address+4))
94213 - address = PAGE_ALIGN(address+4);
94214 - else {
94215 - vma_unlock_anon_vma(vma);
94216 - return -ENOMEM;
94217 - }
94218 error = 0;
94219
94220 /* Somebody else might have raced and expanded it already */
94221 - if (address > vma->vm_end) {
94222 + 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)
94223 + error = -ENOMEM;
94224 + else if (address > vma->vm_end && (!locknext || vma->vm_next->vm_start >= address)) {
94225 unsigned long size, grow;
94226
94227 size = address - vma->vm_start;
94228 @@ -2166,6 +2479,8 @@ int expand_upwards(struct vm_area_struct *vma, unsigned long address)
94229 }
94230 }
94231 }
94232 + if (locknext)
94233 + vma_unlock_anon_vma(vma->vm_next);
94234 vma_unlock_anon_vma(vma);
94235 khugepaged_enter_vma_merge(vma);
94236 validate_mm(vma->vm_mm);
94237 @@ -2180,6 +2495,8 @@ int expand_downwards(struct vm_area_struct *vma,
94238 unsigned long address)
94239 {
94240 int error;
94241 + bool lockprev = false;
94242 + struct vm_area_struct *prev;
94243
94244 /*
94245 * We must make sure the anon_vma is allocated
94246 @@ -2193,6 +2510,15 @@ int expand_downwards(struct vm_area_struct *vma,
94247 if (error)
94248 return error;
94249
94250 + prev = vma->vm_prev;
94251 +#if defined(CONFIG_STACK_GROWSUP) || defined(CONFIG_IA64)
94252 + lockprev = prev && (prev->vm_flags & VM_GROWSUP);
94253 +#endif
94254 + if (lockprev && anon_vma_prepare(prev))
94255 + return -ENOMEM;
94256 + if (lockprev)
94257 + vma_lock_anon_vma(prev);
94258 +
94259 vma_lock_anon_vma(vma);
94260
94261 /*
94262 @@ -2202,9 +2528,17 @@ int expand_downwards(struct vm_area_struct *vma,
94263 */
94264
94265 /* Somebody else might have raced and expanded it already */
94266 - if (address < vma->vm_start) {
94267 + if (prev && (prev->vm_flags & (VM_READ | VM_WRITE | VM_EXEC)) && address - prev->vm_end < sysctl_heap_stack_gap)
94268 + error = -ENOMEM;
94269 + else if (address < vma->vm_start && (!lockprev || prev->vm_end <= address)) {
94270 unsigned long size, grow;
94271
94272 +#ifdef CONFIG_PAX_SEGMEXEC
94273 + struct vm_area_struct *vma_m;
94274 +
94275 + vma_m = pax_find_mirror_vma(vma);
94276 +#endif
94277 +
94278 size = vma->vm_end - address;
94279 grow = (vma->vm_start - address) >> PAGE_SHIFT;
94280
94281 @@ -2229,13 +2563,27 @@ int expand_downwards(struct vm_area_struct *vma,
94282 vma->vm_pgoff -= grow;
94283 anon_vma_interval_tree_post_update_vma(vma);
94284 vma_gap_update(vma);
94285 +
94286 +#ifdef CONFIG_PAX_SEGMEXEC
94287 + if (vma_m) {
94288 + anon_vma_interval_tree_pre_update_vma(vma_m);
94289 + vma_m->vm_start -= grow << PAGE_SHIFT;
94290 + vma_m->vm_pgoff -= grow;
94291 + anon_vma_interval_tree_post_update_vma(vma_m);
94292 + vma_gap_update(vma_m);
94293 + }
94294 +#endif
94295 +
94296 spin_unlock(&vma->vm_mm->page_table_lock);
94297
94298 + track_exec_limit(vma->vm_mm, vma->vm_start, vma->vm_end, vma->vm_flags);
94299 perf_event_mmap(vma);
94300 }
94301 }
94302 }
94303 vma_unlock_anon_vma(vma);
94304 + if (lockprev)
94305 + vma_unlock_anon_vma(prev);
94306 khugepaged_enter_vma_merge(vma);
94307 validate_mm(vma->vm_mm);
94308 return error;
94309 @@ -2333,6 +2681,13 @@ static void remove_vma_list(struct mm_struct *mm, struct vm_area_struct *vma)
94310 do {
94311 long nrpages = vma_pages(vma);
94312
94313 +#ifdef CONFIG_PAX_SEGMEXEC
94314 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_start >= SEGMEXEC_TASK_SIZE)) {
94315 + vma = remove_vma(vma);
94316 + continue;
94317 + }
94318 +#endif
94319 +
94320 if (vma->vm_flags & VM_ACCOUNT)
94321 nr_accounted += nrpages;
94322 vm_stat_account(mm, vma->vm_flags, vma->vm_file, -nrpages);
94323 @@ -2377,6 +2732,16 @@ detach_vmas_to_be_unmapped(struct mm_struct *mm, struct vm_area_struct *vma,
94324 insertion_point = (prev ? &prev->vm_next : &mm->mmap);
94325 vma->vm_prev = NULL;
94326 do {
94327 +
94328 +#ifdef CONFIG_PAX_SEGMEXEC
94329 + if (vma->vm_mirror) {
94330 + BUG_ON(!vma->vm_mirror->vm_mirror || vma->vm_mirror->vm_mirror != vma);
94331 + vma->vm_mirror->vm_mirror = NULL;
94332 + vma->vm_mirror->vm_flags &= ~VM_EXEC;
94333 + vma->vm_mirror = NULL;
94334 + }
94335 +#endif
94336 +
94337 vma_rb_erase(vma, &mm->mm_rb);
94338 mm->map_count--;
94339 tail_vma = vma;
94340 @@ -2404,14 +2769,33 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
94341 struct vm_area_struct *new;
94342 int err = -ENOMEM;
94343
94344 +#ifdef CONFIG_PAX_SEGMEXEC
94345 + struct vm_area_struct *vma_m, *new_m = NULL;
94346 + unsigned long addr_m = addr + SEGMEXEC_TASK_SIZE;
94347 +#endif
94348 +
94349 if (is_vm_hugetlb_page(vma) && (addr &
94350 ~(huge_page_mask(hstate_vma(vma)))))
94351 return -EINVAL;
94352
94353 +#ifdef CONFIG_PAX_SEGMEXEC
94354 + vma_m = pax_find_mirror_vma(vma);
94355 +#endif
94356 +
94357 new = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
94358 if (!new)
94359 goto out_err;
94360
94361 +#ifdef CONFIG_PAX_SEGMEXEC
94362 + if (vma_m) {
94363 + new_m = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
94364 + if (!new_m) {
94365 + kmem_cache_free(vm_area_cachep, new);
94366 + goto out_err;
94367 + }
94368 + }
94369 +#endif
94370 +
94371 /* most fields are the same, copy all, and then fixup */
94372 *new = *vma;
94373
94374 @@ -2424,6 +2808,22 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
94375 new->vm_pgoff += ((addr - vma->vm_start) >> PAGE_SHIFT);
94376 }
94377
94378 +#ifdef CONFIG_PAX_SEGMEXEC
94379 + if (vma_m) {
94380 + *new_m = *vma_m;
94381 + INIT_LIST_HEAD(&new_m->anon_vma_chain);
94382 + new_m->vm_mirror = new;
94383 + new->vm_mirror = new_m;
94384 +
94385 + if (new_below)
94386 + new_m->vm_end = addr_m;
94387 + else {
94388 + new_m->vm_start = addr_m;
94389 + new_m->vm_pgoff += ((addr_m - vma_m->vm_start) >> PAGE_SHIFT);
94390 + }
94391 + }
94392 +#endif
94393 +
94394 err = vma_dup_policy(vma, new);
94395 if (err)
94396 goto out_free_vma;
94397 @@ -2443,6 +2843,38 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
94398 else
94399 err = vma_adjust(vma, vma->vm_start, addr, vma->vm_pgoff, new);
94400
94401 +#ifdef CONFIG_PAX_SEGMEXEC
94402 + if (!err && vma_m) {
94403 + struct mempolicy *pol = vma_policy(new);
94404 +
94405 + if (anon_vma_clone(new_m, vma_m))
94406 + goto out_free_mpol;
94407 +
94408 + mpol_get(pol);
94409 + set_vma_policy(new_m, pol);
94410 +
94411 + if (new_m->vm_file)
94412 + get_file(new_m->vm_file);
94413 +
94414 + if (new_m->vm_ops && new_m->vm_ops->open)
94415 + new_m->vm_ops->open(new_m);
94416 +
94417 + if (new_below)
94418 + err = vma_adjust(vma_m, addr_m, vma_m->vm_end, vma_m->vm_pgoff +
94419 + ((addr_m - new_m->vm_start) >> PAGE_SHIFT), new_m);
94420 + else
94421 + err = vma_adjust(vma_m, vma_m->vm_start, addr_m, vma_m->vm_pgoff, new_m);
94422 +
94423 + if (err) {
94424 + if (new_m->vm_ops && new_m->vm_ops->close)
94425 + new_m->vm_ops->close(new_m);
94426 + if (new_m->vm_file)
94427 + fput(new_m->vm_file);
94428 + mpol_put(pol);
94429 + }
94430 + }
94431 +#endif
94432 +
94433 /* Success. */
94434 if (!err)
94435 return 0;
94436 @@ -2452,10 +2884,18 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
94437 new->vm_ops->close(new);
94438 if (new->vm_file)
94439 fput(new->vm_file);
94440 - unlink_anon_vmas(new);
94441 out_free_mpol:
94442 mpol_put(vma_policy(new));
94443 out_free_vma:
94444 +
94445 +#ifdef CONFIG_PAX_SEGMEXEC
94446 + if (new_m) {
94447 + unlink_anon_vmas(new_m);
94448 + kmem_cache_free(vm_area_cachep, new_m);
94449 + }
94450 +#endif
94451 +
94452 + unlink_anon_vmas(new);
94453 kmem_cache_free(vm_area_cachep, new);
94454 out_err:
94455 return err;
94456 @@ -2468,6 +2908,15 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
94457 int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
94458 unsigned long addr, int new_below)
94459 {
94460 +
94461 +#ifdef CONFIG_PAX_SEGMEXEC
94462 + if (mm->pax_flags & MF_PAX_SEGMEXEC) {
94463 + BUG_ON(vma->vm_end > SEGMEXEC_TASK_SIZE);
94464 + if (mm->map_count >= sysctl_max_map_count-1)
94465 + return -ENOMEM;
94466 + } else
94467 +#endif
94468 +
94469 if (mm->map_count >= sysctl_max_map_count)
94470 return -ENOMEM;
94471
94472 @@ -2479,11 +2928,30 @@ int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
94473 * work. This now handles partial unmappings.
94474 * Jeremy Fitzhardinge <jeremy@goop.org>
94475 */
94476 +#ifdef CONFIG_PAX_SEGMEXEC
94477 int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
94478 {
94479 + int ret = __do_munmap(mm, start, len);
94480 + if (ret || !(mm->pax_flags & MF_PAX_SEGMEXEC))
94481 + return ret;
94482 +
94483 + return __do_munmap(mm, start + SEGMEXEC_TASK_SIZE, len);
94484 +}
94485 +
94486 +int __do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
94487 +#else
94488 +int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
94489 +#endif
94490 +{
94491 unsigned long end;
94492 struct vm_area_struct *vma, *prev, *last;
94493
94494 + /*
94495 + * mm->mmap_sem is required to protect against another thread
94496 + * changing the mappings in case we sleep.
94497 + */
94498 + verify_mm_writelocked(mm);
94499 +
94500 if ((start & ~PAGE_MASK) || start > TASK_SIZE || len > TASK_SIZE-start)
94501 return -EINVAL;
94502
94503 @@ -2558,6 +3026,8 @@ int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
94504 /* Fix up all other VM information */
94505 remove_vma_list(mm, vma);
94506
94507 + track_exec_limit(mm, start, end, 0UL);
94508 +
94509 return 0;
94510 }
94511
94512 @@ -2566,6 +3036,13 @@ int vm_munmap(unsigned long start, size_t len)
94513 int ret;
94514 struct mm_struct *mm = current->mm;
94515
94516 +
94517 +#ifdef CONFIG_PAX_SEGMEXEC
94518 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) &&
94519 + (len > SEGMEXEC_TASK_SIZE || start > SEGMEXEC_TASK_SIZE-len))
94520 + return -EINVAL;
94521 +#endif
94522 +
94523 down_write(&mm->mmap_sem);
94524 ret = do_munmap(mm, start, len);
94525 up_write(&mm->mmap_sem);
94526 @@ -2579,16 +3056,6 @@ SYSCALL_DEFINE2(munmap, unsigned long, addr, size_t, len)
94527 return vm_munmap(addr, len);
94528 }
94529
94530 -static inline void verify_mm_writelocked(struct mm_struct *mm)
94531 -{
94532 -#ifdef CONFIG_DEBUG_VM
94533 - if (unlikely(down_read_trylock(&mm->mmap_sem))) {
94534 - WARN_ON(1);
94535 - up_read(&mm->mmap_sem);
94536 - }
94537 -#endif
94538 -}
94539 -
94540 /*
94541 * this is really a simplified "do_mmap". it only handles
94542 * anonymous maps. eventually we may be able to do some
94543 @@ -2602,6 +3069,7 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
94544 struct rb_node ** rb_link, * rb_parent;
94545 pgoff_t pgoff = addr >> PAGE_SHIFT;
94546 int error;
94547 + unsigned long charged;
94548
94549 len = PAGE_ALIGN(len);
94550 if (!len)
94551 @@ -2609,10 +3077,24 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
94552
94553 flags = VM_DATA_DEFAULT_FLAGS | VM_ACCOUNT | mm->def_flags;
94554
94555 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
94556 + if (mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
94557 + flags &= ~VM_EXEC;
94558 +
94559 +#ifdef CONFIG_PAX_MPROTECT
94560 + if (mm->pax_flags & MF_PAX_MPROTECT)
94561 + flags &= ~VM_MAYEXEC;
94562 +#endif
94563 +
94564 + }
94565 +#endif
94566 +
94567 error = get_unmapped_area(NULL, addr, len, 0, MAP_FIXED);
94568 if (error & ~PAGE_MASK)
94569 return error;
94570
94571 + charged = len >> PAGE_SHIFT;
94572 +
94573 error = mlock_future_check(mm, mm->def_flags, len);
94574 if (error)
94575 return error;
94576 @@ -2626,21 +3108,20 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
94577 /*
94578 * Clear old maps. this also does some error checking for us
94579 */
94580 - munmap_back:
94581 if (find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent)) {
94582 if (do_munmap(mm, addr, len))
94583 return -ENOMEM;
94584 - goto munmap_back;
94585 + BUG_ON(find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent));
94586 }
94587
94588 /* Check against address space limits *after* clearing old maps... */
94589 - if (!may_expand_vm(mm, len >> PAGE_SHIFT))
94590 + if (!may_expand_vm(mm, charged))
94591 return -ENOMEM;
94592
94593 if (mm->map_count > sysctl_max_map_count)
94594 return -ENOMEM;
94595
94596 - if (security_vm_enough_memory_mm(mm, len >> PAGE_SHIFT))
94597 + if (security_vm_enough_memory_mm(mm, charged))
94598 return -ENOMEM;
94599
94600 /* Can we just expand an old private anonymous mapping? */
94601 @@ -2654,7 +3135,7 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
94602 */
94603 vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
94604 if (!vma) {
94605 - vm_unacct_memory(len >> PAGE_SHIFT);
94606 + vm_unacct_memory(charged);
94607 return -ENOMEM;
94608 }
94609
94610 @@ -2668,10 +3149,11 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
94611 vma_link(mm, vma, prev, rb_link, rb_parent);
94612 out:
94613 perf_event_mmap(vma);
94614 - mm->total_vm += len >> PAGE_SHIFT;
94615 + mm->total_vm += charged;
94616 if (flags & VM_LOCKED)
94617 - mm->locked_vm += (len >> PAGE_SHIFT);
94618 + mm->locked_vm += charged;
94619 vma->vm_flags |= VM_SOFTDIRTY;
94620 + track_exec_limit(mm, addr, addr + len, flags);
94621 return addr;
94622 }
94623
94624 @@ -2733,6 +3215,7 @@ void exit_mmap(struct mm_struct *mm)
94625 while (vma) {
94626 if (vma->vm_flags & VM_ACCOUNT)
94627 nr_accounted += vma_pages(vma);
94628 + vma->vm_mirror = NULL;
94629 vma = remove_vma(vma);
94630 }
94631 vm_unacct_memory(nr_accounted);
94632 @@ -2750,6 +3233,13 @@ int insert_vm_struct(struct mm_struct *mm, struct vm_area_struct *vma)
94633 struct vm_area_struct *prev;
94634 struct rb_node **rb_link, *rb_parent;
94635
94636 +#ifdef CONFIG_PAX_SEGMEXEC
94637 + struct vm_area_struct *vma_m = NULL;
94638 +#endif
94639 +
94640 + if (security_mmap_addr(vma->vm_start))
94641 + return -EPERM;
94642 +
94643 /*
94644 * The vm_pgoff of a purely anonymous vma should be irrelevant
94645 * until its first write fault, when page's anon_vma and index
94646 @@ -2773,7 +3263,21 @@ int insert_vm_struct(struct mm_struct *mm, struct vm_area_struct *vma)
94647 security_vm_enough_memory_mm(mm, vma_pages(vma)))
94648 return -ENOMEM;
94649
94650 +#ifdef CONFIG_PAX_SEGMEXEC
94651 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_flags & VM_EXEC)) {
94652 + vma_m = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
94653 + if (!vma_m)
94654 + return -ENOMEM;
94655 + }
94656 +#endif
94657 +
94658 vma_link(mm, vma, prev, rb_link, rb_parent);
94659 +
94660 +#ifdef CONFIG_PAX_SEGMEXEC
94661 + if (vma_m)
94662 + BUG_ON(pax_mirror_vma(vma_m, vma));
94663 +#endif
94664 +
94665 return 0;
94666 }
94667
94668 @@ -2792,6 +3296,8 @@ struct vm_area_struct *copy_vma(struct vm_area_struct **vmap,
94669 struct rb_node **rb_link, *rb_parent;
94670 bool faulted_in_anon_vma = true;
94671
94672 + BUG_ON(vma->vm_mirror);
94673 +
94674 /*
94675 * If anonymous vma has not yet been faulted, update new pgoff
94676 * to match new location, to increase its chance of merging.
94677 @@ -2856,6 +3362,39 @@ struct vm_area_struct *copy_vma(struct vm_area_struct **vmap,
94678 return NULL;
94679 }
94680
94681 +#ifdef CONFIG_PAX_SEGMEXEC
94682 +long pax_mirror_vma(struct vm_area_struct *vma_m, struct vm_area_struct *vma)
94683 +{
94684 + struct vm_area_struct *prev_m;
94685 + struct rb_node **rb_link_m, *rb_parent_m;
94686 + struct mempolicy *pol_m;
94687 +
94688 + BUG_ON(!(vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) || !(vma->vm_flags & VM_EXEC));
94689 + BUG_ON(vma->vm_mirror || vma_m->vm_mirror);
94690 + BUG_ON(!mpol_equal(vma_policy(vma), vma_policy(vma_m)));
94691 + *vma_m = *vma;
94692 + INIT_LIST_HEAD(&vma_m->anon_vma_chain);
94693 + if (anon_vma_clone(vma_m, vma))
94694 + return -ENOMEM;
94695 + pol_m = vma_policy(vma_m);
94696 + mpol_get(pol_m);
94697 + set_vma_policy(vma_m, pol_m);
94698 + vma_m->vm_start += SEGMEXEC_TASK_SIZE;
94699 + vma_m->vm_end += SEGMEXEC_TASK_SIZE;
94700 + vma_m->vm_flags &= ~(VM_WRITE | VM_MAYWRITE | VM_ACCOUNT | VM_LOCKED);
94701 + vma_m->vm_page_prot = vm_get_page_prot(vma_m->vm_flags);
94702 + if (vma_m->vm_file)
94703 + get_file(vma_m->vm_file);
94704 + if (vma_m->vm_ops && vma_m->vm_ops->open)
94705 + vma_m->vm_ops->open(vma_m);
94706 + BUG_ON(find_vma_links(vma->vm_mm, vma_m->vm_start, vma_m->vm_end, &prev_m, &rb_link_m, &rb_parent_m));
94707 + vma_link(vma->vm_mm, vma_m, prev_m, rb_link_m, rb_parent_m);
94708 + vma_m->vm_mirror = vma;
94709 + vma->vm_mirror = vma_m;
94710 + return 0;
94711 +}
94712 +#endif
94713 +
94714 /*
94715 * Return true if the calling process may expand its vm space by the passed
94716 * number of pages
94717 @@ -2867,6 +3406,7 @@ int may_expand_vm(struct mm_struct *mm, unsigned long npages)
94718
94719 lim = rlimit(RLIMIT_AS) >> PAGE_SHIFT;
94720
94721 + gr_learn_resource(current, RLIMIT_AS, (cur + npages) << PAGE_SHIFT, 1);
94722 if (cur + npages > lim)
94723 return 0;
94724 return 1;
94725 @@ -2937,6 +3477,22 @@ struct vm_area_struct *_install_special_mapping(struct mm_struct *mm,
94726 vma->vm_start = addr;
94727 vma->vm_end = addr + len;
94728
94729 +#ifdef CONFIG_PAX_MPROTECT
94730 + if (mm->pax_flags & MF_PAX_MPROTECT) {
94731 +#ifndef CONFIG_PAX_MPROTECT_COMPAT
94732 + if ((vm_flags & (VM_WRITE | VM_EXEC)) == (VM_WRITE | VM_EXEC))
94733 + return ERR_PTR(-EPERM);
94734 + if (!(vm_flags & VM_EXEC))
94735 + vm_flags &= ~VM_MAYEXEC;
94736 +#else
94737 + if ((vm_flags & (VM_WRITE | VM_EXEC)) != VM_EXEC)
94738 + vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
94739 +#endif
94740 + else
94741 + vm_flags &= ~VM_MAYWRITE;
94742 + }
94743 +#endif
94744 +
94745 vma->vm_flags = vm_flags | mm->def_flags | VM_DONTEXPAND | VM_SOFTDIRTY;
94746 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
94747
94748 diff --git a/mm/mprotect.c b/mm/mprotect.c
94749 index c43d557..0b7ccd2 100644
94750 --- a/mm/mprotect.c
94751 +++ b/mm/mprotect.c
94752 @@ -24,10 +24,18 @@
94753 #include <linux/migrate.h>
94754 #include <linux/perf_event.h>
94755 #include <linux/ksm.h>
94756 +#include <linux/sched/sysctl.h>
94757 +
94758 +#ifdef CONFIG_PAX_MPROTECT
94759 +#include <linux/elf.h>
94760 +#include <linux/binfmts.h>
94761 +#endif
94762 +
94763 #include <asm/uaccess.h>
94764 #include <asm/pgtable.h>
94765 #include <asm/cacheflush.h>
94766 #include <asm/tlbflush.h>
94767 +#include <asm/mmu_context.h>
94768
94769 #ifndef pgprot_modify
94770 static inline pgprot_t pgprot_modify(pgprot_t oldprot, pgprot_t newprot)
94771 @@ -256,6 +264,48 @@ unsigned long change_protection(struct vm_area_struct *vma, unsigned long start,
94772 return pages;
94773 }
94774
94775 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
94776 +/* called while holding the mmap semaphor for writing except stack expansion */
94777 +void track_exec_limit(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long prot)
94778 +{
94779 + unsigned long oldlimit, newlimit = 0UL;
94780 +
94781 + if (!(mm->pax_flags & MF_PAX_PAGEEXEC) || (__supported_pte_mask & _PAGE_NX))
94782 + return;
94783 +
94784 + spin_lock(&mm->page_table_lock);
94785 + oldlimit = mm->context.user_cs_limit;
94786 + if ((prot & VM_EXEC) && oldlimit < end)
94787 + /* USER_CS limit moved up */
94788 + newlimit = end;
94789 + else if (!(prot & VM_EXEC) && start < oldlimit && oldlimit <= end)
94790 + /* USER_CS limit moved down */
94791 + newlimit = start;
94792 +
94793 + if (newlimit) {
94794 + mm->context.user_cs_limit = newlimit;
94795 +
94796 +#ifdef CONFIG_SMP
94797 + wmb();
94798 + cpus_clear(mm->context.cpu_user_cs_mask);
94799 + cpu_set(smp_processor_id(), mm->context.cpu_user_cs_mask);
94800 +#endif
94801 +
94802 + set_user_cs(mm->context.user_cs_base, mm->context.user_cs_limit, smp_processor_id());
94803 + }
94804 + spin_unlock(&mm->page_table_lock);
94805 + if (newlimit == end) {
94806 + struct vm_area_struct *vma = find_vma(mm, oldlimit);
94807 +
94808 + for (; vma && vma->vm_start < end; vma = vma->vm_next)
94809 + if (is_vm_hugetlb_page(vma))
94810 + hugetlb_change_protection(vma, vma->vm_start, vma->vm_end, vma->vm_page_prot);
94811 + else
94812 + change_protection(vma, vma->vm_start, vma->vm_end, vma->vm_page_prot, vma_wants_writenotify(vma), 0);
94813 + }
94814 +}
94815 +#endif
94816 +
94817 int
94818 mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
94819 unsigned long start, unsigned long end, unsigned long newflags)
94820 @@ -268,11 +318,29 @@ mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
94821 int error;
94822 int dirty_accountable = 0;
94823
94824 +#ifdef CONFIG_PAX_SEGMEXEC
94825 + struct vm_area_struct *vma_m = NULL;
94826 + unsigned long start_m, end_m;
94827 +
94828 + start_m = start + SEGMEXEC_TASK_SIZE;
94829 + end_m = end + SEGMEXEC_TASK_SIZE;
94830 +#endif
94831 +
94832 if (newflags == oldflags) {
94833 *pprev = vma;
94834 return 0;
94835 }
94836
94837 + if (newflags & (VM_READ | VM_WRITE | VM_EXEC)) {
94838 + struct vm_area_struct *prev = vma->vm_prev, *next = vma->vm_next;
94839 +
94840 + if (next && (next->vm_flags & VM_GROWSDOWN) && sysctl_heap_stack_gap > next->vm_start - end)
94841 + return -ENOMEM;
94842 +
94843 + if (prev && (prev->vm_flags & VM_GROWSUP) && sysctl_heap_stack_gap > start - prev->vm_end)
94844 + return -ENOMEM;
94845 + }
94846 +
94847 /*
94848 * If we make a private mapping writable we increase our commit;
94849 * but (without finer accounting) cannot reduce our commit if we
94850 @@ -289,6 +357,42 @@ mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
94851 }
94852 }
94853
94854 +#ifdef CONFIG_PAX_SEGMEXEC
94855 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && ((oldflags ^ newflags) & VM_EXEC)) {
94856 + if (start != vma->vm_start) {
94857 + error = split_vma(mm, vma, start, 1);
94858 + if (error)
94859 + goto fail;
94860 + BUG_ON(!*pprev || (*pprev)->vm_next == vma);
94861 + *pprev = (*pprev)->vm_next;
94862 + }
94863 +
94864 + if (end != vma->vm_end) {
94865 + error = split_vma(mm, vma, end, 0);
94866 + if (error)
94867 + goto fail;
94868 + }
94869 +
94870 + if (pax_find_mirror_vma(vma)) {
94871 + error = __do_munmap(mm, start_m, end_m - start_m);
94872 + if (error)
94873 + goto fail;
94874 + } else {
94875 + vma_m = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
94876 + if (!vma_m) {
94877 + error = -ENOMEM;
94878 + goto fail;
94879 + }
94880 + vma->vm_flags = newflags;
94881 + error = pax_mirror_vma(vma_m, vma);
94882 + if (error) {
94883 + vma->vm_flags = oldflags;
94884 + goto fail;
94885 + }
94886 + }
94887 + }
94888 +#endif
94889 +
94890 /*
94891 * First try to merge with previous and/or next vma.
94892 */
94893 @@ -319,9 +423,21 @@ success:
94894 * vm_flags and vm_page_prot are protected by the mmap_sem
94895 * held in write mode.
94896 */
94897 +
94898 +#ifdef CONFIG_PAX_SEGMEXEC
94899 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (newflags & VM_EXEC) && ((vma->vm_flags ^ newflags) & VM_READ))
94900 + pax_find_mirror_vma(vma)->vm_flags ^= VM_READ;
94901 +#endif
94902 +
94903 vma->vm_flags = newflags;
94904 +
94905 +#ifdef CONFIG_PAX_MPROTECT
94906 + if (mm->binfmt && mm->binfmt->handle_mprotect)
94907 + mm->binfmt->handle_mprotect(vma, newflags);
94908 +#endif
94909 +
94910 vma->vm_page_prot = pgprot_modify(vma->vm_page_prot,
94911 - vm_get_page_prot(newflags));
94912 + vm_get_page_prot(vma->vm_flags));
94913
94914 if (vma_wants_writenotify(vma)) {
94915 vma->vm_page_prot = vm_get_page_prot(newflags & ~VM_SHARED);
94916 @@ -360,6 +476,17 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
94917 end = start + len;
94918 if (end <= start)
94919 return -ENOMEM;
94920 +
94921 +#ifdef CONFIG_PAX_SEGMEXEC
94922 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC) {
94923 + if (end > SEGMEXEC_TASK_SIZE)
94924 + return -EINVAL;
94925 + } else
94926 +#endif
94927 +
94928 + if (end > TASK_SIZE)
94929 + return -EINVAL;
94930 +
94931 if (!arch_validate_prot(prot))
94932 return -EINVAL;
94933
94934 @@ -367,7 +494,7 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
94935 /*
94936 * Does the application expect PROT_READ to imply PROT_EXEC:
94937 */
94938 - if ((prot & PROT_READ) && (current->personality & READ_IMPLIES_EXEC))
94939 + if ((prot & (PROT_READ | PROT_WRITE)) && (current->personality & READ_IMPLIES_EXEC))
94940 prot |= PROT_EXEC;
94941
94942 vm_flags = calc_vm_prot_bits(prot);
94943 @@ -399,6 +526,11 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
94944 if (start > vma->vm_start)
94945 prev = vma;
94946
94947 +#ifdef CONFIG_PAX_MPROTECT
94948 + if (current->mm->binfmt && current->mm->binfmt->handle_mprotect)
94949 + current->mm->binfmt->handle_mprotect(vma, vm_flags);
94950 +#endif
94951 +
94952 for (nstart = start ; ; ) {
94953 unsigned long newflags;
94954
94955 @@ -409,6 +541,14 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
94956
94957 /* newflags >> 4 shift VM_MAY% in place of VM_% */
94958 if ((newflags & ~(newflags >> 4)) & (VM_READ | VM_WRITE | VM_EXEC)) {
94959 + if (prot & (PROT_WRITE | PROT_EXEC))
94960 + gr_log_rwxmprotect(vma);
94961 +
94962 + error = -EACCES;
94963 + goto out;
94964 + }
94965 +
94966 + if (!gr_acl_handle_mprotect(vma->vm_file, prot)) {
94967 error = -EACCES;
94968 goto out;
94969 }
94970 @@ -423,6 +563,9 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
94971 error = mprotect_fixup(vma, &prev, nstart, tmp, newflags);
94972 if (error)
94973 goto out;
94974 +
94975 + track_exec_limit(current->mm, nstart, tmp, vm_flags);
94976 +
94977 nstart = tmp;
94978
94979 if (nstart < prev->vm_end)
94980 diff --git a/mm/mremap.c b/mm/mremap.c
94981 index 05f1180..c3cde48 100644
94982 --- a/mm/mremap.c
94983 +++ b/mm/mremap.c
94984 @@ -144,6 +144,12 @@ static void move_ptes(struct vm_area_struct *vma, pmd_t *old_pmd,
94985 continue;
94986 pte = ptep_get_and_clear(mm, old_addr, old_pte);
94987 pte = move_pte(pte, new_vma->vm_page_prot, old_addr, new_addr);
94988 +
94989 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
94990 + if (!(__supported_pte_mask & _PAGE_NX) && pte_present(pte) && (new_vma->vm_flags & (VM_PAGEEXEC | VM_EXEC)) == VM_PAGEEXEC)
94991 + pte = pte_exprotect(pte);
94992 +#endif
94993 +
94994 pte = move_soft_dirty_pte(pte);
94995 set_pte_at(mm, new_addr, new_pte, pte);
94996 }
94997 @@ -344,6 +350,11 @@ static struct vm_area_struct *vma_to_resize(unsigned long addr,
94998 if (is_vm_hugetlb_page(vma))
94999 goto Einval;
95000
95001 +#ifdef CONFIG_PAX_SEGMEXEC
95002 + if (pax_find_mirror_vma(vma))
95003 + goto Einval;
95004 +#endif
95005 +
95006 /* We can't remap across vm area boundaries */
95007 if (old_len > vma->vm_end - addr)
95008 goto Efault;
95009 @@ -399,20 +410,25 @@ static unsigned long mremap_to(unsigned long addr, unsigned long old_len,
95010 unsigned long ret = -EINVAL;
95011 unsigned long charged = 0;
95012 unsigned long map_flags;
95013 + unsigned long pax_task_size = TASK_SIZE;
95014
95015 if (new_addr & ~PAGE_MASK)
95016 goto out;
95017
95018 - if (new_len > TASK_SIZE || new_addr > TASK_SIZE - new_len)
95019 +#ifdef CONFIG_PAX_SEGMEXEC
95020 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
95021 + pax_task_size = SEGMEXEC_TASK_SIZE;
95022 +#endif
95023 +
95024 + pax_task_size -= PAGE_SIZE;
95025 +
95026 + if (new_len > TASK_SIZE || new_addr > pax_task_size - new_len)
95027 goto out;
95028
95029 /* Check if the location we're moving into overlaps the
95030 * old location at all, and fail if it does.
95031 */
95032 - if ((new_addr <= addr) && (new_addr+new_len) > addr)
95033 - goto out;
95034 -
95035 - if ((addr <= new_addr) && (addr+old_len) > new_addr)
95036 + if (addr + old_len > new_addr && new_addr + new_len > addr)
95037 goto out;
95038
95039 ret = do_munmap(mm, new_addr, new_len);
95040 @@ -481,6 +497,7 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
95041 unsigned long ret = -EINVAL;
95042 unsigned long charged = 0;
95043 bool locked = false;
95044 + unsigned long pax_task_size = TASK_SIZE;
95045
95046 if (flags & ~(MREMAP_FIXED | MREMAP_MAYMOVE))
95047 return ret;
95048 @@ -502,6 +519,17 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
95049 if (!new_len)
95050 return ret;
95051
95052 +#ifdef CONFIG_PAX_SEGMEXEC
95053 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
95054 + pax_task_size = SEGMEXEC_TASK_SIZE;
95055 +#endif
95056 +
95057 + pax_task_size -= PAGE_SIZE;
95058 +
95059 + if (new_len > pax_task_size || addr > pax_task_size-new_len ||
95060 + old_len > pax_task_size || addr > pax_task_size-old_len)
95061 + return ret;
95062 +
95063 down_write(&current->mm->mmap_sem);
95064
95065 if (flags & MREMAP_FIXED) {
95066 @@ -552,6 +580,7 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
95067 new_addr = addr;
95068 }
95069 ret = addr;
95070 + track_exec_limit(vma->vm_mm, vma->vm_start, addr + new_len, vma->vm_flags);
95071 goto out;
95072 }
95073 }
95074 @@ -575,7 +604,12 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
95075 goto out;
95076 }
95077
95078 + map_flags = vma->vm_flags;
95079 ret = move_vma(vma, addr, old_len, new_len, new_addr, &locked);
95080 + if (!(ret & ~PAGE_MASK)) {
95081 + track_exec_limit(current->mm, addr, addr + old_len, 0UL);
95082 + track_exec_limit(current->mm, new_addr, new_addr + new_len, map_flags);
95083 + }
95084 }
95085 out:
95086 if (ret & ~PAGE_MASK)
95087 diff --git a/mm/nommu.c b/mm/nommu.c
95088 index 85f8d66..b3375fa 100644
95089 --- a/mm/nommu.c
95090 +++ b/mm/nommu.c
95091 @@ -67,7 +67,6 @@ int sysctl_max_map_count = DEFAULT_MAX_MAP_COUNT;
95092 int sysctl_nr_trim_pages = CONFIG_NOMMU_INITIAL_TRIM_EXCESS;
95093 unsigned long sysctl_user_reserve_kbytes __read_mostly = 1UL << 17; /* 128MB */
95094 unsigned long sysctl_admin_reserve_kbytes __read_mostly = 1UL << 13; /* 8MB */
95095 -int heap_stack_gap = 0;
95096
95097 atomic_long_t mmap_pages_allocated;
95098
95099 @@ -854,15 +853,6 @@ struct vm_area_struct *find_vma(struct mm_struct *mm, unsigned long addr)
95100 EXPORT_SYMBOL(find_vma);
95101
95102 /*
95103 - * find a VMA
95104 - * - we don't extend stack VMAs under NOMMU conditions
95105 - */
95106 -struct vm_area_struct *find_extend_vma(struct mm_struct *mm, unsigned long addr)
95107 -{
95108 - return find_vma(mm, addr);
95109 -}
95110 -
95111 -/*
95112 * expand a stack to a given address
95113 * - not supported under NOMMU conditions
95114 */
95115 @@ -1569,6 +1559,7 @@ int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
95116
95117 /* most fields are the same, copy all, and then fixup */
95118 *new = *vma;
95119 + INIT_LIST_HEAD(&new->anon_vma_chain);
95120 *region = *vma->vm_region;
95121 new->vm_region = region;
95122
95123 @@ -2004,8 +1995,8 @@ int generic_file_remap_pages(struct vm_area_struct *vma, unsigned long addr,
95124 }
95125 EXPORT_SYMBOL(generic_file_remap_pages);
95126
95127 -static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
95128 - unsigned long addr, void *buf, int len, int write)
95129 +static ssize_t __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
95130 + unsigned long addr, void *buf, size_t len, int write)
95131 {
95132 struct vm_area_struct *vma;
95133
95134 @@ -2046,8 +2037,8 @@ static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
95135 *
95136 * The caller must hold a reference on @mm.
95137 */
95138 -int access_remote_vm(struct mm_struct *mm, unsigned long addr,
95139 - void *buf, int len, int write)
95140 +ssize_t access_remote_vm(struct mm_struct *mm, unsigned long addr,
95141 + void *buf, size_t len, int write)
95142 {
95143 return __access_remote_vm(NULL, mm, addr, buf, len, write);
95144 }
95145 @@ -2056,7 +2047,7 @@ int access_remote_vm(struct mm_struct *mm, unsigned long addr,
95146 * Access another process' address space.
95147 * - source/target buffer must be kernel space
95148 */
95149 -int access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, int len, int write)
95150 +ssize_t access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, size_t len, int write)
95151 {
95152 struct mm_struct *mm;
95153
95154 diff --git a/mm/page-writeback.c b/mm/page-writeback.c
95155 index a4317da..0198e48 100644
95156 --- a/mm/page-writeback.c
95157 +++ b/mm/page-writeback.c
95158 @@ -685,7 +685,7 @@ static long long pos_ratio_polynom(unsigned long setpoint,
95159 * card's bdi_dirty may rush to many times higher than bdi_setpoint.
95160 * - the bdi dirty thresh drops quickly due to change of JBOD workload
95161 */
95162 -static unsigned long bdi_position_ratio(struct backing_dev_info *bdi,
95163 +static unsigned long __intentional_overflow(-1) bdi_position_ratio(struct backing_dev_info *bdi,
95164 unsigned long thresh,
95165 unsigned long bg_thresh,
95166 unsigned long dirty,
95167 diff --git a/mm/page_alloc.c b/mm/page_alloc.c
95168 index 5dba293..1aca350 100644
95169 --- a/mm/page_alloc.c
95170 +++ b/mm/page_alloc.c
95171 @@ -61,6 +61,7 @@
95172 #include <linux/page-debug-flags.h>
95173 #include <linux/hugetlb.h>
95174 #include <linux/sched/rt.h>
95175 +#include <linux/random.h>
95176
95177 #include <asm/sections.h>
95178 #include <asm/tlbflush.h>
95179 @@ -355,7 +356,7 @@ out:
95180 * This usage means that zero-order pages may not be compound.
95181 */
95182
95183 -static void free_compound_page(struct page *page)
95184 +void free_compound_page(struct page *page)
95185 {
95186 __free_pages_ok(page, compound_order(page));
95187 }
95188 @@ -729,6 +730,10 @@ static bool free_pages_prepare(struct page *page, unsigned int order)
95189 int i;
95190 int bad = 0;
95191
95192 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
95193 + unsigned long index = 1UL << order;
95194 +#endif
95195 +
95196 trace_mm_page_free(page, order);
95197 kmemcheck_free_shadow(page, order);
95198
95199 @@ -745,6 +750,12 @@ static bool free_pages_prepare(struct page *page, unsigned int order)
95200 debug_check_no_obj_freed(page_address(page),
95201 PAGE_SIZE << order);
95202 }
95203 +
95204 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
95205 + for (; index; --index)
95206 + sanitize_highpage(page + index - 1);
95207 +#endif
95208 +
95209 arch_free_page(page, order);
95210 kernel_map_pages(page, 1 << order, 0);
95211
95212 @@ -767,6 +778,20 @@ static void __free_pages_ok(struct page *page, unsigned int order)
95213 local_irq_restore(flags);
95214 }
95215
95216 +#ifdef CONFIG_PAX_LATENT_ENTROPY
95217 +bool __meminitdata extra_latent_entropy;
95218 +
95219 +static int __init setup_pax_extra_latent_entropy(char *str)
95220 +{
95221 + extra_latent_entropy = true;
95222 + return 0;
95223 +}
95224 +early_param("pax_extra_latent_entropy", setup_pax_extra_latent_entropy);
95225 +
95226 +volatile u64 latent_entropy __latent_entropy;
95227 +EXPORT_SYMBOL(latent_entropy);
95228 +#endif
95229 +
95230 void __init __free_pages_bootmem(struct page *page, unsigned int order)
95231 {
95232 unsigned int nr_pages = 1 << order;
95233 @@ -782,6 +807,19 @@ void __init __free_pages_bootmem(struct page *page, unsigned int order)
95234 __ClearPageReserved(p);
95235 set_page_count(p, 0);
95236
95237 +#ifdef CONFIG_PAX_LATENT_ENTROPY
95238 + if (extra_latent_entropy && !PageHighMem(page) && page_to_pfn(page) < 0x100000) {
95239 + u64 hash = 0;
95240 + size_t index, end = PAGE_SIZE * nr_pages / sizeof hash;
95241 + const u64 *data = lowmem_page_address(page);
95242 +
95243 + for (index = 0; index < end; index++)
95244 + hash ^= hash + data[index];
95245 + latent_entropy ^= hash;
95246 + add_device_randomness((const void *)&latent_entropy, sizeof(latent_entropy));
95247 + }
95248 +#endif
95249 +
95250 page_zone(page)->managed_pages += nr_pages;
95251 set_page_refcounted(page);
95252 __free_pages(page, order);
95253 @@ -898,8 +936,10 @@ static int prep_new_page(struct page *page, int order, gfp_t gfp_flags)
95254 arch_alloc_page(page, order);
95255 kernel_map_pages(page, 1 << order, 1);
95256
95257 +#ifndef CONFIG_PAX_MEMORY_SANITIZE
95258 if (gfp_flags & __GFP_ZERO)
95259 prep_zero_page(page, order, gfp_flags);
95260 +#endif
95261
95262 if (order && (gfp_flags & __GFP_COMP))
95263 prep_compound_page(page, order);
95264 @@ -2402,7 +2442,7 @@ static void reset_alloc_batches(struct zonelist *zonelist,
95265 continue;
95266 mod_zone_page_state(zone, NR_ALLOC_BATCH,
95267 high_wmark_pages(zone) - low_wmark_pages(zone) -
95268 - atomic_long_read(&zone->vm_stat[NR_ALLOC_BATCH]));
95269 + atomic_long_read_unchecked(&zone->vm_stat[NR_ALLOC_BATCH]));
95270 }
95271 }
95272
95273 diff --git a/mm/page_io.c b/mm/page_io.c
95274 index 7c59ef6..1358905 100644
95275 --- a/mm/page_io.c
95276 +++ b/mm/page_io.c
95277 @@ -260,7 +260,7 @@ int __swap_writepage(struct page *page, struct writeback_control *wbc,
95278 struct file *swap_file = sis->swap_file;
95279 struct address_space *mapping = swap_file->f_mapping;
95280 struct iovec iov = {
95281 - .iov_base = kmap(page),
95282 + .iov_base = (void __force_user *)kmap(page),
95283 .iov_len = PAGE_SIZE,
95284 };
95285
95286 diff --git a/mm/percpu.c b/mm/percpu.c
95287 index 2ddf9a9..f8fc075 100644
95288 --- a/mm/percpu.c
95289 +++ b/mm/percpu.c
95290 @@ -123,7 +123,7 @@ static unsigned int pcpu_low_unit_cpu __read_mostly;
95291 static unsigned int pcpu_high_unit_cpu __read_mostly;
95292
95293 /* the address of the first chunk which starts with the kernel static area */
95294 -void *pcpu_base_addr __read_mostly;
95295 +void *pcpu_base_addr __read_only;
95296 EXPORT_SYMBOL_GPL(pcpu_base_addr);
95297
95298 static const int *pcpu_unit_map __read_mostly; /* cpu -> unit */
95299 diff --git a/mm/process_vm_access.c b/mm/process_vm_access.c
95300 index 8505c92..946bfc9 100644
95301 --- a/mm/process_vm_access.c
95302 +++ b/mm/process_vm_access.c
95303 @@ -13,6 +13,7 @@
95304 #include <linux/uio.h>
95305 #include <linux/sched.h>
95306 #include <linux/highmem.h>
95307 +#include <linux/security.h>
95308 #include <linux/ptrace.h>
95309 #include <linux/slab.h>
95310 #include <linux/syscalls.h>
95311 @@ -161,19 +162,19 @@ static ssize_t process_vm_rw_core(pid_t pid, struct iov_iter *iter,
95312 ssize_t iov_len;
95313 size_t total_len = iov_iter_count(iter);
95314
95315 + return -ENOSYS; // PaX: until properly audited
95316 +
95317 /*
95318 * Work out how many pages of struct pages we're going to need
95319 * when eventually calling get_user_pages
95320 */
95321 for (i = 0; i < riovcnt; i++) {
95322 iov_len = rvec[i].iov_len;
95323 - if (iov_len > 0) {
95324 - nr_pages_iov = ((unsigned long)rvec[i].iov_base
95325 - + iov_len)
95326 - / PAGE_SIZE - (unsigned long)rvec[i].iov_base
95327 - / PAGE_SIZE + 1;
95328 - nr_pages = max(nr_pages, nr_pages_iov);
95329 - }
95330 + if (iov_len <= 0)
95331 + continue;
95332 + nr_pages_iov = ((unsigned long)rvec[i].iov_base + iov_len) / PAGE_SIZE -
95333 + (unsigned long)rvec[i].iov_base / PAGE_SIZE + 1;
95334 + nr_pages = max(nr_pages, nr_pages_iov);
95335 }
95336
95337 if (nr_pages == 0)
95338 @@ -201,6 +202,11 @@ static ssize_t process_vm_rw_core(pid_t pid, struct iov_iter *iter,
95339 goto free_proc_pages;
95340 }
95341
95342 + if (gr_handle_ptrace(task, vm_write ? PTRACE_POKETEXT : PTRACE_ATTACH)) {
95343 + rc = -EPERM;
95344 + goto put_task_struct;
95345 + }
95346 +
95347 mm = mm_access(task, PTRACE_MODE_ATTACH);
95348 if (!mm || IS_ERR(mm)) {
95349 rc = IS_ERR(mm) ? PTR_ERR(mm) : -ESRCH;
95350 diff --git a/mm/rmap.c b/mm/rmap.c
95351 index 83bfafa..660f059 100644
95352 --- a/mm/rmap.c
95353 +++ b/mm/rmap.c
95354 @@ -163,6 +163,10 @@ int anon_vma_prepare(struct vm_area_struct *vma)
95355 struct anon_vma *anon_vma = vma->anon_vma;
95356 struct anon_vma_chain *avc;
95357
95358 +#ifdef CONFIG_PAX_SEGMEXEC
95359 + struct anon_vma_chain *avc_m = NULL;
95360 +#endif
95361 +
95362 might_sleep();
95363 if (unlikely(!anon_vma)) {
95364 struct mm_struct *mm = vma->vm_mm;
95365 @@ -172,6 +176,12 @@ int anon_vma_prepare(struct vm_area_struct *vma)
95366 if (!avc)
95367 goto out_enomem;
95368
95369 +#ifdef CONFIG_PAX_SEGMEXEC
95370 + avc_m = anon_vma_chain_alloc(GFP_KERNEL);
95371 + if (!avc_m)
95372 + goto out_enomem_free_avc;
95373 +#endif
95374 +
95375 anon_vma = find_mergeable_anon_vma(vma);
95376 allocated = NULL;
95377 if (!anon_vma) {
95378 @@ -185,6 +195,18 @@ int anon_vma_prepare(struct vm_area_struct *vma)
95379 /* page_table_lock to protect against threads */
95380 spin_lock(&mm->page_table_lock);
95381 if (likely(!vma->anon_vma)) {
95382 +
95383 +#ifdef CONFIG_PAX_SEGMEXEC
95384 + struct vm_area_struct *vma_m = pax_find_mirror_vma(vma);
95385 +
95386 + if (vma_m) {
95387 + BUG_ON(vma_m->anon_vma);
95388 + vma_m->anon_vma = anon_vma;
95389 + anon_vma_chain_link(vma_m, avc_m, anon_vma);
95390 + avc_m = NULL;
95391 + }
95392 +#endif
95393 +
95394 vma->anon_vma = anon_vma;
95395 anon_vma_chain_link(vma, avc, anon_vma);
95396 allocated = NULL;
95397 @@ -195,12 +217,24 @@ int anon_vma_prepare(struct vm_area_struct *vma)
95398
95399 if (unlikely(allocated))
95400 put_anon_vma(allocated);
95401 +
95402 +#ifdef CONFIG_PAX_SEGMEXEC
95403 + if (unlikely(avc_m))
95404 + anon_vma_chain_free(avc_m);
95405 +#endif
95406 +
95407 if (unlikely(avc))
95408 anon_vma_chain_free(avc);
95409 }
95410 return 0;
95411
95412 out_enomem_free_avc:
95413 +
95414 +#ifdef CONFIG_PAX_SEGMEXEC
95415 + if (avc_m)
95416 + anon_vma_chain_free(avc_m);
95417 +#endif
95418 +
95419 anon_vma_chain_free(avc);
95420 out_enomem:
95421 return -ENOMEM;
95422 @@ -236,7 +270,7 @@ static inline void unlock_anon_vma_root(struct anon_vma *root)
95423 * Attach the anon_vmas from src to dst.
95424 * Returns 0 on success, -ENOMEM on failure.
95425 */
95426 -int anon_vma_clone(struct vm_area_struct *dst, struct vm_area_struct *src)
95427 +int anon_vma_clone(struct vm_area_struct *dst, const struct vm_area_struct *src)
95428 {
95429 struct anon_vma_chain *avc, *pavc;
95430 struct anon_vma *root = NULL;
95431 @@ -269,7 +303,7 @@ int anon_vma_clone(struct vm_area_struct *dst, struct vm_area_struct *src)
95432 * the corresponding VMA in the parent process is attached to.
95433 * Returns 0 on success, non-zero on failure.
95434 */
95435 -int anon_vma_fork(struct vm_area_struct *vma, struct vm_area_struct *pvma)
95436 +int anon_vma_fork(struct vm_area_struct *vma, const struct vm_area_struct *pvma)
95437 {
95438 struct anon_vma_chain *avc;
95439 struct anon_vma *anon_vma;
95440 @@ -373,8 +407,10 @@ static void anon_vma_ctor(void *data)
95441 void __init anon_vma_init(void)
95442 {
95443 anon_vma_cachep = kmem_cache_create("anon_vma", sizeof(struct anon_vma),
95444 - 0, SLAB_DESTROY_BY_RCU|SLAB_PANIC, anon_vma_ctor);
95445 - anon_vma_chain_cachep = KMEM_CACHE(anon_vma_chain, SLAB_PANIC);
95446 + 0, SLAB_DESTROY_BY_RCU|SLAB_PANIC|SLAB_NO_SANITIZE,
95447 + anon_vma_ctor);
95448 + anon_vma_chain_cachep = KMEM_CACHE(anon_vma_chain,
95449 + SLAB_PANIC|SLAB_NO_SANITIZE);
95450 }
95451
95452 /*
95453 diff --git a/mm/shmem.c b/mm/shmem.c
95454 index 9f70e02..daac1da 100644
95455 --- a/mm/shmem.c
95456 +++ b/mm/shmem.c
95457 @@ -33,7 +33,7 @@
95458 #include <linux/swap.h>
95459 #include <linux/aio.h>
95460
95461 -static struct vfsmount *shm_mnt;
95462 +struct vfsmount *shm_mnt;
95463
95464 #ifdef CONFIG_SHMEM
95465 /*
95466 @@ -77,14 +77,15 @@ static struct vfsmount *shm_mnt;
95467 #define BOGO_DIRENT_SIZE 20
95468
95469 /* Symlink up to this size is kmalloc'ed instead of using a swappable page */
95470 -#define SHORT_SYMLINK_LEN 128
95471 +#define SHORT_SYMLINK_LEN 64
95472
95473 /*
95474 - * shmem_fallocate and shmem_writepage communicate via inode->i_private
95475 - * (with i_mutex making sure that it has only one user at a time):
95476 - * we would prefer not to enlarge the shmem inode just for that.
95477 + * shmem_fallocate communicates with shmem_fault or shmem_writepage via
95478 + * inode->i_private (with i_mutex making sure that it has only one user at
95479 + * a time): we would prefer not to enlarge the shmem inode just for that.
95480 */
95481 struct shmem_falloc {
95482 + int mode; /* FALLOC_FL mode currently operating */
95483 pgoff_t start; /* start of range currently being fallocated */
95484 pgoff_t next; /* the next page offset to be fallocated */
95485 pgoff_t nr_falloced; /* how many new pages have been fallocated */
95486 @@ -759,6 +760,7 @@ static int shmem_writepage(struct page *page, struct writeback_control *wbc)
95487 spin_lock(&inode->i_lock);
95488 shmem_falloc = inode->i_private;
95489 if (shmem_falloc &&
95490 + !shmem_falloc->mode &&
95491 index >= shmem_falloc->start &&
95492 index < shmem_falloc->next)
95493 shmem_falloc->nr_unswapped++;
95494 @@ -1233,6 +1235,43 @@ static int shmem_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
95495 int error;
95496 int ret = VM_FAULT_LOCKED;
95497
95498 + /*
95499 + * Trinity finds that probing a hole which tmpfs is punching can
95500 + * prevent the hole-punch from ever completing: which in turn
95501 + * locks writers out with its hold on i_mutex. So refrain from
95502 + * faulting pages into the hole while it's being punched, and
95503 + * wait on i_mutex to be released if vmf->flags permits,
95504 + */
95505 + if (unlikely(inode->i_private)) {
95506 + struct shmem_falloc *shmem_falloc;
95507 + spin_lock(&inode->i_lock);
95508 + shmem_falloc = inode->i_private;
95509 + if (!shmem_falloc ||
95510 + shmem_falloc->mode != FALLOC_FL_PUNCH_HOLE ||
95511 + vmf->pgoff < shmem_falloc->start ||
95512 + vmf->pgoff >= shmem_falloc->next)
95513 + shmem_falloc = NULL;
95514 + spin_unlock(&inode->i_lock);
95515 + /*
95516 + * i_lock has protected us from taking shmem_falloc seriously
95517 + * once return from shmem_fallocate() went back up that stack.
95518 + * i_lock does not serialize with i_mutex at all, but it does
95519 + * not matter if sometimes we wait unnecessarily, or sometimes
95520 + * miss out on waiting: we just need to make those cases rare.
95521 + */
95522 + if (shmem_falloc) {
95523 + if ((vmf->flags & FAULT_FLAG_ALLOW_RETRY) &&
95524 + !(vmf->flags & FAULT_FLAG_RETRY_NOWAIT)) {
95525 + up_read(&vma->vm_mm->mmap_sem);
95526 + mutex_lock(&inode->i_mutex);
95527 + mutex_unlock(&inode->i_mutex);
95528 + return VM_FAULT_RETRY;
95529 + }
95530 + /* cond_resched? Leave that to GUP or return to user */
95531 + return VM_FAULT_NOPAGE;
95532 + }
95533 + }
95534 +
95535 error = shmem_getpage(inode, vmf->pgoff, &vmf->page, SGP_CACHE, &ret);
95536 if (error)
95537 return ((error == -ENOMEM) ? VM_FAULT_OOM : VM_FAULT_SIGBUS);
95538 @@ -1730,18 +1769,26 @@ static long shmem_fallocate(struct file *file, int mode, loff_t offset,
95539
95540 mutex_lock(&inode->i_mutex);
95541
95542 + shmem_falloc.mode = mode & ~FALLOC_FL_KEEP_SIZE;
95543 +
95544 if (mode & FALLOC_FL_PUNCH_HOLE) {
95545 struct address_space *mapping = file->f_mapping;
95546 loff_t unmap_start = round_up(offset, PAGE_SIZE);
95547 loff_t unmap_end = round_down(offset + len, PAGE_SIZE) - 1;
95548
95549 + shmem_falloc.start = unmap_start >> PAGE_SHIFT;
95550 + shmem_falloc.next = (unmap_end + 1) >> PAGE_SHIFT;
95551 + spin_lock(&inode->i_lock);
95552 + inode->i_private = &shmem_falloc;
95553 + spin_unlock(&inode->i_lock);
95554 +
95555 if ((u64)unmap_end > (u64)unmap_start)
95556 unmap_mapping_range(mapping, unmap_start,
95557 1 + unmap_end - unmap_start, 0);
95558 shmem_truncate_range(inode, offset, offset + len - 1);
95559 /* No need to unmap again: hole-punching leaves COWed pages */
95560 error = 0;
95561 - goto out;
95562 + goto undone;
95563 }
95564
95565 /* We need to check rlimit even when FALLOC_FL_KEEP_SIZE */
95566 @@ -2135,6 +2182,11 @@ static const struct xattr_handler *shmem_xattr_handlers[] = {
95567 static int shmem_xattr_validate(const char *name)
95568 {
95569 struct { const char *prefix; size_t len; } arr[] = {
95570 +
95571 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
95572 + { XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN},
95573 +#endif
95574 +
95575 { XATTR_SECURITY_PREFIX, XATTR_SECURITY_PREFIX_LEN },
95576 { XATTR_TRUSTED_PREFIX, XATTR_TRUSTED_PREFIX_LEN }
95577 };
95578 @@ -2190,6 +2242,15 @@ static int shmem_setxattr(struct dentry *dentry, const char *name,
95579 if (err)
95580 return err;
95581
95582 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
95583 + if (!strncmp(name, XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN)) {
95584 + if (strcmp(name, XATTR_NAME_PAX_FLAGS))
95585 + return -EOPNOTSUPP;
95586 + if (size > 8)
95587 + return -EINVAL;
95588 + }
95589 +#endif
95590 +
95591 return simple_xattr_set(&info->xattrs, name, value, size, flags);
95592 }
95593
95594 @@ -2502,8 +2563,7 @@ int shmem_fill_super(struct super_block *sb, void *data, int silent)
95595 int err = -ENOMEM;
95596
95597 /* Round up to L1_CACHE_BYTES to resist false sharing */
95598 - sbinfo = kzalloc(max((int)sizeof(struct shmem_sb_info),
95599 - L1_CACHE_BYTES), GFP_KERNEL);
95600 + sbinfo = kzalloc(max(sizeof(struct shmem_sb_info), L1_CACHE_BYTES), GFP_KERNEL);
95601 if (!sbinfo)
95602 return -ENOMEM;
95603
95604 diff --git a/mm/slab.c b/mm/slab.c
95605 index 19d9218..8a39707 100644
95606 --- a/mm/slab.c
95607 +++ b/mm/slab.c
95608 @@ -311,10 +311,12 @@ static void kmem_cache_node_init(struct kmem_cache_node *parent)
95609 if ((x)->max_freeable < i) \
95610 (x)->max_freeable = i; \
95611 } while (0)
95612 -#define STATS_INC_ALLOCHIT(x) atomic_inc(&(x)->allochit)
95613 -#define STATS_INC_ALLOCMISS(x) atomic_inc(&(x)->allocmiss)
95614 -#define STATS_INC_FREEHIT(x) atomic_inc(&(x)->freehit)
95615 -#define STATS_INC_FREEMISS(x) atomic_inc(&(x)->freemiss)
95616 +#define STATS_INC_ALLOCHIT(x) atomic_inc_unchecked(&(x)->allochit)
95617 +#define STATS_INC_ALLOCMISS(x) atomic_inc_unchecked(&(x)->allocmiss)
95618 +#define STATS_INC_FREEHIT(x) atomic_inc_unchecked(&(x)->freehit)
95619 +#define STATS_INC_FREEMISS(x) atomic_inc_unchecked(&(x)->freemiss)
95620 +#define STATS_INC_SANITIZED(x) atomic_inc_unchecked(&(x)->sanitized)
95621 +#define STATS_INC_NOT_SANITIZED(x) atomic_inc_unchecked(&(x)->not_sanitized)
95622 #else
95623 #define STATS_INC_ACTIVE(x) do { } while (0)
95624 #define STATS_DEC_ACTIVE(x) do { } while (0)
95625 @@ -331,6 +333,8 @@ static void kmem_cache_node_init(struct kmem_cache_node *parent)
95626 #define STATS_INC_ALLOCMISS(x) do { } while (0)
95627 #define STATS_INC_FREEHIT(x) do { } while (0)
95628 #define STATS_INC_FREEMISS(x) do { } while (0)
95629 +#define STATS_INC_SANITIZED(x) do { } while (0)
95630 +#define STATS_INC_NOT_SANITIZED(x) do { } while (0)
95631 #endif
95632
95633 #if DEBUG
95634 @@ -414,7 +418,7 @@ static inline void *index_to_obj(struct kmem_cache *cache, struct page *page,
95635 * reciprocal_divide(offset, cache->reciprocal_buffer_size)
95636 */
95637 static inline unsigned int obj_to_index(const struct kmem_cache *cache,
95638 - const struct page *page, void *obj)
95639 + const struct page *page, const void *obj)
95640 {
95641 u32 offset = (obj - page->s_mem);
95642 return reciprocal_divide(offset, cache->reciprocal_buffer_size);
95643 @@ -1506,12 +1510,12 @@ void __init kmem_cache_init(void)
95644 */
95645
95646 kmalloc_caches[INDEX_AC] = create_kmalloc_cache("kmalloc-ac",
95647 - kmalloc_size(INDEX_AC), ARCH_KMALLOC_FLAGS);
95648 + kmalloc_size(INDEX_AC), SLAB_USERCOPY | ARCH_KMALLOC_FLAGS);
95649
95650 if (INDEX_AC != INDEX_NODE)
95651 kmalloc_caches[INDEX_NODE] =
95652 create_kmalloc_cache("kmalloc-node",
95653 - kmalloc_size(INDEX_NODE), ARCH_KMALLOC_FLAGS);
95654 + kmalloc_size(INDEX_NODE), SLAB_USERCOPY | ARCH_KMALLOC_FLAGS);
95655
95656 slab_early_init = 0;
95657
95658 @@ -3464,6 +3468,21 @@ static inline void __cache_free(struct kmem_cache *cachep, void *objp,
95659 struct array_cache *ac = cpu_cache_get(cachep);
95660
95661 check_irq_off();
95662 +
95663 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
95664 + if (pax_sanitize_slab) {
95665 + if (!(cachep->flags & (SLAB_POISON | SLAB_NO_SANITIZE))) {
95666 + memset(objp, PAX_MEMORY_SANITIZE_VALUE, cachep->object_size);
95667 +
95668 + if (cachep->ctor)
95669 + cachep->ctor(objp);
95670 +
95671 + STATS_INC_SANITIZED(cachep);
95672 + } else
95673 + STATS_INC_NOT_SANITIZED(cachep);
95674 + }
95675 +#endif
95676 +
95677 kmemleak_free_recursive(objp, cachep->flags);
95678 objp = cache_free_debugcheck(cachep, objp, caller);
95679
95680 @@ -3687,6 +3706,7 @@ void kfree(const void *objp)
95681
95682 if (unlikely(ZERO_OR_NULL_PTR(objp)))
95683 return;
95684 + VM_BUG_ON(!virt_addr_valid(objp));
95685 local_irq_save(flags);
95686 kfree_debugcheck(objp);
95687 c = virt_to_cache(objp);
95688 @@ -4128,14 +4148,22 @@ void slabinfo_show_stats(struct seq_file *m, struct kmem_cache *cachep)
95689 }
95690 /* cpu stats */
95691 {
95692 - unsigned long allochit = atomic_read(&cachep->allochit);
95693 - unsigned long allocmiss = atomic_read(&cachep->allocmiss);
95694 - unsigned long freehit = atomic_read(&cachep->freehit);
95695 - unsigned long freemiss = atomic_read(&cachep->freemiss);
95696 + unsigned long allochit = atomic_read_unchecked(&cachep->allochit);
95697 + unsigned long allocmiss = atomic_read_unchecked(&cachep->allocmiss);
95698 + unsigned long freehit = atomic_read_unchecked(&cachep->freehit);
95699 + unsigned long freemiss = atomic_read_unchecked(&cachep->freemiss);
95700
95701 seq_printf(m, " : cpustat %6lu %6lu %6lu %6lu",
95702 allochit, allocmiss, freehit, freemiss);
95703 }
95704 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
95705 + {
95706 + unsigned long sanitized = atomic_read_unchecked(&cachep->sanitized);
95707 + unsigned long not_sanitized = atomic_read_unchecked(&cachep->not_sanitized);
95708 +
95709 + seq_printf(m, " : pax %6lu %6lu", sanitized, not_sanitized);
95710 + }
95711 +#endif
95712 #endif
95713 }
95714
95715 @@ -4365,13 +4393,69 @@ static const struct file_operations proc_slabstats_operations = {
95716 static int __init slab_proc_init(void)
95717 {
95718 #ifdef CONFIG_DEBUG_SLAB_LEAK
95719 - proc_create("slab_allocators", 0, NULL, &proc_slabstats_operations);
95720 + proc_create("slab_allocators", S_IRUSR, NULL, &proc_slabstats_operations);
95721 #endif
95722 return 0;
95723 }
95724 module_init(slab_proc_init);
95725 #endif
95726
95727 +bool is_usercopy_object(const void *ptr)
95728 +{
95729 + struct page *page;
95730 + struct kmem_cache *cachep;
95731 +
95732 + if (ZERO_OR_NULL_PTR(ptr))
95733 + return false;
95734 +
95735 + if (!slab_is_available())
95736 + return false;
95737 +
95738 + if (!virt_addr_valid(ptr))
95739 + return false;
95740 +
95741 + page = virt_to_head_page(ptr);
95742 +
95743 + if (!PageSlab(page))
95744 + return false;
95745 +
95746 + cachep = page->slab_cache;
95747 + return cachep->flags & SLAB_USERCOPY;
95748 +}
95749 +
95750 +#ifdef CONFIG_PAX_USERCOPY
95751 +const char *check_heap_object(const void *ptr, unsigned long n)
95752 +{
95753 + struct page *page;
95754 + struct kmem_cache *cachep;
95755 + unsigned int objnr;
95756 + unsigned long offset;
95757 +
95758 + if (ZERO_OR_NULL_PTR(ptr))
95759 + return "<null>";
95760 +
95761 + if (!virt_addr_valid(ptr))
95762 + return NULL;
95763 +
95764 + page = virt_to_head_page(ptr);
95765 +
95766 + if (!PageSlab(page))
95767 + return NULL;
95768 +
95769 + cachep = page->slab_cache;
95770 + if (!(cachep->flags & SLAB_USERCOPY))
95771 + return cachep->name;
95772 +
95773 + objnr = obj_to_index(cachep, page, ptr);
95774 + BUG_ON(objnr >= cachep->num);
95775 + offset = ptr - index_to_obj(cachep, page, objnr) - obj_offset(cachep);
95776 + if (offset <= cachep->object_size && n <= cachep->object_size - offset)
95777 + return NULL;
95778 +
95779 + return cachep->name;
95780 +}
95781 +#endif
95782 +
95783 /**
95784 * ksize - get the actual amount of memory allocated for a given object
95785 * @objp: Pointer to the object
95786 diff --git a/mm/slab.h b/mm/slab.h
95787 index 6bd4c35..97565a1 100644
95788 --- a/mm/slab.h
95789 +++ b/mm/slab.h
95790 @@ -32,6 +32,15 @@ extern struct list_head slab_caches;
95791 /* The slab cache that manages slab cache information */
95792 extern struct kmem_cache *kmem_cache;
95793
95794 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
95795 +#ifdef CONFIG_X86_64
95796 +#define PAX_MEMORY_SANITIZE_VALUE '\xfe'
95797 +#else
95798 +#define PAX_MEMORY_SANITIZE_VALUE '\xff'
95799 +#endif
95800 +extern bool pax_sanitize_slab;
95801 +#endif
95802 +
95803 unsigned long calculate_alignment(unsigned long flags,
95804 unsigned long align, unsigned long size);
95805
95806 @@ -67,7 +76,8 @@ __kmem_cache_alias(const char *name, size_t size, size_t align,
95807
95808 /* Legal flag mask for kmem_cache_create(), for various configurations */
95809 #define SLAB_CORE_FLAGS (SLAB_HWCACHE_ALIGN | SLAB_CACHE_DMA | SLAB_PANIC | \
95810 - SLAB_DESTROY_BY_RCU | SLAB_DEBUG_OBJECTS )
95811 + SLAB_DESTROY_BY_RCU | SLAB_DEBUG_OBJECTS | \
95812 + SLAB_USERCOPY | SLAB_NO_SANITIZE)
95813
95814 #if defined(CONFIG_DEBUG_SLAB)
95815 #define SLAB_DEBUG_FLAGS (SLAB_RED_ZONE | SLAB_POISON | SLAB_STORE_USER)
95816 @@ -245,6 +255,9 @@ static inline struct kmem_cache *cache_from_obj(struct kmem_cache *s, void *x)
95817 return s;
95818
95819 page = virt_to_head_page(x);
95820 +
95821 + BUG_ON(!PageSlab(page));
95822 +
95823 cachep = page->slab_cache;
95824 if (slab_equal_or_root(cachep, s))
95825 return cachep;
95826 diff --git a/mm/slab_common.c b/mm/slab_common.c
95827 index 102cc6f..c7aab3d 100644
95828 --- a/mm/slab_common.c
95829 +++ b/mm/slab_common.c
95830 @@ -23,11 +23,22 @@
95831
95832 #include "slab.h"
95833
95834 -enum slab_state slab_state;
95835 +enum slab_state slab_state __read_only;
95836 LIST_HEAD(slab_caches);
95837 DEFINE_MUTEX(slab_mutex);
95838 struct kmem_cache *kmem_cache;
95839
95840 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
95841 +bool pax_sanitize_slab __read_only = true;
95842 +static int __init pax_sanitize_slab_setup(char *str)
95843 +{
95844 + pax_sanitize_slab = !!simple_strtol(str, NULL, 0);
95845 + printk("%sabled PaX slab sanitization\n", pax_sanitize_slab ? "En" : "Dis");
95846 + return 1;
95847 +}
95848 +__setup("pax_sanitize_slab=", pax_sanitize_slab_setup);
95849 +#endif
95850 +
95851 #ifdef CONFIG_DEBUG_VM
95852 static int kmem_cache_sanity_check(const char *name, size_t size)
95853 {
95854 @@ -158,7 +169,7 @@ do_kmem_cache_create(char *name, size_t object_size, size_t size, size_t align,
95855 if (err)
95856 goto out_free_cache;
95857
95858 - s->refcount = 1;
95859 + atomic_set(&s->refcount, 1);
95860 list_add(&s->list, &slab_caches);
95861 memcg_register_cache(s);
95862 out:
95863 @@ -334,8 +345,7 @@ void kmem_cache_destroy(struct kmem_cache *s)
95864 get_online_cpus();
95865 mutex_lock(&slab_mutex);
95866
95867 - s->refcount--;
95868 - if (s->refcount)
95869 + if (!atomic_dec_and_test(&s->refcount))
95870 goto out_unlock;
95871
95872 if (kmem_cache_destroy_memcg_children(s) != 0)
95873 @@ -358,7 +368,7 @@ void kmem_cache_destroy(struct kmem_cache *s)
95874 rcu_barrier();
95875
95876 memcg_free_cache_params(s);
95877 -#ifdef SLAB_SUPPORTS_SYSFS
95878 +#if defined(SLAB_SUPPORTS_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
95879 sysfs_slab_remove(s);
95880 #else
95881 slab_kmem_cache_release(s);
95882 @@ -393,7 +403,7 @@ void __init create_boot_cache(struct kmem_cache *s, const char *name, size_t siz
95883 panic("Creation of kmalloc slab %s size=%zu failed. Reason %d\n",
95884 name, size, err);
95885
95886 - s->refcount = -1; /* Exempt from merging for now */
95887 + atomic_set(&s->refcount, -1); /* Exempt from merging for now */
95888 }
95889
95890 struct kmem_cache *__init create_kmalloc_cache(const char *name, size_t size,
95891 @@ -406,7 +416,7 @@ struct kmem_cache *__init create_kmalloc_cache(const char *name, size_t size,
95892
95893 create_boot_cache(s, name, size, flags);
95894 list_add(&s->list, &slab_caches);
95895 - s->refcount = 1;
95896 + atomic_set(&s->refcount, 1);
95897 return s;
95898 }
95899
95900 @@ -418,6 +428,11 @@ struct kmem_cache *kmalloc_dma_caches[KMALLOC_SHIFT_HIGH + 1];
95901 EXPORT_SYMBOL(kmalloc_dma_caches);
95902 #endif
95903
95904 +#ifdef CONFIG_PAX_USERCOPY_SLABS
95905 +struct kmem_cache *kmalloc_usercopy_caches[KMALLOC_SHIFT_HIGH + 1];
95906 +EXPORT_SYMBOL(kmalloc_usercopy_caches);
95907 +#endif
95908 +
95909 /*
95910 * Conversion table for small slabs sizes / 8 to the index in the
95911 * kmalloc array. This is necessary for slabs < 192 since we have non power
95912 @@ -482,6 +497,13 @@ struct kmem_cache *kmalloc_slab(size_t size, gfp_t flags)
95913 return kmalloc_dma_caches[index];
95914
95915 #endif
95916 +
95917 +#ifdef CONFIG_PAX_USERCOPY_SLABS
95918 + if (unlikely((flags & GFP_USERCOPY)))
95919 + return kmalloc_usercopy_caches[index];
95920 +
95921 +#endif
95922 +
95923 return kmalloc_caches[index];
95924 }
95925
95926 @@ -538,7 +560,7 @@ void __init create_kmalloc_caches(unsigned long flags)
95927 for (i = KMALLOC_SHIFT_LOW; i <= KMALLOC_SHIFT_HIGH; i++) {
95928 if (!kmalloc_caches[i]) {
95929 kmalloc_caches[i] = create_kmalloc_cache(NULL,
95930 - 1 << i, flags);
95931 + 1 << i, SLAB_USERCOPY | flags);
95932 }
95933
95934 /*
95935 @@ -547,10 +569,10 @@ void __init create_kmalloc_caches(unsigned long flags)
95936 * earlier power of two caches
95937 */
95938 if (KMALLOC_MIN_SIZE <= 32 && !kmalloc_caches[1] && i == 6)
95939 - kmalloc_caches[1] = create_kmalloc_cache(NULL, 96, flags);
95940 + kmalloc_caches[1] = create_kmalloc_cache(NULL, 96, SLAB_USERCOPY | flags);
95941
95942 if (KMALLOC_MIN_SIZE <= 64 && !kmalloc_caches[2] && i == 7)
95943 - kmalloc_caches[2] = create_kmalloc_cache(NULL, 192, flags);
95944 + kmalloc_caches[2] = create_kmalloc_cache(NULL, 192, SLAB_USERCOPY | flags);
95945 }
95946
95947 /* Kmalloc array is now usable */
95948 @@ -583,6 +605,23 @@ void __init create_kmalloc_caches(unsigned long flags)
95949 }
95950 }
95951 #endif
95952 +
95953 +#ifdef CONFIG_PAX_USERCOPY_SLABS
95954 + for (i = 0; i <= KMALLOC_SHIFT_HIGH; i++) {
95955 + struct kmem_cache *s = kmalloc_caches[i];
95956 +
95957 + if (s) {
95958 + int size = kmalloc_size(i);
95959 + char *n = kasprintf(GFP_NOWAIT,
95960 + "usercopy-kmalloc-%d", size);
95961 +
95962 + BUG_ON(!n);
95963 + kmalloc_usercopy_caches[i] = create_kmalloc_cache(n,
95964 + size, SLAB_USERCOPY | flags);
95965 + }
95966 + }
95967 +#endif
95968 +
95969 }
95970 #endif /* !CONFIG_SLOB */
95971
95972 @@ -623,6 +662,9 @@ void print_slabinfo_header(struct seq_file *m)
95973 seq_puts(m, " : globalstat <listallocs> <maxobjs> <grown> <reaped> "
95974 "<error> <maxfreeable> <nodeallocs> <remotefrees> <alienoverflow>");
95975 seq_puts(m, " : cpustat <allochit> <allocmiss> <freehit> <freemiss>");
95976 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
95977 + seq_puts(m, " : pax <sanitized> <not_sanitized>");
95978 +#endif
95979 #endif
95980 seq_putc(m, '\n');
95981 }
95982 diff --git a/mm/slob.c b/mm/slob.c
95983 index 730cad4..8cfd442 100644
95984 --- a/mm/slob.c
95985 +++ b/mm/slob.c
95986 @@ -157,7 +157,7 @@ static void set_slob(slob_t *s, slobidx_t size, slob_t *next)
95987 /*
95988 * Return the size of a slob block.
95989 */
95990 -static slobidx_t slob_units(slob_t *s)
95991 +static slobidx_t slob_units(const slob_t *s)
95992 {
95993 if (s->units > 0)
95994 return s->units;
95995 @@ -167,7 +167,7 @@ static slobidx_t slob_units(slob_t *s)
95996 /*
95997 * Return the next free slob block pointer after this one.
95998 */
95999 -static slob_t *slob_next(slob_t *s)
96000 +static slob_t *slob_next(const slob_t *s)
96001 {
96002 slob_t *base = (slob_t *)((unsigned long)s & PAGE_MASK);
96003 slobidx_t next;
96004 @@ -182,14 +182,14 @@ static slob_t *slob_next(slob_t *s)
96005 /*
96006 * Returns true if s is the last free block in its page.
96007 */
96008 -static int slob_last(slob_t *s)
96009 +static int slob_last(const slob_t *s)
96010 {
96011 return !((unsigned long)slob_next(s) & ~PAGE_MASK);
96012 }
96013
96014 -static void *slob_new_pages(gfp_t gfp, int order, int node)
96015 +static struct page *slob_new_pages(gfp_t gfp, unsigned int order, int node)
96016 {
96017 - void *page;
96018 + struct page *page;
96019
96020 #ifdef CONFIG_NUMA
96021 if (node != NUMA_NO_NODE)
96022 @@ -201,14 +201,18 @@ static void *slob_new_pages(gfp_t gfp, int order, int node)
96023 if (!page)
96024 return NULL;
96025
96026 - return page_address(page);
96027 + __SetPageSlab(page);
96028 + return page;
96029 }
96030
96031 -static void slob_free_pages(void *b, int order)
96032 +static void slob_free_pages(struct page *sp, int order)
96033 {
96034 if (current->reclaim_state)
96035 current->reclaim_state->reclaimed_slab += 1 << order;
96036 - free_pages((unsigned long)b, order);
96037 + __ClearPageSlab(sp);
96038 + page_mapcount_reset(sp);
96039 + sp->private = 0;
96040 + __free_pages(sp, order);
96041 }
96042
96043 /*
96044 @@ -313,15 +317,15 @@ static void *slob_alloc(size_t size, gfp_t gfp, int align, int node)
96045
96046 /* Not enough space: must allocate a new page */
96047 if (!b) {
96048 - b = slob_new_pages(gfp & ~__GFP_ZERO, 0, node);
96049 - if (!b)
96050 + sp = slob_new_pages(gfp & ~__GFP_ZERO, 0, node);
96051 + if (!sp)
96052 return NULL;
96053 - sp = virt_to_page(b);
96054 - __SetPageSlab(sp);
96055 + b = page_address(sp);
96056
96057 spin_lock_irqsave(&slob_lock, flags);
96058 sp->units = SLOB_UNITS(PAGE_SIZE);
96059 sp->freelist = b;
96060 + sp->private = 0;
96061 INIT_LIST_HEAD(&sp->lru);
96062 set_slob(b, SLOB_UNITS(PAGE_SIZE), b + SLOB_UNITS(PAGE_SIZE));
96063 set_slob_page_free(sp, slob_list);
96064 @@ -359,12 +363,15 @@ static void slob_free(void *block, int size)
96065 if (slob_page_free(sp))
96066 clear_slob_page_free(sp);
96067 spin_unlock_irqrestore(&slob_lock, flags);
96068 - __ClearPageSlab(sp);
96069 - page_mapcount_reset(sp);
96070 - slob_free_pages(b, 0);
96071 + slob_free_pages(sp, 0);
96072 return;
96073 }
96074
96075 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
96076 + if (pax_sanitize_slab)
96077 + memset(block, PAX_MEMORY_SANITIZE_VALUE, size);
96078 +#endif
96079 +
96080 if (!slob_page_free(sp)) {
96081 /* This slob page is about to become partially free. Easy! */
96082 sp->units = units;
96083 @@ -424,11 +431,10 @@ out:
96084 */
96085
96086 static __always_inline void *
96087 -__do_kmalloc_node(size_t size, gfp_t gfp, int node, unsigned long caller)
96088 +__do_kmalloc_node_align(size_t size, gfp_t gfp, int node, unsigned long caller, int align)
96089 {
96090 - unsigned int *m;
96091 - int align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
96092 - void *ret;
96093 + slob_t *m;
96094 + void *ret = NULL;
96095
96096 gfp &= gfp_allowed_mask;
96097
96098 @@ -442,23 +448,41 @@ __do_kmalloc_node(size_t size, gfp_t gfp, int node, unsigned long caller)
96099
96100 if (!m)
96101 return NULL;
96102 - *m = size;
96103 + BUILD_BUG_ON(ARCH_KMALLOC_MINALIGN < 2 * SLOB_UNIT);
96104 + BUILD_BUG_ON(ARCH_SLAB_MINALIGN < 2 * SLOB_UNIT);
96105 + m[0].units = size;
96106 + m[1].units = align;
96107 ret = (void *)m + align;
96108
96109 trace_kmalloc_node(caller, ret,
96110 size, size + align, gfp, node);
96111 } else {
96112 unsigned int order = get_order(size);
96113 + struct page *page;
96114
96115 if (likely(order))
96116 gfp |= __GFP_COMP;
96117 - ret = slob_new_pages(gfp, order, node);
96118 + page = slob_new_pages(gfp, order, node);
96119 + if (page) {
96120 + ret = page_address(page);
96121 + page->private = size;
96122 + }
96123
96124 trace_kmalloc_node(caller, ret,
96125 size, PAGE_SIZE << order, gfp, node);
96126 }
96127
96128 - kmemleak_alloc(ret, size, 1, gfp);
96129 + return ret;
96130 +}
96131 +
96132 +static __always_inline void *
96133 +__do_kmalloc_node(size_t size, gfp_t gfp, int node, unsigned long caller)
96134 +{
96135 + int align = max(ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
96136 + void *ret = __do_kmalloc_node_align(size, gfp, node, caller, align);
96137 +
96138 + if (!ZERO_OR_NULL_PTR(ret))
96139 + kmemleak_alloc(ret, size, 1, gfp);
96140 return ret;
96141 }
96142
96143 @@ -493,34 +517,112 @@ void kfree(const void *block)
96144 return;
96145 kmemleak_free(block);
96146
96147 + VM_BUG_ON(!virt_addr_valid(block));
96148 sp = virt_to_page(block);
96149 - if (PageSlab(sp)) {
96150 + VM_BUG_ON(!PageSlab(sp));
96151 + if (!sp->private) {
96152 int align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
96153 - unsigned int *m = (unsigned int *)(block - align);
96154 - slob_free(m, *m + align);
96155 - } else
96156 + slob_t *m = (slob_t *)(block - align);
96157 + slob_free(m, m[0].units + align);
96158 + } else {
96159 + __ClearPageSlab(sp);
96160 + page_mapcount_reset(sp);
96161 + sp->private = 0;
96162 __free_pages(sp, compound_order(sp));
96163 + }
96164 }
96165 EXPORT_SYMBOL(kfree);
96166
96167 +bool is_usercopy_object(const void *ptr)
96168 +{
96169 + if (!slab_is_available())
96170 + return false;
96171 +
96172 + // PAX: TODO
96173 +
96174 + return false;
96175 +}
96176 +
96177 +#ifdef CONFIG_PAX_USERCOPY
96178 +const char *check_heap_object(const void *ptr, unsigned long n)
96179 +{
96180 + struct page *page;
96181 + const slob_t *free;
96182 + const void *base;
96183 + unsigned long flags;
96184 +
96185 + if (ZERO_OR_NULL_PTR(ptr))
96186 + return "<null>";
96187 +
96188 + if (!virt_addr_valid(ptr))
96189 + return NULL;
96190 +
96191 + page = virt_to_head_page(ptr);
96192 + if (!PageSlab(page))
96193 + return NULL;
96194 +
96195 + if (page->private) {
96196 + base = page;
96197 + if (base <= ptr && n <= page->private - (ptr - base))
96198 + return NULL;
96199 + return "<slob>";
96200 + }
96201 +
96202 + /* some tricky double walking to find the chunk */
96203 + spin_lock_irqsave(&slob_lock, flags);
96204 + base = (void *)((unsigned long)ptr & PAGE_MASK);
96205 + free = page->freelist;
96206 +
96207 + while (!slob_last(free) && (void *)free <= ptr) {
96208 + base = free + slob_units(free);
96209 + free = slob_next(free);
96210 + }
96211 +
96212 + while (base < (void *)free) {
96213 + slobidx_t m = ((slob_t *)base)[0].units, align = ((slob_t *)base)[1].units;
96214 + int size = SLOB_UNIT * SLOB_UNITS(m + align);
96215 + int offset;
96216 +
96217 + if (ptr < base + align)
96218 + break;
96219 +
96220 + offset = ptr - base - align;
96221 + if (offset >= m) {
96222 + base += size;
96223 + continue;
96224 + }
96225 +
96226 + if (n > m - offset)
96227 + break;
96228 +
96229 + spin_unlock_irqrestore(&slob_lock, flags);
96230 + return NULL;
96231 + }
96232 +
96233 + spin_unlock_irqrestore(&slob_lock, flags);
96234 + return "<slob>";
96235 +}
96236 +#endif
96237 +
96238 /* can't use ksize for kmem_cache_alloc memory, only kmalloc */
96239 size_t ksize(const void *block)
96240 {
96241 struct page *sp;
96242 int align;
96243 - unsigned int *m;
96244 + slob_t *m;
96245
96246 BUG_ON(!block);
96247 if (unlikely(block == ZERO_SIZE_PTR))
96248 return 0;
96249
96250 sp = virt_to_page(block);
96251 - if (unlikely(!PageSlab(sp)))
96252 - return PAGE_SIZE << compound_order(sp);
96253 + VM_BUG_ON(!PageSlab(sp));
96254 + if (sp->private)
96255 + return sp->private;
96256
96257 align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
96258 - m = (unsigned int *)(block - align);
96259 - return SLOB_UNITS(*m) * SLOB_UNIT;
96260 + m = (slob_t *)(block - align);
96261 + return SLOB_UNITS(m[0].units) * SLOB_UNIT;
96262 }
96263 EXPORT_SYMBOL(ksize);
96264
96265 @@ -536,23 +638,33 @@ int __kmem_cache_create(struct kmem_cache *c, unsigned long flags)
96266
96267 void *slob_alloc_node(struct kmem_cache *c, gfp_t flags, int node)
96268 {
96269 - void *b;
96270 + void *b = NULL;
96271
96272 flags &= gfp_allowed_mask;
96273
96274 lockdep_trace_alloc(flags);
96275
96276 +#ifdef CONFIG_PAX_USERCOPY_SLABS
96277 + b = __do_kmalloc_node_align(c->size, flags, node, _RET_IP_, c->align);
96278 +#else
96279 if (c->size < PAGE_SIZE) {
96280 b = slob_alloc(c->size, flags, c->align, node);
96281 trace_kmem_cache_alloc_node(_RET_IP_, b, c->object_size,
96282 SLOB_UNITS(c->size) * SLOB_UNIT,
96283 flags, node);
96284 } else {
96285 - b = slob_new_pages(flags, get_order(c->size), node);
96286 + struct page *sp;
96287 +
96288 + sp = slob_new_pages(flags, get_order(c->size), node);
96289 + if (sp) {
96290 + b = page_address(sp);
96291 + sp->private = c->size;
96292 + }
96293 trace_kmem_cache_alloc_node(_RET_IP_, b, c->object_size,
96294 PAGE_SIZE << get_order(c->size),
96295 flags, node);
96296 }
96297 +#endif
96298
96299 if (b && c->ctor)
96300 c->ctor(b);
96301 @@ -584,10 +696,14 @@ EXPORT_SYMBOL(kmem_cache_alloc_node);
96302
96303 static void __kmem_cache_free(void *b, int size)
96304 {
96305 - if (size < PAGE_SIZE)
96306 + struct page *sp;
96307 +
96308 + sp = virt_to_page(b);
96309 + BUG_ON(!PageSlab(sp));
96310 + if (!sp->private)
96311 slob_free(b, size);
96312 else
96313 - slob_free_pages(b, get_order(size));
96314 + slob_free_pages(sp, get_order(size));
96315 }
96316
96317 static void kmem_rcu_free(struct rcu_head *head)
96318 @@ -600,17 +716,31 @@ static void kmem_rcu_free(struct rcu_head *head)
96319
96320 void kmem_cache_free(struct kmem_cache *c, void *b)
96321 {
96322 + int size = c->size;
96323 +
96324 +#ifdef CONFIG_PAX_USERCOPY_SLABS
96325 + if (size + c->align < PAGE_SIZE) {
96326 + size += c->align;
96327 + b -= c->align;
96328 + }
96329 +#endif
96330 +
96331 kmemleak_free_recursive(b, c->flags);
96332 if (unlikely(c->flags & SLAB_DESTROY_BY_RCU)) {
96333 struct slob_rcu *slob_rcu;
96334 - slob_rcu = b + (c->size - sizeof(struct slob_rcu));
96335 - slob_rcu->size = c->size;
96336 + slob_rcu = b + (size - sizeof(struct slob_rcu));
96337 + slob_rcu->size = size;
96338 call_rcu(&slob_rcu->head, kmem_rcu_free);
96339 } else {
96340 - __kmem_cache_free(b, c->size);
96341 + __kmem_cache_free(b, size);
96342 }
96343
96344 +#ifdef CONFIG_PAX_USERCOPY_SLABS
96345 + trace_kfree(_RET_IP_, b);
96346 +#else
96347 trace_kmem_cache_free(_RET_IP_, b);
96348 +#endif
96349 +
96350 }
96351 EXPORT_SYMBOL(kmem_cache_free);
96352
96353 diff --git a/mm/slub.c b/mm/slub.c
96354 index 2b1ce69..4a2193f 100644
96355 --- a/mm/slub.c
96356 +++ b/mm/slub.c
96357 @@ -207,7 +207,7 @@ struct track {
96358
96359 enum track_item { TRACK_ALLOC, TRACK_FREE };
96360
96361 -#ifdef CONFIG_SYSFS
96362 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
96363 static int sysfs_slab_add(struct kmem_cache *);
96364 static int sysfs_slab_alias(struct kmem_cache *, const char *);
96365 static void memcg_propagate_slab_attrs(struct kmem_cache *s);
96366 @@ -546,7 +546,7 @@ static void print_track(const char *s, struct track *t)
96367 if (!t->addr)
96368 return;
96369
96370 - printk(KERN_ERR "INFO: %s in %pS age=%lu cpu=%u pid=%d\n",
96371 + printk(KERN_ERR "INFO: %s in %pA age=%lu cpu=%u pid=%d\n",
96372 s, (void *)t->addr, jiffies - t->when, t->cpu, t->pid);
96373 #ifdef CONFIG_STACKTRACE
96374 {
96375 @@ -2666,6 +2666,14 @@ static __always_inline void slab_free(struct kmem_cache *s,
96376
96377 slab_free_hook(s, x);
96378
96379 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
96380 + if (pax_sanitize_slab && !(s->flags & SLAB_NO_SANITIZE)) {
96381 + memset(x, PAX_MEMORY_SANITIZE_VALUE, s->object_size);
96382 + if (s->ctor)
96383 + s->ctor(x);
96384 + }
96385 +#endif
96386 +
96387 redo:
96388 /*
96389 * Determine the currently cpus per cpu slab.
96390 @@ -2733,7 +2741,7 @@ static int slub_min_objects;
96391 * Merge control. If this is set then no merging of slab caches will occur.
96392 * (Could be removed. This was introduced to pacify the merge skeptics.)
96393 */
96394 -static int slub_nomerge;
96395 +static int slub_nomerge = 1;
96396
96397 /*
96398 * Calculate the order of allocation given an slab object size.
96399 @@ -3014,6 +3022,9 @@ static int calculate_sizes(struct kmem_cache *s, int forced_order)
96400 s->inuse = size;
96401
96402 if (((flags & (SLAB_DESTROY_BY_RCU | SLAB_POISON)) ||
96403 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
96404 + (pax_sanitize_slab && !(flags & SLAB_NO_SANITIZE)) ||
96405 +#endif
96406 s->ctor)) {
96407 /*
96408 * Relocate free pointer after the object if it is not
96409 @@ -3343,6 +3354,59 @@ void *__kmalloc_node(size_t size, gfp_t flags, int node)
96410 EXPORT_SYMBOL(__kmalloc_node);
96411 #endif
96412
96413 +bool is_usercopy_object(const void *ptr)
96414 +{
96415 + struct page *page;
96416 + struct kmem_cache *s;
96417 +
96418 + if (ZERO_OR_NULL_PTR(ptr))
96419 + return false;
96420 +
96421 + if (!slab_is_available())
96422 + return false;
96423 +
96424 + if (!virt_addr_valid(ptr))
96425 + return false;
96426 +
96427 + page = virt_to_head_page(ptr);
96428 +
96429 + if (!PageSlab(page))
96430 + return false;
96431 +
96432 + s = page->slab_cache;
96433 + return s->flags & SLAB_USERCOPY;
96434 +}
96435 +
96436 +#ifdef CONFIG_PAX_USERCOPY
96437 +const char *check_heap_object(const void *ptr, unsigned long n)
96438 +{
96439 + struct page *page;
96440 + struct kmem_cache *s;
96441 + unsigned long offset;
96442 +
96443 + if (ZERO_OR_NULL_PTR(ptr))
96444 + return "<null>";
96445 +
96446 + if (!virt_addr_valid(ptr))
96447 + return NULL;
96448 +
96449 + page = virt_to_head_page(ptr);
96450 +
96451 + if (!PageSlab(page))
96452 + return NULL;
96453 +
96454 + s = page->slab_cache;
96455 + if (!(s->flags & SLAB_USERCOPY))
96456 + return s->name;
96457 +
96458 + offset = (ptr - page_address(page)) % s->size;
96459 + if (offset <= s->object_size && n <= s->object_size - offset)
96460 + return NULL;
96461 +
96462 + return s->name;
96463 +}
96464 +#endif
96465 +
96466 size_t ksize(const void *object)
96467 {
96468 struct page *page;
96469 @@ -3371,6 +3435,7 @@ void kfree(const void *x)
96470 if (unlikely(ZERO_OR_NULL_PTR(x)))
96471 return;
96472
96473 + VM_BUG_ON(!virt_addr_valid(x));
96474 page = virt_to_head_page(x);
96475 if (unlikely(!PageSlab(page))) {
96476 BUG_ON(!PageCompound(page));
96477 @@ -3679,7 +3744,7 @@ static int slab_unmergeable(struct kmem_cache *s)
96478 /*
96479 * We may have set a slab to be unmergeable during bootstrap.
96480 */
96481 - if (s->refcount < 0)
96482 + if (atomic_read(&s->refcount) < 0)
96483 return 1;
96484
96485 return 0;
96486 @@ -3736,7 +3801,7 @@ __kmem_cache_alias(const char *name, size_t size, size_t align,
96487 int i;
96488 struct kmem_cache *c;
96489
96490 - s->refcount++;
96491 + atomic_inc(&s->refcount);
96492
96493 /*
96494 * Adjust the object sizes so that we clear
96495 @@ -3755,7 +3820,7 @@ __kmem_cache_alias(const char *name, size_t size, size_t align,
96496 }
96497
96498 if (sysfs_slab_alias(s, name)) {
96499 - s->refcount--;
96500 + atomic_dec(&s->refcount);
96501 s = NULL;
96502 }
96503 }
96504 @@ -3872,7 +3937,7 @@ void *__kmalloc_node_track_caller(size_t size, gfp_t gfpflags,
96505 }
96506 #endif
96507
96508 -#ifdef CONFIG_SYSFS
96509 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
96510 static int count_inuse(struct page *page)
96511 {
96512 return page->inuse;
96513 @@ -4156,7 +4221,11 @@ static int list_locations(struct kmem_cache *s, char *buf,
96514 len += sprintf(buf + len, "%7ld ", l->count);
96515
96516 if (l->addr)
96517 +#ifdef CONFIG_GRKERNSEC_HIDESYM
96518 + len += sprintf(buf + len, "%pS", NULL);
96519 +#else
96520 len += sprintf(buf + len, "%pS", (void *)l->addr);
96521 +#endif
96522 else
96523 len += sprintf(buf + len, "<not-available>");
96524
96525 @@ -4261,12 +4330,12 @@ static void resiliency_test(void)
96526 validate_slab_cache(kmalloc_caches[9]);
96527 }
96528 #else
96529 -#ifdef CONFIG_SYSFS
96530 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
96531 static void resiliency_test(void) {};
96532 #endif
96533 #endif
96534
96535 -#ifdef CONFIG_SYSFS
96536 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
96537 enum slab_stat_type {
96538 SL_ALL, /* All slabs */
96539 SL_PARTIAL, /* Only partially allocated slabs */
96540 @@ -4506,13 +4575,17 @@ static ssize_t ctor_show(struct kmem_cache *s, char *buf)
96541 {
96542 if (!s->ctor)
96543 return 0;
96544 +#ifdef CONFIG_GRKERNSEC_HIDESYM
96545 + return sprintf(buf, "%pS\n", NULL);
96546 +#else
96547 return sprintf(buf, "%pS\n", s->ctor);
96548 +#endif
96549 }
96550 SLAB_ATTR_RO(ctor);
96551
96552 static ssize_t aliases_show(struct kmem_cache *s, char *buf)
96553 {
96554 - return sprintf(buf, "%d\n", s->refcount - 1);
96555 + return sprintf(buf, "%d\n", atomic_read(&s->refcount) - 1);
96556 }
96557 SLAB_ATTR_RO(aliases);
96558
96559 @@ -4600,6 +4673,14 @@ static ssize_t cache_dma_show(struct kmem_cache *s, char *buf)
96560 SLAB_ATTR_RO(cache_dma);
96561 #endif
96562
96563 +#ifdef CONFIG_PAX_USERCOPY_SLABS
96564 +static ssize_t usercopy_show(struct kmem_cache *s, char *buf)
96565 +{
96566 + return sprintf(buf, "%d\n", !!(s->flags & SLAB_USERCOPY));
96567 +}
96568 +SLAB_ATTR_RO(usercopy);
96569 +#endif
96570 +
96571 static ssize_t destroy_by_rcu_show(struct kmem_cache *s, char *buf)
96572 {
96573 return sprintf(buf, "%d\n", !!(s->flags & SLAB_DESTROY_BY_RCU));
96574 @@ -4934,6 +5015,9 @@ static struct attribute *slab_attrs[] = {
96575 #ifdef CONFIG_ZONE_DMA
96576 &cache_dma_attr.attr,
96577 #endif
96578 +#ifdef CONFIG_PAX_USERCOPY_SLABS
96579 + &usercopy_attr.attr,
96580 +#endif
96581 #ifdef CONFIG_NUMA
96582 &remote_node_defrag_ratio_attr.attr,
96583 #endif
96584 @@ -5184,6 +5268,7 @@ static char *create_unique_id(struct kmem_cache *s)
96585 return name;
96586 }
96587
96588 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
96589 static int sysfs_slab_add(struct kmem_cache *s)
96590 {
96591 int err;
96592 @@ -5257,6 +5342,7 @@ void sysfs_slab_remove(struct kmem_cache *s)
96593 kobject_del(&s->kobj);
96594 kobject_put(&s->kobj);
96595 }
96596 +#endif
96597
96598 /*
96599 * Need to buffer aliases during bootup until sysfs becomes
96600 @@ -5270,6 +5356,7 @@ struct saved_alias {
96601
96602 static struct saved_alias *alias_list;
96603
96604 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
96605 static int sysfs_slab_alias(struct kmem_cache *s, const char *name)
96606 {
96607 struct saved_alias *al;
96608 @@ -5292,6 +5379,7 @@ static int sysfs_slab_alias(struct kmem_cache *s, const char *name)
96609 alias_list = al;
96610 return 0;
96611 }
96612 +#endif
96613
96614 static int __init slab_sysfs_init(void)
96615 {
96616 diff --git a/mm/sparse-vmemmap.c b/mm/sparse-vmemmap.c
96617 index 4cba9c2..b4f9fcc 100644
96618 --- a/mm/sparse-vmemmap.c
96619 +++ b/mm/sparse-vmemmap.c
96620 @@ -131,7 +131,7 @@ pud_t * __meminit vmemmap_pud_populate(pgd_t *pgd, unsigned long addr, int node)
96621 void *p = vmemmap_alloc_block(PAGE_SIZE, node);
96622 if (!p)
96623 return NULL;
96624 - pud_populate(&init_mm, pud, p);
96625 + pud_populate_kernel(&init_mm, pud, p);
96626 }
96627 return pud;
96628 }
96629 @@ -143,7 +143,7 @@ pgd_t * __meminit vmemmap_pgd_populate(unsigned long addr, int node)
96630 void *p = vmemmap_alloc_block(PAGE_SIZE, node);
96631 if (!p)
96632 return NULL;
96633 - pgd_populate(&init_mm, pgd, p);
96634 + pgd_populate_kernel(&init_mm, pgd, p);
96635 }
96636 return pgd;
96637 }
96638 diff --git a/mm/sparse.c b/mm/sparse.c
96639 index d1b48b6..6e8590e 100644
96640 --- a/mm/sparse.c
96641 +++ b/mm/sparse.c
96642 @@ -750,7 +750,7 @@ static void clear_hwpoisoned_pages(struct page *memmap, int nr_pages)
96643
96644 for (i = 0; i < PAGES_PER_SECTION; i++) {
96645 if (PageHWPoison(&memmap[i])) {
96646 - atomic_long_sub(1, &num_poisoned_pages);
96647 + atomic_long_sub_unchecked(1, &num_poisoned_pages);
96648 ClearPageHWPoison(&memmap[i]);
96649 }
96650 }
96651 diff --git a/mm/swap.c b/mm/swap.c
96652 index 9ce43ba..43bdc4c 100644
96653 --- a/mm/swap.c
96654 +++ b/mm/swap.c
96655 @@ -31,6 +31,7 @@
96656 #include <linux/memcontrol.h>
96657 #include <linux/gfp.h>
96658 #include <linux/uio.h>
96659 +#include <linux/hugetlb.h>
96660
96661 #include "internal.h"
96662
96663 @@ -76,6 +77,8 @@ static void __put_compound_page(struct page *page)
96664
96665 __page_cache_release(page);
96666 dtor = get_compound_page_dtor(page);
96667 + if (!PageHuge(page))
96668 + BUG_ON(dtor != free_compound_page);
96669 (*dtor)(page);
96670 }
96671
96672 diff --git a/mm/swapfile.c b/mm/swapfile.c
96673 index 4a7f7e6..22cddf5 100644
96674 --- a/mm/swapfile.c
96675 +++ b/mm/swapfile.c
96676 @@ -66,7 +66,7 @@ static DEFINE_MUTEX(swapon_mutex);
96677
96678 static DECLARE_WAIT_QUEUE_HEAD(proc_poll_wait);
96679 /* Activity counter to indicate that a swapon or swapoff has occurred */
96680 -static atomic_t proc_poll_event = ATOMIC_INIT(0);
96681 +static atomic_unchecked_t proc_poll_event = ATOMIC_INIT(0);
96682
96683 static inline unsigned char swap_count(unsigned char ent)
96684 {
96685 @@ -1959,7 +1959,7 @@ SYSCALL_DEFINE1(swapoff, const char __user *, specialfile)
96686 spin_unlock(&swap_lock);
96687
96688 err = 0;
96689 - atomic_inc(&proc_poll_event);
96690 + atomic_inc_unchecked(&proc_poll_event);
96691 wake_up_interruptible(&proc_poll_wait);
96692
96693 out_dput:
96694 @@ -1976,8 +1976,8 @@ static unsigned swaps_poll(struct file *file, poll_table *wait)
96695
96696 poll_wait(file, &proc_poll_wait, wait);
96697
96698 - if (seq->poll_event != atomic_read(&proc_poll_event)) {
96699 - seq->poll_event = atomic_read(&proc_poll_event);
96700 + if (seq->poll_event != atomic_read_unchecked(&proc_poll_event)) {
96701 + seq->poll_event = atomic_read_unchecked(&proc_poll_event);
96702 return POLLIN | POLLRDNORM | POLLERR | POLLPRI;
96703 }
96704
96705 @@ -2075,7 +2075,7 @@ static int swaps_open(struct inode *inode, struct file *file)
96706 return ret;
96707
96708 seq = file->private_data;
96709 - seq->poll_event = atomic_read(&proc_poll_event);
96710 + seq->poll_event = atomic_read_unchecked(&proc_poll_event);
96711 return 0;
96712 }
96713
96714 @@ -2534,7 +2534,7 @@ SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags)
96715 (frontswap_map) ? "FS" : "");
96716
96717 mutex_unlock(&swapon_mutex);
96718 - atomic_inc(&proc_poll_event);
96719 + atomic_inc_unchecked(&proc_poll_event);
96720 wake_up_interruptible(&proc_poll_wait);
96721
96722 if (S_ISREG(inode->i_mode))
96723 diff --git a/mm/util.c b/mm/util.c
96724 index d5ea733..e8953f9 100644
96725 --- a/mm/util.c
96726 +++ b/mm/util.c
96727 @@ -299,6 +299,12 @@ done:
96728 void arch_pick_mmap_layout(struct mm_struct *mm)
96729 {
96730 mm->mmap_base = TASK_UNMAPPED_BASE;
96731 +
96732 +#ifdef CONFIG_PAX_RANDMMAP
96733 + if (mm->pax_flags & MF_PAX_RANDMMAP)
96734 + mm->mmap_base += mm->delta_mmap;
96735 +#endif
96736 +
96737 mm->get_unmapped_area = arch_get_unmapped_area;
96738 }
96739 #endif
96740 @@ -475,6 +481,9 @@ int get_cmdline(struct task_struct *task, char *buffer, int buflen)
96741 if (!mm->arg_end)
96742 goto out_mm; /* Shh! No looking before we're done */
96743
96744 + if (gr_acl_handle_procpidmem(task))
96745 + goto out_mm;
96746 +
96747 len = mm->arg_end - mm->arg_start;
96748
96749 if (len > buflen)
96750 diff --git a/mm/vmalloc.c b/mm/vmalloc.c
96751 index bf233b2..680f9ef 100644
96752 --- a/mm/vmalloc.c
96753 +++ b/mm/vmalloc.c
96754 @@ -40,6 +40,21 @@ struct vfree_deferred {
96755 };
96756 static DEFINE_PER_CPU(struct vfree_deferred, vfree_deferred);
96757
96758 +#ifdef CONFIG_GRKERNSEC_KSTACKOVERFLOW
96759 +struct stack_deferred_llist {
96760 + struct llist_head list;
96761 + void *stack;
96762 + void *lowmem_stack;
96763 +};
96764 +
96765 +struct stack_deferred {
96766 + struct stack_deferred_llist list;
96767 + struct work_struct wq;
96768 +};
96769 +
96770 +static DEFINE_PER_CPU(struct stack_deferred, stack_deferred);
96771 +#endif
96772 +
96773 static void __vunmap(const void *, int);
96774
96775 static void free_work(struct work_struct *w)
96776 @@ -47,12 +62,30 @@ static void free_work(struct work_struct *w)
96777 struct vfree_deferred *p = container_of(w, struct vfree_deferred, wq);
96778 struct llist_node *llnode = llist_del_all(&p->list);
96779 while (llnode) {
96780 - void *p = llnode;
96781 + void *x = llnode;
96782 llnode = llist_next(llnode);
96783 - __vunmap(p, 1);
96784 + __vunmap(x, 1);
96785 }
96786 }
96787
96788 +#ifdef CONFIG_GRKERNSEC_KSTACKOVERFLOW
96789 +static void unmap_work(struct work_struct *w)
96790 +{
96791 + struct stack_deferred *p = container_of(w, struct stack_deferred, wq);
96792 + struct llist_node *llnode = llist_del_all(&p->list.list);
96793 + while (llnode) {
96794 + struct stack_deferred_llist *x =
96795 + llist_entry((struct llist_head *)llnode,
96796 + struct stack_deferred_llist, list);
96797 + void *stack = ACCESS_ONCE(x->stack);
96798 + void *lowmem_stack = ACCESS_ONCE(x->lowmem_stack);
96799 + llnode = llist_next(llnode);
96800 + __vunmap(stack, 0);
96801 + free_memcg_kmem_pages((unsigned long)lowmem_stack, THREAD_SIZE_ORDER);
96802 + }
96803 +}
96804 +#endif
96805 +
96806 /*** Page table manipulation functions ***/
96807
96808 static void vunmap_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end)
96809 @@ -61,8 +94,19 @@ static void vunmap_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end)
96810
96811 pte = pte_offset_kernel(pmd, addr);
96812 do {
96813 - pte_t ptent = ptep_get_and_clear(&init_mm, addr, pte);
96814 - WARN_ON(!pte_none(ptent) && !pte_present(ptent));
96815 +
96816 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
96817 + if ((unsigned long)MODULES_EXEC_VADDR <= addr && addr < (unsigned long)MODULES_EXEC_END) {
96818 + BUG_ON(!pte_exec(*pte));
96819 + set_pte_at(&init_mm, addr, pte, pfn_pte(__pa(addr) >> PAGE_SHIFT, PAGE_KERNEL_EXEC));
96820 + continue;
96821 + }
96822 +#endif
96823 +
96824 + {
96825 + pte_t ptent = ptep_get_and_clear(&init_mm, addr, pte);
96826 + WARN_ON(!pte_none(ptent) && !pte_present(ptent));
96827 + }
96828 } while (pte++, addr += PAGE_SIZE, addr != end);
96829 }
96830
96831 @@ -122,16 +166,29 @@ static int vmap_pte_range(pmd_t *pmd, unsigned long addr,
96832 pte = pte_alloc_kernel(pmd, addr);
96833 if (!pte)
96834 return -ENOMEM;
96835 +
96836 + pax_open_kernel();
96837 do {
96838 struct page *page = pages[*nr];
96839
96840 - if (WARN_ON(!pte_none(*pte)))
96841 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
96842 + if (pgprot_val(prot) & _PAGE_NX)
96843 +#endif
96844 +
96845 + if (!pte_none(*pte)) {
96846 + pax_close_kernel();
96847 + WARN_ON(1);
96848 return -EBUSY;
96849 - if (WARN_ON(!page))
96850 + }
96851 + if (!page) {
96852 + pax_close_kernel();
96853 + WARN_ON(1);
96854 return -ENOMEM;
96855 + }
96856 set_pte_at(&init_mm, addr, pte, mk_pte(page, prot));
96857 (*nr)++;
96858 } while (pte++, addr += PAGE_SIZE, addr != end);
96859 + pax_close_kernel();
96860 return 0;
96861 }
96862
96863 @@ -141,7 +198,7 @@ static int vmap_pmd_range(pud_t *pud, unsigned long addr,
96864 pmd_t *pmd;
96865 unsigned long next;
96866
96867 - pmd = pmd_alloc(&init_mm, pud, addr);
96868 + pmd = pmd_alloc_kernel(&init_mm, pud, addr);
96869 if (!pmd)
96870 return -ENOMEM;
96871 do {
96872 @@ -158,7 +215,7 @@ static int vmap_pud_range(pgd_t *pgd, unsigned long addr,
96873 pud_t *pud;
96874 unsigned long next;
96875
96876 - pud = pud_alloc(&init_mm, pgd, addr);
96877 + pud = pud_alloc_kernel(&init_mm, pgd, addr);
96878 if (!pud)
96879 return -ENOMEM;
96880 do {
96881 @@ -218,6 +275,12 @@ int is_vmalloc_or_module_addr(const void *x)
96882 if (addr >= MODULES_VADDR && addr < MODULES_END)
96883 return 1;
96884 #endif
96885 +
96886 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
96887 + if (x >= (const void *)MODULES_EXEC_VADDR && x < (const void *)MODULES_EXEC_END)
96888 + return 1;
96889 +#endif
96890 +
96891 return is_vmalloc_addr(x);
96892 }
96893
96894 @@ -238,8 +301,14 @@ struct page *vmalloc_to_page(const void *vmalloc_addr)
96895
96896 if (!pgd_none(*pgd)) {
96897 pud_t *pud = pud_offset(pgd, addr);
96898 +#ifdef CONFIG_X86
96899 + if (!pud_large(*pud))
96900 +#endif
96901 if (!pud_none(*pud)) {
96902 pmd_t *pmd = pmd_offset(pud, addr);
96903 +#ifdef CONFIG_X86
96904 + if (!pmd_large(*pmd))
96905 +#endif
96906 if (!pmd_none(*pmd)) {
96907 pte_t *ptep, pte;
96908
96909 @@ -1183,13 +1252,23 @@ void __init vmalloc_init(void)
96910 for_each_possible_cpu(i) {
96911 struct vmap_block_queue *vbq;
96912 struct vfree_deferred *p;
96913 +#ifdef CONFIG_GRKERNSEC_KSTACKOVERFLOW
96914 + struct stack_deferred *p2;
96915 +#endif
96916
96917 vbq = &per_cpu(vmap_block_queue, i);
96918 spin_lock_init(&vbq->lock);
96919 INIT_LIST_HEAD(&vbq->free);
96920 +
96921 p = &per_cpu(vfree_deferred, i);
96922 init_llist_head(&p->list);
96923 INIT_WORK(&p->wq, free_work);
96924 +
96925 +#ifdef CONFIG_GRKERNSEC_KSTACKOVERFLOW
96926 + p2 = &per_cpu(stack_deferred, i);
96927 + init_llist_head(&p2->list.list);
96928 + INIT_WORK(&p2->wq, unmap_work);
96929 +#endif
96930 }
96931
96932 /* Import existing vmlist entries. */
96933 @@ -1317,6 +1396,16 @@ static struct vm_struct *__get_vm_area_node(unsigned long size,
96934 struct vm_struct *area;
96935
96936 BUG_ON(in_interrupt());
96937 +
96938 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
96939 + if (flags & VM_KERNEXEC) {
96940 + if (start != VMALLOC_START || end != VMALLOC_END)
96941 + return NULL;
96942 + start = (unsigned long)MODULES_EXEC_VADDR;
96943 + end = (unsigned long)MODULES_EXEC_END;
96944 + }
96945 +#endif
96946 +
96947 if (flags & VM_IOREMAP)
96948 align = 1ul << clamp(fls(size), PAGE_SHIFT, IOREMAP_MAX_ORDER);
96949
96950 @@ -1511,7 +1600,7 @@ EXPORT_SYMBOL(vfree);
96951 * Free the virtually contiguous memory area starting at @addr,
96952 * which was created from the page array passed to vmap().
96953 *
96954 - * Must not be called in interrupt context.
96955 + * Must not be called in NMI context.
96956 */
96957 void vunmap(const void *addr)
96958 {
96959 @@ -1522,6 +1611,23 @@ void vunmap(const void *addr)
96960 }
96961 EXPORT_SYMBOL(vunmap);
96962
96963 +#ifdef CONFIG_GRKERNSEC_KSTACKOVERFLOW
96964 +void unmap_process_stacks(struct task_struct *task)
96965 +{
96966 + if (unlikely(in_interrupt())) {
96967 + struct stack_deferred *p = &__get_cpu_var(stack_deferred);
96968 + struct stack_deferred_llist *list = task->stack;
96969 + list->stack = task->stack;
96970 + list->lowmem_stack = task->lowmem_stack;
96971 + if (llist_add((struct llist_node *)&list->list, &p->list.list))
96972 + schedule_work(&p->wq);
96973 + } else {
96974 + __vunmap(task->stack, 0);
96975 + free_memcg_kmem_pages((unsigned long)task->lowmem_stack, THREAD_SIZE_ORDER);
96976 + }
96977 +}
96978 +#endif
96979 +
96980 /**
96981 * vmap - map an array of pages into virtually contiguous space
96982 * @pages: array of page pointers
96983 @@ -1542,6 +1648,11 @@ void *vmap(struct page **pages, unsigned int count,
96984 if (count > totalram_pages)
96985 return NULL;
96986
96987 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
96988 + if (!(pgprot_val(prot) & _PAGE_NX))
96989 + flags |= VM_KERNEXEC;
96990 +#endif
96991 +
96992 area = get_vm_area_caller((count << PAGE_SHIFT), flags,
96993 __builtin_return_address(0));
96994 if (!area)
96995 @@ -1642,6 +1753,13 @@ void *__vmalloc_node_range(unsigned long size, unsigned long align,
96996 if (!size || (size >> PAGE_SHIFT) > totalram_pages)
96997 goto fail;
96998
96999 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
97000 + if (!(pgprot_val(prot) & _PAGE_NX))
97001 + area = __get_vm_area_node(size, align, VM_ALLOC | VM_UNINITIALIZED | VM_KERNEXEC,
97002 + VMALLOC_START, VMALLOC_END, node, gfp_mask, caller);
97003 + else
97004 +#endif
97005 +
97006 area = __get_vm_area_node(size, align, VM_ALLOC | VM_UNINITIALIZED,
97007 start, end, node, gfp_mask, caller);
97008 if (!area)
97009 @@ -1818,10 +1936,9 @@ EXPORT_SYMBOL(vzalloc_node);
97010 * For tight control over page level allocator and protection flags
97011 * use __vmalloc() instead.
97012 */
97013 -
97014 void *vmalloc_exec(unsigned long size)
97015 {
97016 - return __vmalloc_node(size, 1, GFP_KERNEL | __GFP_HIGHMEM, PAGE_KERNEL_EXEC,
97017 + return __vmalloc_node(size, 1, GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO, PAGE_KERNEL_EXEC,
97018 NUMA_NO_NODE, __builtin_return_address(0));
97019 }
97020
97021 @@ -2128,6 +2245,8 @@ int remap_vmalloc_range_partial(struct vm_area_struct *vma, unsigned long uaddr,
97022 {
97023 struct vm_struct *area;
97024
97025 + BUG_ON(vma->vm_mirror);
97026 +
97027 size = PAGE_ALIGN(size);
97028
97029 if (!PAGE_ALIGNED(uaddr) || !PAGE_ALIGNED(kaddr))
97030 @@ -2610,7 +2729,11 @@ static int s_show(struct seq_file *m, void *p)
97031 v->addr, v->addr + v->size, v->size);
97032
97033 if (v->caller)
97034 +#ifdef CONFIG_GRKERNSEC_HIDESYM
97035 + seq_printf(m, " %pK", v->caller);
97036 +#else
97037 seq_printf(m, " %pS", v->caller);
97038 +#endif
97039
97040 if (v->nr_pages)
97041 seq_printf(m, " pages=%d", v->nr_pages);
97042 diff --git a/mm/vmstat.c b/mm/vmstat.c
97043 index 302dd07..3841f1c 100644
97044 --- a/mm/vmstat.c
97045 +++ b/mm/vmstat.c
97046 @@ -20,6 +20,7 @@
97047 #include <linux/writeback.h>
97048 #include <linux/compaction.h>
97049 #include <linux/mm_inline.h>
97050 +#include <linux/grsecurity.h>
97051
97052 #include "internal.h"
97053
97054 @@ -79,7 +80,7 @@ void vm_events_fold_cpu(int cpu)
97055 *
97056 * vm_stat contains the global counters
97057 */
97058 -atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS] __cacheline_aligned_in_smp;
97059 +atomic_long_unchecked_t vm_stat[NR_VM_ZONE_STAT_ITEMS] __cacheline_aligned_in_smp;
97060 EXPORT_SYMBOL(vm_stat);
97061
97062 #ifdef CONFIG_SMP
97063 @@ -423,7 +424,7 @@ static inline void fold_diff(int *diff)
97064
97065 for (i = 0; i < NR_VM_ZONE_STAT_ITEMS; i++)
97066 if (diff[i])
97067 - atomic_long_add(diff[i], &vm_stat[i]);
97068 + atomic_long_add_unchecked(diff[i], &vm_stat[i]);
97069 }
97070
97071 /*
97072 @@ -455,7 +456,7 @@ static void refresh_cpu_vm_stats(void)
97073 v = this_cpu_xchg(p->vm_stat_diff[i], 0);
97074 if (v) {
97075
97076 - atomic_long_add(v, &zone->vm_stat[i]);
97077 + atomic_long_add_unchecked(v, &zone->vm_stat[i]);
97078 global_diff[i] += v;
97079 #ifdef CONFIG_NUMA
97080 /* 3 seconds idle till flush */
97081 @@ -517,7 +518,7 @@ void cpu_vm_stats_fold(int cpu)
97082
97083 v = p->vm_stat_diff[i];
97084 p->vm_stat_diff[i] = 0;
97085 - atomic_long_add(v, &zone->vm_stat[i]);
97086 + atomic_long_add_unchecked(v, &zone->vm_stat[i]);
97087 global_diff[i] += v;
97088 }
97089 }
97090 @@ -537,8 +538,8 @@ void drain_zonestat(struct zone *zone, struct per_cpu_pageset *pset)
97091 if (pset->vm_stat_diff[i]) {
97092 int v = pset->vm_stat_diff[i];
97093 pset->vm_stat_diff[i] = 0;
97094 - atomic_long_add(v, &zone->vm_stat[i]);
97095 - atomic_long_add(v, &vm_stat[i]);
97096 + atomic_long_add_unchecked(v, &zone->vm_stat[i]);
97097 + atomic_long_add_unchecked(v, &vm_stat[i]);
97098 }
97099 }
97100 #endif
97101 @@ -1156,10 +1157,22 @@ static void *vmstat_start(struct seq_file *m, loff_t *pos)
97102 stat_items_size += sizeof(struct vm_event_state);
97103 #endif
97104
97105 - v = kmalloc(stat_items_size, GFP_KERNEL);
97106 + v = kzalloc(stat_items_size, GFP_KERNEL);
97107 m->private = v;
97108 if (!v)
97109 return ERR_PTR(-ENOMEM);
97110 +
97111 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
97112 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
97113 + if (!uid_eq(current_uid(), GLOBAL_ROOT_UID)
97114 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
97115 + && !in_group_p(grsec_proc_gid)
97116 +#endif
97117 + )
97118 + return (unsigned long *)m->private + *pos;
97119 +#endif
97120 +#endif
97121 +
97122 for (i = 0; i < NR_VM_ZONE_STAT_ITEMS; i++)
97123 v[i] = global_page_state(i);
97124 v += NR_VM_ZONE_STAT_ITEMS;
97125 @@ -1308,10 +1321,16 @@ static int __init setup_vmstat(void)
97126 cpu_notifier_register_done();
97127 #endif
97128 #ifdef CONFIG_PROC_FS
97129 - proc_create("buddyinfo", S_IRUGO, NULL, &fragmentation_file_operations);
97130 - proc_create("pagetypeinfo", S_IRUGO, NULL, &pagetypeinfo_file_ops);
97131 - proc_create("vmstat", S_IRUGO, NULL, &proc_vmstat_file_operations);
97132 - proc_create("zoneinfo", S_IRUGO, NULL, &proc_zoneinfo_file_operations);
97133 + {
97134 + mode_t gr_mode = S_IRUGO;
97135 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
97136 + gr_mode = S_IRUSR;
97137 +#endif
97138 + proc_create("buddyinfo", gr_mode, NULL, &fragmentation_file_operations);
97139 + proc_create("pagetypeinfo", gr_mode, NULL, &pagetypeinfo_file_ops);
97140 + proc_create("vmstat", S_IRUGO, NULL, &proc_vmstat_file_operations);
97141 + proc_create("zoneinfo", gr_mode, NULL, &proc_zoneinfo_file_operations);
97142 + }
97143 #endif
97144 return 0;
97145 }
97146 diff --git a/net/8021q/vlan.c b/net/8021q/vlan.c
97147 index 44ebd5c..1f732bae 100644
97148 --- a/net/8021q/vlan.c
97149 +++ b/net/8021q/vlan.c
97150 @@ -475,7 +475,7 @@ out:
97151 return NOTIFY_DONE;
97152 }
97153
97154 -static struct notifier_block vlan_notifier_block __read_mostly = {
97155 +static struct notifier_block vlan_notifier_block = {
97156 .notifier_call = vlan_device_event,
97157 };
97158
97159 @@ -550,8 +550,7 @@ static int vlan_ioctl_handler(struct net *net, void __user *arg)
97160 err = -EPERM;
97161 if (!ns_capable(net->user_ns, CAP_NET_ADMIN))
97162 break;
97163 - if ((args.u.name_type >= 0) &&
97164 - (args.u.name_type < VLAN_NAME_TYPE_HIGHEST)) {
97165 + if (args.u.name_type < VLAN_NAME_TYPE_HIGHEST) {
97166 struct vlan_net *vn;
97167
97168 vn = net_generic(net, vlan_net_id);
97169 diff --git a/net/9p/client.c b/net/9p/client.c
97170 index 0004cba..feba240 100644
97171 --- a/net/9p/client.c
97172 +++ b/net/9p/client.c
97173 @@ -596,7 +596,7 @@ static int p9_check_zc_errors(struct p9_client *c, struct p9_req_t *req,
97174 len - inline_len);
97175 } else {
97176 err = copy_from_user(ename + inline_len,
97177 - uidata, len - inline_len);
97178 + (char __force_user *)uidata, len - inline_len);
97179 if (err) {
97180 err = -EFAULT;
97181 goto out_err;
97182 @@ -1571,7 +1571,7 @@ p9_client_read(struct p9_fid *fid, char *data, char __user *udata, u64 offset,
97183 kernel_buf = 1;
97184 indata = data;
97185 } else
97186 - indata = (__force char *)udata;
97187 + indata = (__force_kernel char *)udata;
97188 /*
97189 * response header len is 11
97190 * PDU Header(7) + IO Size (4)
97191 @@ -1646,7 +1646,7 @@ p9_client_write(struct p9_fid *fid, char *data, const char __user *udata,
97192 kernel_buf = 1;
97193 odata = data;
97194 } else
97195 - odata = (char *)udata;
97196 + odata = (char __force_kernel *)udata;
97197 req = p9_client_zc_rpc(clnt, P9_TWRITE, NULL, odata, 0, rsize,
97198 P9_ZC_HDR_SZ, kernel_buf, "dqd",
97199 fid->fid, offset, rsize);
97200 diff --git a/net/9p/mod.c b/net/9p/mod.c
97201 index 6ab36ae..6f1841b 100644
97202 --- a/net/9p/mod.c
97203 +++ b/net/9p/mod.c
97204 @@ -84,7 +84,7 @@ static LIST_HEAD(v9fs_trans_list);
97205 void v9fs_register_trans(struct p9_trans_module *m)
97206 {
97207 spin_lock(&v9fs_trans_lock);
97208 - list_add_tail(&m->list, &v9fs_trans_list);
97209 + pax_list_add_tail((struct list_head *)&m->list, &v9fs_trans_list);
97210 spin_unlock(&v9fs_trans_lock);
97211 }
97212 EXPORT_SYMBOL(v9fs_register_trans);
97213 @@ -97,7 +97,7 @@ EXPORT_SYMBOL(v9fs_register_trans);
97214 void v9fs_unregister_trans(struct p9_trans_module *m)
97215 {
97216 spin_lock(&v9fs_trans_lock);
97217 - list_del_init(&m->list);
97218 + pax_list_del_init((struct list_head *)&m->list);
97219 spin_unlock(&v9fs_trans_lock);
97220 }
97221 EXPORT_SYMBOL(v9fs_unregister_trans);
97222 diff --git a/net/9p/trans_fd.c b/net/9p/trans_fd.c
97223 index 80d08f6..de63fd1 100644
97224 --- a/net/9p/trans_fd.c
97225 +++ b/net/9p/trans_fd.c
97226 @@ -428,7 +428,7 @@ static int p9_fd_write(struct p9_client *client, void *v, int len)
97227 oldfs = get_fs();
97228 set_fs(get_ds());
97229 /* The cast to a user pointer is valid due to the set_fs() */
97230 - ret = vfs_write(ts->wr, (__force void __user *)v, len, &ts->wr->f_pos);
97231 + ret = vfs_write(ts->wr, (void __force_user *)v, len, &ts->wr->f_pos);
97232 set_fs(oldfs);
97233
97234 if (ret <= 0 && ret != -ERESTARTSYS && ret != -EAGAIN)
97235 diff --git a/net/appletalk/atalk_proc.c b/net/appletalk/atalk_proc.c
97236 index af46bc4..f9adfcd 100644
97237 --- a/net/appletalk/atalk_proc.c
97238 +++ b/net/appletalk/atalk_proc.c
97239 @@ -256,7 +256,7 @@ int __init atalk_proc_init(void)
97240 struct proc_dir_entry *p;
97241 int rc = -ENOMEM;
97242
97243 - atalk_proc_dir = proc_mkdir("atalk", init_net.proc_net);
97244 + atalk_proc_dir = proc_mkdir_restrict("atalk", init_net.proc_net);
97245 if (!atalk_proc_dir)
97246 goto out;
97247
97248 diff --git a/net/atm/atm_misc.c b/net/atm/atm_misc.c
97249 index 876fbe8..8bbea9f 100644
97250 --- a/net/atm/atm_misc.c
97251 +++ b/net/atm/atm_misc.c
97252 @@ -17,7 +17,7 @@ int atm_charge(struct atm_vcc *vcc, int truesize)
97253 if (atomic_read(&sk_atm(vcc)->sk_rmem_alloc) <= sk_atm(vcc)->sk_rcvbuf)
97254 return 1;
97255 atm_return(vcc, truesize);
97256 - atomic_inc(&vcc->stats->rx_drop);
97257 + atomic_inc_unchecked(&vcc->stats->rx_drop);
97258 return 0;
97259 }
97260 EXPORT_SYMBOL(atm_charge);
97261 @@ -39,7 +39,7 @@ struct sk_buff *atm_alloc_charge(struct atm_vcc *vcc, int pdu_size,
97262 }
97263 }
97264 atm_return(vcc, guess);
97265 - atomic_inc(&vcc->stats->rx_drop);
97266 + atomic_inc_unchecked(&vcc->stats->rx_drop);
97267 return NULL;
97268 }
97269 EXPORT_SYMBOL(atm_alloc_charge);
97270 @@ -86,7 +86,7 @@ EXPORT_SYMBOL(atm_pcr_goal);
97271
97272 void sonet_copy_stats(struct k_sonet_stats *from, struct sonet_stats *to)
97273 {
97274 -#define __HANDLE_ITEM(i) to->i = atomic_read(&from->i)
97275 +#define __HANDLE_ITEM(i) to->i = atomic_read_unchecked(&from->i)
97276 __SONET_ITEMS
97277 #undef __HANDLE_ITEM
97278 }
97279 @@ -94,7 +94,7 @@ EXPORT_SYMBOL(sonet_copy_stats);
97280
97281 void sonet_subtract_stats(struct k_sonet_stats *from, struct sonet_stats *to)
97282 {
97283 -#define __HANDLE_ITEM(i) atomic_sub(to->i, &from->i)
97284 +#define __HANDLE_ITEM(i) atomic_sub_unchecked(to->i,&from->i)
97285 __SONET_ITEMS
97286 #undef __HANDLE_ITEM
97287 }
97288 diff --git a/net/atm/lec.c b/net/atm/lec.c
97289 index 4c5b8ba..95f7005 100644
97290 --- a/net/atm/lec.c
97291 +++ b/net/atm/lec.c
97292 @@ -111,9 +111,9 @@ static inline void lec_arp_put(struct lec_arp_table *entry)
97293 }
97294
97295 static struct lane2_ops lane2_ops = {
97296 - lane2_resolve, /* resolve, spec 3.1.3 */
97297 - lane2_associate_req, /* associate_req, spec 3.1.4 */
97298 - NULL /* associate indicator, spec 3.1.5 */
97299 + .resolve = lane2_resolve,
97300 + .associate_req = lane2_associate_req,
97301 + .associate_indicator = NULL
97302 };
97303
97304 static unsigned char bus_mac[ETH_ALEN] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
97305 diff --git a/net/atm/lec.h b/net/atm/lec.h
97306 index 4149db1..f2ab682 100644
97307 --- a/net/atm/lec.h
97308 +++ b/net/atm/lec.h
97309 @@ -48,7 +48,7 @@ struct lane2_ops {
97310 const u8 *tlvs, u32 sizeoftlvs);
97311 void (*associate_indicator) (struct net_device *dev, const u8 *mac_addr,
97312 const u8 *tlvs, u32 sizeoftlvs);
97313 -};
97314 +} __no_const;
97315
97316 /*
97317 * ATM LAN Emulation supports both LLC & Dix Ethernet EtherType
97318 diff --git a/net/atm/mpoa_caches.c b/net/atm/mpoa_caches.c
97319 index d1b2d9a..d549f7f 100644
97320 --- a/net/atm/mpoa_caches.c
97321 +++ b/net/atm/mpoa_caches.c
97322 @@ -535,30 +535,30 @@ static void eg_destroy_cache(struct mpoa_client *mpc)
97323
97324
97325 static struct in_cache_ops ingress_ops = {
97326 - in_cache_add_entry, /* add_entry */
97327 - in_cache_get, /* get */
97328 - in_cache_get_with_mask, /* get_with_mask */
97329 - in_cache_get_by_vcc, /* get_by_vcc */
97330 - in_cache_put, /* put */
97331 - in_cache_remove_entry, /* remove_entry */
97332 - cache_hit, /* cache_hit */
97333 - clear_count_and_expired, /* clear_count */
97334 - check_resolving_entries, /* check_resolving */
97335 - refresh_entries, /* refresh */
97336 - in_destroy_cache /* destroy_cache */
97337 + .add_entry = in_cache_add_entry,
97338 + .get = in_cache_get,
97339 + .get_with_mask = in_cache_get_with_mask,
97340 + .get_by_vcc = in_cache_get_by_vcc,
97341 + .put = in_cache_put,
97342 + .remove_entry = in_cache_remove_entry,
97343 + .cache_hit = cache_hit,
97344 + .clear_count = clear_count_and_expired,
97345 + .check_resolving = check_resolving_entries,
97346 + .refresh = refresh_entries,
97347 + .destroy_cache = in_destroy_cache
97348 };
97349
97350 static struct eg_cache_ops egress_ops = {
97351 - eg_cache_add_entry, /* add_entry */
97352 - eg_cache_get_by_cache_id, /* get_by_cache_id */
97353 - eg_cache_get_by_tag, /* get_by_tag */
97354 - eg_cache_get_by_vcc, /* get_by_vcc */
97355 - eg_cache_get_by_src_ip, /* get_by_src_ip */
97356 - eg_cache_put, /* put */
97357 - eg_cache_remove_entry, /* remove_entry */
97358 - update_eg_cache_entry, /* update */
97359 - clear_expired, /* clear_expired */
97360 - eg_destroy_cache /* destroy_cache */
97361 + .add_entry = eg_cache_add_entry,
97362 + .get_by_cache_id = eg_cache_get_by_cache_id,
97363 + .get_by_tag = eg_cache_get_by_tag,
97364 + .get_by_vcc = eg_cache_get_by_vcc,
97365 + .get_by_src_ip = eg_cache_get_by_src_ip,
97366 + .put = eg_cache_put,
97367 + .remove_entry = eg_cache_remove_entry,
97368 + .update = update_eg_cache_entry,
97369 + .clear_expired = clear_expired,
97370 + .destroy_cache = eg_destroy_cache
97371 };
97372
97373
97374 diff --git a/net/atm/proc.c b/net/atm/proc.c
97375 index bbb6461..cf04016 100644
97376 --- a/net/atm/proc.c
97377 +++ b/net/atm/proc.c
97378 @@ -45,9 +45,9 @@ static void add_stats(struct seq_file *seq, const char *aal,
97379 const struct k_atm_aal_stats *stats)
97380 {
97381 seq_printf(seq, "%s ( %d %d %d %d %d )", aal,
97382 - atomic_read(&stats->tx), atomic_read(&stats->tx_err),
97383 - atomic_read(&stats->rx), atomic_read(&stats->rx_err),
97384 - atomic_read(&stats->rx_drop));
97385 + atomic_read_unchecked(&stats->tx),atomic_read_unchecked(&stats->tx_err),
97386 + atomic_read_unchecked(&stats->rx),atomic_read_unchecked(&stats->rx_err),
97387 + atomic_read_unchecked(&stats->rx_drop));
97388 }
97389
97390 static void atm_dev_info(struct seq_file *seq, const struct atm_dev *dev)
97391 diff --git a/net/atm/resources.c b/net/atm/resources.c
97392 index 0447d5d..3cf4728 100644
97393 --- a/net/atm/resources.c
97394 +++ b/net/atm/resources.c
97395 @@ -160,7 +160,7 @@ EXPORT_SYMBOL(atm_dev_deregister);
97396 static void copy_aal_stats(struct k_atm_aal_stats *from,
97397 struct atm_aal_stats *to)
97398 {
97399 -#define __HANDLE_ITEM(i) to->i = atomic_read(&from->i)
97400 +#define __HANDLE_ITEM(i) to->i = atomic_read_unchecked(&from->i)
97401 __AAL_STAT_ITEMS
97402 #undef __HANDLE_ITEM
97403 }
97404 @@ -168,7 +168,7 @@ static void copy_aal_stats(struct k_atm_aal_stats *from,
97405 static void subtract_aal_stats(struct k_atm_aal_stats *from,
97406 struct atm_aal_stats *to)
97407 {
97408 -#define __HANDLE_ITEM(i) atomic_sub(to->i, &from->i)
97409 +#define __HANDLE_ITEM(i) atomic_sub_unchecked(to->i, &from->i)
97410 __AAL_STAT_ITEMS
97411 #undef __HANDLE_ITEM
97412 }
97413 diff --git a/net/ax25/sysctl_net_ax25.c b/net/ax25/sysctl_net_ax25.c
97414 index 919a5ce..cc6b444 100644
97415 --- a/net/ax25/sysctl_net_ax25.c
97416 +++ b/net/ax25/sysctl_net_ax25.c
97417 @@ -152,7 +152,7 @@ int ax25_register_dev_sysctl(ax25_dev *ax25_dev)
97418 {
97419 char path[sizeof("net/ax25/") + IFNAMSIZ];
97420 int k;
97421 - struct ctl_table *table;
97422 + ctl_table_no_const *table;
97423
97424 table = kmemdup(ax25_param_table, sizeof(ax25_param_table), GFP_KERNEL);
97425 if (!table)
97426 diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c
97427 index f04224c..f326579 100644
97428 --- a/net/batman-adv/bat_iv_ogm.c
97429 +++ b/net/batman-adv/bat_iv_ogm.c
97430 @@ -312,7 +312,7 @@ static int batadv_iv_ogm_iface_enable(struct batadv_hard_iface *hard_iface)
97431
97432 /* randomize initial seqno to avoid collision */
97433 get_random_bytes(&random_seqno, sizeof(random_seqno));
97434 - atomic_set(&hard_iface->bat_iv.ogm_seqno, random_seqno);
97435 + atomic_set_unchecked(&hard_iface->bat_iv.ogm_seqno, random_seqno);
97436
97437 hard_iface->bat_iv.ogm_buff_len = BATADV_OGM_HLEN;
97438 ogm_buff = kmalloc(hard_iface->bat_iv.ogm_buff_len, GFP_ATOMIC);
97439 @@ -917,9 +917,9 @@ static void batadv_iv_ogm_schedule(struct batadv_hard_iface *hard_iface)
97440 batadv_ogm_packet->tvlv_len = htons(tvlv_len);
97441
97442 /* change sequence number to network order */
97443 - seqno = (uint32_t)atomic_read(&hard_iface->bat_iv.ogm_seqno);
97444 + seqno = (uint32_t)atomic_read_unchecked(&hard_iface->bat_iv.ogm_seqno);
97445 batadv_ogm_packet->seqno = htonl(seqno);
97446 - atomic_inc(&hard_iface->bat_iv.ogm_seqno);
97447 + atomic_inc_unchecked(&hard_iface->bat_iv.ogm_seqno);
97448
97449 batadv_iv_ogm_slide_own_bcast_window(hard_iface);
97450
97451 @@ -1596,7 +1596,7 @@ static void batadv_iv_ogm_process(const struct sk_buff *skb, int ogm_offset,
97452 return;
97453
97454 /* could be changed by schedule_own_packet() */
97455 - if_incoming_seqno = atomic_read(&if_incoming->bat_iv.ogm_seqno);
97456 + if_incoming_seqno = atomic_read_unchecked(&if_incoming->bat_iv.ogm_seqno);
97457
97458 if (ogm_packet->flags & BATADV_DIRECTLINK)
97459 has_directlink_flag = true;
97460 diff --git a/net/batman-adv/fragmentation.c b/net/batman-adv/fragmentation.c
97461 index f14e54a..66f3e2e 100644
97462 --- a/net/batman-adv/fragmentation.c
97463 +++ b/net/batman-adv/fragmentation.c
97464 @@ -446,7 +446,7 @@ bool batadv_frag_send_packet(struct sk_buff *skb,
97465 frag_header.packet_type = BATADV_UNICAST_FRAG;
97466 frag_header.version = BATADV_COMPAT_VERSION;
97467 frag_header.ttl = BATADV_TTL;
97468 - frag_header.seqno = htons(atomic_inc_return(&bat_priv->frag_seqno));
97469 + frag_header.seqno = htons(atomic_inc_return_unchecked(&bat_priv->frag_seqno));
97470 frag_header.reserved = 0;
97471 frag_header.no = 0;
97472 frag_header.total_size = htons(skb->len);
97473 diff --git a/net/batman-adv/soft-interface.c b/net/batman-adv/soft-interface.c
97474 index 744a59b..8fd037c 100644
97475 --- a/net/batman-adv/soft-interface.c
97476 +++ b/net/batman-adv/soft-interface.c
97477 @@ -296,7 +296,7 @@ send:
97478 primary_if->net_dev->dev_addr);
97479
97480 /* set broadcast sequence number */
97481 - seqno = atomic_inc_return(&bat_priv->bcast_seqno);
97482 + seqno = atomic_inc_return_unchecked(&bat_priv->bcast_seqno);
97483 bcast_packet->seqno = htonl(seqno);
97484
97485 batadv_add_bcast_packet_to_list(bat_priv, skb, brd_delay);
97486 @@ -729,7 +729,7 @@ static int batadv_softif_init_late(struct net_device *dev)
97487 atomic_set(&bat_priv->batman_queue_left, BATADV_BATMAN_QUEUE_LEN);
97488
97489 atomic_set(&bat_priv->mesh_state, BATADV_MESH_INACTIVE);
97490 - atomic_set(&bat_priv->bcast_seqno, 1);
97491 + atomic_set_unchecked(&bat_priv->bcast_seqno, 1);
97492 atomic_set(&bat_priv->tt.vn, 0);
97493 atomic_set(&bat_priv->tt.local_changes, 0);
97494 atomic_set(&bat_priv->tt.ogm_append_cnt, 0);
97495 @@ -743,7 +743,7 @@ static int batadv_softif_init_late(struct net_device *dev)
97496
97497 /* randomize initial seqno to avoid collision */
97498 get_random_bytes(&random_seqno, sizeof(random_seqno));
97499 - atomic_set(&bat_priv->frag_seqno, random_seqno);
97500 + atomic_set_unchecked(&bat_priv->frag_seqno, random_seqno);
97501
97502 bat_priv->primary_if = NULL;
97503 bat_priv->num_ifaces = 0;
97504 diff --git a/net/batman-adv/types.h b/net/batman-adv/types.h
97505 index 34891a5..3cfece0 100644
97506 --- a/net/batman-adv/types.h
97507 +++ b/net/batman-adv/types.h
97508 @@ -67,7 +67,7 @@ enum batadv_dhcp_recipient {
97509 struct batadv_hard_iface_bat_iv {
97510 unsigned char *ogm_buff;
97511 int ogm_buff_len;
97512 - atomic_t ogm_seqno;
97513 + atomic_unchecked_t ogm_seqno;
97514 };
97515
97516 /**
97517 @@ -766,7 +766,7 @@ struct batadv_priv {
97518 atomic_t bonding;
97519 atomic_t fragmentation;
97520 atomic_t packet_size_max;
97521 - atomic_t frag_seqno;
97522 + atomic_unchecked_t frag_seqno;
97523 #ifdef CONFIG_BATMAN_ADV_BLA
97524 atomic_t bridge_loop_avoidance;
97525 #endif
97526 @@ -785,7 +785,7 @@ struct batadv_priv {
97527 #endif
97528 uint32_t isolation_mark;
97529 uint32_t isolation_mark_mask;
97530 - atomic_t bcast_seqno;
97531 + atomic_unchecked_t bcast_seqno;
97532 atomic_t bcast_queue_left;
97533 atomic_t batman_queue_left;
97534 char num_ifaces;
97535 diff --git a/net/bluetooth/hci_sock.c b/net/bluetooth/hci_sock.c
97536 index b9a418e..2af862a 100644
97537 --- a/net/bluetooth/hci_sock.c
97538 +++ b/net/bluetooth/hci_sock.c
97539 @@ -1053,7 +1053,7 @@ static int hci_sock_setsockopt(struct socket *sock, int level, int optname,
97540 uf.event_mask[1] = *((u32 *) f->event_mask + 1);
97541 }
97542
97543 - len = min_t(unsigned int, len, sizeof(uf));
97544 + len = min((size_t)len, sizeof(uf));
97545 if (copy_from_user(&uf, optval, len)) {
97546 err = -EFAULT;
97547 break;
97548 diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
97549 index dc4d301..4975bac 100644
97550 --- a/net/bluetooth/l2cap_core.c
97551 +++ b/net/bluetooth/l2cap_core.c
97552 @@ -3536,8 +3536,10 @@ static int l2cap_parse_conf_rsp(struct l2cap_chan *chan, void *rsp, int len,
97553 break;
97554
97555 case L2CAP_CONF_RFC:
97556 - if (olen == sizeof(rfc))
97557 - memcpy(&rfc, (void *)val, olen);
97558 + if (olen != sizeof(rfc))
97559 + break;
97560 +
97561 + memcpy(&rfc, (void *)val, olen);
97562
97563 if (test_bit(CONF_STATE2_DEVICE, &chan->conf_state) &&
97564 rfc.mode != chan->mode)
97565 diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
97566 index ef5e5b0..7d904ad 100644
97567 --- a/net/bluetooth/l2cap_sock.c
97568 +++ b/net/bluetooth/l2cap_sock.c
97569 @@ -628,7 +628,8 @@ static int l2cap_sock_setsockopt_old(struct socket *sock, int optname,
97570 struct sock *sk = sock->sk;
97571 struct l2cap_chan *chan = l2cap_pi(sk)->chan;
97572 struct l2cap_options opts;
97573 - int len, err = 0;
97574 + int err = 0;
97575 + size_t len = optlen;
97576 u32 opt;
97577
97578 BT_DBG("sk %p", sk);
97579 @@ -655,7 +656,7 @@ static int l2cap_sock_setsockopt_old(struct socket *sock, int optname,
97580 opts.max_tx = chan->max_tx;
97581 opts.txwin_size = chan->tx_win;
97582
97583 - len = min_t(unsigned int, sizeof(opts), optlen);
97584 + len = min(sizeof(opts), len);
97585 if (copy_from_user((char *) &opts, optval, len)) {
97586 err = -EFAULT;
97587 break;
97588 @@ -742,7 +743,8 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
97589 struct bt_security sec;
97590 struct bt_power pwr;
97591 struct l2cap_conn *conn;
97592 - int len, err = 0;
97593 + int err = 0;
97594 + size_t len = optlen;
97595 u32 opt;
97596
97597 BT_DBG("sk %p", sk);
97598 @@ -766,7 +768,7 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
97599
97600 sec.level = BT_SECURITY_LOW;
97601
97602 - len = min_t(unsigned int, sizeof(sec), optlen);
97603 + len = min(sizeof(sec), len);
97604 if (copy_from_user((char *) &sec, optval, len)) {
97605 err = -EFAULT;
97606 break;
97607 @@ -866,7 +868,7 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
97608
97609 pwr.force_active = BT_POWER_FORCE_ACTIVE_ON;
97610
97611 - len = min_t(unsigned int, sizeof(pwr), optlen);
97612 + len = min(sizeof(pwr), len);
97613 if (copy_from_user((char *) &pwr, optval, len)) {
97614 err = -EFAULT;
97615 break;
97616 diff --git a/net/bluetooth/rfcomm/sock.c b/net/bluetooth/rfcomm/sock.c
97617 index c603a5e..7f08991 100644
97618 --- a/net/bluetooth/rfcomm/sock.c
97619 +++ b/net/bluetooth/rfcomm/sock.c
97620 @@ -687,7 +687,7 @@ static int rfcomm_sock_setsockopt(struct socket *sock, int level, int optname, c
97621 struct sock *sk = sock->sk;
97622 struct bt_security sec;
97623 int err = 0;
97624 - size_t len;
97625 + size_t len = optlen;
97626 u32 opt;
97627
97628 BT_DBG("sk %p", sk);
97629 @@ -709,7 +709,7 @@ static int rfcomm_sock_setsockopt(struct socket *sock, int level, int optname, c
97630
97631 sec.level = BT_SECURITY_LOW;
97632
97633 - len = min_t(unsigned int, sizeof(sec), optlen);
97634 + len = min(sizeof(sec), len);
97635 if (copy_from_user((char *) &sec, optval, len)) {
97636 err = -EFAULT;
97637 break;
97638 diff --git a/net/bluetooth/rfcomm/tty.c b/net/bluetooth/rfcomm/tty.c
97639 index 403ec09..a21a003 100644
97640 --- a/net/bluetooth/rfcomm/tty.c
97641 +++ b/net/bluetooth/rfcomm/tty.c
97642 @@ -752,7 +752,7 @@ static int rfcomm_tty_open(struct tty_struct *tty, struct file *filp)
97643 BT_DBG("tty %p id %d", tty, tty->index);
97644
97645 BT_DBG("dev %p dst %pMR channel %d opened %d", dev, &dev->dst,
97646 - dev->channel, dev->port.count);
97647 + dev->channel, atomic_read(&dev->port.count));
97648
97649 err = tty_port_open(&dev->port, tty, filp);
97650 if (err)
97651 @@ -775,7 +775,7 @@ static void rfcomm_tty_close(struct tty_struct *tty, struct file *filp)
97652 struct rfcomm_dev *dev = (struct rfcomm_dev *) tty->driver_data;
97653
97654 BT_DBG("tty %p dev %p dlc %p opened %d", tty, dev, dev->dlc,
97655 - dev->port.count);
97656 + atomic_read(&dev->port.count));
97657
97658 tty_port_close(&dev->port, tty, filp);
97659 }
97660 diff --git a/net/bridge/netfilter/ebtables.c b/net/bridge/netfilter/ebtables.c
97661 index 1059ed3..d70846a 100644
97662 --- a/net/bridge/netfilter/ebtables.c
97663 +++ b/net/bridge/netfilter/ebtables.c
97664 @@ -1524,7 +1524,7 @@ static int do_ebt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
97665 tmp.valid_hooks = t->table->valid_hooks;
97666 }
97667 mutex_unlock(&ebt_mutex);
97668 - if (copy_to_user(user, &tmp, *len) != 0) {
97669 + if (*len > sizeof(tmp) || copy_to_user(user, &tmp, *len) != 0) {
97670 BUGPRINT("c2u Didn't work\n");
97671 ret = -EFAULT;
97672 break;
97673 @@ -2330,7 +2330,7 @@ static int compat_do_ebt_get_ctl(struct sock *sk, int cmd,
97674 goto out;
97675 tmp.valid_hooks = t->valid_hooks;
97676
97677 - if (copy_to_user(user, &tmp, *len) != 0) {
97678 + if (*len > sizeof(tmp) || copy_to_user(user, &tmp, *len) != 0) {
97679 ret = -EFAULT;
97680 break;
97681 }
97682 @@ -2341,7 +2341,7 @@ static int compat_do_ebt_get_ctl(struct sock *sk, int cmd,
97683 tmp.entries_size = t->table->entries_size;
97684 tmp.valid_hooks = t->table->valid_hooks;
97685
97686 - if (copy_to_user(user, &tmp, *len) != 0) {
97687 + if (*len > sizeof(tmp) || copy_to_user(user, &tmp, *len) != 0) {
97688 ret = -EFAULT;
97689 break;
97690 }
97691 diff --git a/net/caif/cfctrl.c b/net/caif/cfctrl.c
97692 index 0f45522..dab651f 100644
97693 --- a/net/caif/cfctrl.c
97694 +++ b/net/caif/cfctrl.c
97695 @@ -10,6 +10,7 @@
97696 #include <linux/spinlock.h>
97697 #include <linux/slab.h>
97698 #include <linux/pkt_sched.h>
97699 +#include <linux/sched.h>
97700 #include <net/caif/caif_layer.h>
97701 #include <net/caif/cfpkt.h>
97702 #include <net/caif/cfctrl.h>
97703 @@ -43,8 +44,8 @@ struct cflayer *cfctrl_create(void)
97704 memset(&dev_info, 0, sizeof(dev_info));
97705 dev_info.id = 0xff;
97706 cfsrvl_init(&this->serv, 0, &dev_info, false);
97707 - atomic_set(&this->req_seq_no, 1);
97708 - atomic_set(&this->rsp_seq_no, 1);
97709 + atomic_set_unchecked(&this->req_seq_no, 1);
97710 + atomic_set_unchecked(&this->rsp_seq_no, 1);
97711 this->serv.layer.receive = cfctrl_recv;
97712 sprintf(this->serv.layer.name, "ctrl");
97713 this->serv.layer.ctrlcmd = cfctrl_ctrlcmd;
97714 @@ -130,8 +131,8 @@ static void cfctrl_insert_req(struct cfctrl *ctrl,
97715 struct cfctrl_request_info *req)
97716 {
97717 spin_lock_bh(&ctrl->info_list_lock);
97718 - atomic_inc(&ctrl->req_seq_no);
97719 - req->sequence_no = atomic_read(&ctrl->req_seq_no);
97720 + atomic_inc_unchecked(&ctrl->req_seq_no);
97721 + req->sequence_no = atomic_read_unchecked(&ctrl->req_seq_no);
97722 list_add_tail(&req->list, &ctrl->list);
97723 spin_unlock_bh(&ctrl->info_list_lock);
97724 }
97725 @@ -149,7 +150,7 @@ static struct cfctrl_request_info *cfctrl_remove_req(struct cfctrl *ctrl,
97726 if (p != first)
97727 pr_warn("Requests are not received in order\n");
97728
97729 - atomic_set(&ctrl->rsp_seq_no,
97730 + atomic_set_unchecked(&ctrl->rsp_seq_no,
97731 p->sequence_no);
97732 list_del(&p->list);
97733 goto out;
97734 diff --git a/net/can/af_can.c b/net/can/af_can.c
97735 index a27f8aa..67174a3 100644
97736 --- a/net/can/af_can.c
97737 +++ b/net/can/af_can.c
97738 @@ -863,7 +863,7 @@ static const struct net_proto_family can_family_ops = {
97739 };
97740
97741 /* notifier block for netdevice event */
97742 -static struct notifier_block can_netdev_notifier __read_mostly = {
97743 +static struct notifier_block can_netdev_notifier = {
97744 .notifier_call = can_notifier,
97745 };
97746
97747 diff --git a/net/can/bcm.c b/net/can/bcm.c
97748 index dcb75c0..24b1b43 100644
97749 --- a/net/can/bcm.c
97750 +++ b/net/can/bcm.c
97751 @@ -1624,7 +1624,7 @@ static int __init bcm_module_init(void)
97752 }
97753
97754 /* create /proc/net/can-bcm directory */
97755 - proc_dir = proc_mkdir("can-bcm", init_net.proc_net);
97756 + proc_dir = proc_mkdir_restrict("can-bcm", init_net.proc_net);
97757 return 0;
97758 }
97759
97760 diff --git a/net/can/gw.c b/net/can/gw.c
97761 index 050a211..bb9fe33 100644
97762 --- a/net/can/gw.c
97763 +++ b/net/can/gw.c
97764 @@ -80,7 +80,6 @@ MODULE_PARM_DESC(max_hops,
97765 "default: " __stringify(CGW_DEFAULT_HOPS) ")");
97766
97767 static HLIST_HEAD(cgw_list);
97768 -static struct notifier_block notifier;
97769
97770 static struct kmem_cache *cgw_cache __read_mostly;
97771
97772 @@ -947,6 +946,10 @@ static int cgw_remove_job(struct sk_buff *skb, struct nlmsghdr *nlh)
97773 return err;
97774 }
97775
97776 +static struct notifier_block notifier = {
97777 + .notifier_call = cgw_notifier
97778 +};
97779 +
97780 static __init int cgw_module_init(void)
97781 {
97782 /* sanitize given module parameter */
97783 @@ -962,7 +965,6 @@ static __init int cgw_module_init(void)
97784 return -ENOMEM;
97785
97786 /* set notifier */
97787 - notifier.notifier_call = cgw_notifier;
97788 register_netdevice_notifier(&notifier);
97789
97790 if (__rtnl_register(PF_CAN, RTM_GETROUTE, NULL, cgw_dump_jobs, NULL)) {
97791 diff --git a/net/can/proc.c b/net/can/proc.c
97792 index b543470..d2ddae2 100644
97793 --- a/net/can/proc.c
97794 +++ b/net/can/proc.c
97795 @@ -468,7 +468,7 @@ static void can_remove_proc_readentry(const char *name)
97796 void can_init_proc(void)
97797 {
97798 /* create /proc/net/can directory */
97799 - can_dir = proc_mkdir("can", init_net.proc_net);
97800 + can_dir = proc_mkdir_restrict("can", init_net.proc_net);
97801
97802 if (!can_dir) {
97803 printk(KERN_INFO "can: failed to create /proc/net/can . "
97804 diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c
97805 index 1948d59..9e854d5 100644
97806 --- a/net/ceph/messenger.c
97807 +++ b/net/ceph/messenger.c
97808 @@ -187,7 +187,7 @@ static void con_fault(struct ceph_connection *con);
97809 #define MAX_ADDR_STR_LEN 64 /* 54 is enough */
97810
97811 static char addr_str[ADDR_STR_COUNT][MAX_ADDR_STR_LEN];
97812 -static atomic_t addr_str_seq = ATOMIC_INIT(0);
97813 +static atomic_unchecked_t addr_str_seq = ATOMIC_INIT(0);
97814
97815 static struct page *zero_page; /* used in certain error cases */
97816
97817 @@ -198,7 +198,7 @@ const char *ceph_pr_addr(const struct sockaddr_storage *ss)
97818 struct sockaddr_in *in4 = (struct sockaddr_in *) ss;
97819 struct sockaddr_in6 *in6 = (struct sockaddr_in6 *) ss;
97820
97821 - i = atomic_inc_return(&addr_str_seq) & ADDR_STR_COUNT_MASK;
97822 + i = atomic_inc_return_unchecked(&addr_str_seq) & ADDR_STR_COUNT_MASK;
97823 s = addr_str[i];
97824
97825 switch (ss->ss_family) {
97826 diff --git a/net/compat.c b/net/compat.c
97827 index 9a76eaf..5b8ccfd 100644
97828 --- a/net/compat.c
97829 +++ b/net/compat.c
97830 @@ -73,9 +73,9 @@ int get_compat_msghdr(struct msghdr *kmsg, struct compat_msghdr __user *umsg)
97831 return -EFAULT;
97832 if (kmsg->msg_namelen > sizeof(struct sockaddr_storage))
97833 kmsg->msg_namelen = sizeof(struct sockaddr_storage);
97834 - kmsg->msg_name = compat_ptr(tmp1);
97835 - kmsg->msg_iov = compat_ptr(tmp2);
97836 - kmsg->msg_control = compat_ptr(tmp3);
97837 + kmsg->msg_name = (void __force_kernel *)compat_ptr(tmp1);
97838 + kmsg->msg_iov = (void __force_kernel *)compat_ptr(tmp2);
97839 + kmsg->msg_control = (void __force_kernel *)compat_ptr(tmp3);
97840 return 0;
97841 }
97842
97843 @@ -87,7 +87,7 @@ int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov,
97844
97845 if (kern_msg->msg_namelen) {
97846 if (mode == VERIFY_READ) {
97847 - int err = move_addr_to_kernel(kern_msg->msg_name,
97848 + int err = move_addr_to_kernel((void __force_user *)kern_msg->msg_name,
97849 kern_msg->msg_namelen,
97850 kern_address);
97851 if (err < 0)
97852 @@ -99,7 +99,7 @@ int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov,
97853 kern_msg->msg_name = NULL;
97854
97855 tot_len = iov_from_user_compat_to_kern(kern_iov,
97856 - (struct compat_iovec __user *)kern_msg->msg_iov,
97857 + (struct compat_iovec __force_user *)kern_msg->msg_iov,
97858 kern_msg->msg_iovlen);
97859 if (tot_len >= 0)
97860 kern_msg->msg_iov = kern_iov;
97861 @@ -119,20 +119,20 @@ int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov,
97862
97863 #define CMSG_COMPAT_FIRSTHDR(msg) \
97864 (((msg)->msg_controllen) >= sizeof(struct compat_cmsghdr) ? \
97865 - (struct compat_cmsghdr __user *)((msg)->msg_control) : \
97866 + (struct compat_cmsghdr __force_user *)((msg)->msg_control) : \
97867 (struct compat_cmsghdr __user *)NULL)
97868
97869 #define CMSG_COMPAT_OK(ucmlen, ucmsg, mhdr) \
97870 ((ucmlen) >= sizeof(struct compat_cmsghdr) && \
97871 (ucmlen) <= (unsigned long) \
97872 ((mhdr)->msg_controllen - \
97873 - ((char *)(ucmsg) - (char *)(mhdr)->msg_control)))
97874 + ((char __force_kernel *)(ucmsg) - (char *)(mhdr)->msg_control)))
97875
97876 static inline struct compat_cmsghdr __user *cmsg_compat_nxthdr(struct msghdr *msg,
97877 struct compat_cmsghdr __user *cmsg, int cmsg_len)
97878 {
97879 char __user *ptr = (char __user *)cmsg + CMSG_COMPAT_ALIGN(cmsg_len);
97880 - if ((unsigned long)(ptr + 1 - (char __user *)msg->msg_control) >
97881 + if ((unsigned long)(ptr + 1 - (char __force_user *)msg->msg_control) >
97882 msg->msg_controllen)
97883 return NULL;
97884 return (struct compat_cmsghdr __user *)ptr;
97885 @@ -222,7 +222,7 @@ Efault:
97886
97887 int put_cmsg_compat(struct msghdr *kmsg, int level, int type, int len, void *data)
97888 {
97889 - struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __user *) kmsg->msg_control;
97890 + struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __force_user *) kmsg->msg_control;
97891 struct compat_cmsghdr cmhdr;
97892 struct compat_timeval ctv;
97893 struct compat_timespec cts[3];
97894 @@ -278,7 +278,7 @@ int put_cmsg_compat(struct msghdr *kmsg, int level, int type, int len, void *dat
97895
97896 void scm_detach_fds_compat(struct msghdr *kmsg, struct scm_cookie *scm)
97897 {
97898 - struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __user *) kmsg->msg_control;
97899 + struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __force_user *) kmsg->msg_control;
97900 int fdmax = (kmsg->msg_controllen - sizeof(struct compat_cmsghdr)) / sizeof(int);
97901 int fdnum = scm->fp->count;
97902 struct file **fp = scm->fp->fp;
97903 @@ -366,7 +366,7 @@ static int do_set_sock_timeout(struct socket *sock, int level,
97904 return -EFAULT;
97905 old_fs = get_fs();
97906 set_fs(KERNEL_DS);
97907 - err = sock_setsockopt(sock, level, optname, (char *)&ktime, sizeof(ktime));
97908 + err = sock_setsockopt(sock, level, optname, (char __force_user *)&ktime, sizeof(ktime));
97909 set_fs(old_fs);
97910
97911 return err;
97912 @@ -427,7 +427,7 @@ static int do_get_sock_timeout(struct socket *sock, int level, int optname,
97913 len = sizeof(ktime);
97914 old_fs = get_fs();
97915 set_fs(KERNEL_DS);
97916 - err = sock_getsockopt(sock, level, optname, (char *) &ktime, &len);
97917 + err = sock_getsockopt(sock, level, optname, (char __force_user *) &ktime, (int __force_user *)&len);
97918 set_fs(old_fs);
97919
97920 if (!err) {
97921 @@ -570,7 +570,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
97922 case MCAST_JOIN_GROUP:
97923 case MCAST_LEAVE_GROUP:
97924 {
97925 - struct compat_group_req __user *gr32 = (void *)optval;
97926 + struct compat_group_req __user *gr32 = (void __user *)optval;
97927 struct group_req __user *kgr =
97928 compat_alloc_user_space(sizeof(struct group_req));
97929 u32 interface;
97930 @@ -591,7 +591,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
97931 case MCAST_BLOCK_SOURCE:
97932 case MCAST_UNBLOCK_SOURCE:
97933 {
97934 - struct compat_group_source_req __user *gsr32 = (void *)optval;
97935 + struct compat_group_source_req __user *gsr32 = (void __user *)optval;
97936 struct group_source_req __user *kgsr = compat_alloc_user_space(
97937 sizeof(struct group_source_req));
97938 u32 interface;
97939 @@ -612,7 +612,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
97940 }
97941 case MCAST_MSFILTER:
97942 {
97943 - struct compat_group_filter __user *gf32 = (void *)optval;
97944 + struct compat_group_filter __user *gf32 = (void __user *)optval;
97945 struct group_filter __user *kgf;
97946 u32 interface, fmode, numsrc;
97947
97948 @@ -650,7 +650,7 @@ int compat_mc_getsockopt(struct sock *sock, int level, int optname,
97949 char __user *optval, int __user *optlen,
97950 int (*getsockopt)(struct sock *, int, int, char __user *, int __user *))
97951 {
97952 - struct compat_group_filter __user *gf32 = (void *)optval;
97953 + struct compat_group_filter __user *gf32 = (void __user *)optval;
97954 struct group_filter __user *kgf;
97955 int __user *koptlen;
97956 u32 interface, fmode, numsrc;
97957 @@ -803,7 +803,7 @@ COMPAT_SYSCALL_DEFINE2(socketcall, int, call, u32 __user *, args)
97958
97959 if (call < SYS_SOCKET || call > SYS_SENDMMSG)
97960 return -EINVAL;
97961 - if (copy_from_user(a, args, nas[call]))
97962 + if (nas[call] > sizeof a || copy_from_user(a, args, nas[call]))
97963 return -EFAULT;
97964 a0 = a[0];
97965 a1 = a[1];
97966 diff --git a/net/core/datagram.c b/net/core/datagram.c
97967 index a16ed7b..eb44d17 100644
97968 --- a/net/core/datagram.c
97969 +++ b/net/core/datagram.c
97970 @@ -301,7 +301,7 @@ int skb_kill_datagram(struct sock *sk, struct sk_buff *skb, unsigned int flags)
97971 }
97972
97973 kfree_skb(skb);
97974 - atomic_inc(&sk->sk_drops);
97975 + atomic_inc_unchecked(&sk->sk_drops);
97976 sk_mem_reclaim_partial(sk);
97977
97978 return err;
97979 diff --git a/net/core/dev.c b/net/core/dev.c
97980 index fb8b054..30fb342 100644
97981 --- a/net/core/dev.c
97982 +++ b/net/core/dev.c
97983 @@ -1683,14 +1683,14 @@ int dev_forward_skb(struct net_device *dev, struct sk_buff *skb)
97984 {
97985 if (skb_shinfo(skb)->tx_flags & SKBTX_DEV_ZEROCOPY) {
97986 if (skb_copy_ubufs(skb, GFP_ATOMIC)) {
97987 - atomic_long_inc(&dev->rx_dropped);
97988 + atomic_long_inc_unchecked(&dev->rx_dropped);
97989 kfree_skb(skb);
97990 return NET_RX_DROP;
97991 }
97992 }
97993
97994 if (unlikely(!is_skb_forwardable(dev, skb))) {
97995 - atomic_long_inc(&dev->rx_dropped);
97996 + atomic_long_inc_unchecked(&dev->rx_dropped);
97997 kfree_skb(skb);
97998 return NET_RX_DROP;
97999 }
98000 @@ -2463,7 +2463,7 @@ static int illegal_highdma(struct net_device *dev, struct sk_buff *skb)
98001
98002 struct dev_gso_cb {
98003 void (*destructor)(struct sk_buff *skb);
98004 -};
98005 +} __no_const;
98006
98007 #define DEV_GSO_CB(skb) ((struct dev_gso_cb *)(skb)->cb)
98008
98009 @@ -2893,7 +2893,7 @@ recursion_alert:
98010 rc = -ENETDOWN;
98011 rcu_read_unlock_bh();
98012
98013 - atomic_long_inc(&dev->tx_dropped);
98014 + atomic_long_inc_unchecked(&dev->tx_dropped);
98015 kfree_skb(skb);
98016 return rc;
98017 out:
98018 @@ -3237,7 +3237,7 @@ enqueue:
98019
98020 local_irq_restore(flags);
98021
98022 - atomic_long_inc(&skb->dev->rx_dropped);
98023 + atomic_long_inc_unchecked(&skb->dev->rx_dropped);
98024 kfree_skb(skb);
98025 return NET_RX_DROP;
98026 }
98027 @@ -3314,7 +3314,7 @@ int netif_rx_ni(struct sk_buff *skb)
98028 }
98029 EXPORT_SYMBOL(netif_rx_ni);
98030
98031 -static void net_tx_action(struct softirq_action *h)
98032 +static __latent_entropy void net_tx_action(void)
98033 {
98034 struct softnet_data *sd = &__get_cpu_var(softnet_data);
98035
98036 @@ -3647,7 +3647,7 @@ ncls:
98037 ret = pt_prev->func(skb, skb->dev, pt_prev, orig_dev);
98038 } else {
98039 drop:
98040 - atomic_long_inc(&skb->dev->rx_dropped);
98041 + atomic_long_inc_unchecked(&skb->dev->rx_dropped);
98042 kfree_skb(skb);
98043 /* Jamal, now you will not able to escape explaining
98044 * me how you were going to use this. :-)
98045 @@ -4366,7 +4366,7 @@ void netif_napi_del(struct napi_struct *napi)
98046 }
98047 EXPORT_SYMBOL(netif_napi_del);
98048
98049 -static void net_rx_action(struct softirq_action *h)
98050 +static __latent_entropy void net_rx_action(void)
98051 {
98052 struct softnet_data *sd = &__get_cpu_var(softnet_data);
98053 unsigned long time_limit = jiffies + 2;
98054 @@ -6366,8 +6366,8 @@ struct rtnl_link_stats64 *dev_get_stats(struct net_device *dev,
98055 } else {
98056 netdev_stats_to_stats64(storage, &dev->stats);
98057 }
98058 - storage->rx_dropped += atomic_long_read(&dev->rx_dropped);
98059 - storage->tx_dropped += atomic_long_read(&dev->tx_dropped);
98060 + storage->rx_dropped += atomic_long_read_unchecked(&dev->rx_dropped);
98061 + storage->tx_dropped += atomic_long_read_unchecked(&dev->tx_dropped);
98062 return storage;
98063 }
98064 EXPORT_SYMBOL(dev_get_stats);
98065 diff --git a/net/core/dev_ioctl.c b/net/core/dev_ioctl.c
98066 index cf999e0..c59a975 100644
98067 --- a/net/core/dev_ioctl.c
98068 +++ b/net/core/dev_ioctl.c
98069 @@ -366,9 +366,13 @@ void dev_load(struct net *net, const char *name)
98070 if (no_module && capable(CAP_NET_ADMIN))
98071 no_module = request_module("netdev-%s", name);
98072 if (no_module && capable(CAP_SYS_MODULE)) {
98073 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
98074 + ___request_module(true, "grsec_modharden_netdev", "%s", name);
98075 +#else
98076 if (!request_module("%s", name))
98077 pr_warn("Loading kernel module for a network device with CAP_SYS_MODULE (deprecated). Use CAP_NET_ADMIN and alias netdev-%s instead.\n",
98078 name);
98079 +#endif
98080 }
98081 }
98082 EXPORT_SYMBOL(dev_load);
98083 diff --git a/net/core/filter.c b/net/core/filter.c
98084 index 4aec7b9..5cf605c 100644
98085 --- a/net/core/filter.c
98086 +++ b/net/core/filter.c
98087 @@ -1121,7 +1121,11 @@ do_pass:
98088 break;
98089
98090 default:
98091 - goto err;
98092 + WARN(1, KERN_ALERT "Unknown sock filter code:%u jt:%u tf:%u k:%u\n",
98093 + fp->code, fp->jt, fp->jf, fp->k);
98094 + kfree(addrs);
98095 + BUG();
98096 + return -EINVAL;
98097 }
98098
98099 insn++;
98100 @@ -1170,7 +1174,7 @@ static int check_load_and_stores(struct sock_filter *filter, int flen)
98101 u16 *masks, memvalid = 0; /* one bit per cell, 16 cells */
98102 int pc, ret = 0;
98103
98104 - BUILD_BUG_ON(BPF_MEMWORDS > 16);
98105 + BUILD_BUG_ON(BPF_MEMWORDS != 16);
98106 masks = kmalloc(flen * sizeof(*masks), GFP_KERNEL);
98107 if (!masks)
98108 return -ENOMEM;
98109 @@ -1605,7 +1609,7 @@ int sk_unattached_filter_create(struct sk_filter **pfp,
98110 if (!fp)
98111 return -ENOMEM;
98112
98113 - memcpy(fp->insns, fprog->filter, fsize);
98114 + memcpy(fp->insns, (void __force_kernel *)fprog->filter, fsize);
98115
98116 atomic_set(&fp->refcnt, 1);
98117 fp->len = fprog->len;
98118 diff --git a/net/core/flow.c b/net/core/flow.c
98119 index a0348fd..6951c76 100644
98120 --- a/net/core/flow.c
98121 +++ b/net/core/flow.c
98122 @@ -65,7 +65,7 @@ static void flow_cache_new_hashrnd(unsigned long arg)
98123 static int flow_entry_valid(struct flow_cache_entry *fle,
98124 struct netns_xfrm *xfrm)
98125 {
98126 - if (atomic_read(&xfrm->flow_cache_genid) != fle->genid)
98127 + if (atomic_read_unchecked(&xfrm->flow_cache_genid) != fle->genid)
98128 return 0;
98129 if (fle->object && !fle->object->ops->check(fle->object))
98130 return 0;
98131 @@ -242,7 +242,7 @@ flow_cache_lookup(struct net *net, const struct flowi *key, u16 family, u8 dir,
98132 hlist_add_head(&fle->u.hlist, &fcp->hash_table[hash]);
98133 fcp->hash_count++;
98134 }
98135 - } else if (likely(fle->genid == atomic_read(&net->xfrm.flow_cache_genid))) {
98136 + } else if (likely(fle->genid == atomic_read_unchecked(&net->xfrm.flow_cache_genid))) {
98137 flo = fle->object;
98138 if (!flo)
98139 goto ret_object;
98140 @@ -263,7 +263,7 @@ nocache:
98141 }
98142 flo = resolver(net, key, family, dir, flo, ctx);
98143 if (fle) {
98144 - fle->genid = atomic_read(&net->xfrm.flow_cache_genid);
98145 + fle->genid = atomic_read_unchecked(&net->xfrm.flow_cache_genid);
98146 if (!IS_ERR(flo))
98147 fle->object = flo;
98148 else
98149 diff --git a/net/core/iovec.c b/net/core/iovec.c
98150 index b618694..192bbba 100644
98151 --- a/net/core/iovec.c
98152 +++ b/net/core/iovec.c
98153 @@ -42,7 +42,7 @@ int verify_iovec(struct msghdr *m, struct iovec *iov, struct sockaddr_storage *a
98154 if (m->msg_namelen) {
98155 if (mode == VERIFY_READ) {
98156 void __user *namep;
98157 - namep = (void __user __force *) m->msg_name;
98158 + namep = (void __force_user *) m->msg_name;
98159 err = move_addr_to_kernel(namep, m->msg_namelen,
98160 address);
98161 if (err < 0)
98162 @@ -55,7 +55,7 @@ int verify_iovec(struct msghdr *m, struct iovec *iov, struct sockaddr_storage *a
98163 }
98164
98165 size = m->msg_iovlen * sizeof(struct iovec);
98166 - if (copy_from_user(iov, (void __user __force *) m->msg_iov, size))
98167 + if (copy_from_user(iov, (void __force_user *) m->msg_iov, size))
98168 return -EFAULT;
98169
98170 m->msg_iov = iov;
98171 diff --git a/net/core/neighbour.c b/net/core/neighbour.c
98172 index 32d872e..487e769 100644
98173 --- a/net/core/neighbour.c
98174 +++ b/net/core/neighbour.c
98175 @@ -2825,7 +2825,7 @@ static int proc_unres_qlen(struct ctl_table *ctl, int write,
98176 void __user *buffer, size_t *lenp, loff_t *ppos)
98177 {
98178 int size, ret;
98179 - struct ctl_table tmp = *ctl;
98180 + ctl_table_no_const tmp = *ctl;
98181
98182 tmp.extra1 = &zero;
98183 tmp.extra2 = &unres_qlen_max;
98184 @@ -2887,7 +2887,7 @@ static int neigh_proc_dointvec_zero_intmax(struct ctl_table *ctl, int write,
98185 void __user *buffer,
98186 size_t *lenp, loff_t *ppos)
98187 {
98188 - struct ctl_table tmp = *ctl;
98189 + ctl_table_no_const tmp = *ctl;
98190 int ret;
98191
98192 tmp.extra1 = &zero;
98193 @@ -3059,11 +3059,12 @@ int neigh_sysctl_register(struct net_device *dev, struct neigh_parms *p,
98194 memset(&t->neigh_vars[NEIGH_VAR_GC_INTERVAL], 0,
98195 sizeof(t->neigh_vars[NEIGH_VAR_GC_INTERVAL]));
98196 } else {
98197 + struct neigh_table *ntable = container_of(p, struct neigh_table, parms);
98198 dev_name_source = "default";
98199 - t->neigh_vars[NEIGH_VAR_GC_INTERVAL].data = (int *)(p + 1);
98200 - t->neigh_vars[NEIGH_VAR_GC_THRESH1].data = (int *)(p + 1) + 1;
98201 - t->neigh_vars[NEIGH_VAR_GC_THRESH2].data = (int *)(p + 1) + 2;
98202 - t->neigh_vars[NEIGH_VAR_GC_THRESH3].data = (int *)(p + 1) + 3;
98203 + t->neigh_vars[NEIGH_VAR_GC_INTERVAL].data = &ntable->gc_interval;
98204 + t->neigh_vars[NEIGH_VAR_GC_THRESH1].data = &ntable->gc_thresh1;
98205 + t->neigh_vars[NEIGH_VAR_GC_THRESH2].data = &ntable->gc_thresh2;
98206 + t->neigh_vars[NEIGH_VAR_GC_THRESH3].data = &ntable->gc_thresh3;
98207 }
98208
98209 if (handler) {
98210 diff --git a/net/core/net-procfs.c b/net/core/net-procfs.c
98211 index 2bf8329..2eb1423 100644
98212 --- a/net/core/net-procfs.c
98213 +++ b/net/core/net-procfs.c
98214 @@ -79,7 +79,13 @@ static void dev_seq_printf_stats(struct seq_file *seq, struct net_device *dev)
98215 struct rtnl_link_stats64 temp;
98216 const struct rtnl_link_stats64 *stats = dev_get_stats(dev, &temp);
98217
98218 - seq_printf(seq, "%6s: %7llu %7llu %4llu %4llu %4llu %5llu %10llu %9llu "
98219 + if (gr_proc_is_restricted())
98220 + seq_printf(seq, "%6s: %7llu %7llu %4llu %4llu %4llu %5llu %10llu %9llu "
98221 + "%8llu %7llu %4llu %4llu %4llu %5llu %7llu %10llu\n",
98222 + dev->name, 0ULL, 0ULL, 0ULL, 0ULL, 0ULL, 0ULL, 0ULL, 0ULL, 0ULL, 0ULL,
98223 + 0ULL, 0ULL, 0ULL, 0ULL, 0ULL, 0ULL);
98224 + else
98225 + seq_printf(seq, "%6s: %7llu %7llu %4llu %4llu %4llu %5llu %10llu %9llu "
98226 "%8llu %7llu %4llu %4llu %4llu %5llu %7llu %10llu\n",
98227 dev->name, stats->rx_bytes, stats->rx_packets,
98228 stats->rx_errors,
98229 @@ -166,7 +172,7 @@ static int softnet_seq_show(struct seq_file *seq, void *v)
98230 return 0;
98231 }
98232
98233 -static const struct seq_operations dev_seq_ops = {
98234 +const struct seq_operations dev_seq_ops = {
98235 .start = dev_seq_start,
98236 .next = dev_seq_next,
98237 .stop = dev_seq_stop,
98238 @@ -196,7 +202,7 @@ static const struct seq_operations softnet_seq_ops = {
98239
98240 static int softnet_seq_open(struct inode *inode, struct file *file)
98241 {
98242 - return seq_open(file, &softnet_seq_ops);
98243 + return seq_open_restrict(file, &softnet_seq_ops);
98244 }
98245
98246 static const struct file_operations softnet_seq_fops = {
98247 @@ -283,8 +289,13 @@ static int ptype_seq_show(struct seq_file *seq, void *v)
98248 else
98249 seq_printf(seq, "%04x", ntohs(pt->type));
98250
98251 +#ifdef CONFIG_GRKERNSEC_HIDESYM
98252 + seq_printf(seq, " %-8s %pf\n",
98253 + pt->dev ? pt->dev->name : "", NULL);
98254 +#else
98255 seq_printf(seq, " %-8s %pf\n",
98256 pt->dev ? pt->dev->name : "", pt->func);
98257 +#endif
98258 }
98259
98260 return 0;
98261 diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
98262 index 1cac29e..fb482f3 100644
98263 --- a/net/core/net-sysfs.c
98264 +++ b/net/core/net-sysfs.c
98265 @@ -259,7 +259,7 @@ static ssize_t carrier_changes_show(struct device *dev,
98266 {
98267 struct net_device *netdev = to_net_dev(dev);
98268 return sprintf(buf, fmt_dec,
98269 - atomic_read(&netdev->carrier_changes));
98270 + atomic_read_unchecked(&netdev->carrier_changes));
98271 }
98272 static DEVICE_ATTR_RO(carrier_changes);
98273
98274 diff --git a/net/core/net_namespace.c b/net/core/net_namespace.c
98275 index 7c8ffd9..0cb3687 100644
98276 --- a/net/core/net_namespace.c
98277 +++ b/net/core/net_namespace.c
98278 @@ -443,7 +443,7 @@ static int __register_pernet_operations(struct list_head *list,
98279 int error;
98280 LIST_HEAD(net_exit_list);
98281
98282 - list_add_tail(&ops->list, list);
98283 + pax_list_add_tail((struct list_head *)&ops->list, list);
98284 if (ops->init || (ops->id && ops->size)) {
98285 for_each_net(net) {
98286 error = ops_init(ops, net);
98287 @@ -456,7 +456,7 @@ static int __register_pernet_operations(struct list_head *list,
98288
98289 out_undo:
98290 /* If I have an error cleanup all namespaces I initialized */
98291 - list_del(&ops->list);
98292 + pax_list_del((struct list_head *)&ops->list);
98293 ops_exit_list(ops, &net_exit_list);
98294 ops_free_list(ops, &net_exit_list);
98295 return error;
98296 @@ -467,7 +467,7 @@ static void __unregister_pernet_operations(struct pernet_operations *ops)
98297 struct net *net;
98298 LIST_HEAD(net_exit_list);
98299
98300 - list_del(&ops->list);
98301 + pax_list_del((struct list_head *)&ops->list);
98302 for_each_net(net)
98303 list_add_tail(&net->exit_list, &net_exit_list);
98304 ops_exit_list(ops, &net_exit_list);
98305 @@ -601,7 +601,7 @@ int register_pernet_device(struct pernet_operations *ops)
98306 mutex_lock(&net_mutex);
98307 error = register_pernet_operations(&pernet_list, ops);
98308 if (!error && (first_device == &pernet_list))
98309 - first_device = &ops->list;
98310 + first_device = (struct list_head *)&ops->list;
98311 mutex_unlock(&net_mutex);
98312 return error;
98313 }
98314 diff --git a/net/core/netpoll.c b/net/core/netpoll.c
98315 index e33937f..b2b4981 100644
98316 --- a/net/core/netpoll.c
98317 +++ b/net/core/netpoll.c
98318 @@ -382,7 +382,7 @@ void netpoll_send_udp(struct netpoll *np, const char *msg, int len)
98319 struct udphdr *udph;
98320 struct iphdr *iph;
98321 struct ethhdr *eth;
98322 - static atomic_t ip_ident;
98323 + static atomic_unchecked_t ip_ident;
98324 struct ipv6hdr *ip6h;
98325
98326 udp_len = len + sizeof(*udph);
98327 @@ -453,7 +453,7 @@ void netpoll_send_udp(struct netpoll *np, const char *msg, int len)
98328 put_unaligned(0x45, (unsigned char *)iph);
98329 iph->tos = 0;
98330 put_unaligned(htons(ip_len), &(iph->tot_len));
98331 - iph->id = htons(atomic_inc_return(&ip_ident));
98332 + iph->id = htons(atomic_inc_return_unchecked(&ip_ident));
98333 iph->frag_off = 0;
98334 iph->ttl = 64;
98335 iph->protocol = IPPROTO_UDP;
98336 diff --git a/net/core/pktgen.c b/net/core/pktgen.c
98337 index 0304f98..ddfead6 100644
98338 --- a/net/core/pktgen.c
98339 +++ b/net/core/pktgen.c
98340 @@ -3725,7 +3725,7 @@ static int __net_init pg_net_init(struct net *net)
98341 pn->net = net;
98342 INIT_LIST_HEAD(&pn->pktgen_threads);
98343 pn->pktgen_exiting = false;
98344 - pn->proc_dir = proc_mkdir(PG_PROC_DIR, pn->net->proc_net);
98345 + pn->proc_dir = proc_mkdir_restrict(PG_PROC_DIR, pn->net->proc_net);
98346 if (!pn->proc_dir) {
98347 pr_warn("cannot create /proc/net/%s\n", PG_PROC_DIR);
98348 return -ENODEV;
98349 diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
98350 index 2d8d8fc..b1bcd50 100644
98351 --- a/net/core/rtnetlink.c
98352 +++ b/net/core/rtnetlink.c
98353 @@ -58,7 +58,7 @@ struct rtnl_link {
98354 rtnl_doit_func doit;
98355 rtnl_dumpit_func dumpit;
98356 rtnl_calcit_func calcit;
98357 -};
98358 +} __no_const;
98359
98360 static DEFINE_MUTEX(rtnl_mutex);
98361
98362 @@ -299,10 +299,13 @@ int __rtnl_link_register(struct rtnl_link_ops *ops)
98363 if (rtnl_link_ops_get(ops->kind))
98364 return -EEXIST;
98365
98366 - if (!ops->dellink)
98367 - ops->dellink = unregister_netdevice_queue;
98368 + if (!ops->dellink) {
98369 + pax_open_kernel();
98370 + *(void **)&ops->dellink = unregister_netdevice_queue;
98371 + pax_close_kernel();
98372 + }
98373
98374 - list_add_tail(&ops->list, &link_ops);
98375 + pax_list_add_tail((struct list_head *)&ops->list, &link_ops);
98376 return 0;
98377 }
98378 EXPORT_SYMBOL_GPL(__rtnl_link_register);
98379 @@ -349,7 +352,7 @@ void __rtnl_link_unregister(struct rtnl_link_ops *ops)
98380 for_each_net(net) {
98381 __rtnl_kill_links(net, ops);
98382 }
98383 - list_del(&ops->list);
98384 + pax_list_del((struct list_head *)&ops->list);
98385 }
98386 EXPORT_SYMBOL_GPL(__rtnl_link_unregister);
98387
98388 @@ -1008,7 +1011,7 @@ static int rtnl_fill_ifinfo(struct sk_buff *skb, struct net_device *dev,
98389 (dev->ifalias &&
98390 nla_put_string(skb, IFLA_IFALIAS, dev->ifalias)) ||
98391 nla_put_u32(skb, IFLA_CARRIER_CHANGES,
98392 - atomic_read(&dev->carrier_changes)))
98393 + atomic_read_unchecked(&dev->carrier_changes)))
98394 goto nla_put_failure;
98395
98396 if (1) {
98397 diff --git a/net/core/scm.c b/net/core/scm.c
98398 index b442e7e..6f5b5a2 100644
98399 --- a/net/core/scm.c
98400 +++ b/net/core/scm.c
98401 @@ -210,7 +210,7 @@ EXPORT_SYMBOL(__scm_send);
98402 int put_cmsg(struct msghdr * msg, int level, int type, int len, void *data)
98403 {
98404 struct cmsghdr __user *cm
98405 - = (__force struct cmsghdr __user *)msg->msg_control;
98406 + = (struct cmsghdr __force_user *)msg->msg_control;
98407 struct cmsghdr cmhdr;
98408 int cmlen = CMSG_LEN(len);
98409 int err;
98410 @@ -233,7 +233,7 @@ int put_cmsg(struct msghdr * msg, int level, int type, int len, void *data)
98411 err = -EFAULT;
98412 if (copy_to_user(cm, &cmhdr, sizeof cmhdr))
98413 goto out;
98414 - if (copy_to_user(CMSG_DATA(cm), data, cmlen - sizeof(struct cmsghdr)))
98415 + if (copy_to_user((void __force_user *)CMSG_DATA((void __force_kernel *)cm), data, cmlen - sizeof(struct cmsghdr)))
98416 goto out;
98417 cmlen = CMSG_SPACE(len);
98418 if (msg->msg_controllen < cmlen)
98419 @@ -249,7 +249,7 @@ EXPORT_SYMBOL(put_cmsg);
98420 void scm_detach_fds(struct msghdr *msg, struct scm_cookie *scm)
98421 {
98422 struct cmsghdr __user *cm
98423 - = (__force struct cmsghdr __user*)msg->msg_control;
98424 + = (struct cmsghdr __force_user *)msg->msg_control;
98425
98426 int fdmax = 0;
98427 int fdnum = scm->fp->count;
98428 @@ -269,7 +269,7 @@ void scm_detach_fds(struct msghdr *msg, struct scm_cookie *scm)
98429 if (fdnum < fdmax)
98430 fdmax = fdnum;
98431
98432 - for (i=0, cmfptr=(__force int __user *)CMSG_DATA(cm); i<fdmax;
98433 + for (i=0, cmfptr=(int __force_user *)CMSG_DATA((void __force_kernel *)cm); i<fdmax;
98434 i++, cmfptr++)
98435 {
98436 struct socket *sock;
98437 diff --git a/net/core/skbuff.c b/net/core/skbuff.c
98438 index 8383b2b..6397efb 100644
98439 --- a/net/core/skbuff.c
98440 +++ b/net/core/skbuff.c
98441 @@ -2003,7 +2003,7 @@ EXPORT_SYMBOL(__skb_checksum);
98442 __wsum skb_checksum(const struct sk_buff *skb, int offset,
98443 int len, __wsum csum)
98444 {
98445 - const struct skb_checksum_ops ops = {
98446 + static const struct skb_checksum_ops ops = {
98447 .update = csum_partial_ext,
98448 .combine = csum_block_add_ext,
98449 };
98450 @@ -3220,13 +3220,15 @@ void __init skb_init(void)
98451 skbuff_head_cache = kmem_cache_create("skbuff_head_cache",
98452 sizeof(struct sk_buff),
98453 0,
98454 - SLAB_HWCACHE_ALIGN|SLAB_PANIC,
98455 + SLAB_HWCACHE_ALIGN|SLAB_PANIC|
98456 + SLAB_NO_SANITIZE,
98457 NULL);
98458 skbuff_fclone_cache = kmem_cache_create("skbuff_fclone_cache",
98459 (2*sizeof(struct sk_buff)) +
98460 sizeof(atomic_t),
98461 0,
98462 - SLAB_HWCACHE_ALIGN|SLAB_PANIC,
98463 + SLAB_HWCACHE_ALIGN|SLAB_PANIC|
98464 + SLAB_NO_SANITIZE,
98465 NULL);
98466 }
98467
98468 diff --git a/net/core/sock.c b/net/core/sock.c
98469 index 664ee42..aaf9e6e 100644
98470 --- a/net/core/sock.c
98471 +++ b/net/core/sock.c
98472 @@ -442,7 +442,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
98473 struct sk_buff_head *list = &sk->sk_receive_queue;
98474
98475 if (atomic_read(&sk->sk_rmem_alloc) >= sk->sk_rcvbuf) {
98476 - atomic_inc(&sk->sk_drops);
98477 + atomic_inc_unchecked(&sk->sk_drops);
98478 trace_sock_rcvqueue_full(sk, skb);
98479 return -ENOMEM;
98480 }
98481 @@ -452,7 +452,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
98482 return err;
98483
98484 if (!sk_rmem_schedule(sk, skb, skb->truesize)) {
98485 - atomic_inc(&sk->sk_drops);
98486 + atomic_inc_unchecked(&sk->sk_drops);
98487 return -ENOBUFS;
98488 }
98489
98490 @@ -472,7 +472,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
98491 skb_dst_force(skb);
98492
98493 spin_lock_irqsave(&list->lock, flags);
98494 - skb->dropcount = atomic_read(&sk->sk_drops);
98495 + skb->dropcount = atomic_read_unchecked(&sk->sk_drops);
98496 __skb_queue_tail(list, skb);
98497 spin_unlock_irqrestore(&list->lock, flags);
98498
98499 @@ -492,7 +492,7 @@ int sk_receive_skb(struct sock *sk, struct sk_buff *skb, const int nested)
98500 skb->dev = NULL;
98501
98502 if (sk_rcvqueues_full(sk, skb, sk->sk_rcvbuf)) {
98503 - atomic_inc(&sk->sk_drops);
98504 + atomic_inc_unchecked(&sk->sk_drops);
98505 goto discard_and_relse;
98506 }
98507 if (nested)
98508 @@ -510,7 +510,7 @@ int sk_receive_skb(struct sock *sk, struct sk_buff *skb, const int nested)
98509 mutex_release(&sk->sk_lock.dep_map, 1, _RET_IP_);
98510 } else if (sk_add_backlog(sk, skb, sk->sk_rcvbuf)) {
98511 bh_unlock_sock(sk);
98512 - atomic_inc(&sk->sk_drops);
98513 + atomic_inc_unchecked(&sk->sk_drops);
98514 goto discard_and_relse;
98515 }
98516
98517 @@ -998,12 +998,12 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
98518 struct timeval tm;
98519 } v;
98520
98521 - int lv = sizeof(int);
98522 - int len;
98523 + unsigned int lv = sizeof(int);
98524 + unsigned int len;
98525
98526 if (get_user(len, optlen))
98527 return -EFAULT;
98528 - if (len < 0)
98529 + if (len > INT_MAX)
98530 return -EINVAL;
98531
98532 memset(&v, 0, sizeof(v));
98533 @@ -1155,11 +1155,11 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
98534
98535 case SO_PEERNAME:
98536 {
98537 - char address[128];
98538 + char address[_K_SS_MAXSIZE];
98539
98540 if (sock->ops->getname(sock, (struct sockaddr *)address, &lv, 2))
98541 return -ENOTCONN;
98542 - if (lv < len)
98543 + if (lv < len || sizeof address < len)
98544 return -EINVAL;
98545 if (copy_to_user(optval, address, len))
98546 return -EFAULT;
98547 @@ -1240,7 +1240,7 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
98548
98549 if (len > lv)
98550 len = lv;
98551 - if (copy_to_user(optval, &v, len))
98552 + if (len > sizeof(v) || copy_to_user(optval, &v, len))
98553 return -EFAULT;
98554 lenout:
98555 if (put_user(len, optlen))
98556 @@ -2375,7 +2375,7 @@ void sock_init_data(struct socket *sock, struct sock *sk)
98557 */
98558 smp_wmb();
98559 atomic_set(&sk->sk_refcnt, 1);
98560 - atomic_set(&sk->sk_drops, 0);
98561 + atomic_set_unchecked(&sk->sk_drops, 0);
98562 }
98563 EXPORT_SYMBOL(sock_init_data);
98564
98565 @@ -2503,6 +2503,7 @@ void sock_enable_timestamp(struct sock *sk, int flag)
98566 int sock_recv_errqueue(struct sock *sk, struct msghdr *msg, int len,
98567 int level, int type)
98568 {
98569 + struct sock_extended_err ee;
98570 struct sock_exterr_skb *serr;
98571 struct sk_buff *skb, *skb2;
98572 int copied, err;
98573 @@ -2524,7 +2525,8 @@ int sock_recv_errqueue(struct sock *sk, struct msghdr *msg, int len,
98574 sock_recv_timestamp(msg, sk, skb);
98575
98576 serr = SKB_EXT_ERR(skb);
98577 - put_cmsg(msg, level, type, sizeof(serr->ee), &serr->ee);
98578 + ee = serr->ee;
98579 + put_cmsg(msg, level, type, sizeof ee, &ee);
98580
98581 msg->msg_flags |= MSG_ERRQUEUE;
98582 err = copied;
98583 diff --git a/net/core/sock_diag.c b/net/core/sock_diag.c
98584 index a4216a4..1c07687 100644
98585 --- a/net/core/sock_diag.c
98586 +++ b/net/core/sock_diag.c
98587 @@ -9,26 +9,33 @@
98588 #include <linux/inet_diag.h>
98589 #include <linux/sock_diag.h>
98590
98591 -static const struct sock_diag_handler *sock_diag_handlers[AF_MAX];
98592 +static const struct sock_diag_handler *sock_diag_handlers[AF_MAX] __read_only;
98593 static int (*inet_rcv_compat)(struct sk_buff *skb, struct nlmsghdr *nlh);
98594 static DEFINE_MUTEX(sock_diag_table_mutex);
98595
98596 int sock_diag_check_cookie(void *sk, __u32 *cookie)
98597 {
98598 +#ifndef CONFIG_GRKERNSEC_HIDESYM
98599 if ((cookie[0] != INET_DIAG_NOCOOKIE ||
98600 cookie[1] != INET_DIAG_NOCOOKIE) &&
98601 ((u32)(unsigned long)sk != cookie[0] ||
98602 (u32)((((unsigned long)sk) >> 31) >> 1) != cookie[1]))
98603 return -ESTALE;
98604 else
98605 +#endif
98606 return 0;
98607 }
98608 EXPORT_SYMBOL_GPL(sock_diag_check_cookie);
98609
98610 void sock_diag_save_cookie(void *sk, __u32 *cookie)
98611 {
98612 +#ifdef CONFIG_GRKERNSEC_HIDESYM
98613 + cookie[0] = 0;
98614 + cookie[1] = 0;
98615 +#else
98616 cookie[0] = (u32)(unsigned long)sk;
98617 cookie[1] = (u32)(((unsigned long)sk >> 31) >> 1);
98618 +#endif
98619 }
98620 EXPORT_SYMBOL_GPL(sock_diag_save_cookie);
98621
98622 @@ -110,8 +117,11 @@ int sock_diag_register(const struct sock_diag_handler *hndl)
98623 mutex_lock(&sock_diag_table_mutex);
98624 if (sock_diag_handlers[hndl->family])
98625 err = -EBUSY;
98626 - else
98627 + else {
98628 + pax_open_kernel();
98629 sock_diag_handlers[hndl->family] = hndl;
98630 + pax_close_kernel();
98631 + }
98632 mutex_unlock(&sock_diag_table_mutex);
98633
98634 return err;
98635 @@ -127,7 +137,9 @@ void sock_diag_unregister(const struct sock_diag_handler *hnld)
98636
98637 mutex_lock(&sock_diag_table_mutex);
98638 BUG_ON(sock_diag_handlers[family] != hnld);
98639 + pax_open_kernel();
98640 sock_diag_handlers[family] = NULL;
98641 + pax_close_kernel();
98642 mutex_unlock(&sock_diag_table_mutex);
98643 }
98644 EXPORT_SYMBOL_GPL(sock_diag_unregister);
98645 diff --git a/net/core/sysctl_net_core.c b/net/core/sysctl_net_core.c
98646 index cf9cd13..8b56af3 100644
98647 --- a/net/core/sysctl_net_core.c
98648 +++ b/net/core/sysctl_net_core.c
98649 @@ -32,7 +32,7 @@ static int rps_sock_flow_sysctl(struct ctl_table *table, int write,
98650 {
98651 unsigned int orig_size, size;
98652 int ret, i;
98653 - struct ctl_table tmp = {
98654 + ctl_table_no_const tmp = {
98655 .data = &size,
98656 .maxlen = sizeof(size),
98657 .mode = table->mode
98658 @@ -200,7 +200,7 @@ static int set_default_qdisc(struct ctl_table *table, int write,
98659 void __user *buffer, size_t *lenp, loff_t *ppos)
98660 {
98661 char id[IFNAMSIZ];
98662 - struct ctl_table tbl = {
98663 + ctl_table_no_const tbl = {
98664 .data = id,
98665 .maxlen = IFNAMSIZ,
98666 };
98667 @@ -379,13 +379,12 @@ static struct ctl_table netns_core_table[] = {
98668
98669 static __net_init int sysctl_core_net_init(struct net *net)
98670 {
98671 - struct ctl_table *tbl;
98672 + ctl_table_no_const *tbl = NULL;
98673
98674 net->core.sysctl_somaxconn = SOMAXCONN;
98675
98676 - tbl = netns_core_table;
98677 if (!net_eq(net, &init_net)) {
98678 - tbl = kmemdup(tbl, sizeof(netns_core_table), GFP_KERNEL);
98679 + tbl = kmemdup(netns_core_table, sizeof(netns_core_table), GFP_KERNEL);
98680 if (tbl == NULL)
98681 goto err_dup;
98682
98683 @@ -395,17 +394,16 @@ static __net_init int sysctl_core_net_init(struct net *net)
98684 if (net->user_ns != &init_user_ns) {
98685 tbl[0].procname = NULL;
98686 }
98687 - }
98688 -
98689 - net->core.sysctl_hdr = register_net_sysctl(net, "net/core", tbl);
98690 + net->core.sysctl_hdr = register_net_sysctl(net, "net/core", tbl);
98691 + } else
98692 + net->core.sysctl_hdr = register_net_sysctl(net, "net/core", netns_core_table);
98693 if (net->core.sysctl_hdr == NULL)
98694 goto err_reg;
98695
98696 return 0;
98697
98698 err_reg:
98699 - if (tbl != netns_core_table)
98700 - kfree(tbl);
98701 + kfree(tbl);
98702 err_dup:
98703 return -ENOMEM;
98704 }
98705 @@ -420,7 +418,7 @@ static __net_exit void sysctl_core_net_exit(struct net *net)
98706 kfree(tbl);
98707 }
98708
98709 -static __net_initdata struct pernet_operations sysctl_core_ops = {
98710 +static __net_initconst struct pernet_operations sysctl_core_ops = {
98711 .init = sysctl_core_net_init,
98712 .exit = sysctl_core_net_exit,
98713 };
98714 diff --git a/net/decnet/af_decnet.c b/net/decnet/af_decnet.c
98715 index 4c04848..f575934 100644
98716 --- a/net/decnet/af_decnet.c
98717 +++ b/net/decnet/af_decnet.c
98718 @@ -465,6 +465,7 @@ static struct proto dn_proto = {
98719 .sysctl_rmem = sysctl_decnet_rmem,
98720 .max_header = DN_MAX_NSP_DATA_HEADER + 64,
98721 .obj_size = sizeof(struct dn_sock),
98722 + .slab_flags = SLAB_USERCOPY,
98723 };
98724
98725 static struct sock *dn_alloc_sock(struct net *net, struct socket *sock, gfp_t gfp)
98726 diff --git a/net/decnet/dn_dev.c b/net/decnet/dn_dev.c
98727 index 3b726f3..1af6368 100644
98728 --- a/net/decnet/dn_dev.c
98729 +++ b/net/decnet/dn_dev.c
98730 @@ -200,7 +200,7 @@ static struct dn_dev_sysctl_table {
98731 .extra1 = &min_t3,
98732 .extra2 = &max_t3
98733 },
98734 - {0}
98735 + { }
98736 },
98737 };
98738
98739 diff --git a/net/decnet/sysctl_net_decnet.c b/net/decnet/sysctl_net_decnet.c
98740 index 5325b54..a0d4d69 100644
98741 --- a/net/decnet/sysctl_net_decnet.c
98742 +++ b/net/decnet/sysctl_net_decnet.c
98743 @@ -174,7 +174,7 @@ static int dn_node_address_handler(struct ctl_table *table, int write,
98744
98745 if (len > *lenp) len = *lenp;
98746
98747 - if (copy_to_user(buffer, addr, len))
98748 + if (len > sizeof addr || copy_to_user(buffer, addr, len))
98749 return -EFAULT;
98750
98751 *lenp = len;
98752 @@ -237,7 +237,7 @@ static int dn_def_dev_handler(struct ctl_table *table, int write,
98753
98754 if (len > *lenp) len = *lenp;
98755
98756 - if (copy_to_user(buffer, devname, len))
98757 + if (len > sizeof devname || copy_to_user(buffer, devname, len))
98758 return -EFAULT;
98759
98760 *lenp = len;
98761 diff --git a/net/ieee802154/reassembly.c b/net/ieee802154/reassembly.c
98762 index ef2d543..5b9b73f 100644
98763 --- a/net/ieee802154/reassembly.c
98764 +++ b/net/ieee802154/reassembly.c
98765 @@ -434,12 +434,11 @@ static struct ctl_table lowpan_frags_ctl_table[] = {
98766
98767 static int __net_init lowpan_frags_ns_sysctl_register(struct net *net)
98768 {
98769 - struct ctl_table *table;
98770 + ctl_table_no_const *table = NULL;
98771 struct ctl_table_header *hdr;
98772
98773 - table = lowpan_frags_ns_ctl_table;
98774 if (!net_eq(net, &init_net)) {
98775 - table = kmemdup(table, sizeof(lowpan_frags_ns_ctl_table),
98776 + table = kmemdup(lowpan_frags_ns_ctl_table, sizeof(lowpan_frags_ns_ctl_table),
98777 GFP_KERNEL);
98778 if (table == NULL)
98779 goto err_alloc;
98780 @@ -452,9 +451,9 @@ static int __net_init lowpan_frags_ns_sysctl_register(struct net *net)
98781 /* Don't export sysctls to unprivileged users */
98782 if (net->user_ns != &init_user_ns)
98783 table[0].procname = NULL;
98784 - }
98785 -
98786 - hdr = register_net_sysctl(net, "net/ieee802154/6lowpan", table);
98787 + hdr = register_net_sysctl(net, "net/ieee802154/6lowpan", table);
98788 + } else
98789 + hdr = register_net_sysctl(net, "net/ieee802154/6lowpan", lowpan_frags_ns_ctl_table);
98790 if (hdr == NULL)
98791 goto err_reg;
98792
98793 @@ -462,8 +461,7 @@ static int __net_init lowpan_frags_ns_sysctl_register(struct net *net)
98794 return 0;
98795
98796 err_reg:
98797 - if (!net_eq(net, &init_net))
98798 - kfree(table);
98799 + kfree(table);
98800 err_alloc:
98801 return -ENOMEM;
98802 }
98803 diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
98804 index 6d6dd34..e5c9bec 100644
98805 --- a/net/ipv4/af_inet.c
98806 +++ b/net/ipv4/af_inet.c
98807 @@ -1736,13 +1736,9 @@ static int __init inet_init(void)
98808
98809 BUILD_BUG_ON(sizeof(struct inet_skb_parm) > FIELD_SIZEOF(struct sk_buff, cb));
98810
98811 - sysctl_local_reserved_ports = kzalloc(65536 / 8, GFP_KERNEL);
98812 - if (!sysctl_local_reserved_ports)
98813 - goto out;
98814 -
98815 rc = proto_register(&tcp_prot, 1);
98816 if (rc)
98817 - goto out_free_reserved_ports;
98818 + goto out;
98819
98820 rc = proto_register(&udp_prot, 1);
98821 if (rc)
98822 @@ -1852,8 +1848,6 @@ out_unregister_udp_proto:
98823 proto_unregister(&udp_prot);
98824 out_unregister_tcp_proto:
98825 proto_unregister(&tcp_prot);
98826 -out_free_reserved_ports:
98827 - kfree(sysctl_local_reserved_ports);
98828 goto out;
98829 }
98830
98831 diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c
98832 index bdbf68b..deb4759 100644
98833 --- a/net/ipv4/devinet.c
98834 +++ b/net/ipv4/devinet.c
98835 @@ -1543,7 +1543,7 @@ static int inet_dump_ifaddr(struct sk_buff *skb, struct netlink_callback *cb)
98836 idx = 0;
98837 head = &net->dev_index_head[h];
98838 rcu_read_lock();
98839 - cb->seq = atomic_read(&net->ipv4.dev_addr_genid) ^
98840 + cb->seq = atomic_read_unchecked(&net->ipv4.dev_addr_genid) ^
98841 net->dev_base_seq;
98842 hlist_for_each_entry_rcu(dev, head, index_hlist) {
98843 if (idx < s_idx)
98844 @@ -1861,7 +1861,7 @@ static int inet_netconf_dump_devconf(struct sk_buff *skb,
98845 idx = 0;
98846 head = &net->dev_index_head[h];
98847 rcu_read_lock();
98848 - cb->seq = atomic_read(&net->ipv4.dev_addr_genid) ^
98849 + cb->seq = atomic_read_unchecked(&net->ipv4.dev_addr_genid) ^
98850 net->dev_base_seq;
98851 hlist_for_each_entry_rcu(dev, head, index_hlist) {
98852 if (idx < s_idx)
98853 @@ -2096,7 +2096,7 @@ static int ipv4_doint_and_flush(struct ctl_table *ctl, int write,
98854 #define DEVINET_SYSCTL_FLUSHING_ENTRY(attr, name) \
98855 DEVINET_SYSCTL_COMPLEX_ENTRY(attr, name, ipv4_doint_and_flush)
98856
98857 -static struct devinet_sysctl_table {
98858 +static const struct devinet_sysctl_table {
98859 struct ctl_table_header *sysctl_header;
98860 struct ctl_table devinet_vars[__IPV4_DEVCONF_MAX];
98861 } devinet_sysctl = {
98862 @@ -2218,7 +2218,7 @@ static __net_init int devinet_init_net(struct net *net)
98863 int err;
98864 struct ipv4_devconf *all, *dflt;
98865 #ifdef CONFIG_SYSCTL
98866 - struct ctl_table *tbl = ctl_forward_entry;
98867 + ctl_table_no_const *tbl = NULL;
98868 struct ctl_table_header *forw_hdr;
98869 #endif
98870
98871 @@ -2236,7 +2236,7 @@ static __net_init int devinet_init_net(struct net *net)
98872 goto err_alloc_dflt;
98873
98874 #ifdef CONFIG_SYSCTL
98875 - tbl = kmemdup(tbl, sizeof(ctl_forward_entry), GFP_KERNEL);
98876 + tbl = kmemdup(ctl_forward_entry, sizeof(ctl_forward_entry), GFP_KERNEL);
98877 if (tbl == NULL)
98878 goto err_alloc_ctl;
98879
98880 @@ -2256,7 +2256,10 @@ static __net_init int devinet_init_net(struct net *net)
98881 goto err_reg_dflt;
98882
98883 err = -ENOMEM;
98884 - forw_hdr = register_net_sysctl(net, "net/ipv4", tbl);
98885 + if (!net_eq(net, &init_net))
98886 + forw_hdr = register_net_sysctl(net, "net/ipv4", tbl);
98887 + else
98888 + forw_hdr = register_net_sysctl(net, "net/ipv4", ctl_forward_entry);
98889 if (forw_hdr == NULL)
98890 goto err_reg_ctl;
98891 net->ipv4.forw_hdr = forw_hdr;
98892 @@ -2272,8 +2275,7 @@ err_reg_ctl:
98893 err_reg_dflt:
98894 __devinet_sysctl_unregister(all);
98895 err_reg_all:
98896 - if (tbl != ctl_forward_entry)
98897 - kfree(tbl);
98898 + kfree(tbl);
98899 err_alloc_ctl:
98900 #endif
98901 if (dflt != &ipv4_devconf_dflt)
98902 diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c
98903 index 255aa99..45c78f8 100644
98904 --- a/net/ipv4/fib_frontend.c
98905 +++ b/net/ipv4/fib_frontend.c
98906 @@ -1015,12 +1015,12 @@ static int fib_inetaddr_event(struct notifier_block *this, unsigned long event,
98907 #ifdef CONFIG_IP_ROUTE_MULTIPATH
98908 fib_sync_up(dev);
98909 #endif
98910 - atomic_inc(&net->ipv4.dev_addr_genid);
98911 + atomic_inc_unchecked(&net->ipv4.dev_addr_genid);
98912 rt_cache_flush(dev_net(dev));
98913 break;
98914 case NETDEV_DOWN:
98915 fib_del_ifaddr(ifa, NULL);
98916 - atomic_inc(&net->ipv4.dev_addr_genid);
98917 + atomic_inc_unchecked(&net->ipv4.dev_addr_genid);
98918 if (ifa->ifa_dev->ifa_list == NULL) {
98919 /* Last address was deleted from this interface.
98920 * Disable IP.
98921 @@ -1058,7 +1058,7 @@ static int fib_netdev_event(struct notifier_block *this, unsigned long event, vo
98922 #ifdef CONFIG_IP_ROUTE_MULTIPATH
98923 fib_sync_up(dev);
98924 #endif
98925 - atomic_inc(&net->ipv4.dev_addr_genid);
98926 + atomic_inc_unchecked(&net->ipv4.dev_addr_genid);
98927 rt_cache_flush(net);
98928 break;
98929 case NETDEV_DOWN:
98930 diff --git a/net/ipv4/fib_semantics.c b/net/ipv4/fib_semantics.c
98931 index b10cd43a..22327f9 100644
98932 --- a/net/ipv4/fib_semantics.c
98933 +++ b/net/ipv4/fib_semantics.c
98934 @@ -768,7 +768,7 @@ __be32 fib_info_update_nh_saddr(struct net *net, struct fib_nh *nh)
98935 nh->nh_saddr = inet_select_addr(nh->nh_dev,
98936 nh->nh_gw,
98937 nh->nh_parent->fib_scope);
98938 - nh->nh_saddr_genid = atomic_read(&net->ipv4.dev_addr_genid);
98939 + nh->nh_saddr_genid = atomic_read_unchecked(&net->ipv4.dev_addr_genid);
98940
98941 return nh->nh_saddr;
98942 }
98943 diff --git a/net/ipv4/inet_connection_sock.c b/net/ipv4/inet_connection_sock.c
98944 index a56b8e6..5be2a30 100644
98945 --- a/net/ipv4/inet_connection_sock.c
98946 +++ b/net/ipv4/inet_connection_sock.c
98947 @@ -29,7 +29,7 @@ const char inet_csk_timer_bug_msg[] = "inet_csk BUG: unknown timer value\n";
98948 EXPORT_SYMBOL(inet_csk_timer_bug_msg);
98949 #endif
98950
98951 -unsigned long *sysctl_local_reserved_ports;
98952 +unsigned long sysctl_local_reserved_ports[65536 / 8 / sizeof(unsigned long)];
98953 EXPORT_SYMBOL(sysctl_local_reserved_ports);
98954
98955 void inet_get_local_port_range(struct net *net, int *low, int *high)
98956 diff --git a/net/ipv4/inet_hashtables.c b/net/ipv4/inet_hashtables.c
98957 index 8b9cf27..0d8d592 100644
98958 --- a/net/ipv4/inet_hashtables.c
98959 +++ b/net/ipv4/inet_hashtables.c
98960 @@ -18,6 +18,7 @@
98961 #include <linux/sched.h>
98962 #include <linux/slab.h>
98963 #include <linux/wait.h>
98964 +#include <linux/security.h>
98965
98966 #include <net/inet_connection_sock.h>
98967 #include <net/inet_hashtables.h>
98968 @@ -49,6 +50,8 @@ static unsigned int inet_sk_ehashfn(const struct sock *sk)
98969 return inet_ehashfn(net, laddr, lport, faddr, fport);
98970 }
98971
98972 +extern void gr_update_task_in_ip_table(struct task_struct *task, const struct inet_sock *inet);
98973 +
98974 /*
98975 * Allocate and initialize a new local port bind bucket.
98976 * The bindhash mutex for snum's hash chain must be held here.
98977 @@ -554,6 +557,8 @@ ok:
98978 twrefcnt += inet_twsk_bind_unhash(tw, hinfo);
98979 spin_unlock(&head->lock);
98980
98981 + gr_update_task_in_ip_table(current, inet_sk(sk));
98982 +
98983 if (tw) {
98984 inet_twsk_deschedule(tw, death_row);
98985 while (twrefcnt) {
98986 diff --git a/net/ipv4/inetpeer.c b/net/ipv4/inetpeer.c
98987 index 48f4244..f56d83a 100644
98988 --- a/net/ipv4/inetpeer.c
98989 +++ b/net/ipv4/inetpeer.c
98990 @@ -496,8 +496,8 @@ relookup:
98991 if (p) {
98992 p->daddr = *daddr;
98993 atomic_set(&p->refcnt, 1);
98994 - atomic_set(&p->rid, 0);
98995 - atomic_set(&p->ip_id_count,
98996 + atomic_set_unchecked(&p->rid, 0);
98997 + atomic_set_unchecked(&p->ip_id_count,
98998 (daddr->family == AF_INET) ?
98999 secure_ip_id(daddr->addr.a4) :
99000 secure_ipv6_id(daddr->addr.a6));
99001 diff --git a/net/ipv4/ip_fragment.c b/net/ipv4/ip_fragment.c
99002 index ed32313..3762abe 100644
99003 --- a/net/ipv4/ip_fragment.c
99004 +++ b/net/ipv4/ip_fragment.c
99005 @@ -284,7 +284,7 @@ static inline int ip_frag_too_far(struct ipq *qp)
99006 return 0;
99007
99008 start = qp->rid;
99009 - end = atomic_inc_return(&peer->rid);
99010 + end = atomic_inc_return_unchecked(&peer->rid);
99011 qp->rid = end;
99012
99013 rc = qp->q.fragments && (end - start) > max;
99014 @@ -761,12 +761,11 @@ static struct ctl_table ip4_frags_ctl_table[] = {
99015
99016 static int __net_init ip4_frags_ns_ctl_register(struct net *net)
99017 {
99018 - struct ctl_table *table;
99019 + ctl_table_no_const *table = NULL;
99020 struct ctl_table_header *hdr;
99021
99022 - table = ip4_frags_ns_ctl_table;
99023 if (!net_eq(net, &init_net)) {
99024 - table = kmemdup(table, sizeof(ip4_frags_ns_ctl_table), GFP_KERNEL);
99025 + table = kmemdup(ip4_frags_ns_ctl_table, sizeof(ip4_frags_ns_ctl_table), GFP_KERNEL);
99026 if (table == NULL)
99027 goto err_alloc;
99028
99029 @@ -777,9 +776,10 @@ static int __net_init ip4_frags_ns_ctl_register(struct net *net)
99030 /* Don't export sysctls to unprivileged users */
99031 if (net->user_ns != &init_user_ns)
99032 table[0].procname = NULL;
99033 - }
99034 + hdr = register_net_sysctl(net, "net/ipv4", table);
99035 + } else
99036 + hdr = register_net_sysctl(net, "net/ipv4", ip4_frags_ns_ctl_table);
99037
99038 - hdr = register_net_sysctl(net, "net/ipv4", table);
99039 if (hdr == NULL)
99040 goto err_reg;
99041
99042 @@ -787,8 +787,7 @@ static int __net_init ip4_frags_ns_ctl_register(struct net *net)
99043 return 0;
99044
99045 err_reg:
99046 - if (!net_eq(net, &init_net))
99047 - kfree(table);
99048 + kfree(table);
99049 err_alloc:
99050 return -ENOMEM;
99051 }
99052 diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c
99053 index 94213c8..8bdb342 100644
99054 --- a/net/ipv4/ip_gre.c
99055 +++ b/net/ipv4/ip_gre.c
99056 @@ -115,7 +115,7 @@ static bool log_ecn_error = true;
99057 module_param(log_ecn_error, bool, 0644);
99058 MODULE_PARM_DESC(log_ecn_error, "Log packets received with corrupted ECN");
99059
99060 -static struct rtnl_link_ops ipgre_link_ops __read_mostly;
99061 +static struct rtnl_link_ops ipgre_link_ops;
99062 static int ipgre_tunnel_init(struct net_device *dev);
99063
99064 static int ipgre_net_id __read_mostly;
99065 @@ -732,7 +732,7 @@ static const struct nla_policy ipgre_policy[IFLA_GRE_MAX + 1] = {
99066 [IFLA_GRE_PMTUDISC] = { .type = NLA_U8 },
99067 };
99068
99069 -static struct rtnl_link_ops ipgre_link_ops __read_mostly = {
99070 +static struct rtnl_link_ops ipgre_link_ops = {
99071 .kind = "gre",
99072 .maxtype = IFLA_GRE_MAX,
99073 .policy = ipgre_policy,
99074 @@ -746,7 +746,7 @@ static struct rtnl_link_ops ipgre_link_ops __read_mostly = {
99075 .fill_info = ipgre_fill_info,
99076 };
99077
99078 -static struct rtnl_link_ops ipgre_tap_ops __read_mostly = {
99079 +static struct rtnl_link_ops ipgre_tap_ops = {
99080 .kind = "gretap",
99081 .maxtype = IFLA_GRE_MAX,
99082 .policy = ipgre_policy,
99083 diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c
99084 index 64741b9..6f334a2 100644
99085 --- a/net/ipv4/ip_sockglue.c
99086 +++ b/net/ipv4/ip_sockglue.c
99087 @@ -1188,7 +1188,8 @@ static int do_ip_getsockopt(struct sock *sk, int level, int optname,
99088 len = min_t(unsigned int, len, opt->optlen);
99089 if (put_user(len, optlen))
99090 return -EFAULT;
99091 - if (copy_to_user(optval, opt->__data, len))
99092 + if ((len > (sizeof(optbuf) - sizeof(struct ip_options))) ||
99093 + copy_to_user(optval, opt->__data, len))
99094 return -EFAULT;
99095 return 0;
99096 }
99097 @@ -1319,7 +1320,7 @@ static int do_ip_getsockopt(struct sock *sk, int level, int optname,
99098 if (sk->sk_type != SOCK_STREAM)
99099 return -ENOPROTOOPT;
99100
99101 - msg.msg_control = optval;
99102 + msg.msg_control = (void __force_kernel *)optval;
99103 msg.msg_controllen = len;
99104 msg.msg_flags = flags;
99105
99106 diff --git a/net/ipv4/ip_vti.c b/net/ipv4/ip_vti.c
99107 index 13ef00f..8ffca25 100644
99108 --- a/net/ipv4/ip_vti.c
99109 +++ b/net/ipv4/ip_vti.c
99110 @@ -45,7 +45,7 @@
99111 #include <net/net_namespace.h>
99112 #include <net/netns/generic.h>
99113
99114 -static struct rtnl_link_ops vti_link_ops __read_mostly;
99115 +static struct rtnl_link_ops vti_link_ops;
99116
99117 static int vti_net_id __read_mostly;
99118 static int vti_tunnel_init(struct net_device *dev);
99119 @@ -513,7 +513,7 @@ static const struct nla_policy vti_policy[IFLA_VTI_MAX + 1] = {
99120 [IFLA_VTI_REMOTE] = { .len = FIELD_SIZEOF(struct iphdr, daddr) },
99121 };
99122
99123 -static struct rtnl_link_ops vti_link_ops __read_mostly = {
99124 +static struct rtnl_link_ops vti_link_ops = {
99125 .kind = "vti",
99126 .maxtype = IFLA_VTI_MAX,
99127 .policy = vti_policy,
99128 diff --git a/net/ipv4/ipconfig.c b/net/ipv4/ipconfig.c
99129 index b3e86ea..18ce98c 100644
99130 --- a/net/ipv4/ipconfig.c
99131 +++ b/net/ipv4/ipconfig.c
99132 @@ -334,7 +334,7 @@ static int __init ic_devinet_ioctl(unsigned int cmd, struct ifreq *arg)
99133
99134 mm_segment_t oldfs = get_fs();
99135 set_fs(get_ds());
99136 - res = devinet_ioctl(&init_net, cmd, (struct ifreq __user *) arg);
99137 + res = devinet_ioctl(&init_net, cmd, (struct ifreq __force_user *) arg);
99138 set_fs(oldfs);
99139 return res;
99140 }
99141 @@ -345,7 +345,7 @@ static int __init ic_dev_ioctl(unsigned int cmd, struct ifreq *arg)
99142
99143 mm_segment_t oldfs = get_fs();
99144 set_fs(get_ds());
99145 - res = dev_ioctl(&init_net, cmd, (struct ifreq __user *) arg);
99146 + res = dev_ioctl(&init_net, cmd, (struct ifreq __force_user *) arg);
99147 set_fs(oldfs);
99148 return res;
99149 }
99150 @@ -356,7 +356,7 @@ static int __init ic_route_ioctl(unsigned int cmd, struct rtentry *arg)
99151
99152 mm_segment_t oldfs = get_fs();
99153 set_fs(get_ds());
99154 - res = ip_rt_ioctl(&init_net, cmd, (void __user *) arg);
99155 + res = ip_rt_ioctl(&init_net, cmd, (void __force_user *) arg);
99156 set_fs(oldfs);
99157 return res;
99158 }
99159 diff --git a/net/ipv4/ipip.c b/net/ipv4/ipip.c
99160 index 812b183..56cbe9c 100644
99161 --- a/net/ipv4/ipip.c
99162 +++ b/net/ipv4/ipip.c
99163 @@ -124,7 +124,7 @@ MODULE_PARM_DESC(log_ecn_error, "Log packets received with corrupted ECN");
99164 static int ipip_net_id __read_mostly;
99165
99166 static int ipip_tunnel_init(struct net_device *dev);
99167 -static struct rtnl_link_ops ipip_link_ops __read_mostly;
99168 +static struct rtnl_link_ops ipip_link_ops;
99169
99170 static int ipip_err(struct sk_buff *skb, u32 info)
99171 {
99172 @@ -409,7 +409,7 @@ static const struct nla_policy ipip_policy[IFLA_IPTUN_MAX + 1] = {
99173 [IFLA_IPTUN_PMTUDISC] = { .type = NLA_U8 },
99174 };
99175
99176 -static struct rtnl_link_ops ipip_link_ops __read_mostly = {
99177 +static struct rtnl_link_ops ipip_link_ops = {
99178 .kind = "ipip",
99179 .maxtype = IFLA_IPTUN_MAX,
99180 .policy = ipip_policy,
99181 diff --git a/net/ipv4/netfilter/arp_tables.c b/net/ipv4/netfilter/arp_tables.c
99182 index f95b6f9..2ee2097 100644
99183 --- a/net/ipv4/netfilter/arp_tables.c
99184 +++ b/net/ipv4/netfilter/arp_tables.c
99185 @@ -885,14 +885,14 @@ static int compat_table_info(const struct xt_table_info *info,
99186 #endif
99187
99188 static int get_info(struct net *net, void __user *user,
99189 - const int *len, int compat)
99190 + int len, int compat)
99191 {
99192 char name[XT_TABLE_MAXNAMELEN];
99193 struct xt_table *t;
99194 int ret;
99195
99196 - if (*len != sizeof(struct arpt_getinfo)) {
99197 - duprintf("length %u != %Zu\n", *len,
99198 + if (len != sizeof(struct arpt_getinfo)) {
99199 + duprintf("length %u != %Zu\n", len,
99200 sizeof(struct arpt_getinfo));
99201 return -EINVAL;
99202 }
99203 @@ -929,7 +929,7 @@ static int get_info(struct net *net, void __user *user,
99204 info.size = private->size;
99205 strcpy(info.name, name);
99206
99207 - if (copy_to_user(user, &info, *len) != 0)
99208 + if (copy_to_user(user, &info, len) != 0)
99209 ret = -EFAULT;
99210 else
99211 ret = 0;
99212 @@ -1690,7 +1690,7 @@ static int compat_do_arpt_get_ctl(struct sock *sk, int cmd, void __user *user,
99213
99214 switch (cmd) {
99215 case ARPT_SO_GET_INFO:
99216 - ret = get_info(sock_net(sk), user, len, 1);
99217 + ret = get_info(sock_net(sk), user, *len, 1);
99218 break;
99219 case ARPT_SO_GET_ENTRIES:
99220 ret = compat_get_entries(sock_net(sk), user, len);
99221 @@ -1735,7 +1735,7 @@ static int do_arpt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len
99222
99223 switch (cmd) {
99224 case ARPT_SO_GET_INFO:
99225 - ret = get_info(sock_net(sk), user, len, 0);
99226 + ret = get_info(sock_net(sk), user, *len, 0);
99227 break;
99228
99229 case ARPT_SO_GET_ENTRIES:
99230 diff --git a/net/ipv4/netfilter/ip_tables.c b/net/ipv4/netfilter/ip_tables.c
99231 index 99e810f..3711b81 100644
99232 --- a/net/ipv4/netfilter/ip_tables.c
99233 +++ b/net/ipv4/netfilter/ip_tables.c
99234 @@ -1073,14 +1073,14 @@ static int compat_table_info(const struct xt_table_info *info,
99235 #endif
99236
99237 static int get_info(struct net *net, void __user *user,
99238 - const int *len, int compat)
99239 + int len, int compat)
99240 {
99241 char name[XT_TABLE_MAXNAMELEN];
99242 struct xt_table *t;
99243 int ret;
99244
99245 - if (*len != sizeof(struct ipt_getinfo)) {
99246 - duprintf("length %u != %zu\n", *len,
99247 + if (len != sizeof(struct ipt_getinfo)) {
99248 + duprintf("length %u != %zu\n", len,
99249 sizeof(struct ipt_getinfo));
99250 return -EINVAL;
99251 }
99252 @@ -1117,7 +1117,7 @@ static int get_info(struct net *net, void __user *user,
99253 info.size = private->size;
99254 strcpy(info.name, name);
99255
99256 - if (copy_to_user(user, &info, *len) != 0)
99257 + if (copy_to_user(user, &info, len) != 0)
99258 ret = -EFAULT;
99259 else
99260 ret = 0;
99261 @@ -1973,7 +1973,7 @@ compat_do_ipt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
99262
99263 switch (cmd) {
99264 case IPT_SO_GET_INFO:
99265 - ret = get_info(sock_net(sk), user, len, 1);
99266 + ret = get_info(sock_net(sk), user, *len, 1);
99267 break;
99268 case IPT_SO_GET_ENTRIES:
99269 ret = compat_get_entries(sock_net(sk), user, len);
99270 @@ -2020,7 +2020,7 @@ do_ipt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
99271
99272 switch (cmd) {
99273 case IPT_SO_GET_INFO:
99274 - ret = get_info(sock_net(sk), user, len, 0);
99275 + ret = get_info(sock_net(sk), user, *len, 0);
99276 break;
99277
99278 case IPT_SO_GET_ENTRIES:
99279 diff --git a/net/ipv4/netfilter/ipt_CLUSTERIP.c b/net/ipv4/netfilter/ipt_CLUSTERIP.c
99280 index 2510c02..cfb34fa 100644
99281 --- a/net/ipv4/netfilter/ipt_CLUSTERIP.c
99282 +++ b/net/ipv4/netfilter/ipt_CLUSTERIP.c
99283 @@ -720,7 +720,7 @@ static int clusterip_net_init(struct net *net)
99284 spin_lock_init(&cn->lock);
99285
99286 #ifdef CONFIG_PROC_FS
99287 - cn->procdir = proc_mkdir("ipt_CLUSTERIP", net->proc_net);
99288 + cn->procdir = proc_mkdir_restrict("ipt_CLUSTERIP", net->proc_net);
99289 if (!cn->procdir) {
99290 pr_err("Unable to proc dir entry\n");
99291 return -ENOMEM;
99292 diff --git a/net/ipv4/ping.c b/net/ipv4/ping.c
99293 index 044a0dd..e0c1971 100644
99294 --- a/net/ipv4/ping.c
99295 +++ b/net/ipv4/ping.c
99296 @@ -59,7 +59,7 @@ struct ping_table {
99297 };
99298
99299 static struct ping_table ping_table;
99300 -struct pingv6_ops pingv6_ops;
99301 +struct pingv6_ops *pingv6_ops;
99302 EXPORT_SYMBOL_GPL(pingv6_ops);
99303
99304 static u16 ping_port_rover;
99305 @@ -348,7 +348,7 @@ static int ping_check_bind_addr(struct sock *sk, struct inet_sock *isk,
99306 return -ENODEV;
99307 }
99308 }
99309 - has_addr = pingv6_ops.ipv6_chk_addr(net, &addr->sin6_addr, dev,
99310 + has_addr = pingv6_ops->ipv6_chk_addr(net, &addr->sin6_addr, dev,
99311 scoped);
99312 rcu_read_unlock();
99313
99314 @@ -556,7 +556,7 @@ void ping_err(struct sk_buff *skb, int offset, u32 info)
99315 }
99316 #if IS_ENABLED(CONFIG_IPV6)
99317 } else if (skb->protocol == htons(ETH_P_IPV6)) {
99318 - harderr = pingv6_ops.icmpv6_err_convert(type, code, &err);
99319 + harderr = pingv6_ops->icmpv6_err_convert(type, code, &err);
99320 #endif
99321 }
99322
99323 @@ -574,7 +574,7 @@ void ping_err(struct sk_buff *skb, int offset, u32 info)
99324 info, (u8 *)icmph);
99325 #if IS_ENABLED(CONFIG_IPV6)
99326 } else if (family == AF_INET6) {
99327 - pingv6_ops.ipv6_icmp_error(sk, skb, err, 0,
99328 + pingv6_ops->ipv6_icmp_error(sk, skb, err, 0,
99329 info, (u8 *)icmph);
99330 #endif
99331 }
99332 @@ -844,6 +844,8 @@ int ping_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
99333 {
99334 struct inet_sock *isk = inet_sk(sk);
99335 int family = sk->sk_family;
99336 + struct sockaddr_in *sin;
99337 + struct sockaddr_in6 *sin6;
99338 struct sk_buff *skb;
99339 int copied, err;
99340
99341 @@ -853,12 +855,19 @@ int ping_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
99342 if (flags & MSG_OOB)
99343 goto out;
99344
99345 + if (addr_len) {
99346 + if (family == AF_INET)
99347 + *addr_len = sizeof(*sin);
99348 + else if (family == AF_INET6 && addr_len)
99349 + *addr_len = sizeof(*sin6);
99350 + }
99351 +
99352 if (flags & MSG_ERRQUEUE) {
99353 if (family == AF_INET) {
99354 return ip_recv_error(sk, msg, len, addr_len);
99355 #if IS_ENABLED(CONFIG_IPV6)
99356 } else if (family == AF_INET6) {
99357 - return pingv6_ops.ipv6_recv_error(sk, msg, len,
99358 + return pingv6_ops->ipv6_recv_error(sk, msg, len,
99359 addr_len);
99360 #endif
99361 }
99362 @@ -890,7 +899,6 @@ int ping_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
99363 sin->sin_port = 0 /* skb->h.uh->source */;
99364 sin->sin_addr.s_addr = ip_hdr(skb)->saddr;
99365 memset(sin->sin_zero, 0, sizeof(sin->sin_zero));
99366 - *addr_len = sizeof(*sin);
99367 }
99368
99369 if (isk->cmsg_flags)
99370 @@ -912,14 +920,13 @@ int ping_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
99371 sin6->sin6_scope_id =
99372 ipv6_iface_scope_id(&sin6->sin6_addr,
99373 IP6CB(skb)->iif);
99374 - *addr_len = sizeof(*sin6);
99375 }
99376
99377 if (inet6_sk(sk)->rxopt.all)
99378 - pingv6_ops.ip6_datagram_recv_common_ctl(sk, msg, skb);
99379 + pingv6_ops->ip6_datagram_recv_common_ctl(sk, msg, skb);
99380 if (skb->protocol == htons(ETH_P_IPV6) &&
99381 inet6_sk(sk)->rxopt.all)
99382 - pingv6_ops.ip6_datagram_recv_specific_ctl(sk, msg, skb);
99383 + pingv6_ops->ip6_datagram_recv_specific_ctl(sk, msg, skb);
99384 else if (skb->protocol == htons(ETH_P_IP) && isk->cmsg_flags)
99385 ip_cmsg_recv(msg, skb);
99386 #endif
99387 @@ -1111,7 +1118,7 @@ static void ping_v4_format_sock(struct sock *sp, struct seq_file *f,
99388 from_kuid_munged(seq_user_ns(f), sock_i_uid(sp)),
99389 0, sock_i_ino(sp),
99390 atomic_read(&sp->sk_refcnt), sp,
99391 - atomic_read(&sp->sk_drops));
99392 + atomic_read_unchecked(&sp->sk_drops));
99393 }
99394
99395 static int ping_v4_seq_show(struct seq_file *seq, void *v)
99396 diff --git a/net/ipv4/raw.c b/net/ipv4/raw.c
99397 index a9dbe58..46f577f 100644
99398 --- a/net/ipv4/raw.c
99399 +++ b/net/ipv4/raw.c
99400 @@ -311,7 +311,7 @@ static int raw_rcv_skb(struct sock *sk, struct sk_buff *skb)
99401 int raw_rcv(struct sock *sk, struct sk_buff *skb)
99402 {
99403 if (!xfrm4_policy_check(sk, XFRM_POLICY_IN, skb)) {
99404 - atomic_inc(&sk->sk_drops);
99405 + atomic_inc_unchecked(&sk->sk_drops);
99406 kfree_skb(skb);
99407 return NET_RX_DROP;
99408 }
99409 @@ -696,6 +696,9 @@ static int raw_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
99410 if (flags & MSG_OOB)
99411 goto out;
99412
99413 + if (addr_len)
99414 + *addr_len = sizeof(*sin);
99415 +
99416 if (flags & MSG_ERRQUEUE) {
99417 err = ip_recv_error(sk, msg, len, addr_len);
99418 goto out;
99419 @@ -723,7 +726,6 @@ static int raw_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
99420 sin->sin_addr.s_addr = ip_hdr(skb)->saddr;
99421 sin->sin_port = 0;
99422 memset(&sin->sin_zero, 0, sizeof(sin->sin_zero));
99423 - *addr_len = sizeof(*sin);
99424 }
99425 if (inet->cmsg_flags)
99426 ip_cmsg_recv(msg, skb);
99427 @@ -748,16 +750,20 @@ static int raw_init(struct sock *sk)
99428
99429 static int raw_seticmpfilter(struct sock *sk, char __user *optval, int optlen)
99430 {
99431 + struct icmp_filter filter;
99432 +
99433 if (optlen > sizeof(struct icmp_filter))
99434 optlen = sizeof(struct icmp_filter);
99435 - if (copy_from_user(&raw_sk(sk)->filter, optval, optlen))
99436 + if (copy_from_user(&filter, optval, optlen))
99437 return -EFAULT;
99438 + raw_sk(sk)->filter = filter;
99439 return 0;
99440 }
99441
99442 static int raw_geticmpfilter(struct sock *sk, char __user *optval, int __user *optlen)
99443 {
99444 int len, ret = -EFAULT;
99445 + struct icmp_filter filter;
99446
99447 if (get_user(len, optlen))
99448 goto out;
99449 @@ -767,8 +773,8 @@ static int raw_geticmpfilter(struct sock *sk, char __user *optval, int __user *o
99450 if (len > sizeof(struct icmp_filter))
99451 len = sizeof(struct icmp_filter);
99452 ret = -EFAULT;
99453 - if (put_user(len, optlen) ||
99454 - copy_to_user(optval, &raw_sk(sk)->filter, len))
99455 + filter = raw_sk(sk)->filter;
99456 + if (put_user(len, optlen) || len > sizeof filter || copy_to_user(optval, &filter, len))
99457 goto out;
99458 ret = 0;
99459 out: return ret;
99460 @@ -997,7 +1003,7 @@ static void raw_sock_seq_show(struct seq_file *seq, struct sock *sp, int i)
99461 0, 0L, 0,
99462 from_kuid_munged(seq_user_ns(seq), sock_i_uid(sp)),
99463 0, sock_i_ino(sp),
99464 - atomic_read(&sp->sk_refcnt), sp, atomic_read(&sp->sk_drops));
99465 + atomic_read(&sp->sk_refcnt), sp, atomic_read_unchecked(&sp->sk_drops));
99466 }
99467
99468 static int raw_seq_show(struct seq_file *seq, void *v)
99469 diff --git a/net/ipv4/route.c b/net/ipv4/route.c
99470 index 5e676be..f6c62f1 100644
99471 --- a/net/ipv4/route.c
99472 +++ b/net/ipv4/route.c
99473 @@ -227,7 +227,7 @@ static const struct seq_operations rt_cache_seq_ops = {
99474
99475 static int rt_cache_seq_open(struct inode *inode, struct file *file)
99476 {
99477 - return seq_open(file, &rt_cache_seq_ops);
99478 + return seq_open_restrict(file, &rt_cache_seq_ops);
99479 }
99480
99481 static const struct file_operations rt_cache_seq_fops = {
99482 @@ -318,7 +318,7 @@ static const struct seq_operations rt_cpu_seq_ops = {
99483
99484 static int rt_cpu_seq_open(struct inode *inode, struct file *file)
99485 {
99486 - return seq_open(file, &rt_cpu_seq_ops);
99487 + return seq_open_restrict(file, &rt_cpu_seq_ops);
99488 }
99489
99490 static const struct file_operations rt_cpu_seq_fops = {
99491 @@ -356,7 +356,7 @@ static int rt_acct_proc_show(struct seq_file *m, void *v)
99492
99493 static int rt_acct_proc_open(struct inode *inode, struct file *file)
99494 {
99495 - return single_open(file, rt_acct_proc_show, NULL);
99496 + return single_open_restrict(file, rt_acct_proc_show, NULL);
99497 }
99498
99499 static const struct file_operations rt_acct_proc_fops = {
99500 @@ -2610,34 +2610,34 @@ static struct ctl_table ipv4_route_flush_table[] = {
99501 .maxlen = sizeof(int),
99502 .mode = 0200,
99503 .proc_handler = ipv4_sysctl_rtcache_flush,
99504 + .extra1 = &init_net,
99505 },
99506 { },
99507 };
99508
99509 static __net_init int sysctl_route_net_init(struct net *net)
99510 {
99511 - struct ctl_table *tbl;
99512 + ctl_table_no_const *tbl = NULL;
99513
99514 - tbl = ipv4_route_flush_table;
99515 if (!net_eq(net, &init_net)) {
99516 - tbl = kmemdup(tbl, sizeof(ipv4_route_flush_table), GFP_KERNEL);
99517 + tbl = kmemdup(ipv4_route_flush_table, sizeof(ipv4_route_flush_table), GFP_KERNEL);
99518 if (tbl == NULL)
99519 goto err_dup;
99520
99521 /* Don't export sysctls to unprivileged users */
99522 if (net->user_ns != &init_user_ns)
99523 tbl[0].procname = NULL;
99524 - }
99525 - tbl[0].extra1 = net;
99526 + tbl[0].extra1 = net;
99527 + net->ipv4.route_hdr = register_net_sysctl(net, "net/ipv4/route", tbl);
99528 + } else
99529 + net->ipv4.route_hdr = register_net_sysctl(net, "net/ipv4/route", ipv4_route_flush_table);
99530
99531 - net->ipv4.route_hdr = register_net_sysctl(net, "net/ipv4/route", tbl);
99532 if (net->ipv4.route_hdr == NULL)
99533 goto err_reg;
99534 return 0;
99535
99536 err_reg:
99537 - if (tbl != ipv4_route_flush_table)
99538 - kfree(tbl);
99539 + kfree(tbl);
99540 err_dup:
99541 return -ENOMEM;
99542 }
99543 @@ -2660,8 +2660,8 @@ static __net_initdata struct pernet_operations sysctl_route_ops = {
99544
99545 static __net_init int rt_genid_init(struct net *net)
99546 {
99547 - atomic_set(&net->ipv4.rt_genid, 0);
99548 - atomic_set(&net->fnhe_genid, 0);
99549 + atomic_set_unchecked(&net->ipv4.rt_genid, 0);
99550 + atomic_set_unchecked(&net->fnhe_genid, 0);
99551 get_random_bytes(&net->ipv4.dev_addr_genid,
99552 sizeof(net->ipv4.dev_addr_genid));
99553 return 0;
99554 diff --git a/net/ipv4/sysctl_net_ipv4.c b/net/ipv4/sysctl_net_ipv4.c
99555 index 5cde8f2..5f5684e 100644
99556 --- a/net/ipv4/sysctl_net_ipv4.c
99557 +++ b/net/ipv4/sysctl_net_ipv4.c
99558 @@ -60,7 +60,7 @@ static int ipv4_local_port_range(struct ctl_table *table, int write,
99559 container_of(table->data, struct net, ipv4.ip_local_ports.range);
99560 int ret;
99561 int range[2];
99562 - struct ctl_table tmp = {
99563 + ctl_table_no_const tmp = {
99564 .data = &range,
99565 .maxlen = sizeof(range),
99566 .mode = table->mode,
99567 @@ -118,7 +118,7 @@ static int ipv4_ping_group_range(struct ctl_table *table, int write,
99568 int ret;
99569 gid_t urange[2];
99570 kgid_t low, high;
99571 - struct ctl_table tmp = {
99572 + ctl_table_no_const tmp = {
99573 .data = &urange,
99574 .maxlen = sizeof(urange),
99575 .mode = table->mode,
99576 @@ -149,7 +149,7 @@ static int proc_tcp_congestion_control(struct ctl_table *ctl, int write,
99577 void __user *buffer, size_t *lenp, loff_t *ppos)
99578 {
99579 char val[TCP_CA_NAME_MAX];
99580 - struct ctl_table tbl = {
99581 + ctl_table_no_const tbl = {
99582 .data = val,
99583 .maxlen = TCP_CA_NAME_MAX,
99584 };
99585 @@ -168,7 +168,7 @@ static int proc_tcp_available_congestion_control(struct ctl_table *ctl,
99586 void __user *buffer, size_t *lenp,
99587 loff_t *ppos)
99588 {
99589 - struct ctl_table tbl = { .maxlen = TCP_CA_BUF_MAX, };
99590 + ctl_table_no_const tbl = { .maxlen = TCP_CA_BUF_MAX, };
99591 int ret;
99592
99593 tbl.data = kmalloc(tbl.maxlen, GFP_USER);
99594 @@ -185,7 +185,7 @@ static int proc_allowed_congestion_control(struct ctl_table *ctl,
99595 void __user *buffer, size_t *lenp,
99596 loff_t *ppos)
99597 {
99598 - struct ctl_table tbl = { .maxlen = TCP_CA_BUF_MAX };
99599 + ctl_table_no_const tbl = { .maxlen = TCP_CA_BUF_MAX };
99600 int ret;
99601
99602 tbl.data = kmalloc(tbl.maxlen, GFP_USER);
99603 @@ -204,7 +204,7 @@ static int proc_tcp_fastopen_key(struct ctl_table *ctl, int write,
99604 void __user *buffer, size_t *lenp,
99605 loff_t *ppos)
99606 {
99607 - struct ctl_table tbl = { .maxlen = (TCP_FASTOPEN_KEY_LENGTH * 2 + 10) };
99608 + ctl_table_no_const tbl = { .maxlen = (TCP_FASTOPEN_KEY_LENGTH * 2 + 10) };
99609 struct tcp_fastopen_context *ctxt;
99610 int ret;
99611 u32 user_key[4]; /* 16 bytes, matching TCP_FASTOPEN_KEY_LENGTH */
99612 @@ -438,7 +438,7 @@ static struct ctl_table ipv4_table[] = {
99613 },
99614 {
99615 .procname = "ip_local_reserved_ports",
99616 - .data = NULL, /* initialized in sysctl_ipv4_init */
99617 + .data = sysctl_local_reserved_ports,
99618 .maxlen = 65536,
99619 .mode = 0644,
99620 .proc_handler = proc_do_large_bitmap,
99621 @@ -843,13 +843,12 @@ static struct ctl_table ipv4_net_table[] = {
99622
99623 static __net_init int ipv4_sysctl_init_net(struct net *net)
99624 {
99625 - struct ctl_table *table;
99626 + ctl_table_no_const *table = NULL;
99627
99628 - table = ipv4_net_table;
99629 if (!net_eq(net, &init_net)) {
99630 int i;
99631
99632 - table = kmemdup(table, sizeof(ipv4_net_table), GFP_KERNEL);
99633 + table = kmemdup(ipv4_net_table, sizeof(ipv4_net_table), GFP_KERNEL);
99634 if (table == NULL)
99635 goto err_alloc;
99636
99637 @@ -858,15 +857,17 @@ static __net_init int ipv4_sysctl_init_net(struct net *net)
99638 table[i].data += (void *)net - (void *)&init_net;
99639 }
99640
99641 - net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", table);
99642 + if (!net_eq(net, &init_net))
99643 + net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", table);
99644 + else
99645 + net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", ipv4_net_table);
99646 if (net->ipv4.ipv4_hdr == NULL)
99647 goto err_reg;
99648
99649 return 0;
99650
99651 err_reg:
99652 - if (!net_eq(net, &init_net))
99653 - kfree(table);
99654 + kfree(table);
99655 err_alloc:
99656 return -ENOMEM;
99657 }
99658 @@ -888,16 +889,6 @@ static __net_initdata struct pernet_operations ipv4_sysctl_ops = {
99659 static __init int sysctl_ipv4_init(void)
99660 {
99661 struct ctl_table_header *hdr;
99662 - struct ctl_table *i;
99663 -
99664 - for (i = ipv4_table; i->procname; i++) {
99665 - if (strcmp(i->procname, "ip_local_reserved_ports") == 0) {
99666 - i->data = sysctl_local_reserved_ports;
99667 - break;
99668 - }
99669 - }
99670 - if (!i->procname)
99671 - return -EINVAL;
99672
99673 hdr = register_net_sysctl(&init_net, "net/ipv4", ipv4_table);
99674 if (hdr == NULL)
99675 diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
99676 index 3a26b3b..8bbe4ae 100644
99677 --- a/net/ipv4/tcp_input.c
99678 +++ b/net/ipv4/tcp_input.c
99679 @@ -754,7 +754,7 @@ static void tcp_update_pacing_rate(struct sock *sk)
99680 * without any lock. We want to make sure compiler wont store
99681 * intermediate values in this location.
99682 */
99683 - ACCESS_ONCE(sk->sk_pacing_rate) = min_t(u64, rate,
99684 + ACCESS_ONCE_RW(sk->sk_pacing_rate) = min_t(u64, rate,
99685 sk->sk_max_pacing_rate);
99686 }
99687
99688 @@ -4478,7 +4478,7 @@ static struct sk_buff *tcp_collapse_one(struct sock *sk, struct sk_buff *skb,
99689 * simplifies code)
99690 */
99691 static void
99692 -tcp_collapse(struct sock *sk, struct sk_buff_head *list,
99693 +__intentional_overflow(5,6) tcp_collapse(struct sock *sk, struct sk_buff_head *list,
99694 struct sk_buff *head, struct sk_buff *tail,
99695 u32 start, u32 end)
99696 {
99697 @@ -5558,6 +5558,7 @@ discard:
99698 tcp_paws_reject(&tp->rx_opt, 0))
99699 goto discard_and_undo;
99700
99701 +#ifndef CONFIG_GRKERNSEC_NO_SIMULT_CONNECT
99702 if (th->syn) {
99703 /* We see SYN without ACK. It is attempt of
99704 * simultaneous connect with crossed SYNs.
99705 @@ -5608,6 +5609,7 @@ discard:
99706 goto discard;
99707 #endif
99708 }
99709 +#endif
99710 /* "fifth, if neither of the SYN or RST bits is set then
99711 * drop the segment and return."
99712 */
99713 @@ -5654,7 +5656,7 @@ int tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb,
99714 goto discard;
99715
99716 if (th->syn) {
99717 - if (th->fin)
99718 + if (th->fin || th->urg || th->psh)
99719 goto discard;
99720 if (icsk->icsk_af_ops->conn_request(sk, skb) < 0)
99721 return 1;
99722 diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
99723 index 438f3b9..bc9e1ad 100644
99724 --- a/net/ipv4/tcp_ipv4.c
99725 +++ b/net/ipv4/tcp_ipv4.c
99726 @@ -91,6 +91,10 @@ int sysctl_tcp_low_latency __read_mostly;
99727 EXPORT_SYMBOL(sysctl_tcp_low_latency);
99728
99729
99730 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
99731 +extern int grsec_enable_blackhole;
99732 +#endif
99733 +
99734 #ifdef CONFIG_TCP_MD5SIG
99735 static int tcp_v4_md5_hash_hdr(char *md5_hash, const struct tcp_md5sig_key *key,
99736 __be32 daddr, __be32 saddr, const struct tcphdr *th);
99737 @@ -1829,6 +1833,9 @@ int tcp_v4_do_rcv(struct sock *sk, struct sk_buff *skb)
99738 return 0;
99739
99740 reset:
99741 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
99742 + if (!grsec_enable_blackhole)
99743 +#endif
99744 tcp_v4_send_reset(rsk, skb);
99745 discard:
99746 kfree_skb(skb);
99747 @@ -1974,12 +1981,19 @@ int tcp_v4_rcv(struct sk_buff *skb)
99748 TCP_SKB_CB(skb)->sacked = 0;
99749
99750 sk = __inet_lookup_skb(&tcp_hashinfo, skb, th->source, th->dest);
99751 - if (!sk)
99752 + if (!sk) {
99753 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
99754 + ret = 1;
99755 +#endif
99756 goto no_tcp_socket;
99757 -
99758 + }
99759 process:
99760 - if (sk->sk_state == TCP_TIME_WAIT)
99761 + if (sk->sk_state == TCP_TIME_WAIT) {
99762 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
99763 + ret = 2;
99764 +#endif
99765 goto do_time_wait;
99766 + }
99767
99768 if (unlikely(iph->ttl < inet_sk(sk)->min_ttl)) {
99769 NET_INC_STATS_BH(net, LINUX_MIB_TCPMINTTLDROP);
99770 @@ -2033,6 +2047,10 @@ csum_error:
99771 bad_packet:
99772 TCP_INC_STATS_BH(net, TCP_MIB_INERRS);
99773 } else {
99774 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
99775 + if (!grsec_enable_blackhole || (ret == 1 &&
99776 + (skb->dev->flags & IFF_LOOPBACK)))
99777 +#endif
99778 tcp_v4_send_reset(NULL, skb);
99779 }
99780
99781 diff --git a/net/ipv4/tcp_minisocks.c b/net/ipv4/tcp_minisocks.c
99782 index 05c1b15..3e9344b 100644
99783 --- a/net/ipv4/tcp_minisocks.c
99784 +++ b/net/ipv4/tcp_minisocks.c
99785 @@ -27,6 +27,10 @@
99786 #include <net/inet_common.h>
99787 #include <net/xfrm.h>
99788
99789 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
99790 +extern int grsec_enable_blackhole;
99791 +#endif
99792 +
99793 int sysctl_tcp_syncookies __read_mostly = 1;
99794 EXPORT_SYMBOL(sysctl_tcp_syncookies);
99795
99796 @@ -709,7 +713,10 @@ embryonic_reset:
99797 * avoid becoming vulnerable to outside attack aiming at
99798 * resetting legit local connections.
99799 */
99800 - req->rsk_ops->send_reset(sk, skb);
99801 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
99802 + if (!grsec_enable_blackhole)
99803 +#endif
99804 + req->rsk_ops->send_reset(sk, skb);
99805 } else if (fastopen) { /* received a valid RST pkt */
99806 reqsk_fastopen_remove(sk, req, true);
99807 tcp_reset(sk);
99808 diff --git a/net/ipv4/tcp_probe.c b/net/ipv4/tcp_probe.c
99809 index 3b66610..bfbe23a 100644
99810 --- a/net/ipv4/tcp_probe.c
99811 +++ b/net/ipv4/tcp_probe.c
99812 @@ -238,7 +238,7 @@ static ssize_t tcpprobe_read(struct file *file, char __user *buf,
99813 if (cnt + width >= len)
99814 break;
99815
99816 - if (copy_to_user(buf + cnt, tbuf, width))
99817 + if (width > sizeof tbuf || copy_to_user(buf + cnt, tbuf, width))
99818 return -EFAULT;
99819 cnt += width;
99820 }
99821 diff --git a/net/ipv4/tcp_timer.c b/net/ipv4/tcp_timer.c
99822 index 286227a..c495a76 100644
99823 --- a/net/ipv4/tcp_timer.c
99824 +++ b/net/ipv4/tcp_timer.c
99825 @@ -22,6 +22,10 @@
99826 #include <linux/gfp.h>
99827 #include <net/tcp.h>
99828
99829 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
99830 +extern int grsec_lastack_retries;
99831 +#endif
99832 +
99833 int sysctl_tcp_syn_retries __read_mostly = TCP_SYN_RETRIES;
99834 int sysctl_tcp_synack_retries __read_mostly = TCP_SYNACK_RETRIES;
99835 int sysctl_tcp_keepalive_time __read_mostly = TCP_KEEPALIVE_TIME;
99836 @@ -192,6 +196,13 @@ static int tcp_write_timeout(struct sock *sk)
99837 }
99838 }
99839
99840 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
99841 + if ((sk->sk_state == TCP_LAST_ACK) &&
99842 + (grsec_lastack_retries > 0) &&
99843 + (grsec_lastack_retries < retry_until))
99844 + retry_until = grsec_lastack_retries;
99845 +#endif
99846 +
99847 if (retransmits_timed_out(sk, retry_until,
99848 syn_set ? 0 : icsk->icsk_user_timeout, syn_set)) {
99849 /* Has it gone just too far? */
99850 diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
99851 index 4468e1a..def477a 100644
99852 --- a/net/ipv4/udp.c
99853 +++ b/net/ipv4/udp.c
99854 @@ -87,6 +87,7 @@
99855 #include <linux/types.h>
99856 #include <linux/fcntl.h>
99857 #include <linux/module.h>
99858 +#include <linux/security.h>
99859 #include <linux/socket.h>
99860 #include <linux/sockios.h>
99861 #include <linux/igmp.h>
99862 @@ -113,6 +114,10 @@
99863 #include <net/busy_poll.h>
99864 #include "udp_impl.h"
99865
99866 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
99867 +extern int grsec_enable_blackhole;
99868 +#endif
99869 +
99870 struct udp_table udp_table __read_mostly;
99871 EXPORT_SYMBOL(udp_table);
99872
99873 @@ -615,6 +620,9 @@ found:
99874 return s;
99875 }
99876
99877 +extern int gr_search_udp_recvmsg(struct sock *sk, const struct sk_buff *skb);
99878 +extern int gr_search_udp_sendmsg(struct sock *sk, struct sockaddr_in *addr);
99879 +
99880 /*
99881 * This routine is called by the ICMP module when it gets some
99882 * sort of error condition. If err < 0 then the socket should
99883 @@ -914,9 +922,18 @@ int udp_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
99884 dport = usin->sin_port;
99885 if (dport == 0)
99886 return -EINVAL;
99887 +
99888 + err = gr_search_udp_sendmsg(sk, usin);
99889 + if (err)
99890 + return err;
99891 } else {
99892 if (sk->sk_state != TCP_ESTABLISHED)
99893 return -EDESTADDRREQ;
99894 +
99895 + err = gr_search_udp_sendmsg(sk, NULL);
99896 + if (err)
99897 + return err;
99898 +
99899 daddr = inet->inet_daddr;
99900 dport = inet->inet_dport;
99901 /* Open fast path for connected socket.
99902 @@ -1164,7 +1181,7 @@ static unsigned int first_packet_length(struct sock *sk)
99903 IS_UDPLITE(sk));
99904 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS,
99905 IS_UDPLITE(sk));
99906 - atomic_inc(&sk->sk_drops);
99907 + atomic_inc_unchecked(&sk->sk_drops);
99908 __skb_unlink(skb, rcvq);
99909 __skb_queue_tail(&list_kill, skb);
99910 }
99911 @@ -1235,6 +1252,12 @@ int udp_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
99912 int is_udplite = IS_UDPLITE(sk);
99913 bool slow;
99914
99915 + /*
99916 + * Check any passed addresses
99917 + */
99918 + if (addr_len)
99919 + *addr_len = sizeof(*sin);
99920 +
99921 if (flags & MSG_ERRQUEUE)
99922 return ip_recv_error(sk, msg, len, addr_len);
99923
99924 @@ -1244,6 +1267,10 @@ try_again:
99925 if (!skb)
99926 goto out;
99927
99928 + err = gr_search_udp_recvmsg(sk, skb);
99929 + if (err)
99930 + goto out_free;
99931 +
99932 ulen = skb->len - sizeof(struct udphdr);
99933 copied = len;
99934 if (copied > ulen)
99935 @@ -1277,7 +1304,7 @@ try_again:
99936 if (unlikely(err)) {
99937 trace_kfree_skb(skb, udp_recvmsg);
99938 if (!peeked) {
99939 - atomic_inc(&sk->sk_drops);
99940 + atomic_inc_unchecked(&sk->sk_drops);
99941 UDP_INC_STATS_USER(sock_net(sk),
99942 UDP_MIB_INERRORS, is_udplite);
99943 }
99944 @@ -1296,7 +1323,6 @@ try_again:
99945 sin->sin_port = udp_hdr(skb)->source;
99946 sin->sin_addr.s_addr = ip_hdr(skb)->saddr;
99947 memset(sin->sin_zero, 0, sizeof(sin->sin_zero));
99948 - *addr_len = sizeof(*sin);
99949 }
99950 if (inet->cmsg_flags)
99951 ip_cmsg_recv(msg, skb);
99952 @@ -1567,7 +1593,7 @@ csum_error:
99953 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_CSUMERRORS, is_udplite);
99954 drop:
99955 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS, is_udplite);
99956 - atomic_inc(&sk->sk_drops);
99957 + atomic_inc_unchecked(&sk->sk_drops);
99958 kfree_skb(skb);
99959 return -1;
99960 }
99961 @@ -1586,7 +1612,7 @@ static void flush_stack(struct sock **stack, unsigned int count,
99962 skb1 = (i == final) ? skb : skb_clone(skb, GFP_ATOMIC);
99963
99964 if (!skb1) {
99965 - atomic_inc(&sk->sk_drops);
99966 + atomic_inc_unchecked(&sk->sk_drops);
99967 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_RCVBUFERRORS,
99968 IS_UDPLITE(sk));
99969 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS,
99970 @@ -1787,6 +1813,9 @@ int __udp4_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
99971 goto csum_error;
99972
99973 UDP_INC_STATS_BH(net, UDP_MIB_NOPORTS, proto == IPPROTO_UDPLITE);
99974 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
99975 + if (!grsec_enable_blackhole || (skb->dev->flags & IFF_LOOPBACK))
99976 +#endif
99977 icmp_send(skb, ICMP_DEST_UNREACH, ICMP_PORT_UNREACH, 0);
99978
99979 /*
99980 @@ -2351,7 +2380,7 @@ static void udp4_format_sock(struct sock *sp, struct seq_file *f,
99981 from_kuid_munged(seq_user_ns(f), sock_i_uid(sp)),
99982 0, sock_i_ino(sp),
99983 atomic_read(&sp->sk_refcnt), sp,
99984 - atomic_read(&sp->sk_drops));
99985 + atomic_read_unchecked(&sp->sk_drops));
99986 }
99987
99988 int udp4_seq_show(struct seq_file *seq, void *v)
99989 diff --git a/net/ipv4/xfrm4_policy.c b/net/ipv4/xfrm4_policy.c
99990 index 6156f68..d6ab46d 100644
99991 --- a/net/ipv4/xfrm4_policy.c
99992 +++ b/net/ipv4/xfrm4_policy.c
99993 @@ -186,11 +186,11 @@ _decode_session4(struct sk_buff *skb, struct flowi *fl, int reverse)
99994 fl4->flowi4_tos = iph->tos;
99995 }
99996
99997 -static inline int xfrm4_garbage_collect(struct dst_ops *ops)
99998 +static int xfrm4_garbage_collect(struct dst_ops *ops)
99999 {
100000 struct net *net = container_of(ops, struct net, xfrm.xfrm4_dst_ops);
100001
100002 - xfrm4_policy_afinfo.garbage_collect(net);
100003 + xfrm_garbage_collect_deferred(net);
100004 return (dst_entries_get_slow(ops) > ops->gc_thresh * 2);
100005 }
100006
100007 @@ -269,19 +269,18 @@ static struct ctl_table xfrm4_policy_table[] = {
100008
100009 static int __net_init xfrm4_net_init(struct net *net)
100010 {
100011 - struct ctl_table *table;
100012 + ctl_table_no_const *table = NULL;
100013 struct ctl_table_header *hdr;
100014
100015 - table = xfrm4_policy_table;
100016 if (!net_eq(net, &init_net)) {
100017 - table = kmemdup(table, sizeof(xfrm4_policy_table), GFP_KERNEL);
100018 + table = kmemdup(xfrm4_policy_table, sizeof(xfrm4_policy_table), GFP_KERNEL);
100019 if (!table)
100020 goto err_alloc;
100021
100022 table[0].data = &net->xfrm.xfrm4_dst_ops.gc_thresh;
100023 - }
100024 -
100025 - hdr = register_net_sysctl(net, "net/ipv4", table);
100026 + hdr = register_net_sysctl(net, "net/ipv4", table);
100027 + } else
100028 + hdr = register_net_sysctl(net, "net/ipv4", xfrm4_policy_table);
100029 if (!hdr)
100030 goto err_reg;
100031
100032 @@ -289,8 +288,7 @@ static int __net_init xfrm4_net_init(struct net *net)
100033 return 0;
100034
100035 err_reg:
100036 - if (!net_eq(net, &init_net))
100037 - kfree(table);
100038 + kfree(table);
100039 err_alloc:
100040 return -ENOMEM;
100041 }
100042 diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
100043 index 6c7fa08..285086c 100644
100044 --- a/net/ipv6/addrconf.c
100045 +++ b/net/ipv6/addrconf.c
100046 @@ -598,7 +598,7 @@ static int inet6_netconf_dump_devconf(struct sk_buff *skb,
100047 idx = 0;
100048 head = &net->dev_index_head[h];
100049 rcu_read_lock();
100050 - cb->seq = atomic_read(&net->ipv6.dev_addr_genid) ^
100051 + cb->seq = atomic_read_unchecked(&net->ipv6.dev_addr_genid) ^
100052 net->dev_base_seq;
100053 hlist_for_each_entry_rcu(dev, head, index_hlist) {
100054 if (idx < s_idx)
100055 @@ -2395,7 +2395,7 @@ int addrconf_set_dstaddr(struct net *net, void __user *arg)
100056 p.iph.ihl = 5;
100057 p.iph.protocol = IPPROTO_IPV6;
100058 p.iph.ttl = 64;
100059 - ifr.ifr_ifru.ifru_data = (__force void __user *)&p;
100060 + ifr.ifr_ifru.ifru_data = (void __force_user *)&p;
100061
100062 if (ops->ndo_do_ioctl) {
100063 mm_segment_t oldfs = get_fs();
100064 @@ -4146,7 +4146,7 @@ static int inet6_dump_addr(struct sk_buff *skb, struct netlink_callback *cb,
100065 s_ip_idx = ip_idx = cb->args[2];
100066
100067 rcu_read_lock();
100068 - cb->seq = atomic_read(&net->ipv6.dev_addr_genid) ^ net->dev_base_seq;
100069 + cb->seq = atomic_read_unchecked(&net->ipv6.dev_addr_genid) ^ net->dev_base_seq;
100070 for (h = s_h; h < NETDEV_HASHENTRIES; h++, s_idx = 0) {
100071 idx = 0;
100072 head = &net->dev_index_head[h];
100073 @@ -4758,7 +4758,7 @@ static void __ipv6_ifa_notify(int event, struct inet6_ifaddr *ifp)
100074 dst_free(&ifp->rt->dst);
100075 break;
100076 }
100077 - atomic_inc(&net->ipv6.dev_addr_genid);
100078 + atomic_inc_unchecked(&net->ipv6.dev_addr_genid);
100079 rt_genid_bump_ipv6(net);
100080 }
100081
100082 @@ -4779,7 +4779,7 @@ int addrconf_sysctl_forward(struct ctl_table *ctl, int write,
100083 int *valp = ctl->data;
100084 int val = *valp;
100085 loff_t pos = *ppos;
100086 - struct ctl_table lctl;
100087 + ctl_table_no_const lctl;
100088 int ret;
100089
100090 /*
100091 @@ -4864,7 +4864,7 @@ int addrconf_sysctl_disable(struct ctl_table *ctl, int write,
100092 int *valp = ctl->data;
100093 int val = *valp;
100094 loff_t pos = *ppos;
100095 - struct ctl_table lctl;
100096 + ctl_table_no_const lctl;
100097 int ret;
100098
100099 /*
100100 diff --git a/net/ipv6/af_inet6.c b/net/ipv6/af_inet6.c
100101 index d935889..2f64330 100644
100102 --- a/net/ipv6/af_inet6.c
100103 +++ b/net/ipv6/af_inet6.c
100104 @@ -776,7 +776,7 @@ static int __net_init inet6_net_init(struct net *net)
100105 net->ipv6.sysctl.bindv6only = 0;
100106 net->ipv6.sysctl.icmpv6_time = 1*HZ;
100107 net->ipv6.sysctl.flowlabel_consistency = 1;
100108 - atomic_set(&net->ipv6.rt_genid, 0);
100109 + atomic_set_unchecked(&net->ipv6.rt_genid, 0);
100110
100111 err = ipv6_init_mibs(net);
100112 if (err)
100113 diff --git a/net/ipv6/datagram.c b/net/ipv6/datagram.c
100114 index c3bf2d2..1f00573 100644
100115 --- a/net/ipv6/datagram.c
100116 +++ b/net/ipv6/datagram.c
100117 @@ -938,5 +938,5 @@ void ip6_dgram_sock_seq_show(struct seq_file *seq, struct sock *sp,
100118 0,
100119 sock_i_ino(sp),
100120 atomic_read(&sp->sk_refcnt), sp,
100121 - atomic_read(&sp->sk_drops));
100122 + atomic_read_unchecked(&sp->sk_drops));
100123 }
100124 diff --git a/net/ipv6/icmp.c b/net/ipv6/icmp.c
100125 index 7b32652..0bc348b 100644
100126 --- a/net/ipv6/icmp.c
100127 +++ b/net/ipv6/icmp.c
100128 @@ -1005,7 +1005,7 @@ static struct ctl_table ipv6_icmp_table_template[] = {
100129
100130 struct ctl_table * __net_init ipv6_icmp_sysctl_init(struct net *net)
100131 {
100132 - struct ctl_table *table;
100133 + ctl_table_no_const *table;
100134
100135 table = kmemdup(ipv6_icmp_table_template,
100136 sizeof(ipv6_icmp_table_template),
100137 diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c
100138 index 9d92146..d986c6a 100644
100139 --- a/net/ipv6/ip6_gre.c
100140 +++ b/net/ipv6/ip6_gre.c
100141 @@ -71,7 +71,7 @@ struct ip6gre_net {
100142 struct net_device *fb_tunnel_dev;
100143 };
100144
100145 -static struct rtnl_link_ops ip6gre_link_ops __read_mostly;
100146 +static struct rtnl_link_ops ip6gre_link_ops;
100147 static int ip6gre_tunnel_init(struct net_device *dev);
100148 static void ip6gre_tunnel_setup(struct net_device *dev);
100149 static void ip6gre_tunnel_link(struct ip6gre_net *ign, struct ip6_tnl *t);
100150 @@ -1291,7 +1291,7 @@ static void ip6gre_fb_tunnel_init(struct net_device *dev)
100151 }
100152
100153
100154 -static struct inet6_protocol ip6gre_protocol __read_mostly = {
100155 +static struct inet6_protocol ip6gre_protocol = {
100156 .handler = ip6gre_rcv,
100157 .err_handler = ip6gre_err,
100158 .flags = INET6_PROTO_NOPOLICY|INET6_PROTO_FINAL,
100159 @@ -1636,7 +1636,7 @@ static const struct nla_policy ip6gre_policy[IFLA_GRE_MAX + 1] = {
100160 [IFLA_GRE_FLAGS] = { .type = NLA_U32 },
100161 };
100162
100163 -static struct rtnl_link_ops ip6gre_link_ops __read_mostly = {
100164 +static struct rtnl_link_ops ip6gre_link_ops = {
100165 .kind = "ip6gre",
100166 .maxtype = IFLA_GRE_MAX,
100167 .policy = ip6gre_policy,
100168 @@ -1650,7 +1650,7 @@ static struct rtnl_link_ops ip6gre_link_ops __read_mostly = {
100169 .fill_info = ip6gre_fill_info,
100170 };
100171
100172 -static struct rtnl_link_ops ip6gre_tap_ops __read_mostly = {
100173 +static struct rtnl_link_ops ip6gre_tap_ops = {
100174 .kind = "ip6gretap",
100175 .maxtype = IFLA_GRE_MAX,
100176 .policy = ip6gre_policy,
100177 diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c
100178 index f6a66bb..74b5aca 100644
100179 --- a/net/ipv6/ip6_tunnel.c
100180 +++ b/net/ipv6/ip6_tunnel.c
100181 @@ -85,7 +85,7 @@ static u32 HASH(const struct in6_addr *addr1, const struct in6_addr *addr2)
100182
100183 static int ip6_tnl_dev_init(struct net_device *dev);
100184 static void ip6_tnl_dev_setup(struct net_device *dev);
100185 -static struct rtnl_link_ops ip6_link_ops __read_mostly;
100186 +static struct rtnl_link_ops ip6_link_ops;
100187
100188 static int ip6_tnl_net_id __read_mostly;
100189 struct ip6_tnl_net {
100190 @@ -1707,7 +1707,7 @@ static const struct nla_policy ip6_tnl_policy[IFLA_IPTUN_MAX + 1] = {
100191 [IFLA_IPTUN_PROTO] = { .type = NLA_U8 },
100192 };
100193
100194 -static struct rtnl_link_ops ip6_link_ops __read_mostly = {
100195 +static struct rtnl_link_ops ip6_link_ops = {
100196 .kind = "ip6tnl",
100197 .maxtype = IFLA_IPTUN_MAX,
100198 .policy = ip6_tnl_policy,
100199 diff --git a/net/ipv6/ip6_vti.c b/net/ipv6/ip6_vti.c
100200 index 6cc9f93..6e5bb7c 100644
100201 --- a/net/ipv6/ip6_vti.c
100202 +++ b/net/ipv6/ip6_vti.c
100203 @@ -62,7 +62,7 @@ static u32 HASH(const struct in6_addr *addr1, const struct in6_addr *addr2)
100204
100205 static int vti6_dev_init(struct net_device *dev);
100206 static void vti6_dev_setup(struct net_device *dev);
100207 -static struct rtnl_link_ops vti6_link_ops __read_mostly;
100208 +static struct rtnl_link_ops vti6_link_ops;
100209
100210 static int vti6_net_id __read_mostly;
100211 struct vti6_net {
100212 @@ -980,7 +980,7 @@ static const struct nla_policy vti6_policy[IFLA_VTI_MAX + 1] = {
100213 [IFLA_VTI_OKEY] = { .type = NLA_U32 },
100214 };
100215
100216 -static struct rtnl_link_ops vti6_link_ops __read_mostly = {
100217 +static struct rtnl_link_ops vti6_link_ops = {
100218 .kind = "vti6",
100219 .maxtype = IFLA_VTI_MAX,
100220 .policy = vti6_policy,
100221 diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c
100222 index edb58af..78de133 100644
100223 --- a/net/ipv6/ipv6_sockglue.c
100224 +++ b/net/ipv6/ipv6_sockglue.c
100225 @@ -991,7 +991,7 @@ static int do_ipv6_getsockopt(struct sock *sk, int level, int optname,
100226 if (sk->sk_type != SOCK_STREAM)
100227 return -ENOPROTOOPT;
100228
100229 - msg.msg_control = optval;
100230 + msg.msg_control = (void __force_kernel *)optval;
100231 msg.msg_controllen = len;
100232 msg.msg_flags = flags;
100233
100234 diff --git a/net/ipv6/netfilter/ip6_tables.c b/net/ipv6/netfilter/ip6_tables.c
100235 index e080fbb..412b3cf 100644
100236 --- a/net/ipv6/netfilter/ip6_tables.c
100237 +++ b/net/ipv6/netfilter/ip6_tables.c
100238 @@ -1083,14 +1083,14 @@ static int compat_table_info(const struct xt_table_info *info,
100239 #endif
100240
100241 static int get_info(struct net *net, void __user *user,
100242 - const int *len, int compat)
100243 + int len, int compat)
100244 {
100245 char name[XT_TABLE_MAXNAMELEN];
100246 struct xt_table *t;
100247 int ret;
100248
100249 - if (*len != sizeof(struct ip6t_getinfo)) {
100250 - duprintf("length %u != %zu\n", *len,
100251 + if (len != sizeof(struct ip6t_getinfo)) {
100252 + duprintf("length %u != %zu\n", len,
100253 sizeof(struct ip6t_getinfo));
100254 return -EINVAL;
100255 }
100256 @@ -1127,7 +1127,7 @@ static int get_info(struct net *net, void __user *user,
100257 info.size = private->size;
100258 strcpy(info.name, name);
100259
100260 - if (copy_to_user(user, &info, *len) != 0)
100261 + if (copy_to_user(user, &info, len) != 0)
100262 ret = -EFAULT;
100263 else
100264 ret = 0;
100265 @@ -1983,7 +1983,7 @@ compat_do_ip6t_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
100266
100267 switch (cmd) {
100268 case IP6T_SO_GET_INFO:
100269 - ret = get_info(sock_net(sk), user, len, 1);
100270 + ret = get_info(sock_net(sk), user, *len, 1);
100271 break;
100272 case IP6T_SO_GET_ENTRIES:
100273 ret = compat_get_entries(sock_net(sk), user, len);
100274 @@ -2030,7 +2030,7 @@ do_ip6t_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
100275
100276 switch (cmd) {
100277 case IP6T_SO_GET_INFO:
100278 - ret = get_info(sock_net(sk), user, len, 0);
100279 + ret = get_info(sock_net(sk), user, *len, 0);
100280 break;
100281
100282 case IP6T_SO_GET_ENTRIES:
100283 diff --git a/net/ipv6/netfilter/nf_conntrack_reasm.c b/net/ipv6/netfilter/nf_conntrack_reasm.c
100284 index 767ab8d..c5ec70a 100644
100285 --- a/net/ipv6/netfilter/nf_conntrack_reasm.c
100286 +++ b/net/ipv6/netfilter/nf_conntrack_reasm.c
100287 @@ -90,12 +90,11 @@ static struct ctl_table nf_ct_frag6_sysctl_table[] = {
100288
100289 static int nf_ct_frag6_sysctl_register(struct net *net)
100290 {
100291 - struct ctl_table *table;
100292 + ctl_table_no_const *table = NULL;
100293 struct ctl_table_header *hdr;
100294
100295 - table = nf_ct_frag6_sysctl_table;
100296 if (!net_eq(net, &init_net)) {
100297 - table = kmemdup(table, sizeof(nf_ct_frag6_sysctl_table),
100298 + table = kmemdup(nf_ct_frag6_sysctl_table, sizeof(nf_ct_frag6_sysctl_table),
100299 GFP_KERNEL);
100300 if (table == NULL)
100301 goto err_alloc;
100302 @@ -103,9 +102,9 @@ static int nf_ct_frag6_sysctl_register(struct net *net)
100303 table[0].data = &net->nf_frag.frags.timeout;
100304 table[1].data = &net->nf_frag.frags.low_thresh;
100305 table[2].data = &net->nf_frag.frags.high_thresh;
100306 - }
100307 -
100308 - hdr = register_net_sysctl(net, "net/netfilter", table);
100309 + hdr = register_net_sysctl(net, "net/netfilter", table);
100310 + } else
100311 + hdr = register_net_sysctl(net, "net/netfilter", nf_ct_frag6_sysctl_table);
100312 if (hdr == NULL)
100313 goto err_reg;
100314
100315 @@ -113,8 +112,7 @@ static int nf_ct_frag6_sysctl_register(struct net *net)
100316 return 0;
100317
100318 err_reg:
100319 - if (!net_eq(net, &init_net))
100320 - kfree(table);
100321 + kfree(table);
100322 err_alloc:
100323 return -ENOMEM;
100324 }
100325 diff --git a/net/ipv6/output_core.c b/net/ipv6/output_core.c
100326 index 56596ce..c734618 100644
100327 --- a/net/ipv6/output_core.c
100328 +++ b/net/ipv6/output_core.c
100329 @@ -10,7 +10,7 @@
100330
100331 void ipv6_select_ident(struct frag_hdr *fhdr, struct rt6_info *rt)
100332 {
100333 - static atomic_t ipv6_fragmentation_id;
100334 + static atomic_unchecked_t ipv6_fragmentation_id;
100335 struct in6_addr addr;
100336 int ident;
100337
100338 @@ -26,7 +26,7 @@ void ipv6_select_ident(struct frag_hdr *fhdr, struct rt6_info *rt)
100339 return;
100340 }
100341 #endif
100342 - ident = atomic_inc_return(&ipv6_fragmentation_id);
100343 + ident = atomic_inc_return_unchecked(&ipv6_fragmentation_id);
100344
100345 addr = rt->rt6i_dst.addr;
100346 addr.s6_addr32[0] ^= (__force __be32)ident;
100347 diff --git a/net/ipv6/ping.c b/net/ipv6/ping.c
100348 index bda7429..469b26b 100644
100349 --- a/net/ipv6/ping.c
100350 +++ b/net/ipv6/ping.c
100351 @@ -246,6 +246,24 @@ static struct pernet_operations ping_v6_net_ops = {
100352 };
100353 #endif
100354
100355 +static struct pingv6_ops real_pingv6_ops = {
100356 + .ipv6_recv_error = ipv6_recv_error,
100357 + .ip6_datagram_recv_common_ctl = ip6_datagram_recv_common_ctl,
100358 + .ip6_datagram_recv_specific_ctl = ip6_datagram_recv_specific_ctl,
100359 + .icmpv6_err_convert = icmpv6_err_convert,
100360 + .ipv6_icmp_error = ipv6_icmp_error,
100361 + .ipv6_chk_addr = ipv6_chk_addr,
100362 +};
100363 +
100364 +static struct pingv6_ops dummy_pingv6_ops = {
100365 + .ipv6_recv_error = dummy_ipv6_recv_error,
100366 + .ip6_datagram_recv_common_ctl = dummy_ip6_datagram_recv_ctl,
100367 + .ip6_datagram_recv_specific_ctl = dummy_ip6_datagram_recv_ctl,
100368 + .icmpv6_err_convert = dummy_icmpv6_err_convert,
100369 + .ipv6_icmp_error = dummy_ipv6_icmp_error,
100370 + .ipv6_chk_addr = dummy_ipv6_chk_addr,
100371 +};
100372 +
100373 int __init pingv6_init(void)
100374 {
100375 #ifdef CONFIG_PROC_FS
100376 @@ -253,13 +271,7 @@ int __init pingv6_init(void)
100377 if (ret)
100378 return ret;
100379 #endif
100380 - pingv6_ops.ipv6_recv_error = ipv6_recv_error;
100381 - pingv6_ops.ip6_datagram_recv_common_ctl = ip6_datagram_recv_common_ctl;
100382 - pingv6_ops.ip6_datagram_recv_specific_ctl =
100383 - ip6_datagram_recv_specific_ctl;
100384 - pingv6_ops.icmpv6_err_convert = icmpv6_err_convert;
100385 - pingv6_ops.ipv6_icmp_error = ipv6_icmp_error;
100386 - pingv6_ops.ipv6_chk_addr = ipv6_chk_addr;
100387 + pingv6_ops = &real_pingv6_ops;
100388 return inet6_register_protosw(&pingv6_protosw);
100389 }
100390
100391 @@ -268,14 +280,9 @@ int __init pingv6_init(void)
100392 */
100393 void pingv6_exit(void)
100394 {
100395 - pingv6_ops.ipv6_recv_error = dummy_ipv6_recv_error;
100396 - pingv6_ops.ip6_datagram_recv_common_ctl = dummy_ip6_datagram_recv_ctl;
100397 - pingv6_ops.ip6_datagram_recv_specific_ctl = dummy_ip6_datagram_recv_ctl;
100398 - pingv6_ops.icmpv6_err_convert = dummy_icmpv6_err_convert;
100399 - pingv6_ops.ipv6_icmp_error = dummy_ipv6_icmp_error;
100400 - pingv6_ops.ipv6_chk_addr = dummy_ipv6_chk_addr;
100401 #ifdef CONFIG_PROC_FS
100402 unregister_pernet_subsys(&ping_v6_net_ops);
100403 #endif
100404 + pingv6_ops = &dummy_pingv6_ops;
100405 inet6_unregister_protosw(&pingv6_protosw);
100406 }
100407 diff --git a/net/ipv6/proc.c b/net/ipv6/proc.c
100408 index 091d066..139d410 100644
100409 --- a/net/ipv6/proc.c
100410 +++ b/net/ipv6/proc.c
100411 @@ -309,7 +309,7 @@ static int __net_init ipv6_proc_init_net(struct net *net)
100412 if (!proc_create("snmp6", S_IRUGO, net->proc_net, &snmp6_seq_fops))
100413 goto proc_snmp6_fail;
100414
100415 - net->mib.proc_net_devsnmp6 = proc_mkdir("dev_snmp6", net->proc_net);
100416 + net->mib.proc_net_devsnmp6 = proc_mkdir_restrict("dev_snmp6", net->proc_net);
100417 if (!net->mib.proc_net_devsnmp6)
100418 goto proc_dev_snmp6_fail;
100419 return 0;
100420 diff --git a/net/ipv6/raw.c b/net/ipv6/raw.c
100421 index 1f29996..46fe0c7 100644
100422 --- a/net/ipv6/raw.c
100423 +++ b/net/ipv6/raw.c
100424 @@ -388,7 +388,7 @@ static inline int rawv6_rcv_skb(struct sock *sk, struct sk_buff *skb)
100425 {
100426 if ((raw6_sk(sk)->checksum || rcu_access_pointer(sk->sk_filter)) &&
100427 skb_checksum_complete(skb)) {
100428 - atomic_inc(&sk->sk_drops);
100429 + atomic_inc_unchecked(&sk->sk_drops);
100430 kfree_skb(skb);
100431 return NET_RX_DROP;
100432 }
100433 @@ -416,7 +416,7 @@ int rawv6_rcv(struct sock *sk, struct sk_buff *skb)
100434 struct raw6_sock *rp = raw6_sk(sk);
100435
100436 if (!xfrm6_policy_check(sk, XFRM_POLICY_IN, skb)) {
100437 - atomic_inc(&sk->sk_drops);
100438 + atomic_inc_unchecked(&sk->sk_drops);
100439 kfree_skb(skb);
100440 return NET_RX_DROP;
100441 }
100442 @@ -440,7 +440,7 @@ int rawv6_rcv(struct sock *sk, struct sk_buff *skb)
100443
100444 if (inet->hdrincl) {
100445 if (skb_checksum_complete(skb)) {
100446 - atomic_inc(&sk->sk_drops);
100447 + atomic_inc_unchecked(&sk->sk_drops);
100448 kfree_skb(skb);
100449 return NET_RX_DROP;
100450 }
100451 @@ -469,6 +469,9 @@ static int rawv6_recvmsg(struct kiocb *iocb, struct sock *sk,
100452 if (flags & MSG_OOB)
100453 return -EOPNOTSUPP;
100454
100455 + if (addr_len)
100456 + *addr_len=sizeof(*sin6);
100457 +
100458 if (flags & MSG_ERRQUEUE)
100459 return ipv6_recv_error(sk, msg, len, addr_len);
100460
100461 @@ -507,7 +510,6 @@ static int rawv6_recvmsg(struct kiocb *iocb, struct sock *sk,
100462 sin6->sin6_flowinfo = 0;
100463 sin6->sin6_scope_id = ipv6_iface_scope_id(&sin6->sin6_addr,
100464 IP6CB(skb)->iif);
100465 - *addr_len = sizeof(*sin6);
100466 }
100467
100468 sock_recv_ts_and_drops(msg, sk, skb);
100469 @@ -610,7 +612,7 @@ out:
100470 return err;
100471 }
100472
100473 -static int rawv6_send_hdrinc(struct sock *sk, void *from, int length,
100474 +static int rawv6_send_hdrinc(struct sock *sk, void *from, unsigned int length,
100475 struct flowi6 *fl6, struct dst_entry **dstp,
100476 unsigned int flags)
100477 {
100478 @@ -922,12 +924,15 @@ do_confirm:
100479 static int rawv6_seticmpfilter(struct sock *sk, int level, int optname,
100480 char __user *optval, int optlen)
100481 {
100482 + struct icmp6_filter filter;
100483 +
100484 switch (optname) {
100485 case ICMPV6_FILTER:
100486 if (optlen > sizeof(struct icmp6_filter))
100487 optlen = sizeof(struct icmp6_filter);
100488 - if (copy_from_user(&raw6_sk(sk)->filter, optval, optlen))
100489 + if (copy_from_user(&filter, optval, optlen))
100490 return -EFAULT;
100491 + raw6_sk(sk)->filter = filter;
100492 return 0;
100493 default:
100494 return -ENOPROTOOPT;
100495 @@ -940,6 +945,7 @@ static int rawv6_geticmpfilter(struct sock *sk, int level, int optname,
100496 char __user *optval, int __user *optlen)
100497 {
100498 int len;
100499 + struct icmp6_filter filter;
100500
100501 switch (optname) {
100502 case ICMPV6_FILTER:
100503 @@ -951,7 +957,8 @@ static int rawv6_geticmpfilter(struct sock *sk, int level, int optname,
100504 len = sizeof(struct icmp6_filter);
100505 if (put_user(len, optlen))
100506 return -EFAULT;
100507 - if (copy_to_user(optval, &raw6_sk(sk)->filter, len))
100508 + filter = raw6_sk(sk)->filter;
100509 + if (len > sizeof filter || copy_to_user(optval, &filter, len))
100510 return -EFAULT;
100511 return 0;
100512 default:
100513 diff --git a/net/ipv6/reassembly.c b/net/ipv6/reassembly.c
100514 index cc85a9b..526a133 100644
100515 --- a/net/ipv6/reassembly.c
100516 +++ b/net/ipv6/reassembly.c
100517 @@ -626,12 +626,11 @@ static struct ctl_table ip6_frags_ctl_table[] = {
100518
100519 static int __net_init ip6_frags_ns_sysctl_register(struct net *net)
100520 {
100521 - struct ctl_table *table;
100522 + ctl_table_no_const *table = NULL;
100523 struct ctl_table_header *hdr;
100524
100525 - table = ip6_frags_ns_ctl_table;
100526 if (!net_eq(net, &init_net)) {
100527 - table = kmemdup(table, sizeof(ip6_frags_ns_ctl_table), GFP_KERNEL);
100528 + table = kmemdup(ip6_frags_ns_ctl_table, sizeof(ip6_frags_ns_ctl_table), GFP_KERNEL);
100529 if (table == NULL)
100530 goto err_alloc;
100531
100532 @@ -642,9 +641,10 @@ static int __net_init ip6_frags_ns_sysctl_register(struct net *net)
100533 /* Don't export sysctls to unprivileged users */
100534 if (net->user_ns != &init_user_ns)
100535 table[0].procname = NULL;
100536 - }
100537 + hdr = register_net_sysctl(net, "net/ipv6", table);
100538 + } else
100539 + hdr = register_net_sysctl(net, "net/ipv6", ip6_frags_ns_ctl_table);
100540
100541 - hdr = register_net_sysctl(net, "net/ipv6", table);
100542 if (hdr == NULL)
100543 goto err_reg;
100544
100545 @@ -652,8 +652,7 @@ static int __net_init ip6_frags_ns_sysctl_register(struct net *net)
100546 return 0;
100547
100548 err_reg:
100549 - if (!net_eq(net, &init_net))
100550 - kfree(table);
100551 + kfree(table);
100552 err_alloc:
100553 return -ENOMEM;
100554 }
100555 diff --git a/net/ipv6/route.c b/net/ipv6/route.c
100556 index 6ebdb7b6..f225ab1 100644
100557 --- a/net/ipv6/route.c
100558 +++ b/net/ipv6/route.c
100559 @@ -2971,7 +2971,7 @@ struct ctl_table ipv6_route_table_template[] = {
100560
100561 struct ctl_table * __net_init ipv6_route_sysctl_init(struct net *net)
100562 {
100563 - struct ctl_table *table;
100564 + ctl_table_no_const *table;
100565
100566 table = kmemdup(ipv6_route_table_template,
100567 sizeof(ipv6_route_table_template),
100568 diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c
100569 index e5a453c..237ce95 100644
100570 --- a/net/ipv6/sit.c
100571 +++ b/net/ipv6/sit.c
100572 @@ -74,7 +74,7 @@ static void ipip6_tunnel_setup(struct net_device *dev);
100573 static void ipip6_dev_free(struct net_device *dev);
100574 static bool check_6rd(struct ip_tunnel *tunnel, const struct in6_addr *v6dst,
100575 __be32 *v4dst);
100576 -static struct rtnl_link_ops sit_link_ops __read_mostly;
100577 +static struct rtnl_link_ops sit_link_ops;
100578
100579 static int sit_net_id __read_mostly;
100580 struct sit_net {
100581 @@ -1661,7 +1661,7 @@ static void ipip6_dellink(struct net_device *dev, struct list_head *head)
100582 unregister_netdevice_queue(dev, head);
100583 }
100584
100585 -static struct rtnl_link_ops sit_link_ops __read_mostly = {
100586 +static struct rtnl_link_ops sit_link_ops = {
100587 .kind = "sit",
100588 .maxtype = IFLA_IPTUN_MAX,
100589 .policy = ipip6_policy,
100590 diff --git a/net/ipv6/sysctl_net_ipv6.c b/net/ipv6/sysctl_net_ipv6.c
100591 index 7f405a1..eabef92 100644
100592 --- a/net/ipv6/sysctl_net_ipv6.c
100593 +++ b/net/ipv6/sysctl_net_ipv6.c
100594 @@ -54,7 +54,7 @@ static struct ctl_table ipv6_rotable[] = {
100595
100596 static int __net_init ipv6_sysctl_net_init(struct net *net)
100597 {
100598 - struct ctl_table *ipv6_table;
100599 + ctl_table_no_const *ipv6_table;
100600 struct ctl_table *ipv6_route_table;
100601 struct ctl_table *ipv6_icmp_table;
100602 int err;
100603 diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
100604 index e289830..79a5718 100644
100605 --- a/net/ipv6/tcp_ipv6.c
100606 +++ b/net/ipv6/tcp_ipv6.c
100607 @@ -102,6 +102,10 @@ static void inet6_sk_rx_dst_set(struct sock *sk, const struct sk_buff *skb)
100608 inet6_sk(sk)->rx_dst_cookie = rt->rt6i_node->fn_sernum;
100609 }
100610
100611 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
100612 +extern int grsec_enable_blackhole;
100613 +#endif
100614 +
100615 static void tcp_v6_hash(struct sock *sk)
100616 {
100617 if (sk->sk_state != TCP_CLOSE) {
100618 @@ -1416,6 +1420,9 @@ static int tcp_v6_do_rcv(struct sock *sk, struct sk_buff *skb)
100619 return 0;
100620
100621 reset:
100622 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
100623 + if (!grsec_enable_blackhole)
100624 +#endif
100625 tcp_v6_send_reset(sk, skb);
100626 discard:
100627 if (opt_skb)
100628 @@ -1500,12 +1507,20 @@ static int tcp_v6_rcv(struct sk_buff *skb)
100629 TCP_SKB_CB(skb)->sacked = 0;
100630
100631 sk = __inet6_lookup_skb(&tcp_hashinfo, skb, th->source, th->dest);
100632 - if (!sk)
100633 + if (!sk) {
100634 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
100635 + ret = 1;
100636 +#endif
100637 goto no_tcp_socket;
100638 + }
100639
100640 process:
100641 - if (sk->sk_state == TCP_TIME_WAIT)
100642 + if (sk->sk_state == TCP_TIME_WAIT) {
100643 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
100644 + ret = 2;
100645 +#endif
100646 goto do_time_wait;
100647 + }
100648
100649 if (hdr->hop_limit < inet6_sk(sk)->min_hopcount) {
100650 NET_INC_STATS_BH(net, LINUX_MIB_TCPMINTTLDROP);
100651 @@ -1557,6 +1572,10 @@ csum_error:
100652 bad_packet:
100653 TCP_INC_STATS_BH(net, TCP_MIB_INERRS);
100654 } else {
100655 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
100656 + if (!grsec_enable_blackhole || (ret == 1 &&
100657 + (skb->dev->flags & IFF_LOOPBACK)))
100658 +#endif
100659 tcp_v6_send_reset(NULL, skb);
100660 }
100661
100662 diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
100663 index 1e586d9..384a9c9 100644
100664 --- a/net/ipv6/udp.c
100665 +++ b/net/ipv6/udp.c
100666 @@ -76,6 +76,10 @@ static unsigned int udp6_ehashfn(struct net *net,
100667 udp_ipv6_hash_secret + net_hash_mix(net));
100668 }
100669
100670 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
100671 +extern int grsec_enable_blackhole;
100672 +#endif
100673 +
100674 int ipv6_rcv_saddr_equal(const struct sock *sk, const struct sock *sk2)
100675 {
100676 const struct in6_addr *sk2_rcv_saddr6 = inet6_rcv_saddr(sk2);
100677 @@ -392,6 +396,9 @@ int udpv6_recvmsg(struct kiocb *iocb, struct sock *sk,
100678 int is_udp4;
100679 bool slow;
100680
100681 + if (addr_len)
100682 + *addr_len = sizeof(struct sockaddr_in6);
100683 +
100684 if (flags & MSG_ERRQUEUE)
100685 return ipv6_recv_error(sk, msg, len, addr_len);
100686
100687 @@ -435,7 +442,7 @@ try_again:
100688 if (unlikely(err)) {
100689 trace_kfree_skb(skb, udpv6_recvmsg);
100690 if (!peeked) {
100691 - atomic_inc(&sk->sk_drops);
100692 + atomic_inc_unchecked(&sk->sk_drops);
100693 if (is_udp4)
100694 UDP_INC_STATS_USER(sock_net(sk),
100695 UDP_MIB_INERRORS,
100696 @@ -475,7 +482,7 @@ try_again:
100697 ipv6_iface_scope_id(&sin6->sin6_addr,
100698 IP6CB(skb)->iif);
100699 }
100700 - *addr_len = sizeof(*sin6);
100701 +
100702 }
100703
100704 if (np->rxopt.all)
100705 @@ -690,7 +697,7 @@ csum_error:
100706 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_CSUMERRORS, is_udplite);
100707 drop:
100708 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS, is_udplite);
100709 - atomic_inc(&sk->sk_drops);
100710 + atomic_inc_unchecked(&sk->sk_drops);
100711 kfree_skb(skb);
100712 return -1;
100713 }
100714 @@ -747,7 +754,7 @@ static void flush_stack(struct sock **stack, unsigned int count,
100715 if (likely(skb1 == NULL))
100716 skb1 = (i == final) ? skb : skb_clone(skb, GFP_ATOMIC);
100717 if (!skb1) {
100718 - atomic_inc(&sk->sk_drops);
100719 + atomic_inc_unchecked(&sk->sk_drops);
100720 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_RCVBUFERRORS,
100721 IS_UDPLITE(sk));
100722 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS,
100723 @@ -886,6 +893,9 @@ int __udp6_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
100724 goto csum_error;
100725
100726 UDP6_INC_STATS_BH(net, UDP_MIB_NOPORTS, proto == IPPROTO_UDPLITE);
100727 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
100728 + if (!grsec_enable_blackhole || (skb->dev->flags & IFF_LOOPBACK))
100729 +#endif
100730 icmpv6_send(skb, ICMPV6_DEST_UNREACH, ICMPV6_PORT_UNREACH, 0);
100731
100732 kfree_skb(skb);
100733 diff --git a/net/ipv6/xfrm6_policy.c b/net/ipv6/xfrm6_policy.c
100734 index 2a0bbda..d75ca57 100644
100735 --- a/net/ipv6/xfrm6_policy.c
100736 +++ b/net/ipv6/xfrm6_policy.c
100737 @@ -212,11 +212,11 @@ _decode_session6(struct sk_buff *skb, struct flowi *fl, int reverse)
100738 }
100739 }
100740
100741 -static inline int xfrm6_garbage_collect(struct dst_ops *ops)
100742 +static int xfrm6_garbage_collect(struct dst_ops *ops)
100743 {
100744 struct net *net = container_of(ops, struct net, xfrm.xfrm6_dst_ops);
100745
100746 - xfrm6_policy_afinfo.garbage_collect(net);
100747 + xfrm_garbage_collect_deferred(net);
100748 return dst_entries_get_fast(ops) > ops->gc_thresh * 2;
100749 }
100750
100751 @@ -329,19 +329,19 @@ static struct ctl_table xfrm6_policy_table[] = {
100752
100753 static int __net_init xfrm6_net_init(struct net *net)
100754 {
100755 - struct ctl_table *table;
100756 + ctl_table_no_const *table = NULL;
100757 struct ctl_table_header *hdr;
100758
100759 - table = xfrm6_policy_table;
100760 if (!net_eq(net, &init_net)) {
100761 - table = kmemdup(table, sizeof(xfrm6_policy_table), GFP_KERNEL);
100762 + table = kmemdup(xfrm6_policy_table, sizeof(xfrm6_policy_table), GFP_KERNEL);
100763 if (!table)
100764 goto err_alloc;
100765
100766 table[0].data = &net->xfrm.xfrm6_dst_ops.gc_thresh;
100767 - }
100768 + hdr = register_net_sysctl(net, "net/ipv6", table);
100769 + } else
100770 + hdr = register_net_sysctl(net, "net/ipv6", xfrm6_policy_table);
100771
100772 - hdr = register_net_sysctl(net, "net/ipv6", table);
100773 if (!hdr)
100774 goto err_reg;
100775
100776 @@ -349,8 +349,7 @@ static int __net_init xfrm6_net_init(struct net *net)
100777 return 0;
100778
100779 err_reg:
100780 - if (!net_eq(net, &init_net))
100781 - kfree(table);
100782 + kfree(table);
100783 err_alloc:
100784 return -ENOMEM;
100785 }
100786 diff --git a/net/ipx/ipx_proc.c b/net/ipx/ipx_proc.c
100787 index e15c16a..7cf07aa 100644
100788 --- a/net/ipx/ipx_proc.c
100789 +++ b/net/ipx/ipx_proc.c
100790 @@ -289,7 +289,7 @@ int __init ipx_proc_init(void)
100791 struct proc_dir_entry *p;
100792 int rc = -ENOMEM;
100793
100794 - ipx_proc_dir = proc_mkdir("ipx", init_net.proc_net);
100795 + ipx_proc_dir = proc_mkdir_restrict("ipx", init_net.proc_net);
100796
100797 if (!ipx_proc_dir)
100798 goto out;
100799 diff --git a/net/irda/ircomm/ircomm_tty.c b/net/irda/ircomm/ircomm_tty.c
100800 index 2ba8b97..6d33010 100644
100801 --- a/net/irda/ircomm/ircomm_tty.c
100802 +++ b/net/irda/ircomm/ircomm_tty.c
100803 @@ -317,11 +317,11 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
100804 add_wait_queue(&port->open_wait, &wait);
100805
100806 IRDA_DEBUG(2, "%s(%d):block_til_ready before block on %s open_count=%d\n",
100807 - __FILE__, __LINE__, tty->driver->name, port->count);
100808 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
100809
100810 spin_lock_irqsave(&port->lock, flags);
100811 if (!tty_hung_up_p(filp))
100812 - port->count--;
100813 + atomic_dec(&port->count);
100814 port->blocked_open++;
100815 spin_unlock_irqrestore(&port->lock, flags);
100816
100817 @@ -356,7 +356,7 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
100818 }
100819
100820 IRDA_DEBUG(1, "%s(%d):block_til_ready blocking on %s open_count=%d\n",
100821 - __FILE__, __LINE__, tty->driver->name, port->count);
100822 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
100823
100824 schedule();
100825 }
100826 @@ -366,12 +366,12 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
100827
100828 spin_lock_irqsave(&port->lock, flags);
100829 if (!tty_hung_up_p(filp))
100830 - port->count++;
100831 + atomic_inc(&port->count);
100832 port->blocked_open--;
100833 spin_unlock_irqrestore(&port->lock, flags);
100834
100835 IRDA_DEBUG(1, "%s(%d):block_til_ready after blocking on %s open_count=%d\n",
100836 - __FILE__, __LINE__, tty->driver->name, port->count);
100837 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
100838
100839 if (!retval)
100840 port->flags |= ASYNC_NORMAL_ACTIVE;
100841 @@ -445,12 +445,12 @@ static int ircomm_tty_open(struct tty_struct *tty, struct file *filp)
100842
100843 /* ++ is not atomic, so this should be protected - Jean II */
100844 spin_lock_irqsave(&self->port.lock, flags);
100845 - self->port.count++;
100846 + atomic_inc(&self->port.count);
100847 spin_unlock_irqrestore(&self->port.lock, flags);
100848 tty_port_tty_set(&self->port, tty);
100849
100850 IRDA_DEBUG(1, "%s(), %s%d, count = %d\n", __func__ , tty->driver->name,
100851 - self->line, self->port.count);
100852 + self->line, atomic_read(&self->port.count));
100853
100854 /* Not really used by us, but lets do it anyway */
100855 self->port.low_latency = (self->port.flags & ASYNC_LOW_LATENCY) ? 1 : 0;
100856 @@ -987,7 +987,7 @@ static void ircomm_tty_hangup(struct tty_struct *tty)
100857 tty_kref_put(port->tty);
100858 }
100859 port->tty = NULL;
100860 - port->count = 0;
100861 + atomic_set(&port->count, 0);
100862 spin_unlock_irqrestore(&port->lock, flags);
100863
100864 wake_up_interruptible(&port->open_wait);
100865 @@ -1344,7 +1344,7 @@ static void ircomm_tty_line_info(struct ircomm_tty_cb *self, struct seq_file *m)
100866 seq_putc(m, '\n');
100867
100868 seq_printf(m, "Role: %s\n", self->client ? "client" : "server");
100869 - seq_printf(m, "Open count: %d\n", self->port.count);
100870 + seq_printf(m, "Open count: %d\n", atomic_read(&self->port.count));
100871 seq_printf(m, "Max data size: %d\n", self->max_data_size);
100872 seq_printf(m, "Max header size: %d\n", self->max_header_size);
100873
100874 diff --git a/net/irda/irproc.c b/net/irda/irproc.c
100875 index b9ac598..f88cc56 100644
100876 --- a/net/irda/irproc.c
100877 +++ b/net/irda/irproc.c
100878 @@ -66,7 +66,7 @@ void __init irda_proc_register(void)
100879 {
100880 int i;
100881
100882 - proc_irda = proc_mkdir("irda", init_net.proc_net);
100883 + proc_irda = proc_mkdir_restrict("irda", init_net.proc_net);
100884 if (proc_irda == NULL)
100885 return;
100886
100887 diff --git a/net/iucv/af_iucv.c b/net/iucv/af_iucv.c
100888 index 8c9d730..66c6305 100644
100889 --- a/net/iucv/af_iucv.c
100890 +++ b/net/iucv/af_iucv.c
100891 @@ -773,10 +773,10 @@ static int iucv_sock_autobind(struct sock *sk)
100892
100893 write_lock_bh(&iucv_sk_list.lock);
100894
100895 - sprintf(name, "%08x", atomic_inc_return(&iucv_sk_list.autobind_name));
100896 + sprintf(name, "%08x", atomic_inc_return_unchecked(&iucv_sk_list.autobind_name));
100897 while (__iucv_get_sock_by_name(name)) {
100898 sprintf(name, "%08x",
100899 - atomic_inc_return(&iucv_sk_list.autobind_name));
100900 + atomic_inc_return_unchecked(&iucv_sk_list.autobind_name));
100901 }
100902
100903 write_unlock_bh(&iucv_sk_list.lock);
100904 diff --git a/net/iucv/iucv.c b/net/iucv/iucv.c
100905 index da78793..bdd78cf 100644
100906 --- a/net/iucv/iucv.c
100907 +++ b/net/iucv/iucv.c
100908 @@ -702,7 +702,7 @@ static int iucv_cpu_notify(struct notifier_block *self,
100909 return NOTIFY_OK;
100910 }
100911
100912 -static struct notifier_block __refdata iucv_cpu_notifier = {
100913 +static struct notifier_block iucv_cpu_notifier = {
100914 .notifier_call = iucv_cpu_notify,
100915 };
100916
100917 diff --git a/net/key/af_key.c b/net/key/af_key.c
100918 index f3c8307..7127791 100644
100919 --- a/net/key/af_key.c
100920 +++ b/net/key/af_key.c
100921 @@ -3070,10 +3070,10 @@ static int pfkey_send_policy_notify(struct xfrm_policy *xp, int dir, const struc
100922 static u32 get_acqseq(void)
100923 {
100924 u32 res;
100925 - static atomic_t acqseq;
100926 + static atomic_unchecked_t acqseq;
100927
100928 do {
100929 - res = atomic_inc_return(&acqseq);
100930 + res = atomic_inc_return_unchecked(&acqseq);
100931 } while (!res);
100932 return res;
100933 }
100934 diff --git a/net/l2tp/l2tp_eth.c b/net/l2tp/l2tp_eth.c
100935 index 76125c5..e474828 100644
100936 --- a/net/l2tp/l2tp_eth.c
100937 +++ b/net/l2tp/l2tp_eth.c
100938 @@ -42,12 +42,12 @@ struct l2tp_eth {
100939 struct sock *tunnel_sock;
100940 struct l2tp_session *session;
100941 struct list_head list;
100942 - atomic_long_t tx_bytes;
100943 - atomic_long_t tx_packets;
100944 - atomic_long_t tx_dropped;
100945 - atomic_long_t rx_bytes;
100946 - atomic_long_t rx_packets;
100947 - atomic_long_t rx_errors;
100948 + atomic_long_unchecked_t tx_bytes;
100949 + atomic_long_unchecked_t tx_packets;
100950 + atomic_long_unchecked_t tx_dropped;
100951 + atomic_long_unchecked_t rx_bytes;
100952 + atomic_long_unchecked_t rx_packets;
100953 + atomic_long_unchecked_t rx_errors;
100954 };
100955
100956 /* via l2tp_session_priv() */
100957 @@ -98,10 +98,10 @@ static int l2tp_eth_dev_xmit(struct sk_buff *skb, struct net_device *dev)
100958 int ret = l2tp_xmit_skb(session, skb, session->hdr_len);
100959
100960 if (likely(ret == NET_XMIT_SUCCESS)) {
100961 - atomic_long_add(len, &priv->tx_bytes);
100962 - atomic_long_inc(&priv->tx_packets);
100963 + atomic_long_add_unchecked(len, &priv->tx_bytes);
100964 + atomic_long_inc_unchecked(&priv->tx_packets);
100965 } else {
100966 - atomic_long_inc(&priv->tx_dropped);
100967 + atomic_long_inc_unchecked(&priv->tx_dropped);
100968 }
100969 return NETDEV_TX_OK;
100970 }
100971 @@ -111,12 +111,12 @@ static struct rtnl_link_stats64 *l2tp_eth_get_stats64(struct net_device *dev,
100972 {
100973 struct l2tp_eth *priv = netdev_priv(dev);
100974
100975 - stats->tx_bytes = atomic_long_read(&priv->tx_bytes);
100976 - stats->tx_packets = atomic_long_read(&priv->tx_packets);
100977 - stats->tx_dropped = atomic_long_read(&priv->tx_dropped);
100978 - stats->rx_bytes = atomic_long_read(&priv->rx_bytes);
100979 - stats->rx_packets = atomic_long_read(&priv->rx_packets);
100980 - stats->rx_errors = atomic_long_read(&priv->rx_errors);
100981 + stats->tx_bytes = atomic_long_read_unchecked(&priv->tx_bytes);
100982 + stats->tx_packets = atomic_long_read_unchecked(&priv->tx_packets);
100983 + stats->tx_dropped = atomic_long_read_unchecked(&priv->tx_dropped);
100984 + stats->rx_bytes = atomic_long_read_unchecked(&priv->rx_bytes);
100985 + stats->rx_packets = atomic_long_read_unchecked(&priv->rx_packets);
100986 + stats->rx_errors = atomic_long_read_unchecked(&priv->rx_errors);
100987 return stats;
100988 }
100989
100990 @@ -166,15 +166,15 @@ static void l2tp_eth_dev_recv(struct l2tp_session *session, struct sk_buff *skb,
100991 nf_reset(skb);
100992
100993 if (dev_forward_skb(dev, skb) == NET_RX_SUCCESS) {
100994 - atomic_long_inc(&priv->rx_packets);
100995 - atomic_long_add(data_len, &priv->rx_bytes);
100996 + atomic_long_inc_unchecked(&priv->rx_packets);
100997 + atomic_long_add_unchecked(data_len, &priv->rx_bytes);
100998 } else {
100999 - atomic_long_inc(&priv->rx_errors);
101000 + atomic_long_inc_unchecked(&priv->rx_errors);
101001 }
101002 return;
101003
101004 error:
101005 - atomic_long_inc(&priv->rx_errors);
101006 + atomic_long_inc_unchecked(&priv->rx_errors);
101007 kfree_skb(skb);
101008 }
101009
101010 diff --git a/net/l2tp/l2tp_ip.c b/net/l2tp/l2tp_ip.c
101011 index 3397fe6..861fd1a 100644
101012 --- a/net/l2tp/l2tp_ip.c
101013 +++ b/net/l2tp/l2tp_ip.c
101014 @@ -518,6 +518,9 @@ static int l2tp_ip_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *m
101015 if (flags & MSG_OOB)
101016 goto out;
101017
101018 + if (addr_len)
101019 + *addr_len = sizeof(*sin);
101020 +
101021 skb = skb_recv_datagram(sk, flags, noblock, &err);
101022 if (!skb)
101023 goto out;
101024 @@ -540,7 +543,6 @@ static int l2tp_ip_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *m
101025 sin->sin_addr.s_addr = ip_hdr(skb)->saddr;
101026 sin->sin_port = 0;
101027 memset(&sin->sin_zero, 0, sizeof(sin->sin_zero));
101028 - *addr_len = sizeof(*sin);
101029 }
101030 if (inet->cmsg_flags)
101031 ip_cmsg_recv(msg, skb);
101032 diff --git a/net/llc/llc_proc.c b/net/llc/llc_proc.c
101033 index 1a3c7e0..80f8b0c 100644
101034 --- a/net/llc/llc_proc.c
101035 +++ b/net/llc/llc_proc.c
101036 @@ -247,7 +247,7 @@ int __init llc_proc_init(void)
101037 int rc = -ENOMEM;
101038 struct proc_dir_entry *p;
101039
101040 - llc_proc_dir = proc_mkdir("llc", init_net.proc_net);
101041 + llc_proc_dir = proc_mkdir_restrict("llc", init_net.proc_net);
101042 if (!llc_proc_dir)
101043 goto out;
101044
101045 diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
101046 index aaa59d7..21a2c4a 100644
101047 --- a/net/mac80211/cfg.c
101048 +++ b/net/mac80211/cfg.c
101049 @@ -839,7 +839,7 @@ static int ieee80211_set_monitor_channel(struct wiphy *wiphy,
101050 ret = ieee80211_vif_use_channel(sdata, chandef,
101051 IEEE80211_CHANCTX_EXCLUSIVE);
101052 }
101053 - } else if (local->open_count == local->monitors) {
101054 + } else if (local_read(&local->open_count) == local->monitors) {
101055 local->_oper_chandef = *chandef;
101056 ieee80211_hw_config(local, 0);
101057 }
101058 @@ -3440,7 +3440,7 @@ static void ieee80211_mgmt_frame_register(struct wiphy *wiphy,
101059 else
101060 local->probe_req_reg--;
101061
101062 - if (!local->open_count)
101063 + if (!local_read(&local->open_count))
101064 break;
101065
101066 ieee80211_queue_work(&local->hw, &local->reconfig_filter);
101067 @@ -3903,8 +3903,8 @@ static int ieee80211_cfg_get_channel(struct wiphy *wiphy,
101068 if (chanctx_conf) {
101069 *chandef = chanctx_conf->def;
101070 ret = 0;
101071 - } else if (local->open_count > 0 &&
101072 - local->open_count == local->monitors &&
101073 + } else if (local_read(&local->open_count) > 0 &&
101074 + local_read(&local->open_count) == local->monitors &&
101075 sdata->vif.type == NL80211_IFTYPE_MONITOR) {
101076 if (local->use_chanctx)
101077 *chandef = local->monitor_chandef;
101078 diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h
101079 index f169b6e..a5dc4eb 100644
101080 --- a/net/mac80211/ieee80211_i.h
101081 +++ b/net/mac80211/ieee80211_i.h
101082 @@ -28,6 +28,7 @@
101083 #include <net/ieee80211_radiotap.h>
101084 #include <net/cfg80211.h>
101085 #include <net/mac80211.h>
101086 +#include <asm/local.h>
101087 #include "key.h"
101088 #include "sta_info.h"
101089 #include "debug.h"
101090 @@ -999,7 +1000,7 @@ struct ieee80211_local {
101091 /* also used to protect ampdu_ac_queue and amdpu_ac_stop_refcnt */
101092 spinlock_t queue_stop_reason_lock;
101093
101094 - int open_count;
101095 + local_t open_count;
101096 int monitors, cooked_mntrs;
101097 /* number of interfaces with corresponding FIF_ flags */
101098 int fif_fcsfail, fif_plcpfail, fif_control, fif_other_bss, fif_pspoll,
101099 diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c
101100 index b8d331e..4fd3293 100644
101101 --- a/net/mac80211/iface.c
101102 +++ b/net/mac80211/iface.c
101103 @@ -524,7 +524,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
101104 break;
101105 }
101106
101107 - if (local->open_count == 0) {
101108 + if (local_read(&local->open_count) == 0) {
101109 res = drv_start(local);
101110 if (res)
101111 goto err_del_bss;
101112 @@ -571,7 +571,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
101113 res = drv_add_interface(local, sdata);
101114 if (res)
101115 goto err_stop;
101116 - } else if (local->monitors == 0 && local->open_count == 0) {
101117 + } else if (local->monitors == 0 && local_read(&local->open_count) == 0) {
101118 res = ieee80211_add_virtual_monitor(local);
101119 if (res)
101120 goto err_stop;
101121 @@ -680,7 +680,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
101122 atomic_inc(&local->iff_promiscs);
101123
101124 if (coming_up)
101125 - local->open_count++;
101126 + local_inc(&local->open_count);
101127
101128 if (hw_reconf_flags)
101129 ieee80211_hw_config(local, hw_reconf_flags);
101130 @@ -718,7 +718,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
101131 err_del_interface:
101132 drv_remove_interface(local, sdata);
101133 err_stop:
101134 - if (!local->open_count)
101135 + if (!local_read(&local->open_count))
101136 drv_stop(local);
101137 err_del_bss:
101138 sdata->bss = NULL;
101139 @@ -871,7 +871,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
101140 }
101141
101142 if (going_down)
101143 - local->open_count--;
101144 + local_dec(&local->open_count);
101145
101146 switch (sdata->vif.type) {
101147 case NL80211_IFTYPE_AP_VLAN:
101148 @@ -930,7 +930,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
101149 }
101150 spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags);
101151
101152 - if (local->open_count == 0)
101153 + if (local_read(&local->open_count) == 0)
101154 ieee80211_clear_tx_pending(local);
101155
101156 /*
101157 @@ -970,7 +970,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
101158
101159 ieee80211_recalc_ps(local, -1);
101160
101161 - if (local->open_count == 0) {
101162 + if (local_read(&local->open_count) == 0) {
101163 ieee80211_stop_device(local);
101164
101165 /* no reconfiguring after stop! */
101166 @@ -981,7 +981,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
101167 ieee80211_configure_filter(local);
101168 ieee80211_hw_config(local, hw_reconf_flags);
101169
101170 - if (local->monitors == local->open_count)
101171 + if (local->monitors == local_read(&local->open_count))
101172 ieee80211_add_virtual_monitor(local);
101173 }
101174
101175 diff --git a/net/mac80211/main.c b/net/mac80211/main.c
101176 index 4c1bf61..00b449b 100644
101177 --- a/net/mac80211/main.c
101178 +++ b/net/mac80211/main.c
101179 @@ -174,7 +174,7 @@ int ieee80211_hw_config(struct ieee80211_local *local, u32 changed)
101180 changed &= ~(IEEE80211_CONF_CHANGE_CHANNEL |
101181 IEEE80211_CONF_CHANGE_POWER);
101182
101183 - if (changed && local->open_count) {
101184 + if (changed && local_read(&local->open_count)) {
101185 ret = drv_config(local, changed);
101186 /*
101187 * Goal:
101188 diff --git a/net/mac80211/pm.c b/net/mac80211/pm.c
101189 index d478b88..8c8d157 100644
101190 --- a/net/mac80211/pm.c
101191 +++ b/net/mac80211/pm.c
101192 @@ -12,7 +12,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
101193 struct ieee80211_sub_if_data *sdata;
101194 struct sta_info *sta;
101195
101196 - if (!local->open_count)
101197 + if (!local_read(&local->open_count))
101198 goto suspend;
101199
101200 ieee80211_scan_cancel(local);
101201 @@ -58,7 +58,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
101202 cancel_work_sync(&local->dynamic_ps_enable_work);
101203 del_timer_sync(&local->dynamic_ps_timer);
101204
101205 - local->wowlan = wowlan && local->open_count;
101206 + local->wowlan = wowlan && local_read(&local->open_count);
101207 if (local->wowlan) {
101208 int err = drv_suspend(local, wowlan);
101209 if (err < 0) {
101210 @@ -123,7 +123,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
101211 WARN_ON(!list_empty(&local->chanctx_list));
101212
101213 /* stop hardware - this must stop RX */
101214 - if (local->open_count)
101215 + if (local_read(&local->open_count))
101216 ieee80211_stop_device(local);
101217
101218 suspend:
101219 diff --git a/net/mac80211/rate.c b/net/mac80211/rate.c
101220 index 8fdadfd..a4f72b8 100644
101221 --- a/net/mac80211/rate.c
101222 +++ b/net/mac80211/rate.c
101223 @@ -720,7 +720,7 @@ int ieee80211_init_rate_ctrl_alg(struct ieee80211_local *local,
101224
101225 ASSERT_RTNL();
101226
101227 - if (local->open_count)
101228 + if (local_read(&local->open_count))
101229 return -EBUSY;
101230
101231 if (local->hw.flags & IEEE80211_HW_HAS_RATE_CONTROL) {
101232 diff --git a/net/mac80211/rc80211_pid_debugfs.c b/net/mac80211/rc80211_pid_debugfs.c
101233 index 6ff1346..936ca9a 100644
101234 --- a/net/mac80211/rc80211_pid_debugfs.c
101235 +++ b/net/mac80211/rc80211_pid_debugfs.c
101236 @@ -193,7 +193,7 @@ static ssize_t rate_control_pid_events_read(struct file *file, char __user *buf,
101237
101238 spin_unlock_irqrestore(&events->lock, status);
101239
101240 - if (copy_to_user(buf, pb, p))
101241 + if (p > sizeof(pb) || copy_to_user(buf, pb, p))
101242 return -EFAULT;
101243
101244 return p;
101245 diff --git a/net/mac80211/util.c b/net/mac80211/util.c
101246 index 3c36583..12887fe 100644
101247 --- a/net/mac80211/util.c
101248 +++ b/net/mac80211/util.c
101249 @@ -1509,7 +1509,7 @@ int ieee80211_reconfig(struct ieee80211_local *local)
101250 }
101251 #endif
101252 /* everything else happens only if HW was up & running */
101253 - if (!local->open_count)
101254 + if (!local_read(&local->open_count))
101255 goto wake_up;
101256
101257 /*
101258 @@ -1734,7 +1734,7 @@ int ieee80211_reconfig(struct ieee80211_local *local)
101259 local->in_reconfig = false;
101260 barrier();
101261
101262 - if (local->monitors == local->open_count && local->monitors > 0)
101263 + if (local->monitors == local_read(&local->open_count) && local->monitors > 0)
101264 ieee80211_add_virtual_monitor(local);
101265
101266 /*
101267 diff --git a/net/netfilter/Kconfig b/net/netfilter/Kconfig
101268 index e9410d1..77b6378 100644
101269 --- a/net/netfilter/Kconfig
101270 +++ b/net/netfilter/Kconfig
101271 @@ -1081,6 +1081,16 @@ config NETFILTER_XT_MATCH_ESP
101272
101273 To compile it as a module, choose M here. If unsure, say N.
101274
101275 +config NETFILTER_XT_MATCH_GRADM
101276 + tristate '"gradm" match support'
101277 + depends on NETFILTER_XTABLES && NETFILTER_ADVANCED
101278 + depends on GRKERNSEC && !GRKERNSEC_NO_RBAC
101279 + ---help---
101280 + The gradm match allows to match on grsecurity RBAC being enabled.
101281 + It is useful when iptables rules are applied early on bootup to
101282 + prevent connections to the machine (except from a trusted host)
101283 + while the RBAC system is disabled.
101284 +
101285 config NETFILTER_XT_MATCH_HASHLIMIT
101286 tristate '"hashlimit" match support'
101287 depends on (IP6_NF_IPTABLES || IP6_NF_IPTABLES=n)
101288 diff --git a/net/netfilter/Makefile b/net/netfilter/Makefile
101289 index bffdad7..f9317d1 100644
101290 --- a/net/netfilter/Makefile
101291 +++ b/net/netfilter/Makefile
101292 @@ -133,6 +133,7 @@ obj-$(CONFIG_NETFILTER_XT_MATCH_DEVGROUP) += xt_devgroup.o
101293 obj-$(CONFIG_NETFILTER_XT_MATCH_DSCP) += xt_dscp.o
101294 obj-$(CONFIG_NETFILTER_XT_MATCH_ECN) += xt_ecn.o
101295 obj-$(CONFIG_NETFILTER_XT_MATCH_ESP) += xt_esp.o
101296 +obj-$(CONFIG_NETFILTER_XT_MATCH_GRADM) += xt_gradm.o
101297 obj-$(CONFIG_NETFILTER_XT_MATCH_HASHLIMIT) += xt_hashlimit.o
101298 obj-$(CONFIG_NETFILTER_XT_MATCH_HELPER) += xt_helper.o
101299 obj-$(CONFIG_NETFILTER_XT_MATCH_HL) += xt_hl.o
101300 diff --git a/net/netfilter/ipset/ip_set_core.c b/net/netfilter/ipset/ip_set_core.c
101301 index 1172083..986f1c1 100644
101302 --- a/net/netfilter/ipset/ip_set_core.c
101303 +++ b/net/netfilter/ipset/ip_set_core.c
101304 @@ -1924,7 +1924,7 @@ done:
101305 return ret;
101306 }
101307
101308 -static struct nf_sockopt_ops so_set __read_mostly = {
101309 +static struct nf_sockopt_ops so_set = {
101310 .pf = PF_INET,
101311 .get_optmin = SO_IP_SET,
101312 .get_optmax = SO_IP_SET + 1,
101313 diff --git a/net/netfilter/ipvs/ip_vs_conn.c b/net/netfilter/ipvs/ip_vs_conn.c
101314 index a8eb0a8..86f2de4 100644
101315 --- a/net/netfilter/ipvs/ip_vs_conn.c
101316 +++ b/net/netfilter/ipvs/ip_vs_conn.c
101317 @@ -556,7 +556,7 @@ ip_vs_bind_dest(struct ip_vs_conn *cp, struct ip_vs_dest *dest)
101318 /* Increase the refcnt counter of the dest */
101319 ip_vs_dest_hold(dest);
101320
101321 - conn_flags = atomic_read(&dest->conn_flags);
101322 + conn_flags = atomic_read_unchecked(&dest->conn_flags);
101323 if (cp->protocol != IPPROTO_UDP)
101324 conn_flags &= ~IP_VS_CONN_F_ONE_PACKET;
101325 flags = cp->flags;
101326 @@ -900,7 +900,7 @@ ip_vs_conn_new(const struct ip_vs_conn_param *p,
101327
101328 cp->control = NULL;
101329 atomic_set(&cp->n_control, 0);
101330 - atomic_set(&cp->in_pkts, 0);
101331 + atomic_set_unchecked(&cp->in_pkts, 0);
101332
101333 cp->packet_xmit = NULL;
101334 cp->app = NULL;
101335 @@ -1188,7 +1188,7 @@ static inline int todrop_entry(struct ip_vs_conn *cp)
101336
101337 /* Don't drop the entry if its number of incoming packets is not
101338 located in [0, 8] */
101339 - i = atomic_read(&cp->in_pkts);
101340 + i = atomic_read_unchecked(&cp->in_pkts);
101341 if (i > 8 || i < 0) return 0;
101342
101343 if (!todrop_rate[i]) return 0;
101344 diff --git a/net/netfilter/ipvs/ip_vs_core.c b/net/netfilter/ipvs/ip_vs_core.c
101345 index 3d2d2c8..c87e4d3 100644
101346 --- a/net/netfilter/ipvs/ip_vs_core.c
101347 +++ b/net/netfilter/ipvs/ip_vs_core.c
101348 @@ -567,7 +567,7 @@ int ip_vs_leave(struct ip_vs_service *svc, struct sk_buff *skb,
101349 ret = cp->packet_xmit(skb, cp, pd->pp, iph);
101350 /* do not touch skb anymore */
101351
101352 - atomic_inc(&cp->in_pkts);
101353 + atomic_inc_unchecked(&cp->in_pkts);
101354 ip_vs_conn_put(cp);
101355 return ret;
101356 }
101357 @@ -1711,7 +1711,7 @@ ip_vs_in(unsigned int hooknum, struct sk_buff *skb, int af)
101358 if (cp->flags & IP_VS_CONN_F_ONE_PACKET)
101359 pkts = sysctl_sync_threshold(ipvs);
101360 else
101361 - pkts = atomic_add_return(1, &cp->in_pkts);
101362 + pkts = atomic_add_return_unchecked(1, &cp->in_pkts);
101363
101364 if (ipvs->sync_state & IP_VS_STATE_MASTER)
101365 ip_vs_sync_conn(net, cp, pkts);
101366 diff --git a/net/netfilter/ipvs/ip_vs_ctl.c b/net/netfilter/ipvs/ip_vs_ctl.c
101367 index c42e83d..a6a3f8b 100644
101368 --- a/net/netfilter/ipvs/ip_vs_ctl.c
101369 +++ b/net/netfilter/ipvs/ip_vs_ctl.c
101370 @@ -794,7 +794,7 @@ __ip_vs_update_dest(struct ip_vs_service *svc, struct ip_vs_dest *dest,
101371 */
101372 ip_vs_rs_hash(ipvs, dest);
101373 }
101374 - atomic_set(&dest->conn_flags, conn_flags);
101375 + atomic_set_unchecked(&dest->conn_flags, conn_flags);
101376
101377 /* bind the service */
101378 old_svc = rcu_dereference_protected(dest->svc, 1);
101379 @@ -1654,7 +1654,7 @@ proc_do_sync_ports(struct ctl_table *table, int write,
101380 * align with netns init in ip_vs_control_net_init()
101381 */
101382
101383 -static struct ctl_table vs_vars[] = {
101384 +static ctl_table_no_const vs_vars[] __read_only = {
101385 {
101386 .procname = "amemthresh",
101387 .maxlen = sizeof(int),
101388 @@ -2075,7 +2075,7 @@ static int ip_vs_info_seq_show(struct seq_file *seq, void *v)
101389 " %-7s %-6d %-10d %-10d\n",
101390 &dest->addr.in6,
101391 ntohs(dest->port),
101392 - ip_vs_fwd_name(atomic_read(&dest->conn_flags)),
101393 + ip_vs_fwd_name(atomic_read_unchecked(&dest->conn_flags)),
101394 atomic_read(&dest->weight),
101395 atomic_read(&dest->activeconns),
101396 atomic_read(&dest->inactconns));
101397 @@ -2086,7 +2086,7 @@ static int ip_vs_info_seq_show(struct seq_file *seq, void *v)
101398 "%-7s %-6d %-10d %-10d\n",
101399 ntohl(dest->addr.ip),
101400 ntohs(dest->port),
101401 - ip_vs_fwd_name(atomic_read(&dest->conn_flags)),
101402 + ip_vs_fwd_name(atomic_read_unchecked(&dest->conn_flags)),
101403 atomic_read(&dest->weight),
101404 atomic_read(&dest->activeconns),
101405 atomic_read(&dest->inactconns));
101406 @@ -2564,7 +2564,7 @@ __ip_vs_get_dest_entries(struct net *net, const struct ip_vs_get_dests *get,
101407
101408 entry.addr = dest->addr.ip;
101409 entry.port = dest->port;
101410 - entry.conn_flags = atomic_read(&dest->conn_flags);
101411 + entry.conn_flags = atomic_read_unchecked(&dest->conn_flags);
101412 entry.weight = atomic_read(&dest->weight);
101413 entry.u_threshold = dest->u_threshold;
101414 entry.l_threshold = dest->l_threshold;
101415 @@ -3107,7 +3107,7 @@ static int ip_vs_genl_fill_dest(struct sk_buff *skb, struct ip_vs_dest *dest)
101416 if (nla_put(skb, IPVS_DEST_ATTR_ADDR, sizeof(dest->addr), &dest->addr) ||
101417 nla_put_be16(skb, IPVS_DEST_ATTR_PORT, dest->port) ||
101418 nla_put_u32(skb, IPVS_DEST_ATTR_FWD_METHOD,
101419 - (atomic_read(&dest->conn_flags) &
101420 + (atomic_read_unchecked(&dest->conn_flags) &
101421 IP_VS_CONN_F_FWD_MASK)) ||
101422 nla_put_u32(skb, IPVS_DEST_ATTR_WEIGHT,
101423 atomic_read(&dest->weight)) ||
101424 @@ -3697,7 +3697,7 @@ static int __net_init ip_vs_control_net_init_sysctl(struct net *net)
101425 {
101426 int idx;
101427 struct netns_ipvs *ipvs = net_ipvs(net);
101428 - struct ctl_table *tbl;
101429 + ctl_table_no_const *tbl;
101430
101431 atomic_set(&ipvs->dropentry, 0);
101432 spin_lock_init(&ipvs->dropentry_lock);
101433 diff --git a/net/netfilter/ipvs/ip_vs_lblc.c b/net/netfilter/ipvs/ip_vs_lblc.c
101434 index 547ff33..c8c8117 100644
101435 --- a/net/netfilter/ipvs/ip_vs_lblc.c
101436 +++ b/net/netfilter/ipvs/ip_vs_lblc.c
101437 @@ -118,7 +118,7 @@ struct ip_vs_lblc_table {
101438 * IPVS LBLC sysctl table
101439 */
101440 #ifdef CONFIG_SYSCTL
101441 -static struct ctl_table vs_vars_table[] = {
101442 +static ctl_table_no_const vs_vars_table[] __read_only = {
101443 {
101444 .procname = "lblc_expiration",
101445 .data = NULL,
101446 diff --git a/net/netfilter/ipvs/ip_vs_lblcr.c b/net/netfilter/ipvs/ip_vs_lblcr.c
101447 index 3f21a2f..a112e85 100644
101448 --- a/net/netfilter/ipvs/ip_vs_lblcr.c
101449 +++ b/net/netfilter/ipvs/ip_vs_lblcr.c
101450 @@ -289,7 +289,7 @@ struct ip_vs_lblcr_table {
101451 * IPVS LBLCR sysctl table
101452 */
101453
101454 -static struct ctl_table vs_vars_table[] = {
101455 +static ctl_table_no_const vs_vars_table[] __read_only = {
101456 {
101457 .procname = "lblcr_expiration",
101458 .data = NULL,
101459 diff --git a/net/netfilter/ipvs/ip_vs_sync.c b/net/netfilter/ipvs/ip_vs_sync.c
101460 index db80126..ef7110e 100644
101461 --- a/net/netfilter/ipvs/ip_vs_sync.c
101462 +++ b/net/netfilter/ipvs/ip_vs_sync.c
101463 @@ -609,7 +609,7 @@ static void ip_vs_sync_conn_v0(struct net *net, struct ip_vs_conn *cp,
101464 cp = cp->control;
101465 if (cp) {
101466 if (cp->flags & IP_VS_CONN_F_TEMPLATE)
101467 - pkts = atomic_add_return(1, &cp->in_pkts);
101468 + pkts = atomic_add_return_unchecked(1, &cp->in_pkts);
101469 else
101470 pkts = sysctl_sync_threshold(ipvs);
101471 ip_vs_sync_conn(net, cp->control, pkts);
101472 @@ -771,7 +771,7 @@ control:
101473 if (!cp)
101474 return;
101475 if (cp->flags & IP_VS_CONN_F_TEMPLATE)
101476 - pkts = atomic_add_return(1, &cp->in_pkts);
101477 + pkts = atomic_add_return_unchecked(1, &cp->in_pkts);
101478 else
101479 pkts = sysctl_sync_threshold(ipvs);
101480 goto sloop;
101481 @@ -895,7 +895,7 @@ static void ip_vs_proc_conn(struct net *net, struct ip_vs_conn_param *param,
101482
101483 if (opt)
101484 memcpy(&cp->in_seq, opt, sizeof(*opt));
101485 - atomic_set(&cp->in_pkts, sysctl_sync_threshold(ipvs));
101486 + atomic_set_unchecked(&cp->in_pkts, sysctl_sync_threshold(ipvs));
101487 cp->state = state;
101488 cp->old_state = cp->state;
101489 /*
101490 diff --git a/net/netfilter/ipvs/ip_vs_xmit.c b/net/netfilter/ipvs/ip_vs_xmit.c
101491 index c47444e..b0961c6 100644
101492 --- a/net/netfilter/ipvs/ip_vs_xmit.c
101493 +++ b/net/netfilter/ipvs/ip_vs_xmit.c
101494 @@ -1102,7 +1102,7 @@ ip_vs_icmp_xmit(struct sk_buff *skb, struct ip_vs_conn *cp,
101495 else
101496 rc = NF_ACCEPT;
101497 /* do not touch skb anymore */
101498 - atomic_inc(&cp->in_pkts);
101499 + atomic_inc_unchecked(&cp->in_pkts);
101500 goto out;
101501 }
101502
101503 @@ -1194,7 +1194,7 @@ ip_vs_icmp_xmit_v6(struct sk_buff *skb, struct ip_vs_conn *cp,
101504 else
101505 rc = NF_ACCEPT;
101506 /* do not touch skb anymore */
101507 - atomic_inc(&cp->in_pkts);
101508 + atomic_inc_unchecked(&cp->in_pkts);
101509 goto out;
101510 }
101511
101512 diff --git a/net/netfilter/nf_conntrack_acct.c b/net/netfilter/nf_conntrack_acct.c
101513 index a4b5e2a..13b1de3 100644
101514 --- a/net/netfilter/nf_conntrack_acct.c
101515 +++ b/net/netfilter/nf_conntrack_acct.c
101516 @@ -62,7 +62,7 @@ static struct nf_ct_ext_type acct_extend __read_mostly = {
101517 #ifdef CONFIG_SYSCTL
101518 static int nf_conntrack_acct_init_sysctl(struct net *net)
101519 {
101520 - struct ctl_table *table;
101521 + ctl_table_no_const *table;
101522
101523 table = kmemdup(acct_sysctl_table, sizeof(acct_sysctl_table),
101524 GFP_KERNEL);
101525 diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c
101526 index 75421f2..054c1fc 100644
101527 --- a/net/netfilter/nf_conntrack_core.c
101528 +++ b/net/netfilter/nf_conntrack_core.c
101529 @@ -1789,6 +1789,10 @@ void nf_conntrack_init_end(void)
101530 #define DYING_NULLS_VAL ((1<<30)+1)
101531 #define TEMPLATE_NULLS_VAL ((1<<30)+2)
101532
101533 +#ifdef CONFIG_GRKERNSEC_HIDESYM
101534 +static atomic_unchecked_t conntrack_cache_id = ATOMIC_INIT(0);
101535 +#endif
101536 +
101537 int nf_conntrack_init_net(struct net *net)
101538 {
101539 int ret = -ENOMEM;
101540 @@ -1814,7 +1818,11 @@ int nf_conntrack_init_net(struct net *net)
101541 if (!net->ct.stat)
101542 goto err_pcpu_lists;
101543
101544 +#ifdef CONFIG_GRKERNSEC_HIDESYM
101545 + net->ct.slabname = kasprintf(GFP_KERNEL, "nf_conntrack_%08lx", atomic_inc_return_unchecked(&conntrack_cache_id));
101546 +#else
101547 net->ct.slabname = kasprintf(GFP_KERNEL, "nf_conntrack_%p", net);
101548 +#endif
101549 if (!net->ct.slabname)
101550 goto err_slabname;
101551
101552 diff --git a/net/netfilter/nf_conntrack_ecache.c b/net/netfilter/nf_conntrack_ecache.c
101553 index 1df1761..ce8b88a 100644
101554 --- a/net/netfilter/nf_conntrack_ecache.c
101555 +++ b/net/netfilter/nf_conntrack_ecache.c
101556 @@ -188,7 +188,7 @@ static struct nf_ct_ext_type event_extend __read_mostly = {
101557 #ifdef CONFIG_SYSCTL
101558 static int nf_conntrack_event_init_sysctl(struct net *net)
101559 {
101560 - struct ctl_table *table;
101561 + ctl_table_no_const *table;
101562
101563 table = kmemdup(event_sysctl_table, sizeof(event_sysctl_table),
101564 GFP_KERNEL);
101565 diff --git a/net/netfilter/nf_conntrack_helper.c b/net/netfilter/nf_conntrack_helper.c
101566 index 5b3eae7..dd4b8fe 100644
101567 --- a/net/netfilter/nf_conntrack_helper.c
101568 +++ b/net/netfilter/nf_conntrack_helper.c
101569 @@ -57,7 +57,7 @@ static struct ctl_table helper_sysctl_table[] = {
101570
101571 static int nf_conntrack_helper_init_sysctl(struct net *net)
101572 {
101573 - struct ctl_table *table;
101574 + ctl_table_no_const *table;
101575
101576 table = kmemdup(helper_sysctl_table, sizeof(helper_sysctl_table),
101577 GFP_KERNEL);
101578 diff --git a/net/netfilter/nf_conntrack_proto.c b/net/netfilter/nf_conntrack_proto.c
101579 index b65d586..beec902 100644
101580 --- a/net/netfilter/nf_conntrack_proto.c
101581 +++ b/net/netfilter/nf_conntrack_proto.c
101582 @@ -52,7 +52,7 @@ nf_ct_register_sysctl(struct net *net,
101583
101584 static void
101585 nf_ct_unregister_sysctl(struct ctl_table_header **header,
101586 - struct ctl_table **table,
101587 + ctl_table_no_const **table,
101588 unsigned int users)
101589 {
101590 if (users > 0)
101591 diff --git a/net/netfilter/nf_conntrack_standalone.c b/net/netfilter/nf_conntrack_standalone.c
101592 index f641751..d3c5b51 100644
101593 --- a/net/netfilter/nf_conntrack_standalone.c
101594 +++ b/net/netfilter/nf_conntrack_standalone.c
101595 @@ -471,7 +471,7 @@ static struct ctl_table nf_ct_netfilter_table[] = {
101596
101597 static int nf_conntrack_standalone_init_sysctl(struct net *net)
101598 {
101599 - struct ctl_table *table;
101600 + ctl_table_no_const *table;
101601
101602 table = kmemdup(nf_ct_sysctl_table, sizeof(nf_ct_sysctl_table),
101603 GFP_KERNEL);
101604 diff --git a/net/netfilter/nf_conntrack_timestamp.c b/net/netfilter/nf_conntrack_timestamp.c
101605 index 7a394df..bd91a8a 100644
101606 --- a/net/netfilter/nf_conntrack_timestamp.c
101607 +++ b/net/netfilter/nf_conntrack_timestamp.c
101608 @@ -42,7 +42,7 @@ static struct nf_ct_ext_type tstamp_extend __read_mostly = {
101609 #ifdef CONFIG_SYSCTL
101610 static int nf_conntrack_tstamp_init_sysctl(struct net *net)
101611 {
101612 - struct ctl_table *table;
101613 + ctl_table_no_const *table;
101614
101615 table = kmemdup(tstamp_sysctl_table, sizeof(tstamp_sysctl_table),
101616 GFP_KERNEL);
101617 diff --git a/net/netfilter/nf_log.c b/net/netfilter/nf_log.c
101618 index 85296d4..8becdec 100644
101619 --- a/net/netfilter/nf_log.c
101620 +++ b/net/netfilter/nf_log.c
101621 @@ -243,7 +243,7 @@ static const struct file_operations nflog_file_ops = {
101622
101623 #ifdef CONFIG_SYSCTL
101624 static char nf_log_sysctl_fnames[NFPROTO_NUMPROTO-NFPROTO_UNSPEC][3];
101625 -static struct ctl_table nf_log_sysctl_table[NFPROTO_NUMPROTO+1];
101626 +static ctl_table_no_const nf_log_sysctl_table[NFPROTO_NUMPROTO+1] __read_only;
101627
101628 static int nf_log_proc_dostring(struct ctl_table *table, int write,
101629 void __user *buffer, size_t *lenp, loff_t *ppos)
101630 @@ -274,14 +274,16 @@ static int nf_log_proc_dostring(struct ctl_table *table, int write,
101631 rcu_assign_pointer(net->nf.nf_loggers[tindex], logger);
101632 mutex_unlock(&nf_log_mutex);
101633 } else {
101634 + ctl_table_no_const nf_log_table = *table;
101635 +
101636 mutex_lock(&nf_log_mutex);
101637 logger = rcu_dereference_protected(net->nf.nf_loggers[tindex],
101638 lockdep_is_held(&nf_log_mutex));
101639 if (!logger)
101640 - table->data = "NONE";
101641 + nf_log_table.data = "NONE";
101642 else
101643 - table->data = logger->name;
101644 - r = proc_dostring(table, write, buffer, lenp, ppos);
101645 + nf_log_table.data = logger->name;
101646 + r = proc_dostring(&nf_log_table, write, buffer, lenp, ppos);
101647 mutex_unlock(&nf_log_mutex);
101648 }
101649
101650 diff --git a/net/netfilter/nf_sockopt.c b/net/netfilter/nf_sockopt.c
101651 index f042ae5..30ea486 100644
101652 --- a/net/netfilter/nf_sockopt.c
101653 +++ b/net/netfilter/nf_sockopt.c
101654 @@ -45,7 +45,7 @@ int nf_register_sockopt(struct nf_sockopt_ops *reg)
101655 }
101656 }
101657
101658 - list_add(&reg->list, &nf_sockopts);
101659 + pax_list_add((struct list_head *)&reg->list, &nf_sockopts);
101660 out:
101661 mutex_unlock(&nf_sockopt_mutex);
101662 return ret;
101663 @@ -55,7 +55,7 @@ EXPORT_SYMBOL(nf_register_sockopt);
101664 void nf_unregister_sockopt(struct nf_sockopt_ops *reg)
101665 {
101666 mutex_lock(&nf_sockopt_mutex);
101667 - list_del(&reg->list);
101668 + pax_list_del((struct list_head *)&reg->list);
101669 mutex_unlock(&nf_sockopt_mutex);
101670 }
101671 EXPORT_SYMBOL(nf_unregister_sockopt);
101672 diff --git a/net/netfilter/nfnetlink_log.c b/net/netfilter/nfnetlink_log.c
101673 index d292c8d..9f1e166 100644
101674 --- a/net/netfilter/nfnetlink_log.c
101675 +++ b/net/netfilter/nfnetlink_log.c
101676 @@ -79,7 +79,7 @@ static int nfnl_log_net_id __read_mostly;
101677 struct nfnl_log_net {
101678 spinlock_t instances_lock;
101679 struct hlist_head instance_table[INSTANCE_BUCKETS];
101680 - atomic_t global_seq;
101681 + atomic_unchecked_t global_seq;
101682 };
101683
101684 static struct nfnl_log_net *nfnl_log_pernet(struct net *net)
101685 @@ -561,7 +561,7 @@ __build_packet_message(struct nfnl_log_net *log,
101686 /* global sequence number */
101687 if ((inst->flags & NFULNL_CFG_F_SEQ_GLOBAL) &&
101688 nla_put_be32(inst->skb, NFULA_SEQ_GLOBAL,
101689 - htonl(atomic_inc_return(&log->global_seq))))
101690 + htonl(atomic_inc_return_unchecked(&log->global_seq))))
101691 goto nla_put_failure;
101692
101693 if (data_len) {
101694 diff --git a/net/netfilter/nft_compat.c b/net/netfilter/nft_compat.c
101695 index 8a779be..1551d4c 100644
101696 --- a/net/netfilter/nft_compat.c
101697 +++ b/net/netfilter/nft_compat.c
101698 @@ -216,7 +216,7 @@ target_dump_info(struct sk_buff *skb, const struct xt_target *t, const void *in)
101699 /* We want to reuse existing compat_to_user */
101700 old_fs = get_fs();
101701 set_fs(KERNEL_DS);
101702 - t->compat_to_user(out, in);
101703 + t->compat_to_user((void __force_user *)out, in);
101704 set_fs(old_fs);
101705 ret = nla_put(skb, NFTA_TARGET_INFO, XT_ALIGN(t->targetsize), out);
101706 kfree(out);
101707 @@ -403,7 +403,7 @@ match_dump_info(struct sk_buff *skb, const struct xt_match *m, const void *in)
101708 /* We want to reuse existing compat_to_user */
101709 old_fs = get_fs();
101710 set_fs(KERNEL_DS);
101711 - m->compat_to_user(out, in);
101712 + m->compat_to_user((void __force_user *)out, in);
101713 set_fs(old_fs);
101714 ret = nla_put(skb, NFTA_MATCH_INFO, XT_ALIGN(m->matchsize), out);
101715 kfree(out);
101716 diff --git a/net/netfilter/xt_gradm.c b/net/netfilter/xt_gradm.c
101717 new file mode 100644
101718 index 0000000..c566332
101719 --- /dev/null
101720 +++ b/net/netfilter/xt_gradm.c
101721 @@ -0,0 +1,51 @@
101722 +/*
101723 + * gradm match for netfilter
101724 + * Copyright © Zbigniew Krzystolik, 2010
101725 + *
101726 + * This program is free software; you can redistribute it and/or modify
101727 + * it under the terms of the GNU General Public License; either version
101728 + * 2 or 3 as published by the Free Software Foundation.
101729 + */
101730 +#include <linux/module.h>
101731 +#include <linux/moduleparam.h>
101732 +#include <linux/skbuff.h>
101733 +#include <linux/netfilter/x_tables.h>
101734 +#include <linux/grsecurity.h>
101735 +#include <linux/netfilter/xt_gradm.h>
101736 +
101737 +static bool
101738 +gradm_mt(const struct sk_buff *skb, struct xt_action_param *par)
101739 +{
101740 + const struct xt_gradm_mtinfo *info = par->matchinfo;
101741 + bool retval = false;
101742 + if (gr_acl_is_enabled())
101743 + retval = true;
101744 + return retval ^ info->invflags;
101745 +}
101746 +
101747 +static struct xt_match gradm_mt_reg __read_mostly = {
101748 + .name = "gradm",
101749 + .revision = 0,
101750 + .family = NFPROTO_UNSPEC,
101751 + .match = gradm_mt,
101752 + .matchsize = XT_ALIGN(sizeof(struct xt_gradm_mtinfo)),
101753 + .me = THIS_MODULE,
101754 +};
101755 +
101756 +static int __init gradm_mt_init(void)
101757 +{
101758 + return xt_register_match(&gradm_mt_reg);
101759 +}
101760 +
101761 +static void __exit gradm_mt_exit(void)
101762 +{
101763 + xt_unregister_match(&gradm_mt_reg);
101764 +}
101765 +
101766 +module_init(gradm_mt_init);
101767 +module_exit(gradm_mt_exit);
101768 +MODULE_AUTHOR("Zbigniew Krzystolik <zbyniu@destrukcja.pl>");
101769 +MODULE_DESCRIPTION("Xtables: Grsecurity RBAC match");
101770 +MODULE_LICENSE("GPL");
101771 +MODULE_ALIAS("ipt_gradm");
101772 +MODULE_ALIAS("ip6t_gradm");
101773 diff --git a/net/netfilter/xt_hashlimit.c b/net/netfilter/xt_hashlimit.c
101774 index a3910fc..2d2ba14 100644
101775 --- a/net/netfilter/xt_hashlimit.c
101776 +++ b/net/netfilter/xt_hashlimit.c
101777 @@ -870,11 +870,11 @@ static int __net_init hashlimit_proc_net_init(struct net *net)
101778 {
101779 struct hashlimit_net *hashlimit_net = hashlimit_pernet(net);
101780
101781 - hashlimit_net->ipt_hashlimit = proc_mkdir("ipt_hashlimit", net->proc_net);
101782 + hashlimit_net->ipt_hashlimit = proc_mkdir_restrict("ipt_hashlimit", net->proc_net);
101783 if (!hashlimit_net->ipt_hashlimit)
101784 return -ENOMEM;
101785 #if IS_ENABLED(CONFIG_IP6_NF_IPTABLES)
101786 - hashlimit_net->ip6t_hashlimit = proc_mkdir("ip6t_hashlimit", net->proc_net);
101787 + hashlimit_net->ip6t_hashlimit = proc_mkdir_restrict("ip6t_hashlimit", net->proc_net);
101788 if (!hashlimit_net->ip6t_hashlimit) {
101789 remove_proc_entry("ipt_hashlimit", net->proc_net);
101790 return -ENOMEM;
101791 diff --git a/net/netfilter/xt_recent.c b/net/netfilter/xt_recent.c
101792 index 1e657cf..1eb1c34 100644
101793 --- a/net/netfilter/xt_recent.c
101794 +++ b/net/netfilter/xt_recent.c
101795 @@ -618,7 +618,7 @@ static int __net_init recent_proc_net_init(struct net *net)
101796 {
101797 struct recent_net *recent_net = recent_pernet(net);
101798
101799 - recent_net->xt_recent = proc_mkdir("xt_recent", net->proc_net);
101800 + recent_net->xt_recent = proc_mkdir_restrict("xt_recent", net->proc_net);
101801 if (!recent_net->xt_recent)
101802 return -ENOMEM;
101803 return 0;
101804 diff --git a/net/netfilter/xt_statistic.c b/net/netfilter/xt_statistic.c
101805 index 11de55e..f25e448 100644
101806 --- a/net/netfilter/xt_statistic.c
101807 +++ b/net/netfilter/xt_statistic.c
101808 @@ -19,7 +19,7 @@
101809 #include <linux/module.h>
101810
101811 struct xt_statistic_priv {
101812 - atomic_t count;
101813 + atomic_unchecked_t count;
101814 } ____cacheline_aligned_in_smp;
101815
101816 MODULE_LICENSE("GPL");
101817 @@ -42,9 +42,9 @@ statistic_mt(const struct sk_buff *skb, struct xt_action_param *par)
101818 break;
101819 case XT_STATISTIC_MODE_NTH:
101820 do {
101821 - oval = atomic_read(&info->master->count);
101822 + oval = atomic_read_unchecked(&info->master->count);
101823 nval = (oval == info->u.nth.every) ? 0 : oval + 1;
101824 - } while (atomic_cmpxchg(&info->master->count, oval, nval) != oval);
101825 + } while (atomic_cmpxchg_unchecked(&info->master->count, oval, nval) != oval);
101826 if (nval == 0)
101827 ret = !ret;
101828 break;
101829 @@ -64,7 +64,7 @@ static int statistic_mt_check(const struct xt_mtchk_param *par)
101830 info->master = kzalloc(sizeof(*info->master), GFP_KERNEL);
101831 if (info->master == NULL)
101832 return -ENOMEM;
101833 - atomic_set(&info->master->count, info->u.nth.count);
101834 + atomic_set_unchecked(&info->master->count, info->u.nth.count);
101835
101836 return 0;
101837 }
101838 diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
101839 index f22757a..daf62a2 100644
101840 --- a/net/netlink/af_netlink.c
101841 +++ b/net/netlink/af_netlink.c
101842 @@ -257,7 +257,7 @@ static void netlink_overrun(struct sock *sk)
101843 sk->sk_error_report(sk);
101844 }
101845 }
101846 - atomic_inc(&sk->sk_drops);
101847 + atomic_inc_unchecked(&sk->sk_drops);
101848 }
101849
101850 static void netlink_rcv_wake(struct sock *sk)
101851 @@ -3028,7 +3028,7 @@ static int netlink_seq_show(struct seq_file *seq, void *v)
101852 sk_wmem_alloc_get(s),
101853 nlk->cb_running,
101854 atomic_read(&s->sk_refcnt),
101855 - atomic_read(&s->sk_drops),
101856 + atomic_read_unchecked(&s->sk_drops),
101857 sock_i_ino(s)
101858 );
101859
101860 diff --git a/net/netrom/af_netrom.c b/net/netrom/af_netrom.c
101861 index ede50d1..d2468e6 100644
101862 --- a/net/netrom/af_netrom.c
101863 +++ b/net/netrom/af_netrom.c
101864 @@ -850,7 +850,6 @@ static int nr_getname(struct socket *sock, struct sockaddr *uaddr,
101865 *uaddr_len = sizeof(struct full_sockaddr_ax25);
101866 } else {
101867 sax->fsa_ax25.sax25_family = AF_NETROM;
101868 - sax->fsa_ax25.sax25_ndigis = 0;
101869 sax->fsa_ax25.sax25_call = nr->source_addr;
101870 *uaddr_len = sizeof(struct sockaddr_ax25);
101871 }
101872 diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
101873 index b85c67c..27c3368 100644
101874 --- a/net/packet/af_packet.c
101875 +++ b/net/packet/af_packet.c
101876 @@ -275,7 +275,7 @@ static int packet_direct_xmit(struct sk_buff *skb)
101877
101878 return ret;
101879 drop:
101880 - atomic_long_inc(&dev->tx_dropped);
101881 + atomic_long_inc_unchecked(&dev->tx_dropped);
101882 kfree_skb(skb);
101883 return NET_XMIT_DROP;
101884 }
101885 @@ -1845,7 +1845,7 @@ static int packet_rcv(struct sk_buff *skb, struct net_device *dev,
101886
101887 spin_lock(&sk->sk_receive_queue.lock);
101888 po->stats.stats1.tp_packets++;
101889 - skb->dropcount = atomic_read(&sk->sk_drops);
101890 + skb->dropcount = atomic_read_unchecked(&sk->sk_drops);
101891 __skb_queue_tail(&sk->sk_receive_queue, skb);
101892 spin_unlock(&sk->sk_receive_queue.lock);
101893 sk->sk_data_ready(sk);
101894 @@ -1854,7 +1854,7 @@ static int packet_rcv(struct sk_buff *skb, struct net_device *dev,
101895 drop_n_acct:
101896 spin_lock(&sk->sk_receive_queue.lock);
101897 po->stats.stats1.tp_drops++;
101898 - atomic_inc(&sk->sk_drops);
101899 + atomic_inc_unchecked(&sk->sk_drops);
101900 spin_unlock(&sk->sk_receive_queue.lock);
101901
101902 drop_n_restore:
101903 @@ -3459,7 +3459,7 @@ static int packet_getsockopt(struct socket *sock, int level, int optname,
101904 case PACKET_HDRLEN:
101905 if (len > sizeof(int))
101906 len = sizeof(int);
101907 - if (copy_from_user(&val, optval, len))
101908 + if (len > sizeof(val) || copy_from_user(&val, optval, len))
101909 return -EFAULT;
101910 switch (val) {
101911 case TPACKET_V1:
101912 @@ -3505,7 +3505,7 @@ static int packet_getsockopt(struct socket *sock, int level, int optname,
101913 len = lv;
101914 if (put_user(len, optlen))
101915 return -EFAULT;
101916 - if (copy_to_user(optval, data, len))
101917 + if (len > sizeof(st) || copy_to_user(optval, data, len))
101918 return -EFAULT;
101919 return 0;
101920 }
101921 diff --git a/net/phonet/pep.c b/net/phonet/pep.c
101922 index 70a547e..23477fe 100644
101923 --- a/net/phonet/pep.c
101924 +++ b/net/phonet/pep.c
101925 @@ -388,7 +388,7 @@ static int pipe_do_rcv(struct sock *sk, struct sk_buff *skb)
101926
101927 case PNS_PEP_CTRL_REQ:
101928 if (skb_queue_len(&pn->ctrlreq_queue) >= PNPIPE_CTRLREQ_MAX) {
101929 - atomic_inc(&sk->sk_drops);
101930 + atomic_inc_unchecked(&sk->sk_drops);
101931 break;
101932 }
101933 __skb_pull(skb, 4);
101934 @@ -409,7 +409,7 @@ static int pipe_do_rcv(struct sock *sk, struct sk_buff *skb)
101935 }
101936
101937 if (pn->rx_credits == 0) {
101938 - atomic_inc(&sk->sk_drops);
101939 + atomic_inc_unchecked(&sk->sk_drops);
101940 err = -ENOBUFS;
101941 break;
101942 }
101943 @@ -579,7 +579,7 @@ static int pipe_handler_do_rcv(struct sock *sk, struct sk_buff *skb)
101944 }
101945
101946 if (pn->rx_credits == 0) {
101947 - atomic_inc(&sk->sk_drops);
101948 + atomic_inc_unchecked(&sk->sk_drops);
101949 err = NET_RX_DROP;
101950 break;
101951 }
101952 diff --git a/net/phonet/socket.c b/net/phonet/socket.c
101953 index 008214a..bb68240 100644
101954 --- a/net/phonet/socket.c
101955 +++ b/net/phonet/socket.c
101956 @@ -611,7 +611,7 @@ static int pn_sock_seq_show(struct seq_file *seq, void *v)
101957 from_kuid_munged(seq_user_ns(seq), sock_i_uid(sk)),
101958 sock_i_ino(sk),
101959 atomic_read(&sk->sk_refcnt), sk,
101960 - atomic_read(&sk->sk_drops));
101961 + atomic_read_unchecked(&sk->sk_drops));
101962 }
101963 seq_pad(seq, '\n');
101964 return 0;
101965 diff --git a/net/phonet/sysctl.c b/net/phonet/sysctl.c
101966 index c02a8c4..3c5b600 100644
101967 --- a/net/phonet/sysctl.c
101968 +++ b/net/phonet/sysctl.c
101969 @@ -67,7 +67,7 @@ static int proc_local_port_range(struct ctl_table *table, int write,
101970 {
101971 int ret;
101972 int range[2] = {local_port_range[0], local_port_range[1]};
101973 - struct ctl_table tmp = {
101974 + ctl_table_no_const tmp = {
101975 .data = &range,
101976 .maxlen = sizeof(range),
101977 .mode = table->mode,
101978 diff --git a/net/rds/cong.c b/net/rds/cong.c
101979 index e5b65ac..f3b6fb7 100644
101980 --- a/net/rds/cong.c
101981 +++ b/net/rds/cong.c
101982 @@ -78,7 +78,7 @@
101983 * finds that the saved generation number is smaller than the global generation
101984 * number, it wakes up the process.
101985 */
101986 -static atomic_t rds_cong_generation = ATOMIC_INIT(0);
101987 +static atomic_unchecked_t rds_cong_generation = ATOMIC_INIT(0);
101988
101989 /*
101990 * Congestion monitoring
101991 @@ -233,7 +233,7 @@ void rds_cong_map_updated(struct rds_cong_map *map, uint64_t portmask)
101992 rdsdebug("waking map %p for %pI4\n",
101993 map, &map->m_addr);
101994 rds_stats_inc(s_cong_update_received);
101995 - atomic_inc(&rds_cong_generation);
101996 + atomic_inc_unchecked(&rds_cong_generation);
101997 if (waitqueue_active(&map->m_waitq))
101998 wake_up(&map->m_waitq);
101999 if (waitqueue_active(&rds_poll_waitq))
102000 @@ -259,7 +259,7 @@ EXPORT_SYMBOL_GPL(rds_cong_map_updated);
102001
102002 int rds_cong_updated_since(unsigned long *recent)
102003 {
102004 - unsigned long gen = atomic_read(&rds_cong_generation);
102005 + unsigned long gen = atomic_read_unchecked(&rds_cong_generation);
102006
102007 if (likely(*recent == gen))
102008 return 0;
102009 diff --git a/net/rds/ib.h b/net/rds/ib.h
102010 index 7280ab8..e04f4ea 100644
102011 --- a/net/rds/ib.h
102012 +++ b/net/rds/ib.h
102013 @@ -128,7 +128,7 @@ struct rds_ib_connection {
102014 /* sending acks */
102015 unsigned long i_ack_flags;
102016 #ifdef KERNEL_HAS_ATOMIC64
102017 - atomic64_t i_ack_next; /* next ACK to send */
102018 + atomic64_unchecked_t i_ack_next; /* next ACK to send */
102019 #else
102020 spinlock_t i_ack_lock; /* protect i_ack_next */
102021 u64 i_ack_next; /* next ACK to send */
102022 diff --git a/net/rds/ib_cm.c b/net/rds/ib_cm.c
102023 index 31b74f5..dc1fbfa 100644
102024 --- a/net/rds/ib_cm.c
102025 +++ b/net/rds/ib_cm.c
102026 @@ -717,7 +717,7 @@ void rds_ib_conn_shutdown(struct rds_connection *conn)
102027 /* Clear the ACK state */
102028 clear_bit(IB_ACK_IN_FLIGHT, &ic->i_ack_flags);
102029 #ifdef KERNEL_HAS_ATOMIC64
102030 - atomic64_set(&ic->i_ack_next, 0);
102031 + atomic64_set_unchecked(&ic->i_ack_next, 0);
102032 #else
102033 ic->i_ack_next = 0;
102034 #endif
102035 diff --git a/net/rds/ib_recv.c b/net/rds/ib_recv.c
102036 index b7ebe23..b6352f6 100644
102037 --- a/net/rds/ib_recv.c
102038 +++ b/net/rds/ib_recv.c
102039 @@ -596,7 +596,7 @@ static u64 rds_ib_get_ack(struct rds_ib_connection *ic)
102040 static void rds_ib_set_ack(struct rds_ib_connection *ic, u64 seq,
102041 int ack_required)
102042 {
102043 - atomic64_set(&ic->i_ack_next, seq);
102044 + atomic64_set_unchecked(&ic->i_ack_next, seq);
102045 if (ack_required) {
102046 smp_mb__before_clear_bit();
102047 set_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
102048 @@ -608,7 +608,7 @@ static u64 rds_ib_get_ack(struct rds_ib_connection *ic)
102049 clear_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
102050 smp_mb__after_clear_bit();
102051
102052 - return atomic64_read(&ic->i_ack_next);
102053 + return atomic64_read_unchecked(&ic->i_ack_next);
102054 }
102055 #endif
102056
102057 diff --git a/net/rds/iw.h b/net/rds/iw.h
102058 index 04ce3b1..48119a6 100644
102059 --- a/net/rds/iw.h
102060 +++ b/net/rds/iw.h
102061 @@ -134,7 +134,7 @@ struct rds_iw_connection {
102062 /* sending acks */
102063 unsigned long i_ack_flags;
102064 #ifdef KERNEL_HAS_ATOMIC64
102065 - atomic64_t i_ack_next; /* next ACK to send */
102066 + atomic64_unchecked_t i_ack_next; /* next ACK to send */
102067 #else
102068 spinlock_t i_ack_lock; /* protect i_ack_next */
102069 u64 i_ack_next; /* next ACK to send */
102070 diff --git a/net/rds/iw_cm.c b/net/rds/iw_cm.c
102071 index a91e1db..cf3053f 100644
102072 --- a/net/rds/iw_cm.c
102073 +++ b/net/rds/iw_cm.c
102074 @@ -663,7 +663,7 @@ void rds_iw_conn_shutdown(struct rds_connection *conn)
102075 /* Clear the ACK state */
102076 clear_bit(IB_ACK_IN_FLIGHT, &ic->i_ack_flags);
102077 #ifdef KERNEL_HAS_ATOMIC64
102078 - atomic64_set(&ic->i_ack_next, 0);
102079 + atomic64_set_unchecked(&ic->i_ack_next, 0);
102080 #else
102081 ic->i_ack_next = 0;
102082 #endif
102083 diff --git a/net/rds/iw_recv.c b/net/rds/iw_recv.c
102084 index 4503335..db566b4 100644
102085 --- a/net/rds/iw_recv.c
102086 +++ b/net/rds/iw_recv.c
102087 @@ -427,7 +427,7 @@ static u64 rds_iw_get_ack(struct rds_iw_connection *ic)
102088 static void rds_iw_set_ack(struct rds_iw_connection *ic, u64 seq,
102089 int ack_required)
102090 {
102091 - atomic64_set(&ic->i_ack_next, seq);
102092 + atomic64_set_unchecked(&ic->i_ack_next, seq);
102093 if (ack_required) {
102094 smp_mb__before_clear_bit();
102095 set_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
102096 @@ -439,7 +439,7 @@ static u64 rds_iw_get_ack(struct rds_iw_connection *ic)
102097 clear_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
102098 smp_mb__after_clear_bit();
102099
102100 - return atomic64_read(&ic->i_ack_next);
102101 + return atomic64_read_unchecked(&ic->i_ack_next);
102102 }
102103 #endif
102104
102105 diff --git a/net/rds/rds.h b/net/rds/rds.h
102106 index 48f8ffc..0ef3eec 100644
102107 --- a/net/rds/rds.h
102108 +++ b/net/rds/rds.h
102109 @@ -449,7 +449,7 @@ struct rds_transport {
102110 void (*sync_mr)(void *trans_private, int direction);
102111 void (*free_mr)(void *trans_private, int invalidate);
102112 void (*flush_mrs)(void);
102113 -};
102114 +} __do_const;
102115
102116 struct rds_sock {
102117 struct sock rs_sk;
102118 diff --git a/net/rds/tcp.c b/net/rds/tcp.c
102119 index edac9ef..16bcb98 100644
102120 --- a/net/rds/tcp.c
102121 +++ b/net/rds/tcp.c
102122 @@ -59,7 +59,7 @@ void rds_tcp_nonagle(struct socket *sock)
102123 int val = 1;
102124
102125 set_fs(KERNEL_DS);
102126 - sock->ops->setsockopt(sock, SOL_TCP, TCP_NODELAY, (char __user *)&val,
102127 + sock->ops->setsockopt(sock, SOL_TCP, TCP_NODELAY, (char __force_user *)&val,
102128 sizeof(val));
102129 set_fs(oldfs);
102130 }
102131 diff --git a/net/rds/tcp_send.c b/net/rds/tcp_send.c
102132 index 81cf5a4..b5826ff 100644
102133 --- a/net/rds/tcp_send.c
102134 +++ b/net/rds/tcp_send.c
102135 @@ -43,7 +43,7 @@ static void rds_tcp_cork(struct socket *sock, int val)
102136
102137 oldfs = get_fs();
102138 set_fs(KERNEL_DS);
102139 - sock->ops->setsockopt(sock, SOL_TCP, TCP_CORK, (char __user *)&val,
102140 + sock->ops->setsockopt(sock, SOL_TCP, TCP_CORK, (char __force_user *)&val,
102141 sizeof(val));
102142 set_fs(oldfs);
102143 }
102144 diff --git a/net/rxrpc/af_rxrpc.c b/net/rxrpc/af_rxrpc.c
102145 index 7b16704..9628ec6 100644
102146 --- a/net/rxrpc/af_rxrpc.c
102147 +++ b/net/rxrpc/af_rxrpc.c
102148 @@ -40,7 +40,7 @@ static const struct proto_ops rxrpc_rpc_ops;
102149 __be32 rxrpc_epoch;
102150
102151 /* current debugging ID */
102152 -atomic_t rxrpc_debug_id;
102153 +atomic_unchecked_t rxrpc_debug_id;
102154
102155 /* count of skbs currently in use */
102156 atomic_t rxrpc_n_skbs;
102157 diff --git a/net/rxrpc/ar-ack.c b/net/rxrpc/ar-ack.c
102158 index c6be17a..2a6200a 100644
102159 --- a/net/rxrpc/ar-ack.c
102160 +++ b/net/rxrpc/ar-ack.c
102161 @@ -223,7 +223,7 @@ static void rxrpc_resend(struct rxrpc_call *call)
102162
102163 _enter("{%d,%d,%d,%d},",
102164 call->acks_hard, call->acks_unacked,
102165 - atomic_read(&call->sequence),
102166 + atomic_read_unchecked(&call->sequence),
102167 CIRC_CNT(call->acks_head, call->acks_tail, call->acks_winsz));
102168
102169 stop = 0;
102170 @@ -247,7 +247,7 @@ static void rxrpc_resend(struct rxrpc_call *call)
102171
102172 /* each Tx packet has a new serial number */
102173 sp->hdr.serial =
102174 - htonl(atomic_inc_return(&call->conn->serial));
102175 + htonl(atomic_inc_return_unchecked(&call->conn->serial));
102176
102177 hdr = (struct rxrpc_header *) txb->head;
102178 hdr->serial = sp->hdr.serial;
102179 @@ -451,7 +451,7 @@ static void rxrpc_rotate_tx_window(struct rxrpc_call *call, u32 hard)
102180 */
102181 static void rxrpc_clear_tx_window(struct rxrpc_call *call)
102182 {
102183 - rxrpc_rotate_tx_window(call, atomic_read(&call->sequence));
102184 + rxrpc_rotate_tx_window(call, atomic_read_unchecked(&call->sequence));
102185 }
102186
102187 /*
102188 @@ -677,7 +677,7 @@ process_further:
102189
102190 latest = ntohl(sp->hdr.serial);
102191 hard = ntohl(ack.firstPacket);
102192 - tx = atomic_read(&call->sequence);
102193 + tx = atomic_read_unchecked(&call->sequence);
102194
102195 _proto("Rx ACK %%%u { m=%hu f=#%u p=#%u s=%%%u r=%s n=%u }",
102196 latest,
102197 @@ -1209,7 +1209,7 @@ void rxrpc_process_call(struct work_struct *work)
102198 goto maybe_reschedule;
102199
102200 send_ACK_with_skew:
102201 - ack.maxSkew = htons(atomic_read(&call->conn->hi_serial) -
102202 + ack.maxSkew = htons(atomic_read_unchecked(&call->conn->hi_serial) -
102203 ntohl(ack.serial));
102204 send_ACK:
102205 mtu = call->conn->trans->peer->if_mtu;
102206 @@ -1221,7 +1221,7 @@ send_ACK:
102207 ackinfo.rxMTU = htonl(rxrpc_rx_mtu);
102208 ackinfo.jumbo_max = htonl(rxrpc_rx_jumbo_max);
102209
102210 - hdr.serial = htonl(atomic_inc_return(&call->conn->serial));
102211 + hdr.serial = htonl(atomic_inc_return_unchecked(&call->conn->serial));
102212 _proto("Tx ACK %%%u { m=%hu f=#%u p=#%u s=%%%u r=%s n=%u }",
102213 ntohl(hdr.serial),
102214 ntohs(ack.maxSkew),
102215 @@ -1239,7 +1239,7 @@ send_ACK:
102216 send_message:
102217 _debug("send message");
102218
102219 - hdr.serial = htonl(atomic_inc_return(&call->conn->serial));
102220 + hdr.serial = htonl(atomic_inc_return_unchecked(&call->conn->serial));
102221 _proto("Tx %s %%%u", rxrpc_pkts[hdr.type], ntohl(hdr.serial));
102222 send_message_2:
102223
102224 diff --git a/net/rxrpc/ar-call.c b/net/rxrpc/ar-call.c
102225 index a9e05db..194e793 100644
102226 --- a/net/rxrpc/ar-call.c
102227 +++ b/net/rxrpc/ar-call.c
102228 @@ -232,7 +232,7 @@ static struct rxrpc_call *rxrpc_alloc_call(gfp_t gfp)
102229 spin_lock_init(&call->lock);
102230 rwlock_init(&call->state_lock);
102231 atomic_set(&call->usage, 1);
102232 - call->debug_id = atomic_inc_return(&rxrpc_debug_id);
102233 + call->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
102234 call->state = RXRPC_CALL_CLIENT_SEND_REQUEST;
102235
102236 memset(&call->sock_node, 0xed, sizeof(call->sock_node));
102237 diff --git a/net/rxrpc/ar-connection.c b/net/rxrpc/ar-connection.c
102238 index 6631f4f..bfdf056 100644
102239 --- a/net/rxrpc/ar-connection.c
102240 +++ b/net/rxrpc/ar-connection.c
102241 @@ -210,7 +210,7 @@ static struct rxrpc_connection *rxrpc_alloc_connection(gfp_t gfp)
102242 rwlock_init(&conn->lock);
102243 spin_lock_init(&conn->state_lock);
102244 atomic_set(&conn->usage, 1);
102245 - conn->debug_id = atomic_inc_return(&rxrpc_debug_id);
102246 + conn->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
102247 conn->avail_calls = RXRPC_MAXCALLS;
102248 conn->size_align = 4;
102249 conn->header_size = sizeof(struct rxrpc_header);
102250 diff --git a/net/rxrpc/ar-connevent.c b/net/rxrpc/ar-connevent.c
102251 index e7ed43a..6afa140 100644
102252 --- a/net/rxrpc/ar-connevent.c
102253 +++ b/net/rxrpc/ar-connevent.c
102254 @@ -109,7 +109,7 @@ static int rxrpc_abort_connection(struct rxrpc_connection *conn,
102255
102256 len = iov[0].iov_len + iov[1].iov_len;
102257
102258 - hdr.serial = htonl(atomic_inc_return(&conn->serial));
102259 + hdr.serial = htonl(atomic_inc_return_unchecked(&conn->serial));
102260 _proto("Tx CONN ABORT %%%u { %d }", ntohl(hdr.serial), abort_code);
102261
102262 ret = kernel_sendmsg(conn->trans->local->socket, &msg, iov, 2, len);
102263 diff --git a/net/rxrpc/ar-input.c b/net/rxrpc/ar-input.c
102264 index 63b21e5..330232e 100644
102265 --- a/net/rxrpc/ar-input.c
102266 +++ b/net/rxrpc/ar-input.c
102267 @@ -338,9 +338,9 @@ void rxrpc_fast_process_packet(struct rxrpc_call *call, struct sk_buff *skb)
102268 /* track the latest serial number on this connection for ACK packet
102269 * information */
102270 serial = ntohl(sp->hdr.serial);
102271 - hi_serial = atomic_read(&call->conn->hi_serial);
102272 + hi_serial = atomic_read_unchecked(&call->conn->hi_serial);
102273 while (serial > hi_serial)
102274 - hi_serial = atomic_cmpxchg(&call->conn->hi_serial, hi_serial,
102275 + hi_serial = atomic_cmpxchg_unchecked(&call->conn->hi_serial, hi_serial,
102276 serial);
102277
102278 /* request ACK generation for any ACK or DATA packet that requests
102279 diff --git a/net/rxrpc/ar-internal.h b/net/rxrpc/ar-internal.h
102280 index ba9fd36..9bbfe01 100644
102281 --- a/net/rxrpc/ar-internal.h
102282 +++ b/net/rxrpc/ar-internal.h
102283 @@ -272,8 +272,8 @@ struct rxrpc_connection {
102284 int error; /* error code for local abort */
102285 int debug_id; /* debug ID for printks */
102286 unsigned int call_counter; /* call ID counter */
102287 - atomic_t serial; /* packet serial number counter */
102288 - atomic_t hi_serial; /* highest serial number received */
102289 + atomic_unchecked_t serial; /* packet serial number counter */
102290 + atomic_unchecked_t hi_serial; /* highest serial number received */
102291 u8 avail_calls; /* number of calls available */
102292 u8 size_align; /* data size alignment (for security) */
102293 u8 header_size; /* rxrpc + security header size */
102294 @@ -346,7 +346,7 @@ struct rxrpc_call {
102295 spinlock_t lock;
102296 rwlock_t state_lock; /* lock for state transition */
102297 atomic_t usage;
102298 - atomic_t sequence; /* Tx data packet sequence counter */
102299 + atomic_unchecked_t sequence; /* Tx data packet sequence counter */
102300 u32 abort_code; /* local/remote abort code */
102301 enum { /* current state of call */
102302 RXRPC_CALL_CLIENT_SEND_REQUEST, /* - client sending request phase */
102303 @@ -431,7 +431,7 @@ static inline void rxrpc_abort_call(struct rxrpc_call *call, u32 abort_code)
102304 */
102305 extern atomic_t rxrpc_n_skbs;
102306 extern __be32 rxrpc_epoch;
102307 -extern atomic_t rxrpc_debug_id;
102308 +extern atomic_unchecked_t rxrpc_debug_id;
102309 extern struct workqueue_struct *rxrpc_workqueue;
102310
102311 /*
102312 diff --git a/net/rxrpc/ar-local.c b/net/rxrpc/ar-local.c
102313 index 87f7135..74d3703 100644
102314 --- a/net/rxrpc/ar-local.c
102315 +++ b/net/rxrpc/ar-local.c
102316 @@ -45,7 +45,7 @@ struct rxrpc_local *rxrpc_alloc_local(struct sockaddr_rxrpc *srx)
102317 spin_lock_init(&local->lock);
102318 rwlock_init(&local->services_lock);
102319 atomic_set(&local->usage, 1);
102320 - local->debug_id = atomic_inc_return(&rxrpc_debug_id);
102321 + local->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
102322 memcpy(&local->srx, srx, sizeof(*srx));
102323 }
102324
102325 diff --git a/net/rxrpc/ar-output.c b/net/rxrpc/ar-output.c
102326 index 0b4b9a7..966ffbb 100644
102327 --- a/net/rxrpc/ar-output.c
102328 +++ b/net/rxrpc/ar-output.c
102329 @@ -682,14 +682,14 @@ static int rxrpc_send_data(struct kiocb *iocb,
102330 memset(skb_put(skb, pad), 0, pad);
102331 }
102332
102333 - seq = atomic_inc_return(&call->sequence);
102334 + seq = atomic_inc_return_unchecked(&call->sequence);
102335
102336 sp->hdr.epoch = conn->epoch;
102337 sp->hdr.cid = call->cid;
102338 sp->hdr.callNumber = call->call_id;
102339 sp->hdr.seq = htonl(seq);
102340 sp->hdr.serial =
102341 - htonl(atomic_inc_return(&conn->serial));
102342 + htonl(atomic_inc_return_unchecked(&conn->serial));
102343 sp->hdr.type = RXRPC_PACKET_TYPE_DATA;
102344 sp->hdr.userStatus = 0;
102345 sp->hdr.securityIndex = conn->security_ix;
102346 diff --git a/net/rxrpc/ar-peer.c b/net/rxrpc/ar-peer.c
102347 index bebaa43..2644591 100644
102348 --- a/net/rxrpc/ar-peer.c
102349 +++ b/net/rxrpc/ar-peer.c
102350 @@ -72,7 +72,7 @@ static struct rxrpc_peer *rxrpc_alloc_peer(struct sockaddr_rxrpc *srx,
102351 INIT_LIST_HEAD(&peer->error_targets);
102352 spin_lock_init(&peer->lock);
102353 atomic_set(&peer->usage, 1);
102354 - peer->debug_id = atomic_inc_return(&rxrpc_debug_id);
102355 + peer->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
102356 memcpy(&peer->srx, srx, sizeof(*srx));
102357
102358 rxrpc_assess_MTU_size(peer);
102359 diff --git a/net/rxrpc/ar-proc.c b/net/rxrpc/ar-proc.c
102360 index 38047f7..9f48511 100644
102361 --- a/net/rxrpc/ar-proc.c
102362 +++ b/net/rxrpc/ar-proc.c
102363 @@ -164,8 +164,8 @@ static int rxrpc_connection_seq_show(struct seq_file *seq, void *v)
102364 atomic_read(&conn->usage),
102365 rxrpc_conn_states[conn->state],
102366 key_serial(conn->key),
102367 - atomic_read(&conn->serial),
102368 - atomic_read(&conn->hi_serial));
102369 + atomic_read_unchecked(&conn->serial),
102370 + atomic_read_unchecked(&conn->hi_serial));
102371
102372 return 0;
102373 }
102374 diff --git a/net/rxrpc/ar-transport.c b/net/rxrpc/ar-transport.c
102375 index 1976dec..aa70be5 100644
102376 --- a/net/rxrpc/ar-transport.c
102377 +++ b/net/rxrpc/ar-transport.c
102378 @@ -51,7 +51,7 @@ static struct rxrpc_transport *rxrpc_alloc_transport(struct rxrpc_local *local,
102379 spin_lock_init(&trans->client_lock);
102380 rwlock_init(&trans->conn_lock);
102381 atomic_set(&trans->usage, 1);
102382 - trans->debug_id = atomic_inc_return(&rxrpc_debug_id);
102383 + trans->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
102384
102385 if (peer->srx.transport.family == AF_INET) {
102386 switch (peer->srx.transport_type) {
102387 diff --git a/net/rxrpc/rxkad.c b/net/rxrpc/rxkad.c
102388 index f226709..0e735a8 100644
102389 --- a/net/rxrpc/rxkad.c
102390 +++ b/net/rxrpc/rxkad.c
102391 @@ -610,7 +610,7 @@ static int rxkad_issue_challenge(struct rxrpc_connection *conn)
102392
102393 len = iov[0].iov_len + iov[1].iov_len;
102394
102395 - hdr.serial = htonl(atomic_inc_return(&conn->serial));
102396 + hdr.serial = htonl(atomic_inc_return_unchecked(&conn->serial));
102397 _proto("Tx CHALLENGE %%%u", ntohl(hdr.serial));
102398
102399 ret = kernel_sendmsg(conn->trans->local->socket, &msg, iov, 2, len);
102400 @@ -660,7 +660,7 @@ static int rxkad_send_response(struct rxrpc_connection *conn,
102401
102402 len = iov[0].iov_len + iov[1].iov_len + iov[2].iov_len;
102403
102404 - hdr->serial = htonl(atomic_inc_return(&conn->serial));
102405 + hdr->serial = htonl(atomic_inc_return_unchecked(&conn->serial));
102406 _proto("Tx RESPONSE %%%u", ntohl(hdr->serial));
102407
102408 ret = kernel_sendmsg(conn->trans->local->socket, &msg, iov, 3, len);
102409 diff --git a/net/sched/sch_generic.c b/net/sched/sch_generic.c
102410 index e1543b0..7ce8bd0 100644
102411 --- a/net/sched/sch_generic.c
102412 +++ b/net/sched/sch_generic.c
102413 @@ -310,7 +310,7 @@ void netif_carrier_on(struct net_device *dev)
102414 if (test_and_clear_bit(__LINK_STATE_NOCARRIER, &dev->state)) {
102415 if (dev->reg_state == NETREG_UNINITIALIZED)
102416 return;
102417 - atomic_inc(&dev->carrier_changes);
102418 + atomic_inc_unchecked(&dev->carrier_changes);
102419 linkwatch_fire_event(dev);
102420 if (netif_running(dev))
102421 __netdev_watchdog_up(dev);
102422 @@ -329,7 +329,7 @@ void netif_carrier_off(struct net_device *dev)
102423 if (!test_and_set_bit(__LINK_STATE_NOCARRIER, &dev->state)) {
102424 if (dev->reg_state == NETREG_UNINITIALIZED)
102425 return;
102426 - atomic_inc(&dev->carrier_changes);
102427 + atomic_inc_unchecked(&dev->carrier_changes);
102428 linkwatch_fire_event(dev);
102429 }
102430 }
102431 diff --git a/net/sctp/ipv6.c b/net/sctp/ipv6.c
102432 index 2b1738e..a9d0fc9 100644
102433 --- a/net/sctp/ipv6.c
102434 +++ b/net/sctp/ipv6.c
102435 @@ -966,7 +966,7 @@ static const struct inet6_protocol sctpv6_protocol = {
102436 .flags = INET6_PROTO_NOPOLICY | INET6_PROTO_FINAL,
102437 };
102438
102439 -static struct sctp_af sctp_af_inet6 = {
102440 +static struct sctp_af sctp_af_inet6 __read_only = {
102441 .sa_family = AF_INET6,
102442 .sctp_xmit = sctp_v6_xmit,
102443 .setsockopt = ipv6_setsockopt,
102444 @@ -998,7 +998,7 @@ static struct sctp_af sctp_af_inet6 = {
102445 #endif
102446 };
102447
102448 -static struct sctp_pf sctp_pf_inet6 = {
102449 +static struct sctp_pf sctp_pf_inet6 __read_only = {
102450 .event_msgname = sctp_inet6_event_msgname,
102451 .skb_msgname = sctp_inet6_skb_msgname,
102452 .af_supported = sctp_inet6_af_supported,
102453 @@ -1023,7 +1023,7 @@ void sctp_v6_pf_init(void)
102454
102455 void sctp_v6_pf_exit(void)
102456 {
102457 - list_del(&sctp_af_inet6.list);
102458 + pax_list_del(&sctp_af_inet6.list);
102459 }
102460
102461 /* Initialize IPv6 support and register with socket layer. */
102462 diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c
102463 index 44cbb54..4c5dce6 100644
102464 --- a/net/sctp/protocol.c
102465 +++ b/net/sctp/protocol.c
102466 @@ -836,8 +836,10 @@ int sctp_register_af(struct sctp_af *af)
102467 return 0;
102468 }
102469
102470 + pax_open_kernel();
102471 INIT_LIST_HEAD(&af->list);
102472 - list_add_tail(&af->list, &sctp_address_families);
102473 + pax_close_kernel();
102474 + pax_list_add_tail(&af->list, &sctp_address_families);
102475 return 1;
102476 }
102477
102478 @@ -967,7 +969,7 @@ static inline int sctp_v4_xmit(struct sk_buff *skb,
102479
102480 static struct sctp_af sctp_af_inet;
102481
102482 -static struct sctp_pf sctp_pf_inet = {
102483 +static struct sctp_pf sctp_pf_inet __read_only = {
102484 .event_msgname = sctp_inet_event_msgname,
102485 .skb_msgname = sctp_inet_skb_msgname,
102486 .af_supported = sctp_inet_af_supported,
102487 @@ -1039,7 +1041,7 @@ static const struct net_protocol sctp_protocol = {
102488 };
102489
102490 /* IPv4 address related functions. */
102491 -static struct sctp_af sctp_af_inet = {
102492 +static struct sctp_af sctp_af_inet __read_only = {
102493 .sa_family = AF_INET,
102494 .sctp_xmit = sctp_v4_xmit,
102495 .setsockopt = ip_setsockopt,
102496 @@ -1124,7 +1126,7 @@ static void sctp_v4_pf_init(void)
102497
102498 static void sctp_v4_pf_exit(void)
102499 {
102500 - list_del(&sctp_af_inet.list);
102501 + pax_list_del(&sctp_af_inet.list);
102502 }
102503
102504 static int sctp_v4_protosw_init(void)
102505 diff --git a/net/sctp/sm_sideeffect.c b/net/sctp/sm_sideeffect.c
102506 index fef2acd..c705c4f 100644
102507 --- a/net/sctp/sm_sideeffect.c
102508 +++ b/net/sctp/sm_sideeffect.c
102509 @@ -439,7 +439,7 @@ static void sctp_generate_sack_event(unsigned long data)
102510 sctp_generate_timeout_event(asoc, SCTP_EVENT_TIMEOUT_SACK);
102511 }
102512
102513 -sctp_timer_event_t *sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES] = {
102514 +sctp_timer_event_t * const sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES] = {
102515 NULL,
102516 sctp_generate_t1_cookie_event,
102517 sctp_generate_t1_init_event,
102518 diff --git a/net/sctp/socket.c b/net/sctp/socket.c
102519 index fee06b9..eabc613 100644
102520 --- a/net/sctp/socket.c
102521 +++ b/net/sctp/socket.c
102522 @@ -2175,11 +2175,13 @@ static int sctp_setsockopt_events(struct sock *sk, char __user *optval,
102523 {
102524 struct sctp_association *asoc;
102525 struct sctp_ulpevent *event;
102526 + struct sctp_event_subscribe subscribe;
102527
102528 if (optlen > sizeof(struct sctp_event_subscribe))
102529 return -EINVAL;
102530 - if (copy_from_user(&sctp_sk(sk)->subscribe, optval, optlen))
102531 + if (copy_from_user(&subscribe, optval, optlen))
102532 return -EFAULT;
102533 + sctp_sk(sk)->subscribe = subscribe;
102534
102535 /*
102536 * At the time when a user app subscribes to SCTP_SENDER_DRY_EVENT,
102537 @@ -4259,13 +4261,16 @@ static int sctp_getsockopt_disable_fragments(struct sock *sk, int len,
102538 static int sctp_getsockopt_events(struct sock *sk, int len, char __user *optval,
102539 int __user *optlen)
102540 {
102541 + struct sctp_event_subscribe subscribe;
102542 +
102543 if (len <= 0)
102544 return -EINVAL;
102545 if (len > sizeof(struct sctp_event_subscribe))
102546 len = sizeof(struct sctp_event_subscribe);
102547 if (put_user(len, optlen))
102548 return -EFAULT;
102549 - if (copy_to_user(optval, &sctp_sk(sk)->subscribe, len))
102550 + subscribe = sctp_sk(sk)->subscribe;
102551 + if (copy_to_user(optval, &subscribe, len))
102552 return -EFAULT;
102553 return 0;
102554 }
102555 @@ -4283,6 +4288,8 @@ static int sctp_getsockopt_events(struct sock *sk, int len, char __user *optval,
102556 */
102557 static int sctp_getsockopt_autoclose(struct sock *sk, int len, char __user *optval, int __user *optlen)
102558 {
102559 + __u32 autoclose;
102560 +
102561 /* Applicable to UDP-style socket only */
102562 if (sctp_style(sk, TCP))
102563 return -EOPNOTSUPP;
102564 @@ -4291,7 +4298,8 @@ static int sctp_getsockopt_autoclose(struct sock *sk, int len, char __user *optv
102565 len = sizeof(int);
102566 if (put_user(len, optlen))
102567 return -EFAULT;
102568 - if (copy_to_user(optval, &sctp_sk(sk)->autoclose, sizeof(int)))
102569 + autoclose = sctp_sk(sk)->autoclose;
102570 + if (copy_to_user(optval, &autoclose, sizeof(int)))
102571 return -EFAULT;
102572 return 0;
102573 }
102574 @@ -4666,12 +4674,15 @@ static int sctp_getsockopt_delayed_ack(struct sock *sk, int len,
102575 */
102576 static int sctp_getsockopt_initmsg(struct sock *sk, int len, char __user *optval, int __user *optlen)
102577 {
102578 + struct sctp_initmsg initmsg;
102579 +
102580 if (len < sizeof(struct sctp_initmsg))
102581 return -EINVAL;
102582 len = sizeof(struct sctp_initmsg);
102583 if (put_user(len, optlen))
102584 return -EFAULT;
102585 - if (copy_to_user(optval, &sctp_sk(sk)->initmsg, len))
102586 + initmsg = sctp_sk(sk)->initmsg;
102587 + if (copy_to_user(optval, &initmsg, len))
102588 return -EFAULT;
102589 return 0;
102590 }
102591 @@ -4712,6 +4723,8 @@ static int sctp_getsockopt_peer_addrs(struct sock *sk, int len,
102592 addrlen = sctp_get_af_specific(temp.sa.sa_family)->sockaddr_len;
102593 if (space_left < addrlen)
102594 return -ENOMEM;
102595 + if (addrlen > sizeof(temp) || addrlen < 0)
102596 + return -EFAULT;
102597 if (copy_to_user(to, &temp, addrlen))
102598 return -EFAULT;
102599 to += addrlen;
102600 diff --git a/net/sctp/sysctl.c b/net/sctp/sysctl.c
102601 index c82fdc1..4ca1f95 100644
102602 --- a/net/sctp/sysctl.c
102603 +++ b/net/sctp/sysctl.c
102604 @@ -308,7 +308,7 @@ static int proc_sctp_do_hmac_alg(struct ctl_table *ctl, int write,
102605 {
102606 struct net *net = current->nsproxy->net_ns;
102607 char tmp[8];
102608 - struct ctl_table tbl;
102609 + ctl_table_no_const tbl;
102610 int ret;
102611 int changed = 0;
102612 char *none = "none";
102613 @@ -355,7 +355,7 @@ static int proc_sctp_do_rto_min(struct ctl_table *ctl, int write,
102614 {
102615 struct net *net = current->nsproxy->net_ns;
102616 int new_value;
102617 - struct ctl_table tbl;
102618 + ctl_table_no_const tbl;
102619 unsigned int min = *(unsigned int *) ctl->extra1;
102620 unsigned int max = *(unsigned int *) ctl->extra2;
102621 int ret;
102622 @@ -382,7 +382,7 @@ static int proc_sctp_do_rto_max(struct ctl_table *ctl, int write,
102623 {
102624 struct net *net = current->nsproxy->net_ns;
102625 int new_value;
102626 - struct ctl_table tbl;
102627 + ctl_table_no_const tbl;
102628 unsigned int min = *(unsigned int *) ctl->extra1;
102629 unsigned int max = *(unsigned int *) ctl->extra2;
102630 int ret;
102631 @@ -408,7 +408,7 @@ static int proc_sctp_do_auth(struct ctl_table *ctl, int write,
102632 loff_t *ppos)
102633 {
102634 struct net *net = current->nsproxy->net_ns;
102635 - struct ctl_table tbl;
102636 + ctl_table_no_const tbl;
102637 int new_value, ret;
102638
102639 memset(&tbl, 0, sizeof(struct ctl_table));
102640 @@ -436,7 +436,7 @@ static int proc_sctp_do_auth(struct ctl_table *ctl, int write,
102641
102642 int sctp_sysctl_net_register(struct net *net)
102643 {
102644 - struct ctl_table *table = sctp_net_table;
102645 + ctl_table_no_const *table = NULL;
102646
102647 if (!net_eq(net, &init_net)) {
102648 int i;
102649 @@ -449,7 +449,10 @@ int sctp_sysctl_net_register(struct net *net)
102650 table[i].data += (char *)(&net->sctp) - (char *)&init_net.sctp;
102651 }
102652
102653 - net->sctp.sysctl_header = register_net_sysctl(net, "net/sctp", table);
102654 + if (!net_eq(net, &init_net))
102655 + net->sctp.sysctl_header = register_net_sysctl(net, "net/sctp", table);
102656 + else
102657 + net->sctp.sysctl_header = register_net_sysctl(net, "net/sctp", sctp_net_table);
102658 return 0;
102659 }
102660
102661 diff --git a/net/socket.c b/net/socket.c
102662 index abf56b2..b8998bc 100644
102663 --- a/net/socket.c
102664 +++ b/net/socket.c
102665 @@ -89,6 +89,7 @@
102666 #include <linux/magic.h>
102667 #include <linux/slab.h>
102668 #include <linux/xattr.h>
102669 +#include <linux/in.h>
102670
102671 #include <asm/uaccess.h>
102672 #include <asm/unistd.h>
102673 @@ -112,6 +113,8 @@ unsigned int sysctl_net_busy_read __read_mostly;
102674 unsigned int sysctl_net_busy_poll __read_mostly;
102675 #endif
102676
102677 +#include <linux/grsock.h>
102678 +
102679 static int sock_no_open(struct inode *irrelevant, struct file *dontcare);
102680 static ssize_t sock_aio_read(struct kiocb *iocb, const struct iovec *iov,
102681 unsigned long nr_segs, loff_t pos);
102682 @@ -163,7 +166,7 @@ static const struct file_operations socket_file_ops = {
102683 */
102684
102685 static DEFINE_SPINLOCK(net_family_lock);
102686 -static const struct net_proto_family __rcu *net_families[NPROTO] __read_mostly;
102687 +const struct net_proto_family __rcu *net_families[NPROTO] __read_mostly;
102688
102689 /*
102690 * Statistics counters of the socket lists
102691 @@ -329,7 +332,7 @@ static struct dentry *sockfs_mount(struct file_system_type *fs_type,
102692 &sockfs_dentry_operations, SOCKFS_MAGIC);
102693 }
102694
102695 -static struct vfsmount *sock_mnt __read_mostly;
102696 +struct vfsmount *sock_mnt __read_mostly;
102697
102698 static struct file_system_type sock_fs_type = {
102699 .name = "sockfs",
102700 @@ -1257,6 +1260,8 @@ int __sock_create(struct net *net, int family, int type, int protocol,
102701 return -EAFNOSUPPORT;
102702 if (type < 0 || type >= SOCK_MAX)
102703 return -EINVAL;
102704 + if (protocol < 0)
102705 + return -EINVAL;
102706
102707 /* Compatibility.
102708
102709 @@ -1277,6 +1282,20 @@ int __sock_create(struct net *net, int family, int type, int protocol,
102710 if (err)
102711 return err;
102712
102713 + if(!kern && !gr_search_socket(family, type, protocol)) {
102714 + if (rcu_access_pointer(net_families[family]) == NULL)
102715 + return -EAFNOSUPPORT;
102716 + else
102717 + return -EACCES;
102718 + }
102719 +
102720 + if (!kern && gr_handle_sock_all(family, type, protocol)) {
102721 + if (rcu_access_pointer(net_families[family]) == NULL)
102722 + return -EAFNOSUPPORT;
102723 + else
102724 + return -EACCES;
102725 + }
102726 +
102727 /*
102728 * Allocate the socket and allow the family to set things up. if
102729 * the protocol is 0, the family is instructed to select an appropriate
102730 @@ -1528,6 +1547,14 @@ SYSCALL_DEFINE3(bind, int, fd, struct sockaddr __user *, umyaddr, int, addrlen)
102731 if (sock) {
102732 err = move_addr_to_kernel(umyaddr, addrlen, &address);
102733 if (err >= 0) {
102734 + if (gr_handle_sock_server((struct sockaddr *)&address)) {
102735 + err = -EACCES;
102736 + goto error;
102737 + }
102738 + err = gr_search_bind(sock, (struct sockaddr_in *)&address);
102739 + if (err)
102740 + goto error;
102741 +
102742 err = security_socket_bind(sock,
102743 (struct sockaddr *)&address,
102744 addrlen);
102745 @@ -1536,6 +1563,7 @@ SYSCALL_DEFINE3(bind, int, fd, struct sockaddr __user *, umyaddr, int, addrlen)
102746 (struct sockaddr *)
102747 &address, addrlen);
102748 }
102749 +error:
102750 fput_light(sock->file, fput_needed);
102751 }
102752 return err;
102753 @@ -1559,10 +1587,20 @@ SYSCALL_DEFINE2(listen, int, fd, int, backlog)
102754 if ((unsigned int)backlog > somaxconn)
102755 backlog = somaxconn;
102756
102757 + if (gr_handle_sock_server_other(sock->sk)) {
102758 + err = -EPERM;
102759 + goto error;
102760 + }
102761 +
102762 + err = gr_search_listen(sock);
102763 + if (err)
102764 + goto error;
102765 +
102766 err = security_socket_listen(sock, backlog);
102767 if (!err)
102768 err = sock->ops->listen(sock, backlog);
102769
102770 +error:
102771 fput_light(sock->file, fput_needed);
102772 }
102773 return err;
102774 @@ -1606,6 +1644,18 @@ SYSCALL_DEFINE4(accept4, int, fd, struct sockaddr __user *, upeer_sockaddr,
102775 newsock->type = sock->type;
102776 newsock->ops = sock->ops;
102777
102778 + if (gr_handle_sock_server_other(sock->sk)) {
102779 + err = -EPERM;
102780 + sock_release(newsock);
102781 + goto out_put;
102782 + }
102783 +
102784 + err = gr_search_accept(sock);
102785 + if (err) {
102786 + sock_release(newsock);
102787 + goto out_put;
102788 + }
102789 +
102790 /*
102791 * We don't need try_module_get here, as the listening socket (sock)
102792 * has the protocol module (sock->ops->owner) held.
102793 @@ -1651,6 +1701,8 @@ SYSCALL_DEFINE4(accept4, int, fd, struct sockaddr __user *, upeer_sockaddr,
102794 fd_install(newfd, newfile);
102795 err = newfd;
102796
102797 + gr_attach_curr_ip(newsock->sk);
102798 +
102799 out_put:
102800 fput_light(sock->file, fput_needed);
102801 out:
102802 @@ -1683,6 +1735,7 @@ SYSCALL_DEFINE3(connect, int, fd, struct sockaddr __user *, uservaddr,
102803 int, addrlen)
102804 {
102805 struct socket *sock;
102806 + struct sockaddr *sck;
102807 struct sockaddr_storage address;
102808 int err, fput_needed;
102809
102810 @@ -1693,6 +1746,17 @@ SYSCALL_DEFINE3(connect, int, fd, struct sockaddr __user *, uservaddr,
102811 if (err < 0)
102812 goto out_put;
102813
102814 + sck = (struct sockaddr *)&address;
102815 +
102816 + if (gr_handle_sock_client(sck)) {
102817 + err = -EACCES;
102818 + goto out_put;
102819 + }
102820 +
102821 + err = gr_search_connect(sock, (struct sockaddr_in *)sck);
102822 + if (err)
102823 + goto out_put;
102824 +
102825 err =
102826 security_socket_connect(sock, (struct sockaddr *)&address, addrlen);
102827 if (err)
102828 @@ -1774,6 +1838,8 @@ SYSCALL_DEFINE3(getpeername, int, fd, struct sockaddr __user *, usockaddr,
102829 * the protocol.
102830 */
102831
102832 +asmlinkage long sys_sendto(int, void __user *, size_t, unsigned, struct sockaddr __user *, int);
102833 +
102834 SYSCALL_DEFINE6(sendto, int, fd, void __user *, buff, size_t, len,
102835 unsigned int, flags, struct sockaddr __user *, addr,
102836 int, addr_len)
102837 @@ -1840,7 +1906,7 @@ SYSCALL_DEFINE6(recvfrom, int, fd, void __user *, ubuf, size_t, size,
102838 struct socket *sock;
102839 struct iovec iov;
102840 struct msghdr msg;
102841 - struct sockaddr_storage address;
102842 + struct sockaddr_storage address = { };
102843 int err, err2;
102844 int fput_needed;
102845
102846 @@ -2066,7 +2132,7 @@ static int ___sys_sendmsg(struct socket *sock, struct msghdr __user *msg,
102847 * checking falls down on this.
102848 */
102849 if (copy_from_user(ctl_buf,
102850 - (void __user __force *)msg_sys->msg_control,
102851 + (void __force_user *)msg_sys->msg_control,
102852 ctl_len))
102853 goto out_freectl;
102854 msg_sys->msg_control = ctl_buf;
102855 @@ -2217,7 +2283,7 @@ static int ___sys_recvmsg(struct socket *sock, struct msghdr __user *msg,
102856 int err, total_len, len;
102857
102858 /* kernel mode address */
102859 - struct sockaddr_storage addr;
102860 + struct sockaddr_storage addr = { };
102861
102862 /* user mode address pointers */
102863 struct sockaddr __user *uaddr;
102864 @@ -2246,7 +2312,7 @@ static int ___sys_recvmsg(struct socket *sock, struct msghdr __user *msg,
102865 /* Save the user-mode address (verify_iovec will change the
102866 * kernel msghdr to use the kernel address space)
102867 */
102868 - uaddr = (__force void __user *)msg_sys->msg_name;
102869 + uaddr = (void __force_user *)msg_sys->msg_name;
102870 uaddr_len = COMPAT_NAMELEN(msg);
102871 if (MSG_CMSG_COMPAT & flags)
102872 err = verify_compat_iovec(msg_sys, iov, &addr, VERIFY_WRITE);
102873 @@ -2887,7 +2953,7 @@ static int ethtool_ioctl(struct net *net, struct compat_ifreq __user *ifr32)
102874 ifr = compat_alloc_user_space(buf_size);
102875 rxnfc = (void __user *)ifr + ALIGN(sizeof(struct ifreq), 8);
102876
102877 - if (copy_in_user(&ifr->ifr_name, &ifr32->ifr_name, IFNAMSIZ))
102878 + if (copy_in_user(ifr->ifr_name, ifr32->ifr_name, IFNAMSIZ))
102879 return -EFAULT;
102880
102881 if (put_user(convert_in ? rxnfc : compat_ptr(data),
102882 @@ -2998,7 +3064,7 @@ static int bond_ioctl(struct net *net, unsigned int cmd,
102883 old_fs = get_fs();
102884 set_fs(KERNEL_DS);
102885 err = dev_ioctl(net, cmd,
102886 - (struct ifreq __user __force *) &kifr);
102887 + (struct ifreq __force_user *) &kifr);
102888 set_fs(old_fs);
102889
102890 return err;
102891 @@ -3091,7 +3157,7 @@ static int compat_sioc_ifmap(struct net *net, unsigned int cmd,
102892
102893 old_fs = get_fs();
102894 set_fs(KERNEL_DS);
102895 - err = dev_ioctl(net, cmd, (void __user __force *)&ifr);
102896 + err = dev_ioctl(net, cmd, (void __force_user *)&ifr);
102897 set_fs(old_fs);
102898
102899 if (cmd == SIOCGIFMAP && !err) {
102900 @@ -3175,7 +3241,7 @@ static int routing_ioctl(struct net *net, struct socket *sock,
102901 ret |= get_user(rtdev, &(ur4->rt_dev));
102902 if (rtdev) {
102903 ret |= copy_from_user(devname, compat_ptr(rtdev), 15);
102904 - r4.rt_dev = (char __user __force *)devname;
102905 + r4.rt_dev = (char __force_user *)devname;
102906 devname[15] = 0;
102907 } else
102908 r4.rt_dev = NULL;
102909 @@ -3402,8 +3468,8 @@ int kernel_getsockopt(struct socket *sock, int level, int optname,
102910 int __user *uoptlen;
102911 int err;
102912
102913 - uoptval = (char __user __force *) optval;
102914 - uoptlen = (int __user __force *) optlen;
102915 + uoptval = (char __force_user *) optval;
102916 + uoptlen = (int __force_user *) optlen;
102917
102918 set_fs(KERNEL_DS);
102919 if (level == SOL_SOCKET)
102920 @@ -3423,7 +3489,7 @@ int kernel_setsockopt(struct socket *sock, int level, int optname,
102921 char __user *uoptval;
102922 int err;
102923
102924 - uoptval = (char __user __force *) optval;
102925 + uoptval = (char __force_user *) optval;
102926
102927 set_fs(KERNEL_DS);
102928 if (level == SOL_SOCKET)
102929 diff --git a/net/sunrpc/auth_gss/svcauth_gss.c b/net/sunrpc/auth_gss/svcauth_gss.c
102930 index 0f73f45..a96aa52 100644
102931 --- a/net/sunrpc/auth_gss/svcauth_gss.c
102932 +++ b/net/sunrpc/auth_gss/svcauth_gss.c
102933 @@ -1140,7 +1140,7 @@ static int gss_proxy_save_rsc(struct cache_detail *cd,
102934 uint64_t *handle)
102935 {
102936 struct rsc rsci, *rscp = NULL;
102937 - static atomic64_t ctxhctr;
102938 + static atomic64_unchecked_t ctxhctr = ATOMIC64_INIT(0);
102939 long long ctxh;
102940 struct gss_api_mech *gm = NULL;
102941 time_t expiry;
102942 @@ -1151,7 +1151,7 @@ static int gss_proxy_save_rsc(struct cache_detail *cd,
102943 status = -ENOMEM;
102944 /* the handle needs to be just a unique id,
102945 * use a static counter */
102946 - ctxh = atomic64_inc_return(&ctxhctr);
102947 + ctxh = atomic64_inc_return_unchecked(&ctxhctr);
102948
102949 /* make a copy for the caller */
102950 *handle = ctxh;
102951 diff --git a/net/sunrpc/cache.c b/net/sunrpc/cache.c
102952 index ae333c1..18521f0 100644
102953 --- a/net/sunrpc/cache.c
102954 +++ b/net/sunrpc/cache.c
102955 @@ -1609,7 +1609,7 @@ static int create_cache_proc_entries(struct cache_detail *cd, struct net *net)
102956 struct sunrpc_net *sn;
102957
102958 sn = net_generic(net, sunrpc_net_id);
102959 - cd->u.procfs.proc_ent = proc_mkdir(cd->name, sn->proc_net_rpc);
102960 + cd->u.procfs.proc_ent = proc_mkdir_restrict(cd->name, sn->proc_net_rpc);
102961 if (cd->u.procfs.proc_ent == NULL)
102962 goto out_nomem;
102963 cd->u.procfs.channel_ent = NULL;
102964 diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c
102965 index 2e6ab10..3170800 100644
102966 --- a/net/sunrpc/clnt.c
102967 +++ b/net/sunrpc/clnt.c
102968 @@ -1425,7 +1425,9 @@ call_start(struct rpc_task *task)
102969 (RPC_IS_ASYNC(task) ? "async" : "sync"));
102970
102971 /* Increment call count */
102972 - task->tk_msg.rpc_proc->p_count++;
102973 + pax_open_kernel();
102974 + (*(unsigned int *)&task->tk_msg.rpc_proc->p_count)++;
102975 + pax_close_kernel();
102976 clnt->cl_stats->rpccnt++;
102977 task->tk_action = call_reserve;
102978 }
102979 diff --git a/net/sunrpc/sched.c b/net/sunrpc/sched.c
102980 index 25578af..a29298d 100644
102981 --- a/net/sunrpc/sched.c
102982 +++ b/net/sunrpc/sched.c
102983 @@ -261,9 +261,9 @@ static int rpc_wait_bit_killable(void *word)
102984 #if defined(RPC_DEBUG) || defined(RPC_TRACEPOINTS)
102985 static void rpc_task_set_debuginfo(struct rpc_task *task)
102986 {
102987 - static atomic_t rpc_pid;
102988 + static atomic_unchecked_t rpc_pid;
102989
102990 - task->tk_pid = atomic_inc_return(&rpc_pid);
102991 + task->tk_pid = atomic_inc_return_unchecked(&rpc_pid);
102992 }
102993 #else
102994 static inline void rpc_task_set_debuginfo(struct rpc_task *task)
102995 diff --git a/net/sunrpc/stats.c b/net/sunrpc/stats.c
102996 index 5453049..465669a 100644
102997 --- a/net/sunrpc/stats.c
102998 +++ b/net/sunrpc/stats.c
102999 @@ -267,7 +267,7 @@ int rpc_proc_init(struct net *net)
103000
103001 dprintk("RPC: registering /proc/net/rpc\n");
103002 sn = net_generic(net, sunrpc_net_id);
103003 - sn->proc_net_rpc = proc_mkdir("rpc", net->proc_net);
103004 + sn->proc_net_rpc = proc_mkdir_restrict("rpc", net->proc_net);
103005 if (sn->proc_net_rpc == NULL)
103006 return -ENOMEM;
103007
103008 diff --git a/net/sunrpc/svc.c b/net/sunrpc/svc.c
103009 index 5de6801..b4e330d 100644
103010 --- a/net/sunrpc/svc.c
103011 +++ b/net/sunrpc/svc.c
103012 @@ -1167,7 +1167,9 @@ svc_process_common(struct svc_rqst *rqstp, struct kvec *argv, struct kvec *resv)
103013 svc_putnl(resv, RPC_SUCCESS);
103014
103015 /* Bump per-procedure stats counter */
103016 - procp->pc_count++;
103017 + pax_open_kernel();
103018 + (*(unsigned int *)&procp->pc_count)++;
103019 + pax_close_kernel();
103020
103021 /* Initialize storage for argp and resp */
103022 memset(rqstp->rq_argp, 0, procp->pc_argsize);
103023 diff --git a/net/sunrpc/svcauth_unix.c b/net/sunrpc/svcauth_unix.c
103024 index 621ca7b..59421dd 100644
103025 --- a/net/sunrpc/svcauth_unix.c
103026 +++ b/net/sunrpc/svcauth_unix.c
103027 @@ -414,7 +414,7 @@ struct unix_gid {
103028 struct group_info *gi;
103029 };
103030
103031 -static int unix_gid_hash(kuid_t uid)
103032 +static int __intentional_overflow(-1) unix_gid_hash(kuid_t uid)
103033 {
103034 return hash_long(from_kuid(&init_user_ns, uid), GID_HASHBITS);
103035 }
103036 @@ -470,7 +470,7 @@ static void unix_gid_request(struct cache_detail *cd,
103037 (*bpp)[-1] = '\n';
103038 }
103039
103040 -static struct unix_gid *unix_gid_lookup(struct cache_detail *cd, kuid_t uid);
103041 +static struct unix_gid * __intentional_overflow(-1) unix_gid_lookup(struct cache_detail *cd, kuid_t uid);
103042
103043 static int unix_gid_parse(struct cache_detail *cd,
103044 char *mesg, int mlen)
103045 diff --git a/net/sunrpc/xprtrdma/svc_rdma.c b/net/sunrpc/xprtrdma/svc_rdma.c
103046 index c1b6270..05089c1 100644
103047 --- a/net/sunrpc/xprtrdma/svc_rdma.c
103048 +++ b/net/sunrpc/xprtrdma/svc_rdma.c
103049 @@ -62,15 +62,15 @@ unsigned int svcrdma_max_req_size = RPCRDMA_MAX_REQ_SIZE;
103050 static unsigned int min_max_inline = 4096;
103051 static unsigned int max_max_inline = 65536;
103052
103053 -atomic_t rdma_stat_recv;
103054 -atomic_t rdma_stat_read;
103055 -atomic_t rdma_stat_write;
103056 -atomic_t rdma_stat_sq_starve;
103057 -atomic_t rdma_stat_rq_starve;
103058 -atomic_t rdma_stat_rq_poll;
103059 -atomic_t rdma_stat_rq_prod;
103060 -atomic_t rdma_stat_sq_poll;
103061 -atomic_t rdma_stat_sq_prod;
103062 +atomic_unchecked_t rdma_stat_recv;
103063 +atomic_unchecked_t rdma_stat_read;
103064 +atomic_unchecked_t rdma_stat_write;
103065 +atomic_unchecked_t rdma_stat_sq_starve;
103066 +atomic_unchecked_t rdma_stat_rq_starve;
103067 +atomic_unchecked_t rdma_stat_rq_poll;
103068 +atomic_unchecked_t rdma_stat_rq_prod;
103069 +atomic_unchecked_t rdma_stat_sq_poll;
103070 +atomic_unchecked_t rdma_stat_sq_prod;
103071
103072 /* Temporary NFS request map and context caches */
103073 struct kmem_cache *svc_rdma_map_cachep;
103074 @@ -110,7 +110,7 @@ static int read_reset_stat(struct ctl_table *table, int write,
103075 len -= *ppos;
103076 if (len > *lenp)
103077 len = *lenp;
103078 - if (len && copy_to_user(buffer, str_buf, len))
103079 + if (len > sizeof str_buf || (len && copy_to_user(buffer, str_buf, len)))
103080 return -EFAULT;
103081 *lenp = len;
103082 *ppos += len;
103083 @@ -151,63 +151,63 @@ static struct ctl_table svcrdma_parm_table[] = {
103084 {
103085 .procname = "rdma_stat_read",
103086 .data = &rdma_stat_read,
103087 - .maxlen = sizeof(atomic_t),
103088 + .maxlen = sizeof(atomic_unchecked_t),
103089 .mode = 0644,
103090 .proc_handler = read_reset_stat,
103091 },
103092 {
103093 .procname = "rdma_stat_recv",
103094 .data = &rdma_stat_recv,
103095 - .maxlen = sizeof(atomic_t),
103096 + .maxlen = sizeof(atomic_unchecked_t),
103097 .mode = 0644,
103098 .proc_handler = read_reset_stat,
103099 },
103100 {
103101 .procname = "rdma_stat_write",
103102 .data = &rdma_stat_write,
103103 - .maxlen = sizeof(atomic_t),
103104 + .maxlen = sizeof(atomic_unchecked_t),
103105 .mode = 0644,
103106 .proc_handler = read_reset_stat,
103107 },
103108 {
103109 .procname = "rdma_stat_sq_starve",
103110 .data = &rdma_stat_sq_starve,
103111 - .maxlen = sizeof(atomic_t),
103112 + .maxlen = sizeof(atomic_unchecked_t),
103113 .mode = 0644,
103114 .proc_handler = read_reset_stat,
103115 },
103116 {
103117 .procname = "rdma_stat_rq_starve",
103118 .data = &rdma_stat_rq_starve,
103119 - .maxlen = sizeof(atomic_t),
103120 + .maxlen = sizeof(atomic_unchecked_t),
103121 .mode = 0644,
103122 .proc_handler = read_reset_stat,
103123 },
103124 {
103125 .procname = "rdma_stat_rq_poll",
103126 .data = &rdma_stat_rq_poll,
103127 - .maxlen = sizeof(atomic_t),
103128 + .maxlen = sizeof(atomic_unchecked_t),
103129 .mode = 0644,
103130 .proc_handler = read_reset_stat,
103131 },
103132 {
103133 .procname = "rdma_stat_rq_prod",
103134 .data = &rdma_stat_rq_prod,
103135 - .maxlen = sizeof(atomic_t),
103136 + .maxlen = sizeof(atomic_unchecked_t),
103137 .mode = 0644,
103138 .proc_handler = read_reset_stat,
103139 },
103140 {
103141 .procname = "rdma_stat_sq_poll",
103142 .data = &rdma_stat_sq_poll,
103143 - .maxlen = sizeof(atomic_t),
103144 + .maxlen = sizeof(atomic_unchecked_t),
103145 .mode = 0644,
103146 .proc_handler = read_reset_stat,
103147 },
103148 {
103149 .procname = "rdma_stat_sq_prod",
103150 .data = &rdma_stat_sq_prod,
103151 - .maxlen = sizeof(atomic_t),
103152 + .maxlen = sizeof(atomic_unchecked_t),
103153 .mode = 0644,
103154 .proc_handler = read_reset_stat,
103155 },
103156 diff --git a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
103157 index 8d904e4..b2fc727 100644
103158 --- a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
103159 +++ b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
103160 @@ -504,7 +504,7 @@ next_sge:
103161 svc_rdma_put_context(ctxt, 0);
103162 goto out;
103163 }
103164 - atomic_inc(&rdma_stat_read);
103165 + atomic_inc_unchecked(&rdma_stat_read);
103166
103167 if (read_wr.num_sge < chl_map->ch[ch_no].count) {
103168 chl_map->ch[ch_no].count -= read_wr.num_sge;
103169 @@ -607,7 +607,7 @@ int svc_rdma_recvfrom(struct svc_rqst *rqstp)
103170 dto_q);
103171 list_del_init(&ctxt->dto_q);
103172 } else {
103173 - atomic_inc(&rdma_stat_rq_starve);
103174 + atomic_inc_unchecked(&rdma_stat_rq_starve);
103175 clear_bit(XPT_DATA, &xprt->xpt_flags);
103176 ctxt = NULL;
103177 }
103178 @@ -627,7 +627,7 @@ int svc_rdma_recvfrom(struct svc_rqst *rqstp)
103179 dprintk("svcrdma: processing ctxt=%p on xprt=%p, rqstp=%p, status=%d\n",
103180 ctxt, rdma_xprt, rqstp, ctxt->wc_status);
103181 BUG_ON(ctxt->wc_status != IB_WC_SUCCESS);
103182 - atomic_inc(&rdma_stat_recv);
103183 + atomic_inc_unchecked(&rdma_stat_recv);
103184
103185 /* Build up the XDR from the receive buffers. */
103186 rdma_build_arg_xdr(rqstp, ctxt, ctxt->byte_len);
103187 diff --git a/net/sunrpc/xprtrdma/svc_rdma_sendto.c b/net/sunrpc/xprtrdma/svc_rdma_sendto.c
103188 index 7e024a5..17f13d3 100644
103189 --- a/net/sunrpc/xprtrdma/svc_rdma_sendto.c
103190 +++ b/net/sunrpc/xprtrdma/svc_rdma_sendto.c
103191 @@ -363,7 +363,7 @@ static int send_write(struct svcxprt_rdma *xprt, struct svc_rqst *rqstp,
103192 write_wr.wr.rdma.remote_addr = to;
103193
103194 /* Post It */
103195 - atomic_inc(&rdma_stat_write);
103196 + atomic_inc_unchecked(&rdma_stat_write);
103197 if (svc_rdma_send(xprt, &write_wr))
103198 goto err;
103199 return 0;
103200 diff --git a/net/sunrpc/xprtrdma/svc_rdma_transport.c b/net/sunrpc/xprtrdma/svc_rdma_transport.c
103201 index 25688fa..dc72003 100644
103202 --- a/net/sunrpc/xprtrdma/svc_rdma_transport.c
103203 +++ b/net/sunrpc/xprtrdma/svc_rdma_transport.c
103204 @@ -292,7 +292,7 @@ static void rq_cq_reap(struct svcxprt_rdma *xprt)
103205 return;
103206
103207 ib_req_notify_cq(xprt->sc_rq_cq, IB_CQ_NEXT_COMP);
103208 - atomic_inc(&rdma_stat_rq_poll);
103209 + atomic_inc_unchecked(&rdma_stat_rq_poll);
103210
103211 while ((ret = ib_poll_cq(xprt->sc_rq_cq, 1, &wc)) > 0) {
103212 ctxt = (struct svc_rdma_op_ctxt *)(unsigned long)wc.wr_id;
103213 @@ -314,7 +314,7 @@ static void rq_cq_reap(struct svcxprt_rdma *xprt)
103214 }
103215
103216 if (ctxt)
103217 - atomic_inc(&rdma_stat_rq_prod);
103218 + atomic_inc_unchecked(&rdma_stat_rq_prod);
103219
103220 set_bit(XPT_DATA, &xprt->sc_xprt.xpt_flags);
103221 /*
103222 @@ -386,7 +386,7 @@ static void sq_cq_reap(struct svcxprt_rdma *xprt)
103223 return;
103224
103225 ib_req_notify_cq(xprt->sc_sq_cq, IB_CQ_NEXT_COMP);
103226 - atomic_inc(&rdma_stat_sq_poll);
103227 + atomic_inc_unchecked(&rdma_stat_sq_poll);
103228 while ((ret = ib_poll_cq(cq, 1, &wc)) > 0) {
103229 if (wc.status != IB_WC_SUCCESS)
103230 /* Close the transport */
103231 @@ -404,7 +404,7 @@ static void sq_cq_reap(struct svcxprt_rdma *xprt)
103232 }
103233
103234 if (ctxt)
103235 - atomic_inc(&rdma_stat_sq_prod);
103236 + atomic_inc_unchecked(&rdma_stat_sq_prod);
103237 }
103238
103239 static void sq_comp_handler(struct ib_cq *cq, void *cq_context)
103240 @@ -1261,7 +1261,7 @@ int svc_rdma_send(struct svcxprt_rdma *xprt, struct ib_send_wr *wr)
103241 spin_lock_bh(&xprt->sc_lock);
103242 if (xprt->sc_sq_depth < atomic_read(&xprt->sc_sq_count) + wr_count) {
103243 spin_unlock_bh(&xprt->sc_lock);
103244 - atomic_inc(&rdma_stat_sq_starve);
103245 + atomic_inc_unchecked(&rdma_stat_sq_starve);
103246
103247 /* See if we can opportunistically reap SQ WR to make room */
103248 sq_cq_reap(xprt);
103249 diff --git a/net/sysctl_net.c b/net/sysctl_net.c
103250 index e7000be..e3b0ba7 100644
103251 --- a/net/sysctl_net.c
103252 +++ b/net/sysctl_net.c
103253 @@ -46,7 +46,7 @@ static int net_ctl_permissions(struct ctl_table_header *head,
103254 kgid_t root_gid = make_kgid(net->user_ns, 0);
103255
103256 /* Allow network administrator to have same access as root. */
103257 - if (ns_capable(net->user_ns, CAP_NET_ADMIN) ||
103258 + if (ns_capable_nolog(net->user_ns, CAP_NET_ADMIN) ||
103259 uid_eq(root_uid, current_euid())) {
103260 int mode = (table->mode >> 6) & 7;
103261 return (mode << 6) | (mode << 3) | mode;
103262 diff --git a/net/tipc/subscr.c b/net/tipc/subscr.c
103263 index 6424372..afd36e9 100644
103264 --- a/net/tipc/subscr.c
103265 +++ b/net/tipc/subscr.c
103266 @@ -97,7 +97,7 @@ static void subscr_send_event(struct tipc_subscription *sub, u32 found_lower,
103267 struct tipc_subscriber *subscriber = sub->subscriber;
103268 struct kvec msg_sect;
103269
103270 - msg_sect.iov_base = (void *)&sub->evt;
103271 + msg_sect.iov_base = &sub->evt;
103272 msg_sect.iov_len = sizeof(struct tipc_event);
103273 sub->evt.event = htohl(event, sub->swap);
103274 sub->evt.found_lower = htohl(found_lower, sub->swap);
103275 diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
103276 index bb7e8ba..9f444c6 100644
103277 --- a/net/unix/af_unix.c
103278 +++ b/net/unix/af_unix.c
103279 @@ -791,6 +791,12 @@ static struct sock *unix_find_other(struct net *net,
103280 err = -ECONNREFUSED;
103281 if (!S_ISSOCK(inode->i_mode))
103282 goto put_fail;
103283 +
103284 + if (!gr_acl_handle_unix(path.dentry, path.mnt)) {
103285 + err = -EACCES;
103286 + goto put_fail;
103287 + }
103288 +
103289 u = unix_find_socket_byinode(inode);
103290 if (!u)
103291 goto put_fail;
103292 @@ -811,6 +817,13 @@ static struct sock *unix_find_other(struct net *net,
103293 if (u) {
103294 struct dentry *dentry;
103295 dentry = unix_sk(u)->path.dentry;
103296 +
103297 + if (!gr_handle_chroot_unix(pid_vnr(u->sk_peer_pid))) {
103298 + err = -EPERM;
103299 + sock_put(u);
103300 + goto fail;
103301 + }
103302 +
103303 if (dentry)
103304 touch_atime(&unix_sk(u)->path);
103305 } else
103306 @@ -844,12 +857,18 @@ static int unix_mknod(const char *sun_path, umode_t mode, struct path *res)
103307 */
103308 err = security_path_mknod(&path, dentry, mode, 0);
103309 if (!err) {
103310 + if (!gr_acl_handle_mknod(dentry, path.dentry, path.mnt, mode)) {
103311 + err = -EACCES;
103312 + goto out;
103313 + }
103314 err = vfs_mknod(path.dentry->d_inode, dentry, mode, 0);
103315 if (!err) {
103316 res->mnt = mntget(path.mnt);
103317 res->dentry = dget(dentry);
103318 + gr_handle_create(dentry, path.mnt);
103319 }
103320 }
103321 +out:
103322 done_path_create(&path, dentry);
103323 return err;
103324 }
103325 @@ -2344,9 +2363,13 @@ static int unix_seq_show(struct seq_file *seq, void *v)
103326 seq_puts(seq, "Num RefCount Protocol Flags Type St "
103327 "Inode Path\n");
103328 else {
103329 - struct sock *s = v;
103330 + struct sock *s = v, *peer;
103331 struct unix_sock *u = unix_sk(s);
103332 unix_state_lock(s);
103333 + peer = unix_peer(s);
103334 + unix_state_unlock(s);
103335 +
103336 + unix_state_double_lock(s, peer);
103337
103338 seq_printf(seq, "%pK: %08X %08X %08X %04X %02X %5lu",
103339 s,
103340 @@ -2373,8 +2396,10 @@ static int unix_seq_show(struct seq_file *seq, void *v)
103341 }
103342 for ( ; i < len; i++)
103343 seq_putc(seq, u->addr->name->sun_path[i]);
103344 - }
103345 - unix_state_unlock(s);
103346 + } else if (peer)
103347 + seq_printf(seq, " P%lu", sock_i_ino(peer));
103348 +
103349 + unix_state_double_unlock(s, peer);
103350 seq_putc(seq, '\n');
103351 }
103352
103353 diff --git a/net/unix/sysctl_net_unix.c b/net/unix/sysctl_net_unix.c
103354 index b3d5150..ff3a837 100644
103355 --- a/net/unix/sysctl_net_unix.c
103356 +++ b/net/unix/sysctl_net_unix.c
103357 @@ -28,7 +28,7 @@ static struct ctl_table unix_table[] = {
103358
103359 int __net_init unix_sysctl_register(struct net *net)
103360 {
103361 - struct ctl_table *table;
103362 + ctl_table_no_const *table;
103363
103364 table = kmemdup(unix_table, sizeof(unix_table), GFP_KERNEL);
103365 if (table == NULL)
103366 diff --git a/net/vmw_vsock/vmci_transport_notify.c b/net/vmw_vsock/vmci_transport_notify.c
103367 index 9b7f207..2596621 100644
103368 --- a/net/vmw_vsock/vmci_transport_notify.c
103369 +++ b/net/vmw_vsock/vmci_transport_notify.c
103370 @@ -662,19 +662,19 @@ static void vmci_transport_notify_pkt_process_negotiate(struct sock *sk)
103371
103372 /* Socket control packet based operations. */
103373 struct vmci_transport_notify_ops vmci_transport_notify_pkt_ops = {
103374 - vmci_transport_notify_pkt_socket_init,
103375 - vmci_transport_notify_pkt_socket_destruct,
103376 - vmci_transport_notify_pkt_poll_in,
103377 - vmci_transport_notify_pkt_poll_out,
103378 - vmci_transport_notify_pkt_handle_pkt,
103379 - vmci_transport_notify_pkt_recv_init,
103380 - vmci_transport_notify_pkt_recv_pre_block,
103381 - vmci_transport_notify_pkt_recv_pre_dequeue,
103382 - vmci_transport_notify_pkt_recv_post_dequeue,
103383 - vmci_transport_notify_pkt_send_init,
103384 - vmci_transport_notify_pkt_send_pre_block,
103385 - vmci_transport_notify_pkt_send_pre_enqueue,
103386 - vmci_transport_notify_pkt_send_post_enqueue,
103387 - vmci_transport_notify_pkt_process_request,
103388 - vmci_transport_notify_pkt_process_negotiate,
103389 + .socket_init = vmci_transport_notify_pkt_socket_init,
103390 + .socket_destruct = vmci_transport_notify_pkt_socket_destruct,
103391 + .poll_in = vmci_transport_notify_pkt_poll_in,
103392 + .poll_out = vmci_transport_notify_pkt_poll_out,
103393 + .handle_notify_pkt = vmci_transport_notify_pkt_handle_pkt,
103394 + .recv_init = vmci_transport_notify_pkt_recv_init,
103395 + .recv_pre_block = vmci_transport_notify_pkt_recv_pre_block,
103396 + .recv_pre_dequeue = vmci_transport_notify_pkt_recv_pre_dequeue,
103397 + .recv_post_dequeue = vmci_transport_notify_pkt_recv_post_dequeue,
103398 + .send_init = vmci_transport_notify_pkt_send_init,
103399 + .send_pre_block = vmci_transport_notify_pkt_send_pre_block,
103400 + .send_pre_enqueue = vmci_transport_notify_pkt_send_pre_enqueue,
103401 + .send_post_enqueue = vmci_transport_notify_pkt_send_post_enqueue,
103402 + .process_request = vmci_transport_notify_pkt_process_request,
103403 + .process_negotiate = vmci_transport_notify_pkt_process_negotiate,
103404 };
103405 diff --git a/net/vmw_vsock/vmci_transport_notify_qstate.c b/net/vmw_vsock/vmci_transport_notify_qstate.c
103406 index dc9c792..3089de0 100644
103407 --- a/net/vmw_vsock/vmci_transport_notify_qstate.c
103408 +++ b/net/vmw_vsock/vmci_transport_notify_qstate.c
103409 @@ -420,19 +420,19 @@ vmci_transport_notify_pkt_send_pre_enqueue(
103410
103411 /* Socket always on control packet based operations. */
103412 struct vmci_transport_notify_ops vmci_transport_notify_pkt_q_state_ops = {
103413 - vmci_transport_notify_pkt_socket_init,
103414 - vmci_transport_notify_pkt_socket_destruct,
103415 - vmci_transport_notify_pkt_poll_in,
103416 - vmci_transport_notify_pkt_poll_out,
103417 - vmci_transport_notify_pkt_handle_pkt,
103418 - vmci_transport_notify_pkt_recv_init,
103419 - vmci_transport_notify_pkt_recv_pre_block,
103420 - vmci_transport_notify_pkt_recv_pre_dequeue,
103421 - vmci_transport_notify_pkt_recv_post_dequeue,
103422 - vmci_transport_notify_pkt_send_init,
103423 - vmci_transport_notify_pkt_send_pre_block,
103424 - vmci_transport_notify_pkt_send_pre_enqueue,
103425 - vmci_transport_notify_pkt_send_post_enqueue,
103426 - vmci_transport_notify_pkt_process_request,
103427 - vmci_transport_notify_pkt_process_negotiate,
103428 + .socket_init = vmci_transport_notify_pkt_socket_init,
103429 + .socket_destruct = vmci_transport_notify_pkt_socket_destruct,
103430 + .poll_in = vmci_transport_notify_pkt_poll_in,
103431 + .poll_out = vmci_transport_notify_pkt_poll_out,
103432 + .handle_notify_pkt = vmci_transport_notify_pkt_handle_pkt,
103433 + .recv_init = vmci_transport_notify_pkt_recv_init,
103434 + .recv_pre_block = vmci_transport_notify_pkt_recv_pre_block,
103435 + .recv_pre_dequeue = vmci_transport_notify_pkt_recv_pre_dequeue,
103436 + .recv_post_dequeue = vmci_transport_notify_pkt_recv_post_dequeue,
103437 + .send_init = vmci_transport_notify_pkt_send_init,
103438 + .send_pre_block = vmci_transport_notify_pkt_send_pre_block,
103439 + .send_pre_enqueue = vmci_transport_notify_pkt_send_pre_enqueue,
103440 + .send_post_enqueue = vmci_transport_notify_pkt_send_post_enqueue,
103441 + .process_request = vmci_transport_notify_pkt_process_request,
103442 + .process_negotiate = vmci_transport_notify_pkt_process_negotiate,
103443 };
103444 diff --git a/net/wireless/wext-core.c b/net/wireless/wext-core.c
103445 index c8717c1..08539f5 100644
103446 --- a/net/wireless/wext-core.c
103447 +++ b/net/wireless/wext-core.c
103448 @@ -748,8 +748,7 @@ static int ioctl_standard_iw_point(struct iw_point *iwp, unsigned int cmd,
103449 */
103450
103451 /* Support for very large requests */
103452 - if ((descr->flags & IW_DESCR_FLAG_NOMAX) &&
103453 - (user_length > descr->max_tokens)) {
103454 + if (user_length > descr->max_tokens) {
103455 /* Allow userspace to GET more than max so
103456 * we can support any size GET requests.
103457 * There is still a limit : -ENOMEM.
103458 @@ -788,22 +787,6 @@ static int ioctl_standard_iw_point(struct iw_point *iwp, unsigned int cmd,
103459 }
103460 }
103461
103462 - if (IW_IS_GET(cmd) && !(descr->flags & IW_DESCR_FLAG_NOMAX)) {
103463 - /*
103464 - * If this is a GET, but not NOMAX, it means that the extra
103465 - * data is not bounded by userspace, but by max_tokens. Thus
103466 - * set the length to max_tokens. This matches the extra data
103467 - * allocation.
103468 - * The driver should fill it with the number of tokens it
103469 - * provided, and it may check iwp->length rather than having
103470 - * knowledge of max_tokens. If the driver doesn't change the
103471 - * iwp->length, this ioctl just copies back max_token tokens
103472 - * filled with zeroes. Hopefully the driver isn't claiming
103473 - * them to be valid data.
103474 - */
103475 - iwp->length = descr->max_tokens;
103476 - }
103477 -
103478 err = handler(dev, info, (union iwreq_data *) iwp, extra);
103479
103480 iwp->length += essid_compat;
103481 diff --git a/net/x25/sysctl_net_x25.c b/net/x25/sysctl_net_x25.c
103482 index 4323952..a06dfe1 100644
103483 --- a/net/x25/sysctl_net_x25.c
103484 +++ b/net/x25/sysctl_net_x25.c
103485 @@ -70,7 +70,7 @@ static struct ctl_table x25_table[] = {
103486 .mode = 0644,
103487 .proc_handler = proc_dointvec,
103488 },
103489 - { 0, },
103490 + { },
103491 };
103492
103493 void __init x25_register_sysctl(void)
103494 diff --git a/net/x25/x25_proc.c b/net/x25/x25_proc.c
103495 index 0917f04..f4e3d8c 100644
103496 --- a/net/x25/x25_proc.c
103497 +++ b/net/x25/x25_proc.c
103498 @@ -209,7 +209,7 @@ static const struct file_operations x25_seq_forward_fops = {
103499
103500 int __init x25_proc_init(void)
103501 {
103502 - if (!proc_mkdir("x25", init_net.proc_net))
103503 + if (!proc_mkdir_restrict("x25", init_net.proc_net))
103504 return -ENOMEM;
103505
103506 if (!proc_create("x25/route", S_IRUGO, init_net.proc_net,
103507 diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
103508 index c08fbd1..3d99e85 100644
103509 --- a/net/xfrm/xfrm_policy.c
103510 +++ b/net/xfrm/xfrm_policy.c
103511 @@ -325,7 +325,7 @@ static void xfrm_policy_kill(struct xfrm_policy *policy)
103512 {
103513 policy->walk.dead = 1;
103514
103515 - atomic_inc(&policy->genid);
103516 + atomic_inc_unchecked(&policy->genid);
103517
103518 if (del_timer(&policy->polq.hold_timer))
103519 xfrm_pol_put(policy);
103520 @@ -659,7 +659,7 @@ int xfrm_policy_insert(int dir, struct xfrm_policy *policy, int excl)
103521 hlist_add_head(&policy->bydst, chain);
103522 xfrm_pol_hold(policy);
103523 net->xfrm.policy_count[dir]++;
103524 - atomic_inc(&net->xfrm.flow_cache_genid);
103525 + atomic_inc_unchecked(&net->xfrm.flow_cache_genid);
103526
103527 /* After previous checking, family can either be AF_INET or AF_INET6 */
103528 if (policy->family == AF_INET)
103529 @@ -1759,7 +1759,7 @@ xfrm_resolve_and_create_bundle(struct xfrm_policy **pols, int num_pols,
103530
103531 xdst->num_pols = num_pols;
103532 memcpy(xdst->pols, pols, sizeof(struct xfrm_policy *) * num_pols);
103533 - xdst->policy_genid = atomic_read(&pols[0]->genid);
103534 + xdst->policy_genid = atomic_read_unchecked(&pols[0]->genid);
103535
103536 return xdst;
103537 }
103538 @@ -2546,10 +2546,11 @@ void xfrm_garbage_collect(struct net *net)
103539 }
103540 EXPORT_SYMBOL(xfrm_garbage_collect);
103541
103542 -static void xfrm_garbage_collect_deferred(struct net *net)
103543 +void xfrm_garbage_collect_deferred(struct net *net)
103544 {
103545 flow_cache_flush_deferred(net);
103546 }
103547 +EXPORT_SYMBOL(xfrm_garbage_collect_deferred);
103548
103549 static void xfrm_init_pmtu(struct dst_entry *dst)
103550 {
103551 @@ -2599,7 +2600,7 @@ static int xfrm_bundle_ok(struct xfrm_dst *first)
103552 if (xdst->xfrm_genid != dst->xfrm->genid)
103553 return 0;
103554 if (xdst->num_pols > 0 &&
103555 - xdst->policy_genid != atomic_read(&xdst->pols[0]->genid))
103556 + xdst->policy_genid != atomic_read_unchecked(&xdst->pols[0]->genid))
103557 return 0;
103558
103559 mtu = dst_mtu(dst->child);
103560 @@ -2687,8 +2688,6 @@ int xfrm_policy_register_afinfo(struct xfrm_policy_afinfo *afinfo)
103561 dst_ops->link_failure = xfrm_link_failure;
103562 if (likely(dst_ops->neigh_lookup == NULL))
103563 dst_ops->neigh_lookup = xfrm_neigh_lookup;
103564 - if (likely(afinfo->garbage_collect == NULL))
103565 - afinfo->garbage_collect = xfrm_garbage_collect_deferred;
103566 rcu_assign_pointer(xfrm_policy_afinfo[afinfo->family], afinfo);
103567 }
103568 spin_unlock(&xfrm_policy_afinfo_lock);
103569 @@ -2742,7 +2741,6 @@ int xfrm_policy_unregister_afinfo(struct xfrm_policy_afinfo *afinfo)
103570 dst_ops->check = NULL;
103571 dst_ops->negative_advice = NULL;
103572 dst_ops->link_failure = NULL;
103573 - afinfo->garbage_collect = NULL;
103574 }
103575 return err;
103576 }
103577 @@ -3137,7 +3135,7 @@ static int xfrm_policy_migrate(struct xfrm_policy *pol,
103578 sizeof(pol->xfrm_vec[i].saddr));
103579 pol->xfrm_vec[i].encap_family = mp->new_family;
103580 /* flush bundles */
103581 - atomic_inc(&pol->genid);
103582 + atomic_inc_unchecked(&pol->genid);
103583 }
103584 }
103585
103586 diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c
103587 index 8e9c781..3972135 100644
103588 --- a/net/xfrm/xfrm_state.c
103589 +++ b/net/xfrm/xfrm_state.c
103590 @@ -173,12 +173,14 @@ int xfrm_register_type(const struct xfrm_type *type, unsigned short family)
103591
103592 if (unlikely(afinfo == NULL))
103593 return -EAFNOSUPPORT;
103594 - typemap = afinfo->type_map;
103595 + typemap = (const struct xfrm_type **)afinfo->type_map;
103596 spin_lock_bh(&xfrm_type_lock);
103597
103598 - if (likely(typemap[type->proto] == NULL))
103599 + if (likely(typemap[type->proto] == NULL)) {
103600 + pax_open_kernel();
103601 typemap[type->proto] = type;
103602 - else
103603 + pax_close_kernel();
103604 + } else
103605 err = -EEXIST;
103606 spin_unlock_bh(&xfrm_type_lock);
103607 xfrm_state_put_afinfo(afinfo);
103608 @@ -194,13 +196,16 @@ int xfrm_unregister_type(const struct xfrm_type *type, unsigned short family)
103609
103610 if (unlikely(afinfo == NULL))
103611 return -EAFNOSUPPORT;
103612 - typemap = afinfo->type_map;
103613 + typemap = (const struct xfrm_type **)afinfo->type_map;
103614 spin_lock_bh(&xfrm_type_lock);
103615
103616 if (unlikely(typemap[type->proto] != type))
103617 err = -ENOENT;
103618 - else
103619 + else {
103620 + pax_open_kernel();
103621 typemap[type->proto] = NULL;
103622 + pax_close_kernel();
103623 + }
103624 spin_unlock_bh(&xfrm_type_lock);
103625 xfrm_state_put_afinfo(afinfo);
103626 return err;
103627 @@ -210,7 +215,6 @@ EXPORT_SYMBOL(xfrm_unregister_type);
103628 static const struct xfrm_type *xfrm_get_type(u8 proto, unsigned short family)
103629 {
103630 struct xfrm_state_afinfo *afinfo;
103631 - const struct xfrm_type **typemap;
103632 const struct xfrm_type *type;
103633 int modload_attempted = 0;
103634
103635 @@ -218,9 +222,8 @@ retry:
103636 afinfo = xfrm_state_get_afinfo(family);
103637 if (unlikely(afinfo == NULL))
103638 return NULL;
103639 - typemap = afinfo->type_map;
103640
103641 - type = typemap[proto];
103642 + type = afinfo->type_map[proto];
103643 if (unlikely(type && !try_module_get(type->owner)))
103644 type = NULL;
103645 if (!type && !modload_attempted) {
103646 @@ -254,7 +257,7 @@ int xfrm_register_mode(struct xfrm_mode *mode, int family)
103647 return -EAFNOSUPPORT;
103648
103649 err = -EEXIST;
103650 - modemap = afinfo->mode_map;
103651 + modemap = (struct xfrm_mode **)afinfo->mode_map;
103652 spin_lock_bh(&xfrm_mode_lock);
103653 if (modemap[mode->encap])
103654 goto out;
103655 @@ -263,8 +266,10 @@ int xfrm_register_mode(struct xfrm_mode *mode, int family)
103656 if (!try_module_get(afinfo->owner))
103657 goto out;
103658
103659 - mode->afinfo = afinfo;
103660 + pax_open_kernel();
103661 + *(const void **)&mode->afinfo = afinfo;
103662 modemap[mode->encap] = mode;
103663 + pax_close_kernel();
103664 err = 0;
103665
103666 out:
103667 @@ -288,10 +293,12 @@ int xfrm_unregister_mode(struct xfrm_mode *mode, int family)
103668 return -EAFNOSUPPORT;
103669
103670 err = -ENOENT;
103671 - modemap = afinfo->mode_map;
103672 + modemap = (struct xfrm_mode **)afinfo->mode_map;
103673 spin_lock_bh(&xfrm_mode_lock);
103674 if (likely(modemap[mode->encap] == mode)) {
103675 + pax_open_kernel();
103676 modemap[mode->encap] = NULL;
103677 + pax_close_kernel();
103678 module_put(mode->afinfo->owner);
103679 err = 0;
103680 }
103681 @@ -1519,10 +1526,10 @@ EXPORT_SYMBOL(xfrm_find_acq_byseq);
103682 u32 xfrm_get_acqseq(void)
103683 {
103684 u32 res;
103685 - static atomic_t acqseq;
103686 + static atomic_unchecked_t acqseq;
103687
103688 do {
103689 - res = atomic_inc_return(&acqseq);
103690 + res = atomic_inc_return_unchecked(&acqseq);
103691 } while (!res);
103692
103693 return res;
103694 diff --git a/net/xfrm/xfrm_sysctl.c b/net/xfrm/xfrm_sysctl.c
103695 index 05a6e3d..6716ec9 100644
103696 --- a/net/xfrm/xfrm_sysctl.c
103697 +++ b/net/xfrm/xfrm_sysctl.c
103698 @@ -42,7 +42,7 @@ static struct ctl_table xfrm_table[] = {
103699
103700 int __net_init xfrm_sysctl_init(struct net *net)
103701 {
103702 - struct ctl_table *table;
103703 + ctl_table_no_const *table;
103704
103705 __xfrm_sysctl_init(net);
103706
103707 diff --git a/scripts/Makefile b/scripts/Makefile
103708 index 1d07860..f16fc22 100644
103709 --- a/scripts/Makefile
103710 +++ b/scripts/Makefile
103711 @@ -40,3 +40,5 @@ subdir-$(CONFIG_DTC) += dtc
103712
103713 # Let clean descend into subdirs
103714 subdir- += basic kconfig package selinux
103715 +
103716 +clean-files := randstruct.seed
103717 diff --git a/scripts/Makefile.build b/scripts/Makefile.build
103718 index 003bc26..d5f02b0 100644
103719 --- a/scripts/Makefile.build
103720 +++ b/scripts/Makefile.build
103721 @@ -121,7 +121,7 @@ endif
103722 endif
103723
103724 # Do not include host rules unless needed
103725 -ifneq ($(hostprogs-y)$(hostprogs-m),)
103726 +ifneq ($(hostprogs-y)$(hostprogs-m)$(hostlibs-y)$(hostlibs-m)$(hostcxxlibs-y)$(hostcxxlibs-m),)
103727 include scripts/Makefile.host
103728 endif
103729
103730 diff --git a/scripts/Makefile.clean b/scripts/Makefile.clean
103731 index 686cb0d..9d653bf 100644
103732 --- a/scripts/Makefile.clean
103733 +++ b/scripts/Makefile.clean
103734 @@ -43,7 +43,8 @@ subdir-ymn := $(addprefix $(obj)/,$(subdir-ymn))
103735 __clean-files := $(extra-y) $(always) \
103736 $(targets) $(clean-files) \
103737 $(host-progs) \
103738 - $(hostprogs-y) $(hostprogs-m) $(hostprogs-)
103739 + $(hostprogs-y) $(hostprogs-m) $(hostprogs-) \
103740 + $(hostlibs-y) $(hostlibs-m) $(hostlibs-)
103741
103742 __clean-files := $(filter-out $(no-clean-files), $(__clean-files))
103743
103744 diff --git a/scripts/Makefile.host b/scripts/Makefile.host
103745 index 1ac414f..38575f7 100644
103746 --- a/scripts/Makefile.host
103747 +++ b/scripts/Makefile.host
103748 @@ -31,6 +31,8 @@
103749 # Note: Shared libraries consisting of C++ files are not supported
103750
103751 __hostprogs := $(sort $(hostprogs-y) $(hostprogs-m))
103752 +__hostlibs := $(sort $(hostlibs-y) $(hostlibs-m))
103753 +__hostcxxlibs := $(sort $(hostcxxlibs-y) $(hostcxxlibs-m))
103754
103755 # C code
103756 # Executables compiled from a single .c file
103757 @@ -54,11 +56,15 @@ host-cxxobjs := $(sort $(foreach m,$(host-cxxmulti),$($(m)-cxxobjs)))
103758 # Shared libaries (only .c supported)
103759 # Shared libraries (.so) - all .so files referenced in "xxx-objs"
103760 host-cshlib := $(sort $(filter %.so, $(host-cobjs)))
103761 +host-cshlib += $(sort $(filter %.so, $(__hostlibs)))
103762 +host-cxxshlib := $(sort $(filter %.so, $(__hostcxxlibs)))
103763 # Remove .so files from "xxx-objs"
103764 host-cobjs := $(filter-out %.so,$(host-cobjs))
103765 +host-cxxobjs := $(filter-out %.so,$(host-cxxobjs))
103766
103767 -#Object (.o) files used by the shared libaries
103768 +# Object (.o) files used by the shared libaries
103769 host-cshobjs := $(sort $(foreach m,$(host-cshlib),$($(m:.so=-objs))))
103770 +host-cxxshobjs := $(sort $(foreach m,$(host-cxxshlib),$($(m:.so=-objs))))
103771
103772 # output directory for programs/.o files
103773 # hostprogs-y := tools/build may have been specified. Retrieve directory
103774 @@ -82,7 +88,9 @@ host-cobjs := $(addprefix $(obj)/,$(host-cobjs))
103775 host-cxxmulti := $(addprefix $(obj)/,$(host-cxxmulti))
103776 host-cxxobjs := $(addprefix $(obj)/,$(host-cxxobjs))
103777 host-cshlib := $(addprefix $(obj)/,$(host-cshlib))
103778 +host-cxxshlib := $(addprefix $(obj)/,$(host-cxxshlib))
103779 host-cshobjs := $(addprefix $(obj)/,$(host-cshobjs))
103780 +host-cxxshobjs := $(addprefix $(obj)/,$(host-cxxshobjs))
103781 host-objdirs := $(addprefix $(obj)/,$(host-objdirs))
103782
103783 obj-dirs += $(host-objdirs)
103784 @@ -156,6 +164,13 @@ quiet_cmd_host-cshobjs = HOSTCC -fPIC $@
103785 $(host-cshobjs): $(obj)/%.o: $(src)/%.c FORCE
103786 $(call if_changed_dep,host-cshobjs)
103787
103788 +# Compile .c file, create position independent .o file
103789 +# host-cxxshobjs -> .o
103790 +quiet_cmd_host-cxxshobjs = HOSTCXX -fPIC $@
103791 + cmd_host-cxxshobjs = $(HOSTCXX) $(hostcxx_flags) -fPIC -c -o $@ $<
103792 +$(host-cxxshobjs): $(obj)/%.o: $(src)/%.c FORCE
103793 + $(call if_changed_dep,host-cxxshobjs)
103794 +
103795 # Link a shared library, based on position independent .o files
103796 # *.o -> .so shared library (host-cshlib)
103797 quiet_cmd_host-cshlib = HOSTLLD -shared $@
103798 @@ -165,6 +180,15 @@ quiet_cmd_host-cshlib = HOSTLLD -shared $@
103799 $(host-cshlib): $(obj)/%: $(host-cshobjs) FORCE
103800 $(call if_changed,host-cshlib)
103801
103802 +# Link a shared library, based on position independent .o files
103803 +# *.o -> .so shared library (host-cxxshlib)
103804 +quiet_cmd_host-cxxshlib = HOSTLLD -shared $@
103805 + cmd_host-cxxshlib = $(HOSTCXX) $(HOSTLDFLAGS) -shared -o $@ \
103806 + $(addprefix $(obj)/,$($(@F:.so=-objs))) \
103807 + $(HOST_LOADLIBES) $(HOSTLOADLIBES_$(@F))
103808 +$(host-cxxshlib): $(obj)/%: $(host-cxxshobjs) FORCE
103809 + $(call if_changed,host-cxxshlib)
103810 +
103811 targets += $(host-csingle) $(host-cmulti) $(host-cobjs)\
103812 - $(host-cxxmulti) $(host-cxxobjs) $(host-cshlib) $(host-cshobjs)
103813 + $(host-cxxmulti) $(host-cxxobjs) $(host-cshlib) $(host-cshobjs) $(host-cxxshlib) $(host-cxxshobjs)
103814
103815 diff --git a/scripts/basic/fixdep.c b/scripts/basic/fixdep.c
103816 index 078fe1d..fbdb363 100644
103817 --- a/scripts/basic/fixdep.c
103818 +++ b/scripts/basic/fixdep.c
103819 @@ -161,7 +161,7 @@ static unsigned int strhash(const char *str, unsigned int sz)
103820 /*
103821 * Lookup a value in the configuration string.
103822 */
103823 -static int is_defined_config(const char *name, int len, unsigned int hash)
103824 +static int is_defined_config(const char *name, unsigned int len, unsigned int hash)
103825 {
103826 struct item *aux;
103827
103828 @@ -211,10 +211,10 @@ static void clear_config(void)
103829 /*
103830 * Record the use of a CONFIG_* word.
103831 */
103832 -static void use_config(const char *m, int slen)
103833 +static void use_config(const char *m, unsigned int slen)
103834 {
103835 unsigned int hash = strhash(m, slen);
103836 - int c, i;
103837 + unsigned int c, i;
103838
103839 if (is_defined_config(m, slen, hash))
103840 return;
103841 @@ -235,9 +235,9 @@ static void use_config(const char *m, int slen)
103842
103843 static void parse_config_file(const char *map, size_t len)
103844 {
103845 - const int *end = (const int *) (map + len);
103846 + const unsigned int *end = (const unsigned int *) (map + len);
103847 /* start at +1, so that p can never be < map */
103848 - const int *m = (const int *) map + 1;
103849 + const unsigned int *m = (const unsigned int *) map + 1;
103850 const char *p, *q;
103851
103852 for (; m < end; m++) {
103853 @@ -435,7 +435,7 @@ static void print_deps(void)
103854 static void traps(void)
103855 {
103856 static char test[] __attribute__((aligned(sizeof(int)))) = "CONF";
103857 - int *p = (int *)test;
103858 + unsigned int *p = (unsigned int *)test;
103859
103860 if (*p != INT_CONF) {
103861 fprintf(stderr, "fixdep: sizeof(int) != 4 or wrong endianness? %#x\n",
103862 diff --git a/scripts/gcc-plugin.sh b/scripts/gcc-plugin.sh
103863 new file mode 100644
103864 index 0000000..3fd3699
103865 --- /dev/null
103866 +++ b/scripts/gcc-plugin.sh
103867 @@ -0,0 +1,43 @@
103868 +#!/bin/bash
103869 +srctree=$(dirname "$0")
103870 +gccplugins_dir=$($3 -print-file-name=plugin)
103871 +plugincc=$($1 -E - -o /dev/null -I${srctree}/../tools/gcc -I${gccplugins_dir}/include 2>&1 <<EOF
103872 +#include "gcc-common.h"
103873 +#if BUILDING_GCC_VERSION >= 4008 || defined(ENABLE_BUILD_WITH_CXX)
103874 +#warning $2 CXX
103875 +#else
103876 +#warning $1 CC
103877 +#endif
103878 +EOF
103879 +)
103880 +
103881 +if [ $? -ne 0 ]
103882 +then
103883 + exit 1
103884 +fi
103885 +
103886 +if [[ "$plugincc" =~ "$1 CC" ]]
103887 +then
103888 + echo "$1"
103889 + exit 0
103890 +fi
103891 +
103892 +if [[ "$plugincc" =~ "$2 CXX" ]]
103893 +then
103894 +plugincc=$($1 -c -x c++ -std=gnu++98 - -o /dev/null -I${srctree}/../tools/gcc -I${gccplugins_dir}/include 2>&1 <<EOF
103895 +#include "gcc-common.h"
103896 +class test {
103897 +public:
103898 + int test;
103899 +} test = {
103900 + .test = 1
103901 +};
103902 +EOF
103903 +)
103904 +if [ $? -eq 0 ]
103905 +then
103906 + echo "$2"
103907 + exit 0
103908 +fi
103909 +fi
103910 +exit 1
103911 diff --git a/scripts/headers_install.sh b/scripts/headers_install.sh
103912 index 5de5660..d3deb89 100644
103913 --- a/scripts/headers_install.sh
103914 +++ b/scripts/headers_install.sh
103915 @@ -32,6 +32,7 @@ do
103916 FILE="$(basename "$i")"
103917 sed -r \
103918 -e 's/([ \t(])(__user|__force|__iomem)[ \t]/\1/g' \
103919 + -e 's/__intentional_overflow\([- \t,0-9]*\)//g' \
103920 -e 's/__attribute_const__([ \t]|$)/\1/g' \
103921 -e 's@^#include <linux/compiler.h>@@' \
103922 -e 's/(^|[^a-zA-Z0-9])__packed([^a-zA-Z0-9_]|$)/\1__attribute__((packed))\2/g' \
103923 diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh
103924 index 86a4fe7..99e91f9 100644
103925 --- a/scripts/link-vmlinux.sh
103926 +++ b/scripts/link-vmlinux.sh
103927 @@ -166,7 +166,7 @@ else
103928 fi;
103929
103930 # final build of init/
103931 -${MAKE} -f "${srctree}/scripts/Makefile.build" obj=init
103932 +${MAKE} -f "${srctree}/scripts/Makefile.build" obj=init GCC_PLUGINS_CFLAGS="${GCC_PLUGINS_CFLAGS}" GCC_PLUGINS_AFLAGS="${GCC_PLUGINS_AFLAGS}"
103933
103934 kallsymso=""
103935 kallsyms_vmlinux=""
103936 diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c
103937 index 1924990..3de7363 100644
103938 --- a/scripts/mod/file2alias.c
103939 +++ b/scripts/mod/file2alias.c
103940 @@ -142,7 +142,7 @@ static void device_id_check(const char *modname, const char *device_id,
103941 unsigned long size, unsigned long id_size,
103942 void *symval)
103943 {
103944 - int i;
103945 + unsigned int i;
103946
103947 if (size % id_size || size < id_size) {
103948 fatal("%s: sizeof(struct %s_device_id)=%lu is not a modulo "
103949 @@ -171,7 +171,7 @@ static void device_id_check(const char *modname, const char *device_id,
103950 /* USB is special because the bcdDevice can be matched against a numeric range */
103951 /* Looks like "usb:vNpNdNdcNdscNdpNicNiscNipNinN" */
103952 static void do_usb_entry(void *symval,
103953 - unsigned int bcdDevice_initial, int bcdDevice_initial_digits,
103954 + unsigned int bcdDevice_initial, unsigned int bcdDevice_initial_digits,
103955 unsigned char range_lo, unsigned char range_hi,
103956 unsigned char max, struct module *mod)
103957 {
103958 @@ -281,7 +281,7 @@ static void do_usb_entry_multi(void *symval, struct module *mod)
103959 {
103960 unsigned int devlo, devhi;
103961 unsigned char chi, clo, max;
103962 - int ndigits;
103963 + unsigned int ndigits;
103964
103965 DEF_FIELD(symval, usb_device_id, match_flags);
103966 DEF_FIELD(symval, usb_device_id, idVendor);
103967 @@ -534,7 +534,7 @@ static void do_pnp_device_entry(void *symval, unsigned long size,
103968 for (i = 0; i < count; i++) {
103969 DEF_FIELD_ADDR(symval + i*id_size, pnp_device_id, id);
103970 char acpi_id[sizeof(*id)];
103971 - int j;
103972 + unsigned int j;
103973
103974 buf_printf(&mod->dev_table_buf,
103975 "MODULE_ALIAS(\"pnp:d%s*\");\n", *id);
103976 @@ -563,7 +563,7 @@ static void do_pnp_card_entries(void *symval, unsigned long size,
103977
103978 for (j = 0; j < PNP_MAX_DEVICES; j++) {
103979 const char *id = (char *)(*devs)[j].id;
103980 - int i2, j2;
103981 + unsigned int i2, j2;
103982 int dup = 0;
103983
103984 if (!id[0])
103985 @@ -589,7 +589,7 @@ static void do_pnp_card_entries(void *symval, unsigned long size,
103986 /* add an individual alias for every device entry */
103987 if (!dup) {
103988 char acpi_id[PNP_ID_LEN];
103989 - int k;
103990 + unsigned int k;
103991
103992 buf_printf(&mod->dev_table_buf,
103993 "MODULE_ALIAS(\"pnp:d%s*\");\n", id);
103994 @@ -941,7 +941,7 @@ static void dmi_ascii_filter(char *d, const char *s)
103995 static int do_dmi_entry(const char *filename, void *symval,
103996 char *alias)
103997 {
103998 - int i, j;
103999 + unsigned int i, j;
104000 DEF_FIELD_ADDR(symval, dmi_system_id, matches);
104001 sprintf(alias, "dmi*");
104002
104003 diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
104004 index 0663556..d9494f0 100644
104005 --- a/scripts/mod/modpost.c
104006 +++ b/scripts/mod/modpost.c
104007 @@ -949,6 +949,7 @@ enum mismatch {
104008 ANY_INIT_TO_ANY_EXIT,
104009 ANY_EXIT_TO_ANY_INIT,
104010 EXPORT_TO_INIT_EXIT,
104011 + DATA_TO_TEXT
104012 };
104013
104014 struct sectioncheck {
104015 @@ -1035,6 +1036,12 @@ const struct sectioncheck sectioncheck[] = {
104016 .tosec = { INIT_SECTIONS, EXIT_SECTIONS, NULL },
104017 .mismatch = EXPORT_TO_INIT_EXIT,
104018 .symbol_white_list = { DEFAULT_SYMBOL_WHITE_LIST, NULL },
104019 +},
104020 +/* Do not reference code from writable data */
104021 +{
104022 + .fromsec = { DATA_SECTIONS, NULL },
104023 + .tosec = { TEXT_SECTIONS, NULL },
104024 + .mismatch = DATA_TO_TEXT
104025 }
104026 };
104027
104028 @@ -1155,10 +1162,10 @@ static Elf_Sym *find_elf_symbol(struct elf_info *elf, Elf64_Sword addr,
104029 continue;
104030 if (ELF_ST_TYPE(sym->st_info) == STT_SECTION)
104031 continue;
104032 - if (sym->st_value == addr)
104033 - return sym;
104034 /* Find a symbol nearby - addr are maybe negative */
104035 d = sym->st_value - addr;
104036 + if (d == 0)
104037 + return sym;
104038 if (d < 0)
104039 d = addr - sym->st_value;
104040 if (d < distance) {
104041 @@ -1436,6 +1443,14 @@ static void report_sec_mismatch(const char *modname,
104042 tosym, prl_to, prl_to, tosym);
104043 free(prl_to);
104044 break;
104045 + case DATA_TO_TEXT:
104046 +#if 0
104047 + fprintf(stderr,
104048 + "The %s %s:%s references\n"
104049 + "the %s %s:%s%s\n",
104050 + from, fromsec, fromsym, to, tosec, tosym, to_p);
104051 +#endif
104052 + break;
104053 }
104054 fprintf(stderr, "\n");
104055 }
104056 @@ -1687,7 +1702,7 @@ static void section_rel(const char *modname, struct elf_info *elf,
104057 static void check_sec_ref(struct module *mod, const char *modname,
104058 struct elf_info *elf)
104059 {
104060 - int i;
104061 + unsigned int i;
104062 Elf_Shdr *sechdrs = elf->sechdrs;
104063
104064 /* Walk through all sections */
104065 @@ -1819,7 +1834,7 @@ void __attribute__((format(printf, 2, 3))) buf_printf(struct buffer *buf,
104066 va_end(ap);
104067 }
104068
104069 -void buf_write(struct buffer *buf, const char *s, int len)
104070 +void buf_write(struct buffer *buf, const char *s, unsigned int len)
104071 {
104072 if (buf->size - buf->pos < len) {
104073 buf->size += len + SZ;
104074 @@ -2038,7 +2053,7 @@ static void write_if_changed(struct buffer *b, const char *fname)
104075 if (fstat(fileno(file), &st) < 0)
104076 goto close_write;
104077
104078 - if (st.st_size != b->pos)
104079 + if (st.st_size != (off_t)b->pos)
104080 goto close_write;
104081
104082 tmp = NOFAIL(malloc(b->pos));
104083 diff --git a/scripts/mod/modpost.h b/scripts/mod/modpost.h
104084 index 168b43d..77914bf 100644
104085 --- a/scripts/mod/modpost.h
104086 +++ b/scripts/mod/modpost.h
104087 @@ -92,15 +92,15 @@ void *do_nofail(void *ptr, const char *expr);
104088
104089 struct buffer {
104090 char *p;
104091 - int pos;
104092 - int size;
104093 + unsigned int pos;
104094 + unsigned int size;
104095 };
104096
104097 void __attribute__((format(printf, 2, 3)))
104098 buf_printf(struct buffer *buf, const char *fmt, ...);
104099
104100 void
104101 -buf_write(struct buffer *buf, const char *s, int len);
104102 +buf_write(struct buffer *buf, const char *s, unsigned int len);
104103
104104 struct module {
104105 struct module *next;
104106 diff --git a/scripts/mod/sumversion.c b/scripts/mod/sumversion.c
104107 index deb2994..af4f63e 100644
104108 --- a/scripts/mod/sumversion.c
104109 +++ b/scripts/mod/sumversion.c
104110 @@ -470,7 +470,7 @@ static void write_version(const char *filename, const char *sum,
104111 goto out;
104112 }
104113
104114 - if (write(fd, sum, strlen(sum)+1) != strlen(sum)+1) {
104115 + if (write(fd, sum, strlen(sum)+1) != (ssize_t)strlen(sum)+1) {
104116 warn("writing sum in %s failed: %s\n",
104117 filename, strerror(errno));
104118 goto out;
104119 diff --git a/scripts/module-common.lds b/scripts/module-common.lds
104120 index 0865b3e..7235dd4 100644
104121 --- a/scripts/module-common.lds
104122 +++ b/scripts/module-common.lds
104123 @@ -6,6 +6,10 @@
104124 SECTIONS {
104125 /DISCARD/ : { *(.discard) }
104126
104127 + .rodata : {
104128 + *(.rodata) *(.rodata.*)
104129 + *(.data..read_only)
104130 + }
104131 __ksymtab : { *(SORT(___ksymtab+*)) }
104132 __ksymtab_gpl : { *(SORT(___ksymtab_gpl+*)) }
104133 __ksymtab_unused : { *(SORT(___ksymtab_unused+*)) }
104134 diff --git a/scripts/package/builddeb b/scripts/package/builddeb
104135 index f46e4dd..090e168 100644
104136 --- a/scripts/package/builddeb
104137 +++ b/scripts/package/builddeb
104138 @@ -291,6 +291,7 @@ fi
104139 (cd $srctree; find . -name Makefile\* -o -name Kconfig\* -o -name \*.pl > "$objtree/debian/hdrsrcfiles")
104140 (cd $srctree; find arch/$SRCARCH/include include scripts -type f >> "$objtree/debian/hdrsrcfiles")
104141 (cd $objtree; find arch/$SRCARCH/include Module.symvers include scripts -type f >> "$objtree/debian/hdrobjfiles")
104142 +(cd $objtree; find tools/gcc -name \*.so >> "$objtree/debian/hdrobjfiles")
104143 destdir=$kernel_headers_dir/usr/src/linux-headers-$version
104144 mkdir -p "$destdir"
104145 (cd $srctree; tar -c -f - -T "$objtree/debian/hdrsrcfiles") | (cd $destdir; tar -xf -)
104146 diff --git a/scripts/pnmtologo.c b/scripts/pnmtologo.c
104147 index 68bb4ef..2f419e1 100644
104148 --- a/scripts/pnmtologo.c
104149 +++ b/scripts/pnmtologo.c
104150 @@ -244,14 +244,14 @@ static void write_header(void)
104151 fprintf(out, " * Linux logo %s\n", logoname);
104152 fputs(" */\n\n", out);
104153 fputs("#include <linux/linux_logo.h>\n\n", out);
104154 - fprintf(out, "static unsigned char %s_data[] __initdata = {\n",
104155 + fprintf(out, "static unsigned char %s_data[] = {\n",
104156 logoname);
104157 }
104158
104159 static void write_footer(void)
104160 {
104161 fputs("\n};\n\n", out);
104162 - fprintf(out, "const struct linux_logo %s __initconst = {\n", logoname);
104163 + fprintf(out, "const struct linux_logo %s = {\n", logoname);
104164 fprintf(out, "\t.type\t\t= %s,\n", logo_types[logo_type]);
104165 fprintf(out, "\t.width\t\t= %d,\n", logo_width);
104166 fprintf(out, "\t.height\t\t= %d,\n", logo_height);
104167 @@ -381,7 +381,7 @@ static void write_logo_clut224(void)
104168 fputs("\n};\n\n", out);
104169
104170 /* write logo clut */
104171 - fprintf(out, "static unsigned char %s_clut[] __initdata = {\n",
104172 + fprintf(out, "static unsigned char %s_clut[] = {\n",
104173 logoname);
104174 write_hex_cnt = 0;
104175 for (i = 0; i < logo_clutsize; i++) {
104176 diff --git a/scripts/sortextable.h b/scripts/sortextable.h
104177 index 8fac3fd..32ff38d 100644
104178 --- a/scripts/sortextable.h
104179 +++ b/scripts/sortextable.h
104180 @@ -108,9 +108,9 @@ do_func(Elf_Ehdr *ehdr, char const *const fname, table_sort_t custom_sort)
104181 const char *secstrtab;
104182 const char *strtab;
104183 char *extab_image;
104184 - int extab_index = 0;
104185 - int i;
104186 - int idx;
104187 + unsigned int extab_index = 0;
104188 + unsigned int i;
104189 + unsigned int idx;
104190 unsigned int num_sections;
104191 unsigned int secindex_strings;
104192
104193 diff --git a/security/Kconfig b/security/Kconfig
104194 index beb86b5..40b1edb 100644
104195 --- a/security/Kconfig
104196 +++ b/security/Kconfig
104197 @@ -4,6 +4,957 @@
104198
104199 menu "Security options"
104200
104201 +menu "Grsecurity"
104202 +
104203 + config ARCH_TRACK_EXEC_LIMIT
104204 + bool
104205 +
104206 + config PAX_KERNEXEC_PLUGIN
104207 + bool
104208 +
104209 + config PAX_PER_CPU_PGD
104210 + bool
104211 +
104212 + config TASK_SIZE_MAX_SHIFT
104213 + int
104214 + depends on X86_64
104215 + default 47 if !PAX_PER_CPU_PGD
104216 + default 42 if PAX_PER_CPU_PGD
104217 +
104218 + config PAX_ENABLE_PAE
104219 + bool
104220 + default y if (X86_32 && (MPENTIUM4 || MK8 || MPSC || MCORE2 || MATOM))
104221 +
104222 + config PAX_USERCOPY_SLABS
104223 + bool
104224 +
104225 +config GRKERNSEC
104226 + bool "Grsecurity"
104227 + select CRYPTO
104228 + select CRYPTO_SHA256
104229 + select PROC_FS
104230 + select STOP_MACHINE
104231 + select TTY
104232 + select DEBUG_KERNEL
104233 + select DEBUG_LIST
104234 + help
104235 + If you say Y here, you will be able to configure many features
104236 + that will enhance the security of your system. It is highly
104237 + recommended that you say Y here and read through the help
104238 + for each option so that you fully understand the features and
104239 + can evaluate their usefulness for your machine.
104240 +
104241 +choice
104242 + prompt "Configuration Method"
104243 + depends on GRKERNSEC
104244 + default GRKERNSEC_CONFIG_CUSTOM
104245 + help
104246 +
104247 +config GRKERNSEC_CONFIG_AUTO
104248 + bool "Automatic"
104249 + help
104250 + If you choose this configuration method, you'll be able to answer a small
104251 + number of simple questions about how you plan to use this kernel.
104252 + The settings of grsecurity and PaX will be automatically configured for
104253 + the highest commonly-used settings within the provided constraints.
104254 +
104255 + If you require additional configuration, custom changes can still be made
104256 + from the "custom configuration" menu.
104257 +
104258 +config GRKERNSEC_CONFIG_CUSTOM
104259 + bool "Custom"
104260 + help
104261 + If you choose this configuration method, you'll be able to configure all
104262 + grsecurity and PaX settings manually. Via this method, no options are
104263 + automatically enabled.
104264 +
104265 +endchoice
104266 +
104267 +choice
104268 + prompt "Usage Type"
104269 + depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO)
104270 + default GRKERNSEC_CONFIG_SERVER
104271 + help
104272 +
104273 +config GRKERNSEC_CONFIG_SERVER
104274 + bool "Server"
104275 + help
104276 + Choose this option if you plan to use this kernel on a server.
104277 +
104278 +config GRKERNSEC_CONFIG_DESKTOP
104279 + bool "Desktop"
104280 + help
104281 + Choose this option if you plan to use this kernel on a desktop.
104282 +
104283 +endchoice
104284 +
104285 +choice
104286 + prompt "Virtualization Type"
104287 + depends on (GRKERNSEC && X86 && GRKERNSEC_CONFIG_AUTO)
104288 + default GRKERNSEC_CONFIG_VIRT_NONE
104289 + help
104290 +
104291 +config GRKERNSEC_CONFIG_VIRT_NONE
104292 + bool "None"
104293 + help
104294 + Choose this option if this kernel will be run on bare metal.
104295 +
104296 +config GRKERNSEC_CONFIG_VIRT_GUEST
104297 + bool "Guest"
104298 + help
104299 + Choose this option if this kernel will be run as a VM guest.
104300 +
104301 +config GRKERNSEC_CONFIG_VIRT_HOST
104302 + bool "Host"
104303 + help
104304 + Choose this option if this kernel will be run as a VM host.
104305 +
104306 +endchoice
104307 +
104308 +choice
104309 + prompt "Virtualization Hardware"
104310 + depends on (GRKERNSEC && X86 && GRKERNSEC_CONFIG_AUTO && (GRKERNSEC_CONFIG_VIRT_GUEST || GRKERNSEC_CONFIG_VIRT_HOST))
104311 + help
104312 +
104313 +config GRKERNSEC_CONFIG_VIRT_EPT
104314 + bool "EPT/RVI Processor Support"
104315 + depends on X86
104316 + help
104317 + Choose this option if your CPU supports the EPT or RVI features of 2nd-gen
104318 + hardware virtualization. This allows for additional kernel hardening protections
104319 + to operate without additional performance impact.
104320 +
104321 + To see if your Intel processor supports EPT, see:
104322 + http://ark.intel.com/Products/VirtualizationTechnology
104323 + (Most Core i3/5/7 support EPT)
104324 +
104325 + To see if your AMD processor supports RVI, see:
104326 + http://support.amd.com/us/kbarticles/Pages/GPU120AMDRVICPUsHyperVWin8.aspx
104327 +
104328 +config GRKERNSEC_CONFIG_VIRT_SOFT
104329 + bool "First-gen/No Hardware Virtualization"
104330 + help
104331 + Choose this option if you use an Atom/Pentium/Core 2 processor that either doesn't
104332 + support hardware virtualization or doesn't support the EPT/RVI extensions.
104333 +
104334 +endchoice
104335 +
104336 +choice
104337 + prompt "Virtualization Software"
104338 + depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO && (GRKERNSEC_CONFIG_VIRT_GUEST || GRKERNSEC_CONFIG_VIRT_HOST))
104339 + help
104340 +
104341 +config GRKERNSEC_CONFIG_VIRT_XEN
104342 + bool "Xen"
104343 + help
104344 + Choose this option if this kernel is running as a Xen guest or host.
104345 +
104346 +config GRKERNSEC_CONFIG_VIRT_VMWARE
104347 + bool "VMWare"
104348 + help
104349 + Choose this option if this kernel is running as a VMWare guest or host.
104350 +
104351 +config GRKERNSEC_CONFIG_VIRT_KVM
104352 + bool "KVM"
104353 + help
104354 + Choose this option if this kernel is running as a KVM guest or host.
104355 +
104356 +config GRKERNSEC_CONFIG_VIRT_VIRTUALBOX
104357 + bool "VirtualBox"
104358 + help
104359 + Choose this option if this kernel is running as a VirtualBox guest or host.
104360 +
104361 +endchoice
104362 +
104363 +choice
104364 + prompt "Required Priorities"
104365 + depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO)
104366 + default GRKERNSEC_CONFIG_PRIORITY_PERF
104367 + help
104368 +
104369 +config GRKERNSEC_CONFIG_PRIORITY_PERF
104370 + bool "Performance"
104371 + help
104372 + Choose this option if performance is of highest priority for this deployment
104373 + of grsecurity. Features like UDEREF on a 64bit kernel, kernel stack clearing,
104374 + clearing of structures intended for userland, and freed memory sanitizing will
104375 + be disabled.
104376 +
104377 +config GRKERNSEC_CONFIG_PRIORITY_SECURITY
104378 + bool "Security"
104379 + help
104380 + Choose this option if security is of highest priority for this deployment of
104381 + grsecurity. UDEREF, kernel stack clearing, clearing of structures intended
104382 + for userland, and freed memory sanitizing will be enabled for this kernel.
104383 + In a worst-case scenario, these features can introduce a 20% performance hit
104384 + (UDEREF on x64 contributing half of this hit).
104385 +
104386 +endchoice
104387 +
104388 +menu "Default Special Groups"
104389 +depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO)
104390 +
104391 +config GRKERNSEC_PROC_GID
104392 + int "GID exempted from /proc restrictions"
104393 + default 1001
104394 + help
104395 + Setting this GID determines which group will be exempted from
104396 + grsecurity's /proc restrictions, allowing users of the specified
104397 + group to view network statistics and the existence of other users'
104398 + processes on the system. This GID may also be chosen at boot time
104399 + via "grsec_proc_gid=" on the kernel commandline.
104400 +
104401 +config GRKERNSEC_TPE_UNTRUSTED_GID
104402 + int "GID for TPE-untrusted users"
104403 + depends on GRKERNSEC_CONFIG_SERVER && GRKERNSEC_TPE && !GRKERNSEC_TPE_INVERT
104404 + default 1005
104405 + help
104406 + Setting this GID determines which group untrusted users should
104407 + be added to. These users will be placed under grsecurity's Trusted Path
104408 + Execution mechanism, preventing them from executing their own binaries.
104409 + The users will only be able to execute binaries in directories owned and
104410 + writable only by the root user. If the sysctl option is enabled, a sysctl
104411 + option with name "tpe_gid" is created.
104412 +
104413 +config GRKERNSEC_TPE_TRUSTED_GID
104414 + int "GID for TPE-trusted users"
104415 + depends on GRKERNSEC_CONFIG_SERVER && GRKERNSEC_TPE && GRKERNSEC_TPE_INVERT
104416 + default 1005
104417 + help
104418 + Setting this GID determines what group TPE restrictions will be
104419 + *disabled* for. If the sysctl option is enabled, a sysctl option
104420 + with name "tpe_gid" is created.
104421 +
104422 +config GRKERNSEC_SYMLINKOWN_GID
104423 + int "GID for users with kernel-enforced SymlinksIfOwnerMatch"
104424 + depends on GRKERNSEC_CONFIG_SERVER
104425 + default 1006
104426 + help
104427 + Setting this GID determines what group kernel-enforced
104428 + SymlinksIfOwnerMatch will be enabled for. If the sysctl option
104429 + is enabled, a sysctl option with name "symlinkown_gid" is created.
104430 +
104431 +
104432 +endmenu
104433 +
104434 +menu "Customize Configuration"
104435 +depends on GRKERNSEC
104436 +
104437 +menu "PaX"
104438 +
104439 +config PAX
104440 + bool "Enable various PaX features"
104441 + default y if GRKERNSEC_CONFIG_AUTO
104442 + depends on GRKERNSEC && (ALPHA || ARM || AVR32 || IA64 || MIPS || PARISC || PPC || SPARC || X86)
104443 + help
104444 + This allows you to enable various PaX features. PaX adds
104445 + intrusion prevention mechanisms to the kernel that reduce
104446 + the risks posed by exploitable memory corruption bugs.
104447 +
104448 +menu "PaX Control"
104449 + depends on PAX
104450 +
104451 +config PAX_SOFTMODE
104452 + bool 'Support soft mode'
104453 + help
104454 + Enabling this option will allow you to run PaX in soft mode, that
104455 + is, PaX features will not be enforced by default, only on executables
104456 + marked explicitly. You must also enable PT_PAX_FLAGS or XATTR_PAX_FLAGS
104457 + support as they are the only way to mark executables for soft mode use.
104458 +
104459 + Soft mode can be activated by using the "pax_softmode=1" kernel command
104460 + line option on boot. Furthermore you can control various PaX features
104461 + at runtime via the entries in /proc/sys/kernel/pax.
104462 +
104463 +config PAX_EI_PAX
104464 + bool 'Use legacy ELF header marking'
104465 + default y if GRKERNSEC_CONFIG_AUTO
104466 + help
104467 + Enabling this option will allow you to control PaX features on
104468 + a per executable basis via the 'chpax' utility available at
104469 + http://pax.grsecurity.net/. The control flags will be read from
104470 + an otherwise reserved part of the ELF header. This marking has
104471 + numerous drawbacks (no support for soft-mode, toolchain does not
104472 + know about the non-standard use of the ELF header) therefore it
104473 + has been deprecated in favour of PT_PAX_FLAGS and XATTR_PAX_FLAGS
104474 + support.
104475 +
104476 + Note that if you enable PT_PAX_FLAGS or XATTR_PAX_FLAGS marking
104477 + support as well, they will override the legacy EI_PAX marks.
104478 +
104479 + If you enable none of the marking options then all applications
104480 + will run with PaX enabled on them by default.
104481 +
104482 +config PAX_PT_PAX_FLAGS
104483 + bool 'Use ELF program header marking'
104484 + default y if GRKERNSEC_CONFIG_AUTO
104485 + help
104486 + Enabling this option will allow you to control PaX features on
104487 + a per executable basis via the 'paxctl' utility available at
104488 + http://pax.grsecurity.net/. The control flags will be read from
104489 + a PaX specific ELF program header (PT_PAX_FLAGS). This marking
104490 + has the benefits of supporting both soft mode and being fully
104491 + integrated into the toolchain (the binutils patch is available
104492 + from http://pax.grsecurity.net).
104493 +
104494 + Note that if you enable the legacy EI_PAX marking support as well,
104495 + the EI_PAX marks will be overridden by the PT_PAX_FLAGS marks.
104496 +
104497 + If you enable both PT_PAX_FLAGS and XATTR_PAX_FLAGS support then you
104498 + must make sure that the marks are the same if a binary has both marks.
104499 +
104500 + If you enable none of the marking options then all applications
104501 + will run with PaX enabled on them by default.
104502 +
104503 +config PAX_XATTR_PAX_FLAGS
104504 + bool 'Use filesystem extended attributes marking'
104505 + default y if GRKERNSEC_CONFIG_AUTO
104506 + select CIFS_XATTR if CIFS
104507 + select F2FS_FS_XATTR if F2FS_FS
104508 + select EXT2_FS_XATTR if EXT2_FS
104509 + select EXT3_FS_XATTR if EXT3_FS
104510 + select JFFS2_FS_XATTR if JFFS2_FS
104511 + select REISERFS_FS_XATTR if REISERFS_FS
104512 + select SQUASHFS_XATTR if SQUASHFS
104513 + select TMPFS_XATTR if TMPFS
104514 + help
104515 + Enabling this option will allow you to control PaX features on
104516 + a per executable basis via the 'setfattr' utility. The control
104517 + flags will be read from the user.pax.flags extended attribute of
104518 + the file. This marking has the benefit of supporting binary-only
104519 + applications that self-check themselves (e.g., skype) and would
104520 + not tolerate chpax/paxctl changes. The main drawback is that
104521 + extended attributes are not supported by some filesystems (e.g.,
104522 + isofs, udf, vfat) so copying files through such filesystems will
104523 + lose the extended attributes and these PaX markings.
104524 +
104525 + Note that if you enable the legacy EI_PAX marking support as well,
104526 + the EI_PAX marks will be overridden by the XATTR_PAX_FLAGS marks.
104527 +
104528 + If you enable both PT_PAX_FLAGS and XATTR_PAX_FLAGS support then you
104529 + must make sure that the marks are the same if a binary has both marks.
104530 +
104531 + If you enable none of the marking options then all applications
104532 + will run with PaX enabled on them by default.
104533 +
104534 +choice
104535 + prompt 'MAC system integration'
104536 + default PAX_HAVE_ACL_FLAGS
104537 + help
104538 + Mandatory Access Control systems have the option of controlling
104539 + PaX flags on a per executable basis, choose the method supported
104540 + by your particular system.
104541 +
104542 + - "none": if your MAC system does not interact with PaX,
104543 + - "direct": if your MAC system defines pax_set_initial_flags() itself,
104544 + - "hook": if your MAC system uses the pax_set_initial_flags_func callback.
104545 +
104546 + NOTE: this option is for developers/integrators only.
104547 +
104548 + config PAX_NO_ACL_FLAGS
104549 + bool 'none'
104550 +
104551 + config PAX_HAVE_ACL_FLAGS
104552 + bool 'direct'
104553 +
104554 + config PAX_HOOK_ACL_FLAGS
104555 + bool 'hook'
104556 +endchoice
104557 +
104558 +endmenu
104559 +
104560 +menu "Non-executable pages"
104561 + depends on PAX
104562 +
104563 +config PAX_NOEXEC
104564 + bool "Enforce non-executable pages"
104565 + default y if GRKERNSEC_CONFIG_AUTO
104566 + depends on ALPHA || (ARM && (CPU_V6 || CPU_V6K || CPU_V7)) || IA64 || MIPS || PARISC || PPC || S390 || SPARC || X86
104567 + help
104568 + By design some architectures do not allow for protecting memory
104569 + pages against execution or even if they do, Linux does not make
104570 + use of this feature. In practice this means that if a page is
104571 + readable (such as the stack or heap) it is also executable.
104572 +
104573 + There is a well known exploit technique that makes use of this
104574 + fact and a common programming mistake where an attacker can
104575 + introduce code of his choice somewhere in the attacked program's
104576 + memory (typically the stack or the heap) and then execute it.
104577 +
104578 + If the attacked program was running with different (typically
104579 + higher) privileges than that of the attacker, then he can elevate
104580 + his own privilege level (e.g. get a root shell, write to files for
104581 + which he does not have write access to, etc).
104582 +
104583 + Enabling this option will let you choose from various features
104584 + that prevent the injection and execution of 'foreign' code in
104585 + a program.
104586 +
104587 + This will also break programs that rely on the old behaviour and
104588 + expect that dynamically allocated memory via the malloc() family
104589 + of functions is executable (which it is not). Notable examples
104590 + are the XFree86 4.x server, the java runtime and wine.
104591 +
104592 +config PAX_PAGEEXEC
104593 + bool "Paging based non-executable pages"
104594 + default y if GRKERNSEC_CONFIG_AUTO
104595 + 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)
104596 + select ARCH_TRACK_EXEC_LIMIT if X86_32
104597 + help
104598 + This implementation is based on the paging feature of the CPU.
104599 + On i386 without hardware non-executable bit support there is a
104600 + variable but usually low performance impact, however on Intel's
104601 + P4 core based CPUs it is very high so you should not enable this
104602 + for kernels meant to be used on such CPUs.
104603 +
104604 + On alpha, avr32, ia64, parisc, sparc, sparc64, x86_64 and i386
104605 + with hardware non-executable bit support there is no performance
104606 + impact, on ppc the impact is negligible.
104607 +
104608 + Note that several architectures require various emulations due to
104609 + badly designed userland ABIs, this will cause a performance impact
104610 + but will disappear as soon as userland is fixed. For example, ppc
104611 + userland MUST have been built with secure-plt by a recent toolchain.
104612 +
104613 +config PAX_SEGMEXEC
104614 + bool "Segmentation based non-executable pages"
104615 + default y if GRKERNSEC_CONFIG_AUTO
104616 + depends on PAX_NOEXEC && X86_32
104617 + help
104618 + This implementation is based on the segmentation feature of the
104619 + CPU and has a very small performance impact, however applications
104620 + will be limited to a 1.5 GB address space instead of the normal
104621 + 3 GB.
104622 +
104623 +config PAX_EMUTRAMP
104624 + bool "Emulate trampolines"
104625 + default y if PARISC || GRKERNSEC_CONFIG_AUTO
104626 + depends on (PAX_PAGEEXEC || PAX_SEGMEXEC) && (PARISC || X86)
104627 + help
104628 + There are some programs and libraries that for one reason or
104629 + another attempt to execute special small code snippets from
104630 + non-executable memory pages. Most notable examples are the
104631 + signal handler return code generated by the kernel itself and
104632 + the GCC trampolines.
104633 +
104634 + If you enabled CONFIG_PAX_PAGEEXEC or CONFIG_PAX_SEGMEXEC then
104635 + such programs will no longer work under your kernel.
104636 +
104637 + As a remedy you can say Y here and use the 'chpax' or 'paxctl'
104638 + utilities to enable trampoline emulation for the affected programs
104639 + yet still have the protection provided by the non-executable pages.
104640 +
104641 + On parisc you MUST enable this option and EMUSIGRT as well, otherwise
104642 + your system will not even boot.
104643 +
104644 + Alternatively you can say N here and use the 'chpax' or 'paxctl'
104645 + utilities to disable CONFIG_PAX_PAGEEXEC and CONFIG_PAX_SEGMEXEC
104646 + for the affected files.
104647 +
104648 + NOTE: enabling this feature *may* open up a loophole in the
104649 + protection provided by non-executable pages that an attacker
104650 + could abuse. Therefore the best solution is to not have any
104651 + files on your system that would require this option. This can
104652 + be achieved by not using libc5 (which relies on the kernel
104653 + signal handler return code) and not using or rewriting programs
104654 + that make use of the nested function implementation of GCC.
104655 + Skilled users can just fix GCC itself so that it implements
104656 + nested function calls in a way that does not interfere with PaX.
104657 +
104658 +config PAX_EMUSIGRT
104659 + bool "Automatically emulate sigreturn trampolines"
104660 + depends on PAX_EMUTRAMP && PARISC
104661 + default y
104662 + help
104663 + Enabling this option will have the kernel automatically detect
104664 + and emulate signal return trampolines executing on the stack
104665 + that would otherwise lead to task termination.
104666 +
104667 + This solution is intended as a temporary one for users with
104668 + legacy versions of libc (libc5, glibc 2.0, uClibc before 0.9.17,
104669 + Modula-3 runtime, etc) or executables linked to such, basically
104670 + everything that does not specify its own SA_RESTORER function in
104671 + normal executable memory like glibc 2.1+ does.
104672 +
104673 + On parisc you MUST enable this option, otherwise your system will
104674 + not even boot.
104675 +
104676 + NOTE: this feature cannot be disabled on a per executable basis
104677 + and since it *does* open up a loophole in the protection provided
104678 + by non-executable pages, the best solution is to not have any
104679 + files on your system that would require this option.
104680 +
104681 +config PAX_MPROTECT
104682 + bool "Restrict mprotect()"
104683 + default y if GRKERNSEC_CONFIG_AUTO
104684 + depends on (PAX_PAGEEXEC || PAX_SEGMEXEC)
104685 + help
104686 + Enabling this option will prevent programs from
104687 + - changing the executable status of memory pages that were
104688 + not originally created as executable,
104689 + - making read-only executable pages writable again,
104690 + - creating executable pages from anonymous memory,
104691 + - making read-only-after-relocations (RELRO) data pages writable again.
104692 +
104693 + You should say Y here to complete the protection provided by
104694 + the enforcement of non-executable pages.
104695 +
104696 + NOTE: you can use the 'chpax' or 'paxctl' utilities to control
104697 + this feature on a per file basis.
104698 +
104699 +config PAX_MPROTECT_COMPAT
104700 + bool "Use legacy/compat protection demoting (read help)"
104701 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_DESKTOP)
104702 + depends on PAX_MPROTECT
104703 + help
104704 + The current implementation of PAX_MPROTECT denies RWX allocations/mprotects
104705 + by sending the proper error code to the application. For some broken
104706 + userland, this can cause problems with Python or other applications. The
104707 + current implementation however allows for applications like clamav to
104708 + detect if JIT compilation/execution is allowed and to fall back gracefully
104709 + to an interpreter-based mode if it does not. While we encourage everyone
104710 + to use the current implementation as-is and push upstream to fix broken
104711 + userland (note that the RWX logging option can assist with this), in some
104712 + environments this may not be possible. Having to disable MPROTECT
104713 + completely on certain binaries reduces the security benefit of PaX,
104714 + so this option is provided for those environments to revert to the old
104715 + behavior.
104716 +
104717 +config PAX_ELFRELOCS
104718 + bool "Allow ELF text relocations (read help)"
104719 + depends on PAX_MPROTECT
104720 + default n
104721 + help
104722 + Non-executable pages and mprotect() restrictions are effective
104723 + in preventing the introduction of new executable code into an
104724 + attacked task's address space. There remain only two venues
104725 + for this kind of attack: if the attacker can execute already
104726 + existing code in the attacked task then he can either have it
104727 + create and mmap() a file containing his code or have it mmap()
104728 + an already existing ELF library that does not have position
104729 + independent code in it and use mprotect() on it to make it
104730 + writable and copy his code there. While protecting against
104731 + the former approach is beyond PaX, the latter can be prevented
104732 + by having only PIC ELF libraries on one's system (which do not
104733 + need to relocate their code). If you are sure this is your case,
104734 + as is the case with all modern Linux distributions, then leave
104735 + this option disabled. You should say 'n' here.
104736 +
104737 +config PAX_ETEXECRELOCS
104738 + bool "Allow ELF ET_EXEC text relocations"
104739 + depends on PAX_MPROTECT && (ALPHA || IA64 || PARISC)
104740 + select PAX_ELFRELOCS
104741 + default y
104742 + help
104743 + On some architectures there are incorrectly created applications
104744 + that require text relocations and would not work without enabling
104745 + this option. If you are an alpha, ia64 or parisc user, you should
104746 + enable this option and disable it once you have made sure that
104747 + none of your applications need it.
104748 +
104749 +config PAX_EMUPLT
104750 + bool "Automatically emulate ELF PLT"
104751 + depends on PAX_MPROTECT && (ALPHA || PARISC || SPARC)
104752 + default y
104753 + help
104754 + Enabling this option will have the kernel automatically detect
104755 + and emulate the Procedure Linkage Table entries in ELF files.
104756 + On some architectures such entries are in writable memory, and
104757 + become non-executable leading to task termination. Therefore
104758 + it is mandatory that you enable this option on alpha, parisc,
104759 + sparc and sparc64, otherwise your system would not even boot.
104760 +
104761 + NOTE: this feature *does* open up a loophole in the protection
104762 + provided by the non-executable pages, therefore the proper
104763 + solution is to modify the toolchain to produce a PLT that does
104764 + not need to be writable.
104765 +
104766 +config PAX_DLRESOLVE
104767 + bool 'Emulate old glibc resolver stub'
104768 + depends on PAX_EMUPLT && SPARC
104769 + default n
104770 + help
104771 + This option is needed if userland has an old glibc (before 2.4)
104772 + that puts a 'save' instruction into the runtime generated resolver
104773 + stub that needs special emulation.
104774 +
104775 +config PAX_KERNEXEC
104776 + bool "Enforce non-executable kernel pages"
104777 + default y if GRKERNSEC_CONFIG_AUTO && (!X86 || GRKERNSEC_CONFIG_VIRT_NONE || (GRKERNSEC_CONFIG_VIRT_EPT && GRKERNSEC_CONFIG_VIRT_GUEST) || (GRKERNSEC_CONFIG_VIRT_EPT && GRKERNSEC_CONFIG_VIRT_KVM))
104778 + depends on (X86 || (ARM && (CPU_V6 || CPU_V6K || CPU_V7) && !(ARM_LPAE && MODULES))) && !XEN
104779 + select PAX_PER_CPU_PGD if X86_64 || (X86_32 && X86_PAE)
104780 + select PAX_KERNEXEC_PLUGIN if X86_64
104781 + help
104782 + This is the kernel land equivalent of PAGEEXEC and MPROTECT,
104783 + that is, enabling this option will make it harder to inject
104784 + and execute 'foreign' code in kernel memory itself.
104785 +
104786 +choice
104787 + prompt "Return Address Instrumentation Method"
104788 + default PAX_KERNEXEC_PLUGIN_METHOD_BTS
104789 + depends on PAX_KERNEXEC_PLUGIN
104790 + help
104791 + Select the method used to instrument function pointer dereferences.
104792 + Note that binary modules cannot be instrumented by this approach.
104793 +
104794 + Note that the implementation requires a gcc with plugin support,
104795 + i.e., gcc 4.5 or newer. You may need to install the supporting
104796 + headers explicitly in addition to the normal gcc package.
104797 +
104798 + config PAX_KERNEXEC_PLUGIN_METHOD_BTS
104799 + bool "bts"
104800 + help
104801 + This method is compatible with binary only modules but has
104802 + a higher runtime overhead.
104803 +
104804 + config PAX_KERNEXEC_PLUGIN_METHOD_OR
104805 + bool "or"
104806 + depends on !PARAVIRT
104807 + help
104808 + This method is incompatible with binary only modules but has
104809 + a lower runtime overhead.
104810 +endchoice
104811 +
104812 +config PAX_KERNEXEC_PLUGIN_METHOD
104813 + string
104814 + default "bts" if PAX_KERNEXEC_PLUGIN_METHOD_BTS
104815 + default "or" if PAX_KERNEXEC_PLUGIN_METHOD_OR
104816 + default ""
104817 +
104818 +config PAX_KERNEXEC_MODULE_TEXT
104819 + int "Minimum amount of memory reserved for module code"
104820 + default "4" if (!GRKERNSEC_CONFIG_AUTO || GRKERNSEC_CONFIG_SERVER)
104821 + default "12" if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_DESKTOP)
104822 + depends on PAX_KERNEXEC && X86_32
104823 + help
104824 + Due to implementation details the kernel must reserve a fixed
104825 + amount of memory for runtime allocated code (such as modules)
104826 + at compile time that cannot be changed at runtime. Here you
104827 + can specify the minimum amount in MB that will be reserved.
104828 + Due to the same implementation details this size will always
104829 + be rounded up to the next 2/4 MB boundary (depends on PAE) so
104830 + the actually available memory for runtime allocated code will
104831 + usually be more than this minimum.
104832 +
104833 + The default 4 MB should be enough for most users but if you have
104834 + an excessive number of modules (e.g., most distribution configs
104835 + compile many drivers as modules) or use huge modules such as
104836 + nvidia's kernel driver, you will need to adjust this amount.
104837 + A good rule of thumb is to look at your currently loaded kernel
104838 + modules and add up their sizes.
104839 +
104840 +endmenu
104841 +
104842 +menu "Address Space Layout Randomization"
104843 + depends on PAX
104844 +
104845 +config PAX_ASLR
104846 + bool "Address Space Layout Randomization"
104847 + default y if GRKERNSEC_CONFIG_AUTO
104848 + help
104849 + Many if not most exploit techniques rely on the knowledge of
104850 + certain addresses in the attacked program. The following options
104851 + will allow the kernel to apply a certain amount of randomization
104852 + to specific parts of the program thereby forcing an attacker to
104853 + guess them in most cases. Any failed guess will most likely crash
104854 + the attacked program which allows the kernel to detect such attempts
104855 + and react on them. PaX itself provides no reaction mechanisms,
104856 + instead it is strongly encouraged that you make use of grsecurity's
104857 + (http://www.grsecurity.net/) built-in crash detection features or
104858 + develop one yourself.
104859 +
104860 + By saying Y here you can choose to randomize the following areas:
104861 + - top of the task's kernel stack
104862 + - top of the task's userland stack
104863 + - base address for mmap() requests that do not specify one
104864 + (this includes all libraries)
104865 + - base address of the main executable
104866 +
104867 + It is strongly recommended to say Y here as address space layout
104868 + randomization has negligible impact on performance yet it provides
104869 + a very effective protection.
104870 +
104871 + NOTE: you can use the 'chpax' or 'paxctl' utilities to control
104872 + this feature on a per file basis.
104873 +
104874 +config PAX_RANDKSTACK
104875 + bool "Randomize kernel stack base"
104876 + default y if GRKERNSEC_CONFIG_AUTO && !(GRKERNSEC_CONFIG_VIRT_HOST && GRKERNSEC_CONFIG_VIRT_VIRTUALBOX)
104877 + depends on X86_TSC && X86
104878 + help
104879 + By saying Y here the kernel will randomize every task's kernel
104880 + stack on every system call. This will not only force an attacker
104881 + to guess it but also prevent him from making use of possible
104882 + leaked information about it.
104883 +
104884 + Since the kernel stack is a rather scarce resource, randomization
104885 + may cause unexpected stack overflows, therefore you should very
104886 + carefully test your system. Note that once enabled in the kernel
104887 + configuration, this feature cannot be disabled on a per file basis.
104888 +
104889 +config PAX_RANDUSTACK
104890 + bool
104891 +
104892 +config PAX_RANDMMAP
104893 + bool "Randomize user stack and mmap() bases"
104894 + default y if GRKERNSEC_CONFIG_AUTO
104895 + depends on PAX_ASLR
104896 + select PAX_RANDUSTACK
104897 + help
104898 + By saying Y here the kernel will randomize every task's userland
104899 + stack and use a randomized base address for mmap() requests that
104900 + do not specify one themselves.
104901 +
104902 + The stack randomization is done in two steps where the second
104903 + one may apply a big amount of shift to the top of the stack and
104904 + cause problems for programs that want to use lots of memory (more
104905 + than 2.5 GB if SEGMEXEC is not active, or 1.25 GB when it is).
104906 +
104907 + As a result of mmap randomization all dynamically loaded libraries
104908 + will appear at random addresses and therefore be harder to exploit
104909 + by a technique where an attacker attempts to execute library code
104910 + for his purposes (e.g. spawn a shell from an exploited program that
104911 + is running at an elevated privilege level).
104912 +
104913 + Furthermore, if a program is relinked as a dynamic ELF file, its
104914 + base address will be randomized as well, completing the full
104915 + randomization of the address space layout. Attacking such programs
104916 + becomes a guess game. You can find an example of doing this at
104917 + http://pax.grsecurity.net/et_dyn.tar.gz and practical samples at
104918 + http://www.grsecurity.net/grsec-gcc-specs.tar.gz .
104919 +
104920 + NOTE: you can use the 'chpax' or 'paxctl' utilities to control this
104921 + feature on a per file basis.
104922 +
104923 +endmenu
104924 +
104925 +menu "Miscellaneous hardening features"
104926 +
104927 +config PAX_MEMORY_SANITIZE
104928 + bool "Sanitize all freed memory"
104929 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_PRIORITY_SECURITY)
104930 + help
104931 + By saying Y here the kernel will erase memory pages and slab objects
104932 + as soon as they are freed. This in turn reduces the lifetime of data
104933 + stored in them, making it less likely that sensitive information such
104934 + as passwords, cryptographic secrets, etc stay in memory for too long.
104935 +
104936 + This is especially useful for programs whose runtime is short, long
104937 + lived processes and the kernel itself benefit from this as long as
104938 + they ensure timely freeing of memory that may hold sensitive
104939 + information.
104940 +
104941 + A nice side effect of the sanitization of slab objects is the
104942 + reduction of possible info leaks caused by padding bytes within the
104943 + leaky structures. Use-after-free bugs for structures containing
104944 + pointers can also be detected as dereferencing the sanitized pointer
104945 + will generate an access violation.
104946 +
104947 + The tradeoff is performance impact, on a single CPU system kernel
104948 + compilation sees a 3% slowdown, other systems and workloads may vary
104949 + and you are advised to test this feature on your expected workload
104950 + before deploying it.
104951 +
104952 + To reduce the performance penalty by sanitizing pages only, albeit
104953 + limiting the effectiveness of this feature at the same time, slab
104954 + sanitization can be disabled with the kernel commandline parameter
104955 + "pax_sanitize_slab=0".
104956 +
104957 + Note that this feature does not protect data stored in live pages,
104958 + e.g., process memory swapped to disk may stay there for a long time.
104959 +
104960 +config PAX_MEMORY_STACKLEAK
104961 + bool "Sanitize kernel stack"
104962 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_PRIORITY_SECURITY)
104963 + depends on X86
104964 + help
104965 + By saying Y here the kernel will erase the kernel stack before it
104966 + returns from a system call. This in turn reduces the information
104967 + that a kernel stack leak bug can reveal.
104968 +
104969 + Note that such a bug can still leak information that was put on
104970 + the stack by the current system call (the one eventually triggering
104971 + the bug) but traces of earlier system calls on the kernel stack
104972 + cannot leak anymore.
104973 +
104974 + The tradeoff is performance impact: on a single CPU system kernel
104975 + compilation sees a 1% slowdown, other systems and workloads may vary
104976 + and you are advised to test this feature on your expected workload
104977 + before deploying it.
104978 +
104979 + Note that the full feature requires a gcc with plugin support,
104980 + i.e., gcc 4.5 or newer. You may need to install the supporting
104981 + headers explicitly in addition to the normal gcc package. Using
104982 + older gcc versions means that functions with large enough stack
104983 + frames may leave uninitialized memory behind that may be exposed
104984 + to a later syscall leaking the stack.
104985 +
104986 +config PAX_MEMORY_STRUCTLEAK
104987 + bool "Forcibly initialize local variables copied to userland"
104988 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_PRIORITY_SECURITY)
104989 + help
104990 + By saying Y here the kernel will zero initialize some local
104991 + variables that are going to be copied to userland. This in
104992 + turn prevents unintended information leakage from the kernel
104993 + stack should later code forget to explicitly set all parts of
104994 + the copied variable.
104995 +
104996 + The tradeoff is less performance impact than PAX_MEMORY_STACKLEAK
104997 + at a much smaller coverage.
104998 +
104999 + Note that the implementation requires a gcc with plugin support,
105000 + i.e., gcc 4.5 or newer. You may need to install the supporting
105001 + headers explicitly in addition to the normal gcc package.
105002 +
105003 +config PAX_MEMORY_UDEREF
105004 + bool "Prevent invalid userland pointer dereference"
105005 + default y if GRKERNSEC_CONFIG_AUTO && !(X86_64 && GRKERNSEC_CONFIG_PRIORITY_PERF) && (!X86 || GRKERNSEC_CONFIG_VIRT_NONE || GRKERNSEC_CONFIG_VIRT_EPT)
105006 + depends on (X86 || (ARM && (CPU_V6 || CPU_V6K || CPU_V7) && !ARM_LPAE)) && !UML_X86 && !XEN
105007 + select PAX_PER_CPU_PGD if X86_64
105008 + help
105009 + By saying Y here the kernel will be prevented from dereferencing
105010 + userland pointers in contexts where the kernel expects only kernel
105011 + pointers. This is both a useful runtime debugging feature and a
105012 + security measure that prevents exploiting a class of kernel bugs.
105013 +
105014 + The tradeoff is that some virtualization solutions may experience
105015 + a huge slowdown and therefore you should not enable this feature
105016 + for kernels meant to run in such environments. Whether a given VM
105017 + solution is affected or not is best determined by simply trying it
105018 + out, the performance impact will be obvious right on boot as this
105019 + mechanism engages from very early on. A good rule of thumb is that
105020 + VMs running on CPUs without hardware virtualization support (i.e.,
105021 + the majority of IA-32 CPUs) will likely experience the slowdown.
105022 +
105023 + On X86_64 the kernel will make use of PCID support when available
105024 + (Intel's Westmere, Sandy Bridge, etc) for better security (default)
105025 + or performance impact. Pass pax_weakuderef on the kernel command
105026 + line to choose the latter.
105027 +
105028 +config PAX_REFCOUNT
105029 + bool "Prevent various kernel object reference counter overflows"
105030 + default y if GRKERNSEC_CONFIG_AUTO
105031 + depends on GRKERNSEC && ((ARM && (CPU_V6 || CPU_V6K || CPU_V7)) || MIPS || SPARC64 || X86)
105032 + help
105033 + By saying Y here the kernel will detect and prevent overflowing
105034 + various (but not all) kinds of object reference counters. Such
105035 + overflows can normally occur due to bugs only and are often, if
105036 + not always, exploitable.
105037 +
105038 + The tradeoff is that data structures protected by an overflowed
105039 + refcount will never be freed and therefore will leak memory. Note
105040 + that this leak also happens even without this protection but in
105041 + that case the overflow can eventually trigger the freeing of the
105042 + data structure while it is still being used elsewhere, resulting
105043 + in the exploitable situation that this feature prevents.
105044 +
105045 + Since this has a negligible performance impact, you should enable
105046 + this feature.
105047 +
105048 +config PAX_CONSTIFY_PLUGIN
105049 + bool "Automatically constify eligible structures"
105050 + default y
105051 + depends on !UML && PAX_KERNEXEC
105052 + help
105053 + By saying Y here the compiler will automatically constify a class
105054 + of types that contain only function pointers. This reduces the
105055 + kernel's attack surface and also produces a better memory layout.
105056 +
105057 + Note that the implementation requires a gcc with plugin support,
105058 + i.e., gcc 4.5 or newer. You may need to install the supporting
105059 + headers explicitly in addition to the normal gcc package.
105060 +
105061 + Note that if some code really has to modify constified variables
105062 + then the source code will have to be patched to allow it. Examples
105063 + can be found in PaX itself (the no_const attribute) and for some
105064 + out-of-tree modules at http://www.grsecurity.net/~paxguy1/ .
105065 +
105066 +config PAX_USERCOPY
105067 + bool "Harden heap object copies between kernel and userland"
105068 + default y if GRKERNSEC_CONFIG_AUTO
105069 + depends on ARM || IA64 || PPC || SPARC || X86
105070 + depends on GRKERNSEC && (SLAB || SLUB || SLOB)
105071 + select PAX_USERCOPY_SLABS
105072 + help
105073 + By saying Y here the kernel will enforce the size of heap objects
105074 + when they are copied in either direction between the kernel and
105075 + userland, even if only a part of the heap object is copied.
105076 +
105077 + Specifically, this checking prevents information leaking from the
105078 + kernel heap during kernel to userland copies (if the kernel heap
105079 + object is otherwise fully initialized) and prevents kernel heap
105080 + overflows during userland to kernel copies.
105081 +
105082 + Note that the current implementation provides the strictest bounds
105083 + checks for the SLUB allocator.
105084 +
105085 + Enabling this option also enables per-slab cache protection against
105086 + data in a given cache being copied into/out of via userland
105087 + accessors. Though the whitelist of regions will be reduced over
105088 + time, it notably protects important data structures like task structs.
105089 +
105090 + If frame pointers are enabled on x86, this option will also restrict
105091 + copies into and out of the kernel stack to local variables within a
105092 + single frame.
105093 +
105094 + Since this has a negligible performance impact, you should enable
105095 + this feature.
105096 +
105097 +config PAX_USERCOPY_DEBUG
105098 + bool
105099 + depends on X86 && PAX_USERCOPY
105100 + default n
105101 +
105102 +config PAX_SIZE_OVERFLOW
105103 + bool "Prevent various integer overflows in function size parameters"
105104 + default y if GRKERNSEC_CONFIG_AUTO
105105 + depends on X86
105106 + help
105107 + By saying Y here the kernel recomputes expressions of function
105108 + arguments marked by a size_overflow attribute with double integer
105109 + precision (DImode/TImode for 32/64 bit integer types).
105110 +
105111 + The recomputed argument is checked against TYPE_MAX and an event
105112 + is logged on overflow and the triggering process is killed.
105113 +
105114 + Homepage: http://www.grsecurity.net/~ephox/overflow_plugin/
105115 +
105116 + Note that the implementation requires a gcc with plugin support,
105117 + i.e., gcc 4.5 or newer. You may need to install the supporting
105118 + headers explicitly in addition to the normal gcc package.
105119 +
105120 +config PAX_LATENT_ENTROPY
105121 + bool "Generate some entropy during boot and runtime"
105122 + default y if GRKERNSEC_CONFIG_AUTO
105123 + help
105124 + By saying Y here the kernel will instrument some kernel code to
105125 + extract some entropy from both original and artificially created
105126 + program state. This will help especially embedded systems where
105127 + there is little 'natural' source of entropy normally. The cost
105128 + is some slowdown of the boot process and fork and irq processing.
105129 +
105130 + When pax_extra_latent_entropy is passed on the kernel command line,
105131 + entropy will be extracted from up to the first 4GB of RAM while the
105132 + runtime memory allocator is being initialized. This costs even more
105133 + slowdown of the boot process.
105134 +
105135 + Note that the implementation requires a gcc with plugin support,
105136 + i.e., gcc 4.5 or newer. You may need to install the supporting
105137 + headers explicitly in addition to the normal gcc package.
105138 +
105139 + Note that entropy extracted this way is not cryptographically
105140 + secure!
105141 +
105142 +endmenu
105143 +
105144 +endmenu
105145 +
105146 +source grsecurity/Kconfig
105147 +
105148 +endmenu
105149 +
105150 +endmenu
105151 +
105152 source security/keys/Kconfig
105153
105154 config SECURITY_DMESG_RESTRICT
105155 @@ -103,7 +1054,7 @@ config INTEL_TXT
105156 config LSM_MMAP_MIN_ADDR
105157 int "Low address space for LSM to protect from user allocation"
105158 depends on SECURITY && SECURITY_SELINUX
105159 - default 32768 if ARM || (ARM64 && COMPAT)
105160 + default 32768 if ALPHA || ARM || (ARM64 && COMPAT) || PARISC || SPARC32
105161 default 65536
105162 help
105163 This is the portion of low virtual memory which should be protected
105164 diff --git a/security/apparmor/file.c b/security/apparmor/file.c
105165 index fdaa50c..2761dcb 100644
105166 --- a/security/apparmor/file.c
105167 +++ b/security/apparmor/file.c
105168 @@ -348,8 +348,8 @@ static inline bool xindex_is_subset(u32 link, u32 target)
105169 int aa_path_link(struct aa_profile *profile, struct dentry *old_dentry,
105170 struct path *new_dir, struct dentry *new_dentry)
105171 {
105172 - struct path link = { new_dir->mnt, new_dentry };
105173 - struct path target = { new_dir->mnt, old_dentry };
105174 + struct path link = { .mnt = new_dir->mnt, .dentry = new_dentry };
105175 + struct path target = { .mnt = new_dir->mnt, .dentry = old_dentry };
105176 struct path_cond cond = {
105177 old_dentry->d_inode->i_uid,
105178 old_dentry->d_inode->i_mode
105179 diff --git a/security/apparmor/lsm.c b/security/apparmor/lsm.c
105180 index 9981000..eb21356 100644
105181 --- a/security/apparmor/lsm.c
105182 +++ b/security/apparmor/lsm.c
105183 @@ -186,7 +186,7 @@ static int common_perm_dir_dentry(int op, struct path *dir,
105184 struct dentry *dentry, u32 mask,
105185 struct path_cond *cond)
105186 {
105187 - struct path path = { dir->mnt, dentry };
105188 + struct path path = { .mnt = dir->mnt, .dentry = dentry };
105189
105190 return common_perm(op, &path, mask, cond);
105191 }
105192 @@ -203,7 +203,7 @@ static int common_perm_dir_dentry(int op, struct path *dir,
105193 static int common_perm_mnt_dentry(int op, struct vfsmount *mnt,
105194 struct dentry *dentry, u32 mask)
105195 {
105196 - struct path path = { mnt, dentry };
105197 + struct path path = { .mnt = mnt, .dentry = dentry };
105198 struct path_cond cond = { dentry->d_inode->i_uid,
105199 dentry->d_inode->i_mode
105200 };
105201 @@ -325,8 +325,8 @@ static int apparmor_path_rename(struct path *old_dir, struct dentry *old_dentry,
105202
105203 profile = aa_current_profile();
105204 if (!unconfined(profile)) {
105205 - struct path old_path = { old_dir->mnt, old_dentry };
105206 - struct path new_path = { new_dir->mnt, new_dentry };
105207 + struct path old_path = { .mnt = old_dir->mnt, .dentry = old_dentry };
105208 + struct path new_path = { .mnt = new_dir->mnt, .dentry = new_dentry };
105209 struct path_cond cond = { old_dentry->d_inode->i_uid,
105210 old_dentry->d_inode->i_mode
105211 };
105212 @@ -615,7 +615,7 @@ static int apparmor_task_setrlimit(struct task_struct *task,
105213 return error;
105214 }
105215
105216 -static struct security_operations apparmor_ops = {
105217 +static struct security_operations apparmor_ops __read_only = {
105218 .name = "apparmor",
105219
105220 .ptrace_access_check = apparmor_ptrace_access_check,
105221 diff --git a/security/commoncap.c b/security/commoncap.c
105222 index b9d613e..f68305c 100644
105223 --- a/security/commoncap.c
105224 +++ b/security/commoncap.c
105225 @@ -424,6 +424,32 @@ int get_vfs_caps_from_disk(const struct dentry *dentry, struct cpu_vfs_cap_data
105226 return 0;
105227 }
105228
105229 +/* returns:
105230 + 1 for suid privilege
105231 + 2 for sgid privilege
105232 + 3 for fscap privilege
105233 +*/
105234 +int is_privileged_binary(const struct dentry *dentry)
105235 +{
105236 + struct cpu_vfs_cap_data capdata;
105237 + struct inode *inode = dentry->d_inode;
105238 +
105239 + if (!inode || S_ISDIR(inode->i_mode))
105240 + return 0;
105241 +
105242 + if (inode->i_mode & S_ISUID)
105243 + return 1;
105244 + if ((inode->i_mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))
105245 + return 2;
105246 +
105247 + if (!get_vfs_caps_from_disk(dentry, &capdata)) {
105248 + if (!cap_isclear(capdata.inheritable) || !cap_isclear(capdata.permitted))
105249 + return 3;
105250 + }
105251 +
105252 + return 0;
105253 +}
105254 +
105255 /*
105256 * Attempt to get the on-exec apply capability sets for an executable file from
105257 * its xattrs and, if present, apply them to the proposed credentials being
105258 @@ -592,6 +618,9 @@ int cap_bprm_secureexec(struct linux_binprm *bprm)
105259 const struct cred *cred = current_cred();
105260 kuid_t root_uid = make_kuid(cred->user_ns, 0);
105261
105262 + if (gr_acl_enable_at_secure())
105263 + return 1;
105264 +
105265 if (!uid_eq(cred->uid, root_uid)) {
105266 if (bprm->cap_effective)
105267 return 1;
105268 diff --git a/security/integrity/ima/ima.h b/security/integrity/ima/ima.h
105269 index f79fa8b..6161868 100644
105270 --- a/security/integrity/ima/ima.h
105271 +++ b/security/integrity/ima/ima.h
105272 @@ -118,8 +118,8 @@ int ima_init_template(void);
105273 extern spinlock_t ima_queue_lock;
105274
105275 struct ima_h_table {
105276 - atomic_long_t len; /* number of stored measurements in the list */
105277 - atomic_long_t violations;
105278 + atomic_long_unchecked_t len; /* number of stored measurements in the list */
105279 + atomic_long_unchecked_t violations;
105280 struct hlist_head queue[IMA_MEASURE_HTABLE_SIZE];
105281 };
105282 extern struct ima_h_table ima_htable;
105283 diff --git a/security/integrity/ima/ima_api.c b/security/integrity/ima/ima_api.c
105284 index ba9e4d7..4b8ae03 100644
105285 --- a/security/integrity/ima/ima_api.c
105286 +++ b/security/integrity/ima/ima_api.c
105287 @@ -137,7 +137,7 @@ void ima_add_violation(struct file *file, const unsigned char *filename,
105288 int result;
105289
105290 /* can overflow, only indicator */
105291 - atomic_long_inc(&ima_htable.violations);
105292 + atomic_long_inc_unchecked(&ima_htable.violations);
105293
105294 result = ima_alloc_init_template(NULL, file, filename,
105295 NULL, 0, &entry);
105296 diff --git a/security/integrity/ima/ima_fs.c b/security/integrity/ima/ima_fs.c
105297 index da92fcc..8a5d390 100644
105298 --- a/security/integrity/ima/ima_fs.c
105299 +++ b/security/integrity/ima/ima_fs.c
105300 @@ -28,12 +28,12 @@
105301 static int valid_policy = 1;
105302 #define TMPBUFLEN 12
105303 static ssize_t ima_show_htable_value(char __user *buf, size_t count,
105304 - loff_t *ppos, atomic_long_t *val)
105305 + loff_t *ppos, atomic_long_unchecked_t *val)
105306 {
105307 char tmpbuf[TMPBUFLEN];
105308 ssize_t len;
105309
105310 - len = scnprintf(tmpbuf, TMPBUFLEN, "%li\n", atomic_long_read(val));
105311 + len = scnprintf(tmpbuf, TMPBUFLEN, "%li\n", atomic_long_read_unchecked(val));
105312 return simple_read_from_buffer(buf, count, ppos, tmpbuf, len);
105313 }
105314
105315 diff --git a/security/integrity/ima/ima_queue.c b/security/integrity/ima/ima_queue.c
105316 index 552705d..9920f4fb 100644
105317 --- a/security/integrity/ima/ima_queue.c
105318 +++ b/security/integrity/ima/ima_queue.c
105319 @@ -83,7 +83,7 @@ static int ima_add_digest_entry(struct ima_template_entry *entry)
105320 INIT_LIST_HEAD(&qe->later);
105321 list_add_tail_rcu(&qe->later, &ima_measurements);
105322
105323 - atomic_long_inc(&ima_htable.len);
105324 + atomic_long_inc_unchecked(&ima_htable.len);
105325 key = ima_hash_key(entry->digest);
105326 hlist_add_head_rcu(&qe->hnext, &ima_htable.queue[key]);
105327 return 0;
105328 diff --git a/security/keys/compat.c b/security/keys/compat.c
105329 index 3478965..ec7bb9e 100644
105330 --- a/security/keys/compat.c
105331 +++ b/security/keys/compat.c
105332 @@ -44,7 +44,7 @@ static long compat_keyctl_instantiate_key_iov(
105333 if (ret == 0)
105334 goto no_payload_free;
105335
105336 - ret = keyctl_instantiate_key_common(id, iov, ioc, ret, ringid);
105337 + ret = keyctl_instantiate_key_common(id, (const struct iovec __force_user *)iov, ioc, ret, ringid);
105338 err:
105339 if (iov != iovstack)
105340 kfree(iov);
105341 diff --git a/security/keys/internal.h b/security/keys/internal.h
105342 index 80b2aac..bb7ee65 100644
105343 --- a/security/keys/internal.h
105344 +++ b/security/keys/internal.h
105345 @@ -253,7 +253,7 @@ extern long keyctl_instantiate_key_iov(key_serial_t,
105346 extern long keyctl_invalidate_key(key_serial_t);
105347
105348 extern long keyctl_instantiate_key_common(key_serial_t,
105349 - const struct iovec *,
105350 + const struct iovec __user *,
105351 unsigned, size_t, key_serial_t);
105352 #ifdef CONFIG_PERSISTENT_KEYRINGS
105353 extern long keyctl_get_persistent(uid_t, key_serial_t);
105354 diff --git a/security/keys/key.c b/security/keys/key.c
105355 index 6e21c11..9ed67ca 100644
105356 --- a/security/keys/key.c
105357 +++ b/security/keys/key.c
105358 @@ -285,7 +285,7 @@ struct key *key_alloc(struct key_type *type, const char *desc,
105359
105360 atomic_set(&key->usage, 1);
105361 init_rwsem(&key->sem);
105362 - lockdep_set_class(&key->sem, &type->lock_class);
105363 + lockdep_set_class(&key->sem, (struct lock_class_key *)&type->lock_class);
105364 key->index_key.type = type;
105365 key->user = user;
105366 key->quotalen = quotalen;
105367 @@ -1036,7 +1036,9 @@ int register_key_type(struct key_type *ktype)
105368 struct key_type *p;
105369 int ret;
105370
105371 - memset(&ktype->lock_class, 0, sizeof(ktype->lock_class));
105372 + pax_open_kernel();
105373 + memset((void *)&ktype->lock_class, 0, sizeof(ktype->lock_class));
105374 + pax_close_kernel();
105375
105376 ret = -EEXIST;
105377 down_write(&key_types_sem);
105378 @@ -1048,7 +1050,7 @@ int register_key_type(struct key_type *ktype)
105379 }
105380
105381 /* store the type */
105382 - list_add(&ktype->link, &key_types_list);
105383 + pax_list_add((struct list_head *)&ktype->link, &key_types_list);
105384
105385 pr_notice("Key type %s registered\n", ktype->name);
105386 ret = 0;
105387 @@ -1070,7 +1072,7 @@ EXPORT_SYMBOL(register_key_type);
105388 void unregister_key_type(struct key_type *ktype)
105389 {
105390 down_write(&key_types_sem);
105391 - list_del_init(&ktype->link);
105392 + pax_list_del_init((struct list_head *)&ktype->link);
105393 downgrade_write(&key_types_sem);
105394 key_gc_keytype(ktype);
105395 pr_notice("Key type %s unregistered\n", ktype->name);
105396 @@ -1088,10 +1090,10 @@ void __init key_init(void)
105397 0, SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
105398
105399 /* add the special key types */
105400 - list_add_tail(&key_type_keyring.link, &key_types_list);
105401 - list_add_tail(&key_type_dead.link, &key_types_list);
105402 - list_add_tail(&key_type_user.link, &key_types_list);
105403 - list_add_tail(&key_type_logon.link, &key_types_list);
105404 + pax_list_add_tail((struct list_head *)&key_type_keyring.link, &key_types_list);
105405 + pax_list_add_tail((struct list_head *)&key_type_dead.link, &key_types_list);
105406 + pax_list_add_tail((struct list_head *)&key_type_user.link, &key_types_list);
105407 + pax_list_add_tail((struct list_head *)&key_type_logon.link, &key_types_list);
105408
105409 /* record the root user tracking */
105410 rb_link_node(&root_key_user.node,
105411 diff --git a/security/keys/keyctl.c b/security/keys/keyctl.c
105412 index cee72ce..e46074a 100644
105413 --- a/security/keys/keyctl.c
105414 +++ b/security/keys/keyctl.c
105415 @@ -987,7 +987,7 @@ static int keyctl_change_reqkey_auth(struct key *key)
105416 /*
105417 * Copy the iovec data from userspace
105418 */
105419 -static long copy_from_user_iovec(void *buffer, const struct iovec *iov,
105420 +static long copy_from_user_iovec(void *buffer, const struct iovec __user *iov,
105421 unsigned ioc)
105422 {
105423 for (; ioc > 0; ioc--) {
105424 @@ -1009,7 +1009,7 @@ static long copy_from_user_iovec(void *buffer, const struct iovec *iov,
105425 * If successful, 0 will be returned.
105426 */
105427 long keyctl_instantiate_key_common(key_serial_t id,
105428 - const struct iovec *payload_iov,
105429 + const struct iovec __user *payload_iov,
105430 unsigned ioc,
105431 size_t plen,
105432 key_serial_t ringid)
105433 @@ -1104,7 +1104,7 @@ long keyctl_instantiate_key(key_serial_t id,
105434 [0].iov_len = plen
105435 };
105436
105437 - return keyctl_instantiate_key_common(id, iov, 1, plen, ringid);
105438 + return keyctl_instantiate_key_common(id, (const struct iovec __force_user *)iov, 1, plen, ringid);
105439 }
105440
105441 return keyctl_instantiate_key_common(id, NULL, 0, 0, ringid);
105442 @@ -1137,7 +1137,7 @@ long keyctl_instantiate_key_iov(key_serial_t id,
105443 if (ret == 0)
105444 goto no_payload_free;
105445
105446 - ret = keyctl_instantiate_key_common(id, iov, ioc, ret, ringid);
105447 + ret = keyctl_instantiate_key_common(id, (const struct iovec __force_user *)iov, ioc, ret, ringid);
105448 err:
105449 if (iov != iovstack)
105450 kfree(iov);
105451 diff --git a/security/min_addr.c b/security/min_addr.c
105452 index f728728..6457a0c 100644
105453 --- a/security/min_addr.c
105454 +++ b/security/min_addr.c
105455 @@ -14,6 +14,7 @@ unsigned long dac_mmap_min_addr = CONFIG_DEFAULT_MMAP_MIN_ADDR;
105456 */
105457 static void update_mmap_min_addr(void)
105458 {
105459 +#ifndef SPARC
105460 #ifdef CONFIG_LSM_MMAP_MIN_ADDR
105461 if (dac_mmap_min_addr > CONFIG_LSM_MMAP_MIN_ADDR)
105462 mmap_min_addr = dac_mmap_min_addr;
105463 @@ -22,6 +23,7 @@ static void update_mmap_min_addr(void)
105464 #else
105465 mmap_min_addr = dac_mmap_min_addr;
105466 #endif
105467 +#endif
105468 }
105469
105470 /*
105471 diff --git a/security/security.c b/security/security.c
105472 index 8b774f3..a396233 100644
105473 --- a/security/security.c
105474 +++ b/security/security.c
105475 @@ -33,8 +33,8 @@
105476 static __initdata char chosen_lsm[SECURITY_NAME_MAX + 1] =
105477 CONFIG_DEFAULT_SECURITY;
105478
105479 -static struct security_operations *security_ops;
105480 -static struct security_operations default_security_ops = {
105481 +struct security_operations *security_ops __read_only;
105482 +struct security_operations default_security_ops __read_only = {
105483 .name = "default",
105484 };
105485
105486 @@ -73,11 +73,6 @@ int __init security_init(void)
105487 return 0;
105488 }
105489
105490 -void reset_security_ops(void)
105491 -{
105492 - security_ops = &default_security_ops;
105493 -}
105494 -
105495 /* Save user chosen LSM */
105496 static int __init choose_lsm(char *str)
105497 {
105498 diff --git a/security/selinux/avc.c b/security/selinux/avc.c
105499 index fc3e662..7844c60 100644
105500 --- a/security/selinux/avc.c
105501 +++ b/security/selinux/avc.c
105502 @@ -59,7 +59,7 @@ struct avc_node {
105503 struct avc_cache {
105504 struct hlist_head slots[AVC_CACHE_SLOTS]; /* head for avc_node->list */
105505 spinlock_t slots_lock[AVC_CACHE_SLOTS]; /* lock for writes */
105506 - atomic_t lru_hint; /* LRU hint for reclaim scan */
105507 + atomic_unchecked_t lru_hint; /* LRU hint for reclaim scan */
105508 atomic_t active_nodes;
105509 u32 latest_notif; /* latest revocation notification */
105510 };
105511 @@ -167,7 +167,7 @@ void __init avc_init(void)
105512 spin_lock_init(&avc_cache.slots_lock[i]);
105513 }
105514 atomic_set(&avc_cache.active_nodes, 0);
105515 - atomic_set(&avc_cache.lru_hint, 0);
105516 + atomic_set_unchecked(&avc_cache.lru_hint, 0);
105517
105518 avc_node_cachep = kmem_cache_create("avc_node", sizeof(struct avc_node),
105519 0, SLAB_PANIC, NULL);
105520 @@ -242,7 +242,7 @@ static inline int avc_reclaim_node(void)
105521 spinlock_t *lock;
105522
105523 for (try = 0, ecx = 0; try < AVC_CACHE_SLOTS; try++) {
105524 - hvalue = atomic_inc_return(&avc_cache.lru_hint) & (AVC_CACHE_SLOTS - 1);
105525 + hvalue = atomic_inc_return_unchecked(&avc_cache.lru_hint) & (AVC_CACHE_SLOTS - 1);
105526 head = &avc_cache.slots[hvalue];
105527 lock = &avc_cache.slots_lock[hvalue];
105528
105529 diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
105530 index 2c7341d..1da068e 100644
105531 --- a/security/selinux/hooks.c
105532 +++ b/security/selinux/hooks.c
105533 @@ -95,8 +95,6 @@
105534 #include "audit.h"
105535 #include "avc_ss.h"
105536
105537 -extern struct security_operations *security_ops;
105538 -
105539 /* SECMARK reference count */
105540 static atomic_t selinux_secmark_refcount = ATOMIC_INIT(0);
105541
105542 @@ -5758,7 +5756,7 @@ static int selinux_key_getsecurity(struct key *key, char **_buffer)
105543
105544 #endif
105545
105546 -static struct security_operations selinux_ops = {
105547 +static struct security_operations selinux_ops __read_only = {
105548 .name = "selinux",
105549
105550 .ptrace_access_check = selinux_ptrace_access_check,
105551 @@ -6111,6 +6109,9 @@ static void selinux_nf_ip_exit(void)
105552 #ifdef CONFIG_SECURITY_SELINUX_DISABLE
105553 static int selinux_disabled;
105554
105555 +extern struct security_operations *security_ops;
105556 +extern struct security_operations default_security_ops;
105557 +
105558 int selinux_disable(void)
105559 {
105560 if (ss_initialized) {
105561 @@ -6128,7 +6129,9 @@ int selinux_disable(void)
105562 selinux_disabled = 1;
105563 selinux_enabled = 0;
105564
105565 - reset_security_ops();
105566 + pax_open_kernel();
105567 + security_ops = &default_security_ops;
105568 + pax_close_kernel();
105569
105570 /* Try to destroy the avc node cache */
105571 avc_disable();
105572 diff --git a/security/selinux/include/xfrm.h b/security/selinux/include/xfrm.h
105573 index 1450f85..a91e0bc 100644
105574 --- a/security/selinux/include/xfrm.h
105575 +++ b/security/selinux/include/xfrm.h
105576 @@ -48,7 +48,7 @@ static inline void selinux_xfrm_notify_policyload(void)
105577
105578 rtnl_lock();
105579 for_each_net(net) {
105580 - atomic_inc(&net->xfrm.flow_cache_genid);
105581 + atomic_inc_unchecked(&net->xfrm.flow_cache_genid);
105582 rt_genid_bump_all(net);
105583 }
105584 rtnl_unlock();
105585 diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c
105586 index 14f52be..7352368 100644
105587 --- a/security/smack/smack_lsm.c
105588 +++ b/security/smack/smack_lsm.c
105589 @@ -3726,7 +3726,7 @@ static int smack_inode_getsecctx(struct inode *inode, void **ctx, u32 *ctxlen)
105590 return 0;
105591 }
105592
105593 -struct security_operations smack_ops = {
105594 +struct security_operations smack_ops __read_only = {
105595 .name = "smack",
105596
105597 .ptrace_access_check = smack_ptrace_access_check,
105598 diff --git a/security/tomoyo/file.c b/security/tomoyo/file.c
105599 index 4003907..13a2b55 100644
105600 --- a/security/tomoyo/file.c
105601 +++ b/security/tomoyo/file.c
105602 @@ -692,7 +692,7 @@ int tomoyo_path_number_perm(const u8 type, struct path *path,
105603 {
105604 struct tomoyo_request_info r;
105605 struct tomoyo_obj_info obj = {
105606 - .path1 = *path,
105607 + .path1 = { .mnt = path->mnt, .dentry = path->dentry },
105608 };
105609 int error = -ENOMEM;
105610 struct tomoyo_path_info buf;
105611 @@ -740,7 +740,7 @@ int tomoyo_check_open_permission(struct tomoyo_domain_info *domain,
105612 struct tomoyo_path_info buf;
105613 struct tomoyo_request_info r;
105614 struct tomoyo_obj_info obj = {
105615 - .path1 = *path,
105616 + .path1 = { .mnt = path->mnt, .dentry = path->dentry },
105617 };
105618 int idx;
105619
105620 @@ -786,7 +786,7 @@ int tomoyo_path_perm(const u8 operation, struct path *path, const char *target)
105621 {
105622 struct tomoyo_request_info r;
105623 struct tomoyo_obj_info obj = {
105624 - .path1 = *path,
105625 + .path1 = { .mnt = path->mnt, .dentry = path->dentry },
105626 };
105627 int error;
105628 struct tomoyo_path_info buf;
105629 @@ -843,7 +843,7 @@ int tomoyo_mkdev_perm(const u8 operation, struct path *path,
105630 {
105631 struct tomoyo_request_info r;
105632 struct tomoyo_obj_info obj = {
105633 - .path1 = *path,
105634 + .path1 = { .mnt = path->mnt, .dentry = path->dentry },
105635 };
105636 int error = -ENOMEM;
105637 struct tomoyo_path_info buf;
105638 @@ -890,8 +890,8 @@ int tomoyo_path2_perm(const u8 operation, struct path *path1,
105639 struct tomoyo_path_info buf2;
105640 struct tomoyo_request_info r;
105641 struct tomoyo_obj_info obj = {
105642 - .path1 = *path1,
105643 - .path2 = *path2,
105644 + .path1 = { .mnt = path1->mnt, .dentry = path1->dentry },
105645 + .path2 = { .mnt = path2->mnt, .dentry = path2->dentry }
105646 };
105647 int idx;
105648
105649 diff --git a/security/tomoyo/mount.c b/security/tomoyo/mount.c
105650 index 390c646..f2f8db3 100644
105651 --- a/security/tomoyo/mount.c
105652 +++ b/security/tomoyo/mount.c
105653 @@ -118,6 +118,10 @@ static int tomoyo_mount_acl(struct tomoyo_request_info *r,
105654 type == tomoyo_mounts[TOMOYO_MOUNT_MOVE]) {
105655 need_dev = -1; /* dev_name is a directory */
105656 } else {
105657 + if (!capable(CAP_SYS_ADMIN)) {
105658 + error = -EPERM;
105659 + goto out;
105660 + }
105661 fstype = get_fs_type(type);
105662 if (!fstype) {
105663 error = -ENODEV;
105664 diff --git a/security/tomoyo/tomoyo.c b/security/tomoyo/tomoyo.c
105665 index f0b756e..8aa497b 100644
105666 --- a/security/tomoyo/tomoyo.c
105667 +++ b/security/tomoyo/tomoyo.c
105668 @@ -146,7 +146,7 @@ static int tomoyo_bprm_check_security(struct linux_binprm *bprm)
105669 */
105670 static int tomoyo_inode_getattr(struct vfsmount *mnt, struct dentry *dentry)
105671 {
105672 - struct path path = { mnt, dentry };
105673 + struct path path = { .mnt = mnt, .dentry = dentry };
105674 return tomoyo_path_perm(TOMOYO_TYPE_GETATTR, &path, NULL);
105675 }
105676
105677 @@ -172,7 +172,7 @@ static int tomoyo_path_truncate(struct path *path)
105678 */
105679 static int tomoyo_path_unlink(struct path *parent, struct dentry *dentry)
105680 {
105681 - struct path path = { parent->mnt, dentry };
105682 + struct path path = { .mnt = parent->mnt, .dentry = dentry };
105683 return tomoyo_path_perm(TOMOYO_TYPE_UNLINK, &path, NULL);
105684 }
105685
105686 @@ -188,7 +188,7 @@ static int tomoyo_path_unlink(struct path *parent, struct dentry *dentry)
105687 static int tomoyo_path_mkdir(struct path *parent, struct dentry *dentry,
105688 umode_t mode)
105689 {
105690 - struct path path = { parent->mnt, dentry };
105691 + struct path path = { .mnt = parent->mnt, .dentry = dentry };
105692 return tomoyo_path_number_perm(TOMOYO_TYPE_MKDIR, &path,
105693 mode & S_IALLUGO);
105694 }
105695 @@ -203,7 +203,7 @@ static int tomoyo_path_mkdir(struct path *parent, struct dentry *dentry,
105696 */
105697 static int tomoyo_path_rmdir(struct path *parent, struct dentry *dentry)
105698 {
105699 - struct path path = { parent->mnt, dentry };
105700 + struct path path = { .mnt = parent->mnt, .dentry = dentry };
105701 return tomoyo_path_perm(TOMOYO_TYPE_RMDIR, &path, NULL);
105702 }
105703
105704 @@ -219,7 +219,7 @@ static int tomoyo_path_rmdir(struct path *parent, struct dentry *dentry)
105705 static int tomoyo_path_symlink(struct path *parent, struct dentry *dentry,
105706 const char *old_name)
105707 {
105708 - struct path path = { parent->mnt, dentry };
105709 + struct path path = { .mnt = parent->mnt, .dentry = dentry };
105710 return tomoyo_path_perm(TOMOYO_TYPE_SYMLINK, &path, old_name);
105711 }
105712
105713 @@ -236,7 +236,7 @@ static int tomoyo_path_symlink(struct path *parent, struct dentry *dentry,
105714 static int tomoyo_path_mknod(struct path *parent, struct dentry *dentry,
105715 umode_t mode, unsigned int dev)
105716 {
105717 - struct path path = { parent->mnt, dentry };
105718 + struct path path = { .mnt = parent->mnt, .dentry = dentry };
105719 int type = TOMOYO_TYPE_CREATE;
105720 const unsigned int perm = mode & S_IALLUGO;
105721
105722 @@ -275,8 +275,8 @@ static int tomoyo_path_mknod(struct path *parent, struct dentry *dentry,
105723 static int tomoyo_path_link(struct dentry *old_dentry, struct path *new_dir,
105724 struct dentry *new_dentry)
105725 {
105726 - struct path path1 = { new_dir->mnt, old_dentry };
105727 - struct path path2 = { new_dir->mnt, new_dentry };
105728 + struct path path1 = { .mnt = new_dir->mnt, .dentry = old_dentry };
105729 + struct path path2 = { .mnt = new_dir->mnt, .dentry = new_dentry };
105730 return tomoyo_path2_perm(TOMOYO_TYPE_LINK, &path1, &path2);
105731 }
105732
105733 @@ -295,8 +295,8 @@ static int tomoyo_path_rename(struct path *old_parent,
105734 struct path *new_parent,
105735 struct dentry *new_dentry)
105736 {
105737 - struct path path1 = { old_parent->mnt, old_dentry };
105738 - struct path path2 = { new_parent->mnt, new_dentry };
105739 + struct path path1 = { .mnt = old_parent->mnt, .dentry = old_dentry };
105740 + struct path path2 = { .mnt = new_parent->mnt, .dentry = new_dentry };
105741 return tomoyo_path2_perm(TOMOYO_TYPE_RENAME, &path1, &path2);
105742 }
105743
105744 @@ -424,7 +424,7 @@ static int tomoyo_sb_mount(const char *dev_name, struct path *path,
105745 */
105746 static int tomoyo_sb_umount(struct vfsmount *mnt, int flags)
105747 {
105748 - struct path path = { mnt, mnt->mnt_root };
105749 + struct path path = { .mnt = mnt, .dentry = mnt->mnt_root };
105750 return tomoyo_path_perm(TOMOYO_TYPE_UMOUNT, &path, NULL);
105751 }
105752
105753 @@ -503,7 +503,7 @@ static int tomoyo_socket_sendmsg(struct socket *sock, struct msghdr *msg,
105754 * tomoyo_security_ops is a "struct security_operations" which is used for
105755 * registering TOMOYO.
105756 */
105757 -static struct security_operations tomoyo_security_ops = {
105758 +static struct security_operations tomoyo_security_ops __read_only = {
105759 .name = "tomoyo",
105760 .cred_alloc_blank = tomoyo_cred_alloc_blank,
105761 .cred_prepare = tomoyo_cred_prepare,
105762 diff --git a/security/yama/Kconfig b/security/yama/Kconfig
105763 index 20ef514..4182bed 100644
105764 --- a/security/yama/Kconfig
105765 +++ b/security/yama/Kconfig
105766 @@ -1,6 +1,6 @@
105767 config SECURITY_YAMA
105768 bool "Yama support"
105769 - depends on SECURITY
105770 + depends on SECURITY && !GRKERNSEC
105771 select SECURITYFS
105772 select SECURITY_PATH
105773 default n
105774 diff --git a/security/yama/yama_lsm.c b/security/yama/yama_lsm.c
105775 index 13c88fbc..f8c115e 100644
105776 --- a/security/yama/yama_lsm.c
105777 +++ b/security/yama/yama_lsm.c
105778 @@ -365,7 +365,7 @@ int yama_ptrace_traceme(struct task_struct *parent)
105779 }
105780
105781 #ifndef CONFIG_SECURITY_YAMA_STACKED
105782 -static struct security_operations yama_ops = {
105783 +static struct security_operations yama_ops __read_only = {
105784 .name = "yama",
105785
105786 .ptrace_access_check = yama_ptrace_access_check,
105787 @@ -376,28 +376,24 @@ static struct security_operations yama_ops = {
105788 #endif
105789
105790 #ifdef CONFIG_SYSCTL
105791 +static int zero __read_only;
105792 +static int max_scope __read_only = YAMA_SCOPE_NO_ATTACH;
105793 +
105794 static int yama_dointvec_minmax(struct ctl_table *table, int write,
105795 void __user *buffer, size_t *lenp, loff_t *ppos)
105796 {
105797 - int rc;
105798 + ctl_table_no_const yama_table;
105799
105800 if (write && !capable(CAP_SYS_PTRACE))
105801 return -EPERM;
105802
105803 - rc = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
105804 - if (rc)
105805 - return rc;
105806 -
105807 + yama_table = *table;
105808 /* Lock the max value if it ever gets set. */
105809 - if (write && *(int *)table->data == *(int *)table->extra2)
105810 - table->extra1 = table->extra2;
105811 -
105812 - return rc;
105813 + if (ptrace_scope == max_scope)
105814 + yama_table.extra1 = &max_scope;
105815 + return proc_dointvec_minmax(&yama_table, write, buffer, lenp, ppos);
105816 }
105817
105818 -static int zero;
105819 -static int max_scope = YAMA_SCOPE_NO_ATTACH;
105820 -
105821 struct ctl_path yama_sysctl_path[] = {
105822 { .procname = "kernel", },
105823 { .procname = "yama", },
105824 diff --git a/sound/aoa/codecs/onyx.c b/sound/aoa/codecs/onyx.c
105825 index f01bffb..bdda392 100644
105826 --- a/sound/aoa/codecs/onyx.c
105827 +++ b/sound/aoa/codecs/onyx.c
105828 @@ -54,7 +54,7 @@ struct onyx {
105829 spdif_locked:1,
105830 analog_locked:1,
105831 original_mute:2;
105832 - int open_count;
105833 + local_t open_count;
105834 struct codec_info *codec_info;
105835
105836 /* mutex serializes concurrent access to the device
105837 @@ -753,7 +753,7 @@ static int onyx_open(struct codec_info_item *cii,
105838 struct onyx *onyx = cii->codec_data;
105839
105840 mutex_lock(&onyx->mutex);
105841 - onyx->open_count++;
105842 + local_inc(&onyx->open_count);
105843 mutex_unlock(&onyx->mutex);
105844
105845 return 0;
105846 @@ -765,8 +765,7 @@ static int onyx_close(struct codec_info_item *cii,
105847 struct onyx *onyx = cii->codec_data;
105848
105849 mutex_lock(&onyx->mutex);
105850 - onyx->open_count--;
105851 - if (!onyx->open_count)
105852 + if (local_dec_and_test(&onyx->open_count))
105853 onyx->spdif_locked = onyx->analog_locked = 0;
105854 mutex_unlock(&onyx->mutex);
105855
105856 diff --git a/sound/aoa/codecs/onyx.h b/sound/aoa/codecs/onyx.h
105857 index ffd2025..df062c9 100644
105858 --- a/sound/aoa/codecs/onyx.h
105859 +++ b/sound/aoa/codecs/onyx.h
105860 @@ -11,6 +11,7 @@
105861 #include <linux/i2c.h>
105862 #include <asm/pmac_low_i2c.h>
105863 #include <asm/prom.h>
105864 +#include <asm/local.h>
105865
105866 /* PCM3052 register definitions */
105867
105868 diff --git a/sound/core/oss/pcm_oss.c b/sound/core/oss/pcm_oss.c
105869 index ada69d7..5f65386 100644
105870 --- a/sound/core/oss/pcm_oss.c
105871 +++ b/sound/core/oss/pcm_oss.c
105872 @@ -1190,10 +1190,10 @@ snd_pcm_sframes_t snd_pcm_oss_write3(struct snd_pcm_substream *substream, const
105873 if (in_kernel) {
105874 mm_segment_t fs;
105875 fs = snd_enter_user();
105876 - ret = snd_pcm_lib_write(substream, (void __force __user *)ptr, frames);
105877 + ret = snd_pcm_lib_write(substream, (void __force_user *)ptr, frames);
105878 snd_leave_user(fs);
105879 } else {
105880 - ret = snd_pcm_lib_write(substream, (void __force __user *)ptr, frames);
105881 + ret = snd_pcm_lib_write(substream, (void __force_user *)ptr, frames);
105882 }
105883 if (ret != -EPIPE && ret != -ESTRPIPE)
105884 break;
105885 @@ -1233,10 +1233,10 @@ snd_pcm_sframes_t snd_pcm_oss_read3(struct snd_pcm_substream *substream, char *p
105886 if (in_kernel) {
105887 mm_segment_t fs;
105888 fs = snd_enter_user();
105889 - ret = snd_pcm_lib_read(substream, (void __force __user *)ptr, frames);
105890 + ret = snd_pcm_lib_read(substream, (void __force_user *)ptr, frames);
105891 snd_leave_user(fs);
105892 } else {
105893 - ret = snd_pcm_lib_read(substream, (void __force __user *)ptr, frames);
105894 + ret = snd_pcm_lib_read(substream, (void __force_user *)ptr, frames);
105895 }
105896 if (ret == -EPIPE) {
105897 if (runtime->status->state == SNDRV_PCM_STATE_DRAINING) {
105898 @@ -1332,7 +1332,7 @@ static ssize_t snd_pcm_oss_write2(struct snd_pcm_substream *substream, const cha
105899 struct snd_pcm_plugin_channel *channels;
105900 size_t oss_frame_bytes = (runtime->oss.plugin_first->src_width * runtime->oss.plugin_first->src_format.channels) / 8;
105901 if (!in_kernel) {
105902 - if (copy_from_user(runtime->oss.buffer, (const char __force __user *)buf, bytes))
105903 + if (copy_from_user(runtime->oss.buffer, (const char __force_user *)buf, bytes))
105904 return -EFAULT;
105905 buf = runtime->oss.buffer;
105906 }
105907 @@ -1402,7 +1402,7 @@ static ssize_t snd_pcm_oss_write1(struct snd_pcm_substream *substream, const cha
105908 }
105909 } else {
105910 tmp = snd_pcm_oss_write2(substream,
105911 - (const char __force *)buf,
105912 + (const char __force_kernel *)buf,
105913 runtime->oss.period_bytes, 0);
105914 if (tmp <= 0)
105915 goto err;
105916 @@ -1428,7 +1428,7 @@ static ssize_t snd_pcm_oss_read2(struct snd_pcm_substream *substream, char *buf,
105917 struct snd_pcm_runtime *runtime = substream->runtime;
105918 snd_pcm_sframes_t frames, frames1;
105919 #ifdef CONFIG_SND_PCM_OSS_PLUGINS
105920 - char __user *final_dst = (char __force __user *)buf;
105921 + char __user *final_dst = (char __force_user *)buf;
105922 if (runtime->oss.plugin_first) {
105923 struct snd_pcm_plugin_channel *channels;
105924 size_t oss_frame_bytes = (runtime->oss.plugin_last->dst_width * runtime->oss.plugin_last->dst_format.channels) / 8;
105925 @@ -1490,7 +1490,7 @@ static ssize_t snd_pcm_oss_read1(struct snd_pcm_substream *substream, char __use
105926 xfer += tmp;
105927 runtime->oss.buffer_used -= tmp;
105928 } else {
105929 - tmp = snd_pcm_oss_read2(substream, (char __force *)buf,
105930 + tmp = snd_pcm_oss_read2(substream, (char __force_kernel *)buf,
105931 runtime->oss.period_bytes, 0);
105932 if (tmp <= 0)
105933 goto err;
105934 @@ -1659,7 +1659,7 @@ static int snd_pcm_oss_sync(struct snd_pcm_oss_file *pcm_oss_file)
105935 size1);
105936 size1 /= runtime->channels; /* frames */
105937 fs = snd_enter_user();
105938 - snd_pcm_lib_write(substream, (void __force __user *)runtime->oss.buffer, size1);
105939 + snd_pcm_lib_write(substream, (void __force_user *)runtime->oss.buffer, size1);
105940 snd_leave_user(fs);
105941 }
105942 } else if (runtime->access == SNDRV_PCM_ACCESS_RW_NONINTERLEAVED) {
105943 diff --git a/sound/core/pcm_compat.c b/sound/core/pcm_compat.c
105944 index af49721..e85058e 100644
105945 --- a/sound/core/pcm_compat.c
105946 +++ b/sound/core/pcm_compat.c
105947 @@ -31,7 +31,7 @@ static int snd_pcm_ioctl_delay_compat(struct snd_pcm_substream *substream,
105948 int err;
105949
105950 fs = snd_enter_user();
105951 - err = snd_pcm_delay(substream, &delay);
105952 + err = snd_pcm_delay(substream, (snd_pcm_sframes_t __force_user *)&delay);
105953 snd_leave_user(fs);
105954 if (err < 0)
105955 return err;
105956 diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c
105957 index b653ab0..a4738e3 100644
105958 --- a/sound/core/pcm_native.c
105959 +++ b/sound/core/pcm_native.c
105960 @@ -2812,11 +2812,11 @@ int snd_pcm_kernel_ioctl(struct snd_pcm_substream *substream,
105961 switch (substream->stream) {
105962 case SNDRV_PCM_STREAM_PLAYBACK:
105963 result = snd_pcm_playback_ioctl1(NULL, substream, cmd,
105964 - (void __user *)arg);
105965 + (void __force_user *)arg);
105966 break;
105967 case SNDRV_PCM_STREAM_CAPTURE:
105968 result = snd_pcm_capture_ioctl1(NULL, substream, cmd,
105969 - (void __user *)arg);
105970 + (void __force_user *)arg);
105971 break;
105972 default:
105973 result = -EINVAL;
105974 diff --git a/sound/core/seq/oss/seq_oss.c b/sound/core/seq/oss/seq_oss.c
105975 index 16d4267..fe8b49b 100644
105976 --- a/sound/core/seq/oss/seq_oss.c
105977 +++ b/sound/core/seq/oss/seq_oss.c
105978 @@ -69,8 +69,8 @@ static int __init alsa_seq_oss_init(void)
105979 {
105980 int rc;
105981 static struct snd_seq_dev_ops ops = {
105982 - snd_seq_oss_synth_register,
105983 - snd_seq_oss_synth_unregister,
105984 + .init_device = snd_seq_oss_synth_register,
105985 + .free_device = snd_seq_oss_synth_unregister,
105986 };
105987
105988 snd_seq_autoload_lock();
105989 diff --git a/sound/core/seq/seq_device.c b/sound/core/seq/seq_device.c
105990 index 91a786a..4c07ed4 100644
105991 --- a/sound/core/seq/seq_device.c
105992 +++ b/sound/core/seq/seq_device.c
105993 @@ -64,7 +64,7 @@ struct ops_list {
105994 int argsize; /* argument size */
105995
105996 /* operators */
105997 - struct snd_seq_dev_ops ops;
105998 + struct snd_seq_dev_ops *ops;
105999
106000 /* registered devices */
106001 struct list_head dev_list; /* list of devices */
106002 @@ -333,7 +333,7 @@ int snd_seq_device_register_driver(char *id, struct snd_seq_dev_ops *entry,
106003
106004 mutex_lock(&ops->reg_mutex);
106005 /* copy driver operators */
106006 - ops->ops = *entry;
106007 + ops->ops = entry;
106008 ops->driver |= DRIVER_LOADED;
106009 ops->argsize = argsize;
106010
106011 @@ -463,7 +463,7 @@ static int init_device(struct snd_seq_device *dev, struct ops_list *ops)
106012 dev->name, ops->id, ops->argsize, dev->argsize);
106013 return -EINVAL;
106014 }
106015 - if (ops->ops.init_device(dev) >= 0) {
106016 + if (ops->ops->init_device(dev) >= 0) {
106017 dev->status = SNDRV_SEQ_DEVICE_REGISTERED;
106018 ops->num_init_devices++;
106019 } else {
106020 @@ -490,7 +490,7 @@ static int free_device(struct snd_seq_device *dev, struct ops_list *ops)
106021 dev->name, ops->id, ops->argsize, dev->argsize);
106022 return -EINVAL;
106023 }
106024 - if ((result = ops->ops.free_device(dev)) >= 0 || result == -ENXIO) {
106025 + if ((result = ops->ops->free_device(dev)) >= 0 || result == -ENXIO) {
106026 dev->status = SNDRV_SEQ_DEVICE_FREE;
106027 dev->driver_data = NULL;
106028 ops->num_init_devices--;
106029 diff --git a/sound/core/seq/seq_midi.c b/sound/core/seq/seq_midi.c
106030 index 3e05c55..0f02efc 100644
106031 --- a/sound/core/seq/seq_midi.c
106032 +++ b/sound/core/seq/seq_midi.c
106033 @@ -462,8 +462,8 @@ snd_seq_midisynth_unregister_port(struct snd_seq_device *dev)
106034 static int __init alsa_seq_midi_init(void)
106035 {
106036 static struct snd_seq_dev_ops ops = {
106037 - snd_seq_midisynth_register_port,
106038 - snd_seq_midisynth_unregister_port,
106039 + .init_device = snd_seq_midisynth_register_port,
106040 + .free_device = snd_seq_midisynth_unregister_port,
106041 };
106042 memset(&synths, 0, sizeof(synths));
106043 snd_seq_autoload_lock();
106044 diff --git a/sound/core/sound.c b/sound/core/sound.c
106045 index 38ad1a0..5010a40 100644
106046 --- a/sound/core/sound.c
106047 +++ b/sound/core/sound.c
106048 @@ -86,7 +86,7 @@ static void snd_request_other(int minor)
106049 case SNDRV_MINOR_TIMER: str = "snd-timer"; break;
106050 default: return;
106051 }
106052 - request_module(str);
106053 + request_module("%s", str);
106054 }
106055
106056 #endif /* modular kernel */
106057 diff --git a/sound/drivers/mts64.c b/sound/drivers/mts64.c
106058 index f5fd448..6ae276da 100644
106059 --- a/sound/drivers/mts64.c
106060 +++ b/sound/drivers/mts64.c
106061 @@ -29,6 +29,7 @@
106062 #include <sound/initval.h>
106063 #include <sound/rawmidi.h>
106064 #include <sound/control.h>
106065 +#include <asm/local.h>
106066
106067 #define CARD_NAME "Miditerminal 4140"
106068 #define DRIVER_NAME "MTS64"
106069 @@ -67,7 +68,7 @@ struct mts64 {
106070 struct pardevice *pardev;
106071 int pardev_claimed;
106072
106073 - int open_count;
106074 + local_t open_count;
106075 int current_midi_output_port;
106076 int current_midi_input_port;
106077 u8 mode[MTS64_NUM_INPUT_PORTS];
106078 @@ -697,7 +698,7 @@ static int snd_mts64_rawmidi_open(struct snd_rawmidi_substream *substream)
106079 {
106080 struct mts64 *mts = substream->rmidi->private_data;
106081
106082 - if (mts->open_count == 0) {
106083 + if (local_read(&mts->open_count) == 0) {
106084 /* We don't need a spinlock here, because this is just called
106085 if the device has not been opened before.
106086 So there aren't any IRQs from the device */
106087 @@ -705,7 +706,7 @@ static int snd_mts64_rawmidi_open(struct snd_rawmidi_substream *substream)
106088
106089 msleep(50);
106090 }
106091 - ++(mts->open_count);
106092 + local_inc(&mts->open_count);
106093
106094 return 0;
106095 }
106096 @@ -715,8 +716,7 @@ static int snd_mts64_rawmidi_close(struct snd_rawmidi_substream *substream)
106097 struct mts64 *mts = substream->rmidi->private_data;
106098 unsigned long flags;
106099
106100 - --(mts->open_count);
106101 - if (mts->open_count == 0) {
106102 + if (local_dec_return(&mts->open_count) == 0) {
106103 /* We need the spinlock_irqsave here because we can still
106104 have IRQs at this point */
106105 spin_lock_irqsave(&mts->lock, flags);
106106 @@ -725,8 +725,8 @@ static int snd_mts64_rawmidi_close(struct snd_rawmidi_substream *substream)
106107
106108 msleep(500);
106109
106110 - } else if (mts->open_count < 0)
106111 - mts->open_count = 0;
106112 + } else if (local_read(&mts->open_count) < 0)
106113 + local_set(&mts->open_count, 0);
106114
106115 return 0;
106116 }
106117 diff --git a/sound/drivers/opl3/opl3_seq.c b/sound/drivers/opl3/opl3_seq.c
106118 index 6839953..7a0f4b9 100644
106119 --- a/sound/drivers/opl3/opl3_seq.c
106120 +++ b/sound/drivers/opl3/opl3_seq.c
106121 @@ -281,8 +281,8 @@ static int __init alsa_opl3_seq_init(void)
106122 {
106123 static struct snd_seq_dev_ops ops =
106124 {
106125 - snd_opl3_seq_new_device,
106126 - snd_opl3_seq_delete_device
106127 + .init_device = snd_opl3_seq_new_device,
106128 + .free_device = snd_opl3_seq_delete_device
106129 };
106130
106131 return snd_seq_device_register_driver(SNDRV_SEQ_DEV_ID_OPL3, &ops,
106132 diff --git a/sound/drivers/opl4/opl4_lib.c b/sound/drivers/opl4/opl4_lib.c
106133 index b953fb4..1999c01 100644
106134 --- a/sound/drivers/opl4/opl4_lib.c
106135 +++ b/sound/drivers/opl4/opl4_lib.c
106136 @@ -29,7 +29,7 @@ MODULE_AUTHOR("Clemens Ladisch <clemens@ladisch.de>");
106137 MODULE_DESCRIPTION("OPL4 driver");
106138 MODULE_LICENSE("GPL");
106139
106140 -static void inline snd_opl4_wait(struct snd_opl4 *opl4)
106141 +static inline void snd_opl4_wait(struct snd_opl4 *opl4)
106142 {
106143 int timeout = 10;
106144 while ((inb(opl4->fm_port) & OPL4_STATUS_BUSY) && --timeout > 0)
106145 diff --git a/sound/drivers/opl4/opl4_seq.c b/sound/drivers/opl4/opl4_seq.c
106146 index 9919769..d7de36c 100644
106147 --- a/sound/drivers/opl4/opl4_seq.c
106148 +++ b/sound/drivers/opl4/opl4_seq.c
106149 @@ -198,8 +198,8 @@ static int snd_opl4_seq_delete_device(struct snd_seq_device *dev)
106150 static int __init alsa_opl4_synth_init(void)
106151 {
106152 static struct snd_seq_dev_ops ops = {
106153 - snd_opl4_seq_new_device,
106154 - snd_opl4_seq_delete_device
106155 + .init_device = snd_opl4_seq_new_device,
106156 + .free_device = snd_opl4_seq_delete_device
106157 };
106158
106159 return snd_seq_device_register_driver(SNDRV_SEQ_DEV_ID_OPL4, &ops,
106160 diff --git a/sound/drivers/portman2x4.c b/sound/drivers/portman2x4.c
106161 index 78ccfa4..7a0857b 100644
106162 --- a/sound/drivers/portman2x4.c
106163 +++ b/sound/drivers/portman2x4.c
106164 @@ -48,6 +48,7 @@
106165 #include <sound/initval.h>
106166 #include <sound/rawmidi.h>
106167 #include <sound/control.h>
106168 +#include <asm/local.h>
106169
106170 #define CARD_NAME "Portman 2x4"
106171 #define DRIVER_NAME "portman"
106172 @@ -85,7 +86,7 @@ struct portman {
106173 struct pardevice *pardev;
106174 int pardev_claimed;
106175
106176 - int open_count;
106177 + local_t open_count;
106178 int mode[PORTMAN_NUM_INPUT_PORTS];
106179 struct snd_rawmidi_substream *midi_input[PORTMAN_NUM_INPUT_PORTS];
106180 };
106181 diff --git a/sound/firewire/amdtp.c b/sound/firewire/amdtp.c
106182 index 9048777..2d8b1fc 100644
106183 --- a/sound/firewire/amdtp.c
106184 +++ b/sound/firewire/amdtp.c
106185 @@ -488,7 +488,7 @@ static void queue_out_packet(struct amdtp_out_stream *s, unsigned int cycle)
106186 ptr = s->pcm_buffer_pointer + data_blocks;
106187 if (ptr >= pcm->runtime->buffer_size)
106188 ptr -= pcm->runtime->buffer_size;
106189 - ACCESS_ONCE(s->pcm_buffer_pointer) = ptr;
106190 + ACCESS_ONCE_RW(s->pcm_buffer_pointer) = ptr;
106191
106192 s->pcm_period_pointer += data_blocks;
106193 if (s->pcm_period_pointer >= pcm->runtime->period_size) {
106194 @@ -655,7 +655,7 @@ EXPORT_SYMBOL(amdtp_out_stream_pcm_pointer);
106195 */
106196 void amdtp_out_stream_update(struct amdtp_out_stream *s)
106197 {
106198 - ACCESS_ONCE(s->source_node_id_field) =
106199 + ACCESS_ONCE_RW(s->source_node_id_field) =
106200 (fw_parent_device(s->unit)->card->node_id & 0x3f) << 24;
106201 }
106202 EXPORT_SYMBOL(amdtp_out_stream_update);
106203 diff --git a/sound/firewire/amdtp.h b/sound/firewire/amdtp.h
106204 index 2746ecd..c35dedd 100644
106205 --- a/sound/firewire/amdtp.h
106206 +++ b/sound/firewire/amdtp.h
106207 @@ -135,7 +135,7 @@ static inline bool amdtp_out_streaming_error(struct amdtp_out_stream *s)
106208 static inline void amdtp_out_stream_pcm_trigger(struct amdtp_out_stream *s,
106209 struct snd_pcm_substream *pcm)
106210 {
106211 - ACCESS_ONCE(s->pcm) = pcm;
106212 + ACCESS_ONCE_RW(s->pcm) = pcm;
106213 }
106214
106215 static inline bool cip_sfc_is_base_44100(enum cip_sfc sfc)
106216 diff --git a/sound/firewire/isight.c b/sound/firewire/isight.c
106217 index 7ac9443..0ec6274 100644
106218 --- a/sound/firewire/isight.c
106219 +++ b/sound/firewire/isight.c
106220 @@ -96,7 +96,7 @@ static void isight_update_pointers(struct isight *isight, unsigned int count)
106221 ptr += count;
106222 if (ptr >= runtime->buffer_size)
106223 ptr -= runtime->buffer_size;
106224 - ACCESS_ONCE(isight->buffer_pointer) = ptr;
106225 + ACCESS_ONCE_RW(isight->buffer_pointer) = ptr;
106226
106227 isight->period_counter += count;
106228 if (isight->period_counter >= runtime->period_size) {
106229 @@ -299,7 +299,7 @@ static int isight_hw_params(struct snd_pcm_substream *substream,
106230 if (err < 0)
106231 return err;
106232
106233 - ACCESS_ONCE(isight->pcm_active) = true;
106234 + ACCESS_ONCE_RW(isight->pcm_active) = true;
106235
106236 return 0;
106237 }
106238 @@ -337,7 +337,7 @@ static int isight_hw_free(struct snd_pcm_substream *substream)
106239 {
106240 struct isight *isight = substream->private_data;
106241
106242 - ACCESS_ONCE(isight->pcm_active) = false;
106243 + ACCESS_ONCE_RW(isight->pcm_active) = false;
106244
106245 mutex_lock(&isight->mutex);
106246 isight_stop_streaming(isight);
106247 @@ -430,10 +430,10 @@ static int isight_trigger(struct snd_pcm_substream *substream, int cmd)
106248
106249 switch (cmd) {
106250 case SNDRV_PCM_TRIGGER_START:
106251 - ACCESS_ONCE(isight->pcm_running) = true;
106252 + ACCESS_ONCE_RW(isight->pcm_running) = true;
106253 break;
106254 case SNDRV_PCM_TRIGGER_STOP:
106255 - ACCESS_ONCE(isight->pcm_running) = false;
106256 + ACCESS_ONCE_RW(isight->pcm_running) = false;
106257 break;
106258 default:
106259 return -EINVAL;
106260 diff --git a/sound/firewire/scs1x.c b/sound/firewire/scs1x.c
106261 index 2dba848..c682aef 100644
106262 --- a/sound/firewire/scs1x.c
106263 +++ b/sound/firewire/scs1x.c
106264 @@ -74,7 +74,7 @@ static void scs_output_trigger(struct snd_rawmidi_substream *stream, int up)
106265 {
106266 struct scs *scs = stream->rmidi->private_data;
106267
106268 - ACCESS_ONCE(scs->output) = up ? stream : NULL;
106269 + ACCESS_ONCE_RW(scs->output) = up ? stream : NULL;
106270 if (up) {
106271 scs->output_idle = false;
106272 tasklet_schedule(&scs->tasklet);
106273 @@ -257,7 +257,7 @@ static void scs_input_trigger(struct snd_rawmidi_substream *stream, int up)
106274 {
106275 struct scs *scs = stream->rmidi->private_data;
106276
106277 - ACCESS_ONCE(scs->input) = up ? stream : NULL;
106278 + ACCESS_ONCE_RW(scs->input) = up ? stream : NULL;
106279 }
106280
106281 static void scs_input_escaped_byte(struct snd_rawmidi_substream *stream,
106282 @@ -473,8 +473,8 @@ static void scs_remove(struct fw_unit *unit)
106283
106284 snd_card_disconnect(scs->card);
106285
106286 - ACCESS_ONCE(scs->output) = NULL;
106287 - ACCESS_ONCE(scs->input) = NULL;
106288 + ACCESS_ONCE_RW(scs->output) = NULL;
106289 + ACCESS_ONCE_RW(scs->input) = NULL;
106290
106291 wait_event(scs->idle_wait, scs->output_idle);
106292
106293 diff --git a/sound/isa/sb/emu8000_synth.c b/sound/isa/sb/emu8000_synth.c
106294 index 4e3fcfb..ab45a9d 100644
106295 --- a/sound/isa/sb/emu8000_synth.c
106296 +++ b/sound/isa/sb/emu8000_synth.c
106297 @@ -120,8 +120,8 @@ static int __init alsa_emu8000_init(void)
106298 {
106299
106300 static struct snd_seq_dev_ops ops = {
106301 - snd_emu8000_new_device,
106302 - snd_emu8000_delete_device,
106303 + .init_device = snd_emu8000_new_device,
106304 + .free_device = snd_emu8000_delete_device,
106305 };
106306 return snd_seq_device_register_driver(SNDRV_SEQ_DEV_ID_EMU8000, &ops,
106307 sizeof(struct snd_emu8000*));
106308 diff --git a/sound/oss/sb_audio.c b/sound/oss/sb_audio.c
106309 index 048439a..3be9f6f 100644
106310 --- a/sound/oss/sb_audio.c
106311 +++ b/sound/oss/sb_audio.c
106312 @@ -904,7 +904,7 @@ sb16_copy_from_user(int dev,
106313 buf16 = (signed short *)(localbuf + localoffs);
106314 while (c)
106315 {
106316 - locallen = (c >= LBUFCOPYSIZE ? LBUFCOPYSIZE : c);
106317 + locallen = ((unsigned)c >= LBUFCOPYSIZE ? LBUFCOPYSIZE : c);
106318 if (copy_from_user(lbuf8,
106319 userbuf+useroffs + p,
106320 locallen))
106321 diff --git a/sound/oss/swarm_cs4297a.c b/sound/oss/swarm_cs4297a.c
106322 index f851fd0..92576fb 100644
106323 --- a/sound/oss/swarm_cs4297a.c
106324 +++ b/sound/oss/swarm_cs4297a.c
106325 @@ -2623,7 +2623,6 @@ static int __init cs4297a_init(void)
106326 {
106327 struct cs4297a_state *s;
106328 u32 pwr, id;
106329 - mm_segment_t fs;
106330 int rval;
106331 #ifndef CONFIG_BCM_CS4297A_CSWARM
106332 u64 cfg;
106333 @@ -2713,22 +2712,23 @@ static int __init cs4297a_init(void)
106334 if (!rval) {
106335 char *sb1250_duart_present;
106336
106337 +#if 0
106338 + mm_segment_t fs;
106339 fs = get_fs();
106340 set_fs(KERNEL_DS);
106341 -#if 0
106342 val = SOUND_MASK_LINE;
106343 mixer_ioctl(s, SOUND_MIXER_WRITE_RECSRC, (unsigned long) &val);
106344 for (i = 0; i < ARRAY_SIZE(initvol); i++) {
106345 val = initvol[i].vol;
106346 mixer_ioctl(s, initvol[i].mixch, (unsigned long) &val);
106347 }
106348 + set_fs(fs);
106349 // cs4297a_write_ac97(s, 0x18, 0x0808);
106350 #else
106351 // cs4297a_write_ac97(s, 0x5e, 0x180);
106352 cs4297a_write_ac97(s, 0x02, 0x0808);
106353 cs4297a_write_ac97(s, 0x18, 0x0808);
106354 #endif
106355 - set_fs(fs);
106356
106357 list_add(&s->list, &cs4297a_devs);
106358
106359 diff --git a/sound/pci/emu10k1/emu10k1_synth.c b/sound/pci/emu10k1/emu10k1_synth.c
106360 index 4c41c90..37f3631 100644
106361 --- a/sound/pci/emu10k1/emu10k1_synth.c
106362 +++ b/sound/pci/emu10k1/emu10k1_synth.c
106363 @@ -108,8 +108,8 @@ static int __init alsa_emu10k1_synth_init(void)
106364 {
106365
106366 static struct snd_seq_dev_ops ops = {
106367 - snd_emu10k1_synth_new_device,
106368 - snd_emu10k1_synth_delete_device,
106369 + .init_device = snd_emu10k1_synth_new_device,
106370 + .free_device = snd_emu10k1_synth_delete_device,
106371 };
106372 return snd_seq_device_register_driver(SNDRV_SEQ_DEV_ID_EMU10K1_SYNTH, &ops,
106373 sizeof(struct snd_emu10k1_synth_arg));
106374 diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c
106375 index 4c20277..91abdce 100644
106376 --- a/sound/pci/hda/hda_codec.c
106377 +++ b/sound/pci/hda/hda_codec.c
106378 @@ -966,14 +966,10 @@ find_codec_preset(struct hda_codec *codec)
106379 mutex_unlock(&preset_mutex);
106380
106381 if (mod_requested < HDA_MODREQ_MAX_COUNT) {
106382 - char name[32];
106383 if (!mod_requested)
106384 - snprintf(name, sizeof(name), "snd-hda-codec-id:%08x",
106385 - codec->vendor_id);
106386 + request_module("snd-hda-codec-id:%08x", codec->vendor_id);
106387 else
106388 - snprintf(name, sizeof(name), "snd-hda-codec-id:%04x*",
106389 - (codec->vendor_id >> 16) & 0xffff);
106390 - request_module(name);
106391 + request_module("snd-hda-codec-id:%04x*", (codec->vendor_id >> 16) & 0xffff);
106392 mod_requested++;
106393 goto again;
106394 }
106395 @@ -2777,7 +2773,7 @@ static int get_kctl_0dB_offset(struct snd_kcontrol *kctl, int *step_to_check)
106396 /* FIXME: set_fs() hack for obtaining user-space TLV data */
106397 mm_segment_t fs = get_fs();
106398 set_fs(get_ds());
106399 - if (!kctl->tlv.c(kctl, 0, sizeof(_tlv), _tlv))
106400 + if (!kctl->tlv.c(kctl, 0, sizeof(_tlv), (unsigned int __force_user *)_tlv))
106401 tlv = _tlv;
106402 set_fs(fs);
106403 } else if (kctl->vd[0].access & SNDRV_CTL_ELEM_ACCESS_TLV_READ)
106404 diff --git a/sound/pci/ymfpci/ymfpci.h b/sound/pci/ymfpci/ymfpci.h
106405 index 4631a23..001ae57 100644
106406 --- a/sound/pci/ymfpci/ymfpci.h
106407 +++ b/sound/pci/ymfpci/ymfpci.h
106408 @@ -358,7 +358,7 @@ struct snd_ymfpci {
106409 spinlock_t reg_lock;
106410 spinlock_t voice_lock;
106411 wait_queue_head_t interrupt_sleep;
106412 - atomic_t interrupt_sleep_count;
106413 + atomic_unchecked_t interrupt_sleep_count;
106414 struct snd_info_entry *proc_entry;
106415 const struct firmware *dsp_microcode;
106416 const struct firmware *controller_microcode;
106417 diff --git a/sound/pci/ymfpci/ymfpci_main.c b/sound/pci/ymfpci/ymfpci_main.c
106418 index 81c916a..516f0bf 100644
106419 --- a/sound/pci/ymfpci/ymfpci_main.c
106420 +++ b/sound/pci/ymfpci/ymfpci_main.c
106421 @@ -204,8 +204,8 @@ static void snd_ymfpci_hw_stop(struct snd_ymfpci *chip)
106422 if ((snd_ymfpci_readl(chip, YDSXGR_STATUS) & 2) == 0)
106423 break;
106424 }
106425 - if (atomic_read(&chip->interrupt_sleep_count)) {
106426 - atomic_set(&chip->interrupt_sleep_count, 0);
106427 + if (atomic_read_unchecked(&chip->interrupt_sleep_count)) {
106428 + atomic_set_unchecked(&chip->interrupt_sleep_count, 0);
106429 wake_up(&chip->interrupt_sleep);
106430 }
106431 __end:
106432 @@ -789,7 +789,7 @@ static void snd_ymfpci_irq_wait(struct snd_ymfpci *chip)
106433 continue;
106434 init_waitqueue_entry(&wait, current);
106435 add_wait_queue(&chip->interrupt_sleep, &wait);
106436 - atomic_inc(&chip->interrupt_sleep_count);
106437 + atomic_inc_unchecked(&chip->interrupt_sleep_count);
106438 schedule_timeout_uninterruptible(msecs_to_jiffies(50));
106439 remove_wait_queue(&chip->interrupt_sleep, &wait);
106440 }
106441 @@ -827,8 +827,8 @@ static irqreturn_t snd_ymfpci_interrupt(int irq, void *dev_id)
106442 snd_ymfpci_writel(chip, YDSXGR_MODE, mode);
106443 spin_unlock(&chip->reg_lock);
106444
106445 - if (atomic_read(&chip->interrupt_sleep_count)) {
106446 - atomic_set(&chip->interrupt_sleep_count, 0);
106447 + if (atomic_read_unchecked(&chip->interrupt_sleep_count)) {
106448 + atomic_set_unchecked(&chip->interrupt_sleep_count, 0);
106449 wake_up(&chip->interrupt_sleep);
106450 }
106451 }
106452 @@ -2423,7 +2423,7 @@ int snd_ymfpci_create(struct snd_card *card,
106453 spin_lock_init(&chip->reg_lock);
106454 spin_lock_init(&chip->voice_lock);
106455 init_waitqueue_head(&chip->interrupt_sleep);
106456 - atomic_set(&chip->interrupt_sleep_count, 0);
106457 + atomic_set_unchecked(&chip->interrupt_sleep_count, 0);
106458 chip->card = card;
106459 chip->pci = pci;
106460 chip->irq = -1;
106461 diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c
106462 index 5428a1f..474f651 100644
106463 --- a/sound/soc/fsl/fsl_ssi.c
106464 +++ b/sound/soc/fsl/fsl_ssi.c
106465 @@ -1255,7 +1255,6 @@ static int fsl_ssi_probe(struct platform_device *pdev)
106466 {
106467 struct fsl_ssi_private *ssi_private;
106468 int ret = 0;
106469 - struct device_attribute *dev_attr = NULL;
106470 struct device_node *np = pdev->dev.of_node;
106471 const struct of_device_id *of_id;
106472 enum fsl_ssi_type hw_type;
106473 @@ -1481,7 +1480,7 @@ static int fsl_ssi_probe(struct platform_device *pdev)
106474 &ssi_private->cpu_dai_drv, 1);
106475 if (ret) {
106476 dev_err(&pdev->dev, "failed to register DAI: %d\n", ret);
106477 - goto error_dev;
106478 + goto error_clk;
106479 }
106480
106481 ret = fsl_ssi_debugfs_create(ssi_private, &pdev->dev);
106482 @@ -1562,9 +1561,6 @@ error_pcm:
106483 error_dbgfs:
106484 snd_soc_unregister_component(&pdev->dev);
106485
106486 -error_dev:
106487 - device_remove_file(&pdev->dev, dev_attr);
106488 -
106489 error_clk:
106490 if (ssi_private->ssi_on_imx) {
106491 if (!IS_ERR(ssi_private->baudclk))
106492 diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
106493 index 051c006..70598e8 100644
106494 --- a/sound/soc/soc-core.c
106495 +++ b/sound/soc/soc-core.c
106496 @@ -2255,8 +2255,10 @@ int snd_soc_set_ac97_ops_of_reset(struct snd_ac97_bus_ops *ops,
106497 if (ret)
106498 return ret;
106499
106500 - ops->warm_reset = snd_soc_ac97_warm_reset;
106501 - ops->reset = snd_soc_ac97_reset;
106502 + pax_open_kernel();
106503 + *(void **)&ops->warm_reset = snd_soc_ac97_warm_reset;
106504 + *(void **)&ops->reset = snd_soc_ac97_reset;
106505 + pax_close_kernel();
106506
106507 snd_ac97_rst_cfg = cfg;
106508 return 0;
106509 diff --git a/sound/synth/emux/emux_seq.c b/sound/synth/emux/emux_seq.c
106510 index 7778b8e..3d619fc 100644
106511 --- a/sound/synth/emux/emux_seq.c
106512 +++ b/sound/synth/emux/emux_seq.c
106513 @@ -33,13 +33,13 @@ static int snd_emux_unuse(void *private_data, struct snd_seq_port_subscribe *inf
106514 * MIDI emulation operators
106515 */
106516 static struct snd_midi_op emux_ops = {
106517 - snd_emux_note_on,
106518 - snd_emux_note_off,
106519 - snd_emux_key_press,
106520 - snd_emux_terminate_note,
106521 - snd_emux_control,
106522 - snd_emux_nrpn,
106523 - snd_emux_sysex,
106524 + .note_on = snd_emux_note_on,
106525 + .note_off = snd_emux_note_off,
106526 + .key_press = snd_emux_key_press,
106527 + .note_terminate = snd_emux_terminate_note,
106528 + .control = snd_emux_control,
106529 + .nrpn = snd_emux_nrpn,
106530 + .sysex = snd_emux_sysex,
106531 };
106532
106533
106534 diff --git a/tools/gcc/Makefile b/tools/gcc/Makefile
106535 new file mode 100644
106536 index 0000000..7b8921f
106537 --- /dev/null
106538 +++ b/tools/gcc/Makefile
106539 @@ -0,0 +1,52 @@
106540 +#CC := gcc
106541 +#PLUGIN_SOURCE_FILES := pax_plugin.c
106542 +#PLUGIN_OBJECT_FILES := $(patsubst %.c,%.o,$(PLUGIN_SOURCE_FILES))
106543 +GCCPLUGINS_DIR := $(shell $(CC) -print-file-name=plugin)
106544 +#CFLAGS += -I$(GCCPLUGINS_DIR)/include -fPIC -O2 -Wall -W -std=gnu99
106545 +
106546 +ifeq ($(PLUGINCC),$(HOSTCC))
106547 +HOSTLIBS := hostlibs
106548 +HOST_EXTRACFLAGS += -I$(GCCPLUGINS_DIR)/include -I$(src) -std=gnu99 -ggdb
106549 +export HOST_EXTRACFLAGS
106550 +else
106551 +HOSTLIBS := hostcxxlibs
106552 +HOST_EXTRACXXFLAGS += -I$(GCCPLUGINS_DIR)/include -I$(src) -std=gnu++98 -fno-rtti -ggdb -Wno-unused-parameter -Wno-narrowing -Wno-unused-variable
106553 +export HOST_EXTRACXXFLAGS
106554 +endif
106555 +
106556 +export GCCPLUGINS_DIR HOSTLIBS
106557 +
106558 +$(HOSTLIBS)-$(CONFIG_PAX_CONSTIFY_PLUGIN) := constify_plugin.so
106559 +$(HOSTLIBS)-$(CONFIG_PAX_MEMORY_STACKLEAK) += stackleak_plugin.so
106560 +$(HOSTLIBS)-$(CONFIG_KALLOCSTAT_PLUGIN) += kallocstat_plugin.so
106561 +$(HOSTLIBS)-$(CONFIG_PAX_KERNEXEC_PLUGIN) += kernexec_plugin.so
106562 +$(HOSTLIBS)-$(CONFIG_CHECKER_PLUGIN) += checker_plugin.so
106563 +$(HOSTLIBS)-y += colorize_plugin.so
106564 +$(HOSTLIBS)-$(CONFIG_PAX_LATENT_ENTROPY) += latent_entropy_plugin.so
106565 +$(HOSTLIBS)-$(CONFIG_PAX_MEMORY_STRUCTLEAK) += structleak_plugin.so
106566 +$(HOSTLIBS)-$(CONFIG_GRKERNSEC_RANDSTRUCT) += randomize_layout_plugin.so
106567 +
106568 +subdir-$(CONFIG_PAX_SIZE_OVERFLOW) := size_overflow_plugin
106569 +subdir- += size_overflow_plugin
106570 +
106571 +always := $($(HOSTLIBS)-y)
106572 +
106573 +constify_plugin-objs := constify_plugin.o
106574 +stackleak_plugin-objs := stackleak_plugin.o
106575 +kallocstat_plugin-objs := kallocstat_plugin.o
106576 +kernexec_plugin-objs := kernexec_plugin.o
106577 +checker_plugin-objs := checker_plugin.o
106578 +colorize_plugin-objs := colorize_plugin.o
106579 +latent_entropy_plugin-objs := latent_entropy_plugin.o
106580 +structleak_plugin-objs := structleak_plugin.o
106581 +randomize_layout_plugin-objs := randomize_layout_plugin.o
106582 +
106583 +$(obj)/randomize_layout_plugin.o: $(objtree)/$(obj)/randomize_layout_seed.h
106584 +
106585 +quiet_cmd_create_randomize_layout_seed = GENSEED $@
106586 + cmd_create_randomize_layout_seed = \
106587 + $(CONFIG_SHELL) $(srctree)/$(src)/gen-random-seed.sh $@ $(objtree)/include/generated/randomize_layout_hash.h
106588 +$(objtree)/$(obj)/randomize_layout_seed.h: FORCE
106589 + $(call if_changed,create_randomize_layout_seed)
106590 +
106591 +targets += randomize_layout_seed.h randomize_layout_hash.h
106592 diff --git a/tools/gcc/checker_plugin.c b/tools/gcc/checker_plugin.c
106593 new file mode 100644
106594 index 0000000..5452feea
106595 --- /dev/null
106596 +++ b/tools/gcc/checker_plugin.c
106597 @@ -0,0 +1,150 @@
106598 +/*
106599 + * Copyright 2011-2014 by the PaX Team <pageexec@freemail.hu>
106600 + * Licensed under the GPL v2
106601 + *
106602 + * Note: the choice of the license means that the compilation process is
106603 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
106604 + * but for the kernel it doesn't matter since it doesn't link against
106605 + * any of the gcc libraries
106606 + *
106607 + * gcc plugin to implement various sparse (source code checker) features
106608 + *
106609 + * TODO:
106610 + * - define separate __iomem, __percpu and __rcu address spaces (lots of code to patch)
106611 + *
106612 + * BUGS:
106613 + * - none known
106614 + */
106615 +
106616 +#include "gcc-common.h"
106617 +
106618 +extern void c_register_addr_space (const char *str, addr_space_t as);
106619 +extern enum machine_mode default_addr_space_pointer_mode (addr_space_t);
106620 +extern enum machine_mode default_addr_space_address_mode (addr_space_t);
106621 +extern bool default_addr_space_valid_pointer_mode(enum machine_mode mode, addr_space_t as);
106622 +extern bool default_addr_space_legitimate_address_p(enum machine_mode mode, rtx mem, bool strict, addr_space_t as);
106623 +extern rtx default_addr_space_legitimize_address(rtx x, rtx oldx, enum machine_mode mode, addr_space_t as);
106624 +
106625 +int plugin_is_GPL_compatible;
106626 +
106627 +static struct plugin_info checker_plugin_info = {
106628 + .version = "201304082245",
106629 + .help = NULL,
106630 +};
106631 +
106632 +#define ADDR_SPACE_KERNEL 0
106633 +#define ADDR_SPACE_FORCE_KERNEL 1
106634 +#define ADDR_SPACE_USER 2
106635 +#define ADDR_SPACE_FORCE_USER 3
106636 +#define ADDR_SPACE_IOMEM 0
106637 +#define ADDR_SPACE_FORCE_IOMEM 0
106638 +#define ADDR_SPACE_PERCPU 0
106639 +#define ADDR_SPACE_FORCE_PERCPU 0
106640 +#define ADDR_SPACE_RCU 0
106641 +#define ADDR_SPACE_FORCE_RCU 0
106642 +
106643 +static enum machine_mode checker_addr_space_pointer_mode(addr_space_t addrspace)
106644 +{
106645 + return default_addr_space_pointer_mode(ADDR_SPACE_GENERIC);
106646 +}
106647 +
106648 +static enum machine_mode checker_addr_space_address_mode(addr_space_t addrspace)
106649 +{
106650 + return default_addr_space_address_mode(ADDR_SPACE_GENERIC);
106651 +}
106652 +
106653 +static bool checker_addr_space_valid_pointer_mode(enum machine_mode mode, addr_space_t as)
106654 +{
106655 + return default_addr_space_valid_pointer_mode(mode, as);
106656 +}
106657 +
106658 +static bool checker_addr_space_legitimate_address_p(enum machine_mode mode, rtx mem, bool strict, addr_space_t as)
106659 +{
106660 + return default_addr_space_legitimate_address_p(mode, mem, strict, ADDR_SPACE_GENERIC);
106661 +}
106662 +
106663 +static rtx checker_addr_space_legitimize_address(rtx x, rtx oldx, enum machine_mode mode, addr_space_t as)
106664 +{
106665 + return default_addr_space_legitimize_address(x, oldx, mode, as);
106666 +}
106667 +
106668 +static bool checker_addr_space_subset_p(addr_space_t subset, addr_space_t superset)
106669 +{
106670 + if (subset == ADDR_SPACE_FORCE_KERNEL && superset == ADDR_SPACE_KERNEL)
106671 + return true;
106672 +
106673 + if (subset == ADDR_SPACE_FORCE_USER && superset == ADDR_SPACE_USER)
106674 + return true;
106675 +
106676 + if (subset == ADDR_SPACE_FORCE_IOMEM && superset == ADDR_SPACE_IOMEM)
106677 + return true;
106678 +
106679 + if (subset == ADDR_SPACE_KERNEL && superset == ADDR_SPACE_FORCE_USER)
106680 + return true;
106681 +
106682 + if (subset == ADDR_SPACE_KERNEL && superset == ADDR_SPACE_FORCE_IOMEM)
106683 + return true;
106684 +
106685 + if (subset == ADDR_SPACE_USER && superset == ADDR_SPACE_FORCE_KERNEL)
106686 + return true;
106687 +
106688 + if (subset == ADDR_SPACE_IOMEM && superset == ADDR_SPACE_FORCE_KERNEL)
106689 + return true;
106690 +
106691 + return subset == superset;
106692 +}
106693 +
106694 +static rtx checker_addr_space_convert(rtx op, tree from_type, tree to_type)
106695 +{
106696 +// addr_space_t from_as = TYPE_ADDR_SPACE(TREE_TYPE(from_type));
106697 +// addr_space_t to_as = TYPE_ADDR_SPACE(TREE_TYPE(to_type));
106698 +
106699 + return op;
106700 +}
106701 +
106702 +static void register_checker_address_spaces(void *event_data, void *data)
106703 +{
106704 + c_register_addr_space("__kernel", ADDR_SPACE_KERNEL);
106705 + c_register_addr_space("__force_kernel", ADDR_SPACE_FORCE_KERNEL);
106706 + c_register_addr_space("__user", ADDR_SPACE_USER);
106707 + c_register_addr_space("__force_user", ADDR_SPACE_FORCE_USER);
106708 +// c_register_addr_space("__iomem", ADDR_SPACE_IOMEM);
106709 +// c_register_addr_space("__force_iomem", ADDR_SPACE_FORCE_IOMEM);
106710 +// c_register_addr_space("__percpu", ADDR_SPACE_PERCPU);
106711 +// c_register_addr_space("__force_percpu", ADDR_SPACE_FORCE_PERCPU);
106712 +// c_register_addr_space("__rcu", ADDR_SPACE_RCU);
106713 +// c_register_addr_space("__force_rcu", ADDR_SPACE_FORCE_RCU);
106714 +
106715 + targetm.addr_space.pointer_mode = checker_addr_space_pointer_mode;
106716 + targetm.addr_space.address_mode = checker_addr_space_address_mode;
106717 + targetm.addr_space.valid_pointer_mode = checker_addr_space_valid_pointer_mode;
106718 + targetm.addr_space.legitimate_address_p = checker_addr_space_legitimate_address_p;
106719 +// targetm.addr_space.legitimize_address = checker_addr_space_legitimize_address;
106720 + targetm.addr_space.subset_p = checker_addr_space_subset_p;
106721 + targetm.addr_space.convert = checker_addr_space_convert;
106722 +}
106723 +
106724 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
106725 +{
106726 + const char * const plugin_name = plugin_info->base_name;
106727 + const int argc = plugin_info->argc;
106728 + const struct plugin_argument * const argv = plugin_info->argv;
106729 + int i;
106730 +
106731 + if (!plugin_default_version_check(version, &gcc_version)) {
106732 + error(G_("incompatible gcc/plugin versions"));
106733 + return 1;
106734 + }
106735 +
106736 + register_callback(plugin_name, PLUGIN_INFO, NULL, &checker_plugin_info);
106737 +
106738 + for (i = 0; i < argc; ++i)
106739 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
106740 +
106741 + if (TARGET_64BIT == 0)
106742 + return 0;
106743 +
106744 + register_callback(plugin_name, PLUGIN_PRAGMAS, register_checker_address_spaces, NULL);
106745 +
106746 + return 0;
106747 +}
106748 diff --git a/tools/gcc/colorize_plugin.c b/tools/gcc/colorize_plugin.c
106749 new file mode 100644
106750 index 0000000..54461af
106751 --- /dev/null
106752 +++ b/tools/gcc/colorize_plugin.c
106753 @@ -0,0 +1,210 @@
106754 +/*
106755 + * Copyright 2012-2014 by PaX Team <pageexec@freemail.hu>
106756 + * Licensed under the GPL v2
106757 + *
106758 + * Note: the choice of the license means that the compilation process is
106759 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
106760 + * but for the kernel it doesn't matter since it doesn't link against
106761 + * any of the gcc libraries
106762 + *
106763 + * gcc plugin to colorize diagnostic output
106764 + *
106765 + */
106766 +
106767 +#include "gcc-common.h"
106768 +
106769 +int plugin_is_GPL_compatible;
106770 +
106771 +static struct plugin_info colorize_plugin_info = {
106772 + .version = "201404202350",
106773 + .help = "color=[never|always|auto]\tdetermine when to colorize\n",
106774 +};
106775 +
106776 +#define GREEN "\033[32m\033[K"
106777 +#define LIGHTGREEN "\033[1;32m\033[K"
106778 +#define YELLOW "\033[33m\033[K"
106779 +#define LIGHTYELLOW "\033[1;33m\033[K"
106780 +#define RED "\033[31m\033[K"
106781 +#define LIGHTRED "\033[1;31m\033[K"
106782 +#define BLUE "\033[34m\033[K"
106783 +#define LIGHTBLUE "\033[1;34m\033[K"
106784 +#define BRIGHT "\033[1;m\033[K"
106785 +#define NORMAL "\033[m\033[K"
106786 +
106787 +static diagnostic_starter_fn old_starter;
106788 +static diagnostic_finalizer_fn old_finalizer;
106789 +
106790 +static void start_colorize(diagnostic_context *context, diagnostic_info *diagnostic)
106791 +{
106792 + const char *color;
106793 + char *newprefix;
106794 +
106795 + switch (diagnostic->kind) {
106796 + case DK_NOTE:
106797 + color = LIGHTBLUE;
106798 + break;
106799 +
106800 + case DK_PEDWARN:
106801 + case DK_WARNING:
106802 + color = LIGHTYELLOW;
106803 + break;
106804 +
106805 + case DK_ERROR:
106806 + case DK_FATAL:
106807 + case DK_ICE:
106808 + case DK_PERMERROR:
106809 + case DK_SORRY:
106810 + color = LIGHTRED;
106811 + break;
106812 +
106813 + default:
106814 + color = NORMAL;
106815 + }
106816 +
106817 + old_starter(context, diagnostic);
106818 + if (-1 == asprintf(&newprefix, "%s%s" NORMAL, color, context->printer->prefix))
106819 + return;
106820 + pp_destroy_prefix(context->printer);
106821 + pp_set_prefix(context->printer, newprefix);
106822 +}
106823 +
106824 +static void finalize_colorize(diagnostic_context *context, diagnostic_info *diagnostic)
106825 +{
106826 + old_finalizer(context, diagnostic);
106827 +}
106828 +
106829 +static void colorize_arm(void)
106830 +{
106831 + old_starter = diagnostic_starter(global_dc);
106832 + old_finalizer = diagnostic_finalizer(global_dc);
106833 +
106834 + diagnostic_starter(global_dc) = start_colorize;
106835 + diagnostic_finalizer(global_dc) = finalize_colorize;
106836 +}
106837 +
106838 +static unsigned int execute_colorize_rearm(void)
106839 +{
106840 + if (diagnostic_starter(global_dc) == start_colorize)
106841 + return 0;
106842 +
106843 + colorize_arm();
106844 + return 0;
106845 +}
106846 +
106847 +#if BUILDING_GCC_VERSION >= 4009
106848 +static const struct pass_data colorize_rearm_pass_data = {
106849 +#else
106850 +struct simple_ipa_opt_pass colorize_rearm_pass = {
106851 + .pass = {
106852 +#endif
106853 + .type = SIMPLE_IPA_PASS,
106854 + .name = "colorize_rearm",
106855 +#if BUILDING_GCC_VERSION >= 4008
106856 + .optinfo_flags = OPTGROUP_NONE,
106857 +#endif
106858 +#if BUILDING_GCC_VERSION >= 4009
106859 + .has_gate = false,
106860 + .has_execute = true,
106861 +#else
106862 + .gate = NULL,
106863 + .execute = execute_colorize_rearm,
106864 + .sub = NULL,
106865 + .next = NULL,
106866 + .static_pass_number = 0,
106867 +#endif
106868 + .tv_id = TV_NONE,
106869 + .properties_required = 0,
106870 + .properties_provided = 0,
106871 + .properties_destroyed = 0,
106872 + .todo_flags_start = 0,
106873 + .todo_flags_finish = 0
106874 +#if BUILDING_GCC_VERSION < 4009
106875 + }
106876 +#endif
106877 +};
106878 +
106879 +#if BUILDING_GCC_VERSION >= 4009
106880 +namespace {
106881 +class colorize_rearm_pass : public simple_ipa_opt_pass {
106882 +public:
106883 + colorize_rearm_pass() : simple_ipa_opt_pass(colorize_rearm_pass_data, g) {}
106884 + unsigned int execute() { return execute_colorize_rearm(); }
106885 +};
106886 +}
106887 +
106888 +static opt_pass *make_colorize_rearm_pass(void)
106889 +{
106890 + return new colorize_rearm_pass();
106891 +}
106892 +#else
106893 +static struct opt_pass *make_colorize_rearm_pass(void)
106894 +{
106895 + return &colorize_rearm_pass.pass;
106896 +}
106897 +#endif
106898 +
106899 +static void colorize_start_unit(void *gcc_data, void *user_data)
106900 +{
106901 + colorize_arm();
106902 +}
106903 +
106904 +static bool should_colorize(void)
106905 +{
106906 +#if BUILDING_GCC_VERSION >= 4009
106907 + return false;
106908 +#else
106909 + char const *t = getenv("TERM");
106910 +
106911 + return t && strcmp(t, "dumb") && isatty(STDERR_FILENO);
106912 +#endif
106913 +}
106914 +
106915 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
106916 +{
106917 + const char * const plugin_name = plugin_info->base_name;
106918 + const int argc = plugin_info->argc;
106919 + const struct plugin_argument * const argv = plugin_info->argv;
106920 + int i;
106921 + struct register_pass_info colorize_rearm_pass_info;
106922 + bool colorize;
106923 +
106924 + colorize_rearm_pass_info.pass = make_colorize_rearm_pass();
106925 + colorize_rearm_pass_info.reference_pass_name = "*free_lang_data";
106926 + colorize_rearm_pass_info.ref_pass_instance_number = 1;
106927 + colorize_rearm_pass_info.pos_op = PASS_POS_INSERT_AFTER;
106928 +
106929 + if (!plugin_default_version_check(version, &gcc_version)) {
106930 + error(G_("incompatible gcc/plugin versions"));
106931 + return 1;
106932 + }
106933 +
106934 + register_callback(plugin_name, PLUGIN_INFO, NULL, &colorize_plugin_info);
106935 +
106936 + colorize = getenv("GCC_COLORS") ? should_colorize() : false;
106937 +
106938 + for (i = 0; i < argc; ++i) {
106939 + if (!strcmp(argv[i].key, "color")) {
106940 + if (!argv[i].value) {
106941 + error(G_("no value supplied for option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
106942 + continue;
106943 + }
106944 + if (!strcmp(argv[i].value, "always"))
106945 + colorize = true;
106946 + else if (!strcmp(argv[i].value, "never"))
106947 + colorize = false;
106948 + else if (!strcmp(argv[i].value, "auto"))
106949 + colorize = should_colorize();
106950 + else
106951 + error(G_("invalid option argument '-fplugin-arg-%s-%s=%s'"), plugin_name, argv[i].key, argv[i].value);
106952 + continue;
106953 + }
106954 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
106955 + }
106956 +
106957 + if (colorize) {
106958 + // TODO: parse GCC_COLORS as used by gcc 4.9+
106959 + register_callback(plugin_name, PLUGIN_START_UNIT, &colorize_start_unit, NULL);
106960 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &colorize_rearm_pass_info);
106961 + }
106962 + return 0;
106963 +}
106964 diff --git a/tools/gcc/constify_plugin.c b/tools/gcc/constify_plugin.c
106965 new file mode 100644
106966 index 0000000..82bc5a8
106967 --- /dev/null
106968 +++ b/tools/gcc/constify_plugin.c
106969 @@ -0,0 +1,557 @@
106970 +/*
106971 + * Copyright 2011 by Emese Revfy <re.emese@gmail.com>
106972 + * Copyright 2011-2014 by PaX Team <pageexec@freemail.hu>
106973 + * Licensed under the GPL v2, or (at your option) v3
106974 + *
106975 + * This gcc plugin constifies all structures which contain only function pointers or are explicitly marked for constification.
106976 + *
106977 + * Homepage:
106978 + * http://www.grsecurity.net/~ephox/const_plugin/
106979 + *
106980 + * Usage:
106981 + * $ gcc -I`gcc -print-file-name=plugin`/include -fPIC -shared -O2 -o constify_plugin.so constify_plugin.c
106982 + * $ gcc -fplugin=constify_plugin.so test.c -O2
106983 + */
106984 +
106985 +#include "gcc-common.h"
106986 +
106987 +// unused C type flag in all versions 4.5-4.9
106988 +#define TYPE_CONSTIFY_VISITED(TYPE) TYPE_LANG_FLAG_4(TYPE)
106989 +
106990 +int plugin_is_GPL_compatible;
106991 +
106992 +static struct plugin_info const_plugin_info = {
106993 + .version = "201401270210",
106994 + .help = "no-constify\tturn off constification\n",
106995 +};
106996 +
106997 +typedef struct {
106998 + bool has_fptr_field;
106999 + bool has_writable_field;
107000 + bool has_do_const_field;
107001 + bool has_no_const_field;
107002 +} constify_info;
107003 +
107004 +static const_tree get_field_type(const_tree field)
107005 +{
107006 + return strip_array_types(TREE_TYPE(field));
107007 +}
107008 +
107009 +static bool is_fptr(const_tree field)
107010 +{
107011 + const_tree ptr = get_field_type(field);
107012 +
107013 + if (TREE_CODE(ptr) != POINTER_TYPE)
107014 + return false;
107015 +
107016 + return TREE_CODE(TREE_TYPE(ptr)) == FUNCTION_TYPE;
107017 +}
107018 +
107019 +/*
107020 + * determine whether the given structure type meets the requirements for automatic constification,
107021 + * including the constification attributes on nested structure types
107022 + */
107023 +static void constifiable(const_tree node, constify_info *cinfo)
107024 +{
107025 + const_tree field;
107026 +
107027 + gcc_assert(TREE_CODE(node) == RECORD_TYPE || TREE_CODE(node) == UNION_TYPE);
107028 +
107029 + // e.g., pointer to structure fields while still constructing the structure type
107030 + if (TYPE_FIELDS(node) == NULL_TREE)
107031 + return;
107032 +
107033 + for (field = TYPE_FIELDS(node); field; field = TREE_CHAIN(field)) {
107034 + const_tree type = get_field_type(field);
107035 + enum tree_code code = TREE_CODE(type);
107036 +
107037 + if (node == type)
107038 + continue;
107039 +
107040 + if (is_fptr(field))
107041 + cinfo->has_fptr_field = true;
107042 + else if (!TREE_READONLY(field))
107043 + cinfo->has_writable_field = true;
107044 +
107045 + if (code == RECORD_TYPE || code == UNION_TYPE) {
107046 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
107047 + cinfo->has_do_const_field = true;
107048 + else if (lookup_attribute("no_const", TYPE_ATTRIBUTES(type)))
107049 + cinfo->has_no_const_field = true;
107050 + else
107051 + constifiable(type, cinfo);
107052 + }
107053 + }
107054 +}
107055 +
107056 +static bool constified(const_tree node)
107057 +{
107058 + constify_info cinfo = {
107059 + .has_fptr_field = false,
107060 + .has_writable_field = false,
107061 + .has_do_const_field = false,
107062 + .has_no_const_field = false
107063 + };
107064 +
107065 + gcc_assert(TREE_CODE(node) == RECORD_TYPE || TREE_CODE(node) == UNION_TYPE);
107066 +
107067 + if (lookup_attribute("no_const", TYPE_ATTRIBUTES(node))) {
107068 +// gcc_assert(!TYPE_READONLY(node));
107069 + return false;
107070 + }
107071 +
107072 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(node))) {
107073 + gcc_assert(TYPE_READONLY(node));
107074 + return true;
107075 + }
107076 +
107077 + constifiable(node, &cinfo);
107078 + if ((!cinfo.has_fptr_field || cinfo.has_writable_field) && !cinfo.has_do_const_field)
107079 + return false;
107080 +
107081 + return TYPE_READONLY(node);
107082 +}
107083 +
107084 +static void deconstify_tree(tree node);
107085 +
107086 +static void deconstify_type(tree type)
107087 +{
107088 + tree field;
107089 +
107090 + gcc_assert(TREE_CODE(type) == RECORD_TYPE || TREE_CODE(type) == UNION_TYPE);
107091 +
107092 + for (field = TYPE_FIELDS(type); field; field = TREE_CHAIN(field)) {
107093 + const_tree fieldtype = get_field_type(field);
107094 +
107095 + // special case handling of simple ptr-to-same-array-type members
107096 + if (TREE_CODE(TREE_TYPE(field)) == POINTER_TYPE) {
107097 + tree ptrtype = TREE_TYPE(TREE_TYPE(field));
107098 +
107099 + if (TREE_TYPE(TREE_TYPE(field)) == type)
107100 + continue;
107101 + if (TREE_CODE(ptrtype) != RECORD_TYPE && TREE_CODE(ptrtype) != UNION_TYPE)
107102 + continue;
107103 + if (!constified(ptrtype))
107104 + continue;
107105 + if (TYPE_MAIN_VARIANT(ptrtype) == TYPE_MAIN_VARIANT(type)) {
107106 + TREE_TYPE(field) = copy_node(TREE_TYPE(field));
107107 + TREE_TYPE(TREE_TYPE(field)) = build_qualified_type(type, TYPE_QUALS(ptrtype) & ~TYPE_QUAL_CONST);
107108 + }
107109 + continue;
107110 + }
107111 + if (TREE_CODE(fieldtype) != RECORD_TYPE && TREE_CODE(fieldtype) != UNION_TYPE)
107112 + continue;
107113 + if (!constified(fieldtype))
107114 + continue;
107115 +
107116 + deconstify_tree(field);
107117 + TREE_READONLY(field) = 0;
107118 + }
107119 + TYPE_READONLY(type) = 0;
107120 + C_TYPE_FIELDS_READONLY(type) = 0;
107121 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type))) {
107122 + TYPE_ATTRIBUTES(type) = copy_list(TYPE_ATTRIBUTES(type));
107123 + TYPE_ATTRIBUTES(type) = remove_attribute("do_const", TYPE_ATTRIBUTES(type));
107124 + }
107125 +}
107126 +
107127 +static void deconstify_tree(tree node)
107128 +{
107129 + tree old_type, new_type, field;
107130 +
107131 + old_type = TREE_TYPE(node);
107132 + while (TREE_CODE(old_type) == ARRAY_TYPE && TREE_CODE(TREE_TYPE(old_type)) != ARRAY_TYPE) {
107133 + node = TREE_TYPE(node) = copy_node(old_type);
107134 + old_type = TREE_TYPE(old_type);
107135 + }
107136 +
107137 + gcc_assert(TREE_CODE(old_type) == RECORD_TYPE || TREE_CODE(old_type) == UNION_TYPE);
107138 + gcc_assert(TYPE_READONLY(old_type) && (TYPE_QUALS(old_type) & TYPE_QUAL_CONST));
107139 +
107140 + new_type = build_qualified_type(old_type, TYPE_QUALS(old_type) & ~TYPE_QUAL_CONST);
107141 + TYPE_FIELDS(new_type) = copy_list(TYPE_FIELDS(new_type));
107142 + for (field = TYPE_FIELDS(new_type); field; field = TREE_CHAIN(field))
107143 + DECL_FIELD_CONTEXT(field) = new_type;
107144 +
107145 + deconstify_type(new_type);
107146 +
107147 + TREE_TYPE(node) = new_type;
107148 +}
107149 +
107150 +static tree handle_no_const_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
107151 +{
107152 + tree type;
107153 + constify_info cinfo = {
107154 + .has_fptr_field = false,
107155 + .has_writable_field = false,
107156 + .has_do_const_field = false,
107157 + .has_no_const_field = false
107158 + };
107159 +
107160 + *no_add_attrs = true;
107161 + if (TREE_CODE(*node) == FUNCTION_DECL) {
107162 + error("%qE attribute does not apply to functions (%qF)", name, *node);
107163 + return NULL_TREE;
107164 + }
107165 +
107166 + if (TREE_CODE(*node) == PARM_DECL) {
107167 + error("%qE attribute does not apply to function parameters (%qD)", name, *node);
107168 + return NULL_TREE;
107169 + }
107170 +
107171 + if (TREE_CODE(*node) == VAR_DECL) {
107172 + error("%qE attribute does not apply to variables (%qD)", name, *node);
107173 + return NULL_TREE;
107174 + }
107175 +
107176 + if (TYPE_P(*node)) {
107177 + type = *node;
107178 + } else {
107179 + gcc_assert(TREE_CODE(*node) == TYPE_DECL);
107180 + type = TREE_TYPE(*node);
107181 + }
107182 +
107183 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE) {
107184 + error("%qE attribute used on %qT applies to struct and union types only", name, type);
107185 + return NULL_TREE;
107186 + }
107187 +
107188 + if (lookup_attribute(IDENTIFIER_POINTER(name), TYPE_ATTRIBUTES(type))) {
107189 + error("%qE attribute is already applied to the type %qT", name, type);
107190 + return NULL_TREE;
107191 + }
107192 +
107193 + if (TYPE_P(*node)) {
107194 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
107195 + error("%qE attribute used on type %qT is incompatible with 'do_const'", name, type);
107196 + else
107197 + *no_add_attrs = false;
107198 + return NULL_TREE;
107199 + }
107200 +
107201 + constifiable(type, &cinfo);
107202 + if ((cinfo.has_fptr_field && !cinfo.has_writable_field) || lookup_attribute("do_const", TYPE_ATTRIBUTES(type))) {
107203 + deconstify_tree(*node);
107204 + TYPE_CONSTIFY_VISITED(TREE_TYPE(*node)) = 1;
107205 + return NULL_TREE;
107206 + }
107207 +
107208 + error("%qE attribute used on type %qT that is not constified", name, type);
107209 + return NULL_TREE;
107210 +}
107211 +
107212 +static void constify_type(tree type)
107213 +{
107214 + TYPE_READONLY(type) = 1;
107215 + C_TYPE_FIELDS_READONLY(type) = 1;
107216 + TYPE_CONSTIFY_VISITED(type) = 1;
107217 +// TYPE_ATTRIBUTES(type) = copy_list(TYPE_ATTRIBUTES(type));
107218 +// TYPE_ATTRIBUTES(type) = tree_cons(get_identifier("do_const"), NULL_TREE, TYPE_ATTRIBUTES(type));
107219 +}
107220 +
107221 +static tree handle_do_const_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
107222 +{
107223 + *no_add_attrs = true;
107224 + if (!TYPE_P(*node)) {
107225 + error("%qE attribute applies to types only (%qD)", name, *node);
107226 + return NULL_TREE;
107227 + }
107228 +
107229 + if (TREE_CODE(*node) != RECORD_TYPE && TREE_CODE(*node) != UNION_TYPE) {
107230 + error("%qE attribute used on %qT applies to struct and union types only", name, *node);
107231 + return NULL_TREE;
107232 + }
107233 +
107234 + if (lookup_attribute(IDENTIFIER_POINTER(name), TYPE_ATTRIBUTES(*node))) {
107235 + error("%qE attribute used on %qT is already applied to the type", name, *node);
107236 + return NULL_TREE;
107237 + }
107238 +
107239 + if (lookup_attribute("no_const", TYPE_ATTRIBUTES(*node))) {
107240 + error("%qE attribute used on %qT is incompatible with 'no_const'", name, *node);
107241 + return NULL_TREE;
107242 + }
107243 +
107244 + *no_add_attrs = false;
107245 + return NULL_TREE;
107246 +}
107247 +
107248 +static struct attribute_spec no_const_attr = {
107249 + .name = "no_const",
107250 + .min_length = 0,
107251 + .max_length = 0,
107252 + .decl_required = false,
107253 + .type_required = false,
107254 + .function_type_required = false,
107255 + .handler = handle_no_const_attribute,
107256 +#if BUILDING_GCC_VERSION >= 4007
107257 + .affects_type_identity = true
107258 +#endif
107259 +};
107260 +
107261 +static struct attribute_spec do_const_attr = {
107262 + .name = "do_const",
107263 + .min_length = 0,
107264 + .max_length = 0,
107265 + .decl_required = false,
107266 + .type_required = false,
107267 + .function_type_required = false,
107268 + .handler = handle_do_const_attribute,
107269 +#if BUILDING_GCC_VERSION >= 4007
107270 + .affects_type_identity = true
107271 +#endif
107272 +};
107273 +
107274 +static void register_attributes(void *event_data, void *data)
107275 +{
107276 + register_attribute(&no_const_attr);
107277 + register_attribute(&do_const_attr);
107278 +}
107279 +
107280 +static void finish_type(void *event_data, void *data)
107281 +{
107282 + tree type = (tree)event_data;
107283 + constify_info cinfo = {
107284 + .has_fptr_field = false,
107285 + .has_writable_field = false,
107286 + .has_do_const_field = false,
107287 + .has_no_const_field = false
107288 + };
107289 +
107290 + if (type == NULL_TREE || type == error_mark_node)
107291 + return;
107292 +
107293 + if (TYPE_FIELDS(type) == NULL_TREE || TYPE_CONSTIFY_VISITED(type))
107294 + return;
107295 +
107296 + constifiable(type, &cinfo);
107297 +
107298 + if (lookup_attribute("no_const", TYPE_ATTRIBUTES(type))) {
107299 + if ((cinfo.has_fptr_field && !cinfo.has_writable_field) || cinfo.has_do_const_field) {
107300 + deconstify_type(type);
107301 + TYPE_CONSTIFY_VISITED(type) = 1;
107302 + } else
107303 + error("'no_const' attribute used on type %qT that is not constified", type);
107304 + return;
107305 + }
107306 +
107307 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type))) {
107308 + if (!cinfo.has_writable_field) {
107309 + error("'do_const' attribute used on type %qT that is%sconstified", type, cinfo.has_fptr_field ? " " : " not ");
107310 + return;
107311 + }
107312 + constify_type(type);
107313 + return;
107314 + }
107315 +
107316 + if (cinfo.has_fptr_field && !cinfo.has_writable_field) {
107317 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type))) {
107318 + error("'do_const' attribute used on type %qT that is constified", type);
107319 + return;
107320 + }
107321 + constify_type(type);
107322 + return;
107323 + }
107324 +
107325 + deconstify_type(type);
107326 + TYPE_CONSTIFY_VISITED(type) = 1;
107327 +}
107328 +
107329 +static void check_global_variables(void *event_data, void *data)
107330 +{
107331 +#if BUILDING_GCC_VERSION >= 4009
107332 + varpool_node *node;
107333 +#else
107334 + struct varpool_node *node;
107335 +#endif
107336 +
107337 + FOR_EACH_VARIABLE(node) {
107338 + tree var = NODE_DECL(node);
107339 + tree type = TREE_TYPE(var);
107340 +
107341 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE)
107342 + continue;
107343 +
107344 + if (!TYPE_READONLY(type) || !C_TYPE_FIELDS_READONLY(type))
107345 + continue;
107346 +
107347 + if (!TYPE_CONSTIFY_VISITED(type))
107348 + continue;
107349 +
107350 + if (DECL_EXTERNAL(var))
107351 + continue;
107352 +
107353 + if (DECL_INITIAL(var))
107354 + continue;
107355 +
107356 + // this works around a gcc bug/feature where uninitialized globals
107357 + // are moved into the .bss section regardless of any constification
107358 + DECL_INITIAL(var) = build_constructor(type, NULL);
107359 +// inform(DECL_SOURCE_LOCATION(var), "constified variable %qE moved into .rodata", var);
107360 + }
107361 +}
107362 +
107363 +static unsigned int check_local_variables(void)
107364 +{
107365 + unsigned int ret = 0;
107366 + tree var;
107367 +
107368 + unsigned int i;
107369 +
107370 + FOR_EACH_LOCAL_DECL(cfun, i, var) {
107371 + tree type = TREE_TYPE(var);
107372 +
107373 + gcc_assert(DECL_P(var));
107374 + if (is_global_var(var))
107375 + continue;
107376 +
107377 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE)
107378 + continue;
107379 +
107380 + if (!TYPE_READONLY(type) || !C_TYPE_FIELDS_READONLY(type))
107381 + continue;
107382 +
107383 + if (!TYPE_CONSTIFY_VISITED(type))
107384 + continue;
107385 +
107386 + error_at(DECL_SOURCE_LOCATION(var), "constified variable %qE cannot be local", var);
107387 + ret = 1;
107388 + }
107389 + return ret;
107390 +}
107391 +
107392 +#if BUILDING_GCC_VERSION >= 4009
107393 +static const struct pass_data check_local_variables_pass_data = {
107394 +#else
107395 +static struct gimple_opt_pass check_local_variables_pass = {
107396 + .pass = {
107397 +#endif
107398 + .type = GIMPLE_PASS,
107399 + .name = "check_local_variables",
107400 +#if BUILDING_GCC_VERSION >= 4008
107401 + .optinfo_flags = OPTGROUP_NONE,
107402 +#endif
107403 +#if BUILDING_GCC_VERSION >= 4009
107404 + .has_gate = false,
107405 + .has_execute = true,
107406 +#else
107407 + .gate = NULL,
107408 + .execute = check_local_variables,
107409 + .sub = NULL,
107410 + .next = NULL,
107411 + .static_pass_number = 0,
107412 +#endif
107413 + .tv_id = TV_NONE,
107414 + .properties_required = 0,
107415 + .properties_provided = 0,
107416 + .properties_destroyed = 0,
107417 + .todo_flags_start = 0,
107418 + .todo_flags_finish = 0
107419 +#if BUILDING_GCC_VERSION < 4009
107420 + }
107421 +#endif
107422 +};
107423 +
107424 +#if BUILDING_GCC_VERSION >= 4009
107425 +namespace {
107426 +class check_local_variables_pass : public gimple_opt_pass {
107427 +public:
107428 + check_local_variables_pass() : gimple_opt_pass(check_local_variables_pass_data, g) {}
107429 + unsigned int execute() { return check_local_variables(); }
107430 +};
107431 +}
107432 +
107433 +static opt_pass *make_check_local_variables_pass(void)
107434 +{
107435 + return new check_local_variables_pass();
107436 +}
107437 +#else
107438 +static struct opt_pass *make_check_local_variables_pass(void)
107439 +{
107440 + return &check_local_variables_pass.pass;
107441 +}
107442 +#endif
107443 +
107444 +static struct {
107445 + const char *name;
107446 + const char *asm_op;
107447 +} sections[] = {
107448 + {".init.rodata", "\t.section\t.init.rodata,\"a\""},
107449 + {".ref.rodata", "\t.section\t.ref.rodata,\"a\""},
107450 + {".devinit.rodata", "\t.section\t.devinit.rodata,\"a\""},
107451 + {".devexit.rodata", "\t.section\t.devexit.rodata,\"a\""},
107452 + {".cpuinit.rodata", "\t.section\t.cpuinit.rodata,\"a\""},
107453 + {".cpuexit.rodata", "\t.section\t.cpuexit.rodata,\"a\""},
107454 + {".meminit.rodata", "\t.section\t.meminit.rodata,\"a\""},
107455 + {".memexit.rodata", "\t.section\t.memexit.rodata,\"a\""},
107456 + {".data..read_only", "\t.section\t.data..read_only,\"a\""},
107457 +};
107458 +
107459 +static unsigned int (*old_section_type_flags)(tree decl, const char *name, int reloc);
107460 +
107461 +static unsigned int constify_section_type_flags(tree decl, const char *name, int reloc)
107462 +{
107463 + size_t i;
107464 +
107465 + for (i = 0; i < ARRAY_SIZE(sections); i++)
107466 + if (!strcmp(sections[i].name, name))
107467 + return 0;
107468 + return old_section_type_flags(decl, name, reloc);
107469 +}
107470 +
107471 +static void constify_start_unit(void *gcc_data, void *user_data)
107472 +{
107473 +// size_t i;
107474 +
107475 +// for (i = 0; i < ARRAY_SIZE(sections); i++)
107476 +// sections[i].section = get_unnamed_section(0, output_section_asm_op, sections[i].asm_op);
107477 +// sections[i].section = get_section(sections[i].name, 0, NULL);
107478 +
107479 + old_section_type_flags = targetm.section_type_flags;
107480 + targetm.section_type_flags = constify_section_type_flags;
107481 +}
107482 +
107483 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
107484 +{
107485 + const char * const plugin_name = plugin_info->base_name;
107486 + const int argc = plugin_info->argc;
107487 + const struct plugin_argument * const argv = plugin_info->argv;
107488 + int i;
107489 + bool constify = true;
107490 +
107491 + struct register_pass_info check_local_variables_pass_info;
107492 +
107493 + check_local_variables_pass_info.pass = make_check_local_variables_pass();
107494 + check_local_variables_pass_info.reference_pass_name = "ssa";
107495 + check_local_variables_pass_info.ref_pass_instance_number = 1;
107496 + check_local_variables_pass_info.pos_op = PASS_POS_INSERT_BEFORE;
107497 +
107498 + if (!plugin_default_version_check(version, &gcc_version)) {
107499 + error(G_("incompatible gcc/plugin versions"));
107500 + return 1;
107501 + }
107502 +
107503 + for (i = 0; i < argc; ++i) {
107504 + if (!(strcmp(argv[i].key, "no-constify"))) {
107505 + constify = false;
107506 + continue;
107507 + }
107508 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
107509 + }
107510 +
107511 + if (strcmp(lang_hooks.name, "GNU C")) {
107512 + inform(UNKNOWN_LOCATION, G_("%s supports C only"), plugin_name);
107513 + constify = false;
107514 + }
107515 +
107516 + register_callback(plugin_name, PLUGIN_INFO, NULL, &const_plugin_info);
107517 + if (constify) {
107518 + register_callback(plugin_name, PLUGIN_ALL_IPA_PASSES_START, check_global_variables, NULL);
107519 + register_callback(plugin_name, PLUGIN_FINISH_TYPE, finish_type, NULL);
107520 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &check_local_variables_pass_info);
107521 + register_callback(plugin_name, PLUGIN_START_UNIT, constify_start_unit, NULL);
107522 + }
107523 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
107524 +
107525 + return 0;
107526 +}
107527 diff --git a/tools/gcc/gcc-common.h b/tools/gcc/gcc-common.h
107528 new file mode 100644
107529 index 0000000..e90c205
107530 --- /dev/null
107531 +++ b/tools/gcc/gcc-common.h
107532 @@ -0,0 +1,295 @@
107533 +#ifndef GCC_COMMON_H_INCLUDED
107534 +#define GCC_COMMON_H_INCLUDED
107535 +
107536 +#include "plugin.h"
107537 +#include "bversion.h"
107538 +#include "plugin-version.h"
107539 +#include "config.h"
107540 +#include "system.h"
107541 +#include "coretypes.h"
107542 +#include "tm.h"
107543 +#include "line-map.h"
107544 +#include "input.h"
107545 +#include "tree.h"
107546 +
107547 +#include "tree-inline.h"
107548 +#include "version.h"
107549 +#include "rtl.h"
107550 +#include "tm_p.h"
107551 +#include "flags.h"
107552 +//#include "insn-attr.h"
107553 +//#include "insn-config.h"
107554 +//#include "insn-flags.h"
107555 +#include "hard-reg-set.h"
107556 +//#include "recog.h"
107557 +#include "output.h"
107558 +#include "except.h"
107559 +#include "function.h"
107560 +#include "toplev.h"
107561 +//#include "expr.h"
107562 +#include "basic-block.h"
107563 +#include "intl.h"
107564 +#include "ggc.h"
107565 +//#include "regs.h"
107566 +#include "timevar.h"
107567 +
107568 +#include "params.h"
107569 +#include "pointer-set.h"
107570 +#include "emit-rtl.h"
107571 +//#include "reload.h"
107572 +//#include "ira.h"
107573 +//#include "dwarf2asm.h"
107574 +#include "debug.h"
107575 +#include "target.h"
107576 +#include "langhooks.h"
107577 +#include "cfgloop.h"
107578 +//#include "hosthooks.h"
107579 +#include "cgraph.h"
107580 +#include "opts.h"
107581 +//#include "coverage.h"
107582 +//#include "value-prof.h"
107583 +
107584 +#if BUILDING_GCC_VERSION >= 4007
107585 +#include "tree-pretty-print.h"
107586 +#include "gimple-pretty-print.h"
107587 +#include "c-tree.h"
107588 +//#include "alloc-pool.h"
107589 +#endif
107590 +
107591 +#if BUILDING_GCC_VERSION <= 4008
107592 +#include "tree-flow.h"
107593 +#else
107594 +#include "tree-cfgcleanup.h"
107595 +#endif
107596 +
107597 +#include "diagnostic.h"
107598 +//#include "tree-diagnostic.h"
107599 +#include "tree-dump.h"
107600 +#include "tree-pass.h"
107601 +//#include "df.h"
107602 +#include "predict.h"
107603 +#include "ipa-utils.h"
107604 +
107605 +#if BUILDING_GCC_VERSION >= 4009
107606 +#include "varasm.h"
107607 +#include "stor-layout.h"
107608 +#include "internal-fn.h"
107609 +#include "gimple-expr.h"
107610 +//#include "diagnostic-color.h"
107611 +#include "context.h"
107612 +#include "tree-ssa-alias.h"
107613 +#include "stringpool.h"
107614 +#include "tree-ssanames.h"
107615 +#include "print-tree.h"
107616 +#include "tree-eh.h"
107617 +#include "stmt.h"
107618 +#endif
107619 +
107620 +#include "gimple.h"
107621 +
107622 +#if BUILDING_GCC_VERSION >= 4009
107623 +#include "tree-ssa-operands.h"
107624 +#include "tree-phinodes.h"
107625 +#include "tree-cfg.h"
107626 +#include "gimple-iterator.h"
107627 +#include "gimple-ssa.h"
107628 +#include "ssa-iterators.h"
107629 +#endif
107630 +
107631 +//#include "lto/lto.h"
107632 +//#include "data-streamer.h"
107633 +//#include "lto-compress.h"
107634 +
107635 +//#include "expr.h" where are you...
107636 +extern rtx emit_move_insn(rtx x, rtx y);
107637 +
107638 +// missing from basic_block.h...
107639 +extern void debug_dominance_info(enum cdi_direction dir);
107640 +extern void debug_dominance_tree(enum cdi_direction dir, basic_block root);
107641 +
107642 +#define __unused __attribute__((__unused__))
107643 +
107644 +#define DECL_NAME_POINTER(node) IDENTIFIER_POINTER(DECL_NAME(node))
107645 +#define DECL_NAME_LENGTH(node) IDENTIFIER_LENGTH(DECL_NAME(node))
107646 +#define TYPE_NAME_POINTER(node) IDENTIFIER_POINTER(TYPE_NAME(node))
107647 +#define TYPE_NAME_LENGTH(node) IDENTIFIER_LENGTH(TYPE_NAME(node))
107648 +
107649 +#if BUILDING_GCC_VERSION == 4005
107650 +#define FOR_EACH_LOCAL_DECL(FUN, I, D) for (tree vars = (FUN)->local_decls; vars && (D = TREE_VALUE(vars)); vars = TREE_CHAIN(vars), I)
107651 +#define DECL_CHAIN(NODE) (TREE_CHAIN(DECL_MINIMAL_CHECK(NODE)))
107652 +#define FOR_EACH_VEC_ELT(T, V, I, P) for (I = 0; VEC_iterate(T, (V), (I), (P)); ++(I))
107653 +#define TODO_rebuild_cgraph_edges 0
107654 +
107655 +static inline bool gimple_call_builtin_p(gimple stmt, enum built_in_function code)
107656 +{
107657 + tree fndecl;
107658 +
107659 + if (!is_gimple_call(stmt))
107660 + return false;
107661 + fndecl = gimple_call_fndecl(stmt);
107662 + if (!fndecl || DECL_BUILT_IN_CLASS(fndecl) != BUILT_IN_NORMAL)
107663 + return false;
107664 +// print_node(stderr, "pax", fndecl, 4);
107665 + return DECL_FUNCTION_CODE(fndecl) == code;
107666 +}
107667 +
107668 +static inline bool is_simple_builtin(tree decl)
107669 +{
107670 + if (decl && DECL_BUILT_IN_CLASS(decl) != BUILT_IN_NORMAL)
107671 + return false;
107672 +
107673 + switch (DECL_FUNCTION_CODE(decl)) {
107674 + /* Builtins that expand to constants. */
107675 + case BUILT_IN_CONSTANT_P:
107676 + case BUILT_IN_EXPECT:
107677 + case BUILT_IN_OBJECT_SIZE:
107678 + case BUILT_IN_UNREACHABLE:
107679 + /* Simple register moves or loads from stack. */
107680 + case BUILT_IN_RETURN_ADDRESS:
107681 + case BUILT_IN_EXTRACT_RETURN_ADDR:
107682 + case BUILT_IN_FROB_RETURN_ADDR:
107683 + case BUILT_IN_RETURN:
107684 + case BUILT_IN_AGGREGATE_INCOMING_ADDRESS:
107685 + case BUILT_IN_FRAME_ADDRESS:
107686 + case BUILT_IN_VA_END:
107687 + case BUILT_IN_STACK_SAVE:
107688 + case BUILT_IN_STACK_RESTORE:
107689 + /* Exception state returns or moves registers around. */
107690 + case BUILT_IN_EH_FILTER:
107691 + case BUILT_IN_EH_POINTER:
107692 + case BUILT_IN_EH_COPY_VALUES:
107693 + return true;
107694 +
107695 + default:
107696 + return false;
107697 + }
107698 +}
107699 +#endif
107700 +
107701 +#if BUILDING_GCC_VERSION <= 4006
107702 +#define ANY_RETURN_P(rtx) (GET_CODE(rtx) == RETURN)
107703 +#define C_DECL_REGISTER(EXP) DECL_LANG_FLAG_4(EXP)
107704 +
107705 +// should come from c-tree.h if only it were installed for gcc 4.5...
107706 +#define C_TYPE_FIELDS_READONLY(TYPE) TREE_LANG_FLAG_1(TYPE)
107707 +
107708 +#define get_random_seed(noinit) ({ \
107709 + unsigned HOST_WIDE_INT seed; \
107710 + sscanf(get_random_seed(noinit), "%" HOST_WIDE_INT_PRINT "x", &seed); \
107711 + seed * seed; })
107712 +
107713 +static inline bool gimple_clobber_p(gimple s)
107714 +{
107715 + return false;
107716 +}
107717 +
107718 +static inline tree builtin_decl_implicit(enum built_in_function fncode)
107719 +{
107720 + return implicit_built_in_decls[fncode];
107721 +}
107722 +
107723 +static inline struct cgraph_node *cgraph_get_create_node(tree decl)
107724 +{
107725 + struct cgraph_node *node = cgraph_get_node(decl);
107726 +
107727 + return node ? node : cgraph_node(decl);
107728 +}
107729 +
107730 +static inline bool cgraph_function_with_gimple_body_p(struct cgraph_node *node)
107731 +{
107732 + return node->analyzed && !node->thunk.thunk_p && !node->alias;
107733 +}
107734 +
107735 +static inline struct cgraph_node *cgraph_first_function_with_gimple_body(void)
107736 +{
107737 + struct cgraph_node *node;
107738 +
107739 + for (node = cgraph_nodes; node; node = node->next)
107740 + if (cgraph_function_with_gimple_body_p(node))
107741 + return node;
107742 + return NULL;
107743 +}
107744 +
107745 +static inline struct cgraph_node *cgraph_next_function_with_gimple_body(struct cgraph_node *node)
107746 +{
107747 + for (node = node->next; node; node = node->next)
107748 + if (cgraph_function_with_gimple_body_p(node))
107749 + return node;
107750 + return NULL;
107751 +}
107752 +
107753 +#define FOR_EACH_FUNCTION_WITH_GIMPLE_BODY(node) \
107754 + for ((node) = cgraph_first_function_with_gimple_body(); (node); \
107755 + (node) = cgraph_next_function_with_gimple_body(node))
107756 +#endif
107757 +
107758 +#if BUILDING_GCC_VERSION == 4006
107759 +extern void debug_gimple_stmt(gimple);
107760 +extern void debug_gimple_seq(gimple_seq);
107761 +extern void print_gimple_seq(FILE *, gimple_seq, int, int);
107762 +extern void print_gimple_stmt(FILE *, gimple, int, int);
107763 +extern void print_gimple_expr(FILE *, gimple, int, int);
107764 +extern void dump_gimple_stmt(pretty_printer *, gimple, int, int);
107765 +#endif
107766 +
107767 +#if BUILDING_GCC_VERSION <= 4007
107768 +#define FOR_EACH_VARIABLE(node) for (node = varpool_nodes; node; node = node->next)
107769 +#define PROP_loops 0
107770 +
107771 +static inline int bb_loop_depth(const_basic_block bb)
107772 +{
107773 + return bb->loop_father ? loop_depth(bb->loop_father) : 0;
107774 +}
107775 +
107776 +static inline bool gimple_store_p(gimple gs)
107777 +{
107778 + tree lhs = gimple_get_lhs(gs);
107779 + return lhs && !is_gimple_reg(lhs);
107780 +}
107781 +#endif
107782 +
107783 +#if BUILDING_GCC_VERSION >= 4007
107784 +#define cgraph_create_edge(caller, callee, call_stmt, count, freq, nest) \
107785 + cgraph_create_edge((caller), (callee), (call_stmt), (count), (freq))
107786 +#define cgraph_create_edge_including_clones(caller, callee, old_call_stmt, call_stmt, count, freq, nest, reason) \
107787 + cgraph_create_edge_including_clones((caller), (callee), (old_call_stmt), (call_stmt), (count), (freq), (reason))
107788 +#endif
107789 +
107790 +#if BUILDING_GCC_VERSION <= 4008
107791 +#define ENTRY_BLOCK_PTR_FOR_FN(FN) ENTRY_BLOCK_PTR_FOR_FUNCTION(FN)
107792 +#define EXIT_BLOCK_PTR_FOR_FN(FN) EXIT_BLOCK_PTR_FOR_FUNCTION(FN)
107793 +#define basic_block_info_for_fn(FN) ((FN)->cfg->x_basic_block_info)
107794 +#define n_basic_blocks_for_fn(FN) ((FN)->cfg->x_n_basic_blocks)
107795 +#define n_edges_for_fn(FN) ((FN)->cfg->x_n_edges)
107796 +#define last_basic_block_for_fn(FN) ((FN)->cfg->x_last_basic_block)
107797 +#define label_to_block_map_for_fn(FN) ((FN)->cfg->x_label_to_block_map)
107798 +#define profile_status_for_fn(FN) ((FN)->cfg->x_profile_status)
107799 +
107800 +static inline const char *get_tree_code_name(enum tree_code code)
107801 +{
107802 + gcc_assert(code < MAX_TREE_CODES);
107803 + return tree_code_name[code];
107804 +}
107805 +
107806 +#define ipa_remove_stmt_references(cnode, stmt)
107807 +#endif
107808 +
107809 +#if BUILDING_GCC_VERSION == 4008
107810 +#define NODE_DECL(node) node->symbol.decl
107811 +#else
107812 +#define NODE_DECL(node) node->decl
107813 +#endif
107814 +
107815 +#if BUILDING_GCC_VERSION >= 4008
107816 +#define add_referenced_var(var)
107817 +#define mark_sym_for_renaming(var)
107818 +#define varpool_mark_needed_node(node)
107819 +#define TODO_dump_func 0
107820 +#define TODO_dump_cgraph 0
107821 +#endif
107822 +
107823 +#if BUILDING_GCC_VERSION >= 4009
107824 +#define TODO_ggc_collect 0
107825 +#endif
107826 +
107827 +#endif
107828 diff --git a/tools/gcc/gen-random-seed.sh b/tools/gcc/gen-random-seed.sh
107829 new file mode 100644
107830 index 0000000..7514850
107831 --- /dev/null
107832 +++ b/tools/gcc/gen-random-seed.sh
107833 @@ -0,0 +1,8 @@
107834 +#!/bin/sh
107835 +
107836 +if [ ! -f "$1" ]; then
107837 + SEED=`od -A n -t x8 -N 32 /dev/urandom | tr -d ' \n'`
107838 + echo "const char *randstruct_seed = \"$SEED\";" > "$1"
107839 + HASH=`echo -n "$SEED" | sha256sum | cut -d" " -f1 | tr -d ' \n'`
107840 + echo "#define RANDSTRUCT_HASHED_SEED \"$HASH\"" > "$2"
107841 +fi
107842 diff --git a/tools/gcc/kallocstat_plugin.c b/tools/gcc/kallocstat_plugin.c
107843 new file mode 100644
107844 index 0000000..d81c094
107845 --- /dev/null
107846 +++ b/tools/gcc/kallocstat_plugin.c
107847 @@ -0,0 +1,183 @@
107848 +/*
107849 + * Copyright 2011-2014 by the PaX Team <pageexec@freemail.hu>
107850 + * Licensed under the GPL v2
107851 + *
107852 + * Note: the choice of the license means that the compilation process is
107853 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
107854 + * but for the kernel it doesn't matter since it doesn't link against
107855 + * any of the gcc libraries
107856 + *
107857 + * gcc plugin to find the distribution of k*alloc sizes
107858 + *
107859 + * TODO:
107860 + *
107861 + * BUGS:
107862 + * - none known
107863 + */
107864 +
107865 +#include "gcc-common.h"
107866 +
107867 +int plugin_is_GPL_compatible;
107868 +
107869 +static struct plugin_info kallocstat_plugin_info = {
107870 + .version = "201401260140",
107871 + .help = NULL
107872 +};
107873 +
107874 +static const char * const kalloc_functions[] = {
107875 + "__kmalloc",
107876 + "kmalloc",
107877 + "kmalloc_large",
107878 + "kmalloc_node",
107879 + "kmalloc_order",
107880 + "kmalloc_order_trace",
107881 + "kmalloc_slab",
107882 + "kzalloc",
107883 + "kzalloc_node",
107884 +};
107885 +
107886 +static bool is_kalloc(const char *fnname)
107887 +{
107888 + size_t i;
107889 +
107890 + for (i = 0; i < ARRAY_SIZE(kalloc_functions); i++)
107891 + if (!strcmp(fnname, kalloc_functions[i]))
107892 + return true;
107893 + return false;
107894 +}
107895 +
107896 +static unsigned int execute_kallocstat(void)
107897 +{
107898 + basic_block bb;
107899 +
107900 + // 1. loop through BBs and GIMPLE statements
107901 + FOR_EACH_BB_FN(bb, cfun) {
107902 + gimple_stmt_iterator gsi;
107903 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
107904 + // gimple match:
107905 + tree fndecl, size;
107906 + gimple stmt;
107907 + const char *fnname;
107908 +
107909 + // is it a call
107910 + stmt = gsi_stmt(gsi);
107911 + if (!is_gimple_call(stmt))
107912 + continue;
107913 + fndecl = gimple_call_fndecl(stmt);
107914 + if (fndecl == NULL_TREE)
107915 + continue;
107916 + if (TREE_CODE(fndecl) != FUNCTION_DECL)
107917 + continue;
107918 +
107919 + // is it a call to k*alloc
107920 + fnname = DECL_NAME_POINTER(fndecl);
107921 + if (!is_kalloc(fnname))
107922 + continue;
107923 +
107924 + // is the size arg const or the result of a simple const assignment
107925 + size = gimple_call_arg(stmt, 0);
107926 + while (true) {
107927 + expanded_location xloc;
107928 + size_t size_val;
107929 +
107930 + if (TREE_CONSTANT(size)) {
107931 + xloc = expand_location(gimple_location(stmt));
107932 + if (!xloc.file)
107933 + xloc = expand_location(DECL_SOURCE_LOCATION(current_function_decl));
107934 + size_val = TREE_INT_CST_LOW(size);
107935 + fprintf(stderr, "kallocsize: %8zu %8zx %s %s:%u\n", size_val, size_val, fnname, xloc.file, xloc.line);
107936 + break;
107937 + }
107938 +
107939 + if (TREE_CODE(size) != SSA_NAME)
107940 + break;
107941 + stmt = SSA_NAME_DEF_STMT(size);
107942 +//debug_gimple_stmt(stmt);
107943 +//debug_tree(size);
107944 + if (!stmt || !is_gimple_assign(stmt))
107945 + break;
107946 + if (gimple_num_ops(stmt) != 2)
107947 + break;
107948 + size = gimple_assign_rhs1(stmt);
107949 + }
107950 +//print_gimple_stmt(stderr, call_stmt, 0, TDF_LINENO);
107951 +//debug_tree(gimple_call_fn(call_stmt));
107952 +//print_node(stderr, "pax", fndecl, 4);
107953 + }
107954 + }
107955 +
107956 + return 0;
107957 +}
107958 +
107959 +#if BUILDING_GCC_VERSION >= 4009
107960 +static const struct pass_data kallocstat_pass_data = {
107961 +#else
107962 +static struct gimple_opt_pass kallocstat_pass = {
107963 + .pass = {
107964 +#endif
107965 + .type = GIMPLE_PASS,
107966 + .name = "kallocstat",
107967 +#if BUILDING_GCC_VERSION >= 4008
107968 + .optinfo_flags = OPTGROUP_NONE,
107969 +#endif
107970 +#if BUILDING_GCC_VERSION >= 4009
107971 + .has_gate = false,
107972 + .has_execute = true,
107973 +#else
107974 + .gate = NULL,
107975 + .execute = execute_kallocstat,
107976 + .sub = NULL,
107977 + .next = NULL,
107978 + .static_pass_number = 0,
107979 +#endif
107980 + .tv_id = TV_NONE,
107981 + .properties_required = 0,
107982 + .properties_provided = 0,
107983 + .properties_destroyed = 0,
107984 + .todo_flags_start = 0,
107985 + .todo_flags_finish = 0
107986 +#if BUILDING_GCC_VERSION < 4009
107987 + }
107988 +#endif
107989 +};
107990 +
107991 +#if BUILDING_GCC_VERSION >= 4009
107992 +namespace {
107993 +class kallocstat_pass : public gimple_opt_pass {
107994 +public:
107995 + kallocstat_pass() : gimple_opt_pass(kallocstat_pass_data, g) {}
107996 + unsigned int execute() { return execute_kallocstat(); }
107997 +};
107998 +}
107999 +
108000 +static opt_pass *make_kallocstat_pass(void)
108001 +{
108002 + return new kallocstat_pass();
108003 +}
108004 +#else
108005 +static struct opt_pass *make_kallocstat_pass(void)
108006 +{
108007 + return &kallocstat_pass.pass;
108008 +}
108009 +#endif
108010 +
108011 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
108012 +{
108013 + const char * const plugin_name = plugin_info->base_name;
108014 + struct register_pass_info kallocstat_pass_info;
108015 +
108016 + kallocstat_pass_info.pass = make_kallocstat_pass();
108017 + kallocstat_pass_info.reference_pass_name = "ssa";
108018 + kallocstat_pass_info.ref_pass_instance_number = 1;
108019 + kallocstat_pass_info.pos_op = PASS_POS_INSERT_AFTER;
108020 +
108021 + if (!plugin_default_version_check(version, &gcc_version)) {
108022 + error(G_("incompatible gcc/plugin versions"));
108023 + return 1;
108024 + }
108025 +
108026 + register_callback(plugin_name, PLUGIN_INFO, NULL, &kallocstat_plugin_info);
108027 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kallocstat_pass_info);
108028 +
108029 + return 0;
108030 +}
108031 diff --git a/tools/gcc/kernexec_plugin.c b/tools/gcc/kernexec_plugin.c
108032 new file mode 100644
108033 index 0000000..89f256d
108034 --- /dev/null
108035 +++ b/tools/gcc/kernexec_plugin.c
108036 @@ -0,0 +1,522 @@
108037 +/*
108038 + * Copyright 2011-2014 by the PaX Team <pageexec@freemail.hu>
108039 + * Licensed under the GPL v2
108040 + *
108041 + * Note: the choice of the license means that the compilation process is
108042 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
108043 + * but for the kernel it doesn't matter since it doesn't link against
108044 + * any of the gcc libraries
108045 + *
108046 + * gcc plugin to make KERNEXEC/amd64 almost as good as it is on i386
108047 + *
108048 + * TODO:
108049 + *
108050 + * BUGS:
108051 + * - none known
108052 + */
108053 +
108054 +#include "gcc-common.h"
108055 +
108056 +int plugin_is_GPL_compatible;
108057 +
108058 +static struct plugin_info kernexec_plugin_info = {
108059 + .version = "201401260140",
108060 + .help = "method=[bts|or]\tinstrumentation method\n"
108061 +};
108062 +
108063 +static void (*kernexec_instrument_fptr)(gimple_stmt_iterator *);
108064 +static void (*kernexec_instrument_retaddr)(rtx);
108065 +
108066 +/*
108067 + * add special KERNEXEC instrumentation: reload %r12 after it has been clobbered
108068 + */
108069 +static void kernexec_reload_fptr_mask(gimple_stmt_iterator *gsi)
108070 +{
108071 + gimple asm_movabs_stmt;
108072 +
108073 + // build asm volatile("movabs $0x8000000000000000, %%r12\n\t" : : : );
108074 + asm_movabs_stmt = gimple_build_asm_vec("movabs $0x8000000000000000, %%r12\n\t", NULL, NULL, NULL, NULL);
108075 + gimple_asm_set_volatile(asm_movabs_stmt, true);
108076 + gsi_insert_after(gsi, asm_movabs_stmt, GSI_CONTINUE_LINKING);
108077 + update_stmt(asm_movabs_stmt);
108078 +}
108079 +
108080 +/*
108081 + * find all asm() stmts that clobber r12 and add a reload of r12
108082 + */
108083 +static unsigned int execute_kernexec_reload(void)
108084 +{
108085 + basic_block bb;
108086 +
108087 + // 1. loop through BBs and GIMPLE statements
108088 + FOR_EACH_BB_FN(bb, cfun) {
108089 + gimple_stmt_iterator gsi;
108090 +
108091 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
108092 + // gimple match: __asm__ ("" : : : "r12");
108093 + gimple asm_stmt;
108094 + size_t nclobbers;
108095 +
108096 + // is it an asm ...
108097 + asm_stmt = gsi_stmt(gsi);
108098 + if (gimple_code(asm_stmt) != GIMPLE_ASM)
108099 + continue;
108100 +
108101 + // ... clobbering r12
108102 + nclobbers = gimple_asm_nclobbers(asm_stmt);
108103 + while (nclobbers--) {
108104 + tree op = gimple_asm_clobber_op(asm_stmt, nclobbers);
108105 + if (strcmp(TREE_STRING_POINTER(TREE_VALUE(op)), "r12"))
108106 + continue;
108107 + kernexec_reload_fptr_mask(&gsi);
108108 +//print_gimple_stmt(stderr, asm_stmt, 0, TDF_LINENO);
108109 + break;
108110 + }
108111 + }
108112 + }
108113 +
108114 + return 0;
108115 +}
108116 +
108117 +/*
108118 + * add special KERNEXEC instrumentation: force MSB of fptr to 1, which will produce
108119 + * a non-canonical address from a userland ptr and will just trigger a GPF on dereference
108120 + */
108121 +static void kernexec_instrument_fptr_bts(gimple_stmt_iterator *gsi)
108122 +{
108123 + gimple assign_intptr, assign_new_fptr, call_stmt;
108124 + tree intptr, orptr, old_fptr, new_fptr, kernexec_mask;
108125 +
108126 + call_stmt = gsi_stmt(*gsi);
108127 + old_fptr = gimple_call_fn(call_stmt);
108128 +
108129 + // create temporary unsigned long variable used for bitops and cast fptr to it
108130 + intptr = create_tmp_var(long_unsigned_type_node, "kernexec_bts");
108131 + add_referenced_var(intptr);
108132 + intptr = make_ssa_name(intptr, NULL);
108133 + assign_intptr = gimple_build_assign(intptr, fold_convert(long_unsigned_type_node, old_fptr));
108134 + SSA_NAME_DEF_STMT(intptr) = assign_intptr;
108135 + gsi_insert_before(gsi, assign_intptr, GSI_SAME_STMT);
108136 + update_stmt(assign_intptr);
108137 +
108138 + // apply logical or to temporary unsigned long and bitmask
108139 + kernexec_mask = build_int_cstu(long_long_unsigned_type_node, 0x8000000000000000LL);
108140 +// kernexec_mask = build_int_cstu(long_long_unsigned_type_node, 0xffffffff80000000LL);
108141 + orptr = fold_build2(BIT_IOR_EXPR, long_long_unsigned_type_node, intptr, kernexec_mask);
108142 + intptr = make_ssa_name(SSA_NAME_VAR(intptr), NULL);
108143 + assign_intptr = gimple_build_assign(intptr, orptr);
108144 + SSA_NAME_DEF_STMT(intptr) = assign_intptr;
108145 + gsi_insert_before(gsi, assign_intptr, GSI_SAME_STMT);
108146 + update_stmt(assign_intptr);
108147 +
108148 + // cast temporary unsigned long back to a temporary fptr variable
108149 + new_fptr = create_tmp_var(TREE_TYPE(old_fptr), "kernexec_fptr");
108150 + add_referenced_var(new_fptr);
108151 + new_fptr = make_ssa_name(new_fptr, NULL);
108152 + assign_new_fptr = gimple_build_assign(new_fptr, fold_convert(TREE_TYPE(old_fptr), intptr));
108153 + SSA_NAME_DEF_STMT(new_fptr) = assign_new_fptr;
108154 + gsi_insert_before(gsi, assign_new_fptr, GSI_SAME_STMT);
108155 + update_stmt(assign_new_fptr);
108156 +
108157 + // replace call stmt fn with the new fptr
108158 + gimple_call_set_fn(call_stmt, new_fptr);
108159 + update_stmt(call_stmt);
108160 +}
108161 +
108162 +static void kernexec_instrument_fptr_or(gimple_stmt_iterator *gsi)
108163 +{
108164 + gimple asm_or_stmt, call_stmt;
108165 + tree old_fptr, new_fptr, input, output;
108166 +#if BUILDING_GCC_VERSION <= 4007
108167 + VEC(tree, gc) *inputs = NULL;
108168 + VEC(tree, gc) *outputs = NULL;
108169 +#else
108170 + vec<tree, va_gc> *inputs = NULL;
108171 + vec<tree, va_gc> *outputs = NULL;
108172 +#endif
108173 +
108174 + call_stmt = gsi_stmt(*gsi);
108175 + old_fptr = gimple_call_fn(call_stmt);
108176 +
108177 + // create temporary fptr variable
108178 + new_fptr = create_tmp_var(TREE_TYPE(old_fptr), "kernexec_or");
108179 + add_referenced_var(new_fptr);
108180 + new_fptr = make_ssa_name(new_fptr, NULL);
108181 +
108182 + // build asm volatile("orq %%r12, %0\n\t" : "=r"(new_fptr) : "0"(old_fptr));
108183 + input = build_tree_list(NULL_TREE, build_string(1, "0"));
108184 + input = chainon(NULL_TREE, build_tree_list(input, old_fptr));
108185 + output = build_tree_list(NULL_TREE, build_string(2, "=r"));
108186 + output = chainon(NULL_TREE, build_tree_list(output, new_fptr));
108187 +#if BUILDING_GCC_VERSION <= 4007
108188 + VEC_safe_push(tree, gc, inputs, input);
108189 + VEC_safe_push(tree, gc, outputs, output);
108190 +#else
108191 + vec_safe_push(inputs, input);
108192 + vec_safe_push(outputs, output);
108193 +#endif
108194 + asm_or_stmt = gimple_build_asm_vec("orq %%r12, %0\n\t", inputs, outputs, NULL, NULL);
108195 + SSA_NAME_DEF_STMT(new_fptr) = asm_or_stmt;
108196 + gimple_asm_set_volatile(asm_or_stmt, true);
108197 + gsi_insert_before(gsi, asm_or_stmt, GSI_SAME_STMT);
108198 + update_stmt(asm_or_stmt);
108199 +
108200 + // replace call stmt fn with the new fptr
108201 + gimple_call_set_fn(call_stmt, new_fptr);
108202 + update_stmt(call_stmt);
108203 +}
108204 +
108205 +/*
108206 + * find all C level function pointer dereferences and forcibly set the highest bit of the pointer
108207 + */
108208 +static unsigned int execute_kernexec_fptr(void)
108209 +{
108210 + basic_block bb;
108211 +
108212 + // 1. loop through BBs and GIMPLE statements
108213 + FOR_EACH_BB_FN(bb, cfun) {
108214 + gimple_stmt_iterator gsi;
108215 +
108216 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
108217 + // gimple match: h_1 = get_fptr (); D.2709_3 = h_1 (x_2(D));
108218 + tree fn;
108219 + gimple call_stmt;
108220 +
108221 + // is it a call ...
108222 + call_stmt = gsi_stmt(gsi);
108223 + if (!is_gimple_call(call_stmt))
108224 + continue;
108225 + fn = gimple_call_fn(call_stmt);
108226 + if (TREE_CODE(fn) == ADDR_EXPR)
108227 + continue;
108228 + if (TREE_CODE(fn) != SSA_NAME)
108229 + gcc_unreachable();
108230 +
108231 + // ... through a function pointer
108232 + if (SSA_NAME_VAR(fn) != NULL_TREE) {
108233 + fn = SSA_NAME_VAR(fn);
108234 + if (TREE_CODE(fn) != VAR_DECL && TREE_CODE(fn) != PARM_DECL) {
108235 + debug_tree(fn);
108236 + gcc_unreachable();
108237 + }
108238 + }
108239 + fn = TREE_TYPE(fn);
108240 + if (TREE_CODE(fn) != POINTER_TYPE)
108241 + continue;
108242 + fn = TREE_TYPE(fn);
108243 + if (TREE_CODE(fn) != FUNCTION_TYPE)
108244 + continue;
108245 +
108246 + kernexec_instrument_fptr(&gsi);
108247 +
108248 +//debug_tree(gimple_call_fn(call_stmt));
108249 +//print_gimple_stmt(stderr, call_stmt, 0, TDF_LINENO);
108250 + }
108251 + }
108252 +
108253 + return 0;
108254 +}
108255 +
108256 +// add special KERNEXEC instrumentation: btsq $63,(%rsp) just before retn
108257 +static void kernexec_instrument_retaddr_bts(rtx insn)
108258 +{
108259 + rtx btsq;
108260 + rtvec argvec, constraintvec, labelvec;
108261 + int line;
108262 +
108263 + // create asm volatile("btsq $63,(%%rsp)":::)
108264 + argvec = rtvec_alloc(0);
108265 + constraintvec = rtvec_alloc(0);
108266 + labelvec = rtvec_alloc(0);
108267 + line = expand_location(RTL_LOCATION(insn)).line;
108268 + btsq = gen_rtx_ASM_OPERANDS(VOIDmode, "btsq $63,(%%rsp)", empty_string, 0, argvec, constraintvec, labelvec, line);
108269 + MEM_VOLATILE_P(btsq) = 1;
108270 +// RTX_FRAME_RELATED_P(btsq) = 1; // not for ASM_OPERANDS
108271 + emit_insn_before(btsq, insn);
108272 +}
108273 +
108274 +// add special KERNEXEC instrumentation: orq %r12,(%rsp) just before retn
108275 +static void kernexec_instrument_retaddr_or(rtx insn)
108276 +{
108277 + rtx orq;
108278 + rtvec argvec, constraintvec, labelvec;
108279 + int line;
108280 +
108281 + // create asm volatile("orq %%r12,(%%rsp)":::)
108282 + argvec = rtvec_alloc(0);
108283 + constraintvec = rtvec_alloc(0);
108284 + labelvec = rtvec_alloc(0);
108285 + line = expand_location(RTL_LOCATION(insn)).line;
108286 + orq = gen_rtx_ASM_OPERANDS(VOIDmode, "orq %%r12,(%%rsp)", empty_string, 0, argvec, constraintvec, labelvec, line);
108287 + MEM_VOLATILE_P(orq) = 1;
108288 +// RTX_FRAME_RELATED_P(orq) = 1; // not for ASM_OPERANDS
108289 + emit_insn_before(orq, insn);
108290 +}
108291 +
108292 +/*
108293 + * find all asm level function returns and forcibly set the highest bit of the return address
108294 + */
108295 +static unsigned int execute_kernexec_retaddr(void)
108296 +{
108297 + rtx insn;
108298 +
108299 +// if (stack_realign_drap)
108300 +// inform(DECL_SOURCE_LOCATION(current_function_decl), "drap detected in %s\n", IDENTIFIER_POINTER(DECL_NAME(current_function_decl)));
108301 +
108302 + // 1. find function returns
108303 + for (insn = get_insns(); insn; insn = NEXT_INSN(insn)) {
108304 + // rtl match: (jump_insn 41 40 42 2 (return) fptr.c:42 634 {return_internal} (nil))
108305 + // (jump_insn 12 9 11 2 (parallel [ (return) (unspec [ (0) ] UNSPEC_REP) ]) fptr.c:46 635 {return_internal_long} (nil))
108306 + // (jump_insn 97 96 98 6 (simple_return) fptr.c:50 -1 (nil) -> simple_return)
108307 + rtx body;
108308 +
108309 + // is it a retn
108310 + if (!JUMP_P(insn))
108311 + continue;
108312 + body = PATTERN(insn);
108313 + if (GET_CODE(body) == PARALLEL)
108314 + body = XVECEXP(body, 0, 0);
108315 + if (!ANY_RETURN_P(body))
108316 + continue;
108317 + kernexec_instrument_retaddr(insn);
108318 + }
108319 +
108320 +// print_simple_rtl(stderr, get_insns());
108321 +// print_rtl(stderr, get_insns());
108322 +
108323 + return 0;
108324 +}
108325 +
108326 +static bool kernexec_cmodel_check(void)
108327 +{
108328 + tree section;
108329 +
108330 + if (ix86_cmodel != CM_KERNEL)
108331 + return false;
108332 +
108333 + section = lookup_attribute("section", DECL_ATTRIBUTES(current_function_decl));
108334 + if (!section || !TREE_VALUE(section))
108335 + return true;
108336 +
108337 + section = TREE_VALUE(TREE_VALUE(section));
108338 + if (strncmp(TREE_STRING_POINTER(section), ".vsyscall_", 10))
108339 + return true;
108340 +
108341 + return false;
108342 +}
108343 +
108344 +#if BUILDING_GCC_VERSION >= 4009
108345 +static const struct pass_data kernexec_reload_pass_data = {
108346 +#else
108347 +static struct gimple_opt_pass kernexec_reload_pass = {
108348 + .pass = {
108349 +#endif
108350 + .type = GIMPLE_PASS,
108351 + .name = "kernexec_reload",
108352 +#if BUILDING_GCC_VERSION >= 4008
108353 + .optinfo_flags = OPTGROUP_NONE,
108354 +#endif
108355 +#if BUILDING_GCC_VERSION >= 4009
108356 + .has_gate = true,
108357 + .has_execute = true,
108358 +#else
108359 + .gate = kernexec_cmodel_check,
108360 + .execute = execute_kernexec_reload,
108361 + .sub = NULL,
108362 + .next = NULL,
108363 + .static_pass_number = 0,
108364 +#endif
108365 + .tv_id = TV_NONE,
108366 + .properties_required = 0,
108367 + .properties_provided = 0,
108368 + .properties_destroyed = 0,
108369 + .todo_flags_start = 0,
108370 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_remove_unused_locals | TODO_update_ssa_no_phi
108371 +#if BUILDING_GCC_VERSION < 4009
108372 + }
108373 +#endif
108374 +};
108375 +
108376 +#if BUILDING_GCC_VERSION >= 4009
108377 +static const struct pass_data kernexec_fptr_pass_data = {
108378 +#else
108379 +static struct gimple_opt_pass kernexec_fptr_pass = {
108380 + .pass = {
108381 +#endif
108382 + .type = GIMPLE_PASS,
108383 + .name = "kernexec_fptr",
108384 +#if BUILDING_GCC_VERSION >= 4008
108385 + .optinfo_flags = OPTGROUP_NONE,
108386 +#endif
108387 +#if BUILDING_GCC_VERSION >= 4009
108388 + .has_gate = true,
108389 + .has_execute = true,
108390 +#else
108391 + .gate = kernexec_cmodel_check,
108392 + .execute = execute_kernexec_fptr,
108393 + .sub = NULL,
108394 + .next = NULL,
108395 + .static_pass_number = 0,
108396 +#endif
108397 + .tv_id = TV_NONE,
108398 + .properties_required = 0,
108399 + .properties_provided = 0,
108400 + .properties_destroyed = 0,
108401 + .todo_flags_start = 0,
108402 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_remove_unused_locals | TODO_update_ssa_no_phi
108403 +#if BUILDING_GCC_VERSION < 4009
108404 + }
108405 +#endif
108406 +};
108407 +
108408 +#if BUILDING_GCC_VERSION >= 4009
108409 +static const struct pass_data kernexec_retaddr_pass_data = {
108410 +#else
108411 +static struct rtl_opt_pass kernexec_retaddr_pass = {
108412 + .pass = {
108413 +#endif
108414 + .type = RTL_PASS,
108415 + .name = "kernexec_retaddr",
108416 +#if BUILDING_GCC_VERSION >= 4008
108417 + .optinfo_flags = OPTGROUP_NONE,
108418 +#endif
108419 +#if BUILDING_GCC_VERSION >= 4009
108420 + .has_gate = true,
108421 + .has_execute = true,
108422 +#else
108423 + .gate = kernexec_cmodel_check,
108424 + .execute = execute_kernexec_retaddr,
108425 + .sub = NULL,
108426 + .next = NULL,
108427 + .static_pass_number = 0,
108428 +#endif
108429 + .tv_id = TV_NONE,
108430 + .properties_required = 0,
108431 + .properties_provided = 0,
108432 + .properties_destroyed = 0,
108433 + .todo_flags_start = 0,
108434 + .todo_flags_finish = TODO_dump_func | TODO_ggc_collect
108435 +#if BUILDING_GCC_VERSION < 4009
108436 + }
108437 +#endif
108438 +};
108439 +
108440 +#if BUILDING_GCC_VERSION >= 4009
108441 +namespace {
108442 +class kernexec_reload_pass : public gimple_opt_pass {
108443 +public:
108444 + kernexec_reload_pass() : gimple_opt_pass(kernexec_reload_pass_data, g) {}
108445 + bool gate() { return kernexec_cmodel_check(); }
108446 + unsigned int execute() { return execute_kernexec_reload(); }
108447 +};
108448 +
108449 +class kernexec_fptr_pass : public gimple_opt_pass {
108450 +public:
108451 + kernexec_fptr_pass() : gimple_opt_pass(kernexec_fptr_pass_data, g) {}
108452 + bool gate() { return kernexec_cmodel_check(); }
108453 + unsigned int execute() { return execute_kernexec_fptr(); }
108454 +};
108455 +
108456 +class kernexec_retaddr_pass : public rtl_opt_pass {
108457 +public:
108458 + kernexec_retaddr_pass() : rtl_opt_pass(kernexec_retaddr_pass_data, g) {}
108459 + bool gate() { return kernexec_cmodel_check(); }
108460 + unsigned int execute() { return execute_kernexec_retaddr(); }
108461 +};
108462 +}
108463 +
108464 +static opt_pass *make_kernexec_reload_pass(void)
108465 +{
108466 + return new kernexec_reload_pass();
108467 +}
108468 +
108469 +static opt_pass *make_kernexec_fptr_pass(void)
108470 +{
108471 + return new kernexec_fptr_pass();
108472 +}
108473 +
108474 +static opt_pass *make_kernexec_retaddr_pass(void)
108475 +{
108476 + return new kernexec_retaddr_pass();
108477 +}
108478 +#else
108479 +static struct opt_pass *make_kernexec_reload_pass(void)
108480 +{
108481 + return &kernexec_reload_pass.pass;
108482 +}
108483 +
108484 +static struct opt_pass *make_kernexec_fptr_pass(void)
108485 +{
108486 + return &kernexec_fptr_pass.pass;
108487 +}
108488 +
108489 +static struct opt_pass *make_kernexec_retaddr_pass(void)
108490 +{
108491 + return &kernexec_retaddr_pass.pass;
108492 +}
108493 +#endif
108494 +
108495 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
108496 +{
108497 + const char * const plugin_name = plugin_info->base_name;
108498 + const int argc = plugin_info->argc;
108499 + const struct plugin_argument * const argv = plugin_info->argv;
108500 + int i;
108501 + struct register_pass_info kernexec_reload_pass_info;
108502 + struct register_pass_info kernexec_fptr_pass_info;
108503 + struct register_pass_info kernexec_retaddr_pass_info;
108504 +
108505 + kernexec_reload_pass_info.pass = make_kernexec_reload_pass();
108506 + kernexec_reload_pass_info.reference_pass_name = "ssa";
108507 + kernexec_reload_pass_info.ref_pass_instance_number = 1;
108508 + kernexec_reload_pass_info.pos_op = PASS_POS_INSERT_AFTER;
108509 +
108510 + kernexec_fptr_pass_info.pass = make_kernexec_fptr_pass();
108511 + kernexec_fptr_pass_info.reference_pass_name = "ssa";
108512 + kernexec_fptr_pass_info.ref_pass_instance_number = 1;
108513 + kernexec_fptr_pass_info.pos_op = PASS_POS_INSERT_AFTER;
108514 +
108515 + kernexec_retaddr_pass_info.pass = make_kernexec_retaddr_pass();
108516 + kernexec_retaddr_pass_info.reference_pass_name = "pro_and_epilogue";
108517 + kernexec_retaddr_pass_info.ref_pass_instance_number = 1;
108518 + kernexec_retaddr_pass_info.pos_op = PASS_POS_INSERT_AFTER;
108519 +
108520 + if (!plugin_default_version_check(version, &gcc_version)) {
108521 + error(G_("incompatible gcc/plugin versions"));
108522 + return 1;
108523 + }
108524 +
108525 + register_callback(plugin_name, PLUGIN_INFO, NULL, &kernexec_plugin_info);
108526 +
108527 + if (TARGET_64BIT == 0)
108528 + return 0;
108529 +
108530 + for (i = 0; i < argc; ++i) {
108531 + if (!strcmp(argv[i].key, "method")) {
108532 + if (!argv[i].value) {
108533 + error(G_("no value supplied for option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
108534 + continue;
108535 + }
108536 + if (!strcmp(argv[i].value, "bts")) {
108537 + kernexec_instrument_fptr = kernexec_instrument_fptr_bts;
108538 + kernexec_instrument_retaddr = kernexec_instrument_retaddr_bts;
108539 + } else if (!strcmp(argv[i].value, "or")) {
108540 + kernexec_instrument_fptr = kernexec_instrument_fptr_or;
108541 + kernexec_instrument_retaddr = kernexec_instrument_retaddr_or;
108542 + fix_register("r12", 1, 1);
108543 + } else
108544 + error(G_("invalid option argument '-fplugin-arg-%s-%s=%s'"), plugin_name, argv[i].key, argv[i].value);
108545 + continue;
108546 + }
108547 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
108548 + }
108549 + if (!kernexec_instrument_fptr || !kernexec_instrument_retaddr)
108550 + error(G_("no instrumentation method was selected via '-fplugin-arg-%s-method'"), plugin_name);
108551 +
108552 + if (kernexec_instrument_fptr == kernexec_instrument_fptr_or)
108553 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kernexec_reload_pass_info);
108554 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kernexec_fptr_pass_info);
108555 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kernexec_retaddr_pass_info);
108556 +
108557 + return 0;
108558 +}
108559 diff --git a/tools/gcc/latent_entropy_plugin.c b/tools/gcc/latent_entropy_plugin.c
108560 new file mode 100644
108561 index 0000000..39d7cc7
108562 --- /dev/null
108563 +++ b/tools/gcc/latent_entropy_plugin.c
108564 @@ -0,0 +1,462 @@
108565 +/*
108566 + * Copyright 2012-2014 by the PaX Team <pageexec@freemail.hu>
108567 + * Licensed under the GPL v2
108568 + *
108569 + * Note: the choice of the license means that the compilation process is
108570 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
108571 + * but for the kernel it doesn't matter since it doesn't link against
108572 + * any of the gcc libraries
108573 + *
108574 + * gcc plugin to help generate a little bit of entropy from program state,
108575 + * used throughout the uptime of the kernel
108576 + *
108577 + * TODO:
108578 + * - add ipa pass to identify not explicitly marked candidate functions
108579 + * - mix in more program state (function arguments/return values, loop variables, etc)
108580 + * - more instrumentation control via attribute parameters
108581 + *
108582 + * BUGS:
108583 + * - LTO needs -flto-partition=none for now
108584 + */
108585 +
108586 +#include "gcc-common.h"
108587 +
108588 +int plugin_is_GPL_compatible;
108589 +
108590 +static tree latent_entropy_decl;
108591 +
108592 +static struct plugin_info latent_entropy_plugin_info = {
108593 + .version = "201403280150",
108594 + .help = NULL
108595 +};
108596 +
108597 +static unsigned HOST_WIDE_INT seed;
108598 +static unsigned HOST_WIDE_INT get_random_const(void)
108599 +{
108600 + unsigned int i;
108601 + unsigned HOST_WIDE_INT ret = 0;
108602 +
108603 + for (i = 0; i < 8 * sizeof ret; i++) {
108604 + ret = (ret << 1) | (seed & 1);
108605 + seed >>= 1;
108606 + if (ret & 1)
108607 + seed ^= 0xD800000000000000ULL;
108608 + }
108609 +
108610 + return ret;
108611 +}
108612 +
108613 +static tree handle_latent_entropy_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
108614 +{
108615 + tree type;
108616 + unsigned long long mask;
108617 +#if BUILDING_GCC_VERSION <= 4007
108618 + VEC(constructor_elt, gc) *vals;
108619 +#else
108620 + vec<constructor_elt, va_gc> *vals;
108621 +#endif
108622 +
108623 + switch (TREE_CODE(*node)) {
108624 + default:
108625 + *no_add_attrs = true;
108626 + error("%qE attribute only applies to functions and variables", name);
108627 + break;
108628 +
108629 + case VAR_DECL:
108630 + if (DECL_INITIAL(*node)) {
108631 + *no_add_attrs = true;
108632 + error("variable %qD with %qE attribute must not be initialized", *node, name);
108633 + break;
108634 + }
108635 +
108636 + if (!TREE_STATIC(*node)) {
108637 + *no_add_attrs = true;
108638 + error("variable %qD with %qE attribute must not be local", *node, name);
108639 + break;
108640 + }
108641 +
108642 + type = TREE_TYPE(*node);
108643 + switch (TREE_CODE(type)) {
108644 + default:
108645 + *no_add_attrs = true;
108646 + error("variable %qD with %qE attribute must be an integer or a fixed length integer array type or a fixed sized structure with integer fields", *node, name);
108647 + break;
108648 +
108649 + case RECORD_TYPE: {
108650 + tree field;
108651 + unsigned int nelt = 0;
108652 +
108653 + for (field = TYPE_FIELDS(type); field; nelt++, field = TREE_CHAIN(field)) {
108654 + tree fieldtype;
108655 +
108656 + fieldtype = TREE_TYPE(field);
108657 + if (TREE_CODE(fieldtype) != INTEGER_TYPE) {
108658 + *no_add_attrs = true;
108659 + error("structure variable %qD with %qE attribute has a non-integer field %qE", *node, name, field);
108660 + break;
108661 + }
108662 + }
108663 +
108664 + if (field)
108665 + break;
108666 +
108667 +#if BUILDING_GCC_VERSION <= 4007
108668 + vals = VEC_alloc(constructor_elt, gc, nelt);
108669 +#else
108670 + vec_alloc(vals, nelt);
108671 +#endif
108672 +
108673 + for (field = TYPE_FIELDS(type); field; field = TREE_CHAIN(field)) {
108674 + tree fieldtype;
108675 +
108676 + fieldtype = TREE_TYPE(field);
108677 + mask = 1ULL << (TREE_INT_CST_LOW(TYPE_SIZE(fieldtype)) - 1);
108678 + mask = 2 * (mask - 1) + 1;
108679 +
108680 + if (TYPE_UNSIGNED(fieldtype))
108681 + CONSTRUCTOR_APPEND_ELT(vals, field, build_int_cstu(fieldtype, mask & get_random_const()));
108682 + else
108683 + CONSTRUCTOR_APPEND_ELT(vals, field, build_int_cst(fieldtype, mask & get_random_const()));
108684 + }
108685 +
108686 + DECL_INITIAL(*node) = build_constructor(type, vals);
108687 +//debug_tree(DECL_INITIAL(*node));
108688 + break;
108689 + }
108690 +
108691 + case INTEGER_TYPE:
108692 + mask = 1ULL << (TREE_INT_CST_LOW(TYPE_SIZE(type)) - 1);
108693 + mask = 2 * (mask - 1) + 1;
108694 +
108695 + if (TYPE_UNSIGNED(type))
108696 + DECL_INITIAL(*node) = build_int_cstu(type, mask & get_random_const());
108697 + else
108698 + DECL_INITIAL(*node) = build_int_cst(type, mask & get_random_const());
108699 + break;
108700 +
108701 + case ARRAY_TYPE: {
108702 + tree elt_type, array_size, elt_size;
108703 + unsigned int i, nelt;
108704 +
108705 + elt_type = TREE_TYPE(type);
108706 + elt_size = TYPE_SIZE_UNIT(TREE_TYPE(type));
108707 + array_size = TYPE_SIZE_UNIT(type);
108708 +
108709 + if (TREE_CODE(elt_type) != INTEGER_TYPE || !array_size || TREE_CODE(array_size) != INTEGER_CST) {
108710 + *no_add_attrs = true;
108711 + error("array variable %qD with %qE attribute must be a fixed length integer array type", *node, name);
108712 + break;
108713 + }
108714 +
108715 + nelt = TREE_INT_CST_LOW(array_size) / TREE_INT_CST_LOW(elt_size);
108716 +#if BUILDING_GCC_VERSION <= 4007
108717 + vals = VEC_alloc(constructor_elt, gc, nelt);
108718 +#else
108719 + vec_alloc(vals, nelt);
108720 +#endif
108721 +
108722 + mask = 1ULL << (TREE_INT_CST_LOW(TYPE_SIZE(elt_type)) - 1);
108723 + mask = 2 * (mask - 1) + 1;
108724 +
108725 + for (i = 0; i < nelt; i++)
108726 + if (TYPE_UNSIGNED(elt_type))
108727 + CONSTRUCTOR_APPEND_ELT(vals, size_int(i), build_int_cstu(elt_type, mask & get_random_const()));
108728 + else
108729 + CONSTRUCTOR_APPEND_ELT(vals, size_int(i), build_int_cst(elt_type, mask & get_random_const()));
108730 +
108731 + DECL_INITIAL(*node) = build_constructor(type, vals);
108732 +//debug_tree(DECL_INITIAL(*node));
108733 + break;
108734 + }
108735 + }
108736 + break;
108737 +
108738 + case FUNCTION_DECL:
108739 + break;
108740 + }
108741 +
108742 + return NULL_TREE;
108743 +}
108744 +
108745 +static struct attribute_spec latent_entropy_attr = {
108746 + .name = "latent_entropy",
108747 + .min_length = 0,
108748 + .max_length = 0,
108749 + .decl_required = true,
108750 + .type_required = false,
108751 + .function_type_required = false,
108752 + .handler = handle_latent_entropy_attribute,
108753 +#if BUILDING_GCC_VERSION >= 4007
108754 + .affects_type_identity = false
108755 +#endif
108756 +};
108757 +
108758 +static void register_attributes(void *event_data, void *data)
108759 +{
108760 + register_attribute(&latent_entropy_attr);
108761 +}
108762 +
108763 +static bool gate_latent_entropy(void)
108764 +{
108765 + // don't bother with noreturn functions for now
108766 + if (TREE_THIS_VOLATILE(current_function_decl))
108767 + return false;
108768 +
108769 + return lookup_attribute("latent_entropy", DECL_ATTRIBUTES(current_function_decl)) != NULL_TREE;
108770 +}
108771 +
108772 +static enum tree_code get_op(tree *rhs)
108773 +{
108774 + static enum tree_code op;
108775 + unsigned HOST_WIDE_INT random_const;
108776 +
108777 + random_const = get_random_const();
108778 +
108779 + switch (op) {
108780 + case BIT_XOR_EXPR:
108781 + op = PLUS_EXPR;
108782 + break;
108783 +
108784 + case PLUS_EXPR:
108785 + if (rhs) {
108786 + op = LROTATE_EXPR;
108787 + random_const &= HOST_BITS_PER_WIDE_INT - 1;
108788 + break;
108789 + }
108790 +
108791 + case LROTATE_EXPR:
108792 + default:
108793 + op = BIT_XOR_EXPR;
108794 + break;
108795 + }
108796 + if (rhs)
108797 + *rhs = build_int_cstu(unsigned_intDI_type_node, random_const);
108798 + return op;
108799 +}
108800 +
108801 +static void perturb_local_entropy(basic_block bb, tree local_entropy)
108802 +{
108803 + gimple_stmt_iterator gsi;
108804 + gimple assign;
108805 + tree addxorrol, rhs;
108806 + enum tree_code op;
108807 +
108808 + op = get_op(&rhs);
108809 + addxorrol = fold_build2_loc(UNKNOWN_LOCATION, op, unsigned_intDI_type_node, local_entropy, rhs);
108810 + assign = gimple_build_assign(local_entropy, addxorrol);
108811 + gsi = gsi_after_labels(bb);
108812 + gsi_insert_before(&gsi, assign, GSI_NEW_STMT);
108813 + update_stmt(assign);
108814 +//debug_bb(bb);
108815 +}
108816 +
108817 +static void perturb_latent_entropy(basic_block bb, tree rhs)
108818 +{
108819 + gimple_stmt_iterator gsi;
108820 + gimple assign;
108821 + tree addxorrol, temp;
108822 +
108823 + // 1. create temporary copy of latent_entropy
108824 + temp = create_tmp_var(unsigned_intDI_type_node, "temp_latent_entropy");
108825 + add_referenced_var(temp);
108826 +
108827 + // 2. read...
108828 + temp = make_ssa_name(temp, NULL);
108829 + assign = gimple_build_assign(temp, latent_entropy_decl);
108830 + SSA_NAME_DEF_STMT(temp) = assign;
108831 + add_referenced_var(latent_entropy_decl);
108832 + gsi = gsi_after_labels(bb);
108833 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
108834 + update_stmt(assign);
108835 +
108836 + // 3. ...modify...
108837 + addxorrol = fold_build2_loc(UNKNOWN_LOCATION, get_op(NULL), unsigned_intDI_type_node, temp, rhs);
108838 + temp = make_ssa_name(SSA_NAME_VAR(temp), NULL);
108839 + assign = gimple_build_assign(temp, addxorrol);
108840 + SSA_NAME_DEF_STMT(temp) = assign;
108841 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
108842 + update_stmt(assign);
108843 +
108844 + // 4. ...write latent_entropy
108845 + assign = gimple_build_assign(latent_entropy_decl, temp);
108846 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
108847 + update_stmt(assign);
108848 +}
108849 +
108850 +static unsigned int execute_latent_entropy(void)
108851 +{
108852 + basic_block bb;
108853 + gimple assign;
108854 + gimple_stmt_iterator gsi;
108855 + tree local_entropy;
108856 +
108857 + if (!latent_entropy_decl) {
108858 +#if BUILDING_GCC_VERSION >= 4009
108859 + varpool_node *node;
108860 +#else
108861 + struct varpool_node *node;
108862 +#endif
108863 +
108864 + FOR_EACH_VARIABLE(node) {
108865 + tree var = NODE_DECL(node);
108866 +
108867 + if (strcmp(IDENTIFIER_POINTER(DECL_NAME(var)), "latent_entropy"))
108868 + continue;
108869 + latent_entropy_decl = var;
108870 +// debug_tree(var);
108871 + break;
108872 + }
108873 + if (!latent_entropy_decl) {
108874 +// debug_tree(current_function_decl);
108875 + return 0;
108876 + }
108877 + }
108878 +
108879 +//fprintf(stderr, "latent_entropy: %s\n", IDENTIFIER_POINTER(DECL_NAME(current_function_decl)));
108880 +
108881 + // 1. create local entropy variable
108882 + local_entropy = create_tmp_var(unsigned_intDI_type_node, "local_entropy");
108883 + add_referenced_var(local_entropy);
108884 + mark_sym_for_renaming(local_entropy);
108885 +
108886 + // 2. initialize local entropy variable
108887 + bb = split_block_after_labels(ENTRY_BLOCK_PTR_FOR_FN(cfun))->dest;
108888 + if (dom_info_available_p(CDI_DOMINATORS))
108889 + set_immediate_dominator(CDI_DOMINATORS, bb, ENTRY_BLOCK_PTR_FOR_FN(cfun));
108890 + gsi = gsi_start_bb(bb);
108891 +
108892 + assign = gimple_build_assign(local_entropy, build_int_cstu(unsigned_intDI_type_node, get_random_const()));
108893 +// gimple_set_location(assign, loc);
108894 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
108895 + update_stmt(assign);
108896 +//debug_bb(bb);
108897 + gcc_assert(single_succ_p(bb));
108898 + bb = single_succ(bb);
108899 +
108900 + // 3. instrument each BB with an operation on the local entropy variable
108901 + while (bb != EXIT_BLOCK_PTR_FOR_FN(cfun)) {
108902 + perturb_local_entropy(bb, local_entropy);
108903 +//debug_bb(bb);
108904 + bb = bb->next_bb;
108905 + };
108906 +
108907 + // 4. mix local entropy into the global entropy variable
108908 + gcc_assert(single_pred_p(EXIT_BLOCK_PTR_FOR_FN(cfun)));
108909 + perturb_latent_entropy(single_pred(EXIT_BLOCK_PTR_FOR_FN(cfun)), local_entropy);
108910 +//debug_bb(single_pred(EXIT_BLOCK_PTR_FOR_FN(cfun)));
108911 + return 0;
108912 +}
108913 +
108914 +static void latent_entropy_start_unit(void *gcc_data, void *user_data)
108915 +{
108916 + tree latent_entropy_type;
108917 +
108918 + seed = get_random_seed(false);
108919 +
108920 + if (in_lto_p)
108921 + return;
108922 +
108923 + // extern volatile u64 latent_entropy
108924 + gcc_assert(TYPE_PRECISION(long_long_unsigned_type_node) == 64);
108925 + latent_entropy_type = build_qualified_type(long_long_unsigned_type_node, TYPE_QUALS(long_long_unsigned_type_node) | TYPE_QUAL_VOLATILE);
108926 + latent_entropy_decl = build_decl(UNKNOWN_LOCATION, VAR_DECL, get_identifier("latent_entropy"), latent_entropy_type);
108927 +
108928 + TREE_STATIC(latent_entropy_decl) = 1;
108929 + TREE_PUBLIC(latent_entropy_decl) = 1;
108930 + TREE_USED(latent_entropy_decl) = 1;
108931 + TREE_THIS_VOLATILE(latent_entropy_decl) = 1;
108932 + DECL_EXTERNAL(latent_entropy_decl) = 1;
108933 + DECL_ARTIFICIAL(latent_entropy_decl) = 1;
108934 + lang_hooks.decls.pushdecl(latent_entropy_decl);
108935 +// DECL_ASSEMBLER_NAME(latent_entropy_decl);
108936 +// varpool_finalize_decl(latent_entropy_decl);
108937 +// varpool_mark_needed_node(latent_entropy_decl);
108938 +}
108939 +
108940 +#if BUILDING_GCC_VERSION >= 4009
108941 +static const struct pass_data latent_entropy_pass_data = {
108942 +#else
108943 +static struct gimple_opt_pass latent_entropy_pass = {
108944 + .pass = {
108945 +#endif
108946 + .type = GIMPLE_PASS,
108947 + .name = "latent_entropy",
108948 +#if BUILDING_GCC_VERSION >= 4008
108949 + .optinfo_flags = OPTGROUP_NONE,
108950 +#endif
108951 +#if BUILDING_GCC_VERSION >= 4009
108952 + .has_gate = true,
108953 + .has_execute = true,
108954 +#else
108955 + .gate = gate_latent_entropy,
108956 + .execute = execute_latent_entropy,
108957 + .sub = NULL,
108958 + .next = NULL,
108959 + .static_pass_number = 0,
108960 +#endif
108961 + .tv_id = TV_NONE,
108962 + .properties_required = PROP_gimple_leh | PROP_cfg,
108963 + .properties_provided = 0,
108964 + .properties_destroyed = 0,
108965 + .todo_flags_start = 0, //TODO_verify_ssa | TODO_verify_flow | TODO_verify_stmts,
108966 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_update_ssa
108967 +#if BUILDING_GCC_VERSION < 4009
108968 + }
108969 +#endif
108970 +};
108971 +
108972 +#if BUILDING_GCC_VERSION >= 4009
108973 +namespace {
108974 +class latent_entropy_pass : public gimple_opt_pass {
108975 +public:
108976 + latent_entropy_pass() : gimple_opt_pass(latent_entropy_pass_data, g) {}
108977 + bool gate() { return gate_latent_entropy(); }
108978 + unsigned int execute() { return execute_latent_entropy(); }
108979 +};
108980 +}
108981 +
108982 +static opt_pass *make_latent_entropy_pass(void)
108983 +{
108984 + return new latent_entropy_pass();
108985 +}
108986 +#else
108987 +static struct opt_pass *make_latent_entropy_pass(void)
108988 +{
108989 + return &latent_entropy_pass.pass;
108990 +}
108991 +#endif
108992 +
108993 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
108994 +{
108995 + const char * const plugin_name = plugin_info->base_name;
108996 + struct register_pass_info latent_entropy_pass_info;
108997 +
108998 + latent_entropy_pass_info.pass = make_latent_entropy_pass();
108999 + latent_entropy_pass_info.reference_pass_name = "optimized";
109000 + latent_entropy_pass_info.ref_pass_instance_number = 1;
109001 + latent_entropy_pass_info.pos_op = PASS_POS_INSERT_BEFORE;
109002 + static const struct ggc_root_tab gt_ggc_r_gt_latent_entropy[] = {
109003 + {
109004 + .base = &latent_entropy_decl,
109005 + .nelt = 1,
109006 + .stride = sizeof(latent_entropy_decl),
109007 + .cb = &gt_ggc_mx_tree_node,
109008 + .pchw = &gt_pch_nx_tree_node
109009 + },
109010 + LAST_GGC_ROOT_TAB
109011 + };
109012 +
109013 + if (!plugin_default_version_check(version, &gcc_version)) {
109014 + error(G_("incompatible gcc/plugin versions"));
109015 + return 1;
109016 + }
109017 +
109018 + register_callback(plugin_name, PLUGIN_INFO, NULL, &latent_entropy_plugin_info);
109019 + register_callback(plugin_name, PLUGIN_START_UNIT, &latent_entropy_start_unit, NULL);
109020 + if (!in_lto_p)
109021 + register_callback(plugin_name, PLUGIN_REGISTER_GGC_ROOTS, NULL, (void *)&gt_ggc_r_gt_latent_entropy);
109022 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &latent_entropy_pass_info);
109023 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
109024 +
109025 + return 0;
109026 +}
109027 diff --git a/tools/gcc/randomize_layout_plugin.c b/tools/gcc/randomize_layout_plugin.c
109028 new file mode 100644
109029 index 0000000..8dafb22
109030 --- /dev/null
109031 +++ b/tools/gcc/randomize_layout_plugin.c
109032 @@ -0,0 +1,910 @@
109033 +/*
109034 + * Copyright 2014 by Open Source Security, Inc., Brad Spengler <spender@grsecurity.net>
109035 + * and PaX Team <pageexec@freemail.hu>
109036 + * Licensed under the GPL v2
109037 + *
109038 + * Usage:
109039 + * $ # for 4.5/4.6/C based 4.7
109040 + * $ gcc -I`gcc -print-file-name=plugin`/include -I`gcc -print-file-name=plugin`/include/c-family -fPIC -shared -O2 -o randomize_layout_plugin.so randomize_layout_plugin.c
109041 + * $ # for C++ based 4.7/4.8+
109042 + * $ g++ -I`g++ -print-file-name=plugin`/include -I`g++ -print-file-name=plugin`/include/c-family -fPIC -shared -O2 -o randomize_layout_plugin.so randomize_layout_plugin.c
109043 + * $ gcc -fplugin=./randomize_layout_plugin.so test.c -O2
109044 + */
109045 +
109046 +#include "gcc-common.h"
109047 +#include "randomize_layout_seed.h"
109048 +
109049 +#if BUILDING_GCC_MAJOR < 4 || BUILDING_GCC_MINOR < 6 || (BUILDING_GCC_MINOR == 6 && BUILDING_GCC_PATCHLEVEL < 4)
109050 +#error "The RANDSTRUCT plugin requires GCC 4.6.4 or newer."
109051 +#endif
109052 +
109053 +#define ORIG_TYPE_NAME(node) \
109054 + (TYPE_NAME(TYPE_MAIN_VARIANT(node)) != NULL_TREE ? ((const unsigned char *)IDENTIFIER_POINTER(TYPE_NAME(TYPE_MAIN_VARIANT(node)))) : (const unsigned char *)"anonymous")
109055 +
109056 +int plugin_is_GPL_compatible;
109057 +
109058 +static int performance_mode;
109059 +
109060 +static struct plugin_info randomize_layout_plugin_info = {
109061 + .version = "201402201816",
109062 + .help = "disable\t\t\tdo not activate plugin\n"
109063 + "performance-mode\tenable cacheline-aware layout randomization\n"
109064 +};
109065 +
109066 +/* from old Linux dcache.h */
109067 +static inline unsigned long
109068 +partial_name_hash(unsigned long c, unsigned long prevhash)
109069 +{
109070 + return (prevhash + (c << 4) + (c >> 4)) * 11;
109071 +}
109072 +static inline unsigned int
109073 +name_hash(const unsigned char *name)
109074 +{
109075 + unsigned long hash = 0;
109076 + unsigned int len = strlen((const char *)name);
109077 + while (len--)
109078 + hash = partial_name_hash(*name++, hash);
109079 + return (unsigned int)hash;
109080 +}
109081 +
109082 +static tree handle_randomize_layout_attr(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
109083 +{
109084 + tree type;
109085 +
109086 + *no_add_attrs = true;
109087 + if (TREE_CODE(*node) == FUNCTION_DECL) {
109088 + error("%qE attribute does not apply to functions (%qF)", name, *node);
109089 + return NULL_TREE;
109090 + }
109091 +
109092 + if (TREE_CODE(*node) == PARM_DECL) {
109093 + error("%qE attribute does not apply to function parameters (%qD)", name, *node);
109094 + return NULL_TREE;
109095 + }
109096 +
109097 + if (TREE_CODE(*node) == VAR_DECL) {
109098 + error("%qE attribute does not apply to variables (%qD)", name, *node);
109099 + return NULL_TREE;
109100 + }
109101 +
109102 + if (TYPE_P(*node)) {
109103 + type = *node;
109104 + } else {
109105 + gcc_assert(TREE_CODE(*node) == TYPE_DECL);
109106 + type = TREE_TYPE(*node);
109107 + }
109108 +
109109 + if (TREE_CODE(type) != RECORD_TYPE) {
109110 + error("%qE attribute used on %qT applies to struct types only", name, type);
109111 + return NULL_TREE;
109112 + }
109113 +
109114 + if (lookup_attribute(IDENTIFIER_POINTER(name), TYPE_ATTRIBUTES(type))) {
109115 + error("%qE attribute is already applied to the type %qT", name, type);
109116 + return NULL_TREE;
109117 + }
109118 +
109119 + *no_add_attrs = false;
109120 +
109121 + return NULL_TREE;
109122 +}
109123 +
109124 +/* set on complete types that we don't need to inspect further at all */
109125 +static tree handle_randomize_considered_attr(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
109126 +{
109127 + *no_add_attrs = false;
109128 + return NULL_TREE;
109129 +}
109130 +
109131 +/*
109132 + * set on types that we've performed a shuffle on, to prevent re-shuffling
109133 + * this does not preclude us from inspecting its fields for potential shuffles
109134 + */
109135 +static tree handle_randomize_performed_attr(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
109136 +{
109137 + *no_add_attrs = false;
109138 + return NULL_TREE;
109139 +}
109140 +
109141 +/*
109142 + * 64bit variant of Bob Jenkins' public domain PRNG
109143 + * 256 bits of internal state
109144 + */
109145 +
109146 +typedef unsigned long long u64;
109147 +
109148 +typedef struct ranctx { u64 a; u64 b; u64 c; u64 d; } ranctx;
109149 +
109150 +#define rot(x,k) (((x)<<(k))|((x)>>(64-(k))))
109151 +static u64 ranval(ranctx *x) {
109152 + u64 e = x->a - rot(x->b, 7);
109153 + x->a = x->b ^ rot(x->c, 13);
109154 + x->b = x->c + rot(x->d, 37);
109155 + x->c = x->d + e;
109156 + x->d = e + x->a;
109157 + return x->d;
109158 +}
109159 +
109160 +static void raninit(ranctx *x, u64 *seed) {
109161 + int i;
109162 +
109163 + x->a = seed[0];
109164 + x->b = seed[1];
109165 + x->c = seed[2];
109166 + x->d = seed[3];
109167 +
109168 + for (i=0; i < 30; ++i)
109169 + (void)ranval(x);
109170 +}
109171 +
109172 +static u64 shuffle_seed[4];
109173 +
109174 +struct partition_group {
109175 + tree tree_start;
109176 + unsigned long start;
109177 + unsigned long length;
109178 +};
109179 +
109180 +static void partition_struct(tree *fields, unsigned long length, struct partition_group *size_groups, unsigned long *num_groups)
109181 +{
109182 + unsigned long i;
109183 + unsigned long accum_size = 0;
109184 + unsigned long accum_length = 0;
109185 + unsigned long group_idx = 0;
109186 +
109187 + gcc_assert(length < INT_MAX);
109188 +
109189 + memset(size_groups, 0, sizeof(struct partition_group) * length);
109190 +
109191 + for (i = 0; i < length; i++) {
109192 + if (size_groups[group_idx].tree_start == NULL_TREE) {
109193 + size_groups[group_idx].tree_start = fields[i];
109194 + size_groups[group_idx].start = i;
109195 + accum_length = 0;
109196 + accum_size = 0;
109197 + }
109198 + accum_size += (unsigned long)int_size_in_bytes(TREE_TYPE(fields[i]));
109199 + accum_length++;
109200 + if (accum_size >= 64) {
109201 + size_groups[group_idx].length = accum_length;
109202 + accum_length = 0;
109203 + group_idx++;
109204 + }
109205 + }
109206 +
109207 + if (size_groups[group_idx].tree_start != NULL_TREE &&
109208 + !size_groups[group_idx].length) {
109209 + size_groups[group_idx].length = accum_length;
109210 + group_idx++;
109211 + }
109212 +
109213 + *num_groups = group_idx;
109214 +}
109215 +
109216 +static void performance_shuffle(tree *newtree, unsigned long length, ranctx *prng_state)
109217 +{
109218 + unsigned long i, x;
109219 + struct partition_group size_group[length];
109220 + unsigned long num_groups = 0;
109221 + unsigned long randnum;
109222 +
109223 + partition_struct(newtree, length, (struct partition_group *)&size_group, &num_groups);
109224 + for (i = num_groups - 1; i > 0; i--) {
109225 + struct partition_group tmp;
109226 + randnum = ranval(prng_state) % (i + 1);
109227 + tmp = size_group[i];
109228 + size_group[i] = size_group[randnum];
109229 + size_group[randnum] = tmp;
109230 + }
109231 +
109232 + for (x = 0; x < num_groups; x++) {
109233 + for (i = size_group[x].start + size_group[x].length - 1; i > size_group[x].start; i--) {
109234 + tree tmp;
109235 + if (DECL_BIT_FIELD_TYPE(newtree[i]))
109236 + continue;
109237 + randnum = ranval(prng_state) % (i + 1);
109238 + // we could handle this case differently if desired
109239 + if (DECL_BIT_FIELD_TYPE(newtree[randnum]))
109240 + continue;
109241 + tmp = newtree[i];
109242 + newtree[i] = newtree[randnum];
109243 + newtree[randnum] = tmp;
109244 + }
109245 + }
109246 +}
109247 +
109248 +static void full_shuffle(tree *newtree, unsigned long length, ranctx *prng_state)
109249 +{
109250 + unsigned long i, randnum;
109251 +
109252 + for (i = length - 1; i > 0; i--) {
109253 + tree tmp;
109254 + randnum = ranval(prng_state) % (i + 1);
109255 + tmp = newtree[i];
109256 + newtree[i] = newtree[randnum];
109257 + newtree[randnum] = tmp;
109258 + }
109259 +}
109260 +
109261 +/* modern in-place Fisher-Yates shuffle */
109262 +static void shuffle(const_tree type, tree *newtree, unsigned long length)
109263 +{
109264 + unsigned long i;
109265 + u64 seed[4];
109266 + ranctx prng_state;
109267 + const unsigned char *structname;
109268 +
109269 + if (length == 0)
109270 + return;
109271 +
109272 + gcc_assert(TREE_CODE(type) == RECORD_TYPE);
109273 +
109274 + structname = ORIG_TYPE_NAME(type);
109275 +
109276 +#ifdef __DEBUG_PLUGIN
109277 + fprintf(stderr, "Shuffling struct %s %p\n", (const char *)structname, type);
109278 +#ifdef __DEBUG_VERBOSE
109279 + debug_tree((tree)type);
109280 +#endif
109281 +#endif
109282 +
109283 + for (i = 0; i < 4; i++) {
109284 + seed[i] = shuffle_seed[i];
109285 + seed[i] ^= name_hash(structname);
109286 + }
109287 +
109288 + raninit(&prng_state, (u64 *)&seed);
109289 +
109290 + if (performance_mode)
109291 + performance_shuffle(newtree, length, &prng_state);
109292 + else
109293 + full_shuffle(newtree, length, &prng_state);
109294 +}
109295 +
109296 +static bool is_flexible_array(const_tree field)
109297 +{
109298 + const_tree fieldtype;
109299 + const_tree typesize;
109300 + const_tree elemtype;
109301 + const_tree elemsize;
109302 +
109303 + fieldtype = TREE_TYPE(field);
109304 + typesize = TYPE_SIZE(fieldtype);
109305 +
109306 + if (TREE_CODE(fieldtype) != ARRAY_TYPE)
109307 + return false;
109308 +
109309 + elemtype = TREE_TYPE(fieldtype);
109310 + elemsize = TYPE_SIZE(elemtype);
109311 +
109312 + /* size of type is represented in bits */
109313 +
109314 + if (typesize == NULL_TREE && TYPE_DOMAIN(fieldtype) != NULL_TREE &&
109315 + TYPE_MAX_VALUE(TYPE_DOMAIN(fieldtype)) == NULL_TREE)
109316 + return true;
109317 +
109318 + if (typesize != NULL_TREE &&
109319 + (TREE_CONSTANT(typesize) && (!TREE_INT_CST_LOW(typesize) ||
109320 + TREE_INT_CST_LOW(typesize) == TREE_INT_CST_LOW(elemsize))))
109321 + return true;
109322 +
109323 + return false;
109324 +}
109325 +
109326 +static int relayout_struct(tree type)
109327 +{
109328 + unsigned long num_fields = (unsigned long)list_length(TYPE_FIELDS(type));
109329 + unsigned long shuffle_length = num_fields;
109330 + tree field;
109331 + tree newtree[num_fields];
109332 + unsigned long i;
109333 + tree list;
109334 + tree variant;
109335 + expanded_location xloc;
109336 +
109337 + if (TYPE_FIELDS(type) == NULL_TREE)
109338 + return 0;
109339 +
109340 + if (num_fields < 2)
109341 + return 0;
109342 +
109343 + gcc_assert(TREE_CODE(type) == RECORD_TYPE);
109344 +
109345 + gcc_assert(num_fields < INT_MAX);
109346 +
109347 + if (lookup_attribute("randomize_performed", TYPE_ATTRIBUTES(type)) ||
109348 + lookup_attribute("no_randomize_layout", TYPE_ATTRIBUTES(TYPE_MAIN_VARIANT(type))))
109349 + return 0;
109350 +
109351 + /* throw out any structs in uapi */
109352 + xloc = expand_location(DECL_SOURCE_LOCATION(TYPE_FIELDS(type)));
109353 +
109354 + if (strstr(xloc.file, "/uapi/"))
109355 + error(G_("attempted to randomize userland API struct %s"), ORIG_TYPE_NAME(type));
109356 +
109357 + for (field = TYPE_FIELDS(type), i = 0; field; field = TREE_CHAIN(field), i++) {
109358 + gcc_assert(TREE_CODE(field) == FIELD_DECL);
109359 + newtree[i] = field;
109360 + }
109361 +
109362 + /*
109363 + * enforce that we don't randomize the layout of the last
109364 + * element of a struct if it's a 0 or 1-length array
109365 + * or a proper flexible array
109366 + */
109367 + if (is_flexible_array(newtree[num_fields - 1]))
109368 + shuffle_length--;
109369 +
109370 + shuffle(type, (tree *)newtree, shuffle_length);
109371 +
109372 + /*
109373 + * set up a bogus anonymous struct field designed to error out on unnamed struct initializers
109374 + * as gcc provides no other way to detect such code
109375 + */
109376 + list = make_node(FIELD_DECL);
109377 + TREE_CHAIN(list) = newtree[0];
109378 + TREE_TYPE(list) = void_type_node;
109379 + DECL_SIZE(list) = bitsize_zero_node;
109380 + DECL_NONADDRESSABLE_P(list) = 1;
109381 + DECL_FIELD_BIT_OFFSET(list) = bitsize_zero_node;
109382 + DECL_SIZE_UNIT(list) = size_zero_node;
109383 + DECL_FIELD_OFFSET(list) = size_zero_node;
109384 + // to satisfy the constify plugin
109385 + TREE_READONLY(list) = 1;
109386 +
109387 + for (i = 0; i < num_fields - 1; i++)
109388 + TREE_CHAIN(newtree[i]) = newtree[i+1];
109389 + TREE_CHAIN(newtree[num_fields - 1]) = NULL_TREE;
109390 +
109391 + for (variant = TYPE_MAIN_VARIANT(type); variant; variant = TYPE_NEXT_VARIANT(variant)) {
109392 + TYPE_FIELDS(variant) = list;
109393 + TYPE_ATTRIBUTES(variant) = copy_list(TYPE_ATTRIBUTES(variant));
109394 + TYPE_ATTRIBUTES(variant) = tree_cons(get_identifier("randomize_performed"), NULL_TREE, TYPE_ATTRIBUTES(variant));
109395 + // force a re-layout
109396 + TYPE_SIZE(variant) = NULL_TREE;
109397 + layout_type(variant);
109398 + }
109399 +
109400 + return 1;
109401 +}
109402 +
109403 +/* from constify plugin */
109404 +static const_tree get_field_type(const_tree field)
109405 +{
109406 + return strip_array_types(TREE_TYPE(field));
109407 +}
109408 +
109409 +/* from constify plugin */
109410 +static bool is_fptr(const_tree fieldtype)
109411 +{
109412 + if (TREE_CODE(fieldtype) != POINTER_TYPE)
109413 + return false;
109414 +
109415 + return TREE_CODE(TREE_TYPE(fieldtype)) == FUNCTION_TYPE;
109416 +}
109417 +
109418 +/* derived from constify plugin */
109419 +static int is_pure_ops_struct(const_tree node)
109420 +{
109421 + const_tree field;
109422 +
109423 + gcc_assert(TREE_CODE(node) == RECORD_TYPE || TREE_CODE(node) == UNION_TYPE);
109424 +
109425 + for (field = TYPE_FIELDS(node); field; field = TREE_CHAIN(field)) {
109426 + const_tree fieldtype = get_field_type(field);
109427 + enum tree_code code = TREE_CODE(fieldtype);
109428 +
109429 + if (node == fieldtype)
109430 + continue;
109431 +
109432 + if (!is_fptr(fieldtype))
109433 + return 0;
109434 +
109435 + if (code != RECORD_TYPE && code != UNION_TYPE)
109436 + continue;
109437 +
109438 + if (!is_pure_ops_struct(fieldtype))
109439 + return 0;
109440 + }
109441 +
109442 + return 1;
109443 +}
109444 +
109445 +static void randomize_type(tree type)
109446 +{
109447 + tree variant;
109448 +
109449 + gcc_assert(TREE_CODE(type) == RECORD_TYPE);
109450 +
109451 + if (lookup_attribute("randomize_considered", TYPE_ATTRIBUTES(type)))
109452 + return;
109453 +
109454 + if (lookup_attribute("randomize_layout", TYPE_ATTRIBUTES(TYPE_MAIN_VARIANT(type))) || is_pure_ops_struct(type))
109455 + relayout_struct(type);
109456 +
109457 + for (variant = TYPE_MAIN_VARIANT(type); variant; variant = TYPE_NEXT_VARIANT(variant)) {
109458 + TYPE_ATTRIBUTES(type) = copy_list(TYPE_ATTRIBUTES(type));
109459 + TYPE_ATTRIBUTES(type) = tree_cons(get_identifier("randomize_considered"), NULL_TREE, TYPE_ATTRIBUTES(type));
109460 + }
109461 +#ifdef __DEBUG_PLUGIN
109462 + fprintf(stderr, "Marking randomize_considered on struct %s\n", ORIG_TYPE_NAME(type));
109463 +#ifdef __DEBUG_VERBOSE
109464 + debug_tree(type);
109465 +#endif
109466 +#endif
109467 +}
109468 +
109469 +static void randomize_layout_finish_decl(void *event_data, void *data)
109470 +{
109471 + tree decl = (tree)event_data;
109472 + tree type;
109473 +
109474 + if (decl == NULL_TREE || decl == error_mark_node)
109475 + return;
109476 +
109477 + type = TREE_TYPE(decl);
109478 +
109479 + if (TREE_CODE(decl) != VAR_DECL)
109480 + return;
109481 +
109482 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE)
109483 + return;
109484 +
109485 + if (!lookup_attribute("randomize_performed", TYPE_ATTRIBUTES(type)))
109486 + return;
109487 +
109488 + relayout_decl(decl);
109489 +}
109490 +
109491 +static void finish_type(void *event_data, void *data)
109492 +{
109493 + tree type = (tree)event_data;
109494 +
109495 + if (type == NULL_TREE || type == error_mark_node)
109496 + return;
109497 +
109498 + if (TREE_CODE(type) != RECORD_TYPE)
109499 + return;
109500 +
109501 + if (TYPE_FIELDS(type) == NULL_TREE)
109502 + return;
109503 +
109504 + if (lookup_attribute("randomize_considered", TYPE_ATTRIBUTES(type)))
109505 + return;
109506 +
109507 +#ifdef __DEBUG_PLUGIN
109508 + fprintf(stderr, "Calling randomize_type on %s\n", ORIG_TYPE_NAME(type));
109509 +#endif
109510 +#ifdef __DEBUG_VERBOSE
109511 + debug_tree(type);
109512 +#endif
109513 + randomize_type(type);
109514 +
109515 + return;
109516 +}
109517 +
109518 +static struct attribute_spec randomize_layout_attr = {
109519 + .name = "randomize_layout",
109520 + // related to args
109521 + .min_length = 0,
109522 + .max_length = 0,
109523 + .decl_required = false,
109524 + // need type declaration
109525 + .type_required = true,
109526 + .function_type_required = false,
109527 + .handler = handle_randomize_layout_attr,
109528 +#if BUILDING_GCC_VERSION >= 4007
109529 + .affects_type_identity = true
109530 +#endif
109531 +};
109532 +
109533 +static struct attribute_spec no_randomize_layout_attr = {
109534 + .name = "no_randomize_layout",
109535 + // related to args
109536 + .min_length = 0,
109537 + .max_length = 0,
109538 + .decl_required = false,
109539 + // need type declaration
109540 + .type_required = true,
109541 + .function_type_required = false,
109542 + .handler = handle_randomize_layout_attr,
109543 +#if BUILDING_GCC_VERSION >= 4007
109544 + .affects_type_identity = true
109545 +#endif
109546 +};
109547 +
109548 +static struct attribute_spec randomize_considered_attr = {
109549 + .name = "randomize_considered",
109550 + // related to args
109551 + .min_length = 0,
109552 + .max_length = 0,
109553 + .decl_required = false,
109554 + // need type declaration
109555 + .type_required = true,
109556 + .function_type_required = false,
109557 + .handler = handle_randomize_considered_attr,
109558 +#if BUILDING_GCC_VERSION >= 4007
109559 + .affects_type_identity = false
109560 +#endif
109561 +};
109562 +
109563 +static struct attribute_spec randomize_performed_attr = {
109564 + .name = "randomize_performed",
109565 + // related to args
109566 + .min_length = 0,
109567 + .max_length = 0,
109568 + .decl_required = false,
109569 + // need type declaration
109570 + .type_required = true,
109571 + .function_type_required = false,
109572 + .handler = handle_randomize_performed_attr,
109573 +#if BUILDING_GCC_VERSION >= 4007
109574 + .affects_type_identity = false
109575 +#endif
109576 +};
109577 +
109578 +static void register_attributes(void *event_data, void *data)
109579 +{
109580 + register_attribute(&randomize_layout_attr);
109581 + register_attribute(&no_randomize_layout_attr);
109582 + register_attribute(&randomize_considered_attr);
109583 + register_attribute(&randomize_performed_attr);
109584 +}
109585 +
109586 +static void check_bad_casts_in_constructor(tree var, tree init)
109587 +{
109588 + unsigned HOST_WIDE_INT idx;
109589 + tree field, val;
109590 + tree field_type, val_type;
109591 +
109592 + FOR_EACH_CONSTRUCTOR_ELT(CONSTRUCTOR_ELTS(init), idx, field, val) {
109593 + if (TREE_CODE(val) == CONSTRUCTOR) {
109594 + check_bad_casts_in_constructor(var, val);
109595 + continue;
109596 + }
109597 +
109598 + /* pipacs' plugin creates franken-arrays that differ from those produced by
109599 + normal code which all have valid 'field' trees. work around this */
109600 + if (field == NULL_TREE)
109601 + continue;
109602 + field_type = TREE_TYPE(field);
109603 + val_type = TREE_TYPE(val);
109604 +
109605 + if (TREE_CODE(field_type) != POINTER_TYPE || TREE_CODE(val_type) != POINTER_TYPE)
109606 + continue;
109607 +
109608 + if (field_type == val_type)
109609 + continue;
109610 +
109611 + field_type = TYPE_MAIN_VARIANT(strip_array_types(TYPE_MAIN_VARIANT(TREE_TYPE(field_type))));
109612 + val_type = TYPE_MAIN_VARIANT(strip_array_types(TYPE_MAIN_VARIANT(TREE_TYPE(val_type))));
109613 +
109614 + if (field_type == void_type_node)
109615 + continue;
109616 + if (field_type == val_type)
109617 + continue;
109618 + if (TREE_CODE(val_type) != RECORD_TYPE)
109619 + continue;
109620 +
109621 + if (!lookup_attribute("randomize_performed", TYPE_ATTRIBUTES(val_type)))
109622 + continue;
109623 + inform(DECL_SOURCE_LOCATION(var), "found mismatched struct pointer types: %qT and %qT\n", TYPE_MAIN_VARIANT(field_type), TYPE_MAIN_VARIANT(val_type));
109624 + }
109625 +}
109626 +
109627 +/* derived from the constify plugin */
109628 +static void check_global_variables(void *event_data, void *data)
109629 +{
109630 + struct varpool_node *node;
109631 + tree init;
109632 +
109633 + FOR_EACH_VARIABLE(node) {
109634 + tree var = NODE_DECL(node);
109635 + init = DECL_INITIAL(var);
109636 + if (init == NULL_TREE)
109637 + continue;
109638 +
109639 + if (TREE_CODE(init) != CONSTRUCTOR)
109640 + continue;
109641 +
109642 + check_bad_casts_in_constructor(var, init);
109643 + }
109644 +}
109645 +
109646 +static bool dominated_by_is_err(const_tree rhs, basic_block bb)
109647 +{
109648 + basic_block dom;
109649 + gimple dom_stmt;
109650 + gimple call_stmt;
109651 + const_tree dom_lhs;
109652 + const_tree poss_is_err_cond;
109653 + const_tree poss_is_err_func;
109654 + const_tree is_err_arg;
109655 +
109656 + dom = get_immediate_dominator(CDI_DOMINATORS, bb);
109657 + if (!dom)
109658 + return false;
109659 +
109660 + dom_stmt = last_stmt(dom);
109661 + if (!dom_stmt)
109662 + return false;
109663 +
109664 + if (gimple_code(dom_stmt) != GIMPLE_COND)
109665 + return false;
109666 +
109667 + if (gimple_cond_code(dom_stmt) != NE_EXPR)
109668 + return false;
109669 +
109670 + if (!integer_zerop(gimple_cond_rhs(dom_stmt)))
109671 + return false;
109672 +
109673 + poss_is_err_cond = gimple_cond_lhs(dom_stmt);
109674 +
109675 + if (TREE_CODE(poss_is_err_cond) != SSA_NAME)
109676 + return false;
109677 +
109678 + call_stmt = SSA_NAME_DEF_STMT(poss_is_err_cond);
109679 +
109680 + if (gimple_code(call_stmt) != GIMPLE_CALL)
109681 + return false;
109682 +
109683 + dom_lhs = gimple_get_lhs(call_stmt);
109684 + poss_is_err_func = gimple_call_fndecl(call_stmt);
109685 + if (!poss_is_err_func)
109686 + return false;
109687 + if (dom_lhs != poss_is_err_cond)
109688 + return false;
109689 + if (strcmp(DECL_NAME_POINTER(poss_is_err_func), "IS_ERR"))
109690 + return false;
109691 +
109692 + is_err_arg = gimple_call_arg(call_stmt, 0);
109693 + if (!is_err_arg)
109694 + return false;
109695 +
109696 + if (is_err_arg != rhs)
109697 + return false;
109698 +
109699 + return true;
109700 +}
109701 +
109702 +static void handle_local_var_initializers(void)
109703 +{
109704 + tree var;
109705 + unsigned int i;
109706 +
109707 + FOR_EACH_LOCAL_DECL(cfun, i, var) {
109708 + tree init = DECL_INITIAL(var);
109709 + if (!init)
109710 + continue;
109711 + if (TREE_CODE(init) != CONSTRUCTOR)
109712 + continue;
109713 + check_bad_casts_in_constructor(var, init);
109714 + }
109715 +}
109716 +
109717 +/*
109718 + * iterate over all statements to find "bad" casts:
109719 + * those where the address of the start of a structure is cast
109720 + * to a pointer of a structure of a different type, or a
109721 + * structure pointer type is cast to a different structure pointer type
109722 + */
109723 +static unsigned int find_bad_casts(void)
109724 +{
109725 + basic_block bb;
109726 +
109727 + handle_local_var_initializers();
109728 +
109729 + FOR_ALL_BB_FN(bb, cfun) {
109730 + gimple_stmt_iterator gsi;
109731 +
109732 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
109733 + gimple stmt;
109734 + const_tree lhs;
109735 + const_tree lhs_type;
109736 + const_tree rhs1;
109737 + const_tree rhs_type;
109738 + const_tree ptr_lhs_type;
109739 + const_tree ptr_rhs_type;
109740 + const_tree op0;
109741 + const_tree op0_type;
109742 + enum tree_code rhs_code;
109743 +
109744 + stmt = gsi_stmt(gsi);
109745 +
109746 +#ifdef __DEBUG_PLUGIN
109747 +#ifdef __DEBUG_VERBOSE
109748 + debug_gimple_stmt(stmt);
109749 + debug_tree(gimple_get_lhs(stmt));
109750 +#endif
109751 +#endif
109752 +
109753 + if (gimple_code(stmt) != GIMPLE_ASSIGN)
109754 + continue;
109755 +
109756 +#ifdef __DEBUG_PLUGIN
109757 +#ifdef __DEBUG_VERBOSE
109758 + debug_tree(gimple_assign_rhs1(stmt));
109759 +#endif
109760 +#endif
109761 +
109762 + rhs_code = gimple_assign_rhs_code(stmt);
109763 +
109764 + if (rhs_code != ADDR_EXPR && rhs_code != SSA_NAME)
109765 + continue;
109766 +
109767 + lhs = gimple_get_lhs(stmt);
109768 + lhs_type = TREE_TYPE(lhs);
109769 + rhs1 = gimple_assign_rhs1(stmt);
109770 + rhs_type = TREE_TYPE(rhs1);
109771 +
109772 + if (TREE_CODE(rhs_type) != POINTER_TYPE ||
109773 + TREE_CODE(lhs_type) != POINTER_TYPE)
109774 + continue;
109775 +
109776 + ptr_lhs_type = TYPE_MAIN_VARIANT(strip_array_types(TYPE_MAIN_VARIANT(TREE_TYPE(lhs_type))));
109777 + ptr_rhs_type = TYPE_MAIN_VARIANT(strip_array_types(TYPE_MAIN_VARIANT(TREE_TYPE(rhs_type))));
109778 +
109779 + if (ptr_rhs_type == void_type_node)
109780 + continue;
109781 +
109782 + if (ptr_lhs_type == void_type_node)
109783 + continue;
109784 +
109785 + if (dominated_by_is_err(rhs1, bb))
109786 + continue;
109787 +
109788 + if (TREE_CODE(ptr_rhs_type) != RECORD_TYPE) {
109789 +#ifndef __DEBUG_PLUGIN
109790 + if (lookup_attribute("randomize_performed", TYPE_ATTRIBUTES(ptr_lhs_type)))
109791 +#endif
109792 + inform(gimple_location(stmt), "found mismatched struct pointer types: %qT and %qT\n", ptr_lhs_type, ptr_rhs_type);
109793 + continue;
109794 + }
109795 +
109796 + if (rhs_code == SSA_NAME && ptr_lhs_type == ptr_rhs_type)
109797 + continue;
109798 +
109799 + if (rhs_code == ADDR_EXPR) {
109800 + op0 = TREE_OPERAND(rhs1, 0);
109801 +
109802 + if (op0 == NULL_TREE)
109803 + continue;
109804 +
109805 + if (TREE_CODE(op0) != VAR_DECL)
109806 + continue;
109807 +
109808 + op0_type = TYPE_MAIN_VARIANT(strip_array_types(TYPE_MAIN_VARIANT(TREE_TYPE(op0))));
109809 + if (op0_type == ptr_lhs_type)
109810 + continue;
109811 +
109812 +#ifndef __DEBUG_PLUGIN
109813 + if (lookup_attribute("randomize_performed", TYPE_ATTRIBUTES(op0_type)))
109814 +#endif
109815 + inform(gimple_location(stmt), "found mismatched struct pointer types: %qT and %qT\n", ptr_lhs_type, op0_type);
109816 + } else {
109817 + const_tree ssa_name_var = SSA_NAME_VAR(rhs1);
109818 + /* skip bogus type casts introduced by container_of */
109819 + if (ssa_name_var != NULL_TREE && DECL_NAME(ssa_name_var) &&
109820 + !strcmp((const char *)DECL_NAME_POINTER(ssa_name_var), "__mptr"))
109821 + continue;
109822 +#ifndef __DEBUG_PLUGIN
109823 + if (lookup_attribute("randomize_performed", TYPE_ATTRIBUTES(ptr_rhs_type)))
109824 +#endif
109825 + inform(gimple_location(stmt), "found mismatched struct pointer types: %qT and %qT\n", ptr_lhs_type, ptr_rhs_type);
109826 + }
109827 +
109828 + }
109829 + }
109830 + return 0;
109831 +}
109832 +
109833 +#if BUILDING_GCC_VERSION >= 4009
109834 +static const struct pass_data randomize_layout_bad_cast_data = {
109835 +#else
109836 +static struct gimple_opt_pass randomize_layout_bad_cast = {
109837 + .pass = {
109838 +#endif
109839 + .type = GIMPLE_PASS,
109840 + .name = "randomize_layout_bad_cast",
109841 +#if BUILDING_GCC_VERSION >= 4008
109842 + .optinfo_flags = OPTGROUP_NONE,
109843 +#endif
109844 +#if BUILDING_GCC_VERSION >= 4009
109845 + .has_gate = false,
109846 + .has_execute = true,
109847 +#else
109848 + .gate = NULL,
109849 + .execute = find_bad_casts,
109850 + .sub = NULL,
109851 + .next = NULL,
109852 + .static_pass_number = 0,
109853 +#endif
109854 + .tv_id = TV_NONE,
109855 + .properties_required = PROP_cfg,
109856 + .properties_provided = 0,
109857 + .properties_destroyed = 0,
109858 + .todo_flags_start = 0,
109859 + .todo_flags_finish = TODO_dump_func
109860 +#if BUILDING_GCC_VERSION < 4009
109861 + }
109862 +#endif
109863 +};
109864 +
109865 +#if BUILDING_GCC_VERSION >= 4009
109866 +namespace {
109867 +class randomize_layout_bad_cast : public gimple_opt_pass {
109868 +public:
109869 + randomize_layout_bad_cast() : gimple_opt_pass(randomize_layout_bad_cast_data, g) {}
109870 + unsigned int execute() { return find_bad_casts(); }
109871 +};
109872 +}
109873 +#endif
109874 +
109875 +static struct opt_pass *make_randomize_layout_bad_cast(void)
109876 +{
109877 +#if BUILDING_GCC_VERSION >= 4009
109878 + return new randomize_layout_bad_cast();
109879 +#else
109880 + return &randomize_layout_bad_cast.pass;
109881 +#endif
109882 +}
109883 +
109884 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
109885 +{
109886 + int i;
109887 + const char * const plugin_name = plugin_info->base_name;
109888 + const int argc = plugin_info->argc;
109889 + const struct plugin_argument * const argv = plugin_info->argv;
109890 + bool enable = true;
109891 + int obtained_seed = 0;
109892 + struct register_pass_info randomize_layout_bad_cast_info;
109893 +
109894 + randomize_layout_bad_cast_info.pass = make_randomize_layout_bad_cast();
109895 + randomize_layout_bad_cast_info.reference_pass_name = "ssa";
109896 + randomize_layout_bad_cast_info.ref_pass_instance_number = 1;
109897 + randomize_layout_bad_cast_info.pos_op = PASS_POS_INSERT_AFTER;
109898 +
109899 + if (!plugin_default_version_check(version, &gcc_version)) {
109900 + error(G_("incompatible gcc/plugin versions"));
109901 + return 1;
109902 + }
109903 +
109904 + if (strcmp(lang_hooks.name, "GNU C")) {
109905 + inform(UNKNOWN_LOCATION, G_("%s supports C only"), plugin_name);
109906 + enable = false;
109907 + }
109908 +
109909 + for (i = 0; i < argc; ++i) {
109910 + if (!strcmp(argv[i].key, "disable")) {
109911 + enable = false;
109912 + continue;
109913 + }
109914 + if (!strcmp(argv[i].key, "performance-mode")) {
109915 + performance_mode = 1;
109916 + continue;
109917 + }
109918 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
109919 + }
109920 +
109921 + if (strlen(randstruct_seed) != 64) {
109922 + error(G_("invalid seed value supplied for %s plugin"), plugin_name);
109923 + return 1;
109924 + }
109925 + obtained_seed = sscanf(randstruct_seed, "%016llx%016llx%016llx%016llx",
109926 + &shuffle_seed[0], &shuffle_seed[1], &shuffle_seed[2], &shuffle_seed[3]);
109927 + if (obtained_seed != 4) {
109928 + error(G_("Invalid seed supplied for %s plugin"), plugin_name);
109929 + return 1;
109930 + }
109931 +
109932 + register_callback(plugin_name, PLUGIN_INFO, NULL, &randomize_layout_plugin_info);
109933 + if (enable) {
109934 + register_callback(plugin_name, PLUGIN_ALL_IPA_PASSES_START, check_global_variables, NULL);
109935 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &randomize_layout_bad_cast_info);
109936 + register_callback(plugin_name, PLUGIN_FINISH_TYPE, finish_type, NULL);
109937 + register_callback(plugin_name, PLUGIN_FINISH_DECL, randomize_layout_finish_decl, NULL);
109938 + }
109939 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
109940 +
109941 + return 0;
109942 +}
109943 diff --git a/tools/gcc/size_overflow_plugin/.gitignore b/tools/gcc/size_overflow_plugin/.gitignore
109944 new file mode 100644
109945 index 0000000..1f0214f
109946 --- /dev/null
109947 +++ b/tools/gcc/size_overflow_plugin/.gitignore
109948 @@ -0,0 +1,3 @@
109949 +randomize_layout_seed.h
109950 +size_overflow_hash.h
109951 +size_overflow_hash_aux.h
109952 diff --git a/tools/gcc/size_overflow_plugin/Makefile b/tools/gcc/size_overflow_plugin/Makefile
109953 new file mode 100644
109954 index 0000000..1ae2ed5
109955 --- /dev/null
109956 +++ b/tools/gcc/size_overflow_plugin/Makefile
109957 @@ -0,0 +1,20 @@
109958 +$(HOSTLIBS)-$(CONFIG_PAX_SIZE_OVERFLOW) += size_overflow_plugin.so
109959 +always := $($(HOSTLIBS)-y)
109960 +
109961 +size_overflow_plugin-objs := $(patsubst $(srctree)/$(src)/%.c,%.o,$(wildcard $(srctree)/$(src)/*.c))
109962 +
109963 +$(patsubst $(srctree)/$(src)/%.c,$(obj)/%.o,$(wildcard $(srctree)/$(src)/*.c)): $(objtree)/$(obj)/size_overflow_hash.h $(objtree)/$(obj)/size_overflow_hash_aux.h
109964 +
109965 +quiet_cmd_build_size_overflow_hash = GENHASH $@
109966 + cmd_build_size_overflow_hash = \
109967 + $(CONFIG_SHELL) $(srctree)/$(src)/generate_size_overflow_hash.sh -s size_overflow_hash -d $< -o $@
109968 +$(objtree)/$(obj)/size_overflow_hash.h: $(src)/size_overflow_hash.data FORCE
109969 + $(call if_changed,build_size_overflow_hash)
109970 +
109971 +quiet_cmd_build_size_overflow_hash_aux = GENHASH $@
109972 + cmd_build_size_overflow_hash_aux = \
109973 + $(CONFIG_SHELL) $(srctree)/$(src)/generate_size_overflow_hash.sh -s size_overflow_hash_aux -d $< -o $@
109974 +$(objtree)/$(obj)/size_overflow_hash_aux.h: $(src)/size_overflow_hash_aux.data FORCE
109975 + $(call if_changed,build_size_overflow_hash_aux)
109976 +
109977 +targets += size_overflow_hash.h size_overflow_hash_aux.h
109978 diff --git a/tools/gcc/size_overflow_plugin/generate_size_overflow_hash.sh b/tools/gcc/size_overflow_plugin/generate_size_overflow_hash.sh
109979 new file mode 100644
109980 index 0000000..12b1e3b
109981 --- /dev/null
109982 +++ b/tools/gcc/size_overflow_plugin/generate_size_overflow_hash.sh
109983 @@ -0,0 +1,102 @@
109984 +#!/bin/bash
109985 +
109986 +# This script generates the hash table (size_overflow_hash.h) for the size_overflow gcc plugin (size_overflow_plugin.c).
109987 +
109988 +header1="size_overflow_hash.h"
109989 +database="size_overflow_hash.data"
109990 +n=65536
109991 +hashtable_name="size_overflow_hash"
109992 +
109993 +usage() {
109994 +cat <<EOF
109995 +usage: $0 options
109996 +OPTIONS:
109997 + -h|--help help
109998 + -o header file
109999 + -d database file
110000 + -n hash array size
110001 + -s name of the hash table
110002 +EOF
110003 + return 0
110004 +}
110005 +
110006 +while true
110007 +do
110008 + case "$1" in
110009 + -h|--help) usage && exit 0;;
110010 + -n) n=$2; shift 2;;
110011 + -o) header1="$2"; shift 2;;
110012 + -d) database="$2"; shift 2;;
110013 + -s) hashtable_name="$2"; shift 2;;
110014 + --) shift 1; break ;;
110015 + *) break ;;
110016 + esac
110017 +done
110018 +
110019 +create_defines() {
110020 + for i in `seq 0 31`
110021 + do
110022 + echo -e "#define PARAM"$i" (1U << "$i")" >> "$header1"
110023 + done
110024 + echo >> "$header1"
110025 +}
110026 +
110027 +create_structs() {
110028 + rm -f "$header1"
110029 +
110030 + create_defines
110031 +
110032 + cat "$database" | while read data
110033 + do
110034 + data_array=($data)
110035 + struct_hash_name="${data_array[0]}"
110036 + funcn="${data_array[1]}"
110037 + params="${data_array[2]}"
110038 + next="${data_array[4]}"
110039 +
110040 + echo "const struct size_overflow_hash $struct_hash_name = {" >> "$header1"
110041 +
110042 + echo -e "\t.next\t= $next,\n\t.name\t= \"$funcn\"," >> "$header1"
110043 + echo -en "\t.param\t= " >> "$header1"
110044 + line=
110045 + for param_num in ${params//-/ };
110046 + do
110047 + line="${line}PARAM"$param_num"|"
110048 + done
110049 +
110050 + echo -e "${line%?},\n};\n" >> "$header1"
110051 + done
110052 +}
110053 +
110054 +create_headers() {
110055 + echo "const struct size_overflow_hash * const $hashtable_name[$n] = {" >> "$header1"
110056 +}
110057 +
110058 +create_array_elements() {
110059 + index=0
110060 + grep -v "nohasharray" $database | sort -n -k 4 | while read data
110061 + do
110062 + data_array=($data)
110063 + i="${data_array[3]}"
110064 + hash="${data_array[0]}"
110065 + while [[ $index -lt $i ]]
110066 + do
110067 + echo -e "\t["$index"]\t= NULL," >> "$header1"
110068 + index=$(($index + 1))
110069 + done
110070 + index=$(($index + 1))
110071 + echo -e "\t["$i"]\t= &"$hash"," >> "$header1"
110072 + done
110073 + echo '};' >> $header1
110074 +}
110075 +
110076 +size_overflow_plugin_dir=`dirname $header1`
110077 +if [ "$size_overflow_plugin_dir" != '.' ]; then
110078 + mkdir -p "$size_overflow_plugin_dir" 2> /dev/null
110079 +fi
110080 +
110081 +create_structs
110082 +create_headers
110083 +create_array_elements
110084 +
110085 +exit 0
110086 diff --git a/tools/gcc/size_overflow_plugin/insert_size_overflow_asm.c b/tools/gcc/size_overflow_plugin/insert_size_overflow_asm.c
110087 new file mode 100644
110088 index 0000000..3e8148c
110089 --- /dev/null
110090 +++ b/tools/gcc/size_overflow_plugin/insert_size_overflow_asm.c
110091 @@ -0,0 +1,790 @@
110092 +/*
110093 + * Copyright 2011-2014 by Emese Revfy <re.emese@gmail.com>
110094 + * Licensed under the GPL v2, or (at your option) v3
110095 + *
110096 + * Homepage:
110097 + * http://www.grsecurity.net/~ephox/overflow_plugin/
110098 + *
110099 + * Documentation:
110100 + * http://forums.grsecurity.net/viewtopic.php?f=7&t=3043
110101 + *
110102 + * This plugin recomputes expressions of function arguments marked by a size_overflow attribute
110103 + * with double integer precision (DImode/TImode for 32/64 bit integer types).
110104 + * The recomputed argument is checked against TYPE_MAX and an event is logged on overflow and the triggering process is killed.
110105 + *
110106 + * Usage:
110107 + * $ make
110108 + * $ make run
110109 + */
110110 +
110111 +#include "gcc-common.h"
110112 +#include "size_overflow.h"
110113 +
110114 +static void search_size_overflow_attribute(struct pointer_set_t *visited, tree lhs);
110115 +static enum mark search_intentional(struct pointer_set_t *visited, const_tree lhs);
110116 +
110117 +// data for the size_overflow asm stmt
110118 +struct asm_data {
110119 + gimple def_stmt;
110120 + tree input;
110121 + tree output;
110122 +};
110123 +
110124 +#if BUILDING_GCC_VERSION <= 4007
110125 +static VEC(tree, gc) *create_asm_io_list(tree string, tree io)
110126 +#else
110127 +static vec<tree, va_gc> *create_asm_io_list(tree string, tree io)
110128 +#endif
110129 +{
110130 + tree list;
110131 +#if BUILDING_GCC_VERSION <= 4007
110132 + VEC(tree, gc) *vec_list = NULL;
110133 +#else
110134 + vec<tree, va_gc> *vec_list = NULL;
110135 +#endif
110136 +
110137 + list = build_tree_list(NULL_TREE, string);
110138 + list = chainon(NULL_TREE, build_tree_list(list, io));
110139 +#if BUILDING_GCC_VERSION <= 4007
110140 + VEC_safe_push(tree, gc, vec_list, list);
110141 +#else
110142 + vec_safe_push(vec_list, list);
110143 +#endif
110144 + return vec_list;
110145 +}
110146 +
110147 +static void create_asm_stmt(const char *str, tree str_input, tree str_output, struct asm_data *asm_data)
110148 +{
110149 + gimple asm_stmt;
110150 + gimple_stmt_iterator gsi;
110151 +#if BUILDING_GCC_VERSION <= 4007
110152 + VEC(tree, gc) *input, *output = NULL;
110153 +#else
110154 + vec<tree, va_gc> *input, *output = NULL;
110155 +#endif
110156 +
110157 + input = create_asm_io_list(str_input, asm_data->input);
110158 +
110159 + if (asm_data->output)
110160 + output = create_asm_io_list(str_output, asm_data->output);
110161 +
110162 + asm_stmt = gimple_build_asm_vec(str, input, output, NULL, NULL);
110163 + gsi = gsi_for_stmt(asm_data->def_stmt);
110164 + gsi_insert_after(&gsi, asm_stmt, GSI_NEW_STMT);
110165 +
110166 + if (asm_data->output)
110167 + SSA_NAME_DEF_STMT(asm_data->output) = asm_stmt;
110168 +}
110169 +
110170 +static void replace_call_lhs(const struct asm_data *asm_data)
110171 +{
110172 + gimple_set_lhs(asm_data->def_stmt, asm_data->input);
110173 + update_stmt(asm_data->def_stmt);
110174 + SSA_NAME_DEF_STMT(asm_data->input) = asm_data->def_stmt;
110175 +}
110176 +
110177 +static enum mark search_intentional_phi(struct pointer_set_t *visited, const_tree result)
110178 +{
110179 + enum mark cur_fndecl_attr;
110180 + gimple phi = get_def_stmt(result);
110181 + unsigned int i, n = gimple_phi_num_args(phi);
110182 +
110183 + pointer_set_insert(visited, phi);
110184 + for (i = 0; i < n; i++) {
110185 + tree arg = gimple_phi_arg_def(phi, i);
110186 +
110187 + cur_fndecl_attr = search_intentional(visited, arg);
110188 + if (cur_fndecl_attr != MARK_NO)
110189 + return cur_fndecl_attr;
110190 + }
110191 + return MARK_NO;
110192 +}
110193 +
110194 +static enum mark search_intentional_binary(struct pointer_set_t *visited, const_tree lhs)
110195 +{
110196 + enum mark cur_fndecl_attr;
110197 + const_tree rhs1, rhs2;
110198 + gimple def_stmt = get_def_stmt(lhs);
110199 +
110200 + rhs1 = gimple_assign_rhs1(def_stmt);
110201 + rhs2 = gimple_assign_rhs2(def_stmt);
110202 +
110203 + cur_fndecl_attr = search_intentional(visited, rhs1);
110204 + if (cur_fndecl_attr != MARK_NO)
110205 + return cur_fndecl_attr;
110206 + return search_intentional(visited, rhs2);
110207 +}
110208 +
110209 +// Look up the intentional_overflow attribute on the caller and the callee functions.
110210 +static enum mark search_intentional(struct pointer_set_t *visited, const_tree lhs)
110211 +{
110212 + const_gimple def_stmt;
110213 +
110214 + if (TREE_CODE(lhs) != SSA_NAME)
110215 + return get_intentional_attr_type(lhs);
110216 +
110217 + def_stmt = get_def_stmt(lhs);
110218 + if (!def_stmt)
110219 + return MARK_NO;
110220 +
110221 + if (pointer_set_contains(visited, def_stmt))
110222 + return MARK_NO;
110223 +
110224 + switch (gimple_code(def_stmt)) {
110225 + case GIMPLE_NOP:
110226 + return search_intentional(visited, SSA_NAME_VAR(lhs));
110227 + case GIMPLE_ASM:
110228 + if (is_size_overflow_intentional_asm_turn_off(def_stmt))
110229 + return MARK_TURN_OFF;
110230 + return MARK_NO;
110231 + case GIMPLE_CALL:
110232 + return MARK_NO;
110233 + case GIMPLE_PHI:
110234 + return search_intentional_phi(visited, lhs);
110235 + case GIMPLE_ASSIGN:
110236 + switch (gimple_num_ops(def_stmt)) {
110237 + case 2:
110238 + return search_intentional(visited, gimple_assign_rhs1(def_stmt));
110239 + case 3:
110240 + return search_intentional_binary(visited, lhs);
110241 + }
110242 + case GIMPLE_RETURN:
110243 + return MARK_NO;
110244 + default:
110245 + debug_gimple_stmt((gimple)def_stmt);
110246 + error("%s: unknown gimple code", __func__);
110247 + gcc_unreachable();
110248 + }
110249 +}
110250 +
110251 +// Check the intentional_overflow attribute and create the asm comment string for the size_overflow asm stmt.
110252 +static enum mark check_intentional_attribute_gimple(const_tree arg, const_gimple stmt, unsigned int argnum)
110253 +{
110254 + const_tree fndecl;
110255 + struct pointer_set_t *visited;
110256 + enum mark cur_fndecl_attr, decl_attr = MARK_NO;
110257 +
110258 + fndecl = get_interesting_orig_fndecl(stmt, argnum);
110259 + if (is_end_intentional_intentional_attr(fndecl, argnum))
110260 + decl_attr = MARK_NOT_INTENTIONAL;
110261 + else if (is_yes_intentional_attr(fndecl, argnum))
110262 + decl_attr = MARK_YES;
110263 + else if (is_turn_off_intentional_attr(fndecl) || is_turn_off_intentional_attr(DECL_ORIGIN(current_function_decl))) {
110264 + return MARK_TURN_OFF;
110265 + }
110266 +
110267 + visited = pointer_set_create();
110268 + cur_fndecl_attr = search_intentional(visited, arg);
110269 + pointer_set_destroy(visited);
110270 +
110271 + switch (cur_fndecl_attr) {
110272 + case MARK_NO:
110273 + case MARK_TURN_OFF:
110274 + return cur_fndecl_attr;
110275 + default:
110276 + print_missing_intentional(decl_attr, cur_fndecl_attr, fndecl, argnum);
110277 + return MARK_YES;
110278 + }
110279 +}
110280 +
110281 +static void check_missing_size_overflow_attribute(tree var)
110282 +{
110283 + tree orig_fndecl;
110284 + unsigned int num;
110285 +
110286 + if (is_a_return_check(var))
110287 + orig_fndecl = DECL_ORIGIN(var);
110288 + else
110289 + orig_fndecl = DECL_ORIGIN(current_function_decl);
110290 +
110291 + num = get_function_num(var, orig_fndecl);
110292 + if (num == CANNOT_FIND_ARG)
110293 + return;
110294 +
110295 + is_missing_function(orig_fndecl, num);
110296 +}
110297 +
110298 +static void search_size_overflow_attribute_phi(struct pointer_set_t *visited, const_tree result)
110299 +{
110300 + gimple phi = get_def_stmt(result);
110301 + unsigned int i, n = gimple_phi_num_args(phi);
110302 +
110303 + pointer_set_insert(visited, phi);
110304 + for (i = 0; i < n; i++) {
110305 + tree arg = gimple_phi_arg_def(phi, i);
110306 +
110307 + search_size_overflow_attribute(visited, arg);
110308 + }
110309 +}
110310 +
110311 +static void search_size_overflow_attribute_binary(struct pointer_set_t *visited, const_tree lhs)
110312 +{
110313 + const_gimple def_stmt = get_def_stmt(lhs);
110314 + tree rhs1, rhs2;
110315 +
110316 + rhs1 = gimple_assign_rhs1(def_stmt);
110317 + rhs2 = gimple_assign_rhs2(def_stmt);
110318 +
110319 + search_size_overflow_attribute(visited, rhs1);
110320 + search_size_overflow_attribute(visited, rhs2);
110321 +}
110322 +
110323 +static void search_size_overflow_attribute(struct pointer_set_t *visited, tree lhs)
110324 +{
110325 + const_gimple def_stmt;
110326 +
110327 + if (TREE_CODE(lhs) == PARM_DECL) {
110328 + check_missing_size_overflow_attribute(lhs);
110329 + return;
110330 + }
110331 +
110332 + def_stmt = get_def_stmt(lhs);
110333 + if (!def_stmt)
110334 + return;
110335 +
110336 + if (pointer_set_insert(visited, def_stmt))
110337 + return;
110338 +
110339 + switch (gimple_code(def_stmt)) {
110340 + case GIMPLE_NOP:
110341 + return search_size_overflow_attribute(visited, SSA_NAME_VAR(lhs));
110342 + case GIMPLE_ASM:
110343 + return;
110344 + case GIMPLE_CALL: {
110345 + tree fndecl = gimple_call_fndecl(def_stmt);
110346 +
110347 + if (fndecl == NULL_TREE)
110348 + return;
110349 + check_missing_size_overflow_attribute(fndecl);
110350 + return;
110351 + }
110352 + case GIMPLE_PHI:
110353 + return search_size_overflow_attribute_phi(visited, lhs);
110354 + case GIMPLE_ASSIGN:
110355 + switch (gimple_num_ops(def_stmt)) {
110356 + case 2:
110357 + return search_size_overflow_attribute(visited, gimple_assign_rhs1(def_stmt));
110358 + case 3:
110359 + return search_size_overflow_attribute_binary(visited, lhs);
110360 + }
110361 + default:
110362 + debug_gimple_stmt((gimple)def_stmt);
110363 + error("%s: unknown gimple code", __func__);
110364 + gcc_unreachable();
110365 + }
110366 +}
110367 +
110368 +// Search missing entries in the hash table (invoked from the gimple pass)
110369 +static void search_missing_size_overflow_attribute_gimple(const_gimple stmt, unsigned int num)
110370 +{
110371 + tree fndecl = NULL_TREE;
110372 + tree lhs;
110373 + struct pointer_set_t *visited;
110374 +
110375 + if (is_turn_off_intentional_attr(DECL_ORIGIN(current_function_decl)))
110376 + return;
110377 +
110378 + if (num == 0) {
110379 + gcc_assert(gimple_code(stmt) == GIMPLE_RETURN);
110380 + lhs = gimple_return_retval(stmt);
110381 + } else {
110382 + gcc_assert(is_gimple_call(stmt));
110383 + lhs = gimple_call_arg(stmt, num - 1);
110384 + fndecl = gimple_call_fndecl(stmt);
110385 + }
110386 +
110387 + if (fndecl != NULL_TREE && is_turn_off_intentional_attr(DECL_ORIGIN(fndecl)))
110388 + return;
110389 +
110390 + visited = pointer_set_create();
110391 + search_size_overflow_attribute(visited, lhs);
110392 + pointer_set_destroy(visited);
110393 +}
110394 +
110395 +static void create_output_from_phi(gimple stmt, unsigned int argnum, struct asm_data *asm_data)
110396 +{
110397 + gimple_stmt_iterator gsi;
110398 + gimple assign;
110399 +
110400 + assign = gimple_build_assign(asm_data->input, asm_data->output);
110401 + gsi = gsi_for_stmt(stmt);
110402 + gsi_insert_before(&gsi, assign, GSI_NEW_STMT);
110403 + asm_data->def_stmt = assign;
110404 +
110405 + asm_data->output = create_new_var(TREE_TYPE(asm_data->output));
110406 + asm_data->output = make_ssa_name(asm_data->output, stmt);
110407 + if (gimple_code(stmt) == GIMPLE_RETURN)
110408 + gimple_return_set_retval(stmt, asm_data->output);
110409 + else
110410 + gimple_call_set_arg(stmt, argnum - 1, asm_data->output);
110411 + update_stmt(stmt);
110412 +}
110413 +
110414 +static char *create_asm_comment(unsigned int argnum, const_gimple stmt , const char *mark_str)
110415 +{
110416 + const char *fn_name;
110417 + char *asm_comment;
110418 + unsigned int len;
110419 +
110420 + if (argnum == 0)
110421 + fn_name = DECL_NAME_POINTER(current_function_decl);
110422 + else
110423 + fn_name = DECL_NAME_POINTER(gimple_call_fndecl(stmt));
110424 +
110425 + len = asprintf(&asm_comment, "%s %s %u", mark_str, fn_name, argnum);
110426 + gcc_assert(len > 0);
110427 +
110428 + return asm_comment;
110429 +}
110430 +
110431 +static const char *convert_mark_to_str(enum mark mark)
110432 +{
110433 + switch (mark) {
110434 + case MARK_NO:
110435 + return OK_ASM_STR;
110436 + case MARK_YES:
110437 + case MARK_NOT_INTENTIONAL:
110438 + return YES_ASM_STR;
110439 + case MARK_TURN_OFF:
110440 + return TURN_OFF_ASM_STR;
110441 + }
110442 +
110443 + gcc_unreachable();
110444 +}
110445 +
110446 +/* Create the input of the size_overflow asm stmt.
110447 + * When the arg of the callee function is a parm_decl it creates this kind of size_overflow asm stmt:
110448 + * __asm__("# size_overflow MARK_YES" : : "rm" size_1(D));
110449 + * The input field in asm_data will be empty if there is no need for further size_overflow asm stmt insertion.
110450 + * otherwise create the input (for a phi stmt the output too) of the asm stmt.
110451 + */
110452 +static void create_asm_input(gimple stmt, unsigned int argnum, struct asm_data *asm_data)
110453 +{
110454 + if (!asm_data->def_stmt) {
110455 + asm_data->input = NULL_TREE;
110456 + return;
110457 + }
110458 +
110459 + asm_data->input = create_new_var(TREE_TYPE(asm_data->output));
110460 + asm_data->input = make_ssa_name(asm_data->input, asm_data->def_stmt);
110461 +
110462 + switch (gimple_code(asm_data->def_stmt)) {
110463 + case GIMPLE_ASSIGN:
110464 + case GIMPLE_CALL:
110465 + replace_call_lhs(asm_data);
110466 + break;
110467 + case GIMPLE_PHI:
110468 + create_output_from_phi(stmt, argnum, asm_data);
110469 + break;
110470 + case GIMPLE_NOP: {
110471 + enum mark mark;
110472 + const char *mark_str;
110473 + char *asm_comment;
110474 +
110475 + mark = check_intentional_attribute_gimple(asm_data->output, stmt, argnum);
110476 +
110477 + asm_data->input = asm_data->output;
110478 + asm_data->output = NULL;
110479 + asm_data->def_stmt = stmt;
110480 +
110481 + mark_str = convert_mark_to_str(mark);
110482 + asm_comment = create_asm_comment(argnum, stmt, mark_str);
110483 +
110484 + create_asm_stmt(asm_comment, build_string(3, "rm"), NULL, asm_data);
110485 + free(asm_comment);
110486 + asm_data->input = NULL_TREE;
110487 + break;
110488 + }
110489 + case GIMPLE_ASM:
110490 + if (is_size_overflow_asm(asm_data->def_stmt)) {
110491 + asm_data->input = NULL_TREE;
110492 + break;
110493 + }
110494 + default:
110495 + debug_gimple_stmt(asm_data->def_stmt);
110496 + gcc_unreachable();
110497 + }
110498 +}
110499 +
110500 +/* This is the gimple part of searching for a missing size_overflow attribute. If the intentional_overflow attribute type
110501 + * is of the right kind create the appropriate size_overflow asm stmts:
110502 + * __asm__("# size_overflow" : =rm" D.3344_8 : "0" cicus.4_16);
110503 + * __asm__("# size_overflow MARK_YES" : : "rm" size_1(D));
110504 + */
110505 +static void create_size_overflow_asm(gimple stmt, tree output_node, unsigned int argnum)
110506 +{
110507 + struct asm_data asm_data;
110508 + const char *mark_str;
110509 + char *asm_comment;
110510 + enum mark mark;
110511 +
110512 + if (is_gimple_constant(output_node))
110513 + return;
110514 +
110515 + asm_data.output = output_node;
110516 + mark = check_intentional_attribute_gimple(asm_data.output, stmt, argnum);
110517 + if (mark != MARK_TURN_OFF)
110518 + search_missing_size_overflow_attribute_gimple(stmt, argnum);
110519 +
110520 + asm_data.def_stmt = get_def_stmt(asm_data.output);
110521 + if (is_size_overflow_intentional_asm_turn_off(asm_data.def_stmt))
110522 + return;
110523 +
110524 + create_asm_input(stmt, argnum, &asm_data);
110525 + if (asm_data.input == NULL_TREE)
110526 + return;
110527 +
110528 + mark_str = convert_mark_to_str(mark);
110529 + asm_comment = create_asm_comment(argnum, stmt, mark_str);
110530 + create_asm_stmt(asm_comment, build_string(2, "0"), build_string(4, "=rm"), &asm_data);
110531 + free(asm_comment);
110532 +}
110533 +
110534 +// Insert an asm stmt with "MARK_TURN_OFF", "MARK_YES" or "MARK_NOT_INTENTIONAL".
110535 +static bool create_mark_asm(gimple stmt, enum mark mark)
110536 +{
110537 + struct asm_data asm_data;
110538 + const char *asm_str;
110539 +
110540 + switch (mark) {
110541 + case MARK_TURN_OFF:
110542 + asm_str = TURN_OFF_ASM_STR;
110543 + break;
110544 + case MARK_NOT_INTENTIONAL:
110545 + case MARK_YES:
110546 + asm_str = YES_ASM_STR;
110547 + break;
110548 + default:
110549 + gcc_unreachable();
110550 + }
110551 +
110552 + asm_data.def_stmt = stmt;
110553 + asm_data.output = gimple_call_lhs(stmt);
110554 +
110555 + if (asm_data.output == NULL_TREE) {
110556 + asm_data.input = gimple_call_arg(stmt, 0);
110557 + if (is_gimple_constant(asm_data.input))
110558 + return false;
110559 + asm_data.output = NULL;
110560 + create_asm_stmt(asm_str, build_string(3, "rm"), NULL, &asm_data);
110561 + return true;
110562 + }
110563 +
110564 + create_asm_input(stmt, 0, &asm_data);
110565 + gcc_assert(asm_data.input != NULL_TREE);
110566 +
110567 + create_asm_stmt(asm_str, build_string(2, "0"), build_string(4, "=rm"), &asm_data);
110568 + return true;
110569 +}
110570 +
110571 +static bool is_from_cast(const_tree node)
110572 +{
110573 + gimple def_stmt = get_def_stmt(node);
110574 +
110575 + if (!def_stmt)
110576 + return false;
110577 +
110578 + if (gimple_assign_cast_p(def_stmt))
110579 + return true;
110580 +
110581 + return false;
110582 +}
110583 +
110584 +// Skip duplication when there is a minus expr and the type of rhs1 or rhs2 is a pointer_type.
110585 +static bool skip_ptr_minus(gimple stmt)
110586 +{
110587 + const_tree rhs1, rhs2, ptr1_rhs, ptr2_rhs;
110588 +
110589 + if (gimple_assign_rhs_code(stmt) != MINUS_EXPR)
110590 + return false;
110591 +
110592 + rhs1 = gimple_assign_rhs1(stmt);
110593 + if (!is_from_cast(rhs1))
110594 + return false;
110595 +
110596 + rhs2 = gimple_assign_rhs2(stmt);
110597 + if (!is_from_cast(rhs2))
110598 + return false;
110599 +
110600 + ptr1_rhs = gimple_assign_rhs1(get_def_stmt(rhs1));
110601 + ptr2_rhs = gimple_assign_rhs1(get_def_stmt(rhs2));
110602 +
110603 + if (TREE_CODE(TREE_TYPE(ptr1_rhs)) != POINTER_TYPE && TREE_CODE(TREE_TYPE(ptr2_rhs)) != POINTER_TYPE)
110604 + return false;
110605 +
110606 + create_mark_asm(stmt, MARK_YES);
110607 + return true;
110608 +}
110609 +
110610 +static void walk_use_def_ptr(struct pointer_set_t *visited, const_tree lhs)
110611 +{
110612 + gimple def_stmt;
110613 +
110614 + def_stmt = get_def_stmt(lhs);
110615 + if (!def_stmt)
110616 + return;
110617 +
110618 + if (pointer_set_insert(visited, def_stmt))
110619 + return;
110620 +
110621 + switch (gimple_code(def_stmt)) {
110622 + case GIMPLE_NOP:
110623 + case GIMPLE_ASM:
110624 + case GIMPLE_CALL:
110625 + break;
110626 + case GIMPLE_PHI: {
110627 + unsigned int i, n = gimple_phi_num_args(def_stmt);
110628 +
110629 + pointer_set_insert(visited, def_stmt);
110630 +
110631 + for (i = 0; i < n; i++) {
110632 + tree arg = gimple_phi_arg_def(def_stmt, i);
110633 +
110634 + walk_use_def_ptr(visited, arg);
110635 + }
110636 + }
110637 + case GIMPLE_ASSIGN:
110638 + switch (gimple_num_ops(def_stmt)) {
110639 + case 2:
110640 + walk_use_def_ptr(visited, gimple_assign_rhs1(def_stmt));
110641 + return;
110642 + case 3:
110643 + if (skip_ptr_minus(def_stmt))
110644 + return;
110645 +
110646 + walk_use_def_ptr(visited, gimple_assign_rhs1(def_stmt));
110647 + walk_use_def_ptr(visited, gimple_assign_rhs2(def_stmt));
110648 + return;
110649 + default:
110650 + return;
110651 + }
110652 + default:
110653 + debug_gimple_stmt((gimple)def_stmt);
110654 + error("%s: unknown gimple code", __func__);
110655 + gcc_unreachable();
110656 + }
110657 +}
110658 +
110659 +// Look for a ptr - ptr expression (e.g., cpuset_common_file_read() s - page)
110660 +static void insert_mark_not_intentional_asm_at_ptr(const_tree arg)
110661 +{
110662 + struct pointer_set_t *visited;
110663 +
110664 + visited = pointer_set_create();
110665 + walk_use_def_ptr(visited, arg);
110666 + pointer_set_destroy(visited);
110667 +}
110668 +
110669 +// Determine the return value and insert the asm stmt to mark the return stmt.
110670 +static void insert_asm_ret(gimple stmt)
110671 +{
110672 + tree ret;
110673 +
110674 + ret = gimple_return_retval(stmt);
110675 + create_size_overflow_asm(stmt, ret, 0);
110676 +}
110677 +
110678 +// Determine the correct arg index and arg and insert the asm stmt to mark the stmt.
110679 +static void insert_asm_arg(gimple stmt, unsigned int orig_argnum)
110680 +{
110681 + tree arg;
110682 + unsigned int argnum;
110683 +
110684 + argnum = get_correct_arg_count(orig_argnum, gimple_call_fndecl(stmt));
110685 + gcc_assert(argnum != 0);
110686 + if (argnum == CANNOT_FIND_ARG)
110687 + return;
110688 +
110689 + arg = gimple_call_arg(stmt, argnum - 1);
110690 + gcc_assert(arg != NULL_TREE);
110691 +
110692 + // skip all ptr - ptr expressions
110693 + insert_mark_not_intentional_asm_at_ptr(arg);
110694 +
110695 + create_size_overflow_asm(stmt, arg, argnum);
110696 +}
110697 +
110698 +// If a function arg or the return value is marked by the size_overflow attribute then set its index in the array.
110699 +static void set_argnum_attribute(const_tree attr, bool *argnums)
110700 +{
110701 + unsigned int argnum;
110702 + tree attr_value;
110703 +
110704 + for (attr_value = TREE_VALUE(attr); attr_value; attr_value = TREE_CHAIN(attr_value)) {
110705 + argnum = TREE_INT_CST_LOW(TREE_VALUE(attr_value));
110706 + argnums[argnum] = true;
110707 + }
110708 +}
110709 +
110710 +// If a function arg or the return value is in the hash table then set its index in the array.
110711 +static void set_argnum_hash(tree fndecl, bool *argnums)
110712 +{
110713 + unsigned int num;
110714 + const struct size_overflow_hash *hash;
110715 +
110716 + hash = get_function_hash(DECL_ORIGIN(fndecl));
110717 + if (!hash)
110718 + return;
110719 +
110720 + for (num = 0; num <= MAX_PARAM; num++) {
110721 + if (!(hash->param & (1U << num)))
110722 + continue;
110723 +
110724 + argnums[num] = true;
110725 + }
110726 +}
110727 +
110728 +static bool is_all_the_argnums_empty(bool *argnums)
110729 +{
110730 + unsigned int i;
110731 +
110732 + for (i = 0; i <= MAX_PARAM; i++)
110733 + if (argnums[i])
110734 + return false;
110735 + return true;
110736 +}
110737 +
110738 +// Check whether the arguments or the return value of the function are in the hash table or are marked by the size_overflow attribute.
110739 +static void search_interesting_args(tree fndecl, bool *argnums)
110740 +{
110741 + const_tree attr;
110742 +
110743 + set_argnum_hash(fndecl, argnums);
110744 + if (!is_all_the_argnums_empty(argnums))
110745 + return;
110746 +
110747 + attr = lookup_attribute("size_overflow", DECL_ATTRIBUTES(fndecl));
110748 + if (attr && TREE_VALUE(attr))
110749 + set_argnum_attribute(attr, argnums);
110750 +}
110751 +
110752 +/*
110753 + * Look up the intentional_overflow attribute that turns off ipa based duplication
110754 + * on the callee function.
110755 + */
110756 +static bool is_mark_turn_off_attribute(gimple stmt)
110757 +{
110758 + enum mark mark;
110759 + const_tree fndecl = gimple_call_fndecl(stmt);
110760 +
110761 + mark = get_intentional_attr_type(DECL_ORIGIN(fndecl));
110762 + if (mark == MARK_TURN_OFF)
110763 + return true;
110764 + return false;
110765 +}
110766 +
110767 +// 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
110768 +static void handle_interesting_function(gimple stmt)
110769 +{
110770 + unsigned int argnum;
110771 + tree fndecl;
110772 + bool orig_argnums[MAX_PARAM + 1] = {false};
110773 +
110774 + if (gimple_call_num_args(stmt) == 0)
110775 + return;
110776 + fndecl = gimple_call_fndecl(stmt);
110777 + if (fndecl == NULL_TREE)
110778 + return;
110779 + fndecl = DECL_ORIGIN(fndecl);
110780 +
110781 + if (is_mark_turn_off_attribute(stmt)) {
110782 + create_mark_asm(stmt, MARK_TURN_OFF);
110783 + return;
110784 + }
110785 +
110786 + search_interesting_args(fndecl, orig_argnums);
110787 +
110788 + for (argnum = 1; argnum < MAX_PARAM; argnum++)
110789 + if (orig_argnums[argnum])
110790 + insert_asm_arg(stmt, argnum);
110791 +}
110792 +
110793 +// 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
110794 +static void handle_interesting_ret(gimple stmt)
110795 +{
110796 + bool orig_argnums[MAX_PARAM + 1] = {false};
110797 +
110798 + search_interesting_args(current_function_decl, orig_argnums);
110799 +
110800 + if (orig_argnums[0])
110801 + insert_asm_ret(stmt);
110802 +}
110803 +
110804 +// Iterate over all the stmts and search for call and return stmts and mark them if they're in the hash table
110805 +static unsigned int search_interesting_functions(void)
110806 +{
110807 + basic_block bb;
110808 +
110809 + FOR_ALL_BB_FN(bb, cfun) {
110810 + gimple_stmt_iterator gsi;
110811 +
110812 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
110813 + gimple stmt = gsi_stmt(gsi);
110814 +
110815 + if (is_size_overflow_asm(stmt))
110816 + continue;
110817 +
110818 + if (is_gimple_call(stmt))
110819 + handle_interesting_function(stmt);
110820 + else if (gimple_code(stmt) == GIMPLE_RETURN)
110821 + handle_interesting_ret(stmt);
110822 + }
110823 + }
110824 + return 0;
110825 +}
110826 +
110827 +/*
110828 + * A lot of functions get inlined before the ipa passes so after the build_ssa gimple pass
110829 + * this pass inserts asm stmts to mark the interesting args
110830 + * that the ipa pass will detect and insert the size overflow checks for.
110831 + */
110832 +#if BUILDING_GCC_VERSION >= 4009
110833 +static const struct pass_data insert_size_overflow_asm_pass_data = {
110834 +#else
110835 +static struct gimple_opt_pass insert_size_overflow_asm_pass = {
110836 + .pass = {
110837 +#endif
110838 + .type = GIMPLE_PASS,
110839 + .name = "insert_size_overflow_asm",
110840 +#if BUILDING_GCC_VERSION >= 4008
110841 + .optinfo_flags = OPTGROUP_NONE,
110842 +#endif
110843 +#if BUILDING_GCC_VERSION >= 4009
110844 + .has_gate = false,
110845 + .has_execute = true,
110846 +#else
110847 + .gate = NULL,
110848 + .execute = search_interesting_functions,
110849 + .sub = NULL,
110850 + .next = NULL,
110851 + .static_pass_number = 0,
110852 +#endif
110853 + .tv_id = TV_NONE,
110854 + .properties_required = PROP_cfg,
110855 + .properties_provided = 0,
110856 + .properties_destroyed = 0,
110857 + .todo_flags_start = 0,
110858 + .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
110859 +#if BUILDING_GCC_VERSION < 4009
110860 + }
110861 +#endif
110862 +};
110863 +
110864 +#if BUILDING_GCC_VERSION >= 4009
110865 +namespace {
110866 +class insert_size_overflow_asm_pass : public gimple_opt_pass {
110867 +public:
110868 + insert_size_overflow_asm_pass() : gimple_opt_pass(insert_size_overflow_asm_pass_data, g) {}
110869 + unsigned int execute() { return search_interesting_functions(); }
110870 +};
110871 +}
110872 +#endif
110873 +
110874 +struct opt_pass *make_insert_size_overflow_asm_pass(void)
110875 +{
110876 +#if BUILDING_GCC_VERSION >= 4009
110877 + return new insert_size_overflow_asm_pass();
110878 +#else
110879 + return &insert_size_overflow_asm_pass.pass;
110880 +#endif
110881 +}
110882 diff --git a/tools/gcc/size_overflow_plugin/insert_size_overflow_check_core.c b/tools/gcc/size_overflow_plugin/insert_size_overflow_check_core.c
110883 new file mode 100644
110884 index 0000000..88469e9
110885 --- /dev/null
110886 +++ b/tools/gcc/size_overflow_plugin/insert_size_overflow_check_core.c
110887 @@ -0,0 +1,902 @@
110888 +/*
110889 + * Copyright 2011-2014 by Emese Revfy <re.emese@gmail.com>
110890 + * Licensed under the GPL v2, or (at your option) v3
110891 + *
110892 + * Homepage:
110893 + * http://www.grsecurity.net/~ephox/overflow_plugin/
110894 + *
110895 + * Documentation:
110896 + * http://forums.grsecurity.net/viewtopic.php?f=7&t=3043
110897 + *
110898 + * This plugin recomputes expressions of function arguments marked by a size_overflow attribute
110899 + * with double integer precision (DImode/TImode for 32/64 bit integer types).
110900 + * The recomputed argument is checked against TYPE_MAX and an event is logged on overflow and the triggering process is killed.
110901 + *
110902 + * Usage:
110903 + * $ make
110904 + * $ make run
110905 + */
110906 +
110907 +#include "gcc-common.h"
110908 +#include "size_overflow.h"
110909 +
110910 +#define MIN_CHECK true
110911 +#define MAX_CHECK false
110912 +
110913 +static tree get_size_overflow_type(struct visited *visited, const_gimple stmt, const_tree node)
110914 +{
110915 + const_tree type;
110916 + tree new_type;
110917 +
110918 + gcc_assert(node != NULL_TREE);
110919 +
110920 + type = TREE_TYPE(node);
110921 +
110922 + if (pointer_set_contains(visited->my_stmts, stmt))
110923 + return TREE_TYPE(node);
110924 +
110925 + switch (TYPE_MODE(type)) {
110926 + case QImode:
110927 + new_type = size_overflow_type_HI;
110928 + break;
110929 + case HImode:
110930 + new_type = size_overflow_type_SI;
110931 + break;
110932 + case SImode:
110933 + new_type = size_overflow_type_DI;
110934 + break;
110935 + case DImode:
110936 + if (LONG_TYPE_SIZE == GET_MODE_BITSIZE(SImode))
110937 + new_type = TYPE_UNSIGNED(type) ? unsigned_intDI_type_node : intDI_type_node;
110938 + else
110939 + new_type = size_overflow_type_TI;
110940 + break;
110941 + case TImode:
110942 + gcc_assert(!TYPE_UNSIGNED(type));
110943 + new_type = size_overflow_type_TI;
110944 + break;
110945 + default:
110946 + debug_tree((tree)node);
110947 + error("%s: unsupported gcc configuration (%qE).", __func__, current_function_decl);
110948 + gcc_unreachable();
110949 + }
110950 +
110951 + if (TYPE_QUALS(type) != 0)
110952 + return build_qualified_type(new_type, TYPE_QUALS(type));
110953 + return new_type;
110954 +}
110955 +
110956 +static tree get_lhs(const_gimple stmt)
110957 +{
110958 + switch (gimple_code(stmt)) {
110959 + case GIMPLE_ASSIGN:
110960 + case GIMPLE_CALL:
110961 + return gimple_get_lhs(stmt);
110962 + case GIMPLE_PHI:
110963 + return gimple_phi_result(stmt);
110964 + default:
110965 + return NULL_TREE;
110966 + }
110967 +}
110968 +
110969 +static tree cast_to_new_size_overflow_type(struct visited *visited, gimple stmt, tree rhs, tree size_overflow_type, bool before)
110970 +{
110971 + gimple_stmt_iterator gsi;
110972 + tree lhs;
110973 + gimple new_stmt;
110974 +
110975 + if (rhs == NULL_TREE)
110976 + return NULL_TREE;
110977 +
110978 + gsi = gsi_for_stmt(stmt);
110979 + new_stmt = build_cast_stmt(visited, size_overflow_type, rhs, CREATE_NEW_VAR, &gsi, before, false);
110980 + pointer_set_insert(visited->my_stmts, new_stmt);
110981 +
110982 + lhs = get_lhs(new_stmt);
110983 + gcc_assert(lhs != NULL_TREE);
110984 + return lhs;
110985 +}
110986 +
110987 +tree create_assign(struct visited *visited, gimple oldstmt, tree rhs1, bool before)
110988 +{
110989 + tree lhs, dst_type;
110990 + gimple_stmt_iterator gsi;
110991 +
110992 + if (rhs1 == NULL_TREE) {
110993 + debug_gimple_stmt(oldstmt);
110994 + error("%s: rhs1 is NULL_TREE", __func__);
110995 + gcc_unreachable();
110996 + }
110997 +
110998 + switch (gimple_code(oldstmt)) {
110999 + case GIMPLE_ASM:
111000 + lhs = rhs1;
111001 + break;
111002 + case GIMPLE_CALL:
111003 + case GIMPLE_ASSIGN:
111004 + lhs = gimple_get_lhs(oldstmt);
111005 + break;
111006 + default:
111007 + debug_gimple_stmt(oldstmt);
111008 + gcc_unreachable();
111009 + }
111010 +
111011 + gsi = gsi_for_stmt(oldstmt);
111012 + pointer_set_insert(visited->stmts, oldstmt);
111013 + if (lookup_stmt_eh_lp(oldstmt) != 0) {
111014 + basic_block next_bb, cur_bb;
111015 + const_edge e;
111016 +
111017 + gcc_assert(before == false);
111018 + gcc_assert(stmt_can_throw_internal(oldstmt));
111019 + gcc_assert(gimple_code(oldstmt) == GIMPLE_CALL);
111020 + gcc_assert(!gsi_end_p(gsi));
111021 +
111022 + cur_bb = gimple_bb(oldstmt);
111023 + next_bb = cur_bb->next_bb;
111024 + e = find_edge(cur_bb, next_bb);
111025 + gcc_assert(e != NULL);
111026 + gcc_assert(e->flags & EDGE_FALLTHRU);
111027 +
111028 + gsi = gsi_after_labels(next_bb);
111029 + gcc_assert(!gsi_end_p(gsi));
111030 +
111031 + before = true;
111032 + oldstmt = gsi_stmt(gsi);
111033 + }
111034 +
111035 + dst_type = get_size_overflow_type(visited, oldstmt, lhs);
111036 +
111037 + if (is_gimple_constant(rhs1))
111038 + return cast_a_tree(dst_type, rhs1);
111039 + return cast_to_new_size_overflow_type(visited, oldstmt, rhs1, dst_type, before);
111040 +}
111041 +
111042 +tree dup_assign(struct visited *visited, gimple oldstmt, const_tree node, tree rhs1, tree rhs2, tree __unused rhs3)
111043 +{
111044 + gimple stmt;
111045 + gimple_stmt_iterator gsi;
111046 + tree size_overflow_type, new_var, lhs = gimple_assign_lhs(oldstmt);
111047 +
111048 + if (pointer_set_contains(visited->my_stmts, oldstmt))
111049 + return lhs;
111050 +
111051 + if (gimple_num_ops(oldstmt) != 4 && rhs1 == NULL_TREE) {
111052 + rhs1 = gimple_assign_rhs1(oldstmt);
111053 + rhs1 = create_assign(visited, oldstmt, rhs1, BEFORE_STMT);
111054 + }
111055 + if (gimple_num_ops(oldstmt) == 3 && rhs2 == NULL_TREE) {
111056 + rhs2 = gimple_assign_rhs2(oldstmt);
111057 + rhs2 = create_assign(visited, oldstmt, rhs2, BEFORE_STMT);
111058 + }
111059 +
111060 + stmt = gimple_copy(oldstmt);
111061 + gimple_set_location(stmt, gimple_location(oldstmt));
111062 + pointer_set_insert(visited->my_stmts, stmt);
111063 +
111064 + if (gimple_assign_rhs_code(oldstmt) == WIDEN_MULT_EXPR)
111065 + gimple_assign_set_rhs_code(stmt, MULT_EXPR);
111066 +
111067 + size_overflow_type = get_size_overflow_type(visited, oldstmt, node);
111068 +
111069 + new_var = create_new_var(size_overflow_type);
111070 + new_var = make_ssa_name(new_var, stmt);
111071 + gimple_assign_set_lhs(stmt, new_var);
111072 +
111073 + if (rhs1 != NULL_TREE)
111074 + gimple_assign_set_rhs1(stmt, rhs1);
111075 +
111076 + if (rhs2 != NULL_TREE)
111077 + gimple_assign_set_rhs2(stmt, rhs2);
111078 +#if BUILDING_GCC_VERSION >= 4006
111079 + if (rhs3 != NULL_TREE)
111080 + gimple_assign_set_rhs3(stmt, rhs3);
111081 +#endif
111082 + gimple_set_vuse(stmt, gimple_vuse(oldstmt));
111083 + gimple_set_vdef(stmt, gimple_vdef(oldstmt));
111084 +
111085 + gsi = gsi_for_stmt(oldstmt);
111086 + gsi_insert_after(&gsi, stmt, GSI_SAME_STMT);
111087 + update_stmt(stmt);
111088 + pointer_set_insert(visited->stmts, oldstmt);
111089 + return gimple_assign_lhs(stmt);
111090 +}
111091 +
111092 +static tree cast_parm_decl(struct visited *visited, tree phi_ssa_name, tree arg, tree size_overflow_type, basic_block bb)
111093 +{
111094 + gimple assign;
111095 + gimple_stmt_iterator gsi;
111096 + basic_block first_bb;
111097 +
111098 + gcc_assert(SSA_NAME_IS_DEFAULT_DEF(arg));
111099 +
111100 + if (bb->index == 0) {
111101 + first_bb = split_block_after_labels(ENTRY_BLOCK_PTR_FOR_FN(cfun))->dest;
111102 + gcc_assert(dom_info_available_p(CDI_DOMINATORS));
111103 + set_immediate_dominator(CDI_DOMINATORS, first_bb, ENTRY_BLOCK_PTR_FOR_FN(cfun));
111104 + bb = first_bb;
111105 + }
111106 +
111107 + gsi = gsi_after_labels(bb);
111108 + assign = build_cast_stmt(visited, size_overflow_type, arg, phi_ssa_name, &gsi, BEFORE_STMT, false);
111109 + pointer_set_insert(visited->my_stmts, assign);
111110 +
111111 + return gimple_assign_lhs(assign);
111112 +}
111113 +
111114 +static tree use_phi_ssa_name(struct visited *visited, tree ssa_name_var, tree new_arg)
111115 +{
111116 + gimple_stmt_iterator gsi;
111117 + gimple assign, def_stmt = get_def_stmt(new_arg);
111118 +
111119 + if (gimple_code(def_stmt) == GIMPLE_PHI) {
111120 + gsi = gsi_after_labels(gimple_bb(def_stmt));
111121 + assign = build_cast_stmt(visited, TREE_TYPE(new_arg), new_arg, ssa_name_var, &gsi, BEFORE_STMT, true);
111122 + } else {
111123 + gsi = gsi_for_stmt(def_stmt);
111124 + assign = build_cast_stmt(visited, TREE_TYPE(new_arg), new_arg, ssa_name_var, &gsi, AFTER_STMT, true);
111125 + }
111126 +
111127 + pointer_set_insert(visited->my_stmts, assign);
111128 + return gimple_assign_lhs(assign);
111129 +}
111130 +
111131 +static tree cast_visited_phi_arg(struct visited *visited, tree ssa_name_var, tree arg, tree size_overflow_type)
111132 +{
111133 + basic_block bb;
111134 + gimple_stmt_iterator gsi;
111135 + const_gimple def_stmt;
111136 + gimple assign;
111137 +
111138 + def_stmt = get_def_stmt(arg);
111139 + bb = gimple_bb(def_stmt);
111140 + gcc_assert(bb->index != 0);
111141 + gsi = gsi_after_labels(bb);
111142 +
111143 + assign = build_cast_stmt(visited, size_overflow_type, arg, ssa_name_var, &gsi, BEFORE_STMT, false);
111144 + pointer_set_insert(visited->my_stmts, assign);
111145 + return gimple_assign_lhs(assign);
111146 +}
111147 +
111148 +static tree create_new_phi_arg(struct visited *visited, tree ssa_name_var, tree new_arg, gimple oldstmt, unsigned int i)
111149 +{
111150 + tree size_overflow_type;
111151 + tree arg;
111152 + const_gimple def_stmt;
111153 +
111154 + if (new_arg != NULL_TREE && is_gimple_constant(new_arg))
111155 + return new_arg;
111156 +
111157 + arg = gimple_phi_arg_def(oldstmt, i);
111158 + def_stmt = get_def_stmt(arg);
111159 + gcc_assert(def_stmt != NULL);
111160 + size_overflow_type = get_size_overflow_type(visited, oldstmt, arg);
111161 +
111162 + switch (gimple_code(def_stmt)) {
111163 + case GIMPLE_PHI:
111164 + return cast_visited_phi_arg(visited, ssa_name_var, arg, size_overflow_type);
111165 + case GIMPLE_NOP: {
111166 + basic_block bb;
111167 +
111168 + bb = gimple_phi_arg_edge(oldstmt, i)->src;
111169 + return cast_parm_decl(visited, ssa_name_var, arg, size_overflow_type, bb);
111170 + }
111171 + case GIMPLE_ASM: {
111172 + gimple_stmt_iterator gsi;
111173 + gimple assign, stmt = get_def_stmt(arg);
111174 +
111175 + gsi = gsi_for_stmt(stmt);
111176 + assign = build_cast_stmt(visited, size_overflow_type, arg, ssa_name_var, &gsi, AFTER_STMT, false);
111177 + pointer_set_insert(visited->my_stmts, assign);
111178 + return gimple_assign_lhs(assign);
111179 + }
111180 + default:
111181 + gcc_assert(new_arg != NULL_TREE);
111182 + gcc_assert(types_compatible_p(TREE_TYPE(new_arg), size_overflow_type));
111183 + return use_phi_ssa_name(visited, ssa_name_var, new_arg);
111184 + }
111185 +}
111186 +
111187 +static gimple overflow_create_phi_node(struct visited *visited, gimple oldstmt, tree result)
111188 +{
111189 + basic_block bb;
111190 + gimple phi;
111191 + gimple_seq seq;
111192 + gimple_stmt_iterator gsi = gsi_for_stmt(oldstmt);
111193 +
111194 + bb = gsi_bb(gsi);
111195 +
111196 + if (result == NULL_TREE) {
111197 + tree old_result = gimple_phi_result(oldstmt);
111198 + tree size_overflow_type = get_size_overflow_type(visited, oldstmt, old_result);
111199 +
111200 + result = create_new_var(size_overflow_type);
111201 + }
111202 +
111203 + phi = create_phi_node(result, bb);
111204 + gimple_phi_set_result(phi, make_ssa_name(result, phi));
111205 + seq = phi_nodes(bb);
111206 + gsi = gsi_last(seq);
111207 + gsi_remove(&gsi, false);
111208 +
111209 + gsi = gsi_for_stmt(oldstmt);
111210 + gsi_insert_after(&gsi, phi, GSI_NEW_STMT);
111211 + gimple_set_bb(phi, bb);
111212 + return phi;
111213 +}
111214 +
111215 +#if BUILDING_GCC_VERSION <= 4007
111216 +static tree create_new_phi_node(struct visited *visited, VEC(tree, heap) **args, tree ssa_name_var, gimple oldstmt)
111217 +#else
111218 +static tree create_new_phi_node(struct visited *visited, vec<tree, va_heap, vl_embed> *&args, tree ssa_name_var, gimple oldstmt)
111219 +#endif
111220 +{
111221 + gimple new_phi;
111222 + unsigned int i;
111223 + tree arg, result;
111224 + location_t loc = gimple_location(oldstmt);
111225 +
111226 +#if BUILDING_GCC_VERSION <= 4007
111227 + gcc_assert(!VEC_empty(tree, *args));
111228 +#else
111229 + gcc_assert(!args->is_empty());
111230 +#endif
111231 +
111232 + new_phi = overflow_create_phi_node(visited, oldstmt, ssa_name_var);
111233 + result = gimple_phi_result(new_phi);
111234 + ssa_name_var = SSA_NAME_VAR(result);
111235 +
111236 +#if BUILDING_GCC_VERSION <= 4007
111237 + FOR_EACH_VEC_ELT(tree, *args, i, arg) {
111238 +#else
111239 + FOR_EACH_VEC_SAFE_ELT(args, i, arg) {
111240 +#endif
111241 + arg = create_new_phi_arg(visited, ssa_name_var, arg, oldstmt, i);
111242 + add_phi_arg(new_phi, arg, gimple_phi_arg_edge(oldstmt, i), loc);
111243 + }
111244 +
111245 +#if BUILDING_GCC_VERSION <= 4007
111246 + VEC_free(tree, heap, *args);
111247 +#else
111248 + vec_free(args);
111249 +#endif
111250 + update_stmt(new_phi);
111251 + pointer_set_insert(visited->my_stmts, new_phi);
111252 + return result;
111253 +}
111254 +
111255 +static tree handle_phi(struct visited *visited, struct cgraph_node *caller_node, tree orig_result)
111256 +{
111257 + tree ssa_name_var = NULL_TREE;
111258 +#if BUILDING_GCC_VERSION <= 4007
111259 + VEC(tree, heap) *args = NULL;
111260 +#else
111261 + vec<tree, va_heap, vl_embed> *args = NULL;
111262 +#endif
111263 + gimple oldstmt = get_def_stmt(orig_result);
111264 + unsigned int i, len = gimple_phi_num_args(oldstmt);
111265 +
111266 + pointer_set_insert(visited->stmts, oldstmt);
111267 + for (i = 0; i < len; i++) {
111268 + tree arg, new_arg;
111269 +
111270 + arg = gimple_phi_arg_def(oldstmt, i);
111271 + new_arg = expand(visited, caller_node, arg);
111272 +
111273 + if (ssa_name_var == NULL_TREE && new_arg != NULL_TREE)
111274 + ssa_name_var = SSA_NAME_VAR(new_arg);
111275 +
111276 + if (is_gimple_constant(arg)) {
111277 + tree size_overflow_type = get_size_overflow_type(visited, oldstmt, arg);
111278 +
111279 + new_arg = cast_a_tree(size_overflow_type, arg);
111280 + }
111281 +
111282 +#if BUILDING_GCC_VERSION <= 4007
111283 + VEC_safe_push(tree, heap, args, new_arg);
111284 +#else
111285 + vec_safe_push(args, new_arg);
111286 +#endif
111287 + }
111288 +
111289 +#if BUILDING_GCC_VERSION <= 4007
111290 + return create_new_phi_node(visited, &args, ssa_name_var, oldstmt);
111291 +#else
111292 + return create_new_phi_node(visited, args, ssa_name_var, oldstmt);
111293 +#endif
111294 +}
111295 +
111296 +static tree create_cast_assign(struct visited *visited, gimple stmt)
111297 +{
111298 + tree rhs1 = gimple_assign_rhs1(stmt);
111299 + tree lhs = gimple_assign_lhs(stmt);
111300 + const_tree rhs1_type = TREE_TYPE(rhs1);
111301 + const_tree lhs_type = TREE_TYPE(lhs);
111302 +
111303 + if (TYPE_UNSIGNED(rhs1_type) == TYPE_UNSIGNED(lhs_type))
111304 + return create_assign(visited, stmt, lhs, AFTER_STMT);
111305 +
111306 + return create_assign(visited, stmt, rhs1, AFTER_STMT);
111307 +}
111308 +
111309 +static bool skip_lhs_cast_check(const_gimple stmt)
111310 +{
111311 + const_tree rhs = gimple_assign_rhs1(stmt);
111312 + const_gimple def_stmt = get_def_stmt(rhs);
111313 +
111314 + // 3.8.2 kernel/futex_compat.c compat_exit_robust_list(): get_user() 64 ulong -> int (compat_long_t), int max
111315 + if (gimple_code(def_stmt) == GIMPLE_ASM)
111316 + return true;
111317 +
111318 + if (is_const_plus_unsigned_signed_truncation(rhs))
111319 + return true;
111320 +
111321 + return false;
111322 +}
111323 +
111324 +static tree create_string_param(tree string)
111325 +{
111326 + tree i_type, a_type;
111327 + const int length = TREE_STRING_LENGTH(string);
111328 +
111329 + gcc_assert(length > 0);
111330 +
111331 + i_type = build_index_type(build_int_cst(NULL_TREE, length - 1));
111332 + a_type = build_array_type(char_type_node, i_type);
111333 +
111334 + TREE_TYPE(string) = a_type;
111335 + TREE_CONSTANT(string) = 1;
111336 + TREE_READONLY(string) = 1;
111337 +
111338 + return build1(ADDR_EXPR, ptr_type_node, string);
111339 +}
111340 +
111341 +static void insert_cond(basic_block cond_bb, tree arg, enum tree_code cond_code, tree type_value)
111342 +{
111343 + gimple cond_stmt;
111344 + gimple_stmt_iterator gsi = gsi_last_bb(cond_bb);
111345 +
111346 + cond_stmt = gimple_build_cond(cond_code, arg, type_value, NULL_TREE, NULL_TREE);
111347 + gsi_insert_after(&gsi, cond_stmt, GSI_CONTINUE_LINKING);
111348 + update_stmt(cond_stmt);
111349 +}
111350 +
111351 +static void insert_cond_result(struct cgraph_node *caller_node, basic_block bb_true, const_gimple stmt, const_tree arg, bool min)
111352 +{
111353 + gimple func_stmt;
111354 + const_gimple def_stmt;
111355 + const_tree loc_line;
111356 + tree loc_file, ssa_name, current_func;
111357 + expanded_location xloc;
111358 + char *ssa_name_buf;
111359 + int len;
111360 + struct cgraph_edge *edge;
111361 + struct cgraph_node *callee_node;
111362 + int frequency;
111363 + gimple_stmt_iterator gsi = gsi_start_bb(bb_true);
111364 +
111365 + def_stmt = get_def_stmt(arg);
111366 + xloc = expand_location(gimple_location(def_stmt));
111367 +
111368 + if (!gimple_has_location(def_stmt)) {
111369 + xloc = expand_location(gimple_location(stmt));
111370 + if (!gimple_has_location(stmt))
111371 + xloc = expand_location(DECL_SOURCE_LOCATION(current_function_decl));
111372 + }
111373 +
111374 + loc_line = build_int_cstu(unsigned_type_node, xloc.line);
111375 +
111376 + loc_file = build_string(strlen(xloc.file) + 1, xloc.file);
111377 + loc_file = create_string_param(loc_file);
111378 +
111379 + current_func = build_string(DECL_NAME_LENGTH(current_function_decl) + 1, DECL_NAME_POINTER(current_function_decl));
111380 + current_func = create_string_param(current_func);
111381 +
111382 + gcc_assert(DECL_NAME(SSA_NAME_VAR(arg)) != NULL);
111383 + call_count++;
111384 + len = asprintf(&ssa_name_buf, "%s_%u %s, count: %u\n", DECL_NAME_POINTER(SSA_NAME_VAR(arg)), SSA_NAME_VERSION(arg), min ? "min" : "max", call_count);
111385 + gcc_assert(len > 0);
111386 + ssa_name = build_string(len + 1, ssa_name_buf);
111387 + free(ssa_name_buf);
111388 + ssa_name = create_string_param(ssa_name);
111389 +
111390 + // void report_size_overflow(const char *file, unsigned int line, const char *func, const char *ssa_name)
111391 + func_stmt = gimple_build_call(report_size_overflow_decl, 4, loc_file, loc_line, current_func, ssa_name);
111392 + gsi_insert_after(&gsi, func_stmt, GSI_CONTINUE_LINKING);
111393 +
111394 + callee_node = cgraph_get_create_node(report_size_overflow_decl);
111395 + frequency = compute_call_stmt_bb_frequency(current_function_decl, bb_true);
111396 +
111397 + edge = cgraph_create_edge(caller_node, callee_node, func_stmt, bb_true->count, frequency, bb_true->loop_depth);
111398 + gcc_assert(edge != NULL);
111399 +}
111400 +
111401 +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)
111402 +{
111403 + basic_block cond_bb, join_bb, bb_true;
111404 + edge e;
111405 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
111406 +
111407 + cond_bb = gimple_bb(stmt);
111408 + if (before)
111409 + gsi_prev(&gsi);
111410 + if (gsi_end_p(gsi))
111411 + e = split_block_after_labels(cond_bb);
111412 + else
111413 + e = split_block(cond_bb, gsi_stmt(gsi));
111414 + cond_bb = e->src;
111415 + join_bb = e->dest;
111416 + e->flags = EDGE_FALSE_VALUE;
111417 + e->probability = REG_BR_PROB_BASE;
111418 +
111419 + bb_true = create_empty_bb(cond_bb);
111420 + make_edge(cond_bb, bb_true, EDGE_TRUE_VALUE);
111421 + make_edge(cond_bb, join_bb, EDGE_FALSE_VALUE);
111422 + make_edge(bb_true, join_bb, EDGE_FALLTHRU);
111423 +
111424 + gcc_assert(dom_info_available_p(CDI_DOMINATORS));
111425 + set_immediate_dominator(CDI_DOMINATORS, bb_true, cond_bb);
111426 + set_immediate_dominator(CDI_DOMINATORS, join_bb, cond_bb);
111427 +
111428 + if (current_loops != NULL) {
111429 + gcc_assert(cond_bb->loop_father == join_bb->loop_father);
111430 + add_bb_to_loop(bb_true, cond_bb->loop_father);
111431 + }
111432 +
111433 + insert_cond(cond_bb, arg, cond_code, type_value);
111434 + insert_cond_result(caller_node, bb_true, stmt, arg, min);
111435 +
111436 +// print_the_code_insertions(stmt);
111437 +}
111438 +
111439 +void check_size_overflow(struct cgraph_node *caller_node, gimple stmt, tree size_overflow_type, tree cast_rhs, tree rhs, bool before)
111440 +{
111441 + const_tree rhs_type = TREE_TYPE(rhs);
111442 + tree cast_rhs_type, type_max_type, type_min_type, type_max, type_min;
111443 +
111444 + gcc_assert(rhs_type != NULL_TREE);
111445 + if (TREE_CODE(rhs_type) == POINTER_TYPE)
111446 + return;
111447 +
111448 + gcc_assert(TREE_CODE(rhs_type) == INTEGER_TYPE || TREE_CODE(rhs_type) == ENUMERAL_TYPE);
111449 +
111450 + if (is_const_plus_unsigned_signed_truncation(rhs))
111451 + return;
111452 +
111453 + type_max = cast_a_tree(size_overflow_type, TYPE_MAX_VALUE(rhs_type));
111454 + // typemax (-1) < typemin (0)
111455 + if (TREE_OVERFLOW(type_max))
111456 + return;
111457 +
111458 + type_min = cast_a_tree(size_overflow_type, TYPE_MIN_VALUE(rhs_type));
111459 +
111460 + cast_rhs_type = TREE_TYPE(cast_rhs);
111461 + type_max_type = TREE_TYPE(type_max);
111462 + gcc_assert(types_compatible_p(cast_rhs_type, type_max_type));
111463 +
111464 + insert_check_size_overflow(caller_node, stmt, GT_EXPR, cast_rhs, type_max, before, MAX_CHECK);
111465 +
111466 + // special case: get_size_overflow_type(), 32, u64->s
111467 + if (LONG_TYPE_SIZE == GET_MODE_BITSIZE(SImode) && TYPE_UNSIGNED(size_overflow_type) && !TYPE_UNSIGNED(rhs_type))
111468 + return;
111469 +
111470 + type_min_type = TREE_TYPE(type_min);
111471 + gcc_assert(types_compatible_p(type_max_type, type_min_type));
111472 + insert_check_size_overflow(caller_node, stmt, LT_EXPR, cast_rhs, type_min, before, MIN_CHECK);
111473 +}
111474 +
111475 +static tree create_cast_overflow_check(struct visited *visited, struct cgraph_node *caller_node, tree new_rhs1, gimple stmt)
111476 +{
111477 + bool cast_lhs, cast_rhs;
111478 + tree lhs = gimple_assign_lhs(stmt);
111479 + tree rhs = gimple_assign_rhs1(stmt);
111480 + const_tree lhs_type = TREE_TYPE(lhs);
111481 + const_tree rhs_type = TREE_TYPE(rhs);
111482 + enum machine_mode lhs_mode = TYPE_MODE(lhs_type);
111483 + enum machine_mode rhs_mode = TYPE_MODE(rhs_type);
111484 + unsigned int lhs_size = GET_MODE_BITSIZE(lhs_mode);
111485 + unsigned int rhs_size = GET_MODE_BITSIZE(rhs_mode);
111486 +
111487 + static bool check_lhs[3][4] = {
111488 + // ss su us uu
111489 + { false, true, true, false }, // lhs > rhs
111490 + { false, false, false, false }, // lhs = rhs
111491 + { true, true, true, true }, // lhs < rhs
111492 + };
111493 +
111494 + static bool check_rhs[3][4] = {
111495 + // ss su us uu
111496 + { true, false, true, true }, // lhs > rhs
111497 + { true, false, true, true }, // lhs = rhs
111498 + { true, false, true, true }, // lhs < rhs
111499 + };
111500 +
111501 + // skip lhs check on signed SI -> HI cast or signed SI -> QI cast !!!!
111502 + if (rhs_mode == SImode && !TYPE_UNSIGNED(rhs_type) && (lhs_mode == HImode || lhs_mode == QImode))
111503 + return create_assign(visited, stmt, lhs, AFTER_STMT);
111504 +
111505 + if (lhs_size > rhs_size) {
111506 + cast_lhs = check_lhs[0][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
111507 + cast_rhs = check_rhs[0][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
111508 + } else if (lhs_size == rhs_size) {
111509 + cast_lhs = check_lhs[1][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
111510 + cast_rhs = check_rhs[1][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
111511 + } else {
111512 + cast_lhs = check_lhs[2][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
111513 + cast_rhs = check_rhs[2][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
111514 + }
111515 +
111516 + if (!cast_lhs && !cast_rhs)
111517 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
111518 +
111519 + if (cast_lhs && !skip_lhs_cast_check(stmt))
111520 + check_size_overflow(caller_node, stmt, TREE_TYPE(new_rhs1), new_rhs1, lhs, BEFORE_STMT);
111521 +
111522 + if (cast_rhs)
111523 + check_size_overflow(caller_node, stmt, TREE_TYPE(new_rhs1), new_rhs1, rhs, BEFORE_STMT);
111524 +
111525 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
111526 +}
111527 +
111528 +static tree handle_unary_rhs(struct visited *visited, struct cgraph_node *caller_node, gimple stmt)
111529 +{
111530 + enum tree_code rhs_code;
111531 + tree rhs1, new_rhs1, lhs = gimple_assign_lhs(stmt);
111532 +
111533 + if (pointer_set_contains(visited->my_stmts, stmt))
111534 + return lhs;
111535 +
111536 + rhs1 = gimple_assign_rhs1(stmt);
111537 + if (TREE_CODE(TREE_TYPE(rhs1)) == POINTER_TYPE)
111538 + return create_assign(visited, stmt, lhs, AFTER_STMT);
111539 +
111540 + new_rhs1 = expand(visited, caller_node, rhs1);
111541 +
111542 + if (new_rhs1 == NULL_TREE)
111543 + return create_cast_assign(visited, stmt);
111544 +
111545 + if (pointer_set_contains(visited->no_cast_check, stmt))
111546 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
111547 +
111548 + rhs_code = gimple_assign_rhs_code(stmt);
111549 + if (rhs_code == BIT_NOT_EXPR || rhs_code == NEGATE_EXPR) {
111550 + tree size_overflow_type = get_size_overflow_type(visited, stmt, rhs1);
111551 +
111552 + new_rhs1 = cast_to_new_size_overflow_type(visited, stmt, new_rhs1, size_overflow_type, BEFORE_STMT);
111553 + check_size_overflow(caller_node, stmt, size_overflow_type, new_rhs1, rhs1, BEFORE_STMT);
111554 + return create_assign(visited, stmt, lhs, AFTER_STMT);
111555 + }
111556 +
111557 + if (!gimple_assign_cast_p(stmt))
111558 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
111559 +
111560 + return create_cast_overflow_check(visited, caller_node, new_rhs1, stmt);
111561 +}
111562 +
111563 +static tree handle_unary_ops(struct visited *visited, struct cgraph_node *caller_node, gimple stmt)
111564 +{
111565 + tree rhs1, lhs = gimple_assign_lhs(stmt);
111566 + gimple def_stmt = get_def_stmt(lhs);
111567 +
111568 + gcc_assert(gimple_code(def_stmt) != GIMPLE_NOP);
111569 + rhs1 = gimple_assign_rhs1(def_stmt);
111570 +
111571 + if (is_gimple_constant(rhs1))
111572 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
111573 +
111574 + switch (TREE_CODE(rhs1)) {
111575 + case SSA_NAME: {
111576 + tree ret = handle_unary_rhs(visited, caller_node, def_stmt);
111577 +
111578 + if (gimple_assign_cast_p(stmt))
111579 + unsigned_signed_cast_intentional_overflow(visited, stmt);
111580 + return ret;
111581 + }
111582 + case ARRAY_REF:
111583 + case BIT_FIELD_REF:
111584 + case ADDR_EXPR:
111585 + case COMPONENT_REF:
111586 + case INDIRECT_REF:
111587 +#if BUILDING_GCC_VERSION >= 4006
111588 + case MEM_REF:
111589 +#endif
111590 + case TARGET_MEM_REF:
111591 + case VIEW_CONVERT_EXPR:
111592 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
111593 + case PARM_DECL:
111594 + case VAR_DECL:
111595 + return create_assign(visited, stmt, lhs, AFTER_STMT);
111596 +
111597 + default:
111598 + debug_gimple_stmt(def_stmt);
111599 + debug_tree(rhs1);
111600 + gcc_unreachable();
111601 + }
111602 +}
111603 +
111604 +static void __unused print_the_code_insertions(const_gimple stmt)
111605 +{
111606 + location_t loc = gimple_location(stmt);
111607 +
111608 + inform(loc, "Integer size_overflow check applied here.");
111609 +}
111610 +
111611 +static tree handle_binary_ops(struct visited *visited, struct cgraph_node *caller_node, tree lhs)
111612 +{
111613 + enum intentional_overflow_type res;
111614 + tree rhs1, rhs2, new_lhs;
111615 + gimple def_stmt = get_def_stmt(lhs);
111616 + tree new_rhs1 = NULL_TREE;
111617 + tree new_rhs2 = NULL_TREE;
111618 +
111619 + rhs1 = gimple_assign_rhs1(def_stmt);
111620 + rhs2 = gimple_assign_rhs2(def_stmt);
111621 +
111622 + /* no DImode/TImode division in the 32/64 bit kernel */
111623 + switch (gimple_assign_rhs_code(def_stmt)) {
111624 + case RDIV_EXPR:
111625 + case TRUNC_DIV_EXPR:
111626 + case CEIL_DIV_EXPR:
111627 + case FLOOR_DIV_EXPR:
111628 + case ROUND_DIV_EXPR:
111629 + case TRUNC_MOD_EXPR:
111630 + case CEIL_MOD_EXPR:
111631 + case FLOOR_MOD_EXPR:
111632 + case ROUND_MOD_EXPR:
111633 + case EXACT_DIV_EXPR:
111634 + case POINTER_PLUS_EXPR:
111635 + case BIT_AND_EXPR:
111636 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
111637 + default:
111638 + break;
111639 + }
111640 +
111641 + new_lhs = handle_integer_truncation(visited, caller_node, lhs);
111642 + if (new_lhs != NULL_TREE)
111643 + return new_lhs;
111644 +
111645 + if (TREE_CODE(rhs1) == SSA_NAME)
111646 + new_rhs1 = expand(visited, caller_node, rhs1);
111647 + if (TREE_CODE(rhs2) == SSA_NAME)
111648 + new_rhs2 = expand(visited, caller_node, rhs2);
111649 +
111650 + res = add_mul_intentional_overflow(def_stmt);
111651 + if (res != NO_INTENTIONAL_OVERFLOW) {
111652 + new_lhs = dup_assign(visited, def_stmt, lhs, new_rhs1, new_rhs2, NULL_TREE);
111653 + insert_cast_expr(visited, get_def_stmt(new_lhs), res);
111654 + return new_lhs;
111655 + }
111656 +
111657 + if (skip_expr_on_double_type(def_stmt)) {
111658 + new_lhs = dup_assign(visited, def_stmt, lhs, new_rhs1, new_rhs2, NULL_TREE);
111659 + insert_cast_expr(visited, get_def_stmt(new_lhs), NO_INTENTIONAL_OVERFLOW);
111660 + return new_lhs;
111661 + }
111662 +
111663 + if (is_a_neg_overflow(def_stmt, rhs2))
111664 + return handle_intentional_overflow(visited, caller_node, true, def_stmt, new_rhs1, NULL_TREE);
111665 + if (is_a_neg_overflow(def_stmt, rhs1))
111666 + return handle_intentional_overflow(visited, caller_node, true, def_stmt, new_rhs2, new_rhs2);
111667 +
111668 +
111669 + if (is_a_constant_overflow(def_stmt, rhs2))
111670 + return handle_intentional_overflow(visited, caller_node, !is_a_cast_and_const_overflow(rhs1), def_stmt, new_rhs1, NULL_TREE);
111671 + if (is_a_constant_overflow(def_stmt, rhs1))
111672 + return handle_intentional_overflow(visited, caller_node, !is_a_cast_and_const_overflow(rhs2), def_stmt, new_rhs2, new_rhs2);
111673 +
111674 + // the const is between 0 and (signed) MAX
111675 + if (is_gimple_constant(rhs1))
111676 + new_rhs1 = create_assign(visited, def_stmt, rhs1, BEFORE_STMT);
111677 + if (is_gimple_constant(rhs2))
111678 + new_rhs2 = create_assign(visited, def_stmt, rhs2, BEFORE_STMT);
111679 +
111680 + return dup_assign(visited, def_stmt, lhs, new_rhs1, new_rhs2, NULL_TREE);
111681 +}
111682 +
111683 +#if BUILDING_GCC_VERSION >= 4006
111684 +static tree get_new_rhs(struct visited *visited, struct cgraph_node *caller_node, tree size_overflow_type, tree rhs)
111685 +{
111686 + if (is_gimple_constant(rhs))
111687 + return cast_a_tree(size_overflow_type, rhs);
111688 + if (TREE_CODE(rhs) != SSA_NAME)
111689 + return NULL_TREE;
111690 + return expand(visited, caller_node, rhs);
111691 +}
111692 +
111693 +static tree handle_ternary_ops(struct visited *visited, struct cgraph_node *caller_node, tree lhs)
111694 +{
111695 + tree rhs1, rhs2, rhs3, new_rhs1, new_rhs2, new_rhs3, size_overflow_type;
111696 + gimple def_stmt = get_def_stmt(lhs);
111697 +
111698 + size_overflow_type = get_size_overflow_type(visited, def_stmt, lhs);
111699 +
111700 + rhs1 = gimple_assign_rhs1(def_stmt);
111701 + rhs2 = gimple_assign_rhs2(def_stmt);
111702 + rhs3 = gimple_assign_rhs3(def_stmt);
111703 + new_rhs1 = get_new_rhs(visited, caller_node, size_overflow_type, rhs1);
111704 + new_rhs2 = get_new_rhs(visited, caller_node, size_overflow_type, rhs2);
111705 + new_rhs3 = get_new_rhs(visited, caller_node, size_overflow_type, rhs3);
111706 +
111707 + return dup_assign(visited, def_stmt, lhs, new_rhs1, new_rhs2, new_rhs3);
111708 +}
111709 +#endif
111710 +
111711 +static tree get_my_stmt_lhs(struct visited *visited, gimple stmt)
111712 +{
111713 + gimple_stmt_iterator gsi;
111714 + gimple next_stmt = NULL;
111715 +
111716 + gsi = gsi_for_stmt(stmt);
111717 +
111718 + do {
111719 + gsi_next(&gsi);
111720 + next_stmt = gsi_stmt(gsi);
111721 +
111722 + if (gimple_code(stmt) == GIMPLE_PHI && !pointer_set_contains(visited->my_stmts, next_stmt))
111723 + return NULL_TREE;
111724 +
111725 + if (pointer_set_contains(visited->my_stmts, next_stmt) && !pointer_set_contains(visited->skip_expr_casts, next_stmt))
111726 + break;
111727 +
111728 + gcc_assert(pointer_set_contains(visited->my_stmts, next_stmt));
111729 + } while (!gsi_end_p(gsi));
111730 +
111731 + gcc_assert(next_stmt);
111732 + return get_lhs(next_stmt);
111733 +}
111734 +
111735 +static tree expand_visited(struct visited *visited, gimple def_stmt)
111736 +{
111737 + gimple_stmt_iterator gsi;
111738 + enum gimple_code code = gimple_code(def_stmt);
111739 +
111740 + if (code == GIMPLE_ASM)
111741 + return NULL_TREE;
111742 +
111743 + gsi = gsi_for_stmt(def_stmt);
111744 + gsi_next(&gsi);
111745 +
111746 + if (gimple_code(def_stmt) == GIMPLE_PHI && gsi_end_p(gsi))
111747 + return NULL_TREE;
111748 + return get_my_stmt_lhs(visited, def_stmt);
111749 +}
111750 +
111751 +tree expand(struct visited *visited, struct cgraph_node *caller_node, tree lhs)
111752 +{
111753 + gimple def_stmt;
111754 +
111755 + def_stmt = get_def_stmt(lhs);
111756 +
111757 + if (!def_stmt || gimple_code(def_stmt) == GIMPLE_NOP)
111758 + return NULL_TREE;
111759 +
111760 + if (pointer_set_contains(visited->my_stmts, def_stmt))
111761 + return lhs;
111762 +
111763 + if (pointer_set_contains(visited->stmts, def_stmt))
111764 + return expand_visited(visited, def_stmt);
111765 +
111766 + switch (gimple_code(def_stmt)) {
111767 + case GIMPLE_PHI:
111768 + return handle_phi(visited, caller_node, lhs);
111769 + case GIMPLE_CALL:
111770 + case GIMPLE_ASM:
111771 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
111772 + case GIMPLE_ASSIGN:
111773 + switch (gimple_num_ops(def_stmt)) {
111774 + case 2:
111775 + return handle_unary_ops(visited, caller_node, def_stmt);
111776 + case 3:
111777 + return handle_binary_ops(visited, caller_node, lhs);
111778 +#if BUILDING_GCC_VERSION >= 4006
111779 + case 4:
111780 + return handle_ternary_ops(visited, caller_node, lhs);
111781 +#endif
111782 + }
111783 + default:
111784 + debug_gimple_stmt(def_stmt);
111785 + error("%s: unknown gimple code", __func__);
111786 + gcc_unreachable();
111787 + }
111788 +}
111789 +
111790 diff --git a/tools/gcc/size_overflow_plugin/insert_size_overflow_check_ipa.c b/tools/gcc/size_overflow_plugin/insert_size_overflow_check_ipa.c
111791 new file mode 100644
111792 index 0000000..f8f5dd5
111793 --- /dev/null
111794 +++ b/tools/gcc/size_overflow_plugin/insert_size_overflow_check_ipa.c
111795 @@ -0,0 +1,1133 @@
111796 +/*
111797 + * Copyright 2011-2014 by Emese Revfy <re.emese@gmail.com>
111798 + * Licensed under the GPL v2, or (at your option) v3
111799 + *
111800 + * Homepage:
111801 + * http://www.grsecurity.net/~ephox/overflow_plugin/
111802 + *
111803 + * Documentation:
111804 + * http://forums.grsecurity.net/viewtopic.php?f=7&t=3043
111805 + *
111806 + * This plugin recomputes expressions of function arguments marked by a size_overflow attribute
111807 + * with double integer precision (DImode/TImode for 32/64 bit integer types).
111808 + * The recomputed argument is checked against TYPE_MAX and an event is logged on overflow and the triggering process is killed.
111809 + *
111810 + * Usage:
111811 + * $ make
111812 + * $ make run
111813 + */
111814 +
111815 +#include "gcc-common.h"
111816 +#include "size_overflow.h"
111817 +
111818 +#define VEC_LEN 128
111819 +#define RET_CHECK NULL_TREE
111820 +#define WRONG_NODE 32
111821 +#define NOT_INTENTIONAL_ASM NULL
111822 +
111823 +unsigned int call_count;
111824 +
111825 +static void set_conditions(struct pointer_set_t *visited, bool *interesting_conditions, const_tree lhs);
111826 +static void walk_use_def(struct pointer_set_t *visited, struct interesting_node *cur_node, tree lhs);
111827 +
111828 +struct visited_fns {
111829 + struct visited_fns *next;
111830 + const_tree fndecl;
111831 + unsigned int num;
111832 + const_gimple first_stmt;
111833 +};
111834 +
111835 +struct next_cgraph_node {
111836 + struct next_cgraph_node *next;
111837 + struct cgraph_node *current_function;
111838 + tree callee_fndecl;
111839 + unsigned int num;
111840 +};
111841 +
111842 +// Don't want to duplicate entries in next_cgraph_node
111843 +static bool is_in_next_cgraph_node(struct next_cgraph_node *head, struct cgraph_node *node, const_tree fndecl, unsigned int num)
111844 +{
111845 + const_tree new_callee_fndecl;
111846 + struct next_cgraph_node *cur_node;
111847 +
111848 + if (fndecl == RET_CHECK)
111849 + new_callee_fndecl = NODE_DECL(node);
111850 + else
111851 + new_callee_fndecl = fndecl;
111852 +
111853 + for (cur_node = head; cur_node; cur_node = cur_node->next) {
111854 + if (!operand_equal_p(NODE_DECL(cur_node->current_function), NODE_DECL(node), 0))
111855 + continue;
111856 + if (!operand_equal_p(cur_node->callee_fndecl, new_callee_fndecl, 0))
111857 + continue;
111858 + if (num == cur_node->num)
111859 + return true;
111860 + }
111861 + return false;
111862 +}
111863 +
111864 +/* Add a next_cgraph_node into the list for handle_function().
111865 + * handle_function() iterates over all the next cgraph nodes and
111866 + * starts the overflow check insertion process.
111867 + */
111868 +static struct next_cgraph_node *create_new_next_cgraph_node(struct next_cgraph_node *head, struct cgraph_node *node, tree fndecl, unsigned int num)
111869 +{
111870 + struct next_cgraph_node *new_node;
111871 +
111872 + if (is_in_next_cgraph_node(head, node, fndecl, num))
111873 + return head;
111874 +
111875 + new_node = (struct next_cgraph_node *)xmalloc(sizeof(*new_node));
111876 + new_node->current_function = node;
111877 + new_node->next = NULL;
111878 + new_node->num = num;
111879 + if (fndecl == RET_CHECK)
111880 + new_node->callee_fndecl = NODE_DECL(node);
111881 + else
111882 + new_node->callee_fndecl = fndecl;
111883 +
111884 + if (!head)
111885 + return new_node;
111886 +
111887 + new_node->next = head;
111888 + return new_node;
111889 +}
111890 +
111891 +static struct next_cgraph_node *create_new_next_cgraph_nodes(struct next_cgraph_node *head, struct cgraph_node *node, unsigned int num)
111892 +{
111893 + struct cgraph_edge *e;
111894 +
111895 + if (num == 0)
111896 + return create_new_next_cgraph_node(head, node, RET_CHECK, num);
111897 +
111898 + for (e = node->callers; e; e = e->next_caller) {
111899 + tree fndecl = gimple_call_fndecl(e->call_stmt);
111900 +
111901 + gcc_assert(fndecl != NULL_TREE);
111902 + head = create_new_next_cgraph_node(head, e->caller, fndecl, num);
111903 + }
111904 +
111905 + return head;
111906 +}
111907 +
111908 +struct missing_functions {
111909 + struct missing_functions *next;
111910 + const_tree node;
111911 + tree fndecl;
111912 +};
111913 +
111914 +static struct missing_functions *create_new_missing_function(struct missing_functions *missing_fn_head, tree node)
111915 +{
111916 + struct missing_functions *new_function;
111917 +
111918 + new_function = (struct missing_functions *)xmalloc(sizeof(*new_function));
111919 + new_function->node = node;
111920 + new_function->next = NULL;
111921 +
111922 + if (TREE_CODE(node) == FUNCTION_DECL)
111923 + new_function->fndecl = node;
111924 + else
111925 + new_function->fndecl = current_function_decl;
111926 + gcc_assert(new_function->fndecl);
111927 +
111928 + if (!missing_fn_head)
111929 + return new_function;
111930 +
111931 + new_function->next = missing_fn_head;
111932 + return new_function;
111933 +}
111934 +
111935 +/* If the function is missing from the hash table and it is a static function
111936 + * then create a next_cgraph_node from it for handle_function()
111937 + */
111938 +static struct next_cgraph_node *check_missing_overflow_attribute_and_create_next_node(struct next_cgraph_node *cnodes, struct missing_functions *missing_fn_head)
111939 +{
111940 + unsigned int num;
111941 + const_tree orig_fndecl;
111942 + struct cgraph_node *next_node = NULL;
111943 +
111944 + orig_fndecl = DECL_ORIGIN(missing_fn_head->fndecl);
111945 +
111946 + num = get_function_num(missing_fn_head->node, orig_fndecl);
111947 + if (num == CANNOT_FIND_ARG)
111948 + return cnodes;
111949 +
111950 + if (!is_missing_function(orig_fndecl, num))
111951 + return cnodes;
111952 +
111953 + next_node = cgraph_get_node(missing_fn_head->fndecl);
111954 + if (next_node && next_node->local.local)
111955 + cnodes = create_new_next_cgraph_nodes(cnodes, next_node, num);
111956 + return cnodes;
111957 +}
111958 +
111959 +/* Search for missing size_overflow attributes on the last nodes in ipa and collect them
111960 + * into the next_cgraph_node list. They will be the next interesting returns or callees.
111961 + */
111962 +static struct next_cgraph_node *search_overflow_attribute(struct next_cgraph_node *cnodes, struct interesting_node *cur_node)
111963 +{
111964 + unsigned int i;
111965 + tree node;
111966 + struct missing_functions *cur, *missing_fn_head = NULL;
111967 +
111968 +#if BUILDING_GCC_VERSION <= 4007
111969 + FOR_EACH_VEC_ELT(tree, cur_node->last_nodes, i, node) {
111970 +#else
111971 + FOR_EACH_VEC_ELT(*cur_node->last_nodes, i, node) {
111972 +#endif
111973 + switch (TREE_CODE(node)) {
111974 + case PARM_DECL:
111975 + if (TREE_CODE(TREE_TYPE(node)) != INTEGER_TYPE)
111976 + break;
111977 + case FUNCTION_DECL:
111978 + missing_fn_head = create_new_missing_function(missing_fn_head, node);
111979 + break;
111980 + default:
111981 + break;
111982 + }
111983 + }
111984 +
111985 + while (missing_fn_head) {
111986 + cnodes = check_missing_overflow_attribute_and_create_next_node(cnodes, missing_fn_head);
111987 +
111988 + cur = missing_fn_head->next;
111989 + free(missing_fn_head);
111990 + missing_fn_head = cur;
111991 + }
111992 +
111993 + return cnodes;
111994 +}
111995 +
111996 +static void walk_phi_set_conditions(struct pointer_set_t *visited, bool *interesting_conditions, const_tree result)
111997 +{
111998 + gimple phi = get_def_stmt(result);
111999 + unsigned int i, n = gimple_phi_num_args(phi);
112000 +
112001 + pointer_set_insert(visited, phi);
112002 + for (i = 0; i < n; i++) {
112003 + const_tree arg = gimple_phi_arg_def(phi, i);
112004 +
112005 + set_conditions(visited, interesting_conditions, arg);
112006 + }
112007 +}
112008 +
112009 +enum conditions {
112010 + FROM_CONST, NOT_UNARY, CAST
112011 +};
112012 +
112013 +// Search for constants, cast assignments and binary/ternary assignments
112014 +static void set_conditions(struct pointer_set_t *visited, bool *interesting_conditions, const_tree lhs)
112015 +{
112016 + gimple def_stmt = get_def_stmt(lhs);
112017 +
112018 + if (is_gimple_constant(lhs)) {
112019 + interesting_conditions[FROM_CONST] = true;
112020 + return;
112021 + }
112022 +
112023 + if (!def_stmt)
112024 + return;
112025 +
112026 + if (pointer_set_contains(visited, def_stmt))
112027 + return;
112028 +
112029 + switch (gimple_code(def_stmt)) {
112030 + case GIMPLE_NOP:
112031 + case GIMPLE_CALL:
112032 + case GIMPLE_ASM:
112033 + return;
112034 + case GIMPLE_PHI:
112035 + return walk_phi_set_conditions(visited, interesting_conditions, lhs);
112036 + case GIMPLE_ASSIGN:
112037 + if (gimple_num_ops(def_stmt) == 2) {
112038 + const_tree rhs = gimple_assign_rhs1(def_stmt);
112039 +
112040 + if (gimple_assign_cast_p(def_stmt))
112041 + interesting_conditions[CAST] = true;
112042 +
112043 + return set_conditions(visited, interesting_conditions, rhs);
112044 + } else {
112045 + interesting_conditions[NOT_UNARY] = true;
112046 + return;
112047 + }
112048 + default:
112049 + debug_gimple_stmt(def_stmt);
112050 + gcc_unreachable();
112051 + }
112052 +}
112053 +
112054 +// determine whether duplication will be necessary or not.
112055 +static void search_interesting_conditions(struct interesting_node *cur_node, bool *interesting_conditions)
112056 +{
112057 + struct pointer_set_t *visited;
112058 +
112059 + if (gimple_assign_cast_p(cur_node->first_stmt))
112060 + interesting_conditions[CAST] = true;
112061 + else if (is_gimple_assign(cur_node->first_stmt) && gimple_num_ops(cur_node->first_stmt) > 2)
112062 + interesting_conditions[NOT_UNARY] = true;
112063 +
112064 + visited = pointer_set_create();
112065 + set_conditions(visited, interesting_conditions, cur_node->node);
112066 + pointer_set_destroy(visited);
112067 +}
112068 +
112069 +// Remove the size_overflow asm stmt and create an assignment from the input and output of the asm
112070 +static void replace_size_overflow_asm_with_assign(gimple asm_stmt, tree lhs, tree rhs)
112071 +{
112072 + gimple assign;
112073 + gimple_stmt_iterator gsi;
112074 +
112075 + // already removed
112076 + if (gimple_bb(asm_stmt) == NULL)
112077 + return;
112078 + gsi = gsi_for_stmt(asm_stmt);
112079 +
112080 + assign = gimple_build_assign(lhs, rhs);
112081 + gsi_insert_before(&gsi, assign, GSI_SAME_STMT);
112082 + SSA_NAME_DEF_STMT(lhs) = assign;
112083 +
112084 + gsi_remove(&gsi, true);
112085 +}
112086 +
112087 +/* Get the fndecl of an interesting stmt, the fndecl is the caller function if the interesting
112088 + * stmt is a return otherwise it is the callee function.
112089 + */
112090 +const_tree get_interesting_orig_fndecl(const_gimple stmt, unsigned int argnum)
112091 +{
112092 + const_tree fndecl;
112093 +
112094 + if (argnum == 0)
112095 + fndecl = current_function_decl;
112096 + else
112097 + fndecl = gimple_call_fndecl(stmt);
112098 +
112099 + if (fndecl == NULL_TREE)
112100 + return NULL_TREE;
112101 +
112102 + return DECL_ORIGIN(fndecl);
112103 +}
112104 +
112105 +// e.g., 3.8.2, 64, arch/x86/ia32/ia32_signal.c copy_siginfo_from_user32(): compat_ptr() u32 max
112106 +static bool skip_asm(const_tree arg)
112107 +{
112108 + gimple def_stmt = get_def_stmt(arg);
112109 +
112110 + if (!def_stmt || !gimple_assign_cast_p(def_stmt))
112111 + return false;
112112 +
112113 + def_stmt = get_def_stmt(gimple_assign_rhs1(def_stmt));
112114 + return def_stmt && gimple_code(def_stmt) == GIMPLE_ASM;
112115 +}
112116 +
112117 +static void walk_use_def_phi(struct pointer_set_t *visited, struct interesting_node *cur_node, tree result)
112118 +{
112119 + gimple phi = get_def_stmt(result);
112120 + unsigned int i, n = gimple_phi_num_args(phi);
112121 +
112122 + pointer_set_insert(visited, phi);
112123 + for (i = 0; i < n; i++) {
112124 + tree arg = gimple_phi_arg_def(phi, i);
112125 +
112126 + walk_use_def(visited, cur_node, arg);
112127 + }
112128 +}
112129 +
112130 +static void walk_use_def_binary(struct pointer_set_t *visited, struct interesting_node *cur_node, tree lhs)
112131 +{
112132 + gimple def_stmt = get_def_stmt(lhs);
112133 + tree rhs1, rhs2;
112134 +
112135 + rhs1 = gimple_assign_rhs1(def_stmt);
112136 + rhs2 = gimple_assign_rhs2(def_stmt);
112137 +
112138 + walk_use_def(visited, cur_node, rhs1);
112139 + walk_use_def(visited, cur_node, rhs2);
112140 +}
112141 +
112142 +static void insert_last_node(struct interesting_node *cur_node, tree node)
112143 +{
112144 + unsigned int i;
112145 + tree element;
112146 + enum tree_code code;
112147 +
112148 + gcc_assert(node != NULL_TREE);
112149 +
112150 + if (is_gimple_constant(node))
112151 + return;
112152 +
112153 + code = TREE_CODE(node);
112154 + if (code == VAR_DECL) {
112155 + node = DECL_ORIGIN(node);
112156 + code = TREE_CODE(node);
112157 + }
112158 +
112159 + if (code != PARM_DECL && code != FUNCTION_DECL && code != COMPONENT_REF)
112160 + return;
112161 +
112162 +#if BUILDING_GCC_VERSION <= 4007
112163 + FOR_EACH_VEC_ELT(tree, cur_node->last_nodes, i, element) {
112164 +#else
112165 + FOR_EACH_VEC_ELT(*cur_node->last_nodes, i, element) {
112166 +#endif
112167 + if (operand_equal_p(node, element, 0))
112168 + return;
112169 + }
112170 +
112171 +#if BUILDING_GCC_VERSION <= 4007
112172 + gcc_assert(VEC_length(tree, cur_node->last_nodes) < VEC_LEN);
112173 + VEC_safe_push(tree, gc, cur_node->last_nodes, node);
112174 +#else
112175 + gcc_assert(cur_node->last_nodes->length() < VEC_LEN);
112176 + vec_safe_push(cur_node->last_nodes, node);
112177 +#endif
112178 +}
112179 +
112180 +// a size_overflow asm stmt in the control flow doesn't stop the recursion
112181 +static void handle_asm_stmt(struct pointer_set_t *visited, struct interesting_node *cur_node, tree lhs, const_gimple stmt)
112182 +{
112183 + if (!is_size_overflow_asm(stmt))
112184 + walk_use_def(visited, cur_node, SSA_NAME_VAR(lhs));
112185 +}
112186 +
112187 +/* collect the parm_decls and fndecls (for checking a missing size_overflow attribute (ret or arg) or intentional_overflow)
112188 + * and component refs (for checking the intentional_overflow attribute).
112189 + */
112190 +static void walk_use_def(struct pointer_set_t *visited, struct interesting_node *cur_node, tree lhs)
112191 +{
112192 + const_gimple def_stmt;
112193 +
112194 + if (TREE_CODE(lhs) != SSA_NAME) {
112195 + insert_last_node(cur_node, lhs);
112196 + return;
112197 + }
112198 +
112199 + def_stmt = get_def_stmt(lhs);
112200 + if (!def_stmt)
112201 + return;
112202 +
112203 + if (pointer_set_insert(visited, def_stmt))
112204 + return;
112205 +
112206 + switch (gimple_code(def_stmt)) {
112207 + case GIMPLE_NOP:
112208 + return walk_use_def(visited, cur_node, SSA_NAME_VAR(lhs));
112209 + case GIMPLE_ASM:
112210 + return handle_asm_stmt(visited, cur_node, lhs, def_stmt);
112211 + case GIMPLE_CALL: {
112212 + tree fndecl = gimple_call_fndecl(def_stmt);
112213 +
112214 + if (fndecl == NULL_TREE)
112215 + return;
112216 + insert_last_node(cur_node, fndecl);
112217 + return;
112218 + }
112219 + case GIMPLE_PHI:
112220 + return walk_use_def_phi(visited, cur_node, lhs);
112221 + case GIMPLE_ASSIGN:
112222 + switch (gimple_num_ops(def_stmt)) {
112223 + case 2:
112224 + return walk_use_def(visited, cur_node, gimple_assign_rhs1(def_stmt));
112225 + case 3:
112226 + return walk_use_def_binary(visited, cur_node, lhs);
112227 + }
112228 + default:
112229 + debug_gimple_stmt((gimple)def_stmt);
112230 + error("%s: unknown gimple code", __func__);
112231 + gcc_unreachable();
112232 + }
112233 +}
112234 +
112235 +// Collect all the last nodes for checking the intentional_overflow and size_overflow attributes
112236 +static void set_last_nodes(struct interesting_node *cur_node)
112237 +{
112238 + struct pointer_set_t *visited;
112239 +
112240 + visited = pointer_set_create();
112241 + walk_use_def(visited, cur_node, cur_node->node);
112242 + pointer_set_destroy(visited);
112243 +}
112244 +
112245 +enum precond {
112246 + NO_ATTRIBUTE_SEARCH, NO_CHECK_INSERT, NONE
112247 +};
112248 +
112249 +/* 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.
112250 + * There is only missing size_overflow attribute checking if the intentional_overflow attribute is the mark_no type.
112251 + * Stmt duplication is unnecessary if there are no binary/ternary assignements or if the unary assignment isn't a cast.
112252 + * 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.
112253 + */
112254 +static enum precond check_preconditions(struct interesting_node *cur_node)
112255 +{
112256 + bool interesting_conditions[3] = {false, false, false};
112257 +
112258 + set_last_nodes(cur_node);
112259 +
112260 + check_intentional_attribute_ipa(cur_node);
112261 + if (cur_node->intentional_attr_decl == MARK_TURN_OFF || cur_node->intentional_attr_cur_fndecl == MARK_TURN_OFF)
112262 + return NO_ATTRIBUTE_SEARCH;
112263 +
112264 + search_interesting_conditions(cur_node, interesting_conditions);
112265 +
112266 + // error code
112267 + if (interesting_conditions[CAST] && interesting_conditions[FROM_CONST] && !interesting_conditions[NOT_UNARY])
112268 + return NO_ATTRIBUTE_SEARCH;
112269 +
112270 + // unnecessary overflow check
112271 + if (!interesting_conditions[CAST] && !interesting_conditions[NOT_UNARY])
112272 + return NO_CHECK_INSERT;
112273 +
112274 + if (cur_node->intentional_attr_cur_fndecl != MARK_NO)
112275 + return NO_CHECK_INSERT;
112276 +
112277 + return NONE;
112278 +}
112279 +
112280 +static tree cast_to_orig_type(struct visited *visited, gimple stmt, const_tree orig_node, tree new_node)
112281 +{
112282 + const_gimple assign;
112283 + tree orig_type = TREE_TYPE(orig_node);
112284 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
112285 +
112286 + assign = build_cast_stmt(visited, orig_type, new_node, CREATE_NEW_VAR, &gsi, BEFORE_STMT, false);
112287 + return gimple_assign_lhs(assign);
112288 +}
112289 +
112290 +static void change_orig_node(struct visited *visited, struct interesting_node *cur_node, tree new_node)
112291 +{
112292 + void (*set_rhs)(gimple, tree);
112293 + gimple stmt = cur_node->first_stmt;
112294 + const_tree orig_node = cur_node->node;
112295 +
112296 + switch (gimple_code(stmt)) {
112297 + case GIMPLE_RETURN:
112298 + gimple_return_set_retval(stmt, cast_to_orig_type(visited, stmt, orig_node, new_node));
112299 + break;
112300 + case GIMPLE_CALL:
112301 + gimple_call_set_arg(stmt, cur_node->num - 1, cast_to_orig_type(visited, stmt, orig_node, new_node));
112302 + break;
112303 + case GIMPLE_ASSIGN:
112304 + switch (cur_node->num) {
112305 + case 1:
112306 + set_rhs = &gimple_assign_set_rhs1;
112307 + break;
112308 + case 2:
112309 + set_rhs = &gimple_assign_set_rhs2;
112310 + break;
112311 +#if BUILDING_GCC_VERSION >= 4006
112312 + case 3:
112313 + set_rhs = &gimple_assign_set_rhs3;
112314 + break;
112315 +#endif
112316 + default:
112317 + gcc_unreachable();
112318 + }
112319 +
112320 + set_rhs(stmt, cast_to_orig_type(visited, stmt, orig_node, new_node));
112321 + break;
112322 + default:
112323 + debug_gimple_stmt(stmt);
112324 + gcc_unreachable();
112325 + }
112326 +
112327 + update_stmt(stmt);
112328 +}
112329 +
112330 +static struct visited *create_visited(void)
112331 +{
112332 + struct visited *new_node;
112333 +
112334 + new_node = (struct visited *)xmalloc(sizeof(*new_node));
112335 + new_node->stmts = pointer_set_create();
112336 + new_node->my_stmts = pointer_set_create();
112337 + new_node->skip_expr_casts = pointer_set_create();
112338 + new_node->no_cast_check = pointer_set_create();
112339 + return new_node;
112340 +}
112341 +
112342 +static void free_visited(struct visited *visited)
112343 +{
112344 + pointer_set_destroy(visited->stmts);
112345 + pointer_set_destroy(visited->my_stmts);
112346 + pointer_set_destroy(visited->skip_expr_casts);
112347 + pointer_set_destroy(visited->no_cast_check);
112348 +
112349 + free(visited);
112350 +}
112351 +
112352 +/* This function calls the main recursion function (expand) that duplicates the stmts. Before that it checks the intentional_overflow attribute and asm stmts,
112353 + * 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
112354 + * in the original stmt (first stmt) and it inserts the overflow check for the arg of the callee or for the return value.
112355 + */
112356 +static struct next_cgraph_node *handle_interesting_stmt(struct visited *visited, struct next_cgraph_node *cnodes, struct interesting_node *cur_node, struct cgraph_node *caller_node)
112357 +{
112358 + enum precond ret;
112359 + tree new_node, orig_node = cur_node->node;
112360 +
112361 + ret = check_preconditions(cur_node);
112362 + if (ret == NO_ATTRIBUTE_SEARCH)
112363 + return cnodes;
112364 +
112365 + cnodes = search_overflow_attribute(cnodes, cur_node);
112366 +
112367 + if (ret == NO_CHECK_INSERT)
112368 + return cnodes;
112369 +
112370 + new_node = expand(visited, caller_node, orig_node);
112371 + if (new_node == NULL_TREE)
112372 + return cnodes;
112373 +
112374 + change_orig_node(visited, cur_node, new_node);
112375 + check_size_overflow(caller_node, cur_node->first_stmt, TREE_TYPE(new_node), new_node, orig_node, BEFORE_STMT);
112376 +
112377 + return cnodes;
112378 +}
112379 +
112380 +// Check visited_fns interesting nodes.
112381 +static bool is_in_interesting_node(struct interesting_node *head, const_gimple first_stmt, const_tree node, unsigned int num)
112382 +{
112383 + struct interesting_node *cur;
112384 +
112385 + for (cur = head; cur; cur = cur->next) {
112386 + if (!operand_equal_p(node, cur->node, 0))
112387 + continue;
112388 + if (num != cur->num)
112389 + continue;
112390 + if (first_stmt == cur->first_stmt)
112391 + return true;
112392 + }
112393 + return false;
112394 +}
112395 +
112396 +/* Create an interesting node. The ipa pass starts to duplicate from these stmts.
112397 + 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
112398 + 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
112399 + the intentional_overflow attribute check. They are collected by set_last_nodes().
112400 + num: arg count of a call stmt or 0 when it is a ret
112401 + node: the recursion starts from here, it is a call arg or a return value
112402 + 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.
112403 + intentional_attr_decl: intentional_overflow attribute of the callee function
112404 + intentional_attr_cur_fndecl: intentional_overflow attribute of the caller function
112405 + intentional_mark_from_gimple: the intentional overflow type of size_overflow asm stmt from gimple if it exists
112406 + */
112407 +static struct interesting_node *create_new_interesting_node(struct interesting_node *head, gimple first_stmt, tree node, unsigned int num, gimple asm_stmt)
112408 +{
112409 + struct interesting_node *new_node;
112410 + tree fndecl;
112411 + enum gimple_code code;
112412 +
112413 + gcc_assert(node != NULL_TREE);
112414 + code = gimple_code(first_stmt);
112415 + gcc_assert(code == GIMPLE_CALL || code == GIMPLE_ASM || code == GIMPLE_ASSIGN || code == GIMPLE_RETURN);
112416 +
112417 + if (num == CANNOT_FIND_ARG)
112418 + return head;
112419 +
112420 + if (skip_types(node))
112421 + return head;
112422 +
112423 + if (skip_asm(node))
112424 + return head;
112425 +
112426 + if (is_gimple_call(first_stmt))
112427 + fndecl = gimple_call_fndecl(first_stmt);
112428 + else
112429 + fndecl = current_function_decl;
112430 +
112431 + if (fndecl == NULL_TREE)
112432 + return head;
112433 +
112434 + if (is_in_interesting_node(head, first_stmt, node, num))
112435 + return head;
112436 +
112437 + new_node = (struct interesting_node *)xmalloc(sizeof(*new_node));
112438 +
112439 + new_node->next = NULL;
112440 + new_node->first_stmt = first_stmt;
112441 +#if BUILDING_GCC_VERSION <= 4007
112442 + new_node->last_nodes = VEC_alloc(tree, gc, VEC_LEN);
112443 +#else
112444 + vec_alloc(new_node->last_nodes, VEC_LEN);
112445 +#endif
112446 + new_node->num = num;
112447 + new_node->node = node;
112448 + new_node->fndecl = fndecl;
112449 + new_node->intentional_attr_decl = MARK_NO;
112450 + new_node->intentional_attr_cur_fndecl = MARK_NO;
112451 + new_node->intentional_mark_from_gimple = asm_stmt;
112452 +
112453 + if (!head)
112454 + return new_node;
112455 +
112456 + new_node->next = head;
112457 + return new_node;
112458 +}
112459 +
112460 +/* 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).
112461 + * If the ret stmt is in the next cgraph node list then it's an interesting ret.
112462 + */
112463 +static struct interesting_node *handle_stmt_by_cgraph_nodes_ret(struct interesting_node *head, gimple stmt, struct next_cgraph_node *next_node)
112464 +{
112465 + struct next_cgraph_node *cur_node;
112466 + tree ret = gimple_return_retval(stmt);
112467 +
112468 + if (ret == NULL_TREE)
112469 + return head;
112470 +
112471 + for (cur_node = next_node; cur_node; cur_node = cur_node->next) {
112472 + if (!operand_equal_p(cur_node->callee_fndecl, DECL_ORIGIN(current_function_decl), 0))
112473 + continue;
112474 + if (cur_node->num == 0)
112475 + head = create_new_interesting_node(head, stmt, ret, 0, NOT_INTENTIONAL_ASM);
112476 + }
112477 +
112478 + return head;
112479 +}
112480 +
112481 +/* 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).
112482 + * If the call stmt is in the next cgraph node list then it's an interesting call.
112483 + */
112484 +static struct interesting_node *handle_stmt_by_cgraph_nodes_call(struct interesting_node *head, gimple stmt, struct next_cgraph_node *next_node)
112485 +{
112486 + unsigned int argnum;
112487 + tree arg;
112488 + const_tree fndecl;
112489 + struct next_cgraph_node *cur_node;
112490 +
112491 + fndecl = gimple_call_fndecl(stmt);
112492 + if (fndecl == NULL_TREE)
112493 + return head;
112494 +
112495 + for (cur_node = next_node; cur_node; cur_node = cur_node->next) {
112496 + if (!operand_equal_p(cur_node->callee_fndecl, fndecl, 0))
112497 + continue;
112498 + argnum = get_correct_arg_count(cur_node->num, fndecl);
112499 + gcc_assert(argnum != CANNOT_FIND_ARG);
112500 + if (argnum == 0)
112501 + continue;
112502 +
112503 + arg = gimple_call_arg(stmt, argnum - 1);
112504 + head = create_new_interesting_node(head, stmt, arg, argnum, NOT_INTENTIONAL_ASM);
112505 + }
112506 +
112507 + return head;
112508 +}
112509 +
112510 +static unsigned int check_ops(const_tree orig_node, const_tree node, unsigned int ret_count)
112511 +{
112512 + if (!operand_equal_p(orig_node, node, 0))
112513 + return WRONG_NODE;
112514 + if (skip_types(node))
112515 + return WRONG_NODE;
112516 + return ret_count;
112517 +}
112518 +
112519 +// Get the index of the rhs node in an assignment
112520 +static unsigned int get_assign_ops_count(const_gimple stmt, tree node)
112521 +{
112522 + const_tree rhs1, rhs2;
112523 + unsigned int ret;
112524 +
112525 + gcc_assert(stmt);
112526 + gcc_assert(is_gimple_assign(stmt));
112527 +
112528 + rhs1 = gimple_assign_rhs1(stmt);
112529 + gcc_assert(rhs1 != NULL_TREE);
112530 +
112531 + switch (gimple_num_ops(stmt)) {
112532 + case 2:
112533 + return check_ops(node, rhs1, 1);
112534 + case 3:
112535 + ret = check_ops(node, rhs1, 1);
112536 + if (ret != WRONG_NODE)
112537 + return ret;
112538 +
112539 + rhs2 = gimple_assign_rhs2(stmt);
112540 + gcc_assert(rhs2 != NULL_TREE);
112541 + return check_ops(node, rhs2, 2);
112542 + default:
112543 + gcc_unreachable();
112544 + }
112545 +}
112546 +
112547 +// Find the correct arg number of a call stmt. It is needed when the interesting function is a cloned function.
112548 +static unsigned int find_arg_number_gimple(const_tree arg, const_gimple stmt)
112549 +{
112550 + unsigned int i;
112551 +
112552 + if (gimple_call_fndecl(stmt) == NULL_TREE)
112553 + return CANNOT_FIND_ARG;
112554 +
112555 + for (i = 0; i < gimple_call_num_args(stmt); i++) {
112556 + tree node;
112557 +
112558 + node = gimple_call_arg(stmt, i);
112559 + if (!operand_equal_p(arg, node, 0))
112560 + continue;
112561 + if (!skip_types(node))
112562 + return i + 1;
112563 + }
112564 +
112565 + return CANNOT_FIND_ARG;
112566 +}
112567 +
112568 +/* starting from the size_overflow asm stmt collect interesting stmts. They can be
112569 + * any of return, call or assignment stmts (because of inlining).
112570 + */
112571 +static struct interesting_node *get_interesting_ret_or_call(struct pointer_set_t *visited, struct interesting_node *head, tree node, gimple intentional_asm)
112572 +{
112573 + use_operand_p use_p;
112574 + imm_use_iterator imm_iter;
112575 + unsigned int argnum;
112576 +
112577 + gcc_assert(TREE_CODE(node) == SSA_NAME);
112578 +
112579 + if (pointer_set_insert(visited, node))
112580 + return head;
112581 +
112582 + FOR_EACH_IMM_USE_FAST(use_p, imm_iter, node) {
112583 + gimple stmt = USE_STMT(use_p);
112584 +
112585 + if (stmt == NULL)
112586 + return head;
112587 + if (is_gimple_debug(stmt))
112588 + continue;
112589 +
112590 + switch (gimple_code(stmt)) {
112591 + case GIMPLE_CALL:
112592 + argnum = find_arg_number_gimple(node, stmt);
112593 + head = create_new_interesting_node(head, stmt, node, argnum, intentional_asm);
112594 + break;
112595 + case GIMPLE_RETURN:
112596 + head = create_new_interesting_node(head, stmt, node, 0, intentional_asm);
112597 + break;
112598 + case GIMPLE_ASSIGN:
112599 + argnum = get_assign_ops_count(stmt, node);
112600 + head = create_new_interesting_node(head, stmt, node, argnum, intentional_asm);
112601 + break;
112602 + case GIMPLE_PHI: {
112603 + tree result = gimple_phi_result(stmt);
112604 + head = get_interesting_ret_or_call(visited, head, result, intentional_asm);
112605 + break;
112606 + }
112607 + case GIMPLE_ASM:
112608 + if (gimple_asm_noutputs(stmt) != 0)
112609 + break;
112610 + if (!is_size_overflow_asm(stmt))
112611 + break;
112612 + head = create_new_interesting_node(head, stmt, node, 1, intentional_asm);
112613 + break;
112614 + case GIMPLE_COND:
112615 + case GIMPLE_SWITCH:
112616 + break;
112617 + default:
112618 + debug_gimple_stmt(stmt);
112619 + gcc_unreachable();
112620 + break;
112621 + }
112622 + }
112623 + return head;
112624 +}
112625 +
112626 +static void remove_size_overflow_asm(gimple stmt)
112627 +{
112628 + gimple_stmt_iterator gsi;
112629 + tree input, output;
112630 +
112631 + if (!is_size_overflow_asm(stmt))
112632 + return;
112633 +
112634 + if (gimple_asm_noutputs(stmt) == 0) {
112635 + gsi = gsi_for_stmt(stmt);
112636 + ipa_remove_stmt_references(cgraph_get_create_node(current_function_decl), stmt);
112637 + gsi_remove(&gsi, true);
112638 + return;
112639 + }
112640 +
112641 + input = gimple_asm_input_op(stmt, 0);
112642 + output = gimple_asm_output_op(stmt, 0);
112643 + replace_size_overflow_asm_with_assign(stmt, TREE_VALUE(output), TREE_VALUE(input));
112644 +}
112645 +
112646 +/* handle the size_overflow asm stmts from the gimple pass and collect the interesting stmts.
112647 + * If the asm stmt is a parm_decl kind (noutputs == 0) then remove it.
112648 + * If it is a simple asm stmt then replace it with an assignment from the asm input to the asm output.
112649 + */
112650 +static struct interesting_node *handle_stmt_by_size_overflow_asm(gimple stmt, struct interesting_node *head)
112651 +{
112652 + const_tree output;
112653 + struct pointer_set_t *visited;
112654 + gimple intentional_asm = NOT_INTENTIONAL_ASM;
112655 +
112656 + if (!is_size_overflow_asm(stmt))
112657 + return head;
112658 +
112659 + if (is_size_overflow_intentional_asm_yes(stmt) || is_size_overflow_intentional_asm_turn_off(stmt))
112660 + intentional_asm = stmt;
112661 +
112662 + gcc_assert(gimple_asm_ninputs(stmt) == 1);
112663 +
112664 + if (gimple_asm_noutputs(stmt) == 0 && is_size_overflow_intentional_asm_turn_off(stmt))
112665 + return head;
112666 +
112667 + if (gimple_asm_noutputs(stmt) == 0) {
112668 + const_tree input;
112669 +
112670 + if (!is_size_overflow_intentional_asm_turn_off(stmt))
112671 + return head;
112672 +
112673 + input = gimple_asm_input_op(stmt, 0);
112674 + remove_size_overflow_asm(stmt);
112675 + if (is_gimple_constant(TREE_VALUE(input)))
112676 + return head;
112677 + visited = pointer_set_create();
112678 + head = get_interesting_ret_or_call(visited, head, TREE_VALUE(input), intentional_asm);
112679 + pointer_set_destroy(visited);
112680 + return head;
112681 + }
112682 +
112683 + if (!is_size_overflow_intentional_asm_yes(stmt) && !is_size_overflow_intentional_asm_turn_off(stmt))
112684 + remove_size_overflow_asm(stmt);
112685 +
112686 + visited = pointer_set_create();
112687 + output = gimple_asm_output_op(stmt, 0);
112688 + head = get_interesting_ret_or_call(visited, head, TREE_VALUE(output), intentional_asm);
112689 + pointer_set_destroy(visited);
112690 + return head;
112691 +}
112692 +
112693 +/* Iterate over all the stmts of a function and look for the size_overflow asm stmts (they were created in the gimple pass)
112694 + * or a call stmt or a return stmt and store them in the interesting_node list
112695 + */
112696 +static struct interesting_node *collect_interesting_stmts(struct next_cgraph_node *next_node)
112697 +{
112698 + basic_block bb;
112699 + struct interesting_node *head = NULL;
112700 +
112701 + FOR_ALL_BB_FN(bb, cfun) {
112702 + gimple_stmt_iterator gsi;
112703 +
112704 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
112705 + enum gimple_code code;
112706 + gimple stmt = gsi_stmt(gsi);
112707 +
112708 + code = gimple_code(stmt);
112709 +
112710 + if (code == GIMPLE_ASM)
112711 + head = handle_stmt_by_size_overflow_asm(stmt, head);
112712 +
112713 + if (!next_node)
112714 + continue;
112715 + if (code == GIMPLE_CALL)
112716 + head = handle_stmt_by_cgraph_nodes_call(head, stmt, next_node);
112717 + if (code == GIMPLE_RETURN)
112718 + head = handle_stmt_by_cgraph_nodes_ret(head, stmt, next_node);
112719 + }
112720 + }
112721 + return head;
112722 +}
112723 +
112724 +static void free_interesting_node(struct interesting_node *head)
112725 +{
112726 + struct interesting_node *cur;
112727 +
112728 + while (head) {
112729 + cur = head->next;
112730 +#if BUILDING_GCC_VERSION <= 4007
112731 + VEC_free(tree, gc, head->last_nodes);
112732 +#else
112733 + vec_free(head->last_nodes);
112734 +#endif
112735 + free(head);
112736 + head = cur;
112737 + }
112738 +}
112739 +
112740 +static struct visited_fns *insert_visited_fns_function(struct visited_fns *head, struct interesting_node *cur_node)
112741 +{
112742 + struct visited_fns *new_visited_fns;
112743 +
112744 + new_visited_fns = (struct visited_fns *)xmalloc(sizeof(*new_visited_fns));
112745 + new_visited_fns->fndecl = cur_node->fndecl;
112746 + new_visited_fns->num = cur_node->num;
112747 + new_visited_fns->first_stmt = cur_node->first_stmt;
112748 + new_visited_fns->next = NULL;
112749 +
112750 + if (!head)
112751 + return new_visited_fns;
112752 +
112753 + new_visited_fns->next = head;
112754 + return new_visited_fns;
112755 +}
112756 +
112757 +/* Check whether the function was already visited_fns. If the fndecl, the arg count of the fndecl and the first_stmt (call or return) are same then
112758 + * it is a visited_fns function.
112759 + */
112760 +static bool is_visited_fns_function(struct visited_fns *head, struct interesting_node *cur_node)
112761 +{
112762 + struct visited_fns *cur;
112763 +
112764 + if (!head)
112765 + return false;
112766 +
112767 + for (cur = head; cur; cur = cur->next) {
112768 + if (cur_node->first_stmt != cur->first_stmt)
112769 + continue;
112770 + if (!operand_equal_p(cur_node->fndecl, cur->fndecl, 0))
112771 + continue;
112772 + if (cur_node->num == cur->num)
112773 + return true;
112774 + }
112775 + return false;
112776 +}
112777 +
112778 +static void free_next_cgraph_node(struct next_cgraph_node *head)
112779 +{
112780 + struct next_cgraph_node *cur;
112781 +
112782 + while (head) {
112783 + cur = head->next;
112784 + free(head);
112785 + head = cur;
112786 + }
112787 +}
112788 +
112789 +static void remove_all_size_overflow_asm(void)
112790 +{
112791 + basic_block bb;
112792 +
112793 + FOR_ALL_BB_FN(bb, cfun) {
112794 + gimple_stmt_iterator si;
112795 +
112796 + for (si = gsi_start_bb(bb); !gsi_end_p(si); gsi_next(&si))
112797 + remove_size_overflow_asm(gsi_stmt(si));
112798 + }
112799 +}
112800 +
112801 +/* Main recursive walk of the ipa pass: iterate over the collected interesting stmts in a function
112802 + * (they are interesting if they have an associated size_overflow asm stmt) and recursively walk
112803 + * the newly collected interesting functions (they are interesting if there is control flow between
112804 + * the interesting stmts and them).
112805 + */
112806 +static struct visited_fns *handle_function(struct cgraph_node *node, struct next_cgraph_node *next_node, struct visited_fns *visited_fns)
112807 +{
112808 + struct visited *visited;
112809 + struct interesting_node *head, *cur_node;
112810 + struct next_cgraph_node *cur_cnodes, *cnodes_head = NULL;
112811 +
112812 + set_current_function_decl(NODE_DECL(node));
112813 + call_count = 0;
112814 +
112815 + head = collect_interesting_stmts(next_node);
112816 +
112817 + visited = create_visited();
112818 + for (cur_node = head; cur_node; cur_node = cur_node->next) {
112819 + if (is_visited_fns_function(visited_fns, cur_node))
112820 + continue;
112821 + cnodes_head = handle_interesting_stmt(visited, cnodes_head, cur_node, node);
112822 + visited_fns = insert_visited_fns_function(visited_fns, cur_node);
112823 + }
112824 +
112825 + free_visited(visited);
112826 + free_interesting_node(head);
112827 + remove_all_size_overflow_asm();
112828 + unset_current_function_decl();
112829 +
112830 + for (cur_cnodes = cnodes_head; cur_cnodes; cur_cnodes = cur_cnodes->next)
112831 + visited_fns = handle_function(cur_cnodes->current_function, cur_cnodes, visited_fns);
112832 +
112833 + free_next_cgraph_node(cnodes_head);
112834 + return visited_fns;
112835 +}
112836 +
112837 +static void free_visited_fns(struct visited_fns *head)
112838 +{
112839 + struct visited_fns *cur;
112840 +
112841 + while (head) {
112842 + cur = head->next;
112843 + free(head);
112844 + head = cur;
112845 + }
112846 +}
112847 +
112848 +// Main entry point of the ipa pass: erases the plf flag of all stmts and iterates over all the functions
112849 +unsigned int search_function(void)
112850 +{
112851 + struct cgraph_node *node;
112852 + struct visited_fns *visited_fns = NULL;
112853 +
112854 + FOR_EACH_FUNCTION_WITH_GIMPLE_BODY(node) {
112855 + gcc_assert(cgraph_function_flags_ready);
112856 +#if BUILDING_GCC_VERSION <= 4007
112857 + gcc_assert(node->reachable);
112858 +#endif
112859 +
112860 + visited_fns = handle_function(node, NULL, visited_fns);
112861 + }
112862 +
112863 + free_visited_fns(visited_fns);
112864 + return 0;
112865 +}
112866 +
112867 +#if BUILDING_GCC_VERSION >= 4009
112868 +static const struct pass_data insert_size_overflow_check_data = {
112869 +#else
112870 +static struct ipa_opt_pass_d insert_size_overflow_check = {
112871 + .pass = {
112872 +#endif
112873 + .type = SIMPLE_IPA_PASS,
112874 + .name = "size_overflow",
112875 +#if BUILDING_GCC_VERSION >= 4008
112876 + .optinfo_flags = OPTGROUP_NONE,
112877 +#endif
112878 +#if BUILDING_GCC_VERSION >= 4009
112879 + .has_gate = false,
112880 + .has_execute = true,
112881 +#else
112882 + .gate = NULL,
112883 + .execute = search_function,
112884 + .sub = NULL,
112885 + .next = NULL,
112886 + .static_pass_number = 0,
112887 +#endif
112888 + .tv_id = TV_NONE,
112889 + .properties_required = 0,
112890 + .properties_provided = 0,
112891 + .properties_destroyed = 0,
112892 + .todo_flags_start = 0,
112893 + .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,
112894 +#if BUILDING_GCC_VERSION < 4009
112895 + },
112896 + .generate_summary = NULL,
112897 + .write_summary = NULL,
112898 + .read_summary = NULL,
112899 +#if BUILDING_GCC_VERSION >= 4006
112900 + .write_optimization_summary = NULL,
112901 + .read_optimization_summary = NULL,
112902 +#endif
112903 + .stmt_fixup = NULL,
112904 + .function_transform_todo_flags_start = 0,
112905 + .function_transform = NULL,
112906 + .variable_transform = NULL,
112907 +#endif
112908 +};
112909 +
112910 +#if BUILDING_GCC_VERSION >= 4009
112911 +namespace {
112912 +class insert_size_overflow_check : public ipa_opt_pass_d {
112913 +public:
112914 + insert_size_overflow_check() : ipa_opt_pass_d(insert_size_overflow_check_data, g, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL) {}
112915 + unsigned int execute() { return search_function(); }
112916 +};
112917 +}
112918 +#endif
112919 +
112920 +struct opt_pass *make_insert_size_overflow_check(void)
112921 +{
112922 +#if BUILDING_GCC_VERSION >= 4009
112923 + return new insert_size_overflow_check();
112924 +#else
112925 + return &insert_size_overflow_check.pass;
112926 +#endif
112927 +}
112928 +
112929 diff --git a/tools/gcc/size_overflow_plugin/intentional_overflow.c b/tools/gcc/size_overflow_plugin/intentional_overflow.c
112930 new file mode 100644
112931 index 0000000..38904bc
112932 --- /dev/null
112933 +++ b/tools/gcc/size_overflow_plugin/intentional_overflow.c
112934 @@ -0,0 +1,733 @@
112935 +/*
112936 + * Copyright 2011-2014 by Emese Revfy <re.emese@gmail.com>
112937 + * Licensed under the GPL v2, or (at your option) v3
112938 + *
112939 + * Homepage:
112940 + * http://www.grsecurity.net/~ephox/overflow_plugin/
112941 + *
112942 + * Documentation:
112943 + * http://forums.grsecurity.net/viewtopic.php?f=7&t=3043
112944 + *
112945 + * This plugin recomputes expressions of function arguments marked by a size_overflow attribute
112946 + * with double integer precision (DImode/TImode for 32/64 bit integer types).
112947 + * The recomputed argument is checked against TYPE_MAX and an event is logged on overflow and the triggering process is killed.
112948 + *
112949 + * Usage:
112950 + * $ make
112951 + * $ make run
112952 + */
112953 +
112954 +#include "gcc-common.h"
112955 +#include "size_overflow.h"
112956 +
112957 +/* Get the param of the intentional_overflow attribute.
112958 + * * 0: MARK_NOT_INTENTIONAL
112959 + * * 1..MAX_PARAM: MARK_YES
112960 + * * -1: MARK_TURN_OFF
112961 + */
112962 +static tree get_attribute_param(const_tree decl)
112963 +{
112964 + const_tree attr;
112965 +
112966 + if (decl == NULL_TREE)
112967 + return NULL_TREE;
112968 +
112969 + attr = lookup_attribute("intentional_overflow", DECL_ATTRIBUTES(decl));
112970 + if (!attr || !TREE_VALUE(attr))
112971 + return NULL_TREE;
112972 +
112973 + return TREE_VALUE(attr);
112974 +}
112975 +
112976 +// MARK_TURN_OFF
112977 +bool is_turn_off_intentional_attr(const_tree decl)
112978 +{
112979 + const_tree param_head;
112980 +
112981 + param_head = get_attribute_param(decl);
112982 + if (param_head == NULL_TREE)
112983 + return false;
112984 +
112985 + if (TREE_INT_CST_HIGH(TREE_VALUE(param_head)) == -1)
112986 + return true;
112987 + return false;
112988 +}
112989 +
112990 +// MARK_NOT_INTENTIONAL
112991 +bool is_end_intentional_intentional_attr(const_tree decl, unsigned int argnum)
112992 +{
112993 + const_tree param_head;
112994 +
112995 + if (argnum == 0)
112996 + return false;
112997 +
112998 + param_head = get_attribute_param(decl);
112999 + if (param_head == NULL_TREE)
113000 + return false;
113001 +
113002 + if (!TREE_INT_CST_LOW(TREE_VALUE(param_head)))
113003 + return true;
113004 + return false;
113005 +}
113006 +
113007 +// MARK_YES
113008 +bool is_yes_intentional_attr(const_tree decl, unsigned int argnum)
113009 +{
113010 + tree param, param_head;
113011 +
113012 + if (argnum == 0)
113013 + return false;
113014 +
113015 + param_head = get_attribute_param(decl);
113016 + for (param = param_head; param; param = TREE_CHAIN(param))
113017 + if (argnum == TREE_INT_CST_LOW(TREE_VALUE(param)))
113018 + return true;
113019 + return false;
113020 +}
113021 +
113022 +void print_missing_intentional(enum mark callee_attr, enum mark caller_attr, const_tree decl, unsigned int argnum)
113023 +{
113024 + location_t loc;
113025 +
113026 + if (caller_attr == MARK_NO || caller_attr == MARK_NOT_INTENTIONAL || caller_attr == MARK_TURN_OFF)
113027 + return;
113028 +
113029 + if (callee_attr == MARK_NOT_INTENTIONAL || callee_attr == MARK_YES)
113030 + return;
113031 +
113032 + loc = DECL_SOURCE_LOCATION(decl);
113033 + inform(loc, "The intentional_overflow attribute is missing from +%s+%u+", DECL_NAME_POINTER(decl), argnum);
113034 +}
113035 +
113036 +// Get the field decl of a component ref for intentional_overflow checking
113037 +static const_tree search_field_decl(const_tree comp_ref)
113038 +{
113039 + const_tree field = NULL_TREE;
113040 + unsigned int i, len = TREE_OPERAND_LENGTH(comp_ref);
113041 +
113042 + for (i = 0; i < len; i++) {
113043 + field = TREE_OPERAND(comp_ref, i);
113044 + if (TREE_CODE(field) == FIELD_DECL)
113045 + break;
113046 + }
113047 + gcc_assert(TREE_CODE(field) == FIELD_DECL);
113048 + return field;
113049 +}
113050 +
113051 +/* Get the type of the intentional_overflow attribute of a node
113052 + * * MARK_TURN_OFF
113053 + * * MARK_YES
113054 + * * MARK_NO
113055 + * * MARK_NOT_INTENTIONAL
113056 + */
113057 +enum mark get_intentional_attr_type(const_tree node)
113058 +{
113059 + const_tree cur_decl;
113060 +
113061 + if (node == NULL_TREE)
113062 + return MARK_NO;
113063 +
113064 + switch (TREE_CODE(node)) {
113065 + case COMPONENT_REF:
113066 + cur_decl = search_field_decl(node);
113067 + if (is_turn_off_intentional_attr(cur_decl))
113068 + return MARK_TURN_OFF;
113069 + if (is_end_intentional_intentional_attr(cur_decl, 1))
113070 + return MARK_YES;
113071 + break;
113072 + case PARM_DECL: {
113073 + unsigned int argnum;
113074 +
113075 + cur_decl = DECL_ORIGIN(current_function_decl);
113076 + argnum = find_arg_number_tree(node, cur_decl);
113077 + if (argnum == CANNOT_FIND_ARG)
113078 + return MARK_NO;
113079 + if (is_yes_intentional_attr(cur_decl, argnum))
113080 + return MARK_YES;
113081 + if (is_end_intentional_intentional_attr(cur_decl, argnum))
113082 + return MARK_NOT_INTENTIONAL;
113083 + break;
113084 + }
113085 + case FUNCTION_DECL:
113086 + if (is_turn_off_intentional_attr(DECL_ORIGIN(node)))
113087 + return MARK_TURN_OFF;
113088 + break;
113089 + default:
113090 + break;
113091 + }
113092 + return MARK_NO;
113093 +}
113094 +
113095 +// Search for the intentional_overflow attribute on the last nodes
113096 +static enum mark search_last_nodes_intentional(struct interesting_node *cur_node)
113097 +{
113098 + unsigned int i;
113099 + tree last_node;
113100 + enum mark mark = MARK_NO;
113101 +
113102 +#if BUILDING_GCC_VERSION <= 4007
113103 + FOR_EACH_VEC_ELT(tree, cur_node->last_nodes, i, last_node) {
113104 +#else
113105 + FOR_EACH_VEC_ELT(*cur_node->last_nodes, i, last_node) {
113106 +#endif
113107 + mark = get_intentional_attr_type(last_node);
113108 + if (mark != MARK_NO)
113109 + break;
113110 + }
113111 + return mark;
113112 +}
113113 +
113114 +/* Check the intentional kind of size_overflow asm stmt (created by the gimple pass) and
113115 + * set the appropriate intentional_overflow type. Delete the asm stmt in the end.
113116 + */
113117 +static bool is_intentional_attribute_from_gimple(struct interesting_node *cur_node)
113118 +{
113119 + if (!cur_node->intentional_mark_from_gimple)
113120 + return false;
113121 +
113122 + if (is_size_overflow_intentional_asm_yes(cur_node->intentional_mark_from_gimple))
113123 + cur_node->intentional_attr_cur_fndecl = MARK_YES;
113124 + else
113125 + cur_node->intentional_attr_cur_fndecl = MARK_TURN_OFF;
113126 +
113127 + // skip param decls
113128 + if (gimple_asm_noutputs(cur_node->intentional_mark_from_gimple) == 0)
113129 + return true;
113130 + return true;
113131 +}
113132 +
113133 +/* Search intentional_overflow attribute on caller and on callee too.
113134 + * 0</MARK_YES: no dup, search size_overflow and intentional_overflow attributes
113135 + * 0/MARK_NOT_INTENTIONAL: no dup, search size_overflow attribute (int)
113136 + * -1/MARK_TURN_OFF: no dup, no search, current_function_decl -> no dup
113137 +*/
113138 +void check_intentional_attribute_ipa(struct interesting_node *cur_node)
113139 +{
113140 + const_tree fndecl;
113141 +
113142 + if (is_intentional_attribute_from_gimple(cur_node))
113143 + return;
113144 +
113145 + if (is_turn_off_intentional_attr(DECL_ORIGIN(current_function_decl))) {
113146 + cur_node->intentional_attr_cur_fndecl = MARK_TURN_OFF;
113147 + return;
113148 + }
113149 +
113150 + if (gimple_code(cur_node->first_stmt) == GIMPLE_ASM) {
113151 + cur_node->intentional_attr_cur_fndecl = MARK_NOT_INTENTIONAL;
113152 + return;
113153 + }
113154 +
113155 + if (gimple_code(cur_node->first_stmt) == GIMPLE_ASSIGN)
113156 + return;
113157 +
113158 + fndecl = get_interesting_orig_fndecl(cur_node->first_stmt, cur_node->num);
113159 + if (is_turn_off_intentional_attr(fndecl)) {
113160 + cur_node->intentional_attr_decl = MARK_TURN_OFF;
113161 + return;
113162 + }
113163 +
113164 + if (is_end_intentional_intentional_attr(fndecl, cur_node->num))
113165 + cur_node->intentional_attr_decl = MARK_NOT_INTENTIONAL;
113166 + else if (is_yes_intentional_attr(fndecl, cur_node->num))
113167 + cur_node->intentional_attr_decl = MARK_YES;
113168 +
113169 + cur_node->intentional_attr_cur_fndecl = search_last_nodes_intentional(cur_node);
113170 + print_missing_intentional(cur_node->intentional_attr_decl, cur_node->intentional_attr_cur_fndecl, cur_node->fndecl, cur_node->num);
113171 +}
113172 +
113173 +bool is_a_cast_and_const_overflow(const_tree no_const_rhs)
113174 +{
113175 + const_tree rhs1, lhs, rhs1_type, lhs_type;
113176 + enum machine_mode lhs_mode, rhs_mode;
113177 + gimple def_stmt = get_def_stmt(no_const_rhs);
113178 +
113179 + if (!def_stmt || !gimple_assign_cast_p(def_stmt))
113180 + return false;
113181 +
113182 + rhs1 = gimple_assign_rhs1(def_stmt);
113183 + lhs = gimple_assign_lhs(def_stmt);
113184 + rhs1_type = TREE_TYPE(rhs1);
113185 + lhs_type = TREE_TYPE(lhs);
113186 + rhs_mode = TYPE_MODE(rhs1_type);
113187 + lhs_mode = TYPE_MODE(lhs_type);
113188 + if (TYPE_UNSIGNED(lhs_type) == TYPE_UNSIGNED(rhs1_type) || lhs_mode != rhs_mode)
113189 + return false;
113190 +
113191 + return true;
113192 +}
113193 +
113194 +static unsigned int uses_num(tree node)
113195 +{
113196 + imm_use_iterator imm_iter;
113197 + use_operand_p use_p;
113198 + unsigned int num = 0;
113199 +
113200 + FOR_EACH_IMM_USE_FAST(use_p, imm_iter, node) {
113201 + gimple use_stmt = USE_STMT(use_p);
113202 +
113203 + if (use_stmt == NULL)
113204 + return num;
113205 + if (is_gimple_debug(use_stmt))
113206 + continue;
113207 + if (gimple_assign_cast_p(use_stmt) && is_size_overflow_type(gimple_assign_lhs(use_stmt)))
113208 + continue;
113209 + num++;
113210 + }
113211 + return num;
113212 +}
113213 +
113214 +static bool no_uses(tree node)
113215 +{
113216 + return !uses_num(node);
113217 +}
113218 +
113219 +// 3.8.5 mm/page-writeback.c __ilog2_u64(): ret, uint + uintmax; uint -> int; int max
113220 +bool is_const_plus_unsigned_signed_truncation(const_tree lhs)
113221 +{
113222 + tree rhs1, lhs_type, rhs_type, rhs2, not_const_rhs;
113223 + gimple def_stmt = get_def_stmt(lhs);
113224 +
113225 + if (!def_stmt || !gimple_assign_cast_p(def_stmt))
113226 + return false;
113227 +
113228 + rhs1 = gimple_assign_rhs1(def_stmt);
113229 + rhs_type = TREE_TYPE(rhs1);
113230 + lhs_type = TREE_TYPE(lhs);
113231 + if (TYPE_UNSIGNED(lhs_type) || !TYPE_UNSIGNED(rhs_type))
113232 + return false;
113233 + if (TYPE_MODE(lhs_type) != TYPE_MODE(rhs_type))
113234 + return false;
113235 +
113236 + def_stmt = get_def_stmt(rhs1);
113237 + if (!def_stmt || !is_gimple_assign(def_stmt) || gimple_num_ops(def_stmt) != 3)
113238 + return false;
113239 +
113240 + if (gimple_assign_rhs_code(def_stmt) != PLUS_EXPR)
113241 + return false;
113242 +
113243 + rhs1 = gimple_assign_rhs1(def_stmt);
113244 + rhs2 = gimple_assign_rhs2(def_stmt);
113245 + if (!is_gimple_constant(rhs1) && !is_gimple_constant(rhs2))
113246 + return false;
113247 +
113248 + if (is_gimple_constant(rhs2))
113249 + not_const_rhs = rhs1;
113250 + else
113251 + not_const_rhs = rhs2;
113252 +
113253 + return no_uses(not_const_rhs);
113254 +}
113255 +
113256 +static bool is_lt_signed_type_max(const_tree rhs)
113257 +{
113258 + const_tree new_type, type_max, type = TREE_TYPE(rhs);
113259 +
113260 + if (!TYPE_UNSIGNED(type))
113261 + return true;
113262 +
113263 + switch (TYPE_MODE(type)) {
113264 + case QImode:
113265 + new_type = intQI_type_node;
113266 + break;
113267 + case HImode:
113268 + new_type = intHI_type_node;
113269 + break;
113270 + case SImode:
113271 + new_type = intSI_type_node;
113272 + break;
113273 + case DImode:
113274 + new_type = intDI_type_node;
113275 + break;
113276 + default:
113277 + debug_tree((tree)type);
113278 + gcc_unreachable();
113279 + }
113280 +
113281 + type_max = TYPE_MAX_VALUE(new_type);
113282 + if (!tree_int_cst_lt(type_max, rhs))
113283 + return true;
113284 +
113285 + return false;
113286 +}
113287 +
113288 +static bool is_gt_zero(const_tree rhs)
113289 +{
113290 + const_tree type = TREE_TYPE(rhs);
113291 +
113292 + if (TYPE_UNSIGNED(type))
113293 + return true;
113294 +
113295 + if (!tree_int_cst_lt(rhs, integer_zero_node))
113296 + return true;
113297 +
113298 + return false;
113299 +}
113300 +
113301 +bool is_a_constant_overflow(const_gimple stmt, const_tree rhs)
113302 +{
113303 + if (gimple_assign_rhs_code(stmt) == MIN_EXPR)
113304 + return false;
113305 + if (!is_gimple_constant(rhs))
113306 + return false;
113307 +
113308 + // If the const is between 0 and the max value of the signed type of the same bitsize then there is no intentional overflow
113309 + if (is_lt_signed_type_max(rhs) && is_gt_zero(rhs))
113310 + return false;
113311 +
113312 + return true;
113313 +}
113314 +
113315 +static tree change_assign_rhs(struct visited *visited, gimple stmt, const_tree orig_rhs, tree new_rhs)
113316 +{
113317 + gimple assign;
113318 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
113319 + tree origtype = TREE_TYPE(orig_rhs);
113320 +
113321 + gcc_assert(is_gimple_assign(stmt));
113322 +
113323 + assign = build_cast_stmt(visited, origtype, new_rhs, CREATE_NEW_VAR, &gsi, BEFORE_STMT, false);
113324 + pointer_set_insert(visited->my_stmts, assign);
113325 + return gimple_assign_lhs(assign);
113326 +}
113327 +
113328 +tree handle_intentional_overflow(struct visited *visited, struct cgraph_node *caller_node, bool check_overflow, gimple stmt, tree change_rhs, tree new_rhs2)
113329 +{
113330 + tree new_rhs, orig_rhs;
113331 + void (*gimple_assign_set_rhs)(gimple, tree);
113332 + tree rhs1 = gimple_assign_rhs1(stmt);
113333 + tree rhs2 = gimple_assign_rhs2(stmt);
113334 + tree lhs = gimple_assign_lhs(stmt);
113335 +
113336 + if (!check_overflow)
113337 + return create_assign(visited, stmt, lhs, AFTER_STMT);
113338 +
113339 + if (change_rhs == NULL_TREE)
113340 + return create_assign(visited, stmt, lhs, AFTER_STMT);
113341 +
113342 + if (new_rhs2 == NULL_TREE) {
113343 + orig_rhs = rhs1;
113344 + gimple_assign_set_rhs = &gimple_assign_set_rhs1;
113345 + } else {
113346 + orig_rhs = rhs2;
113347 + gimple_assign_set_rhs = &gimple_assign_set_rhs2;
113348 + }
113349 +
113350 + check_size_overflow(caller_node, stmt, TREE_TYPE(change_rhs), change_rhs, orig_rhs, BEFORE_STMT);
113351 +
113352 + new_rhs = change_assign_rhs(visited, stmt, orig_rhs, change_rhs);
113353 + gimple_assign_set_rhs(stmt, new_rhs);
113354 + update_stmt(stmt);
113355 +
113356 + return create_assign(visited, stmt, lhs, AFTER_STMT);
113357 +}
113358 +
113359 +static bool is_subtraction_special(struct visited *visited, const_gimple stmt)
113360 +{
113361 + gimple rhs1_def_stmt, rhs2_def_stmt;
113362 + const_tree rhs1_def_stmt_rhs1, rhs2_def_stmt_rhs1, rhs1_def_stmt_lhs, rhs2_def_stmt_lhs;
113363 + enum machine_mode rhs1_def_stmt_rhs1_mode, rhs2_def_stmt_rhs1_mode, rhs1_def_stmt_lhs_mode, rhs2_def_stmt_lhs_mode;
113364 + const_tree rhs1 = gimple_assign_rhs1(stmt);
113365 + const_tree rhs2 = gimple_assign_rhs2(stmt);
113366 +
113367 + if (is_gimple_constant(rhs1) || is_gimple_constant(rhs2))
113368 + return false;
113369 +
113370 + gcc_assert(TREE_CODE(rhs1) == SSA_NAME && TREE_CODE(rhs2) == SSA_NAME);
113371 +
113372 + if (gimple_assign_rhs_code(stmt) != MINUS_EXPR)
113373 + return false;
113374 +
113375 + rhs1_def_stmt = get_def_stmt(rhs1);
113376 + rhs2_def_stmt = get_def_stmt(rhs2);
113377 + if (!gimple_assign_cast_p(rhs1_def_stmt) || !gimple_assign_cast_p(rhs2_def_stmt))
113378 + return false;
113379 +
113380 + rhs1_def_stmt_rhs1 = gimple_assign_rhs1(rhs1_def_stmt);
113381 + rhs2_def_stmt_rhs1 = gimple_assign_rhs1(rhs2_def_stmt);
113382 + rhs1_def_stmt_lhs = gimple_assign_lhs(rhs1_def_stmt);
113383 + rhs2_def_stmt_lhs = gimple_assign_lhs(rhs2_def_stmt);
113384 + rhs1_def_stmt_rhs1_mode = TYPE_MODE(TREE_TYPE(rhs1_def_stmt_rhs1));
113385 + rhs2_def_stmt_rhs1_mode = TYPE_MODE(TREE_TYPE(rhs2_def_stmt_rhs1));
113386 + rhs1_def_stmt_lhs_mode = TYPE_MODE(TREE_TYPE(rhs1_def_stmt_lhs));
113387 + rhs2_def_stmt_lhs_mode = TYPE_MODE(TREE_TYPE(rhs2_def_stmt_lhs));
113388 + if (GET_MODE_BITSIZE(rhs1_def_stmt_rhs1_mode) <= GET_MODE_BITSIZE(rhs1_def_stmt_lhs_mode))
113389 + return false;
113390 + if (GET_MODE_BITSIZE(rhs2_def_stmt_rhs1_mode) <= GET_MODE_BITSIZE(rhs2_def_stmt_lhs_mode))
113391 + return false;
113392 +
113393 + pointer_set_insert(visited->no_cast_check, rhs1_def_stmt);
113394 + pointer_set_insert(visited->no_cast_check, rhs2_def_stmt);
113395 + return true;
113396 +}
113397 +
113398 +static gimple create_binary_assign(struct visited *visited, enum tree_code code, gimple stmt, tree rhs1, tree rhs2)
113399 +{
113400 + gimple assign;
113401 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
113402 + tree type = TREE_TYPE(rhs1);
113403 + tree lhs = create_new_var(type);
113404 +
113405 + gcc_assert(types_compatible_p(type, TREE_TYPE(rhs2)));
113406 + assign = gimple_build_assign_with_ops(code, lhs, rhs1, rhs2);
113407 + gimple_assign_set_lhs(assign, make_ssa_name(lhs, assign));
113408 +
113409 + gsi_insert_before(&gsi, assign, GSI_NEW_STMT);
113410 + update_stmt(assign);
113411 + pointer_set_insert(visited->my_stmts, assign);
113412 + return assign;
113413 +}
113414 +
113415 +static tree cast_to_TI_type(struct visited *visited, gimple stmt, tree node)
113416 +{
113417 + gimple_stmt_iterator gsi;
113418 + gimple cast_stmt;
113419 + tree type = TREE_TYPE(node);
113420 +
113421 + if (types_compatible_p(type, intTI_type_node))
113422 + return node;
113423 +
113424 + gsi = gsi_for_stmt(stmt);
113425 + cast_stmt = build_cast_stmt(visited, intTI_type_node, node, CREATE_NEW_VAR, &gsi, BEFORE_STMT, false);
113426 + pointer_set_insert(visited->my_stmts, cast_stmt);
113427 + return gimple_assign_lhs(cast_stmt);
113428 +}
113429 +
113430 +static tree get_def_stmt_rhs(struct visited *visited, const_tree var)
113431 +{
113432 + tree rhs1, def_stmt_rhs1;
113433 + gimple rhs1_def_stmt, def_stmt_rhs1_def_stmt, def_stmt;
113434 +
113435 + def_stmt = get_def_stmt(var);
113436 + if (!gimple_assign_cast_p(def_stmt))
113437 + return NULL_TREE;
113438 + gcc_assert(gimple_code(def_stmt) != GIMPLE_NOP && pointer_set_contains(visited->my_stmts, def_stmt) && gimple_assign_cast_p(def_stmt));
113439 +
113440 + rhs1 = gimple_assign_rhs1(def_stmt);
113441 + rhs1_def_stmt = get_def_stmt(rhs1);
113442 + if (!gimple_assign_cast_p(rhs1_def_stmt))
113443 + return rhs1;
113444 +
113445 + def_stmt_rhs1 = gimple_assign_rhs1(rhs1_def_stmt);
113446 + def_stmt_rhs1_def_stmt = get_def_stmt(def_stmt_rhs1);
113447 +
113448 + switch (gimple_code(def_stmt_rhs1_def_stmt)) {
113449 + case GIMPLE_CALL:
113450 + case GIMPLE_NOP:
113451 + case GIMPLE_ASM:
113452 + case GIMPLE_PHI:
113453 + return def_stmt_rhs1;
113454 + case GIMPLE_ASSIGN:
113455 + return rhs1;
113456 + default:
113457 + debug_gimple_stmt(def_stmt_rhs1_def_stmt);
113458 + gcc_unreachable();
113459 + }
113460 +}
113461 +
113462 +tree handle_integer_truncation(struct visited *visited, struct cgraph_node *caller_node, const_tree lhs)
113463 +{
113464 + tree new_rhs1, new_rhs2;
113465 + tree new_rhs1_def_stmt_rhs1, new_rhs2_def_stmt_rhs1, new_lhs;
113466 + gimple assign, stmt = get_def_stmt(lhs);
113467 + tree rhs1 = gimple_assign_rhs1(stmt);
113468 + tree rhs2 = gimple_assign_rhs2(stmt);
113469 +
113470 + if (!is_subtraction_special(visited, stmt))
113471 + return NULL_TREE;
113472 +
113473 + new_rhs1 = expand(visited, caller_node, rhs1);
113474 + new_rhs2 = expand(visited, caller_node, rhs2);
113475 +
113476 + new_rhs1_def_stmt_rhs1 = get_def_stmt_rhs(visited, new_rhs1);
113477 + new_rhs2_def_stmt_rhs1 = get_def_stmt_rhs(visited, new_rhs2);
113478 +
113479 + if (new_rhs1_def_stmt_rhs1 == NULL_TREE || new_rhs2_def_stmt_rhs1 == NULL_TREE)
113480 + return NULL_TREE;
113481 +
113482 + if (!types_compatible_p(TREE_TYPE(new_rhs1_def_stmt_rhs1), TREE_TYPE(new_rhs2_def_stmt_rhs1))) {
113483 + new_rhs1_def_stmt_rhs1 = cast_to_TI_type(visited, stmt, new_rhs1_def_stmt_rhs1);
113484 + new_rhs2_def_stmt_rhs1 = cast_to_TI_type(visited, stmt, new_rhs2_def_stmt_rhs1);
113485 + }
113486 +
113487 + assign = create_binary_assign(visited, MINUS_EXPR, stmt, new_rhs1_def_stmt_rhs1, new_rhs2_def_stmt_rhs1);
113488 + new_lhs = gimple_assign_lhs(assign);
113489 + check_size_overflow(caller_node, assign, TREE_TYPE(new_lhs), new_lhs, rhs1, AFTER_STMT);
113490 +
113491 + return dup_assign(visited, stmt, lhs, new_rhs1, new_rhs2, NULL_TREE);
113492 +}
113493 +
113494 +bool is_a_neg_overflow(const_gimple stmt, const_tree rhs)
113495 +{
113496 + const_gimple def_stmt;
113497 +
113498 + if (TREE_CODE(rhs) != SSA_NAME)
113499 + return false;
113500 +
113501 + if (gimple_assign_rhs_code(stmt) != PLUS_EXPR)
113502 + return false;
113503 +
113504 + def_stmt = get_def_stmt(rhs);
113505 + if (!is_gimple_assign(def_stmt) || gimple_assign_rhs_code(def_stmt) != BIT_NOT_EXPR)
113506 + return false;
113507 +
113508 + return true;
113509 +}
113510 +
113511 +/* e.g., drivers/acpi/acpica/utids.c acpi_ut_execute_CID()
113512 + * ((count - 1) * sizeof(struct acpi_pnp_dee_id_list) -> (count + fffffff) * 16
113513 + * fffffff * 16 > signed max -> truncate
113514 + */
113515 +static bool look_for_mult_and_add(const_gimple stmt)
113516 +{
113517 + const_tree res;
113518 + tree rhs1, rhs2, def_rhs1, def_rhs2, const_rhs, def_const_rhs;
113519 + const_gimple def_stmt;
113520 +
113521 + if (!stmt || gimple_code(stmt) == GIMPLE_NOP)
113522 + return false;
113523 + if (!is_gimple_assign(stmt))
113524 + return false;
113525 + if (gimple_assign_rhs_code(stmt) != MULT_EXPR)
113526 + return false;
113527 +
113528 + rhs1 = gimple_assign_rhs1(stmt);
113529 + rhs2 = gimple_assign_rhs2(stmt);
113530 + if (is_gimple_constant(rhs1)) {
113531 + const_rhs = rhs1;
113532 + def_stmt = get_def_stmt(rhs2);
113533 + } else if (is_gimple_constant(rhs2)) {
113534 + const_rhs = rhs2;
113535 + def_stmt = get_def_stmt(rhs1);
113536 + } else
113537 + return false;
113538 +
113539 + if (gimple_assign_rhs_code(def_stmt) != PLUS_EXPR && gimple_assign_rhs_code(def_stmt) != MINUS_EXPR)
113540 + return false;
113541 +
113542 + def_rhs1 = gimple_assign_rhs1(def_stmt);
113543 + def_rhs2 = gimple_assign_rhs2(def_stmt);
113544 + if (is_gimple_constant(def_rhs1))
113545 + def_const_rhs = def_rhs1;
113546 + else if (is_gimple_constant(def_rhs2))
113547 + def_const_rhs = def_rhs2;
113548 + else
113549 + return false;
113550 +
113551 + res = fold_binary_loc(gimple_location(def_stmt), MULT_EXPR, TREE_TYPE(const_rhs), const_rhs, def_const_rhs);
113552 + if (is_lt_signed_type_max(res) && is_gt_zero(res))
113553 + return false;
113554 + return true;
113555 +}
113556 +
113557 +enum intentional_overflow_type add_mul_intentional_overflow(const_gimple stmt)
113558 +{
113559 + const_gimple def_stmt_1, def_stmt_2;
113560 + const_tree rhs1, rhs2;
113561 + bool add_mul_rhs1, add_mul_rhs2;
113562 +
113563 + rhs1 = gimple_assign_rhs1(stmt);
113564 + def_stmt_1 = get_def_stmt(rhs1);
113565 + add_mul_rhs1 = look_for_mult_and_add(def_stmt_1);
113566 +
113567 + rhs2 = gimple_assign_rhs2(stmt);
113568 + def_stmt_2 = get_def_stmt(rhs2);
113569 + add_mul_rhs2 = look_for_mult_and_add(def_stmt_2);
113570 +
113571 + if (add_mul_rhs1)
113572 + return RHS1_INTENTIONAL_OVERFLOW;
113573 + if (add_mul_rhs2)
113574 + return RHS2_INTENTIONAL_OVERFLOW;
113575 + return NO_INTENTIONAL_OVERFLOW;
113576 +}
113577 +
113578 +static gimple get_dup_stmt(struct visited *visited, gimple stmt)
113579 +{
113580 + gimple my_stmt;
113581 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
113582 +
113583 + gsi_next(&gsi);
113584 + my_stmt = gsi_stmt(gsi);
113585 +
113586 + gcc_assert(pointer_set_contains(visited->my_stmts, my_stmt));
113587 + gcc_assert(gimple_assign_rhs_code(stmt) == gimple_assign_rhs_code(my_stmt));
113588 +
113589 + return my_stmt;
113590 +}
113591 +
113592 +/* unsigned type -> unary or binary assign (rhs1 or rhs2 is constant)
113593 + * unsigned type cast to signed type, unsigned type: no more uses
113594 + * e.g., lib/vsprintf.c:simple_strtol()
113595 + * _10 = (unsigned long int) _9
113596 + * _11 = -_10;
113597 + * _12 = (long int) _11; (_11_ no more uses)
113598 + */
113599 +static bool is_call_or_cast(gimple stmt)
113600 +{
113601 + return gimple_assign_cast_p(stmt) || is_gimple_call(stmt);
113602 +}
113603 +
113604 +static bool is_unsigned_cast_or_call_def_stmt(const_tree node)
113605 +{
113606 + const_tree rhs;
113607 + gimple def_stmt;
113608 +
113609 + if (node == NULL_TREE)
113610 + return true;
113611 + if (is_gimple_constant(node))
113612 + return true;
113613 +
113614 + def_stmt = get_def_stmt(node);
113615 + if (!def_stmt)
113616 + return false;
113617 +
113618 + if (is_call_or_cast(def_stmt))
113619 + return true;
113620 +
113621 + if (!is_gimple_assign(def_stmt) || gimple_num_ops(def_stmt) != 2)
113622 + return false;
113623 + rhs = gimple_assign_rhs1(def_stmt);
113624 + def_stmt = get_def_stmt(rhs);
113625 + if (!def_stmt)
113626 + return false;
113627 + return is_call_or_cast(def_stmt);
113628 +}
113629 +
113630 +void unsigned_signed_cast_intentional_overflow(struct visited *visited, gimple stmt)
113631 +{
113632 + unsigned int use_num;
113633 + gimple so_stmt;
113634 + const_gimple def_stmt;
113635 + const_tree rhs1, rhs2;
113636 + tree rhs = gimple_assign_rhs1(stmt);
113637 + tree lhs_type = TREE_TYPE(gimple_assign_lhs(stmt));
113638 + const_tree rhs_type = TREE_TYPE(rhs);
113639 +
113640 + if (!(TYPE_UNSIGNED(rhs_type) && !TYPE_UNSIGNED(lhs_type)))
113641 + return;
113642 + if (GET_MODE_BITSIZE(TYPE_MODE(rhs_type)) != GET_MODE_BITSIZE(TYPE_MODE(lhs_type)))
113643 + return;
113644 + use_num = uses_num(rhs);
113645 + if (use_num != 1)
113646 + return;
113647 +
113648 + def_stmt = get_def_stmt(rhs);
113649 + if (!def_stmt)
113650 + return;
113651 + if (!is_gimple_assign(def_stmt))
113652 + return;
113653 +
113654 + rhs1 = gimple_assign_rhs1(def_stmt);
113655 + if (!is_unsigned_cast_or_call_def_stmt(rhs1))
113656 + return;
113657 +
113658 + rhs2 = gimple_assign_rhs2(def_stmt);
113659 + if (!is_unsigned_cast_or_call_def_stmt(rhs2))
113660 + return;
113661 + if (gimple_num_ops(def_stmt) == 3 && !is_gimple_constant(rhs1) && !is_gimple_constant(rhs2))
113662 + return;
113663 +
113664 + so_stmt = get_dup_stmt(visited, stmt);
113665 + create_up_and_down_cast(visited, so_stmt, lhs_type, gimple_assign_rhs1(so_stmt));
113666 +}
113667 +
113668 diff --git a/tools/gcc/size_overflow_plugin/misc.c b/tools/gcc/size_overflow_plugin/misc.c
113669 new file mode 100644
113670 index 0000000..4bddad2
113671 --- /dev/null
113672 +++ b/tools/gcc/size_overflow_plugin/misc.c
113673 @@ -0,0 +1,203 @@
113674 +/*
113675 + * Copyright 2011-2014 by Emese Revfy <re.emese@gmail.com>
113676 + * Licensed under the GPL v2, or (at your option) v3
113677 + *
113678 + * Homepage:
113679 + * http://www.grsecurity.net/~ephox/overflow_plugin/
113680 + *
113681 + * Documentation:
113682 + * http://forums.grsecurity.net/viewtopic.php?f=7&t=3043
113683 + *
113684 + * This plugin recomputes expressions of function arguments marked by a size_overflow attribute
113685 + * with double integer precision (DImode/TImode for 32/64 bit integer types).
113686 + * The recomputed argument is checked against TYPE_MAX and an event is logged on overflow and the triggering process is killed.
113687 + *
113688 + * Usage:
113689 + * $ make
113690 + * $ make run
113691 + */
113692 +
113693 +#include "gcc-common.h"
113694 +#include "size_overflow.h"
113695 +
113696 +void set_current_function_decl(tree fndecl)
113697 +{
113698 + gcc_assert(fndecl != NULL_TREE);
113699 +
113700 + push_cfun(DECL_STRUCT_FUNCTION(fndecl));
113701 + calculate_dominance_info(CDI_DOMINATORS);
113702 + current_function_decl = fndecl;
113703 +}
113704 +
113705 +void unset_current_function_decl(void)
113706 +{
113707 + free_dominance_info(CDI_DOMINATORS);
113708 + pop_cfun();
113709 + current_function_decl = NULL_TREE;
113710 +}
113711 +
113712 +static bool is_bool(const_tree node)
113713 +{
113714 + const_tree type;
113715 +
113716 + if (node == NULL_TREE)
113717 + return false;
113718 +
113719 + type = TREE_TYPE(node);
113720 + if (!INTEGRAL_TYPE_P(type))
113721 + return false;
113722 + if (TREE_CODE(type) == BOOLEAN_TYPE)
113723 + return true;
113724 + if (TYPE_PRECISION(type) == 1)
113725 + return true;
113726 + return false;
113727 +}
113728 +
113729 +bool skip_types(const_tree var)
113730 +{
113731 + tree type;
113732 + enum tree_code code;
113733 +
113734 + if (is_gimple_constant(var))
113735 + return true;
113736 +
113737 + switch (TREE_CODE(var)) {
113738 + case ADDR_EXPR:
113739 +#if BUILDING_GCC_VERSION >= 4006
113740 + case MEM_REF:
113741 +#endif
113742 + case ARRAY_REF:
113743 + case BIT_FIELD_REF:
113744 + case INDIRECT_REF:
113745 + case TARGET_MEM_REF:
113746 + case COMPONENT_REF:
113747 + case VAR_DECL:
113748 + case VIEW_CONVERT_EXPR:
113749 + return true;
113750 + default:
113751 + break;
113752 + }
113753 +
113754 + code = TREE_CODE(var);
113755 + gcc_assert(code == SSA_NAME || code == PARM_DECL);
113756 +
113757 + type = TREE_TYPE(var);
113758 + switch (TREE_CODE(type)) {
113759 + case INTEGER_TYPE:
113760 + case ENUMERAL_TYPE:
113761 + return false;
113762 + case BOOLEAN_TYPE:
113763 + return is_bool(var);
113764 + default:
113765 + return true;
113766 + }
113767 +}
113768 +
113769 +gimple get_def_stmt(const_tree node)
113770 +{
113771 + gcc_assert(node != NULL_TREE);
113772 +
113773 + if (skip_types(node))
113774 + return NULL;
113775 +
113776 + if (TREE_CODE(node) != SSA_NAME)
113777 + return NULL;
113778 + return SSA_NAME_DEF_STMT(node);
113779 +}
113780 +
113781 +tree create_new_var(tree type)
113782 +{
113783 + tree new_var = create_tmp_var(type, "cicus");
113784 +
113785 + add_referenced_var(new_var);
113786 + return new_var;
113787 +}
113788 +
113789 +static bool skip_cast(tree dst_type, const_tree rhs, bool force)
113790 +{
113791 + const_gimple def_stmt = get_def_stmt(rhs);
113792 +
113793 + if (force)
113794 + return false;
113795 +
113796 + if (is_gimple_constant(rhs))
113797 + return false;
113798 +
113799 + if (!def_stmt || gimple_code(def_stmt) == GIMPLE_NOP)
113800 + return false;
113801 +
113802 + if (!types_compatible_p(dst_type, TREE_TYPE(rhs)))
113803 + return false;
113804 +
113805 + // DI type can be on 32 bit (from create_assign) but overflow type stays DI
113806 + if (LONG_TYPE_SIZE == GET_MODE_BITSIZE(SImode))
113807 + return false;
113808 +
113809 + return true;
113810 +}
113811 +
113812 +tree cast_a_tree(tree type, tree var)
113813 +{
113814 + gcc_assert(type != NULL_TREE);
113815 + gcc_assert(var != NULL_TREE);
113816 + gcc_assert(fold_convertible_p(type, var));
113817 +
113818 + return fold_convert(type, var);
113819 +}
113820 +
113821 +gimple build_cast_stmt(struct visited *visited, tree dst_type, tree rhs, tree lhs, gimple_stmt_iterator *gsi, bool before, bool force)
113822 +{
113823 + gimple assign, def_stmt;
113824 +
113825 + gcc_assert(dst_type != NULL_TREE && rhs != NULL_TREE);
113826 + gcc_assert(!is_gimple_constant(rhs));
113827 + if (gsi_end_p(*gsi) && before == AFTER_STMT)
113828 + gcc_unreachable();
113829 +
113830 + def_stmt = get_def_stmt(rhs);
113831 + if (def_stmt && gimple_code(def_stmt) != GIMPLE_NOP && skip_cast(dst_type, rhs, force) && pointer_set_contains(visited->my_stmts, def_stmt))
113832 + return def_stmt;
113833 +
113834 + if (lhs == CREATE_NEW_VAR)
113835 + lhs = create_new_var(dst_type);
113836 +
113837 + assign = gimple_build_assign(lhs, cast_a_tree(dst_type, rhs));
113838 +
113839 + if (!gsi_end_p(*gsi)) {
113840 + location_t loc = gimple_location(gsi_stmt(*gsi));
113841 + gimple_set_location(assign, loc);
113842 + }
113843 +
113844 + gimple_assign_set_lhs(assign, make_ssa_name(lhs, assign));
113845 +
113846 + if (before)
113847 + gsi_insert_before(gsi, assign, GSI_NEW_STMT);
113848 + else
113849 + gsi_insert_after(gsi, assign, GSI_NEW_STMT);
113850 + update_stmt(assign);
113851 + return assign;
113852 +}
113853 +
113854 +bool is_size_overflow_type(const_tree var)
113855 +{
113856 + const char *name;
113857 + const_tree type_name, type;
113858 +
113859 + if (var == NULL_TREE)
113860 + return false;
113861 +
113862 + type = TREE_TYPE(var);
113863 + type_name = TYPE_NAME(type);
113864 + if (type_name == NULL_TREE)
113865 + return false;
113866 +
113867 + if (DECL_P(type_name))
113868 + name = DECL_NAME_POINTER(type_name);
113869 + else
113870 + name = IDENTIFIER_POINTER(type_name);
113871 +
113872 + if (!strncmp(name, "size_overflow_type", 18))
113873 + return true;
113874 + return false;
113875 +}
113876 +
113877 diff --git a/tools/gcc/size_overflow_plugin/remove_unnecessary_dup.c b/tools/gcc/size_overflow_plugin/remove_unnecessary_dup.c
113878 new file mode 100644
113879 index 0000000..7c9e6d1
113880 --- /dev/null
113881 +++ b/tools/gcc/size_overflow_plugin/remove_unnecessary_dup.c
113882 @@ -0,0 +1,138 @@
113883 +/*
113884 + * Copyright 2011-2014 by Emese Revfy <re.emese@gmail.com>
113885 + * Licensed under the GPL v2, or (at your option) v3
113886 + *
113887 + * Homepage:
113888 + * http://www.grsecurity.net/~ephox/overflow_plugin/
113889 + *
113890 + * Documentation:
113891 + * http://forums.grsecurity.net/viewtopic.php?f=7&t=3043
113892 + *
113893 + * This plugin recomputes expressions of function arguments marked by a size_overflow attribute
113894 + * with double integer precision (DImode/TImode for 32/64 bit integer types).
113895 + * The recomputed argument is checked against TYPE_MAX and an event is logged on overflow and the triggering process is killed.
113896 + *
113897 + * Usage:
113898 + * $ make
113899 + * $ make run
113900 + */
113901 +
113902 +#include "gcc-common.h"
113903 +#include "size_overflow.h"
113904 +
113905 +bool skip_expr_on_double_type(const_gimple stmt)
113906 +{
113907 + enum tree_code code = gimple_assign_rhs_code(stmt);
113908 +
113909 + switch (code) {
113910 + case RSHIFT_EXPR:
113911 + case TRUNC_DIV_EXPR:
113912 + case CEIL_DIV_EXPR:
113913 + case FLOOR_DIV_EXPR:
113914 + case ROUND_DIV_EXPR:
113915 + case EXACT_DIV_EXPR:
113916 + case RDIV_EXPR:
113917 + case TRUNC_MOD_EXPR:
113918 + case CEIL_MOD_EXPR:
113919 + case FLOOR_MOD_EXPR:
113920 + case ROUND_MOD_EXPR:
113921 + return true;
113922 + default:
113923 + return false;
113924 + }
113925 +}
113926 +
113927 +void create_up_and_down_cast(struct visited *visited, gimple use_stmt, tree orig_type, tree rhs)
113928 +{
113929 + const_tree orig_rhs1;
113930 + tree down_lhs, new_lhs, dup_type = TREE_TYPE(rhs);
113931 + gimple down_cast, up_cast;
113932 + gimple_stmt_iterator gsi = gsi_for_stmt(use_stmt);
113933 +
113934 + down_cast = build_cast_stmt(visited, orig_type, rhs, CREATE_NEW_VAR, &gsi, BEFORE_STMT, false);
113935 + down_lhs = gimple_assign_lhs(down_cast);
113936 +
113937 + gsi = gsi_for_stmt(use_stmt);
113938 + up_cast = build_cast_stmt(visited, dup_type, down_lhs, CREATE_NEW_VAR, &gsi, BEFORE_STMT, false);
113939 + new_lhs = gimple_assign_lhs(up_cast);
113940 +
113941 + orig_rhs1 = gimple_assign_rhs1(use_stmt);
113942 + if (operand_equal_p(orig_rhs1, rhs, 0))
113943 + gimple_assign_set_rhs1(use_stmt, new_lhs);
113944 + else
113945 + gimple_assign_set_rhs2(use_stmt, new_lhs);
113946 + update_stmt(use_stmt);
113947 +
113948 + pointer_set_insert(visited->my_stmts, up_cast);
113949 + pointer_set_insert(visited->my_stmts, down_cast);
113950 + pointer_set_insert(visited->skip_expr_casts, up_cast);
113951 + pointer_set_insert(visited->skip_expr_casts, down_cast);
113952 +}
113953 +
113954 +static tree get_proper_unsigned_half_type(const_tree node)
113955 +{
113956 + tree new_type, type;
113957 +
113958 + gcc_assert(is_size_overflow_type(node));
113959 +
113960 + type = TREE_TYPE(node);
113961 + switch (TYPE_MODE(type)) {
113962 + case HImode:
113963 + new_type = unsigned_intQI_type_node;
113964 + break;
113965 + case SImode:
113966 + new_type = unsigned_intHI_type_node;
113967 + break;
113968 + case DImode:
113969 + new_type = unsigned_intSI_type_node;
113970 + break;
113971 + case TImode:
113972 + new_type = unsigned_intDI_type_node;
113973 + break;
113974 + default:
113975 + gcc_unreachable();
113976 + }
113977 +
113978 + if (TYPE_QUALS(type) != 0)
113979 + return build_qualified_type(new_type, TYPE_QUALS(type));
113980 + return new_type;
113981 +}
113982 +
113983 +static void insert_cast_rhs(struct visited *visited, gimple stmt, tree rhs)
113984 +{
113985 + tree type;
113986 +
113987 + if (rhs == NULL_TREE)
113988 + return;
113989 + if (!is_size_overflow_type(rhs))
113990 + return;
113991 +
113992 + type = get_proper_unsigned_half_type(rhs);
113993 + if (is_gimple_constant(rhs))
113994 + return;
113995 + create_up_and_down_cast(visited, stmt, type, rhs);
113996 +}
113997 +
113998 +static void insert_cast(struct visited *visited, gimple stmt, tree rhs)
113999 +{
114000 + if (LONG_TYPE_SIZE == GET_MODE_BITSIZE(SImode) && !is_size_overflow_type(rhs))
114001 + return;
114002 + gcc_assert(is_size_overflow_type(rhs));
114003 + insert_cast_rhs(visited, stmt, rhs);
114004 +}
114005 +
114006 +void insert_cast_expr(struct visited *visited, gimple stmt, enum intentional_overflow_type type)
114007 +{
114008 + tree rhs1, rhs2;
114009 +
114010 + if (type == NO_INTENTIONAL_OVERFLOW || type == RHS1_INTENTIONAL_OVERFLOW) {
114011 + rhs1 = gimple_assign_rhs1(stmt);
114012 + insert_cast(visited, stmt, rhs1);
114013 + }
114014 +
114015 + if (type == NO_INTENTIONAL_OVERFLOW || type == RHS2_INTENTIONAL_OVERFLOW) {
114016 + rhs2 = gimple_assign_rhs2(stmt);
114017 + insert_cast(visited, stmt, rhs2);
114018 + }
114019 +}
114020 +
114021 diff --git a/tools/gcc/size_overflow_plugin/size_overflow.h b/tools/gcc/size_overflow_plugin/size_overflow.h
114022 new file mode 100644
114023 index 0000000..e5b4e50
114024 --- /dev/null
114025 +++ b/tools/gcc/size_overflow_plugin/size_overflow.h
114026 @@ -0,0 +1,127 @@
114027 +#ifndef SIZE_OVERFLOW_H
114028 +#define SIZE_OVERFLOW_H
114029 +
114030 +#define CREATE_NEW_VAR NULL_TREE
114031 +#define CANNOT_FIND_ARG 32
114032 +#define MAX_PARAM 31
114033 +#define BEFORE_STMT true
114034 +#define AFTER_STMT false
114035 +
114036 +#define TURN_OFF_ASM_STR "# size_overflow MARK_TURN_OFF "
114037 +#define YES_ASM_STR "# size_overflow MARK_YES "
114038 +#define OK_ASM_STR "# size_overflow "
114039 +
114040 +enum mark {
114041 + MARK_NO, MARK_YES, MARK_NOT_INTENTIONAL, MARK_TURN_OFF
114042 +};
114043 +
114044 +enum intentional_overflow_type {
114045 + NO_INTENTIONAL_OVERFLOW, RHS1_INTENTIONAL_OVERFLOW, RHS2_INTENTIONAL_OVERFLOW
114046 +};
114047 +
114048 +struct visited {
114049 + struct pointer_set_t *stmts;
114050 + struct pointer_set_t *my_stmts;
114051 + struct pointer_set_t *skip_expr_casts;
114052 + struct pointer_set_t *no_cast_check;
114053 +};
114054 +
114055 +// size_overflow_plugin.c
114056 +extern tree report_size_overflow_decl;
114057 +extern tree size_overflow_type_HI;
114058 +extern tree size_overflow_type_SI;
114059 +extern tree size_overflow_type_DI;
114060 +extern tree size_overflow_type_TI;
114061 +
114062 +
114063 +// size_overflow_plugin_hash.c
114064 +struct size_overflow_hash {
114065 + const struct size_overflow_hash * const next;
114066 + const char * const name;
114067 + const unsigned int param;
114068 +};
114069 +
114070 +struct interesting_node {
114071 + struct interesting_node *next;
114072 + gimple first_stmt;
114073 + const_tree fndecl;
114074 + tree node;
114075 +#if BUILDING_GCC_VERSION <= 4007
114076 + VEC(tree, gc) *last_nodes;
114077 +#else
114078 + vec<tree, va_gc> *last_nodes;
114079 +#endif
114080 + unsigned int num;
114081 + enum mark intentional_attr_decl;
114082 + enum mark intentional_attr_cur_fndecl;
114083 + gimple intentional_mark_from_gimple;
114084 +};
114085 +
114086 +extern bool is_size_overflow_asm(const_gimple stmt);
114087 +extern unsigned int get_function_num(const_tree node, const_tree orig_fndecl);
114088 +extern unsigned int get_correct_arg_count(unsigned int argnum, const_tree fndecl);
114089 +extern bool is_missing_function(const_tree orig_fndecl, unsigned int num);
114090 +extern bool is_a_return_check(const_tree node);
114091 +extern const struct size_overflow_hash *get_function_hash(const_tree fndecl);
114092 +extern unsigned int find_arg_number_tree(const_tree arg, const_tree func);
114093 +
114094 +
114095 +// size_overflow_debug.c
114096 +extern struct opt_pass *make_dump_pass(void);
114097 +
114098 +
114099 +// intentional_overflow.c
114100 +extern enum mark get_intentional_attr_type(const_tree node);
114101 +extern bool is_size_overflow_intentional_asm_yes(const_gimple stmt);
114102 +extern bool is_size_overflow_intentional_asm_turn_off(const_gimple stmt);
114103 +extern bool is_end_intentional_intentional_attr(const_tree decl, unsigned int argnum);
114104 +extern bool is_yes_intentional_attr(const_tree decl, unsigned int argnum);
114105 +extern bool is_turn_off_intentional_attr(const_tree decl);
114106 +extern void print_missing_intentional(enum mark callee_attr, enum mark caller_attr, const_tree decl, unsigned int argnum);
114107 +extern void check_intentional_attribute_ipa(struct interesting_node *cur_node);
114108 +extern bool is_a_cast_and_const_overflow(const_tree no_const_rhs);
114109 +extern bool is_const_plus_unsigned_signed_truncation(const_tree lhs);
114110 +extern bool is_a_constant_overflow(const_gimple stmt, const_tree rhs);
114111 +extern tree handle_intentional_overflow(struct visited *visited, struct cgraph_node *caller_node, bool check_overflow, gimple stmt, tree change_rhs, tree new_rhs2);
114112 +extern tree handle_integer_truncation(struct visited *visited, struct cgraph_node *caller_node, const_tree lhs);
114113 +extern bool is_a_neg_overflow(const_gimple stmt, const_tree rhs);
114114 +extern enum intentional_overflow_type add_mul_intentional_overflow(const_gimple def_stmt);
114115 +extern void unsigned_signed_cast_intentional_overflow(struct visited *visited, gimple stmt);
114116 +
114117 +
114118 +// insert_size_overflow_check_ipa.c
114119 +extern unsigned int search_function(void);
114120 +extern unsigned int call_count;
114121 +extern struct opt_pass *make_insert_size_overflow_check(void);
114122 +extern const_tree get_interesting_orig_fndecl(const_gimple stmt, unsigned int argnum);
114123 +
114124 +
114125 +// insert_size_overflow_asm.c
114126 +extern struct opt_pass *make_insert_size_overflow_asm_pass(void);
114127 +
114128 +
114129 +// misc.c
114130 +extern void set_current_function_decl(tree fndecl);
114131 +extern void unset_current_function_decl(void);
114132 +extern gimple get_def_stmt(const_tree node);
114133 +extern tree create_new_var(tree type);
114134 +extern gimple build_cast_stmt(struct visited *visited, tree dst_type, tree rhs, tree lhs, gimple_stmt_iterator *gsi, bool before, bool force);
114135 +extern bool skip_types(const_tree var);
114136 +extern tree cast_a_tree(tree type, tree var);
114137 +extern bool is_size_overflow_type(const_tree var);
114138 +
114139 +
114140 +// insert_size_overflow_check_core.c
114141 +extern tree expand(struct visited *visited, struct cgraph_node *caller_node, tree lhs);
114142 +extern void check_size_overflow(struct cgraph_node *caller_node, gimple stmt, tree size_overflow_type, tree cast_rhs, tree rhs, bool before);
114143 +extern tree dup_assign(struct visited *visited, gimple oldstmt, const_tree node, tree rhs1, tree rhs2, tree __unused rhs3);
114144 +extern tree create_assign(struct visited *visited, gimple oldstmt, tree rhs1, bool before);
114145 +
114146 +
114147 +// remove_unnecessary_dup.c
114148 +extern struct opt_pass *make_remove_unnecessary_dup_pass(void);
114149 +extern void insert_cast_expr(struct visited *visited, gimple stmt, enum intentional_overflow_type type);
114150 +extern bool skip_expr_on_double_type(const_gimple stmt);
114151 +extern void create_up_and_down_cast(struct visited *visited, gimple use_stmt, tree orig_type, tree rhs);
114152 +
114153 +#endif
114154 diff --git a/tools/gcc/size_overflow_plugin/size_overflow_debug.c b/tools/gcc/size_overflow_plugin/size_overflow_debug.c
114155 new file mode 100644
114156 index 0000000..4378111
114157 --- /dev/null
114158 +++ b/tools/gcc/size_overflow_plugin/size_overflow_debug.c
114159 @@ -0,0 +1,116 @@
114160 +/*
114161 + * Copyright 2011-2014 by Emese Revfy <re.emese@gmail.com>
114162 + * Licensed under the GPL v2, or (at your option) v3
114163 + *
114164 + * Homepage:
114165 + * http://www.grsecurity.net/~ephox/overflow_plugin/
114166 + *
114167 + * Documentation:
114168 + * http://forums.grsecurity.net/viewtopic.php?f=7&t=3043
114169 + *
114170 + * This plugin recomputes expressions of function arguments marked by a size_overflow attribute
114171 + * with double integer precision (DImode/TImode for 32/64 bit integer types).
114172 + * The recomputed argument is checked against TYPE_MAX and an event is logged on overflow and the triggering process is killed.
114173 + *
114174 + * Usage:
114175 + * $ make
114176 + * $ make run
114177 + */
114178 +
114179 +#include "gcc-common.h"
114180 +
114181 +static unsigned int dump_functions(void)
114182 +{
114183 + struct cgraph_node *node;
114184 +
114185 + FOR_EACH_FUNCTION_WITH_GIMPLE_BODY(node) {
114186 + basic_block bb;
114187 +
114188 + push_cfun(DECL_STRUCT_FUNCTION(NODE_DECL(node)));
114189 + current_function_decl = NODE_DECL(node);
114190 +
114191 + fprintf(stderr, "-----------------------------------------\n%s\n-----------------------------------------\n", DECL_NAME_POINTER(current_function_decl));
114192 +
114193 + FOR_ALL_BB_FN(bb, cfun) {
114194 + gimple_stmt_iterator si;
114195 +
114196 + fprintf(stderr, "<bb %u>:\n", bb->index);
114197 + for (si = gsi_start_phis(bb); !gsi_end_p(si); gsi_next(&si))
114198 + debug_gimple_stmt(gsi_stmt(si));
114199 + for (si = gsi_start_bb(bb); !gsi_end_p(si); gsi_next(&si))
114200 + debug_gimple_stmt(gsi_stmt(si));
114201 + fprintf(stderr, "\n");
114202 + }
114203 +
114204 + fprintf(stderr, "-------------------------------------------------------------------------\n");
114205 +
114206 + pop_cfun();
114207 + current_function_decl = NULL_TREE;
114208 + }
114209 +
114210 + fprintf(stderr, "###############################################################################\n");
114211 +
114212 + return 0;
114213 +}
114214 +
114215 +#if BUILDING_GCC_VERSION >= 4009
114216 +static const struct pass_data dump_pass_data = {
114217 +#else
114218 +static struct ipa_opt_pass_d dump_pass = {
114219 + .pass = {
114220 +#endif
114221 + .type = SIMPLE_IPA_PASS,
114222 + .name = "dump",
114223 +#if BUILDING_GCC_VERSION >= 4008
114224 + .optinfo_flags = OPTGROUP_NONE,
114225 +#endif
114226 +#if BUILDING_GCC_VERSION >= 4009
114227 + .has_gate = false,
114228 + .has_execute = true,
114229 +#else
114230 + .gate = NULL,
114231 + .execute = dump_functions,
114232 + .sub = NULL,
114233 + .next = NULL,
114234 + .static_pass_number = 0,
114235 +#endif
114236 + .tv_id = TV_NONE,
114237 + .properties_required = 0,
114238 + .properties_provided = 0,
114239 + .properties_destroyed = 0,
114240 + .todo_flags_start = 0,
114241 + .todo_flags_finish = 0,
114242 +#if BUILDING_GCC_VERSION < 4009
114243 + },
114244 + .generate_summary = NULL,
114245 + .write_summary = NULL,
114246 + .read_summary = NULL,
114247 +#if BUILDING_GCC_VERSION >= 4006
114248 + .write_optimization_summary = NULL,
114249 + .read_optimization_summary = NULL,
114250 +#endif
114251 + .stmt_fixup = NULL,
114252 + .function_transform_todo_flags_start = 0,
114253 + .function_transform = NULL,
114254 + .variable_transform = NULL,
114255 +#endif
114256 +};
114257 +
114258 +#if BUILDING_GCC_VERSION >= 4009
114259 +namespace {
114260 +class dump_pass : public ipa_opt_pass_d {
114261 +public:
114262 + dump_pass() : ipa_opt_pass_d(dump_pass_data, g, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL) {}
114263 + unsigned int execute() { return dump_functions(); }
114264 +};
114265 +}
114266 +#endif
114267 +
114268 +struct opt_pass *make_dump_pass(void)
114269 +{
114270 +#if BUILDING_GCC_VERSION >= 4009
114271 + return new dump_pass();
114272 +#else
114273 + return &dump_pass.pass;
114274 +#endif
114275 +}
114276 diff --git a/tools/gcc/size_overflow_plugin/size_overflow_hash.data b/tools/gcc/size_overflow_plugin/size_overflow_hash.data
114277 new file mode 100644
114278 index 0000000..8709512
114279 --- /dev/null
114280 +++ b/tools/gcc/size_overflow_plugin/size_overflow_hash.data
114281 @@ -0,0 +1,8131 @@
114282 +intel_fake_agp_alloc_by_type_1 intel_fake_agp_alloc_by_type 1 1 NULL
114283 +ocfs2_get_refcount_tree_3 ocfs2_get_refcount_tree 0 3 NULL nohasharray
114284 +bmp085_detect_3 bmp085_detect 0 3 &ocfs2_get_refcount_tree_3
114285 +ext3_writeback_write_end_11 ext3_writeback_write_end 5 11 NULL
114286 +storvsc_connect_to_vsp_22 storvsc_connect_to_vsp 2-0 22 NULL
114287 +compat_sock_setsockopt_23 compat_sock_setsockopt 5 23 NULL
114288 +snd_hwdep_new_24 snd_hwdep_new 0 24 NULL
114289 +carl9170_alloc_27 carl9170_alloc 1 27 NULL
114290 +sel_read_policyvers_55 sel_read_policyvers 3 55 NULL nohasharray
114291 +padzero_55 padzero 1 55 &sel_read_policyvers_55
114292 +cfg80211_disconnected_57 cfg80211_disconnected 4 57 NULL
114293 +si4713_checkrev_60 si4713_checkrev 0 60 NULL
114294 +__skb_to_sgvec_72 __skb_to_sgvec 0 72 NULL
114295 +asd_request_firmware_77 asd_request_firmware 0 77 NULL
114296 +power_supply_populate_supplied_from_85 power_supply_populate_supplied_from 0 85 NULL
114297 +snd_korg1212_copy_to_92 snd_korg1212_copy_to 6 92 NULL
114298 +load_msg_95 load_msg 2 95 NULL
114299 +device_flush_iotlb_115 device_flush_iotlb 2-3 115 NULL
114300 +pci_revert_fw_address_116 pci_revert_fw_address 0 116 NULL
114301 +ipath_verbs_send_117 ipath_verbs_send 5-3 117 NULL
114302 +init_q_132 init_q 4 132 NULL
114303 +ocfs2_local_alloc_slide_window_134 ocfs2_local_alloc_slide_window 0 134 NULL
114304 +memstick_alloc_host_142 memstick_alloc_host 1 142 NULL
114305 +gfs2_glock_get_147 gfs2_glock_get 0 147 NULL
114306 +hva_to_gfn_memslot_149 hva_to_gfn_memslot 0-1 149 NULL
114307 +ping_v6_sendmsg_152 ping_v6_sendmsg 4 152 NULL
114308 +ext4_ext_get_actual_len_153 ext4_ext_get_actual_len 0 153 NULL nohasharray
114309 +tracing_trace_options_write_153 tracing_trace_options_write 3 153 &ext4_ext_get_actual_len_153
114310 +snd_opti93x_mixer_166 snd_opti93x_mixer 0 166 NULL
114311 +pci_request_selected_regions_169 pci_request_selected_regions 0 169 NULL
114312 +t4vf_get_rss_glb_config_172 t4vf_get_rss_glb_config 0 172 NULL
114313 +xfs_buf_item_get_format_189 xfs_buf_item_get_format 2 189 NULL
114314 +xfs_bmap_btalloc_192 xfs_bmap_btalloc 0 192 NULL
114315 +iscsi_session_setup_196 iscsi_session_setup 4-5 196 NULL nohasharray
114316 +remove_mpt_ok_196 remove_mpt_ok 0 196 &iscsi_session_setup_196
114317 +ll_xattr_cache_seq_write_250 ll_xattr_cache_seq_write 3 250 NULL
114318 +br_port_info_size_268 br_port_info_size 0 268 NULL
114319 +read_file_war_stats_292 read_file_war_stats 3 292 NULL
114320 +xfs_zero_last_block_298 xfs_zero_last_block 0 298 NULL
114321 +grgpio_to_irq_300 grgpio_to_irq 2 300 NULL
114322 +SYSC_connect_304 SYSC_connect 3 304 NULL
114323 +syslog_print_307 syslog_print 2 307 NULL
114324 +platform_device_add_data_310 platform_device_add_data 0 310 NULL
114325 +dn_setsockopt_314 dn_setsockopt 5 314 NULL
114326 +mlx5_core_access_reg_361 mlx5_core_access_reg 3-5 361 NULL nohasharray
114327 +if_spi_prog_main_firmware_361 if_spi_prog_main_firmware 0 361 &mlx5_core_access_reg_361
114328 +xfs_get_blocks_364 xfs_get_blocks 2 364 NULL
114329 +hw_device_state_409 hw_device_state 0 409 NULL
114330 +aio_read_events_ring_410 aio_read_events_ring 3 410 NULL nohasharray
114331 +vnic_dev_init_410 vnic_dev_init 0 410 &aio_read_events_ring_410
114332 +lbs_rdmac_read_418 lbs_rdmac_read 3 418 NULL
114333 +snd_ca0106_ptr_read_467 snd_ca0106_ptr_read 0 467 NULL
114334 +cfs_trace_set_debug_mb_usrstr_486 cfs_trace_set_debug_mb_usrstr 2 486 NULL
114335 +nvme_trans_modesel_data_488 nvme_trans_modesel_data 4 488 NULL
114336 +iwl_dbgfs_protection_mode_write_502 iwl_dbgfs_protection_mode_write 3 502 NULL
114337 +rx_rx_defrag_end_read_505 rx_rx_defrag_end_read 3 505 NULL
114338 +ocfs2_validate_meta_ecc_bhs_527 ocfs2_validate_meta_ecc_bhs 0 527 NULL
114339 +mwifiex_pcie_create_rxbd_ring_535 mwifiex_pcie_create_rxbd_ring 0 535 NULL
114340 +zlib_deflate_workspacesize_537 zlib_deflate_workspacesize 0-1-2 537 NULL
114341 +iwl_dbgfs_wowlan_sram_read_540 iwl_dbgfs_wowlan_sram_read 3 540 NULL
114342 +do_unregister_framebuffer_546 do_unregister_framebuffer 0 546 NULL
114343 +sco_sock_setsockopt_552 sco_sock_setsockopt 5 552 NULL
114344 +lpfc_nlp_state_name_556 lpfc_nlp_state_name 2 556 NULL
114345 +snd_aw2_saa7146_get_hw_ptr_playback_558 snd_aw2_saa7146_get_hw_ptr_playback 0 558 NULL
114346 +ib_device_register_sysfs_561 ib_device_register_sysfs 0 561 NULL
114347 +start_isoc_chain_565 start_isoc_chain 2 565 NULL nohasharray
114348 +dev_hard_header_565 dev_hard_header 0 565 &start_isoc_chain_565
114349 +ocfs2_refcounted_xattr_delete_need_584 ocfs2_refcounted_xattr_delete_need 0 584 NULL
114350 +fb_check_caps_585 fb_check_caps 0 585 NULL
114351 +rsxx_dma_ctrl_init_588 rsxx_dma_ctrl_init 0 588 NULL
114352 +smk_write_load_self2_591 smk_write_load_self2 3 591 NULL
114353 +btrfs_stack_file_extent_offset_607 btrfs_stack_file_extent_offset 0 607 NULL
114354 +ni_gpct_device_construct_610 ni_gpct_device_construct 5 610 NULL
114355 +fuse_request_alloc_nofs_617 fuse_request_alloc_nofs 1 617 NULL
114356 +ptlrpc_lprocfs_nrs_seq_write_621 ptlrpc_lprocfs_nrs_seq_write 3 621 NULL
114357 +viafb_dfpl_proc_write_627 viafb_dfpl_proc_write 3 627 NULL
114358 +ocfs2_num_free_extents_632 ocfs2_num_free_extents 0 632 NULL
114359 +ceph_osdc_new_request_635 ceph_osdc_new_request 6 635 NULL
114360 +cfs_hash_bkt_size_643 cfs_hash_bkt_size 0 643 NULL
114361 +unlink_queued_645 unlink_queued 4 645 NULL
114362 +dtim_interval_read_654 dtim_interval_read 3 654 NULL
114363 +mem_rx_free_mem_blks_read_675 mem_rx_free_mem_blks_read 3 675 NULL
114364 +vfio_cap_init_698 vfio_cap_init 0 698 NULL
114365 +persistent_ram_vmap_709 persistent_ram_vmap 1-2 709 NULL
114366 +xfs_bmap_eof_728 xfs_bmap_eof 0 728 NULL
114367 +sctp_setsockopt_peer_addr_params_734 sctp_setsockopt_peer_addr_params 3 734 NULL
114368 +dvb_video_write_754 dvb_video_write 3 754 NULL
114369 +cfs_trace_allocate_string_buffer_781 cfs_trace_allocate_string_buffer 2 781 NULL
114370 +ath6kl_disconnect_timeout_write_794 ath6kl_disconnect_timeout_write 3 794 NULL
114371 +snd_pcm_drain_811 snd_pcm_drain 0 811 NULL
114372 +if_writecmd_815 if_writecmd 2 815 NULL
114373 +aac_change_queue_depth_825 aac_change_queue_depth 2 825 NULL
114374 +dnet_mii_init_833 dnet_mii_init 0 833 NULL
114375 +SyS_write_846 SyS_write 3 846 NULL
114376 +hpsa_find_cfgtables_847 hpsa_find_cfgtables 0 847 NULL
114377 +error_state_read_859 error_state_read 6 859 NULL
114378 +o2net_send_message_vec_879 o2net_send_message_vec 4 879 NULL nohasharray
114379 +iwl_dbgfs_fh_reg_read_879 iwl_dbgfs_fh_reg_read 3 879 &o2net_send_message_vec_879
114380 +regulator_bulk_enable_903 regulator_bulk_enable 0 903 NULL
114381 +snd_pcm_action_single_905 snd_pcm_action_single 0 905 NULL
114382 +carl9170_cmd_buf_950 carl9170_cmd_buf 3 950 NULL
114383 +__nodes_weight_956 __nodes_weight 0-2 956 NULL
114384 +bnx2x_fill_fw_str_968 bnx2x_fill_fw_str 3 968 NULL
114385 +mnt_want_write_975 mnt_want_write 0 975 NULL nohasharray
114386 +pcap_add_subdev_975 pcap_add_subdev 0 975 &mnt_want_write_975
114387 +usnic_ib_qp_grp_dump_hdr_989 usnic_ib_qp_grp_dump_hdr 2 989 NULL
114388 +memcmp_990 memcmp 0 990 NULL
114389 +skge_rx_fill_991 skge_rx_fill 0 991 NULL
114390 +readreg_1017 readreg 0-1 1017 NULL
114391 +smk_write_cipso2_1021 smk_write_cipso2 3 1021 NULL
114392 +myri10ge_validate_firmware_1043 myri10ge_validate_firmware 0 1043 NULL
114393 +mdiobus_register_1047 mdiobus_register 0 1047 NULL
114394 +gigaset_initdriver_1060 gigaset_initdriver 2 1060 NULL
114395 +mce_request_packet_1073 mce_request_packet 3 1073 NULL nohasharray
114396 +mlx4_create_eq_1073 mlx4_create_eq 0 1073 &mce_request_packet_1073 nohasharray
114397 +writeout_1073 writeout 0 1073 &mlx4_create_eq_1073
114398 +agp_create_memory_1075 agp_create_memory 1 1075 NULL
114399 +snd_vortex_create_1077 snd_vortex_create 0 1077 NULL nohasharray
114400 +hwrng_init_1077 hwrng_init 0 1077 &snd_vortex_create_1077
114401 +_scsih_adjust_queue_depth_1083 _scsih_adjust_queue_depth 2 1083 NULL
114402 +llcp_sock_sendmsg_1092 llcp_sock_sendmsg 4 1092 NULL
114403 +nfs4_init_nonuniform_client_string_1097 nfs4_init_nonuniform_client_string 3 1097 NULL
114404 +ath10k_hif_start_1098 ath10k_hif_start 0 1098 NULL
114405 +utf8s_to_utf16s_1115 utf8s_to_utf16s 0 1115 NULL
114406 +vnic_dev_get_mac_addr_1119 vnic_dev_get_mac_addr 0 1119 NULL
114407 +hid_hw_start_1121 hid_hw_start 0 1121 NULL
114408 +cfg80211_report_obss_beacon_1133 cfg80211_report_obss_beacon 3 1133 NULL
114409 +i2400m_rx_ctl_1157 i2400m_rx_ctl 4 1157 NULL
114410 +ipc_alloc_1192 ipc_alloc 1 1192 NULL
114411 +ib_create_send_mad_1196 ib_create_send_mad 5 1196 NULL
114412 +pstore_ftrace_knob_write_1198 pstore_ftrace_knob_write 3 1198 NULL
114413 +i2400m_rx_ctl_ack_1199 i2400m_rx_ctl_ack 3 1199 NULL
114414 +usb_parse_interface_1201 usb_parse_interface 0 1201 NULL
114415 +dgrp_dpa_read_1204 dgrp_dpa_read 3 1204 NULL
114416 +i2cdev_read_1206 i2cdev_read 3 1206 NULL
114417 +lpfc_fof_queue_setup_1208 lpfc_fof_queue_setup 0 1208 NULL
114418 +lov_ost_pool_init_1215 lov_ost_pool_init 2 1215 NULL
114419 +fsync_buffers_list_1219 fsync_buffers_list 0 1219 NULL
114420 +dvb_register_adapter_1227 dvb_register_adapter 0 1227 NULL
114421 +kernfs_file_direct_read_1238 kernfs_file_direct_read 3 1238 NULL
114422 +acpi_battery_write_alarm_1240 acpi_battery_write_alarm 3 1240 NULL
114423 +__mlx4_register_vlan_1242 __mlx4_register_vlan 0 1242 NULL
114424 +mthca_cmd_imm_1256 mthca_cmd_imm 0 1256 NULL
114425 +drm_primary_helper_create_plane_1262 drm_primary_helper_create_plane 3 1262 NULL
114426 +ocfs2_extend_file_1266 ocfs2_extend_file 3 1266 NULL
114427 +qla4xxx_change_queue_depth_1268 qla4xxx_change_queue_depth 2 1268 NULL
114428 +ioctl_private_iw_point_1273 ioctl_private_iw_point 7 1273 NULL
114429 +SyS_flistxattr_1287 SyS_flistxattr 3 1287 NULL
114430 +tx_frag_in_process_called_read_1290 tx_frag_in_process_called_read 3 1290 NULL
114431 +ath5k_init_ah_1299 ath5k_init_ah 0 1299 NULL
114432 +posix_acl_xattr_set_1301 posix_acl_xattr_set 4 1301 NULL
114433 +ocfs2_append_rec_to_path_1321 ocfs2_append_rec_to_path 0 1321 NULL
114434 +ffs_1322 ffs 0 1322 NULL
114435 +qlcnic_pci_sriov_configure_1327 qlcnic_pci_sriov_configure 2 1327 NULL
114436 +devm_gpio_request_1332 devm_gpio_request 0 1332 NULL
114437 +btrfs_submit_compressed_write_1347 btrfs_submit_compressed_write 5 1347 NULL
114438 +gen_pool_best_fit_1348 gen_pool_best_fit 4 1348 NULL
114439 +em28xx_set_audio_source_1356 em28xx_set_audio_source 0 1356 NULL nohasharray
114440 +nouveau_ttm_global_init_1356 nouveau_ttm_global_init 0 1356 &em28xx_set_audio_source_1356
114441 +snd_pcm_lib_write1_1358 snd_pcm_lib_write1 0-3 1358 NULL
114442 +fill_phy_probe_info_1360 fill_phy_probe_info 0 1360 NULL
114443 +ipx_sendmsg_1362 ipx_sendmsg 4 1362 NULL
114444 +fw_stats_raw_read_1369 fw_stats_raw_read 3 1369 NULL
114445 +ocfs2_prepare_inode_for_write_1372 ocfs2_prepare_inode_for_write 3 1372 NULL
114446 +ngene_command_1375 ngene_command 0 1375 NULL
114447 +rtl8180_init_rx_ring_1381 rtl8180_init_rx_ring 0 1381 NULL
114448 +sctp_setsockopt_initmsg_1383 sctp_setsockopt_initmsg 3 1383 NULL
114449 +do_msgsnd_1387 do_msgsnd 4 1387 NULL
114450 +SYSC_io_getevents_1392 SYSC_io_getevents 3 1392 NULL
114451 +cfs_trace_copyout_string_1416 cfs_trace_copyout_string 2 1416 NULL
114452 +p54_parse_eeprom_1418 p54_parse_eeprom 0 1418 NULL
114453 +mlx4_set_port_vlan_table_1420 mlx4_set_port_vlan_table 0 1420 NULL
114454 +gfs2_unlink_ok_1435 gfs2_unlink_ok 0 1435 NULL
114455 +init_rs_internal_1436 init_rs_internal 1 1436 NULL
114456 +at86rf230_hw_init_1441 at86rf230_hw_init 0 1441 NULL
114457 +stack_max_size_read_1445 stack_max_size_read 3 1445 NULL
114458 +t4_sge_alloc_eth_txq_1454 t4_sge_alloc_eth_txq 0 1454 NULL
114459 +tx_queue_len_read_1463 tx_queue_len_read 3 1463 NULL
114460 +xprt_alloc_1475 xprt_alloc 2 1475 NULL
114461 +SYSC_syslog_1477 SYSC_syslog 3 1477 NULL
114462 +sta_num_ps_buf_frames_read_1488 sta_num_ps_buf_frames_read 3 1488 NULL
114463 +fpregs_set_1497 fpregs_set 4 1497 NULL
114464 +ocfs2_alloc_dinode_update_counts_1507 ocfs2_alloc_dinode_update_counts 0 1507 NULL
114465 +tomoyo_round2_1518 tomoyo_round2 0 1518 NULL
114466 +alloc_perm_bits_1532 alloc_perm_bits 2 1532 NULL
114467 +ath6kl_init_get_fwcaps_1557 ath6kl_init_get_fwcaps 3 1557 NULL
114468 +device_check_1561 device_check 0 1561 NULL
114469 +ffs_mutex_lock_1564 ffs_mutex_lock 0 1564 NULL
114470 +ieee80211_if_read_dot11MeshHWMPnetDiameterTraversalTime_1589 ieee80211_if_read_dot11MeshHWMPnetDiameterTraversalTime 3 1589 NULL
114471 +ipath_ht_handle_hwerrors_1592 ipath_ht_handle_hwerrors 3 1592 NULL
114472 +packet_buffer_init_1607 packet_buffer_init 2 1607 NULL
114473 +btmrvl_hscmd_read_1614 btmrvl_hscmd_read 3 1614 NULL
114474 +v9fs_fid_xattr_get_1618 v9fs_fid_xattr_get 0 1618 NULL
114475 +mlx4_alloc_eq_table_1641 mlx4_alloc_eq_table 0 1641 NULL
114476 +ikconfig_read_current_1658 ikconfig_read_current 3 1658 NULL
114477 +mlx4_QUERY_DEV_CAP_1659 mlx4_QUERY_DEV_CAP 0 1659 NULL
114478 +mei_cl_recv_1665 mei_cl_recv 3 1665 NULL
114479 +rmap_add_1677 rmap_add 3 1677 NULL
114480 +ath10k_bmi_lz_data_1682 ath10k_bmi_lz_data 0 1682 NULL
114481 +configfs_read_file_1683 configfs_read_file 3 1683 NULL
114482 +ican3_set_id_filter_1688 ican3_set_id_filter 0 1688 NULL
114483 +iwl_dbgfs_d0i3_refs_read_1705 iwl_dbgfs_d0i3_refs_read 3 1705 NULL
114484 +pdu_write_u_1710 pdu_write_u 3 1710 NULL
114485 +coda_psdev_write_1711 coda_psdev_write 3 1711 NULL
114486 +btrfs_dir_data_len_1714 btrfs_dir_data_len 0 1714 NULL
114487 +internal_create_group_1733 internal_create_group 0 1733 NULL
114488 +dev_irnet_read_1741 dev_irnet_read 3 1741 NULL
114489 +usb_ep_align_maybe_1743 usb_ep_align_maybe 0-3 1743 NULL
114490 +tx_frag_called_read_1748 tx_frag_called_read 3 1748 NULL
114491 +cosa_write_1774 cosa_write 3 1774 NULL
114492 +mwifiex_pcie_init_evt_ring_1775 mwifiex_pcie_init_evt_ring 0 1775 NULL
114493 +fcoe_ctlr_device_add_1793 fcoe_ctlr_device_add 3 1793 NULL
114494 +__nodelist_scnprintf_1815 __nodelist_scnprintf 2-0 1815 NULL
114495 +xfs_vm_write_end_1854 xfs_vm_write_end 5 1854 NULL
114496 +carm_init_disks_1865 carm_init_disks 0 1865 NULL
114497 +sb_issue_zeroout_1884 sb_issue_zeroout 3 1884 NULL
114498 +rx_defrag_called_read_1897 rx_defrag_called_read 3 1897 NULL
114499 +nfs_parse_server_name_1899 nfs_parse_server_name 2 1899 NULL
114500 +SyS_add_key_1900 SyS_add_key 4 1900 NULL
114501 +uhid_char_read_1920 uhid_char_read 3 1920 NULL
114502 +tx_tx_retry_data_read_1926 tx_tx_retry_data_read 3 1926 NULL
114503 +bdev_erase_1933 bdev_erase 3 1933 NULL
114504 +ext3_fiemap_1936 ext3_fiemap 4 1936 NULL
114505 +cyttsp_probe_1940 cyttsp_probe 4 1940 NULL
114506 +ieee80211_if_fmt_dot11MeshConfirmTimeout_1945 ieee80211_if_fmt_dot11MeshConfirmTimeout 3 1945 NULL
114507 +update_qd_1955 update_qd 0 1955 NULL
114508 +__assign_irq_vector_1961 __assign_irq_vector 0 1961 NULL
114509 +ivtv_v4l2_read_1964 ivtv_v4l2_read 3 1964 NULL
114510 +sel_read_avc_hash_stats_1984 sel_read_avc_hash_stats 3 1984 NULL
114511 +gpio_power_write_1991 gpio_power_write 3 1991 NULL
114512 +__alloc_bootmem_node_1992 __alloc_bootmem_node 2 1992 NULL
114513 +rx_rx_defrag_read_2010 rx_rx_defrag_read 3 2010 NULL
114514 +xfs_mru_cache_insert_2013 xfs_mru_cache_insert 0 2013 NULL
114515 +ocfs2_global_qinit_alloc_2018 ocfs2_global_qinit_alloc 0 2018 NULL
114516 +write_flush_pipefs_2021 write_flush_pipefs 3 2021 NULL
114517 +w1_add_master_device_2031 w1_add_master_device 0 2031 NULL
114518 +BcmCopySection_2035 BcmCopySection 5 2035 NULL
114519 +t4_early_init_2048 t4_early_init 0 2048 NULL
114520 +ath6kl_fwlog_mask_read_2050 ath6kl_fwlog_mask_read 3 2050 NULL
114521 +snd_msnd_dsp_full_reset_2060 snd_msnd_dsp_full_reset 0 2060 NULL
114522 +ocfs2_expand_inline_dir_2063 ocfs2_expand_inline_dir 3 2063 NULL
114523 +__generic_copy_from_user_intel_2073 __generic_copy_from_user_intel 0-3 2073 NULL
114524 +diva_set_driver_dbg_mask_2077 diva_set_driver_dbg_mask 0 2077 NULL
114525 +iwl_dbgfs_current_sleep_command_read_2081 iwl_dbgfs_current_sleep_command_read 3 2081 NULL
114526 +idetape_chrdev_read_2097 idetape_chrdev_read 3 2097 NULL
114527 +audit_expand_2098 audit_expand 0 2098 NULL
114528 +__set_print_fmt_2106 __set_print_fmt 0 2106 NULL
114529 +iwl_dbgfs_log_event_read_2107 iwl_dbgfs_log_event_read 3 2107 NULL
114530 +ecryptfs_encrypt_and_encode_filename_2109 ecryptfs_encrypt_and_encode_filename 6 2109 NULL
114531 +btrfs_file_extent_inline_len_2116 btrfs_file_extent_inline_len 0 2116 NULL
114532 +enable_read_2117 enable_read 3 2117 NULL
114533 +pcf50633_write_block_2124 pcf50633_write_block 2-3 2124 NULL
114534 +dscc4_init_ring_2126 dscc4_init_ring 0 2126 NULL
114535 +xfs_recover_inode_owner_change_2132 xfs_recover_inode_owner_change 0 2132 NULL
114536 +check_load_and_stores_2143 check_load_and_stores 2 2143 NULL
114537 +mtip_block_initialize_2150 mtip_block_initialize 0 2150 NULL
114538 +mlx4_init_icm_table_2151 mlx4_init_icm_table 0 2151 NULL
114539 +iov_iter_count_2152 iov_iter_count 0 2152 NULL
114540 +__copy_to_user_ll_2157 __copy_to_user_ll 0-3 2157 NULL
114541 +ocfs2_et_sanity_check_2164 ocfs2_et_sanity_check 0 2164 NULL
114542 +_ore_get_io_state_2166 _ore_get_io_state 3-4-5 2166 NULL
114543 +bio_integrity_alloc_2194 bio_integrity_alloc 3 2194 NULL
114544 +picolcd_debug_reset_write_2195 picolcd_debug_reset_write 3 2195 NULL
114545 +pcim_iomap_regions_request_all_2202 pcim_iomap_regions_request_all 0 2202 NULL
114546 +xfs_inobt_update_2206 xfs_inobt_update 0 2206 NULL
114547 +tsi721_messages_init_2214 tsi721_messages_init 0 2214 NULL
114548 +u32_array_read_2219 u32_array_read 3 2219 NULL nohasharray
114549 +mei_dbgfs_read_meclients_2219 mei_dbgfs_read_meclients 3 2219 &u32_array_read_2219
114550 +gpio_export_2221 gpio_export 0 2221 NULL
114551 +__ocfs2_journal_access_2241 __ocfs2_journal_access 0 2241 NULL
114552 +mlx4_buddy_init_2244 mlx4_buddy_init 0 2244 NULL
114553 +ieee80211_if_read_dot11MeshHWMPRannInterval_2249 ieee80211_if_read_dot11MeshHWMPRannInterval 3 2249 NULL
114554 +netlbl_secattr_catmap_walk_2255 netlbl_secattr_catmap_walk 0-2 2255 NULL
114555 +sel_write_avc_cache_threshold_2256 sel_write_avc_cache_threshold 3 2256 NULL
114556 +do_update_counters_2259 do_update_counters 4 2259 NULL
114557 +ath6kl_wmi_bssinfo_event_rx_2275 ath6kl_wmi_bssinfo_event_rx 3 2275 NULL
114558 +debug_debug5_read_2291 debug_debug5_read 3 2291 NULL
114559 +ocfs2_shift_tree_depth_2292 ocfs2_shift_tree_depth 0 2292 NULL
114560 +c2_errno_2296 c2_errno 0 2296 NULL
114561 +sr_read_cmd_2299 sr_read_cmd 5 2299 NULL
114562 +kvm_clear_guest_page_2308 kvm_clear_guest_page 4 2308 NULL
114563 +intel_sdvo_set_value_2311 intel_sdvo_set_value 4 2311 NULL
114564 +hfsplus_find_init_2318 hfsplus_find_init 0 2318 NULL nohasharray
114565 +picolcd_fb_write_2318 picolcd_fb_write 3 2318 &hfsplus_find_init_2318
114566 +gart_map_page_2325 gart_map_page 3-4 2325 NULL
114567 +dice_hwdep_read_2326 dice_hwdep_read 3 2326 NULL
114568 +ath10k_htt_attach_target_2338 ath10k_htt_attach_target 0 2338 NULL
114569 +__erst_read_to_erange_2341 __erst_read_to_erange 0 2341 NULL
114570 +bcm2048_send_command_2347 bcm2048_send_command 0 2347 NULL
114571 +zr364xx_read_2354 zr364xx_read 3 2354 NULL
114572 +ntfs_file_aio_write_nolock_2360 ntfs_file_aio_write_nolock 0 2360 NULL
114573 +viafb_iga2_odev_proc_write_2363 viafb_iga2_odev_proc_write 3 2363 NULL
114574 +xfs_buf_map_from_irec_2368 xfs_buf_map_from_irec 5-0 2368 NULL nohasharray
114575 +rose_recvmsg_2368 rose_recvmsg 4 2368 &xfs_buf_map_from_irec_2368
114576 +il_dbgfs_sensitivity_read_2370 il_dbgfs_sensitivity_read 3 2370 NULL
114577 +rxpipe_rx_prep_beacon_drop_read_2403 rxpipe_rx_prep_beacon_drop_read 3 2403 NULL
114578 +isdn_v110_open_2418 isdn_v110_open 3 2418 NULL
114579 +raid1_size_2419 raid1_size 0-2 2419 NULL
114580 +arch_msi_check_device_2449 arch_msi_check_device 0 2449 NULL
114581 +lbs_start_card_2450 lbs_start_card 0 2450 NULL
114582 +ieee80211_register_hw_2456 ieee80211_register_hw 0 2456 NULL
114583 +b43legacy_debugfs_read_2473 b43legacy_debugfs_read 3 2473 NULL
114584 +wiphy_new_2482 wiphy_new 2 2482 NULL
114585 +bio_alloc_bioset_2484 bio_alloc_bioset 2 2484 NULL
114586 +squashfs_read_fragment_index_table_2506 squashfs_read_fragment_index_table 4 2506 NULL
114587 +v9fs_cached_file_read_2514 v9fs_cached_file_read 3 2514 NULL
114588 +ext4_get_inode_loc_2516 ext4_get_inode_loc 0 2516 NULL
114589 +batadv_tvlv_container_list_size_2524 batadv_tvlv_container_list_size 0 2524 NULL
114590 +smk_write_syslog_2529 smk_write_syslog 3 2529 NULL
114591 +__ceph_setxattr_2532 __ceph_setxattr 4 2532 NULL
114592 +device_wakeup_enable_2539 device_wakeup_enable 0 2539 NULL
114593 +ata_host_start_2545 ata_host_start 0 2545 NULL
114594 +gspca_dev_probe_2570 gspca_dev_probe 4 2570 NULL
114595 +pcm_sanity_check_2574 pcm_sanity_check 0 2574 NULL
114596 +rsxx_creg_setup_2583 rsxx_creg_setup 0 2583 NULL
114597 +mdc_max_rpcs_in_flight_seq_write_2594 mdc_max_rpcs_in_flight_seq_write 3 2594 NULL
114598 +slot_bytes_2609 slot_bytes 0 2609 NULL
114599 +smk_write_logging_2618 smk_write_logging 3 2618 NULL
114600 +switch_status_2629 switch_status 5 2629 NULL
114601 +tcp_xmit_size_goal_2661 tcp_xmit_size_goal 2 2661 NULL nohasharray
114602 +request_msix_queue_irqs_2661 request_msix_queue_irqs 0 2661 &tcp_xmit_size_goal_2661
114603 +osc_build_ppga_2670 osc_build_ppga 2 2670 NULL
114604 +ffs_ep0_read_2672 ffs_ep0_read 3 2672 NULL
114605 +ocfs2_rotate_subtree_right_2674 ocfs2_rotate_subtree_right 0 2674 NULL
114606 +oti6858_write_2692 oti6858_write 4 2692 NULL
114607 +nfc_llcp_send_ui_frame_2702 nfc_llcp_send_ui_frame 5 2702 NULL
114608 +memcpy_fromiovecend_2707 memcpy_fromiovecend 3-4 2707 NULL
114609 +lprocfs_stats_counter_size_2708 lprocfs_stats_counter_size 0 2708 NULL nohasharray
114610 +SyS_pwrite64_2708 SyS_pwrite64 3 2708 &lprocfs_stats_counter_size_2708
114611 +gpiod_direction_input_2718 gpiod_direction_input 0 2718 NULL
114612 +t4_flash_erase_sectors_2719 t4_flash_erase_sectors 0 2719 NULL
114613 +ath10k_htt_tx_alloc_msdu_id_2734 ath10k_htt_tx_alloc_msdu_id 0 2734 NULL
114614 +gfs2_glock_nq_num_2747 gfs2_glock_nq_num 0 2747 NULL
114615 +xfs_readdir_2767 xfs_readdir 3 2767 NULL
114616 +fsl_edma_alloc_desc_2769 fsl_edma_alloc_desc 2 2769 NULL
114617 +mon_bin_ioctl_2771 mon_bin_ioctl 3 2771 NULL
114618 +vmbus_sendpacket_2774 vmbus_sendpacket 0 2774 NULL
114619 +cfg80211_can_add_interface_2775 cfg80211_can_add_interface 0 2775 NULL
114620 +set_msr_hyperv_pw_2785 set_msr_hyperv_pw 3 2785 NULL
114621 +device_add_attrs_2789 device_add_attrs 0 2789 NULL
114622 +vnic_dev_spec_2796 vnic_dev_spec 0 2796 NULL
114623 +iwl_dbgfs_clear_ucode_statistics_write_2804 iwl_dbgfs_clear_ucode_statistics_write 3 2804 NULL
114624 +sel_read_enforce_2828 sel_read_enforce 3 2828 NULL
114625 +snd_pcm_reset_2829 snd_pcm_reset 0 2829 NULL nohasharray
114626 +vb2_dc_get_userptr_2829 vb2_dc_get_userptr 2-3 2829 &snd_pcm_reset_2829
114627 +wait_for_avail_2847 wait_for_avail 0 2847 NULL
114628 +snd_cx25821_pcm_2859 snd_cx25821_pcm 0 2859 NULL
114629 +sfq_alloc_2861 sfq_alloc 1 2861 NULL
114630 +irnet_ctrl_read_2863 irnet_ctrl_read 4 2863 NULL
114631 +move_addr_to_user_2868 move_addr_to_user 2 2868 NULL
114632 +nla_padlen_2883 nla_padlen 1 2883 NULL
114633 +mb862xx_pci_gdc_init_2891 mb862xx_pci_gdc_init 0 2891 NULL
114634 +cmm_write_2896 cmm_write 3 2896 NULL
114635 +osc_import_seq_write_2923 osc_import_seq_write 3 2923 NULL
114636 +xfs_trans_get_buf_map_2927 xfs_trans_get_buf_map 4 2927 NULL
114637 +nes_read_indexed_2946 nes_read_indexed 0 2946 NULL
114638 +tm6000_i2c_recv_regs16_2949 tm6000_i2c_recv_regs16 5 2949 NULL
114639 +i40e_dbg_prep_dump_buf_2951 i40e_dbg_prep_dump_buf 2 2951 NULL
114640 +set_fast_connectable_2952 set_fast_connectable 4 2952 NULL
114641 +free_area_init_core_2962 free_area_init_core 2-3 2962 NULL
114642 +bio_setup_sector_2970 bio_setup_sector 3 2970 NULL
114643 +do_strnlen_user_2976 do_strnlen_user 0-2 2976 NULL
114644 +ocfs2_find_branch_target_2989 ocfs2_find_branch_target 0 2989 NULL
114645 +p9_nr_pages_2992 p9_nr_pages 0-2 2992 NULL
114646 +_xfs_filestream_pick_ag_3007 _xfs_filestream_pick_ag 0 3007 NULL
114647 +lov_stripetype_seq_write_3013 lov_stripetype_seq_write 3 3013 NULL
114648 +do_dmabuf_dirty_sou_3017 do_dmabuf_dirty_sou 7 3017 NULL
114649 +depth_write_3021 depth_write 3 3021 NULL
114650 +snd_azf3328_codec_inl_3022 snd_azf3328_codec_inl 0 3022 NULL
114651 +nvme_split_and_submit_3027 nvme_split_and_submit 3 3027 NULL
114652 +kvm_unmap_hva_3028 kvm_unmap_hva 2 3028 NULL nohasharray
114653 +__blocking_notifier_call_chain_3028 __blocking_notifier_call_chain 0 3028 &kvm_unmap_hva_3028
114654 +xfrm_dst_alloc_copy_3034 xfrm_dst_alloc_copy 3 3034 NULL
114655 +lpfc_idiag_mbxacc_write_3038 lpfc_idiag_mbxacc_write 3 3038 NULL nohasharray
114656 +iwl_dbgfs_sleep_level_override_read_3038 iwl_dbgfs_sleep_level_override_read 3 3038 &lpfc_idiag_mbxacc_write_3038
114657 +nr_free_buffer_pages_3044 nr_free_buffer_pages 0 3044 NULL
114658 +il3945_ucode_rx_stats_read_3048 il3945_ucode_rx_stats_read 3 3048 NULL
114659 +mwl8k_post_pervif_cmd_3050 mwl8k_post_pervif_cmd 0 3050 NULL
114660 +ath10k_wmi_main_cmd_init_3054 ath10k_wmi_main_cmd_init 0 3054 NULL
114661 +mwl8k_post_cmd_3056 mwl8k_post_cmd 0 3056 NULL
114662 +qp_alloc_ppn_set_3068 qp_alloc_ppn_set 2-4 3068 NULL
114663 +__blk_end_bidi_request_3070 __blk_end_bidi_request 3-4 3070 NULL
114664 +dac960_user_command_proc_write_3071 dac960_user_command_proc_write 3 3071 NULL
114665 +read_file_antenna_diversity_3077 read_file_antenna_diversity 3 3077 NULL
114666 +free_coherent_3082 free_coherent 4-2 3082 NULL
114667 +init_tx_ring_3085 init_tx_ring 0 3085 NULL
114668 +ocfs2_get_right_path_3097 ocfs2_get_right_path 0 3097 NULL
114669 +ttusb2_msg_3100 ttusb2_msg 4 3100 NULL
114670 +rb_alloc_3102 rb_alloc 1 3102 NULL
114671 +simple_write_to_buffer_3122 simple_write_to_buffer 5-2 3122 NULL
114672 +print_time_3132 print_time 0 3132 NULL
114673 +fill_write_buffer_3142 fill_write_buffer 3 3142 NULL
114674 +CIFSSMBSetPosixACL_3154 CIFSSMBSetPosixACL 5 3154 NULL
114675 +gfs2_rindex_update_3165 gfs2_rindex_update 0 3165 NULL
114676 +uv_num_possible_blades_3177 uv_num_possible_blades 0 3177 NULL
114677 +uinput_ioctl_handler_3181 uinput_ioctl_handler 2 3181 NULL nohasharray
114678 +uvc_video_stats_dump_3181 uvc_video_stats_dump 3 3181 &uinput_ioctl_handler_3181
114679 +compat_do_ip6t_set_ctl_3184 compat_do_ip6t_set_ctl 4 3184 NULL
114680 +mempool_create_node_3191 mempool_create_node 1 3191 NULL
114681 +alloc_context_3194 alloc_context 1 3194 NULL
114682 +shmem_pread_slow_3198 shmem_pread_slow 3-2 3198 NULL
114683 +codec_reg_write_file_3204 codec_reg_write_file 3 3204 NULL
114684 +SyS_sendto_3219 SyS_sendto 6 3219 NULL
114685 +btrfs_prealloc_file_range_3227 btrfs_prealloc_file_range 3 3227 NULL
114686 +kimage_crash_alloc_3233 kimage_crash_alloc 3 3233 NULL
114687 +write_adapter_mem_3234 write_adapter_mem 3 3234 NULL
114688 +do_read_log_to_user_3236 do_read_log_to_user 4 3236 NULL
114689 +ext3_xattr_find_entry_3237 ext3_xattr_find_entry 0 3237 NULL
114690 +key_key_read_3241 key_key_read 3 3241 NULL
114691 +cx25821_dev_setup_3263 cx25821_dev_setup 0 3263 NULL
114692 +fnic_set_intr_mode_3266 fnic_set_intr_mode 0 3266 NULL
114693 +uvc_queue_init_3276 uvc_queue_init 0 3276 NULL
114694 +__ilog2_u64_3284 __ilog2_u64 0 3284 NULL
114695 +ieee80211_if_write_beacon_loss_3296 ieee80211_if_write_beacon_loss 3 3296 NULL
114696 +cgroup_name_3300 cgroup_name 3 3300 NULL
114697 +__set_extent_bit_3305 __set_extent_bit 0 3305 NULL
114698 +mthca_create_agents_3307 mthca_create_agents 0 3307 NULL
114699 +__iovec_copy_from_user_inatomic_3314 __iovec_copy_from_user_inatomic 4-3-0 3314 NULL
114700 +_iwl_dbgfs_d3_sram_write_3315 _iwl_dbgfs_d3_sram_write 3 3315 NULL
114701 +dbDiscardAG_3322 dbDiscardAG 3 3322 NULL
114702 +read_from_oldmem_3337 read_from_oldmem 2 3337 NULL
114703 +sysfs_create_group_3339 sysfs_create_group 0 3339 NULL
114704 +tty_port_register_device_attr_3341 tty_port_register_device_attr 3 3341 NULL
114705 +il_dbgfs_interrupt_read_3351 il_dbgfs_interrupt_read 3 3351 NULL
114706 +gsm_control_rls_3353 gsm_control_rls 3 3353 NULL
114707 +scnprintf_3360 scnprintf 0-2 3360 NULL
114708 +ReadByteAmd7930_3365 ReadByteAmd7930 0 3365 NULL
114709 +sr_read_3366 sr_read 3 3366 NULL
114710 +mlx4_MAP_ICM_AUX_3386 mlx4_MAP_ICM_AUX 0 3386 NULL
114711 +mtdchar_writeoob_3393 mtdchar_writeoob 4 3393 NULL
114712 +isdn_readbchan_3401 isdn_readbchan 0-5 3401 NULL
114713 +mei_io_cb_alloc_resp_buf_3414 mei_io_cb_alloc_resp_buf 2 3414 NULL
114714 +pci_add_cap_save_buffer_3426 pci_add_cap_save_buffer 3 3426 NULL
114715 +crystalhd_create_dio_pool_3427 crystalhd_create_dio_pool 2 3427 NULL
114716 +SyS_msgsnd_3436 SyS_msgsnd 3 3436 NULL
114717 +softsynth_write_3455 softsynth_write 3 3455 NULL
114718 +snd_pcm_lib_readv_transfer_3464 snd_pcm_lib_readv_transfer 5-4-2 3464 NULL
114719 +ngene_command_mutex_3467 ngene_command_mutex 0 3467 NULL
114720 +dwc2_get_hwparams_3491 dwc2_get_hwparams 0 3491 NULL
114721 +security_context_to_sid_default_3492 security_context_to_sid_default 2 3492 NULL
114722 +xfrm_migrate_msgsize_3496 xfrm_migrate_msgsize 1 3496 NULL
114723 +mem_tx_free_mem_blks_read_3521 mem_tx_free_mem_blks_read 3 3521 NULL
114724 +SyS_semtimedop_3532 SyS_semtimedop 3 3532 NULL
114725 +SyS_readv_3539 SyS_readv 3 3539 NULL
114726 +sht15_send_status_3544 sht15_send_status 0 3544 NULL
114727 +btrfs_dir_name_len_3549 btrfs_dir_name_len 0 3549 NULL
114728 +alloc_smp_resp_3566 alloc_smp_resp 1 3566 NULL
114729 +evtchn_read_3569 evtchn_read 3 3569 NULL
114730 +ll_track_ppid_seq_write_3582 ll_track_ppid_seq_write 3 3582 NULL
114731 +vc_resize_3585 vc_resize 3-2 3585 NULL
114732 +kvm_mmu_notifier_change_pte_3596 kvm_mmu_notifier_change_pte 3 3596 NULL nohasharray
114733 +ipw_prom_alloc_3596 ipw_prom_alloc 0 3596 &kvm_mmu_notifier_change_pte_3596
114734 +sctp_getsockopt_events_3607 sctp_getsockopt_events 2 3607 NULL
114735 +edac_mc_alloc_3611 edac_mc_alloc 4 3611 NULL
114736 +tx_tx_starts_read_3617 tx_tx_starts_read 3 3617 NULL
114737 +aligned_kmalloc_3628 aligned_kmalloc 1 3628 NULL
114738 +mlx4_init_cq_table_3637 mlx4_init_cq_table 0 3637 NULL
114739 +ath6kl_disconnect_timeout_read_3650 ath6kl_disconnect_timeout_read 3 3650 NULL
114740 +i915_compat_ioctl_3656 i915_compat_ioctl 2 3656 NULL
114741 +_il_poll_bit_3657 _il_poll_bit 0 3657 NULL
114742 +xfs_attr3_leaf_list_int_3661 xfs_attr3_leaf_list_int 0 3661 NULL
114743 +_iwl_dbgfs_tx_flush_write_3675 _iwl_dbgfs_tx_flush_write 3 3675 NULL
114744 +snd_m3_assp_read_3703 snd_m3_assp_read 0 3703 NULL
114745 +ci_ll_write_3740 ci_ll_write 4 3740 NULL
114746 +niu_get_of_props_3752 niu_get_of_props 0 3752 NULL
114747 +start_isolate_page_range_3767 start_isolate_page_range 0 3767 NULL
114748 +lpfc_sli4_xri_sgl_update_3771 lpfc_sli4_xri_sgl_update 0 3771 NULL
114749 +sctp_setsockopt_auth_key_3793 sctp_setsockopt_auth_key 3 3793 NULL
114750 +ncp_file_write_3813 ncp_file_write 3 3813 NULL
114751 +llc_ui_recvmsg_3826 llc_ui_recvmsg 4 3826 NULL
114752 +hfsplus_direct_IO_3835 hfsplus_direct_IO 4 3835 NULL
114753 +create_one_cdev_3852 create_one_cdev 2 3852 NULL
114754 +smk_read_onlycap_3855 smk_read_onlycap 3 3855 NULL
114755 +get_fd_set_3866 get_fd_set 1 3866 NULL
114756 +apei_res_sub_3873 apei_res_sub 0 3873 NULL
114757 +c2_rnic_init_3880 c2_rnic_init 0 3880 NULL
114758 +garp_attr_create_3883 garp_attr_create 3 3883 NULL
114759 +efivarfs_file_read_3893 efivarfs_file_read 3 3893 NULL
114760 +nvram_write_3894 nvram_write 3 3894 NULL
114761 +pipeline_pre_proc_swi_read_3898 pipeline_pre_proc_swi_read 3 3898 NULL
114762 +comedi_buf_read_n_available_3899 comedi_buf_read_n_available 0 3899 NULL
114763 +vcs_write_3910 vcs_write 3 3910 NULL
114764 +SyS_move_pages_3920 SyS_move_pages 2 3920 NULL
114765 +hdlc_irq_one_3944 hdlc_irq_one 2 3944 NULL
114766 +brcmf_debugfs_fws_stats_read_3947 brcmf_debugfs_fws_stats_read 3 3947 NULL nohasharray
114767 +cp_refill_rx_3947 cp_refill_rx 0 3947 &brcmf_debugfs_fws_stats_read_3947
114768 +ath10k_hif_exchange_bmi_msg_3948 ath10k_hif_exchange_bmi_msg 0 3948 NULL
114769 +mite_bytes_written_to_memory_lb_3987 mite_bytes_written_to_memory_lb 0 3987 NULL
114770 +virtfn_add_3988 virtfn_add 0 3988 NULL
114771 +do_add_counters_3992 do_add_counters 3 3992 NULL
114772 +xfs_bmbt_lookup_eq_3997 xfs_bmbt_lookup_eq 0 3997 NULL
114773 +snd_msnd_initialize_3999 snd_msnd_initialize 0 3999 NULL
114774 +obd_alloc_memmd_4002 obd_alloc_memmd 0 4002 NULL
114775 +userspace_status_4004 userspace_status 4 4004 NULL
114776 +mei_write_4005 mei_write 3 4005 NULL nohasharray
114777 +xfs_check_block_4005 xfs_check_block 4 4005 &mei_write_4005
114778 +gfs2_dir_get_existing_buffer_4007 gfs2_dir_get_existing_buffer 0 4007 NULL
114779 +snd_hdsp_capture_copy_4011 snd_hdsp_capture_copy 5 4011 NULL
114780 +mptbase_sas_persist_operation_4019 mptbase_sas_persist_operation 0 4019 NULL
114781 +_request_firmware_4021 _request_firmware 0 4021 NULL
114782 +blk_end_request_4024 blk_end_request 3 4024 NULL
114783 +ext4_xattr_find_entry_4025 ext4_xattr_find_entry 0 4025 NULL
114784 +xfs_free_ag_extent_4036 xfs_free_ag_extent 0 4036 NULL
114785 +mtip_hw_read_registers_4037 mtip_hw_read_registers 3 4037 NULL
114786 +read_file_queues_4078 read_file_queues 3 4078 NULL
114787 +fbcon_do_set_font_4079 fbcon_do_set_font 2-3 4079 NULL
114788 +da9052_free_irq_4090 da9052_free_irq 2 4090 NULL
114789 +ath10k_bmi_lz_stream_start_4103 ath10k_bmi_lz_stream_start 0 4103 NULL
114790 +C_SYSC_rt_sigpending_4114 C_SYSC_rt_sigpending 2 4114 NULL
114791 +usb_hcd_request_irqs_4121 usb_hcd_request_irqs 0 4121 NULL
114792 +ath10k_htt_send_rx_ring_cfg_ll_4143 ath10k_htt_send_rx_ring_cfg_ll 0 4143 NULL
114793 +tm6000_read_4151 tm6000_read 3 4151 NULL
114794 +mpt_raid_phys_disk_get_num_paths_4155 mpt_raid_phys_disk_get_num_paths 0 4155 NULL nohasharray
114795 +cx18_reg_dev_4155 cx18_reg_dev 0 4155 &mpt_raid_phys_disk_get_num_paths_4155
114796 +ifx_spi_create_port_4157 ifx_spi_create_port 0 4157 NULL
114797 +msg_bits_4158 msg_bits 0-3-4 4158 NULL
114798 +t1_init_hw_modules_4163 t1_init_hw_modules 0 4163 NULL
114799 +get_alua_req_4166 get_alua_req 3 4166 NULL
114800 +blk_dropped_read_4168 blk_dropped_read 3 4168 NULL
114801 +read_file_bool_4180 read_file_bool 3 4180 NULL
114802 +ocfs2_find_cpos_for_right_leaf_4194 ocfs2_find_cpos_for_right_leaf 0 4194 NULL
114803 +vring_new_virtqueue_4199 vring_new_virtqueue 2 4199 NULL
114804 +f1x_determine_channel_4202 f1x_determine_channel 2 4202 NULL
114805 +_osd_req_list_objects_4204 _osd_req_list_objects 6 4204 NULL
114806 +e100_alloc_4207 e100_alloc 0 4207 NULL
114807 +__snd_gf1_read_addr_4210 __snd_gf1_read_addr 0 4210 NULL
114808 +vq_wait_for_reply_4211 vq_wait_for_reply 0 4211 NULL
114809 +si4713_start_seq_4224 si4713_start_seq 0 4224 NULL
114810 +usbhs_mod_host_probe_4227 usbhs_mod_host_probe 0 4227 NULL
114811 +tg3_init_5401phy_dsp_4272 tg3_init_5401phy_dsp 0 4272 NULL
114812 +ath6kl_force_roam_write_4282 ath6kl_force_roam_write 3 4282 NULL
114813 +goldfish_audio_write_4284 goldfish_audio_write 3 4284 NULL
114814 +get_connectors_for_crtc_4291 get_connectors_for_crtc 0 4291 NULL
114815 +__usbnet_read_cmd_4299 __usbnet_read_cmd 7 4299 NULL
114816 +fw_read_file_contents_4301 fw_read_file_contents 0 4301 NULL
114817 +dvb_ringbuffer_pkt_read_user_4303 dvb_ringbuffer_pkt_read_user 3-2-5 4303 NULL
114818 +count_strings_4315 count_strings 0 4315 NULL
114819 +nouveau_fifo_create__4327 nouveau_fifo_create_ 5-6 4327 NULL
114820 +snd_rawmidi_kernel_read_4328 snd_rawmidi_kernel_read 3 4328 NULL
114821 +ima_eventdigest_init_common_4338 ima_eventdigest_init_common 2 4338 NULL
114822 +__copy_from_user_inatomic_4365 __copy_from_user_inatomic 3-0 4365 NULL nohasharray
114823 +lookup_string_4365 lookup_string 0 4365 &__copy_from_user_inatomic_4365
114824 +__migrate_balloon_page_4367 __migrate_balloon_page 0 4367 NULL
114825 +irda_sendmsg_4388 irda_sendmsg 4 4388 NULL
114826 +access_process_vm_4412 access_process_vm 0 4412 NULL nohasharray
114827 +cxacru_cm_get_array_4412 cxacru_cm_get_array 4 4412 &access_process_vm_4412
114828 +libfc_vport_create_4415 libfc_vport_create 2 4415 NULL
114829 +rtw_android_get_rssi_4421 rtw_android_get_rssi 0 4421 NULL
114830 +read_code_4429 read_code 4 4429 NULL
114831 +ath10k_htc_start_4430 ath10k_htc_start 0 4430 NULL
114832 +do_pages_stat_4437 do_pages_stat 2 4437 NULL
114833 +netdev_register_kobject_4444 netdev_register_kobject 0 4444 NULL
114834 +at76_set_card_command_4471 at76_set_card_command 4 4471 NULL
114835 +iio_device_register_sysfs_4478 iio_device_register_sysfs 0 4478 NULL
114836 +snd_seq_expand_var_event_4481 snd_seq_expand_var_event 0-5 4481 NULL
114837 +snd_wss_mixer_4490 snd_wss_mixer 0 4490 NULL
114838 +ocfs2_grow_tree_4492 ocfs2_grow_tree 0 4492 NULL
114839 +vmbus_establish_gpadl_4495 vmbus_establish_gpadl 3-0 4495 NULL
114840 +set_link_security_4502 set_link_security 4 4502 NULL
114841 +t4_read_reg_4509 t4_read_reg 0 4509 NULL
114842 +xfs_btree_kill_root_4526 xfs_btree_kill_root 0 4526 NULL
114843 +ll_max_readahead_per_file_mb_seq_write_4531 ll_max_readahead_per_file_mb_seq_write 3 4531 NULL
114844 +tty_register_device_4544 tty_register_device 2 4544 NULL
114845 +fsl_edma_prep_slave_sg_4555 fsl_edma_prep_slave_sg 3 4555 NULL
114846 +btrfs_file_extent_inline_item_len_4575 btrfs_file_extent_inline_item_len 0 4575 NULL
114847 +xfs_buf_get_maps_4581 xfs_buf_get_maps 2 4581 NULL
114848 +bch_alloc_4593 bch_alloc 1 4593 NULL
114849 +ocfs2_refcount_lock_4595 ocfs2_refcount_lock 0 4595 NULL
114850 +dscc4_found1_4599 dscc4_found1 0 4599 NULL
114851 +ll_rw_extents_stats_seq_write_4633 ll_rw_extents_stats_seq_write 3 4633 NULL
114852 +iwl_dbgfs_tx_queue_read_4635 iwl_dbgfs_tx_queue_read 3 4635 NULL
114853 +adap_init0_tweaks_4663 adap_init0_tweaks 0 4663 NULL
114854 +skb_add_data_nocache_4682 skb_add_data_nocache 4 4682 NULL
114855 +cx18_read_pos_4683 cx18_read_pos 3 4683 NULL
114856 +short_retry_limit_read_4687 short_retry_limit_read 3 4687 NULL
114857 +register_queue_kobjects_4688 register_queue_kobjects 0 4688 NULL
114858 +kone_receive_4690 kone_receive 4 4690 NULL
114859 +write8_reg_4701 write8_reg 0-4 4701 NULL
114860 +hash_netportnet6_expire_4702 hash_netportnet6_expire 4 4702 NULL
114861 +cxgbi_alloc_big_mem_4707 cxgbi_alloc_big_mem 1 4707 NULL nohasharray
114862 +enic_dev_open_4707 enic_dev_open 0 4707 &cxgbi_alloc_big_mem_4707
114863 +ati_create_gatt_pages_4722 ati_create_gatt_pages 1 4722 NULL nohasharray
114864 +show_header_4722 show_header 3 4722 &ati_create_gatt_pages_4722
114865 +fw_lookup_and_allocate_buf_4723 fw_lookup_and_allocate_buf 0 4723 NULL
114866 +fallback_migrate_page_4726 fallback_migrate_page 0 4726 NULL
114867 +bitmap_startwrite_4736 bitmap_startwrite 2 4736 NULL nohasharray
114868 +ll_rw_offset_stats_seq_write_4736 ll_rw_offset_stats_seq_write 3 4736 &bitmap_startwrite_4736
114869 +lu_buf_alloc_4753 lu_buf_alloc 2 4753 NULL
114870 +pwr_rcvd_bcns_cnt_read_4774 pwr_rcvd_bcns_cnt_read 3 4774 NULL
114871 +create_subvol_4791 create_subvol 4 4791 NULL
114872 +skd_start_timer_4803 skd_start_timer 0 4803 NULL
114873 +ncp__vol2io_4804 ncp__vol2io 5 4804 NULL
114874 +C_SYSC_setsockopt_4806 C_SYSC_setsockopt 5 4806 NULL
114875 +repair_io_failure_4815 repair_io_failure 4-3 4815 NULL
114876 +ntb_setup_interrupts_4836 ntb_setup_interrupts 0 4836 NULL
114877 +amradio_set_stereo_4845 amradio_set_stereo 0 4845 NULL
114878 +comedi_buf_write_free_4847 comedi_buf_write_free 2 4847 NULL
114879 +gigaset_if_receive_4861 gigaset_if_receive 3 4861 NULL
114880 +key_tx_spec_read_4862 key_tx_spec_read 3 4862 NULL
114881 +ocfs2_defrag_extent_4873 ocfs2_defrag_extent 2 4873 NULL
114882 +hid_register_field_4874 hid_register_field 2-3 4874 NULL
114883 +tg3_phy_reset_4876 tg3_phy_reset 0 4876 NULL
114884 +vga_arb_read_4886 vga_arb_read 3 4886 NULL
114885 +ufshcd_hba_enable_4908 ufshcd_hba_enable 0 4908 NULL
114886 +ieee80211_if_fmt_ave_beacon_4941 ieee80211_if_fmt_ave_beacon 3 4941 NULL
114887 +myri10ge_request_irq_4945 myri10ge_request_irq 0 4945 NULL
114888 +mvumi_map_pci_addr_4948 mvumi_map_pci_addr 0 4948 NULL
114889 +sigma_action_write_i2c_4951 sigma_action_write_i2c 3 4951 NULL
114890 +request_msix_data_irqs_4956 request_msix_data_irqs 0 4956 NULL
114891 +ocfs2_should_refresh_lock_res_4958 ocfs2_should_refresh_lock_res 0 4958 NULL
114892 +compat_rawv6_setsockopt_4967 compat_rawv6_setsockopt 5 4967 NULL
114893 +ath10k_read_chip_id_4969 ath10k_read_chip_id 3 4969 NULL
114894 +skb_network_header_len_4971 skb_network_header_len 0 4971 NULL
114895 +ieee80211_if_fmt_dot11MeshHWMPconfirmationInterval_4976 ieee80211_if_fmt_dot11MeshHWMPconfirmationInterval 3 4976 NULL
114896 +do_sync_read_4977 do_sync_read 0 4977 NULL
114897 +compat_SyS_ipc_5000 compat_SyS_ipc 3 5000 NULL
114898 +mthca_dev_lim_5009 mthca_dev_lim 0 5009 NULL
114899 +do_mincore_5018 do_mincore 0-2-1 5018 NULL
114900 +btrfs_punch_hole_5041 btrfs_punch_hole 2 5041 NULL
114901 +cfg80211_rx_mgmt_5056 cfg80211_rx_mgmt 5 5056 NULL
114902 +ocfs2_check_range_for_holes_5066 ocfs2_check_range_for_holes 2-3 5066 NULL
114903 +snd_mixart_BA1_read_5082 snd_mixart_BA1_read 5 5082 NULL
114904 +sep_reconfig_shared_area_5085 sep_reconfig_shared_area 0 5085 NULL
114905 +snd_emu10k1_ptr20_read_5087 snd_emu10k1_ptr20_read 0 5087 NULL
114906 +kfifo_copy_from_user_5091 kfifo_copy_from_user 3-4-0 5091 NULL nohasharray
114907 +get_random_bytes_5091 get_random_bytes 2 5091 &kfifo_copy_from_user_5091 nohasharray
114908 +blk_rq_sectors_5091 blk_rq_sectors 0 5091 &get_random_bytes_5091
114909 +sound_write_5102 sound_write 3 5102 NULL
114910 +alloc_init_skbufs_5109 alloc_init_skbufs 0 5109 NULL
114911 +i40e_dbg_netdev_ops_write_5117 i40e_dbg_netdev_ops_write 3 5117 NULL
114912 +qib_7220_handle_hwerrors_5142 qib_7220_handle_hwerrors 3 5142 NULL
114913 +ocfs2_inode_lock_full_nested_5148 ocfs2_inode_lock_full_nested 0 5148 NULL
114914 +__uwb_addr_print_5161 __uwb_addr_print 2 5161 NULL
114915 +iwl_dbgfs_status_read_5171 iwl_dbgfs_status_read 3 5171 NULL nohasharray
114916 +ec_bhf_setup_offsets_5171 ec_bhf_setup_offsets 0 5171 &iwl_dbgfs_status_read_5171
114917 +acpi_pcc_get_sqty_5176 acpi_pcc_get_sqty 0 5176 NULL
114918 +trf7970a_read_cont_5179 trf7970a_read_cont 4 5179 NULL
114919 +b44_alloc_consistent_5200 b44_alloc_consistent 0 5200 NULL
114920 +ath10k_download_board_data_5203 ath10k_download_board_data 0 5203 NULL
114921 +ppp_cp_parse_cr_5214 ppp_cp_parse_cr 4 5214 NULL
114922 +dwc2_hcd_urb_alloc_5217 dwc2_hcd_urb_alloc 2 5217 NULL
114923 +ath6kl_debug_roam_tbl_event_5224 ath6kl_debug_roam_tbl_event 3 5224 NULL
114924 +hpsa_request_irq_5254 hpsa_request_irq 0 5254 NULL
114925 +usb_descriptor_fillbuf_5302 usb_descriptor_fillbuf 0 5302 NULL
114926 +t4vf_write_rss_vi_config_5304 t4vf_write_rss_vi_config 0 5304 NULL
114927 +r592_write_fifo_pio_5315 r592_write_fifo_pio 3 5315 NULL
114928 +sbc_get_write_same_sectors_5317 sbc_get_write_same_sectors 0 5317 NULL
114929 +pwr_elp_enter_read_5324 pwr_elp_enter_read 3 5324 NULL
114930 +uinput_ioctl_5342 uinput_ioctl 2 5342 NULL
114931 +ad714x_i2c_read_5345 ad714x_i2c_read 4 5345 NULL
114932 +ata_tlink_add_5349 ata_tlink_add 0 5349 NULL
114933 +cq_free_res_5355 cq_free_res 5 5355 NULL
114934 +ps_pspoll_utilization_read_5361 ps_pspoll_utilization_read 3 5361 NULL
114935 +cciss_allocate_sg_chain_blocks_5368 cciss_allocate_sg_chain_blocks 3-2 5368 NULL
114936 +bma180_set_pmode_5389 bma180_set_pmode 0 5389 NULL
114937 +xfs_free_extent_5411 xfs_free_extent 0 5411 NULL
114938 +xfs_efd_init_5463 xfs_efd_init 3 5463 NULL
114939 +ll_xattr_cache_refill_5468 ll_xattr_cache_refill 0 5468 NULL
114940 +kernfs_fop_write_5471 kernfs_fop_write 3 5471 NULL
114941 +xfs_efi_init_5476 xfs_efi_init 2 5476 NULL
114942 +pci_enable_msix_exact_5482 pci_enable_msix_exact 3-0 5482 NULL
114943 +il4965_eeprom_check_version_5483 il4965_eeprom_check_version 0 5483 NULL
114944 +cifs_security_flags_proc_write_5484 cifs_security_flags_proc_write 3 5484 NULL
114945 +tty_write_5494 tty_write 3 5494 NULL
114946 +tomoyo_update_domain_5498 tomoyo_update_domain 2 5498 NULL nohasharray
114947 +ieee80211_if_fmt_last_beacon_5498 ieee80211_if_fmt_last_beacon 3 5498 &tomoyo_update_domain_5498
114948 +ath10k_init_uart_5501 ath10k_init_uart 0 5501 NULL
114949 +__max_nr_grant_frames_5505 __max_nr_grant_frames 0 5505 NULL
114950 +tg3_phy_probe_5517 tg3_phy_probe 0 5517 NULL
114951 +ieee80211_if_fmt_auto_open_plinks_5534 ieee80211_if_fmt_auto_open_plinks 3 5534 NULL nohasharray
114952 +typhoon_reset_5534 typhoon_reset 0 5534 &ieee80211_if_fmt_auto_open_plinks_5534
114953 +get_entry_msg_len_5552 get_entry_msg_len 0 5552 NULL
114954 +le_readq_5557 le_readq 0 5557 NULL
114955 +inw_5558 inw 0 5558 NULL
114956 +gfs2_extent_map_5561 gfs2_extent_map 0 5561 NULL
114957 +ace_load_firmware_5577 ace_load_firmware 0 5577 NULL
114958 +bioset_create_5580 bioset_create 1 5580 NULL
114959 +oz_ep_alloc_5587 oz_ep_alloc 1 5587 NULL
114960 +__remove_suid_5618 __remove_suid 0 5618 NULL
114961 +gfs2_unstuffer_page_5620 gfs2_unstuffer_page 0 5620 NULL
114962 +enic_set_nic_cfg_5628 enic_set_nic_cfg 0 5628 NULL
114963 +SYSC_fsetxattr_5639 SYSC_fsetxattr 4 5639 NULL
114964 +usb_enumerate_device_otg_5648 usb_enumerate_device_otg 0 5648 NULL
114965 +ext4_xattr_get_5661 ext4_xattr_get 0 5661 NULL
114966 +posix_clock_register_5662 posix_clock_register 2 5662 NULL
114967 +clk_prepare_5663 clk_prepare 0 5663 NULL
114968 +stmmac_init_rx_buffers_5673 stmmac_init_rx_buffers 0 5673 NULL
114969 +smsc911x_mii_init_5692 smsc911x_mii_init 0 5692 NULL
114970 +get_arg_5694 get_arg 3 5694 NULL
114971 +subbuf_read_actor_5708 subbuf_read_actor 3 5708 NULL
114972 +vmw_kms_readback_5727 vmw_kms_readback 6 5727 NULL
114973 +rts51x_transfer_data_partial_5735 rts51x_transfer_data_partial 6 5735 NULL
114974 +mtip_dma_alloc_5757 mtip_dma_alloc 0 5757 NULL
114975 +sctp_setsockopt_autoclose_5775 sctp_setsockopt_autoclose 3 5775 NULL
114976 +__vxge_hw_blockpool_malloc_5786 __vxge_hw_blockpool_malloc 2 5786 NULL
114977 +lpfc_sli_issue_mbox_5792 lpfc_sli_issue_mbox 0 5792 NULL
114978 +nvme_trans_bdev_char_page_5797 nvme_trans_bdev_char_page 3 5797 NULL
114979 +skb_copy_datagram_iovec_5806 skb_copy_datagram_iovec 2-4 5806 NULL
114980 +nv50_disp_pioc_create__5812 nv50_disp_pioc_create_ 5 5812 NULL
114981 +ceph_x_encrypt_buflen_5829 ceph_x_encrypt_buflen 0-1 5829 NULL
114982 +ceph_msg_new_5846 ceph_msg_new 2 5846 NULL
114983 +setup_req_5848 setup_req 3 5848 NULL
114984 +ria_page_count_5849 ria_page_count 0 5849 NULL
114985 +rx_filter_max_arp_queue_dep_read_5851 rx_filter_max_arp_queue_dep_read 3 5851 NULL
114986 +uinput_compat_ioctl_5861 uinput_compat_ioctl 2 5861 NULL
114987 +config_buf_5862 config_buf 0 5862 NULL
114988 +lprocfs_fid_width_seq_write_5889 lprocfs_fid_width_seq_write 3 5889 NULL
114989 +port_show_regs_5904 port_show_regs 3 5904 NULL
114990 +rbd_segment_length_5907 rbd_segment_length 0-3-2 5907 NULL
114991 +uhci_debug_read_5911 uhci_debug_read 3 5911 NULL
114992 +ntb_setup_intx_5930 ntb_setup_intx 0 5930 NULL
114993 +lbs_highsnr_read_5931 lbs_highsnr_read 3 5931 NULL
114994 +ps_poll_ps_poll_timeouts_read_5934 ps_poll_ps_poll_timeouts_read 3 5934 NULL
114995 +edac_device_alloc_ctl_info_5941 edac_device_alloc_ctl_info 1 5941 NULL
114996 +ngene_i2c_init_5946 ngene_i2c_init 0 5946 NULL
114997 +ll_statahead_one_5962 ll_statahead_one 3 5962 NULL
114998 +__apu_get_register_5967 __apu_get_register 0 5967 NULL
114999 +ieee80211_if_fmt_rc_rateidx_mask_5ghz_5971 ieee80211_if_fmt_rc_rateidx_mask_5ghz 3 5971 NULL
115000 +SyS_semop_5980 SyS_semop 3 5980 NULL
115001 +snd_opl3_hwdep_new_6008 snd_opl3_hwdep_new 0 6008 NULL
115002 +da9052_request_irq_6058 da9052_request_irq 2 6058 NULL
115003 +alloc_msg_6072 alloc_msg 1 6072 NULL
115004 +sctp_setsockopt_connectx_6073 sctp_setsockopt_connectx 3 6073 NULL
115005 +rts51x_ms_rw_multi_sector_6076 rts51x_ms_rw_multi_sector 3-4 6076 NULL
115006 +pt1_reset_pci_6085 pt1_reset_pci 0 6085 NULL
115007 +__mnt_want_write_6091 __mnt_want_write 0 6091 NULL
115008 +ipmi_addr_length_6110 ipmi_addr_length 0 6110 NULL nohasharray
115009 +force_static_address_read_6110 force_static_address_read 3 6110 &ipmi_addr_length_6110
115010 +dfs_global_file_write_6112 dfs_global_file_write 3 6112 NULL
115011 +nouveau_parent_create__6131 nouveau_parent_create_ 7 6131 NULL
115012 +ieee80211_if_fmt_beacon_timeout_6153 ieee80211_if_fmt_beacon_timeout 3 6153 NULL
115013 +ivtv_copy_buf_to_user_6159 ivtv_copy_buf_to_user 4 6159 NULL
115014 +maybe_insert_hole_6167 maybe_insert_hole 3 6167 NULL
115015 +myri10ge_load_firmware_6168 myri10ge_load_firmware 0 6168 NULL
115016 +wl1251_cmd_template_set_6172 wl1251_cmd_template_set 4 6172 NULL
115017 +SyS_setgroups_6182 SyS_setgroups 1 6182 NULL
115018 +mxt_show_instance_6207 mxt_show_instance 2-0 6207 NULL
115019 +v4l2_ctrl_new_std_menu_6221 v4l2_ctrl_new_std_menu 4 6221 NULL
115020 +mqueue_read_file_6228 mqueue_read_file 3 6228 NULL
115021 +ata_host_register_6229 ata_host_register 0 6229 NULL
115022 +__clk_prepare_6234 __clk_prepare 0 6234 NULL
115023 +f_hidg_read_6238 f_hidg_read 3 6238 NULL
115024 +fbcon_prepare_logo_6246 fbcon_prepare_logo 5 6246 NULL
115025 +of_gpio_count_6270 of_gpio_count 0 6270 NULL
115026 +tx_tx_start_null_frame_read_6281 tx_tx_start_null_frame_read 3 6281 NULL
115027 +snd_hda_override_conn_list_6282 snd_hda_override_conn_list 3-0 6282 NULL nohasharray
115028 +xenbus_file_write_6282 xenbus_file_write 3 6282 &snd_hda_override_conn_list_6282
115029 +posix_acl_fix_xattr_to_user_6283 posix_acl_fix_xattr_to_user 2 6283 NULL
115030 +serial_port_in_6291 serial_port_in 0 6291 NULL
115031 +qlcnic_sriov_alloc_bc_msg_6309 qlcnic_sriov_alloc_bc_msg 2 6309 NULL
115032 +ieee80211_init_rate_ctrl_alg_6322 ieee80211_init_rate_ctrl_alg 0 6322 NULL
115033 +hfa384x_inw_6329 hfa384x_inw 0 6329 NULL nohasharray
115034 +SyS_mincore_6329 SyS_mincore 1-2 6329 &hfa384x_inw_6329
115035 +fuse_get_req_for_background_6337 fuse_get_req_for_background 2 6337 NULL
115036 +ucs2_strnlen_6342 ucs2_strnlen 0 6342 NULL
115037 +regcache_sync_block_raw_6350 regcache_sync_block_raw 5-4 6350 NULL
115038 +mei_dbgfs_read_devstate_6352 mei_dbgfs_read_devstate 3 6352 NULL
115039 +netdev_queue_add_kobject_6375 netdev_queue_add_kobject 0 6375 NULL
115040 +_proc_do_string_6376 _proc_do_string 2 6376 NULL
115041 +osd_req_read_sg_kern_6378 osd_req_read_sg_kern 5 6378 NULL
115042 +gfs2_dir_read_stuffed_6380 gfs2_dir_read_stuffed 3 6380 NULL
115043 +xfs_bmap_extents_to_btree_6387 xfs_bmap_extents_to_btree 0 6387 NULL
115044 +posix_acl_fix_xattr_userns_6420 posix_acl_fix_xattr_userns 4 6420 NULL
115045 +add_transaction_credits_6422 add_transaction_credits 2-3 6422 NULL
115046 +ipr_change_queue_depth_6431 ipr_change_queue_depth 2 6431 NULL
115047 +__alloc_bootmem_node_nopanic_6432 __alloc_bootmem_node_nopanic 2 6432 NULL
115048 +t4_cfg_pfvf_6440 t4_cfg_pfvf 0 6440 NULL
115049 +C_SYSC_vmsplice_6470 C_SYSC_vmsplice 3 6470 NULL
115050 +ieee80211_if_fmt_dot11MeshMaxRetries_6476 ieee80211_if_fmt_dot11MeshMaxRetries 3 6476 NULL
115051 +qp_memcpy_from_queue_6479 qp_memcpy_from_queue 5-4 6479 NULL
115052 +cipso_v4_map_lvl_hton_6490 cipso_v4_map_lvl_hton 0 6490 NULL
115053 +dvb_dmxdev_init_6496 dvb_dmxdev_init 0 6496 NULL
115054 +dbg_intr_buf_6501 dbg_intr_buf 2 6501 NULL
115055 +mei_read_6507 mei_read 3 6507 NULL
115056 +rndis_set_oid_6547 rndis_set_oid 4 6547 NULL
115057 +wdm_read_6549 wdm_read 3 6549 NULL
115058 +dm_stats_create_6551 dm_stats_create 4-2-3 6551 NULL
115059 +fb_alloc_cmap_6554 fb_alloc_cmap 2 6554 NULL
115060 +SyS_semtimedop_6563 SyS_semtimedop 3 6563 NULL
115061 +xfs_iozero_6573 xfs_iozero 0 6573 NULL
115062 +snd_pcm_hw_refine_old_user_6586 snd_pcm_hw_refine_old_user 0 6586 NULL
115063 +ecryptfs_filldir_6622 ecryptfs_filldir 3 6622 NULL
115064 +dvb_dmx_init_6631 dvb_dmx_init 0 6631 NULL
115065 +xfs_do_div_6649 xfs_do_div 0-2 6649 NULL
115066 +process_rcvd_data_6679 process_rcvd_data 3 6679 NULL
115067 +pvscsi_allocate_rings_6689 pvscsi_allocate_rings 0 6689 NULL
115068 +btrfs_lookup_csums_range_6696 btrfs_lookup_csums_range 2-3 6696 NULL
115069 +ps_pspoll_max_apturn_read_6699 ps_pspoll_max_apturn_read 3 6699 NULL
115070 +bnad_debugfs_write_regrd_6706 bnad_debugfs_write_regrd 3 6706 NULL
115071 +mpeg_read_6708 mpeg_read 3 6708 NULL
115072 +ibmpex_query_sensor_count_6709 ibmpex_query_sensor_count 0 6709 NULL
115073 +video_proc_write_6724 video_proc_write 3 6724 NULL nohasharray
115074 +dwc2_hs_phy_init_6724 dwc2_hs_phy_init 0 6724 &video_proc_write_6724
115075 +posix_acl_xattr_count_6725 posix_acl_xattr_count 0-1 6725 NULL
115076 +ocfs2_insert_extent_6737 ocfs2_insert_extent 0 6737 NULL
115077 +t4_sge_init_6743 t4_sge_init 0 6743 NULL
115078 +kobject_add_varg_6781 kobject_add_varg 0 6781 NULL
115079 +iwl_dbgfs_channels_read_6784 iwl_dbgfs_channels_read 3 6784 NULL
115080 +ieee80211_if_read_6785 ieee80211_if_read 3 6785 NULL
115081 +zone_spanned_pages_in_node_6787 zone_spanned_pages_in_node 0-3-4 6787 NULL
115082 +hdlcdrv_register_6792 hdlcdrv_register 2 6792 NULL
115083 +ll_xattr_cache_find_6798 ll_xattr_cache_find 0 6798 NULL
115084 +tx_tx_done_data_read_6799 tx_tx_done_data_read 3 6799 NULL
115085 +ocfs2_calc_refcount_meta_credits_6802 ocfs2_calc_refcount_meta_credits 0 6802 NULL
115086 +lbs_rdrf_write_6826 lbs_rdrf_write 3 6826 NULL
115087 +calc_pages_for_6838 calc_pages_for 0-2-1 6838 NULL
115088 +mon_bin_read_6841 mon_bin_read 3 6841 NULL
115089 +snd_cs4281_BA0_read_6847 snd_cs4281_BA0_read 5 6847 NULL
115090 +xfs_rtany_summary_6851 xfs_rtany_summary 0 6851 NULL
115091 +as3722_gpio_to_irq_6861 as3722_gpio_to_irq 2 6861 NULL
115092 +perf_output_sample_ustack_6868 perf_output_sample_ustack 2 6868 NULL
115093 +ecryptfs_write_lower_6870 ecryptfs_write_lower 4 6870 NULL
115094 +p54_init_leds_6872 p54_init_leds 0 6872 NULL
115095 +dio_complete_6879 dio_complete 0-3-2 6879 NULL
115096 +raw_seticmpfilter_6888 raw_seticmpfilter 3 6888 NULL nohasharray
115097 +ieee80211_if_fmt_path_refresh_time_6888 ieee80211_if_fmt_path_refresh_time 3 6888 &raw_seticmpfilter_6888
115098 +dlmfs_file_write_6892 dlmfs_file_write 3 6892 NULL
115099 +proc_sessionid_read_6911 proc_sessionid_read 3 6911 NULL nohasharray
115100 +spi_show_regs_6911 spi_show_regs 3 6911 &proc_sessionid_read_6911 nohasharray
115101 +acm_alloc_minor_6911 acm_alloc_minor 0 6911 &spi_show_regs_6911
115102 +__kfifo_dma_in_finish_r_6913 __kfifo_dma_in_finish_r 2-3 6913 NULL
115103 +lops_scan_elements_6916 lops_scan_elements 0 6916 NULL
115104 +do_msgrcv_6921 do_msgrcv 3 6921 NULL
115105 +cache_do_downcall_6926 cache_do_downcall 3 6926 NULL
115106 +ipath_verbs_send_dma_6929 ipath_verbs_send_dma 6 6929 NULL
115107 +qsfp_cks_6945 qsfp_cks 2-0 6945 NULL
115108 +ab3100_get_register_page_interruptible_6951 ab3100_get_register_page_interruptible 4 6951 NULL
115109 +tg3_nvram_write_block_unbuffered_6955 tg3_nvram_write_block_unbuffered 3 6955 NULL
115110 +start_tx_6960 start_tx 0 6960 NULL
115111 +pch_uart_hal_read_6961 pch_uart_hal_read 0 6961 NULL
115112 +rsa_extract_mpi_6973 rsa_extract_mpi 5 6973 NULL nohasharray
115113 +i40e_dbg_dump_write_6973 i40e_dbg_dump_write 3 6973 &rsa_extract_mpi_6973
115114 +request_key_async_6990 request_key_async 4 6990 NULL
115115 +tpl_write_6998 tpl_write 3 6998 NULL
115116 +r871x_set_wpa_ie_7000 r871x_set_wpa_ie 3 7000 NULL
115117 +cipso_v4_gentag_enum_7006 cipso_v4_gentag_enum 0 7006 NULL
115118 +tracing_cpumask_read_7010 tracing_cpumask_read 3 7010 NULL
115119 +va1j5jf8007t_prepare_7021 va1j5jf8007t_prepare 0 7021 NULL
115120 +ld_usb_write_7022 ld_usb_write 3 7022 NULL
115121 +cx18_setup_pci_7025 cx18_setup_pci 0 7025 NULL
115122 +wimax_msg_7030 wimax_msg 4 7030 NULL
115123 +ceph_kvmalloc_7033 ceph_kvmalloc 1 7033 NULL
115124 +ipath_get_base_info_7043 ipath_get_base_info 3 7043 NULL
115125 +snd_pcm_oss_bytes_7051 snd_pcm_oss_bytes 2 7051 NULL
115126 +nouveau_device_create__7063 nouveau_device_create_ 7 7063 NULL
115127 +hci_sock_recvmsg_7072 hci_sock_recvmsg 4 7072 NULL
115128 +event_enable_read_7074 event_enable_read 3 7074 NULL
115129 +tipc_send_packet_7091 tipc_send_packet 4 7091 NULL nohasharray
115130 +beacon_interval_read_7091 beacon_interval_read 3 7091 &tipc_send_packet_7091
115131 +pipeline_enc_rx_stat_fifo_int_read_7107 pipeline_enc_rx_stat_fifo_int_read 3 7107 NULL
115132 +osc_resend_count_seq_write_7120 osc_resend_count_seq_write 3 7120 NULL
115133 +qib_format_hwerrors_7133 qib_format_hwerrors 5 7133 NULL
115134 +kvm_mmu_notifier_test_young_7139 kvm_mmu_notifier_test_young 3 7139 NULL
115135 +qlcnic_enable_msix_7144 qlcnic_enable_msix 2 7144 NULL
115136 +ocfs2_get_left_path_7159 ocfs2_get_left_path 0 7159 NULL
115137 +core_alua_write_tpg_metadata_7168 core_alua_write_tpg_metadata 3 7168 NULL
115138 +__alloc_objio_seg_7203 __alloc_objio_seg 1 7203 NULL
115139 +usb_add_gadget_udc_7218 usb_add_gadget_udc 0 7218 NULL
115140 +regulator_bulk_get_7220 regulator_bulk_get 0 7220 NULL
115141 +pch_uart_hal_set_fifo_7242 pch_uart_hal_set_fifo 0 7242 NULL
115142 +get_param_h_7247 get_param_h 0 7247 NULL
115143 +hdlc_loop_7255 hdlc_loop 0 7255 NULL
115144 +cx18_streams_register_7266 cx18_streams_register 0 7266 NULL
115145 +f_midi_start_ep_7270 f_midi_start_ep 0 7270 NULL
115146 +dma_ops_alloc_addresses_7272 dma_ops_alloc_addresses 3-4-0 7272 NULL
115147 +mwifiex_init_txq_ring_7281 mwifiex_init_txq_ring 0 7281 NULL
115148 +rx_rate_rx_frames_per_rates_read_7282 rx_rate_rx_frames_per_rates_read 3 7282 NULL
115149 +get_string_7302 get_string 0 7302 NULL
115150 +bcm2048_set_fm_frequency_7314 bcm2048_set_fm_frequency 0 7314 NULL
115151 +security_inode_need_killpriv_7322 security_inode_need_killpriv 0 7322 NULL
115152 +pci_vpd_info_field_size_7324 pci_vpd_info_field_size 0 7324 NULL
115153 +wait_on_sync_kiocb_7327 wait_on_sync_kiocb 0 7327 NULL
115154 +mgmt_control_7349 mgmt_control 3 7349 NULL
115155 +at_est2timeout_7365 at_est2timeout 0-1 7365 NULL
115156 +ieee80211_if_read_dot11MeshHWMPactivePathTimeout_7368 ieee80211_if_read_dot11MeshHWMPactivePathTimeout 3 7368 NULL
115157 +xfs_btree_delete_7384 xfs_btree_delete 0 7384 NULL
115158 +ath10k_read_fw_stats_7387 ath10k_read_fw_stats 3 7387 NULL
115159 +hweight_long_7388 hweight_long 0-1 7388 NULL
115160 +sl_change_mtu_7396 sl_change_mtu 2 7396 NULL
115161 +ar5008_hw_attach_phy_ops_7397 ar5008_hw_attach_phy_ops 0 7397 NULL
115162 +_ore_add_stripe_unit_7399 _ore_add_stripe_unit 6-3 7399 NULL
115163 +audmux_read_file_7400 audmux_read_file 3 7400 NULL
115164 +readb_7401 readb 0 7401 NULL
115165 +tipc_recvmsg_7402 tipc_recvmsg 4 7402 NULL
115166 +drm_property_create_blob_7414 drm_property_create_blob 2 7414 NULL
115167 +spi_setup_7442 spi_setup 0 7442 NULL
115168 +__copy_to_user_nocheck_7443 __copy_to_user_nocheck 0-3 7443 NULL
115169 +ip_options_get_alloc_7448 ip_options_get_alloc 1 7448 NULL
115170 +dac33_read_7450 dac33_read 0 7450 NULL
115171 +SYSC_setgroups_7454 SYSC_setgroups 1 7454 NULL
115172 +rt2x00debug_read_queue_stats_7455 rt2x00debug_read_queue_stats 3 7455 NULL
115173 +mtip_read_log_page_7459 mtip_read_log_page 0 7459 NULL
115174 +l2tp_ip6_sendmsg_7461 l2tp_ip6_sendmsg 4 7461 NULL
115175 +garp_request_join_7471 garp_request_join 4 7471 NULL nohasharray
115176 +ReadHSCX_7471 ReadHSCX 0 7471 &garp_request_join_7471
115177 +snd_pcm_lib_read1_7491 snd_pcm_lib_read1 0-3 7491 NULL
115178 +__padata_add_cpu_7497 __padata_add_cpu 0 7497 NULL
115179 +ahash_instance_headroom_7509 ahash_instance_headroom 0 7509 NULL nohasharray
115180 +sdhci_alloc_host_7509 sdhci_alloc_host 2 7509 &ahash_instance_headroom_7509
115181 +ll_recv_msg_7510 ll_recv_msg 0 7510 NULL
115182 +jump_label_add_module_7513 jump_label_add_module 0 7513 NULL
115183 +array_zalloc_7519 array_zalloc 1-2 7519 NULL
115184 +tg3_writephy_7522 tg3_writephy 0 7522 NULL
115185 +sk_convert_filter_7541 sk_convert_filter 2 7541 NULL
115186 +ath10k_read_htt_stats_mask_7557 ath10k_read_htt_stats_mask 3 7557 NULL
115187 +smk_read_mapped_7562 smk_read_mapped 3 7562 NULL
115188 +netvsc_get_slots_7565 netvsc_get_slots 0 7565 NULL
115189 +cfs_cpt_num_estimate_7571 cfs_cpt_num_estimate 0 7571 NULL
115190 +ocfs2_lock_create_7612 ocfs2_lock_create 0 7612 NULL
115191 +groups_alloc_7614 groups_alloc 1 7614 NULL nohasharray
115192 +create_dir_7614 create_dir 0 7614 &groups_alloc_7614
115193 +send_to_group_7627 send_to_group 0 7627 NULL
115194 +_rtw_zmalloc_7636 _rtw_zmalloc 1 7636 NULL
115195 +xfs_bmap_btalloc_nullfb_7654 xfs_bmap_btalloc_nullfb 0 7654 NULL
115196 +msnd_register_7656 msnd_register 0 7656 NULL
115197 +fault_inject_write_7662 fault_inject_write 3 7662 NULL
115198 +acpi_ex_allocate_name_string_7685 acpi_ex_allocate_name_string 2-1 7685 NULL
115199 +acpi_ns_get_pathname_length_7699 acpi_ns_get_pathname_length 0 7699 NULL
115200 +dev_write_7708 dev_write 3 7708 NULL
115201 +pci_raw_set_power_state_7729 pci_raw_set_power_state 0 7729 NULL
115202 +vxge_device_register_7752 vxge_device_register 4 7752 NULL
115203 +ubi_io_read_vid_hdr_7766 ubi_io_read_vid_hdr 0 7766 NULL
115204 +iwl_dbgfs_bt_cmd_read_7770 iwl_dbgfs_bt_cmd_read 3 7770 NULL
115205 +alloc_candev_7776 alloc_candev 1-2 7776 NULL
115206 +dfs_global_file_read_7787 dfs_global_file_read 3 7787 NULL
115207 +bnx2_nvram_write_7790 bnx2_nvram_write 4-2 7790 NULL
115208 +diva_os_copy_from_user_7792 diva_os_copy_from_user 4 7792 NULL nohasharray
115209 +lustre_packed_msg_size_7792 lustre_packed_msg_size 0 7792 &diva_os_copy_from_user_7792
115210 +xfs_alloc_find_best_extent_7837 xfs_alloc_find_best_extent 0 7837 NULL
115211 +be_mcc_wait_compl_7854 be_mcc_wait_compl 0 7854 NULL
115212 +cfs_trace_dump_debug_buffer_usrstr_7861 cfs_trace_dump_debug_buffer_usrstr 2 7861 NULL
115213 +tipc_alloc_entry_7875 tipc_alloc_entry 2 7875 NULL nohasharray
115214 +t4_sge_alloc_ctrl_txq_7875 t4_sge_alloc_ctrl_txq 0 7875 &tipc_alloc_entry_7875
115215 +config_desc_7878 config_desc 0 7878 NULL
115216 +gfs2_permission_7884 gfs2_permission 0 7884 NULL
115217 +dvb_dmxdev_read_sec_7892 dvb_dmxdev_read_sec 4 7892 NULL
115218 +xfs_trans_get_efi_7898 xfs_trans_get_efi 2 7898 NULL
115219 +libfc_host_alloc_7917 libfc_host_alloc 2 7917 NULL
115220 +f_hidg_write_7932 f_hidg_write 3 7932 NULL
115221 +fsnotify_7943 fsnotify 0 7943 NULL
115222 +integrity_digsig_verify_7956 integrity_digsig_verify 3-0 7956 NULL
115223 +clk_set_rate_7957 clk_set_rate 0 7957 NULL
115224 +smk_write_load_self_7958 smk_write_load_self 3 7958 NULL
115225 +spu_get_chip_revision_7993 spu_get_chip_revision 0 7993 NULL
115226 +mthca_QUERY_DEV_LIM_8009 mthca_QUERY_DEV_LIM 0 8009 NULL
115227 +tt3650_ci_msg_locked_8013 tt3650_ci_msg_locked 4 8013 NULL
115228 +vcs_read_8017 vcs_read 3 8017 NULL
115229 +vhost_add_used_and_signal_n_8038 vhost_add_used_and_signal_n 4 8038 NULL
115230 +ms_read_multiple_pages_8052 ms_read_multiple_pages 5-4 8052 NULL
115231 +msm_gpio_to_irq_8053 msm_gpio_to_irq 2 8053 NULL
115232 +dgrp_mon_read_8065 dgrp_mon_read 3 8065 NULL
115233 +spi_write_then_read_8073 spi_write_then_read 5-3 8073 NULL
115234 +qla4xxx_post_ping_evt_work_8074 qla4xxx_post_ping_evt_work 4 8074 NULL
115235 +ext2_commit_chunk_8097 ext2_commit_chunk 3 8097 NULL
115236 +venus_lookup_8121 venus_lookup 4 8121 NULL
115237 +ieee80211_if_fmt_num_buffered_multicast_8127 ieee80211_if_fmt_num_buffered_multicast 3 8127 NULL
115238 +xfs_file_fallocate_8150 xfs_file_fallocate 3-4 8150 NULL
115239 +dscc4_set_quartz_8173 dscc4_set_quartz 0 8173 NULL
115240 +dma_map_area_8178 dma_map_area 2-3-5-0 8178 NULL
115241 +__sk_mem_schedule_8185 __sk_mem_schedule 2 8185 NULL
115242 +ieee80211_if_fmt_dot11MeshHoldingTimeout_8187 ieee80211_if_fmt_dot11MeshHoldingTimeout 3 8187 NULL
115243 +recent_mt_proc_write_8206 recent_mt_proc_write 3 8206 NULL
115244 +__ocfs2_lock_refcount_tree_8207 __ocfs2_lock_refcount_tree 0 8207 NULL
115245 +rt2x00debug_write_bbp_8212 rt2x00debug_write_bbp 3 8212 NULL
115246 +ad7879_spi_multi_read_8218 ad7879_spi_multi_read 3 8218 NULL
115247 +play_iframe_8219 play_iframe 3 8219 NULL
115248 +kvm_mmu_page_set_gfn_8225 kvm_mmu_page_set_gfn 2 8225 NULL
115249 +sctp_ssnmap_size_8228 sctp_ssnmap_size 0-1-2 8228 NULL
115250 +fnic_dev_mac_addr_8234 fnic_dev_mac_addr 0 8234 NULL
115251 +check_xattr_ref_inode_8244 check_xattr_ref_inode 0 8244 NULL
115252 +mvumi_io_attach_8255 mvumi_io_attach 0 8255 NULL
115253 +t3_init_l2t_8261 t3_init_l2t 1 8261 NULL
115254 +init_cdev_8274 init_cdev 1 8274 NULL
115255 +rproc_recovery_write_8281 rproc_recovery_write 3 8281 NULL
115256 +controller_reset_failed_8304 controller_reset_failed 0 8304 NULL
115257 +qib_decode_7220_err_8315 qib_decode_7220_err 3 8315 NULL
115258 +snd_pcm_update_state_8320 snd_pcm_update_state 0 8320 NULL
115259 +ipwireless_send_packet_8328 ipwireless_send_packet 4 8328 NULL
115260 +rtw_cfg80211_rx_action_8329 rtw_cfg80211_rx_action 3 8329 NULL
115261 +tracing_entries_read_8345 tracing_entries_read 3 8345 NULL
115262 +ieee80211_if_fmt_ht_opmode_8347 ieee80211_if_fmt_ht_opmode 3 8347 NULL
115263 +open_candev_8354 open_candev 0 8354 NULL
115264 +generic_write_sync_8358 generic_write_sync 0 8358 NULL
115265 +ping_getfrag_8360 ping_getfrag 4-3 8360 NULL
115266 +ath6kl_lrssi_roam_write_8362 ath6kl_lrssi_roam_write 3 8362 NULL
115267 +ocfs2_decrease_refcount_rec_8385 ocfs2_decrease_refcount_rec 0 8385 NULL
115268 +xdi_copy_from_user_8395 xdi_copy_from_user 4 8395 NULL
115269 +zd_rf_scnprint_id_8406 zd_rf_scnprint_id 0-3 8406 NULL
115270 +smk_write_change_rule_8411 smk_write_change_rule 3 8411 NULL nohasharray
115271 +uvc_v4l2_ioctl_8411 uvc_v4l2_ioctl 2 8411 &smk_write_change_rule_8411
115272 +pca953x_gpio_to_irq_8424 pca953x_gpio_to_irq 2 8424 NULL
115273 +myri10ge_alloc_slices_8426 myri10ge_alloc_slices 0 8426 NULL
115274 +spi_master_initialize_queue_8430 spi_master_initialize_queue 0 8430 NULL
115275 +roccat_common2_sysfs_read_8431 roccat_common2_sysfs_read 6 8431 NULL
115276 +irq_create_mapping_8437 irq_create_mapping 0-2 8437 NULL
115277 +afs_cell_lookup_8482 afs_cell_lookup 2 8482 NULL
115278 +fore200e_chunk_alloc_8501 fore200e_chunk_alloc 4-3 8501 NULL
115279 +batadv_tt_len_8502 batadv_tt_len 0-1 8502 NULL
115280 +dev_config_8506 dev_config 3 8506 NULL
115281 +ACL_to_cifs_posix_8509 ACL_to_cifs_posix 3 8509 NULL
115282 +opticon_process_data_packet_8524 opticon_process_data_packet 3 8524 NULL
115283 +de_alloc_rings_8538 de_alloc_rings 0 8538 NULL nohasharray
115284 +spu_read_8538 spu_read 0 8538 &de_alloc_rings_8538
115285 +user_on_off_8552 user_on_off 2 8552 NULL
115286 +profile_remove_8556 profile_remove 3 8556 NULL
115287 +cache_slow_downcall_8570 cache_slow_downcall 2 8570 NULL nohasharray
115288 +pci_msi_check_device_8570 pci_msi_check_device 0 8570 &cache_slow_downcall_8570
115289 +isr_dma0_done_read_8574 isr_dma0_done_read 3 8574 NULL
115290 +tower_write_8580 tower_write 3 8580 NULL
115291 +ocfs2_reserve_local_alloc_bits_8581 ocfs2_reserve_local_alloc_bits 0 8581 NULL
115292 +cfs_cpt_number_8618 cfs_cpt_number 0 8618 NULL
115293 +shash_setkey_unaligned_8620 shash_setkey_unaligned 3 8620 NULL
115294 +xfs_qm_dqattach_locked_8625 xfs_qm_dqattach_locked 0 8625 NULL
115295 +it821x_firmware_command_8628 it821x_firmware_command 3 8628 NULL
115296 +scsi_dma_map_8632 scsi_dma_map 0 8632 NULL
115297 +fuse_send_write_pages_8636 fuse_send_write_pages 0-5 8636 NULL
115298 +mlx5_vzalloc_8663 mlx5_vzalloc 1 8663 NULL
115299 +dio_bio_alloc_8677 dio_bio_alloc 5 8677 NULL
115300 +lbs_bcnmiss_read_8678 lbs_bcnmiss_read 3 8678 NULL
115301 +rproc_trace_read_8686 rproc_trace_read 3 8686 NULL
115302 +skb_frag_size_8695 skb_frag_size 0 8695 NULL
115303 +saa7110_write_block_8701 saa7110_write_block 3 8701 NULL
115304 +arcfb_write_8702 arcfb_write 3 8702 NULL
115305 +i_size_read_8703 i_size_read 0 8703 NULL nohasharray
115306 +init_header_8703 init_header 0 8703 &i_size_read_8703
115307 +HDLC_irq_8709 HDLC_irq 2 8709 NULL
115308 +ctrl_out_8712 ctrl_out 3-5 8712 NULL
115309 +tracing_max_lat_write_8728 tracing_max_lat_write 3 8728 NULL
115310 +jffs2_acl_count_8729 jffs2_acl_count 0-1 8729 NULL
115311 +mem_cgroup_try_charge_8731 mem_cgroup_try_charge 0 8731 NULL
115312 +__create_irqs_8733 __create_irqs 2-0 8733 NULL
115313 +tx_tx_exch_expiry_read_8749 tx_tx_exch_expiry_read 3 8749 NULL
115314 +compound_order_8750 compound_order 0 8750 NULL
115315 +ocfs2_find_path_8754 ocfs2_find_path 0 8754 NULL
115316 +yurex_write_8761 yurex_write 3 8761 NULL
115317 +joydev_compat_ioctl_8765 joydev_compat_ioctl 2 8765 NULL
115318 +kstrtoint_from_user_8778 kstrtoint_from_user 2 8778 NULL
115319 +paging32_prefetch_gpte_8783 paging32_prefetch_gpte 4 8783 NULL
115320 +ext4_try_to_write_inline_data_8785 ext4_try_to_write_inline_data 3-4 8785 NULL
115321 +__bitmap_weight_8796 __bitmap_weight 0-2 8796 NULL
115322 +gfs2_glock_nq_8808 gfs2_glock_nq 0 8808 NULL
115323 +ntfs_commit_pages_after_write_8809 ntfs_commit_pages_after_write 0 8809 NULL
115324 +lpfc_mq_create_8814 lpfc_mq_create 0 8814 NULL
115325 +metronomefb_write_8823 metronomefb_write 3 8823 NULL
115326 +SyS_llistxattr_8824 SyS_llistxattr 3 8824 NULL
115327 +extent_read_full_page_8826 extent_read_full_page 0 8826 NULL nohasharray
115328 +usb_alloc_streams_8826 usb_alloc_streams 0 8826 &extent_read_full_page_8826
115329 +ll_xattr_cache_get_8829 ll_xattr_cache_get 0 8829 NULL
115330 +get_queue_depth_8833 get_queue_depth 0 8833 NULL
115331 +dvb_ringbuffer_pkt_next_8834 dvb_ringbuffer_pkt_next 0-2 8834 NULL
115332 +usb_ep_queue_8839 usb_ep_queue 0 8839 NULL
115333 +iwl_rx_packet_len_8854 iwl_rx_packet_len 0 8854 NULL
115334 +debug_debug1_read_8856 debug_debug1_read 3 8856 NULL
115335 +wa_nep_queue_8858 wa_nep_queue 2 8858 NULL nohasharray
115336 +pci_save_vc_state_8858 pci_save_vc_state 0 8858 &wa_nep_queue_8858
115337 +radeon_drm_ioctl_8875 radeon_drm_ioctl 2 8875 NULL
115338 +compressed_bio_size_8887 compressed_bio_size 0-2 8887 NULL
115339 +ab3100_get_set_reg_8890 ab3100_get_set_reg 3 8890 NULL nohasharray
115340 +tracing_max_lat_read_8890 tracing_max_lat_read 3 8890 &ab3100_get_set_reg_8890
115341 +sdio_max_byte_size_8907 sdio_max_byte_size 0 8907 NULL
115342 +sysfs_merge_group_8917 sysfs_merge_group 0 8917 NULL
115343 +write_file_ani_8918 write_file_ani 3 8918 NULL
115344 +ivtv_setup_pci_8920 ivtv_setup_pci 0 8920 NULL
115345 +layout_commit_8926 layout_commit 3 8926 NULL
115346 +cp2112_hid_get_8933 cp2112_hid_get 4 8933 NULL
115347 +adjust_priv_size_8935 adjust_priv_size 0-1 8935 NULL
115348 +driver_stats_read_8944 driver_stats_read 3 8944 NULL
115349 +t3_init_hw_8947 t3_init_hw 0 8947 NULL
115350 +read_file_tgt_stats_8959 read_file_tgt_stats 3 8959 NULL
115351 +usb_allocate_stream_buffers_8964 usb_allocate_stream_buffers 3 8964 NULL
115352 +qib_qsfp_dump_8966 qib_qsfp_dump 0-3 8966 NULL
115353 +venus_mkdir_8967 venus_mkdir 4 8967 NULL
115354 +vol_cdev_read_8968 vol_cdev_read 3 8968 NULL nohasharray
115355 +seq_open_net_8968 seq_open_net 4 8968 &vol_cdev_read_8968
115356 +bio_integrity_get_tag_8974 bio_integrity_get_tag 3 8974 NULL
115357 +sony_register_touchpad_8981 sony_register_touchpad 2 8981 NULL
115358 +jbd2_journal_blocks_per_page_9004 jbd2_journal_blocks_per_page 0 9004 NULL
115359 +get_pipes_9008 get_pipes 0 9008 NULL
115360 +il_dbgfs_clear_ucode_stats_write_9016 il_dbgfs_clear_ucode_stats_write 3 9016 NULL
115361 +xfs_inobt_get_rec_9023 xfs_inobt_get_rec 0 9023 NULL
115362 +snd_emu10k1_ptr_read_9026 snd_emu10k1_ptr_read 0-2 9026 NULL
115363 +ql_route_initialize_9027 ql_route_initialize 0 9027 NULL
115364 +fd_ioctl_9028 fd_ioctl 3 9028 NULL
115365 +nla_put_9042 nla_put 3 9042 NULL
115366 +sta_tx_latency_stat_header_9050 sta_tx_latency_stat_header 0-3-4 9050 NULL
115367 +snd_emu10k1_synth_copy_from_user_9061 snd_emu10k1_synth_copy_from_user 3-5 9061 NULL
115368 +snd_gus_dram_peek_9062 snd_gus_dram_peek 4 9062 NULL
115369 +gpio_ensure_requested_9063 gpio_ensure_requested 0 9063 NULL
115370 +fib_info_hash_alloc_9075 fib_info_hash_alloc 1 9075 NULL
115371 +create_queues_9088 create_queues 2-3 9088 NULL
115372 +ftdi_prepare_write_buffer_9093 ftdi_prepare_write_buffer 3 9093 NULL
115373 +pci_assign_resource_9105 pci_assign_resource 0 9105 NULL
115374 +adxl34x_spi_read_block_9108 adxl34x_spi_read_block 3 9108 NULL
115375 +caif_stream_sendmsg_9110 caif_stream_sendmsg 4 9110 NULL nohasharray
115376 +gfn_to_rmap_9110 gfn_to_rmap 3-2 9110 &caif_stream_sendmsg_9110 nohasharray
115377 +jhead_scan_9110 jhead_scan 0 9110 &gfn_to_rmap_9110
115378 +udf_direct_IO_9111 udf_direct_IO 4 9111 NULL
115379 +pmcraid_change_queue_depth_9116 pmcraid_change_queue_depth 2 9116 NULL
115380 +apei_resources_merge_9149 apei_resources_merge 0 9149 NULL
115381 +vb2_dma_sg_alloc_9157 vb2_dma_sg_alloc 2 9157 NULL
115382 +dbg_command_buf_9165 dbg_command_buf 2 9165 NULL
115383 +clk_prepare_enable_9166 clk_prepare_enable 0 9166 NULL
115384 +isr_irqs_read_9181 isr_irqs_read 3 9181 NULL
115385 +count_leading_zeros_9183 count_leading_zeros 0 9183 NULL nohasharray
115386 +ni_660x_alloc_mite_rings_9183 ni_660x_alloc_mite_rings 0 9183 &count_leading_zeros_9183
115387 +il3945_hw_set_hw_params_9186 il3945_hw_set_hw_params 0 9186 NULL
115388 +xfs_btree_rshift_9187 xfs_btree_rshift 0 9187 NULL
115389 +altera_swap_ir_9194 altera_swap_ir 2 9194 NULL
115390 +snd_m3_get_pointer_9206 snd_m3_get_pointer 0 9206 NULL
115391 +iwl_dbgfs_frame_stats_read_9211 iwl_dbgfs_frame_stats_read 3 9211 NULL
115392 +virtqueue_add_9217 virtqueue_add 4-5 9217 NULL
115393 +tx_tx_prepared_descs_read_9221 tx_tx_prepared_descs_read 3 9221 NULL
115394 +sctp_getsockopt_delayed_ack_9232 sctp_getsockopt_delayed_ack 2 9232 NULL
115395 +xfs_error_trap_9239 xfs_error_trap 0-1 9239 NULL
115396 +ocfs2_clear_ext_refcount_9256 ocfs2_clear_ext_refcount 0 9256 NULL
115397 +hfsplus_bnode_read_u16_9262 hfsplus_bnode_read_u16 0 9262 NULL
115398 +ocfs2_merge_rec_right_9267 ocfs2_merge_rec_right 0 9267 NULL
115399 +hdpvr_read_9273 hdpvr_read 3 9273 NULL
115400 +flakey_status_9274 flakey_status 5 9274 NULL
115401 +ath9k_eeprom_request_9280 ath9k_eeprom_request 0 9280 NULL
115402 +mlx4_SET_ICM_SIZE_9297 mlx4_SET_ICM_SIZE 0 9297 NULL
115403 +iwl_dbgfs_stations_read_9309 iwl_dbgfs_stations_read 3 9309 NULL
115404 +ceph_sync_setxattr_9310 ceph_sync_setxattr 4 9310 NULL
115405 +ieee80211_if_fmt_txpower_9334 ieee80211_if_fmt_txpower 3 9334 NULL
115406 +nvme_trans_fmt_get_parm_header_9340 nvme_trans_fmt_get_parm_header 2 9340 NULL
115407 +ocfs2_orphan_for_truncate_9342 ocfs2_orphan_for_truncate 4 9342 NULL
115408 +ll_direct_rw_pages_9361 ll_direct_rw_pages 0 9361 NULL
115409 +sta_beacon_loss_count_read_9370 sta_beacon_loss_count_read 3 9370 NULL
115410 +mlx4_bitmap_init_9393 mlx4_bitmap_init 5-2-0 9393 NULL nohasharray
115411 +get_request_type_9393 get_request_type 0 9393 &mlx4_bitmap_init_9393
115412 +virtqueue_add_outbuf_9395 virtqueue_add_outbuf 3 9395 NULL
115413 +read_9397 read 3 9397 NULL
115414 +tpm_stm_i2c_send_9412 tpm_stm_i2c_send 3 9412 NULL
115415 +hash_ipportip4_expire_9415 hash_ipportip4_expire 4 9415 NULL
115416 +btrfs_drop_extents_9423 btrfs_drop_extents 4 9423 NULL
115417 +bm_realloc_pages_9431 bm_realloc_pages 2 9431 NULL
115418 +bcm2048_set_region_9436 bcm2048_set_region 0 9436 NULL
115419 +ffs_ep0_write_9438 ffs_ep0_write 3 9438 NULL
115420 +ath9k_init_soc_platform_9441 ath9k_init_soc_platform 0 9441 NULL
115421 +ieee80211_if_fmt_fwded_unicast_9454 ieee80211_if_fmt_fwded_unicast 3 9454 NULL
115422 +agp_generic_alloc_user_9470 agp_generic_alloc_user 1 9470 NULL nohasharray
115423 +get_registers_9470 get_registers 4 9470 &agp_generic_alloc_user_9470
115424 +slab_mem_going_online_callback_9474 slab_mem_going_online_callback 0 9474 NULL
115425 +crypt_status_9492 crypt_status 5 9492 NULL
115426 +lbs_threshold_write_9502 lbs_threshold_write 5 9502 NULL
115427 +lp_write_9511 lp_write 3 9511 NULL
115428 +mext_calc_swap_extents_9517 mext_calc_swap_extents 4 9517 NULL nohasharray
115429 +do_strip_9517 do_strip 0 9517 &mext_calc_swap_extents_9517
115430 +scsi_tgt_kspace_exec_9522 scsi_tgt_kspace_exec 8 9522 NULL
115431 +ll_max_read_ahead_whole_mb_seq_write_9528 ll_max_read_ahead_whole_mb_seq_write 3 9528 NULL
115432 +read_file_dma_9530 read_file_dma 3 9530 NULL
115433 +iwl_dbgfs_bf_params_read_9542 iwl_dbgfs_bf_params_read 3 9542 NULL
115434 +xfs_ialloc_read_agi_9545 xfs_ialloc_read_agi 0 9545 NULL
115435 +il_dbgfs_missed_beacon_write_9546 il_dbgfs_missed_beacon_write 3 9546 NULL
115436 +compat_SyS_pwritev64_9548 compat_SyS_pwritev64 3 9548 NULL
115437 +fw_node_create_9559 fw_node_create 2 9559 NULL
115438 +kobj_map_9566 kobj_map 2-3-0 9566 NULL
115439 +asd_init_escbs_9570 asd_init_escbs 0 9570 NULL
115440 +f2fs_read_data_pages_9574 f2fs_read_data_pages 4 9574 NULL
115441 +mlx4_NOP_9582 mlx4_NOP 0 9582 NULL
115442 +snd_emu10k1_fx8010_read_9605 snd_emu10k1_fx8010_read 5-6 9605 NULL
115443 +xfs_qm_dqattach_one_9612 xfs_qm_dqattach_one 0 9612 NULL
115444 +ocfs2_claim_suballoc_bits_9615 ocfs2_claim_suballoc_bits 0 9615 NULL
115445 +lov_ost_pool_add_9626 lov_ost_pool_add 3 9626 NULL
115446 +saa7164_buffer_alloc_user_9627 saa7164_buffer_alloc_user 2 9627 NULL
115447 +ceph_copy_user_to_page_vector_9635 ceph_copy_user_to_page_vector 4-3 9635 NULL
115448 +acpi_ex_insert_into_field_9638 acpi_ex_insert_into_field 3 9638 NULL
115449 +ll_checksum_seq_write_9648 ll_checksum_seq_write 3 9648 NULL
115450 +ocfs2_xattr_get_rec_9652 ocfs2_xattr_get_rec 0 9652 NULL
115451 +queue_received_packet_9657 queue_received_packet 5 9657 NULL
115452 +tipc_port_mcast_xmit_9663 tipc_port_mcast_xmit 4 9663 NULL
115453 +snd_opl4_mem_proc_write_9670 snd_opl4_mem_proc_write 5 9670 NULL
115454 +dns_query_9676 dns_query 3 9676 NULL
115455 +qib_7322_handle_hwerrors_9678 qib_7322_handle_hwerrors 3 9678 NULL
115456 +__erst_read_from_storage_9690 __erst_read_from_storage 0 9690 NULL
115457 +vx_transfer_end_9701 vx_transfer_end 0 9701 NULL
115458 +fuse_iter_npages_9705 fuse_iter_npages 0 9705 NULL nohasharray
115459 +ieee80211_if_read_aid_9705 ieee80211_if_read_aid 3 9705 &fuse_iter_npages_9705
115460 +get_leaf_9711 get_leaf 0 9711 NULL
115461 +cfg80211_tx_mlme_mgmt_9715 cfg80211_tx_mlme_mgmt 3 9715 NULL
115462 +parse_uac2_sample_rate_range_9718 parse_uac2_sample_rate_range 0 9718 NULL
115463 +btrfs_stack_file_extent_num_bytes_9720 btrfs_stack_file_extent_num_bytes 0 9720 NULL
115464 +SYSC_ppoll_9721 SYSC_ppoll 2 9721 NULL
115465 +t4_wr_mbox_9732 t4_wr_mbox 0 9732 NULL
115466 +nla_get_u8_9736 nla_get_u8 0 9736 NULL
115467 +ieee80211_if_fmt_num_mcast_sta_9738 ieee80211_if_fmt_num_mcast_sta 3 9738 NULL
115468 +shmem_replace_page_9740 shmem_replace_page 0 9740 NULL
115469 +ddb_input_read_9743 ddb_input_read 3-0 9743 NULL
115470 +regmap_multi_reg_write_bypassed_9751 regmap_multi_reg_write_bypassed 3 9751 NULL nohasharray
115471 +sta_last_ack_signal_read_9751 sta_last_ack_signal_read 3 9751 &regmap_multi_reg_write_bypassed_9751
115472 +t4vf_get_sge_params_9761 t4vf_get_sge_params 0 9761 NULL
115473 +btrfs_super_root_9763 btrfs_super_root 0 9763 NULL
115474 +init_controller_9771 init_controller 0 9771 NULL
115475 +sh_eth_check_reset_9773 sh_eth_check_reset 0 9773 NULL
115476 +fnic_rq_alloc_9775 fnic_rq_alloc 0 9775 NULL
115477 +__blk_queue_init_tags_9778 __blk_queue_init_tags 2 9778 NULL
115478 +kvm_age_hva_9795 kvm_age_hva 2 9795 NULL
115479 +ath10k_debug_start_9800 ath10k_debug_start 0 9800 NULL
115480 +tpm_data_in_9802 tpm_data_in 0 9802 NULL
115481 +_regmap_write_9803 _regmap_write 0 9803 NULL
115482 +udpv6_recvmsg_9813 udpv6_recvmsg 4 9813 NULL nohasharray
115483 +ieee80211_if_read_state_9813 ieee80211_if_read_state 3 9813 &udpv6_recvmsg_9813
115484 +compat_SyS_vmsplice_9828 compat_SyS_vmsplice 3 9828 NULL
115485 +ath_txstatus_setup_9830 ath_txstatus_setup 0 9830 NULL
115486 +bcm2048_set_mute_9863 bcm2048_set_mute 0 9863 NULL
115487 +pmcraid_alloc_sglist_9864 pmcraid_alloc_sglist 1 9864 NULL
115488 +btrfs_free_reserved_extent_9867 btrfs_free_reserved_extent 2 9867 NULL
115489 +f1x_translate_sysaddr_to_cs_9868 f1x_translate_sysaddr_to_cs 2 9868 NULL
115490 +mlx4_bitmap_alloc_range_9876 mlx4_bitmap_alloc_range 2-3 9876 NULL
115491 +wil_read_file_ioblob_9878 wil_read_file_ioblob 3 9878 NULL nohasharray
115492 +dir_commit_chunk_9878 dir_commit_chunk 3 9878 &wil_read_file_ioblob_9878
115493 +snd_midi_event_new_9893 snd_midi_event_new 1 9893 NULL nohasharray
115494 +bm_register_write_9893 bm_register_write 3 9893 &snd_midi_event_new_9893
115495 +snd_gf1_pcm_playback_copy_9895 snd_gf1_pcm_playback_copy 3-5 9895 NULL
115496 +sf1_write_9903 sf1_write 0 9903 NULL
115497 +nonpaging_page_fault_9908 nonpaging_page_fault 2 9908 NULL
115498 +iwl_dbgfs_prph_reg_read_9928 iwl_dbgfs_prph_reg_read 3 9928 NULL
115499 +root_nfs_parse_options_9937 root_nfs_parse_options 3 9937 NULL
115500 +pstore_ftrace_knob_read_9947 pstore_ftrace_knob_read 3 9947 NULL
115501 +read_file_misc_9948 read_file_misc 3 9948 NULL
115502 +csum_partial_copy_fromiovecend_9957 csum_partial_copy_fromiovecend 3-4 9957 NULL
115503 +xfs_buf_geterror_9959 xfs_buf_geterror 0 9959 NULL
115504 +SyS_gethostname_9964 SyS_gethostname 2 9964 NULL
115505 +get_free_serial_index_9969 get_free_serial_index 0 9969 NULL
115506 +btrfs_add_link_9973 btrfs_add_link 5 9973 NULL
115507 +gameport_read_9983 gameport_read 0 9983 NULL
115508 +SYSC_move_pages_9986 SYSC_move_pages 2 9986 NULL
115509 +ceph_oloc_oid_to_pg_10003 ceph_oloc_oid_to_pg 0 10003 NULL
115510 +snd_wss_create_10004 snd_wss_create 0 10004 NULL
115511 +aat2870_dump_reg_10019 aat2870_dump_reg 0 10019 NULL
115512 +regulator_ena_gpio_ctrl_10053 regulator_ena_gpio_ctrl 0 10053 NULL
115513 +ieee80211_set_probe_resp_10077 ieee80211_set_probe_resp 3 10077 NULL nohasharray
115514 +ar9003_mci_reset_10077 ar9003_mci_reset 0 10077 &ieee80211_set_probe_resp_10077
115515 +xfs_attr_rmtval_get_10092 xfs_attr_rmtval_get 0 10092 NULL
115516 +xfs_btree_check_lptr_10104 xfs_btree_check_lptr 0 10104 NULL
115517 +get_elem_size_10110 get_elem_size 0-2 10110 NULL nohasharray
115518 +dynamic_ps_timeout_read_10110 dynamic_ps_timeout_read 3 10110 &get_elem_size_10110
115519 +gfs2_meta_read_10112 gfs2_meta_read 0 10112 NULL
115520 +SyS_migrate_pages_10134 SyS_migrate_pages 2 10134 NULL
115521 +dev_get_valid_name_10138 dev_get_valid_name 0 10138 NULL
115522 +aes_decrypt_packets_read_10155 aes_decrypt_packets_read 3 10155 NULL
115523 +rx_out_of_mem_read_10157 rx_out_of_mem_read 3 10157 NULL
115524 +hidg_alloc_ep_req_10159 hidg_alloc_ep_req 2 10159 NULL nohasharray
115525 +ath5k_eeprom_read_ants_10159 ath5k_eeprom_read_ants 0 10159 &hidg_alloc_ep_req_10159
115526 +asd_store_update_bios_10165 asd_store_update_bios 4 10165 NULL
115527 +kstrtol_from_user_10168 kstrtol_from_user 2 10168 NULL
115528 +init_rfdlist_10170 init_rfdlist 0 10170 NULL
115529 +proc_pid_attr_read_10173 proc_pid_attr_read 3 10173 NULL
115530 +pci_bus_write_config_word_10180 pci_bus_write_config_word 0 10180 NULL
115531 +jffs2_user_setxattr_10182 jffs2_user_setxattr 4 10182 NULL
115532 +sram_test_and_clear_10186 sram_test_and_clear 0 10186 NULL
115533 +smsc911x_init_10196 smsc911x_init 0 10196 NULL
115534 +cy8ctmg110_write_regs_10204 cy8ctmg110_write_regs 3 10204 NULL
115535 +c2_register_device_10219 c2_register_device 0 10219 NULL
115536 +xfs_attr_rmtval_copyout_10222 xfs_attr_rmtval_copyout 0 10222 NULL nohasharray
115537 +xfs_btree_read_buf_block_10222 xfs_btree_read_buf_block 0 10222 &xfs_attr_rmtval_copyout_10222
115538 +ican3_old_send_msg_10231 ican3_old_send_msg 0 10231 NULL
115539 +hdlc_rpr_irq_10240 hdlc_rpr_irq 2 10240 NULL
115540 +mutex_lock_killable_10244 mutex_lock_killable 0 10244 NULL
115541 +cciss_proc_write_10259 cciss_proc_write 3 10259 NULL
115542 +gpiochip_add_to_list_10262 gpiochip_add_to_list 0 10262 NULL
115543 +bcm2048_recv_command_10269 bcm2048_recv_command 0 10269 NULL
115544 +snd_pcm_lib_preallocate_pages1_10273 snd_pcm_lib_preallocate_pages1 0 10273 NULL
115545 +__qlcnic_pci_sriov_enable_10281 __qlcnic_pci_sriov_enable 2 10281 NULL
115546 +snd_rme9652_capture_copy_10287 snd_rme9652_capture_copy 5 10287 NULL
115547 +ubi_leb_change_10289 ubi_leb_change 0 10289 NULL
115548 +read_emulate_10310 read_emulate 2-4 10310 NULL
115549 +read_file_spectral_count_10320 read_file_spectral_count 3 10320 NULL nohasharray
115550 +atm_init_10320 atm_init 0 10320 &read_file_spectral_count_10320 nohasharray
115551 +ican3_send_msg_10320 ican3_send_msg 0 10320 &atm_init_10320
115552 +compat_SyS_writev_10327 compat_SyS_writev 3 10327 NULL
115553 +tun_sendmsg_10337 tun_sendmsg 4 10337 NULL
115554 +em28xx_read_reg_req_len_10340 em28xx_read_reg_req_len 0 10340 NULL
115555 +ufx_alloc_urb_list_10349 ufx_alloc_urb_list 3 10349 NULL
115556 +whci_add_cap_10350 whci_add_cap 0 10350 NULL
115557 +dbAllocAny_10354 dbAllocAny 0 10354 NULL
115558 +ath6kl_listen_int_read_10355 ath6kl_listen_int_read 3 10355 NULL
115559 +ms_write_multiple_pages_10362 ms_write_multiple_pages 6-5 10362 NULL
115560 +sta_ht_capa_read_10366 sta_ht_capa_read 3 10366 NULL
115561 +ecryptfs_decode_and_decrypt_filename_10379 ecryptfs_decode_and_decrypt_filename 5 10379 NULL
115562 +led_classdev_register_10384 led_classdev_register 0 10384 NULL
115563 +do_compat_pselect_10398 do_compat_pselect 1 10398 NULL
115564 +lis3lv02d_init_device_10416 lis3lv02d_init_device 0 10416 NULL
115565 +fwtty_rx_10434 fwtty_rx 3 10434 NULL
115566 +event_phy_transmit_error_read_10471 event_phy_transmit_error_read 3 10471 NULL
115567 +add_controls_10473 add_controls 0 10473 NULL
115568 +hash_ipportip6_expire_10478 hash_ipportip6_expire 4 10478 NULL
115569 +nouveau_pwr_create__10483 nouveau_pwr_create_ 4 10483 NULL
115570 +ext4_itable_unused_count_10501 ext4_itable_unused_count 0 10501 NULL
115571 +qib_alloc_fast_reg_page_list_10507 qib_alloc_fast_reg_page_list 2 10507 NULL
115572 +sel_write_disable_10511 sel_write_disable 3 10511 NULL
115573 +osd_req_write_sg_kern_10514 osd_req_write_sg_kern 5 10514 NULL
115574 +rds_message_alloc_10517 rds_message_alloc 1 10517 NULL
115575 +qlcnic_pci_sriov_enable_10519 qlcnic_pci_sriov_enable 2 10519 NULL
115576 +snd_pcm_hw_params_user_10520 snd_pcm_hw_params_user 0 10520 NULL
115577 +kstrtouint_from_user_10536 kstrtouint_from_user 2 10536 NULL nohasharray
115578 +snd_pcm_lib_read_10536 snd_pcm_lib_read 0-3 10536 &kstrtouint_from_user_10536
115579 +SYSC_read_10545 SYSC_read 3 10545 NULL
115580 +mccic_register_10565 mccic_register 0 10565 NULL
115581 +pci_set_mwi_10568 pci_set_mwi 0 10568 NULL
115582 +ext4_write_begin_10576 ext4_write_begin 3-4 10576 NULL
115583 +scrub_remap_extent_10588 scrub_remap_extent 2 10588 NULL
115584 +otp_read_10594 otp_read 2-4-5 10594 NULL
115585 +supply_map_read_file_10608 supply_map_read_file 3 10608 NULL
115586 +ima_show_htable_violations_10619 ima_show_htable_violations 3 10619 NULL
115587 +de_refill_rx_10626 de_refill_rx 0 10626 NULL
115588 +alloc_coherent_10632 alloc_coherent 2 10632 NULL
115589 +fq_alloc_node_10633 fq_alloc_node 1 10633 NULL
115590 +mcam_cam_init_10638 mcam_cam_init 0 10638 NULL
115591 +devm_request_irq_10640 devm_request_irq 0 10640 NULL
115592 +niu_pci_probe_sprom_10646 niu_pci_probe_sprom 0 10646 NULL
115593 +nfs_idmap_lookup_id_10660 nfs_idmap_lookup_id 2 10660 NULL nohasharray
115594 +ubi_io_write_vid_hdr_10660 ubi_io_write_vid_hdr 0 10660 &nfs_idmap_lookup_id_10660
115595 +efx_max_tx_len_10662 efx_max_tx_len 0-2 10662 NULL
115596 +parport_write_10669 parport_write 0 10669 NULL
115597 +mlx4_map_clr_int_10680 mlx4_map_clr_int 0 10680 NULL
115598 +edge_write_10692 edge_write 4 10692 NULL
115599 +ubi_wl_get_peb_10699 ubi_wl_get_peb 0 10699 NULL
115600 +selinux_inode_setxattr_10708 selinux_inode_setxattr 4 10708 NULL nohasharray
115601 +inl_10708 inl 0 10708 &selinux_inode_setxattr_10708
115602 +shash_async_setkey_10720 shash_async_setkey 3 10720 NULL nohasharray
115603 +pvr2_ioread_read_10720 pvr2_ioread_read 3 10720 &shash_async_setkey_10720
115604 +vfio_pm_config_write_10722 vfio_pm_config_write 3 10722 NULL
115605 +pch_uart_hal_set_line_10724 pch_uart_hal_set_line 0 10724 NULL
115606 +gfs2_ok_to_move_10728 gfs2_ok_to_move 0 10728 NULL
115607 +spi_sync_10731 spi_sync 0 10731 NULL
115608 +sctp_getsockopt_maxseg_10737 sctp_getsockopt_maxseg 2 10737 NULL nohasharray
115609 +apu_get_register_10737 apu_get_register 0 10737 &sctp_getsockopt_maxseg_10737
115610 +SyS_io_getevents_10756 SyS_io_getevents 3 10756 NULL
115611 +vhost_add_used_n_10760 vhost_add_used_n 3 10760 NULL
115612 +rd_build_prot_space_10761 rd_build_prot_space 2-3 10761 NULL
115613 +kvm_read_guest_atomic_10765 kvm_read_guest_atomic 4 10765 NULL
115614 +__qp_memcpy_to_queue_10779 __qp_memcpy_to_queue 2-4 10779 NULL
115615 +pch_gbe_init_phy_10780 pch_gbe_init_phy 0 10780 NULL
115616 +enic_get_vnic_config_10793 enic_get_vnic_config 0 10793 NULL
115617 +diva_set_trace_filter_10820 diva_set_trace_filter 0-1 10820 NULL
115618 +ar9002_hw_attach_ops_10823 ar9002_hw_attach_ops 0 10823 NULL
115619 +init_rss_10830 init_rss 0 10830 NULL
115620 +lbs_sleepparams_read_10840 lbs_sleepparams_read 3 10840 NULL
115621 +ida_get_new_above_10853 ida_get_new_above 0 10853 NULL
115622 +fuse_conn_max_background_read_10855 fuse_conn_max_background_read 3 10855 NULL
115623 +snd_pcm_oss_write1_10872 snd_pcm_oss_write1 3 10872 NULL
115624 +wiidebug_drm_write_10879 wiidebug_drm_write 3 10879 NULL nohasharray
115625 +mthca_SYS_EN_10879 mthca_SYS_EN 0 10879 &wiidebug_drm_write_10879
115626 +get_scq_10897 get_scq 2 10897 NULL
115627 +tifm_alloc_adapter_10903 tifm_alloc_adapter 1 10903 NULL
115628 +lprocfs_wr_atomic_10912 lprocfs_wr_atomic 3 10912 NULL
115629 +__copy_from_user_10918 __copy_from_user 0-3 10918 NULL
115630 +kobject_add_10919 kobject_add 0 10919 NULL
115631 +da9052_map_irq_10952 da9052_map_irq 2 10952 NULL
115632 +ar9003_dump_modal_eeprom_10959 ar9003_dump_modal_eeprom 3-2-0 10959 NULL
115633 +ci_port_test_write_10962 ci_port_test_write 3 10962 NULL
115634 +bm_entry_read_10976 bm_entry_read 3 10976 NULL
115635 +sched_autogroup_write_10984 sched_autogroup_write 3 10984 NULL
115636 +xfrm_hash_alloc_10997 xfrm_hash_alloc 1 10997 NULL
115637 +rx_filter_accum_arp_pend_requests_read_11003 rx_filter_accum_arp_pend_requests_read 3 11003 NULL
115638 +gfs2_dir_read_11017 gfs2_dir_read 0 11017 NULL
115639 +SetLineNumber_11023 SetLineNumber 0 11023 NULL
115640 +pci_msi_vec_count_11046 pci_msi_vec_count 0 11046 NULL
115641 +tda10048_writeregbulk_11050 tda10048_writeregbulk 4 11050 NULL
115642 +insert_inline_extent_backref_11063 insert_inline_extent_backref 8 11063 NULL nohasharray
115643 +qlcnic_83xx_calculate_msix_vector_11063 qlcnic_83xx_calculate_msix_vector 0 11063 &insert_inline_extent_backref_11063
115644 +xfs_collapse_file_space_11075 xfs_collapse_file_space 2-3 11075 NULL
115645 +tcp_send_mss_11079 tcp_send_mss 0 11079 NULL
115646 +snd_pcm_delay_11081 snd_pcm_delay 0 11081 NULL
115647 +at86rf230_write_subreg_11082 at86rf230_write_subreg 0 11082 NULL
115648 +count_argc_11083 count_argc 0 11083 NULL
115649 +kvm_write_guest_cached_11106 kvm_write_guest_cached 4 11106 NULL
115650 +stmpe_gpio_to_irq_11110 stmpe_gpio_to_irq 2 11110 NULL
115651 +tw_change_queue_depth_11116 tw_change_queue_depth 2 11116 NULL
115652 +page_offset_11120 page_offset 0 11120 NULL
115653 +tracing_buffers_read_11124 tracing_buffers_read 3 11124 NULL nohasharray
115654 +cea_db_payload_len_11124 cea_db_payload_len 0 11124 &tracing_buffers_read_11124
115655 +alloc_alien_cache_11127 alloc_alien_cache 2 11127 NULL
115656 +mic_setup_callbacks_11143 mic_setup_callbacks 0 11143 NULL
115657 +snd_gf1_pcm_playback_silence_11172 snd_gf1_pcm_playback_silence 3-4 11172 NULL
115658 +blkdev_write_end_11180 blkdev_write_end 5 11180 NULL
115659 +fb_set_var_11211 fb_set_var 0 11211 NULL
115660 +dma_mapping_error_11213 dma_mapping_error 0 11213 NULL
115661 +il_dbgfs_rx_queue_read_11221 il_dbgfs_rx_queue_read 3 11221 NULL
115662 +comedi_alloc_spriv_11234 comedi_alloc_spriv 2 11234 NULL
115663 +of_irq_count_11253 of_irq_count 0 11253 NULL
115664 +hugetlbfs_read_11268 hugetlbfs_read 3 11268 NULL
115665 +asd_alloc_escbs_11271 asd_alloc_escbs 0 11271 NULL
115666 +ath6kl_power_params_write_11274 ath6kl_power_params_write 3 11274 NULL
115667 +pcie_capability_write_word_11301 pcie_capability_write_word 0 11301 NULL
115668 +__proc_daemon_file_11305 __proc_daemon_file 5 11305 NULL
115669 +ext4_xattr_check_names_11314 ext4_xattr_check_names 0 11314 NULL
115670 +bcache_dev_sectors_dirty_add_11315 bcache_dev_sectors_dirty_add 3-4 11315 NULL
115671 +sk_filter_size_11316 sk_filter_size 0 11316 NULL nohasharray
115672 +tcp_send_rcvq_11316 tcp_send_rcvq 3 11316 &sk_filter_size_11316
115673 +shmem_radix_tree_replace_11325 shmem_radix_tree_replace 0 11325 NULL
115674 +construct_key_11329 construct_key 3 11329 NULL nohasharray
115675 +__kfifo_out_peek_11329 __kfifo_out_peek 0-3 11329 &construct_key_11329
115676 +next_segment_11330 next_segment 0-2-1 11330 NULL
115677 +persistent_ram_buffer_map_11332 persistent_ram_buffer_map 2-1 11332 NULL
115678 +ext4_get_inline_size_11349 ext4_get_inline_size 0 11349 NULL
115679 +sel_write_create_11353 sel_write_create 3 11353 NULL nohasharray
115680 +nl80211_send_mgmt_11353 nl80211_send_mgmt 7 11353 &sel_write_create_11353
115681 +of_get_available_child_count_11361 of_get_available_child_count 0 11361 NULL
115682 +qib_get_base_info_11369 qib_get_base_info 3 11369 NULL
115683 +tcf_register_action_11381 tcf_register_action 2 11381 NULL nohasharray
115684 +nft_value_dump_11381 nft_value_dump 3 11381 &tcf_register_action_11381
115685 +power_supply_register_11385 power_supply_register 0 11385 NULL
115686 +isku_sysfs_read_keys_capslock_11392 isku_sysfs_read_keys_capslock 6 11392 NULL
115687 +dev_irnet_write_11398 dev_irnet_write 3 11398 NULL
115688 +lprocfs_wr_evict_client_11402 lprocfs_wr_evict_client 3 11402 NULL
115689 +___alloc_bootmem_11410 ___alloc_bootmem 1 11410 NULL
115690 +str_to_user_11411 str_to_user 2 11411 NULL
115691 +mem_fw_gen_free_mem_blks_read_11413 mem_fw_gen_free_mem_blks_read 3 11413 NULL
115692 +ath6kl_wmi_test_rx_11414 ath6kl_wmi_test_rx 3 11414 NULL
115693 +xfs_btree_lookup_11417 xfs_btree_lookup 0 11417 NULL nohasharray
115694 +adis16480_show_firmware_revision_11417 adis16480_show_firmware_revision 3 11417 &xfs_btree_lookup_11417
115695 +trace_options_read_11419 trace_options_read 3 11419 NULL
115696 +i40e_dbg_command_write_11421 i40e_dbg_command_write 3 11421 NULL
115697 +xd_read_multiple_pages_11422 xd_read_multiple_pages 5-4 11422 NULL
115698 +bttv_read_11432 bttv_read 3 11432 NULL
115699 +create_zero_mask_11453 create_zero_mask 0-1 11453 NULL
115700 +do_blockdev_direct_IO_11455 do_blockdev_direct_IO 0-6 11455 NULL nohasharray
115701 +bcm2048_set_power_state_11455 bcm2048_set_power_state 0 11455 &do_blockdev_direct_IO_11455
115702 +sca3000_read_first_n_hw_rb_11479 sca3000_read_first_n_hw_rb 2 11479 NULL nohasharray
115703 +pci_set_power_state_11479 pci_set_power_state 0 11479 &sca3000_read_first_n_hw_rb_11479
115704 +solo_g723_init_11488 solo_g723_init 0 11488 NULL
115705 +xfs_file_buffered_aio_write_11492 xfs_file_buffered_aio_write 4-0 11492 NULL
115706 +sd_do_mode_sense_11507 sd_do_mode_sense 5 11507 NULL
115707 +kmem_zalloc_11510 kmem_zalloc 1 11510 NULL
115708 +ll_direct_IO_26_seg_11518 ll_direct_IO_26_seg 0 11518 NULL
115709 +twl_direction_in_11527 twl_direction_in 2 11527 NULL
115710 +xfs_rtcheck_alloc_range_11553 xfs_rtcheck_alloc_range 0 11553 NULL
115711 +radix_tree_extend_11555 radix_tree_extend 0 11555 NULL
115712 +skb_cow_data_11565 skb_cow_data 0 11565 NULL
115713 +atomic_notifier_call_chain_11567 atomic_notifier_call_chain 0 11567 NULL
115714 +mlx4_init_cmpt_table_11569 mlx4_init_cmpt_table 0 11569 NULL
115715 +snd_ac97_mixer_11571 snd_ac97_mixer 0 11571 NULL
115716 +lpfc_idiag_ctlacc_write_11576 lpfc_idiag_ctlacc_write 3 11576 NULL
115717 +oprofilefs_ulong_to_user_11582 oprofilefs_ulong_to_user 3 11582 NULL
115718 +batadv_iv_ogm_orig_add_if_11586 batadv_iv_ogm_orig_add_if 2 11586 NULL
115719 +snd_pcm_action_11589 snd_pcm_action 0 11589 NULL
115720 +ath5k_hw_init_desc_functions_11590 ath5k_hw_init_desc_functions 0 11590 NULL
115721 +fw_device_op_ioctl_11595 fw_device_op_ioctl 2 11595 NULL
115722 +batadv_iv_ogm_orig_del_if_11604 batadv_iv_ogm_orig_del_if 2 11604 NULL
115723 +SYSC_mq_timedsend_11607 SYSC_mq_timedsend 3 11607 NULL
115724 +C_SYSC_migrate_pages_11618 C_SYSC_migrate_pages 2 11618 NULL
115725 +vnic_wq_alloc_11648 vnic_wq_alloc 0 11648 NULL
115726 +sisusb_send_bridge_packet_11649 sisusb_send_bridge_packet 2 11649 NULL
115727 +nla_total_size_11658 nla_total_size 1-0 11658 NULL
115728 +slab_ksize_11664 slab_ksize 0 11664 NULL
115729 +ide_queue_pc_tail_11673 ide_queue_pc_tail 5 11673 NULL
115730 +compat_SyS_msgsnd_11675 compat_SyS_msgsnd 3 11675 NULL
115731 +btrfs_alloc_delayed_item_11678 btrfs_alloc_delayed_item 1 11678 NULL
115732 +sctp_setsockopt_hmac_ident_11687 sctp_setsockopt_hmac_ident 3 11687 NULL
115733 +split_11691 split 2 11691 NULL
115734 +compat_SyS_keyctl_11695 compat_SyS_keyctl 4 11695 NULL nohasharray
115735 +snd_ctl_elem_user_tlv_11695 snd_ctl_elem_user_tlv 3 11695 &compat_SyS_keyctl_11695
115736 +blk_rq_cur_bytes_11723 blk_rq_cur_bytes 0 11723 NULL
115737 +i2c_master_recv_11734 i2c_master_recv 0-3 11734 NULL
115738 +dm_bio_prison_create_11749 dm_bio_prison_create 1 11749 NULL
115739 +irq_set_affinity_notifier_11752 irq_set_affinity_notifier 0 11752 NULL
115740 +iwl_dbgfs_qos_read_11753 iwl_dbgfs_qos_read 3 11753 NULL
115741 +ieee80211_get_num_supported_channels_11768 ieee80211_get_num_supported_channels 0 11768 NULL
115742 +tipc_sendmsg_11769 tipc_sendmsg 4 11769 NULL nohasharray
115743 +ocfs2_relink_block_group_11769 ocfs2_relink_block_group 0 11769 &tipc_sendmsg_11769
115744 +ps_pspoll_timeouts_read_11776 ps_pspoll_timeouts_read 3 11776 NULL
115745 +btrfs_key_blockptr_11786 btrfs_key_blockptr 0 11786 NULL
115746 +pcpu_fc_alloc_11818 pcpu_fc_alloc 2 11818 NULL
115747 +xfs_ialloc_11819 xfs_ialloc 0 11819 NULL
115748 +umc_device_register_11824 umc_device_register 0 11824 NULL
115749 +zerocopy_sg_from_iovec_11828 zerocopy_sg_from_iovec 3 11828 NULL
115750 +sctp_setsockopt_maxseg_11829 sctp_setsockopt_maxseg 3 11829 NULL
115751 +rts51x_read_status_11830 rts51x_read_status 4 11830 NULL
115752 +unix_stream_connect_11844 unix_stream_connect 3 11844 NULL
115753 +xfs_file_aio_write_checks_11851 xfs_file_aio_write_checks 0 11851 NULL
115754 +pci_enable_msix_range_11852 pci_enable_msix_range 0-4 11852 NULL
115755 +ecryptfs_copy_filename_11868 ecryptfs_copy_filename 4 11868 NULL
115756 +ieee80211_rx_bss_info_11887 ieee80211_rx_bss_info 3 11887 NULL
115757 +mthca_MAP_ICM_AUX_11891 mthca_MAP_ICM_AUX 0 11891 NULL
115758 +mdc_rename_11899 mdc_rename 4-6 11899 NULL
115759 +videobuf_dvb_register_frontend_11904 videobuf_dvb_register_frontend 0 11904 NULL
115760 +xstateregs_get_11906 xstateregs_get 4 11906 NULL
115761 +ti_write_11916 ti_write 4 11916 NULL
115762 +fs_devrw_entry_11924 fs_devrw_entry 3 11924 NULL
115763 +bitmap_remap_11929 bitmap_remap 5 11929 NULL
115764 +atomic_sub_return_11939 atomic_sub_return 0-1 11939 NULL
115765 +r1_sync_page_io_11963 r1_sync_page_io 3 11963 NULL
115766 +f1x_swap_interleaved_region_11970 f1x_swap_interleaved_region 0-2 11970 NULL
115767 +read_and_add_raw_conns_11987 read_and_add_raw_conns 0 11987 NULL
115768 +sxgbe_init_phy_12000 sxgbe_init_phy 0 12000 NULL
115769 +notifier_call_chain_12036 notifier_call_chain 0 12036 NULL
115770 +ftdi_elan_total_command_size_12045 ftdi_elan_total_command_size 0 12045 NULL
115771 +ieee80211_if_read_user_power_level_12050 ieee80211_if_read_user_power_level 3 12050 NULL
115772 +em28xx_i2c_read_block_12055 em28xx_i2c_read_block 5 12055 NULL
115773 +il4965_ucode_tx_stats_read_12064 il4965_ucode_tx_stats_read 3 12064 NULL
115774 +ptc_proc_write_12076 ptc_proc_write 3 12076 NULL
115775 +batadv_tt_global_size_mod_12085 batadv_tt_global_size_mod 3 12085 NULL
115776 +ath10k_bmi_execute_12088 ath10k_bmi_execute 0 12088 NULL
115777 +rtw_malloc2d_12102 rtw_malloc2d 1-2-3 12102 NULL
115778 +get_dma_id_12115 get_dma_id 0 12115 NULL
115779 +gfs2_find_jhead_12117 gfs2_find_jhead 0 12117 NULL
115780 +alloc_bulk_urbs_generic_12127 alloc_bulk_urbs_generic 5 12127 NULL
115781 +set_powered_12129 set_powered 4 12129 NULL
115782 +ramoops_init_prz_12134 ramoops_init_prz 5 12134 NULL
115783 +xfs_handle_to_dentry_12135 xfs_handle_to_dentry 3 12135 NULL
115784 +rawv6_seticmpfilter_12137 rawv6_seticmpfilter 5 12137 NULL
115785 +rawsock_recvmsg_12144 rawsock_recvmsg 4 12144 NULL
115786 +get_idx_gc_leb_12148 get_idx_gc_leb 0 12148 NULL
115787 +btmrvl_sdio_host_to_card_12152 btmrvl_sdio_host_to_card 3 12152 NULL
115788 +vmbus_open_12154 vmbus_open 2-3-0 12154 NULL
115789 +ath5k_eeprom_read_pcal_info_12159 ath5k_eeprom_read_pcal_info 0 12159 NULL
115790 +fnic_reset_stats_write_12177 fnic_reset_stats_write 3 12177 NULL
115791 +LNetEQAlloc_12178 LNetEQAlloc 1 12178 NULL
115792 +ddp_make_gl_12179 ddp_make_gl 1 12179 NULL
115793 +compat_do_arpt_set_ctl_12184 compat_do_arpt_set_ctl 4 12184 NULL
115794 +ip_generic_getfrag_12187 ip_generic_getfrag 3-4 12187 NULL
115795 +qt2160_read_block_12198 qt2160_read_block 4 12198 NULL
115796 +pci_bus_read_config_dword_12210 pci_bus_read_config_dword 0 12210 NULL
115797 +snd_pcm_kernel_ioctl_12219 snd_pcm_kernel_ioctl 0 12219 NULL
115798 +fuse_get_req_12221 fuse_get_req 2 12221 NULL nohasharray
115799 +aat2870_reg_read_file_12221 aat2870_reg_read_file 3 12221 &fuse_get_req_12221
115800 +xfs_attr3_leaf_read_12222 xfs_attr3_leaf_read 0 12222 NULL
115801 +__alloc_bootmem_low_nopanic_12235 __alloc_bootmem_low_nopanic 1 12235 NULL
115802 +usnic_ib_qp_grp_dump_rows_12239 usnic_ib_qp_grp_dump_rows 3 12239 NULL
115803 +ib_uverbs_unmarshall_recv_12251 ib_uverbs_unmarshall_recv 5 12251 NULL
115804 +ath_descdma_setup_12257 ath_descdma_setup 0 12257 NULL
115805 +shash_compat_setkey_12267 shash_compat_setkey 3 12267 NULL
115806 +add_sctp_bind_addr_12269 add_sctp_bind_addr 3 12269 NULL
115807 +SYSC_vm86_12279 SYSC_vm86 2 12279 NULL
115808 +note_last_dentry_12285 note_last_dentry 3 12285 NULL
115809 +roundup_to_multiple_of_64_12288 roundup_to_multiple_of_64 0-1 12288 NULL nohasharray
115810 +il_dbgfs_nvm_read_12288 il_dbgfs_nvm_read 3 12288 &roundup_to_multiple_of_64_12288
115811 +__lbs_cmd_12307 __lbs_cmd 0 12307 NULL
115812 +bt_sock_recvmsg_12316 bt_sock_recvmsg 4 12316 NULL
115813 +usnic_transport_sock_to_str_12322 usnic_transport_sock_to_str 2-0 12322 NULL
115814 +pcbit_writecmd_12332 pcbit_writecmd 2 12332 NULL
115815 +xfs_bmap_last_extent_12335 xfs_bmap_last_extent 0 12335 NULL
115816 +get_burstcount_12341 get_burstcount 0 12341 NULL
115817 +pn544_hci_i2c_fw_secure_write_frame_cmd_12342 pn544_hci_i2c_fw_secure_write_frame_cmd 3 12342 NULL
115818 +c2_init_mqsp_pool_12345 c2_init_mqsp_pool 0 12345 NULL
115819 +mptctl_ioctl_12355 mptctl_ioctl 2 12355 NULL
115820 +tsi721_doorbell_init_12356 tsi721_doorbell_init 0 12356 NULL
115821 +__nf_ct_ext_add_length_12364 __nf_ct_ext_add_length 3 12364 NULL
115822 +xfs_iext_inline_to_direct_12384 xfs_iext_inline_to_direct 2 12384 NULL
115823 +populate_dir_12391 populate_dir 0 12391 NULL nohasharray
115824 +write_file_dump_12391 write_file_dump 3 12391 &populate_dir_12391
115825 +mwifiex_pcie_create_evtbd_ring_12401 mwifiex_pcie_create_evtbd_ring 0 12401 NULL
115826 +hbucket_elem_add_12416 hbucket_elem_add 3 12416 NULL
115827 +ieee80211_if_read_num_mcast_sta_12419 ieee80211_if_read_num_mcast_sta 3 12419 NULL
115828 +cfs_array_alloc_12441 cfs_array_alloc 2 12441 NULL
115829 +skb_do_copy_data_nocache_12465 skb_do_copy_data_nocache 5 12465 NULL
115830 +cfg80211_can_use_iftype_chan_12471 cfg80211_can_use_iftype_chan 0 12471 NULL
115831 +ql_wait_for_drvr_lock_12472 ql_wait_for_drvr_lock 0 12472 NULL
115832 +x25_sendmsg_12487 x25_sendmsg 4 12487 NULL
115833 +fnic_trace_ctrl_read_12497 fnic_trace_ctrl_read 3 12497 NULL
115834 +__ceph_osdc_start_request_12502 __ceph_osdc_start_request 0 12502 NULL nohasharray
115835 +bmp085_read_calibration_data_12502 bmp085_read_calibration_data 0 12502 &__ceph_osdc_start_request_12502
115836 +ql_start_rss_12521 ql_start_rss 0 12521 NULL
115837 +qib_alloc_fast_reg_mr_12526 qib_alloc_fast_reg_mr 2 12526 NULL
115838 +myri10ge_read_mac_addr_12530 myri10ge_read_mac_addr 0 12530 NULL
115839 +xfs_get_extsz_hint_12531 xfs_get_extsz_hint 0 12531 NULL
115840 +e100_hw_init_12536 e100_hw_init 0 12536 NULL
115841 +snd_pcm_substream_proc_init_12558 snd_pcm_substream_proc_init 0 12558 NULL
115842 +write_inode_now_12565 write_inode_now 0 12565 NULL
115843 +hvc_alloc_12579 hvc_alloc 4 12579 NULL
115844 +pcpu_extend_area_map_12589 pcpu_extend_area_map 2 12589 NULL
115845 +_iwl_dbgfs_prph_reg_write_12597 _iwl_dbgfs_prph_reg_write 3 12597 NULL
115846 +tlbflush_write_file_12598 tlbflush_write_file 3 12598 NULL
115847 +vhci_put_user_12604 vhci_put_user 4 12604 NULL
115848 +sdhci_pltfm_init_12627 sdhci_pltfm_init 3 12627 NULL
115849 +smsc911x_request_resources_12629 smsc911x_request_resources 0 12629 NULL
115850 +pwr_rcvd_awake_bcns_cnt_read_12632 pwr_rcvd_awake_bcns_cnt_read 3 12632 NULL
115851 +pn_sendmsg_12640 pn_sendmsg 4 12640 NULL
115852 +dwc3_link_state_write_12641 dwc3_link_state_write 3 12641 NULL
115853 +nr_recvmsg_12649 nr_recvmsg 4 12649 NULL
115854 +rtw_android_get_link_speed_12655 rtw_android_get_link_speed 0 12655 NULL
115855 +ocfs2_read_block_12659 ocfs2_read_block 0 12659 NULL
115856 +sel_read_class_12669 sel_read_class 3 12669 NULL nohasharray
115857 +sparse_mem_maps_populate_node_12669 sparse_mem_maps_populate_node 4 12669 &sel_read_class_12669
115858 +ext4_writepage_trans_blocks_12674 ext4_writepage_trans_blocks 0 12674 NULL
115859 +mcp23s08_gpio_to_irq_12692 mcp23s08_gpio_to_irq 2 12692 NULL
115860 +iwl_dbgfs_calib_disabled_write_12707 iwl_dbgfs_calib_disabled_write 3 12707 NULL
115861 +ieee80211_if_read_num_buffered_multicast_12716 ieee80211_if_read_num_buffered_multicast 3 12716 NULL
115862 +ivtv_write_12721 ivtv_write 3 12721 NULL
115863 +key_rx_spec_read_12736 key_rx_spec_read 3 12736 NULL
115864 +__mei_cl_async_send_12737 __mei_cl_async_send 3 12737 NULL
115865 +ieee80211_if_read_dot11MeshMaxRetries_12756 ieee80211_if_read_dot11MeshMaxRetries 3 12756 NULL
115866 +listxattr_12769 listxattr 3 12769 NULL
115867 +sctp_ssnmap_init_12772 sctp_ssnmap_init 3-2 12772 NULL
115868 +scsi_adjust_queue_depth_12802 scsi_adjust_queue_depth 3 12802 NULL
115869 +xfs_inumbers_fmt_12817 xfs_inumbers_fmt 3 12817 NULL
115870 +readq_12825 readq 0 12825 NULL
115871 +SyS_add_key_12834 SyS_add_key 4 12834 NULL
115872 +gfs2_log_reserve_12835 gfs2_log_reserve 0 12835 NULL
115873 +TSS_authhmac_12839 TSS_authhmac 3 12839 NULL
115874 +spidev_sync_12842 spidev_sync 0 12842 NULL nohasharray
115875 +hpsa_pci_find_memory_BAR_12842 hpsa_pci_find_memory_BAR 0 12842 &spidev_sync_12842
115876 +spidev_ioctl_12846 spidev_ioctl 2 12846 NULL
115877 +xfs_rtallocate_extent_exact_12865 xfs_rtallocate_extent_exact 0 12865 NULL
115878 +ath9k_dump_4k_modal_eeprom_12883 ath9k_dump_4k_modal_eeprom 3-2 12883 NULL
115879 +get_leb_cnt_12892 get_leb_cnt 0-2 12892 NULL
115880 +niu_xcvr_init_12901 niu_xcvr_init 0 12901 NULL
115881 +_regmap_raw_read_12902 _regmap_raw_read 0 12902 NULL
115882 +get_virtual_node_size_12908 get_virtual_node_size 0 12908 NULL
115883 +rds_pages_in_vec_12922 rds_pages_in_vec 0 12922 NULL
115884 +SYSC_sendfile_12936 SYSC_sendfile 4 12936 NULL
115885 +do_inode_permission_12946 do_inode_permission 0 12946 NULL
115886 +myri10ge_update_mac_address_12962 myri10ge_update_mac_address 0 12962 NULL
115887 +bm_status_write_12964 bm_status_write 3 12964 NULL
115888 +ath5k_eeprom_read_ctl_info_12979 ath5k_eeprom_read_ctl_info 0 12979 NULL
115889 +raid56_parity_recover_12987 raid56_parity_recover 5 12987 NULL
115890 +TransmitTcb_12989 TransmitTcb 4 12989 NULL
115891 +sk_peek_offset_12991 sk_peek_offset 0 12991 NULL
115892 +__btrfs_direct_write_13007 __btrfs_direct_write 4-0 13007 NULL
115893 +bset_prev_bytes_13020 bset_prev_bytes 0 13020 NULL
115894 +subsystem_filter_write_13022 subsystem_filter_write 3 13022 NULL
115895 +generic_segment_checks_13041 generic_segment_checks 0 13041 NULL
115896 +SyS_sendfile64_13043 SyS_sendfile64 4 13043 NULL
115897 +ocfs2_write_begin_13045 ocfs2_write_begin 3-4 13045 NULL
115898 +__dn_setsockopt_13060 __dn_setsockopt 5 13060 NULL nohasharray
115899 +ptlrpc_lprocfs_threads_min_seq_write_13060 ptlrpc_lprocfs_threads_min_seq_write 3 13060 &__dn_setsockopt_13060
115900 +t4vf_query_params_13061 t4vf_query_params 0 13061 NULL
115901 +biovec_create_pool_13079 biovec_create_pool 2 13079 NULL
115902 +xattr_getsecurity_13090 xattr_getsecurity 0 13090 NULL
115903 +pcmcia_loop_config_13099 pcmcia_loop_config 0 13099 NULL
115904 +ttm_dma_pool_alloc_new_pages_13105 ttm_dma_pool_alloc_new_pages 3 13105 NULL
115905 +SyS_msgrcv_13109 SyS_msgrcv 3 13109 NULL
115906 +snd_rme96_playback_copy_13111 snd_rme96_playback_copy 5 13111 NULL
115907 +snd_pcm_lib_preallocate_pages_for_all_13112 snd_pcm_lib_preallocate_pages_for_all 0 13112 NULL
115908 +bfad_debugfs_read_13119 bfad_debugfs_read 3 13119 NULL
115909 +blk_update_request_13146 blk_update_request 3 13146 NULL
115910 +vnic_dev_alloc_desc_ring_13158 vnic_dev_alloc_desc_ring 0 13158 NULL
115911 +pt1_init_adapters_13168 pt1_init_adapters 0 13168 NULL
115912 +caif_stream_recvmsg_13173 caif_stream_recvmsg 4 13173 NULL
115913 +pwr_disable_ps_read_13176 pwr_disable_ps_read 3 13176 NULL
115914 +ucs2_strlen_13178 ucs2_strlen 0 13178 NULL
115915 +dgrp_net_ioctl_13183 dgrp_net_ioctl 2 13183 NULL
115916 +create_trace_uprobe_13184 create_trace_uprobe 1 13184 NULL
115917 +comedi_read_13199 comedi_read 3 13199 NULL
115918 +hash_ipport4_expire_13201 hash_ipport4_expire 4 13201 NULL
115919 +mmc_ext_csd_read_13205 mmc_ext_csd_read 3 13205 NULL
115920 +svm_msrpm_offset_13220 svm_msrpm_offset 0-1 13220 NULL
115921 +fnic_trace_ctrl_write_13229 fnic_trace_ctrl_write 3 13229 NULL
115922 +tg3_phy_cl45_write_13238 tg3_phy_cl45_write 0 13238 NULL
115923 +_iwl_dbgfs_disable_power_off_write_13243 _iwl_dbgfs_disable_power_off_write 3 13243 NULL
115924 +asix_read_cmd_13245 asix_read_cmd 5 13245 NULL
115925 +init_tid_tabs_13252 init_tid_tabs 2-3-4 13252 NULL
115926 +bio_integrity_trim_13259 bio_integrity_trim 3-2 13259 NULL
115927 +simple_attr_write_13260 simple_attr_write 3 13260 NULL
115928 +pmcraid_notify_aen_13274 pmcraid_notify_aen 3 13274 NULL
115929 +devm_regulator_bulk_register_supply_alias_13278 devm_regulator_bulk_register_supply_alias 0 13278 NULL
115930 +il4965_stats_flag_13281 il4965_stats_flag 0-3 13281 NULL
115931 +lpfc_idiag_mbxacc_get_setup_13282 lpfc_idiag_mbxacc_get_setup 0 13282 NULL
115932 +platform_device_add_resources_13289 platform_device_add_resources 0 13289 NULL
115933 +sd_major_13294 sd_major 0-1 13294 NULL
115934 +read_file_phy_err_13318 read_file_phy_err 3 13318 NULL
115935 +kvm_read_nested_guest_page_13337 kvm_read_nested_guest_page 5 13337 NULL
115936 +round_event_name_len_13348 round_event_name_len 0 13348 NULL
115937 +hscx_empty_fifo_13360 hscx_empty_fifo 2 13360 NULL
115938 +ttm_bo_device_init_13362 ttm_bo_device_init 0 13362 NULL
115939 +xfs_btree_delrec_13364 xfs_btree_delrec 0 13364 NULL
115940 +iso_sched_alloc_13377 iso_sched_alloc 1 13377 NULL nohasharray
115941 +wep_key_not_found_read_13377 wep_key_not_found_read 3 13377 &iso_sched_alloc_13377
115942 +ext4_meta_trans_blocks_13380 ext4_meta_trans_blocks 0-3-2 13380 NULL
115943 +lov_mds_md_size_13388 lov_mds_md_size 0-1 13388 NULL nohasharray
115944 +dis_bypass_write_13388 dis_bypass_write 3 13388 &lov_mds_md_size_13388
115945 +ocfs2_inode_lock_update_13414 ocfs2_inode_lock_update 0 13414 NULL
115946 +netxen_alloc_sds_rings_13417 netxen_alloc_sds_rings 2 13417 NULL
115947 +compat_SyS_sendfile64_13420 compat_SyS_sendfile64 4 13420 NULL
115948 +request_firmware_nowait_13439 request_firmware_nowait 0 13439 NULL
115949 +sctp_setsockopt_peer_primary_addr_13440 sctp_setsockopt_peer_primary_addr 3 13440 NULL
115950 +ath6kl_cfg80211_connect_event_13443 ath6kl_cfg80211_connect_event 8-9-7 13443 NULL
115951 +mthca_load_fw_13447 mthca_load_fw 0 13447 NULL
115952 +sb_init_dio_done_wq_13482 sb_init_dio_done_wq 0 13482 NULL
115953 +data_read_13494 data_read 3 13494 NULL nohasharray
115954 +ata_pci_bmdma_prepare_host_13494 ata_pci_bmdma_prepare_host 0 13494 &data_read_13494
115955 +ioat_chansts_32_13506 ioat_chansts_32 0 13506 NULL
115956 +ocfs2_align_bytes_to_blocks_13512 ocfs2_align_bytes_to_blocks 0-2 13512 NULL
115957 +core_status_13515 core_status 4 13515 NULL
115958 +smk_write_mapped_13519 smk_write_mapped 3 13519 NULL
115959 +bm_init_13529 bm_init 2 13529 NULL
115960 +request_any_context_irq_13530 request_any_context_irq 0 13530 NULL
115961 +dm1105_hw_init_13538 dm1105_hw_init 0 13538 NULL
115962 +vfio_cap_len_13549 vfio_cap_len 0 13549 NULL
115963 +llcp_sock_recvmsg_13556 llcp_sock_recvmsg 4 13556 NULL nohasharray
115964 +migrate_page_move_mapping_13556 migrate_page_move_mapping 0 13556 &llcp_sock_recvmsg_13556
115965 +SyS_vm86_13557 SyS_vm86 2 13557 NULL
115966 +ieee80211_if_read_ap_power_level_13558 ieee80211_if_read_ap_power_level 3 13558 NULL
115967 +hash_net4_expire_13559 hash_net4_expire 4 13559 NULL
115968 +ubifs_get_idx_gc_leb_13566 ubifs_get_idx_gc_leb 0 13566 NULL nohasharray
115969 +mwifiex_init_rxq_ring_13566 mwifiex_init_rxq_ring 0 13566 &ubifs_get_idx_gc_leb_13566
115970 +read_file_antenna_13574 read_file_antenna 3 13574 NULL
115971 +cache_write_13589 cache_write 3 13589 NULL
115972 +Rd_Indx_13602 Rd_Indx 3-2 13602 NULL
115973 +wm8994_bulk_write_13615 wm8994_bulk_write 2-3 13615 NULL
115974 +__ntfs_grab_cache_pages_13617 __ntfs_grab_cache_pages 0 13617 NULL
115975 +pmcraid_get_minor_13619 pmcraid_get_minor 0 13619 NULL
115976 +iio_device_add_event_sysfs_13627 iio_device_add_event_sysfs 0 13627 NULL nohasharray
115977 +fnic_dev_wait_13627 fnic_dev_wait 0 13627 &iio_device_add_event_sysfs_13627
115978 +packet_snd_13634 packet_snd 3 13634 NULL
115979 +device_rename_13653 device_rename 0 13653 NULL
115980 +blk_msg_write_13655 blk_msg_write 3 13655 NULL
115981 +cache_downcall_13666 cache_downcall 3 13666 NULL
115982 +bcm2048_set_fm_search_rssi_threshold_13668 bcm2048_set_fm_search_rssi_threshold 0 13668 NULL
115983 +intel_gpio_to_irq_13679 intel_gpio_to_irq 2 13679 NULL
115984 +ext3_xattr_list_entries_13682 ext3_xattr_list_entries 0 13682 NULL
115985 +nv94_aux_13689 nv94_aux 2-5 13689 NULL
115986 +usb_get_string_13693 usb_get_string 0 13693 NULL
115987 +pt1_init_frontends_13701 pt1_init_frontends 0 13701 NULL
115988 +fw_iso_buffer_alloc_13704 fw_iso_buffer_alloc 2 13704 NULL
115989 +mthca_cmd_wait_13707 mthca_cmd_wait 0 13707 NULL
115990 +ocfs2_cache_block_dealloc_13731 ocfs2_cache_block_dealloc 0 13731 NULL
115991 +ql_wait_reg_rdy_13741 ql_wait_reg_rdy 0 13741 NULL
115992 +audit_unpack_string_13748 audit_unpack_string 3 13748 NULL
115993 +ieee802154_alloc_device_13767 ieee802154_alloc_device 1 13767 NULL
115994 +fb_sys_read_13778 fb_sys_read 3 13778 NULL
115995 +ath6kl_mgmt_powersave_ap_13791 ath6kl_mgmt_powersave_ap 6 13791 NULL
115996 +mthca_SET_ICM_SIZE_13793 mthca_SET_ICM_SIZE 0 13793 NULL
115997 +e100_rx_alloc_list_13812 e100_rx_alloc_list 0 13812 NULL
115998 +random_read_13815 random_read 3 13815 NULL
115999 +mutex_lock_interruptible_nested_13817 mutex_lock_interruptible_nested 0 13817 NULL
116000 +hsi_register_board_info_13820 hsi_register_board_info 2 13820 NULL
116001 +___mei_cl_send_13821 ___mei_cl_send 3 13821 NULL
116002 +i2c_bit_add_bus_13840 i2c_bit_add_bus 0 13840 NULL
116003 +enc_pools_insert_13849 enc_pools_insert 3 13849 NULL
116004 +evdev_ioctl_compat_13851 evdev_ioctl_compat 2 13851 NULL
116005 +compat_ip_setsockopt_13870 compat_ip_setsockopt 5 13870 NULL
116006 +qp_memcpy_to_queue_13886 qp_memcpy_to_queue 5-2 13886 NULL nohasharray
116007 +__fsnotify_parent_13886 __fsnotify_parent 0 13886 &qp_memcpy_to_queue_13886
116008 +snd_pcm_aio_read_13900 snd_pcm_aio_read 3 13900 NULL
116009 +cfg80211_inform_bss_width_13933 cfg80211_inform_bss_width 9 13933 NULL
116010 +ext3_xattr_block_get_13936 ext3_xattr_block_get 0 13936 NULL
116011 +ieee80211_if_read_dot11MeshForwarding_13940 ieee80211_if_read_dot11MeshForwarding 3 13940 NULL nohasharray
116012 +ocfs2_xa_value_truncate_13940 ocfs2_xa_value_truncate 2 13940 &ieee80211_if_read_dot11MeshForwarding_13940
116013 +t4_wait_dev_ready_13941 t4_wait_dev_ready 0 13941 NULL
116014 +iwl_dbgfs_protection_mode_read_13943 iwl_dbgfs_protection_mode_read 3 13943 NULL
116015 +ieee80211_if_read_min_discovery_timeout_13946 ieee80211_if_read_min_discovery_timeout 3 13946 NULL
116016 +lpfc_idiag_queacc_read_13950 lpfc_idiag_queacc_read 3 13950 NULL nohasharray
116017 +pagecache_write_end_13950 pagecache_write_end 0 13950 &lpfc_idiag_queacc_read_13950
116018 +osc_grant_shrink_interval_seq_write_13952 osc_grant_shrink_interval_seq_write 3 13952 NULL
116019 +ocfs2_refresh_slot_info_13957 ocfs2_refresh_slot_info 0 13957 NULL
116020 +snd_pcm_plug_slave_size_13967 snd_pcm_plug_slave_size 0-2 13967 NULL
116021 +qcam_read_13977 qcam_read 3 13977 NULL
116022 +dsp_read_13980 dsp_read 2 13980 NULL
116023 +dvb_demux_read_13981 dvb_demux_read 3 13981 NULL
116024 +sddr09_write_data_14014 sddr09_write_data 3 14014 NULL
116025 +btrfs_get_blocks_direct_14016 btrfs_get_blocks_direct 2 14016 NULL
116026 +dmi_format_ids_14018 dmi_format_ids 2 14018 NULL
116027 +iscsi_create_flashnode_conn_14022 iscsi_create_flashnode_conn 4 14022 NULL
116028 +pci_add_ext_cap_save_buffer_14032 pci_add_ext_cap_save_buffer 3 14032 NULL
116029 +dvb_usercopy_14036 dvb_usercopy 2 14036 NULL
116030 +read_def_modal_eeprom_14041 read_def_modal_eeprom 3 14041 NULL
116031 +xfs_bmap_alloc_14044 xfs_bmap_alloc 0 14044 NULL
116032 +ieee80211_if_fmt_aid_14055 ieee80211_if_fmt_aid 3 14055 NULL
116033 +ovs_nla_alloc_flow_actions_14056 ovs_nla_alloc_flow_actions 1 14056 NULL
116034 +sta_agg_status_read_14058 sta_agg_status_read 3 14058 NULL
116035 +lov_stripeoffset_seq_write_14078 lov_stripeoffset_seq_write 3 14078 NULL
116036 +cp_tm1217_write_14079 cp_tm1217_write 3 14079 NULL
116037 +do_proc_readlink_14096 do_proc_readlink 3 14096 NULL
116038 +enic_set_mac_addr_14119 enic_set_mac_addr 0 14119 NULL
116039 +ext4_journal_blocks_per_page_14127 ext4_journal_blocks_per_page 0 14127 NULL
116040 +isku_sysfs_read_light_14140 isku_sysfs_read_light 6 14140 NULL
116041 +em_canid_change_14150 em_canid_change 3 14150 NULL
116042 +gsm_dlci_data_14155 gsm_dlci_data 3 14155 NULL
116043 +midi_alloc_ep_req_14159 midi_alloc_ep_req 2 14159 NULL
116044 +ccp_alloc_ksb_14167 ccp_alloc_ksb 2 14167 NULL
116045 +print_input_mask_14168 print_input_mask 3-0 14168 NULL
116046 +ocfs2_split_and_insert_14171 ocfs2_split_and_insert 0 14171 NULL nohasharray
116047 +ican3_msg_newhostif_14171 ican3_msg_newhostif 0 14171 &ocfs2_split_and_insert_14171
116048 +ocfs2_xattr_value_truncate_14183 ocfs2_xattr_value_truncate 3 14183 NULL
116049 +datafab_read_data_14186 datafab_read_data 4 14186 NULL
116050 +do_splice_14196 do_splice 5 14196 NULL
116051 +hfsplus_brec_find_14200 hfsplus_brec_find 0 14200 NULL
116052 +vfio_user_config_read_14202 vfio_user_config_read 0 14202 NULL
116053 +alloc_async_14208 alloc_async 1 14208 NULL
116054 +ath6kl_regread_write_14220 ath6kl_regread_write 3 14220 NULL
116055 +vfio_direct_config_read_14231 vfio_direct_config_read 3-0 14231 NULL
116056 +ieee80211_if_write_uapsd_max_sp_len_14233 ieee80211_if_write_uapsd_max_sp_len 3 14233 NULL
116057 +dma_declare_coherent_memory_14244 dma_declare_coherent_memory 4 14244 NULL
116058 +btrfs_token_file_extent_ram_bytes_14247 btrfs_token_file_extent_ram_bytes 0 14247 NULL
116059 +ath6kl_connect_event_14267 ath6kl_connect_event 7-8-9 14267 NULL
116060 +rr_status_14293 rr_status 5 14293 NULL
116061 +stex_set_dma_mask_14300 stex_set_dma_mask 0 14300 NULL
116062 +read_default_ldt_14302 read_default_ldt 2 14302 NULL
116063 +update_rgrp_lvb_14303 update_rgrp_lvb 0 14303 NULL
116064 +xfs_qm_qino_alloc_14309 xfs_qm_qino_alloc 0 14309 NULL
116065 +i2c_add_numbered_adapter_14311 i2c_add_numbered_adapter 0 14311 NULL
116066 +oo_objects_14319 oo_objects 0 14319 NULL
116067 +ll_get_user_pages_14328 ll_get_user_pages 3-2-0 14328 NULL
116068 +p9_client_zc_rpc_14345 p9_client_zc_rpc 7 14345 NULL
116069 +alloc_tx_struct_14349 alloc_tx_struct 1 14349 NULL
116070 +ath5k_hw_nic_wakeup_14352 ath5k_hw_nic_wakeup 0 14352 NULL
116071 +hash_ipportnet4_expire_14354 hash_ipportnet4_expire 4 14354 NULL
116072 +snd_pcm_lib_readv_14363 snd_pcm_lib_readv 0-3 14363 NULL
116073 +lowpan_read_14369 lowpan_read 3 14369 NULL
116074 +snd_ctl_create_14377 snd_ctl_create 0 14377 NULL
116075 +ath6kl_regdump_read_14393 ath6kl_regdump_read 3 14393 NULL
116076 +smk_write_onlycap_14400 smk_write_onlycap 3 14400 NULL
116077 +mtd_concat_create_14416 mtd_concat_create 2 14416 NULL
116078 +get_kcore_size_14425 get_kcore_size 0 14425 NULL
116079 +_iwl_dbgfs_sram_write_14439 _iwl_dbgfs_sram_write 3 14439 NULL
116080 +block_size_14443 block_size 0 14443 NULL
116081 +fnic_get_vnic_config_14445 fnic_get_vnic_config 0 14445 NULL
116082 +t4_read_reg64_14447 t4_read_reg64 0 14447 NULL
116083 +lmv_user_md_size_14456 lmv_user_md_size 0-1 14456 NULL
116084 +snd_emu10k1_proc_spdif_status_14457 snd_emu10k1_proc_spdif_status 4-5 14457 NULL
116085 +ath10k_write_htt_stats_mask_14458 ath10k_write_htt_stats_mask 3 14458 NULL
116086 +lustre_msg_size_v2_14470 lustre_msg_size_v2 0 14470 NULL
116087 +dma_transfer_size_14473 dma_transfer_size 0 14473 NULL
116088 +udplite_getfrag_14479 udplite_getfrag 3-4 14479 NULL
116089 +ieee80211_if_read_dot11MeshGateAnnouncementProtocol_14486 ieee80211_if_read_dot11MeshGateAnnouncementProtocol 3 14486 NULL
116090 +split_state_14491 split_state 0 14491 NULL
116091 +ocfs2_debug_read_14507 ocfs2_debug_read 3 14507 NULL
116092 +snd_at73c213_mixer_14530 snd_at73c213_mixer 0 14530 NULL
116093 +mfd_platform_add_cell_14532 mfd_platform_add_cell 0 14532 NULL
116094 +ep0_write_14536 ep0_write 3 14536 NULL nohasharray
116095 +dataflash_read_user_otp_14536 dataflash_read_user_otp 3-2 14536 &ep0_write_14536
116096 +picolcd_debug_eeprom_read_14549 picolcd_debug_eeprom_read 3 14549 NULL
116097 +t4_wait_op_done_val_14550 t4_wait_op_done_val 0 14550 NULL
116098 +snd_rawmidi_alloc_substreams_14559 snd_rawmidi_alloc_substreams 0 14559 NULL
116099 +qp_host_alloc_queue_14566 qp_host_alloc_queue 1 14566 NULL
116100 +SyS_setdomainname_14569 SyS_setdomainname 2 14569 NULL
116101 +stuffed_readpage_14581 stuffed_readpage 0 14581 NULL
116102 +idmap_pipe_downcall_14591 idmap_pipe_downcall 3 14591 NULL
116103 +ceph_osdc_alloc_request_14597 ceph_osdc_alloc_request 3 14597 NULL
116104 +walk_phys_14601 walk_phys 0 14601 NULL
116105 +ocfs2_steal_meta_14602 ocfs2_steal_meta 0 14602 NULL
116106 +dbJoin_14644 dbJoin 0 14644 NULL
116107 +profile_replace_14652 profile_replace 3 14652 NULL
116108 +usnic_vnic_dump_14662 usnic_vnic_dump 3 14662 NULL
116109 +min_bytes_needed_14675 min_bytes_needed 0 14675 NULL
116110 +nvme_trans_log_info_exceptions_14677 nvme_trans_log_info_exceptions 3 14677 NULL
116111 +pipeline_enc_tx_stat_fifo_int_read_14680 pipeline_enc_tx_stat_fifo_int_read 3 14680 NULL
116112 +ieee80211_if_fmt_rc_rateidx_mask_2ghz_14683 ieee80211_if_fmt_rc_rateidx_mask_2ghz 3 14683 NULL
116113 +SyS_fsetxattr_14702 SyS_fsetxattr 4 14702 NULL
116114 +persistent_ram_ecc_string_14704 persistent_ram_ecc_string 0 14704 NULL
116115 +u_audio_playback_14709 u_audio_playback 3 14709 NULL
116116 +rtw_cbuf_alloc_14710 rtw_cbuf_alloc 1 14710 NULL
116117 +vfd_write_14717 vfd_write 3 14717 NULL
116118 +SyS_sendfile_14718 SyS_sendfile 4 14718 NULL
116119 +__blk_end_request_14729 __blk_end_request 3 14729 NULL
116120 +raid1_resize_14740 raid1_resize 2 14740 NULL nohasharray
116121 +c2_init_pd_table_14740 c2_init_pd_table 0 14740 &raid1_resize_14740
116122 +i915_error_state_buf_init_14742 i915_error_state_buf_init 2 14742 NULL
116123 +btrfs_inode_extref_name_len_14752 btrfs_inode_extref_name_len 0 14752 NULL
116124 +rx_rx_cmplt_read_14753 rx_rx_cmplt_read 3 14753 NULL nohasharray
116125 +ide_pci_enable_14753 ide_pci_enable 0 14753 &rx_rx_cmplt_read_14753
116126 +regmap_range_read_file_14775 regmap_range_read_file 3 14775 NULL
116127 +sta_dev_read_14782 sta_dev_read 3 14782 NULL
116128 +keys_proc_write_14792 keys_proc_write 3 14792 NULL nohasharray
116129 +cp_tm1217_read_14792 cp_tm1217_read 3 14792 &keys_proc_write_14792
116130 +ext4_kvmalloc_14796 ext4_kvmalloc 1 14796 NULL
116131 +__kfifo_in_14797 __kfifo_in 3-0 14797 NULL
116132 +hpet_readl_14801 hpet_readl 0 14801 NULL nohasharray
116133 +snd_als300_gcr_read_14801 snd_als300_gcr_read 0 14801 &hpet_readl_14801
116134 +xfs_btree_kill_iroot_14824 xfs_btree_kill_iroot 0 14824 NULL
116135 +do_tune_cpucache_14828 do_tune_cpucache 2 14828 NULL
116136 +mrp_attr_create_14853 mrp_attr_create 3 14853 NULL
116137 +lcd_write_14857 lcd_write 3 14857 NULL
116138 +get_user_cpu_mask_14861 get_user_cpu_mask 2 14861 NULL
116139 +mlx4_init_qp_table_14876 mlx4_init_qp_table 0 14876 NULL
116140 +spi_init_queue_14883 spi_init_queue 0 14883 NULL
116141 +xfs_bmapi_convert_unwritten_14886 xfs_bmapi_convert_unwritten 0 14886 NULL
116142 +gmux_index_read8_14890 gmux_index_read8 0 14890 NULL
116143 +acpi_os_allocate_14892 acpi_os_allocate 1 14892 NULL
116144 +SYSC_readv_14901 SYSC_readv 3 14901 NULL
116145 +regmap_irq_get_virq_14910 regmap_irq_get_virq 2 14910 NULL
116146 +__arch_hweight64_14923 __arch_hweight64 0 14923 NULL nohasharray
116147 +qp_memcpy_to_queue_iov_14923 qp_memcpy_to_queue_iov 5-2 14923 &__arch_hweight64_14923
116148 +ocfs2_expand_nonsparse_inode_14936 ocfs2_expand_nonsparse_inode 3-4 14936 NULL
116149 +t4vf_port_init_14942 t4vf_port_init 0 14942 NULL
116150 +queue_cnt_14951 queue_cnt 0 14951 NULL
116151 +unix_dgram_recvmsg_14952 unix_dgram_recvmsg 4 14952 NULL
116152 +videobuf_read_stream_14956 videobuf_read_stream 3 14956 NULL
116153 +mce_flush_rx_buffer_14976 mce_flush_rx_buffer 2 14976 NULL
116154 +setkey_14987 setkey 3 14987 NULL nohasharray
116155 +gpio_twl4030_write_14987 gpio_twl4030_write 1 14987 &setkey_14987
116156 +blk_integrity_tuple_size_15027 blk_integrity_tuple_size 0 15027 NULL
116157 +read_file_node_aggr_15040 read_file_node_aggr 3 15040 NULL
116158 +cld_pipe_downcall_15058 cld_pipe_downcall 3 15058 NULL
116159 +ieee80211_if_read_uapsd_max_sp_len_15067 ieee80211_if_read_uapsd_max_sp_len 3 15067 NULL
116160 +nfs4_write_cached_acl_15070 nfs4_write_cached_acl 4 15070 NULL
116161 +ntfs_copy_from_user_15072 ntfs_copy_from_user 0-5-3 15072 NULL
116162 +pppoe_recvmsg_15073 pppoe_recvmsg 4 15073 NULL
116163 +smscore_load_firmware_family2_15086 smscore_load_firmware_family2 3 15086 NULL
116164 +xfs_btree_insrec_15090 xfs_btree_insrec 0 15090 NULL
116165 +btrfs_readpage_15094 btrfs_readpage 0 15094 NULL
116166 +init_cx18_i2c_15097 init_cx18_i2c 0 15097 NULL nohasharray
116167 +t4_fw_hello_15097 t4_fw_hello 0 15097 &init_cx18_i2c_15097
116168 +compat_SyS_pwritev_15118 compat_SyS_pwritev 3 15118 NULL
116169 +hex_dump_to_buffer_15121 hex_dump_to_buffer 6 15121 NULL
116170 +start_port_15124 start_port 0 15124 NULL
116171 +ipwireless_ppp_mru_15153 ipwireless_ppp_mru 0 15153 NULL
116172 +setup_sge_queues_15154 setup_sge_queues 0 15154 NULL
116173 +self_check_not_bad_15175 self_check_not_bad 0 15175 NULL
116174 +t4_sge_alloc_ofld_txq_15179 t4_sge_alloc_ofld_txq 0 15179 NULL
116175 +SYSC_setdomainname_15180 SYSC_setdomainname 2 15180 NULL
116176 +atp867x_set_priv_15182 atp867x_set_priv 0 15182 NULL
116177 +iscsi_create_endpoint_15193 iscsi_create_endpoint 1 15193 NULL
116178 +mtt_alloc_res_15211 mtt_alloc_res 5 15211 NULL
116179 +bfad_debugfs_write_regrd_15218 bfad_debugfs_write_regrd 3 15218 NULL
116180 +mlx4_setup_hca_15238 mlx4_setup_hca 0 15238 NULL
116181 +iwl_dbgfs_sram_write_15239 iwl_dbgfs_sram_write 3 15239 NULL
116182 +il_dbgfs_rx_stats_read_15243 il_dbgfs_rx_stats_read 3 15243 NULL
116183 +simple_strtol_15273 simple_strtol 0 15273 NULL
116184 +fw_realloc_buffer_15280 fw_realloc_buffer 2 15280 NULL
116185 +arch_enable_uv_irq_15294 arch_enable_uv_irq 0-2 15294 NULL
116186 +ocfs2_read_refcount_block_15305 ocfs2_read_refcount_block 0 15305 NULL
116187 +xlog_ticket_alloc_15335 xlog_ticket_alloc 2 15335 NULL
116188 +kovaplus_sysfs_read_15337 kovaplus_sysfs_read 6 15337 NULL
116189 +ioread16_15342 ioread16 0 15342 NULL
116190 +ept_prefetch_gpte_15348 ept_prefetch_gpte 4 15348 NULL
116191 +get_leaf_nr_15357 get_leaf_nr 0 15357 NULL
116192 +acpi_ut_create_string_object_15360 acpi_ut_create_string_object 1 15360 NULL
116193 +ext4_direct_IO_15369 ext4_direct_IO 4 15369 NULL
116194 +graph_depth_read_15371 graph_depth_read 3 15371 NULL
116195 +fq_codel_zalloc_15378 fq_codel_zalloc 1 15378 NULL
116196 +domain_flush_pages_15379 domain_flush_pages 2-3 15379 NULL
116197 +alloc_fddidev_15382 alloc_fddidev 1 15382 NULL
116198 +_regmap_read_15396 _regmap_read 0 15396 NULL
116199 +mlx4_cmd_wait_15399 mlx4_cmd_wait 0 15399 NULL
116200 +pipeline_csum_to_rx_xfer_swi_read_15403 pipeline_csum_to_rx_xfer_swi_read 3 15403 NULL
116201 +get_modalias_15406 get_modalias 2 15406 NULL
116202 +blockdev_direct_IO_15408 blockdev_direct_IO 5 15408 NULL
116203 +__videobuf_copy_to_user_15423 __videobuf_copy_to_user 4-0 15423 NULL
116204 +rtw_cfg80211_rx_action_p2p_15432 rtw_cfg80211_rx_action_p2p 3 15432 NULL
116205 +tty_register_driver_15433 tty_register_driver 0 15433 NULL
116206 +tcp_mtu_to_mss_15438 tcp_mtu_to_mss 2-0 15438 NULL nohasharray
116207 +dac33_read_id_15438 dac33_read_id 0 15438 &tcp_mtu_to_mss_15438
116208 +hpsa_change_queue_depth_15449 hpsa_change_queue_depth 2 15449 NULL
116209 +memweight_15450 memweight 2 15450 NULL
116210 +__mutex_lock_killable_slowpath_15472 __mutex_lock_killable_slowpath 0 15472 NULL
116211 +devm_gpio_request_one_15481 devm_gpio_request_one 0 15481 NULL
116212 +insert_old_idx_znode_15500 insert_old_idx_znode 0 15500 NULL
116213 +zd_chip_is_zd1211b_15518 zd_chip_is_zd1211b 0 15518 NULL nohasharray
116214 +ata_pci_sff_prepare_host_15518 ata_pci_sff_prepare_host 0 15518 &zd_chip_is_zd1211b_15518
116215 +ifx_spi_write_15531 ifx_spi_write 3 15531 NULL
116216 +da9052_bat_irq_15533 da9052_bat_irq 1 15533 NULL
116217 +p9_check_zc_errors_15534 p9_check_zc_errors 4 15534 NULL
116218 +xfrm_state_mtu_15548 xfrm_state_mtu 0-2 15548 NULL
116219 +snd_pcm_channel_info_15572 snd_pcm_channel_info 0 15572 NULL
116220 +persistent_status_15574 persistent_status 4 15574 NULL
116221 +bnx2fc_process_unsol_compl_15576 bnx2fc_process_unsol_compl 2 15576 NULL
116222 +vme_user_write_15587 vme_user_write 3 15587 NULL
116223 +ocfs2_truncate_rec_15595 ocfs2_truncate_rec 0 15595 NULL
116224 +compat_fillonedir_15620 compat_fillonedir 3 15620 NULL
116225 +pci_user_read_config_dword_15624 pci_user_read_config_dword 0 15624 NULL
116226 +proc_loginuid_read_15631 proc_loginuid_read 3 15631 NULL
116227 +mlx4_SET_PORT_15636 mlx4_SET_PORT 0 15636 NULL
116228 +tomoyo_scan_bprm_15642 tomoyo_scan_bprm 2-4 15642 NULL nohasharray
116229 +sk_memory_allocated_add_15642 sk_memory_allocated_add 2 15642 &tomoyo_scan_bprm_15642 nohasharray
116230 +pipeline_hs_tx_stat_fifo_int_read_15642 pipeline_hs_tx_stat_fifo_int_read 3 15642 &sk_memory_allocated_add_15642
116231 +joydev_handle_JSIOCSBTNMAP_15643 joydev_handle_JSIOCSBTNMAP 3 15643 NULL
116232 +fs_path_add_15648 fs_path_add 3 15648 NULL
116233 +__do_readpage_15652 __do_readpage 0 15652 NULL
116234 +xsd_read_15653 xsd_read 3 15653 NULL
116235 +unix_bind_15668 unix_bind 3 15668 NULL
116236 +dm_read_15674 dm_read 3 15674 NULL nohasharray
116237 +SyS_connect_15674 SyS_connect 3 15674 &dm_read_15674
116238 +uinput_str_to_user_15695 uinput_str_to_user 3 15695 NULL
116239 +__sk_migrate_realloc_15709 __sk_migrate_realloc 3 15709 NULL
116240 +ocfs2_split_tree_15716 ocfs2_split_tree 0 15716 NULL
116241 +as3722_irq_get_virq_15718 as3722_irq_get_virq 2 15718 NULL
116242 +tracing_snapshot_write_15719 tracing_snapshot_write 3 15719 NULL
116243 +HiSax_readstatus_15752 HiSax_readstatus 2 15752 NULL
116244 +smk_read_direct_15803 smk_read_direct 3 15803 NULL
116245 +nameseq_list_15817 nameseq_list 3-0 15817 NULL nohasharray
116246 +gnttab_expand_15817 gnttab_expand 1 15817 &nameseq_list_15817
116247 +afs_proc_rootcell_write_15822 afs_proc_rootcell_write 3 15822 NULL
116248 +ql_start_tx_ring_15823 ql_start_tx_ring 0 15823 NULL
116249 +table_size_15851 table_size 0-1-2 15851 NULL
116250 +write_file_tx99_15856 write_file_tx99 3 15856 NULL
116251 +ubi_io_write_15870 ubi_io_write 0 15870 NULL nohasharray
116252 +media_entity_init_15870 media_entity_init 2-4 15870 &ubi_io_write_15870
116253 +__mptctl_ioctl_15875 __mptctl_ioctl 2 15875 NULL
116254 +handler_set_err_15886 handler_set_err 0-2 15886 NULL
116255 +native_read_msr_15905 native_read_msr 0 15905 NULL
116256 +remove_ok_15910 remove_ok 0 15910 NULL
116257 +parse_audio_stream_data_15937 parse_audio_stream_data 3 15937 NULL
116258 +power_read_15939 power_read 3 15939 NULL
116259 +lpfc_idiag_drbacc_read_15948 lpfc_idiag_drbacc_read 3 15948 NULL
116260 +snd_pcm_lib_read_transfer_15952 snd_pcm_lib_read_transfer 5-2-4 15952 NULL
116261 +memblock_virt_alloc_try_nid_15954 memblock_virt_alloc_try_nid 1 15954 NULL
116262 +ar9003_mci_setup_15969 ar9003_mci_setup 0 15969 NULL
116263 +sht15_connection_reset_15973 sht15_connection_reset 0 15973 NULL
116264 +viafb_vt1636_proc_write_16018 viafb_vt1636_proc_write 3 16018 NULL
116265 +dev_alloc_name_16019 dev_alloc_name 0 16019 NULL
116266 +dccp_recvmsg_16056 dccp_recvmsg 4 16056 NULL
116267 +read_file_spectral_period_16057 read_file_spectral_period 3 16057 NULL
116268 +si5351_msynth_params_address_16062 si5351_msynth_params_address 0-1 16062 NULL
116269 +isr_tx_exch_complete_read_16103 isr_tx_exch_complete_read 3 16103 NULL
116270 +isr_hw_pm_mode_changes_read_16110 isr_hw_pm_mode_changes_read 3 16110 NULL nohasharray
116271 +dma_tx_requested_read_16110 dma_tx_requested_read 3 16110 &isr_hw_pm_mode_changes_read_16110
116272 +gfs2_jdesc_check_16122 gfs2_jdesc_check 0 16122 NULL
116273 +snd_dma_pointer_16126 snd_dma_pointer 0-2 16126 NULL
116274 +fsm_init_16134 fsm_init 2 16134 NULL
116275 +input_register_device_16147 input_register_device 0 16147 NULL
116276 +ext4_xattr_block_get_16148 ext4_xattr_block_get 0 16148 NULL
116277 +__clk_round_rate_16169 __clk_round_rate 0 16169 NULL
116278 +optimal_reclaimed_pages_16172 optimal_reclaimed_pages 0 16172 NULL
116279 +mapping_level_16188 mapping_level 2-0 16188 NULL
116280 +i40e_allocate_virt_mem_d_16191 i40e_allocate_virt_mem_d 3 16191 NULL
116281 +ath10k_htt_rx_ring_size_16201 ath10k_htt_rx_ring_size 0 16201 NULL
116282 +cipso_v4_map_cat_rng_hton_16203 cipso_v4_map_cat_rng_hton 0 16203 NULL
116283 +SyS_pselect6_16210 SyS_pselect6 1 16210 NULL
116284 +create_table_16213 create_table 2 16213 NULL
116285 +si476x_core_send_command_16219 si476x_core_send_command 4-6 16219 NULL
116286 +ath9k_hw_ar9287_dump_eeprom_16224 ath9k_hw_ar9287_dump_eeprom 5-4 16224 NULL
116287 +atomic_read_file_16227 atomic_read_file 3 16227 NULL
116288 +r6040_up_16233 r6040_up 0 16233 NULL
116289 +BcmGetSectionValStartOffset_16235 BcmGetSectionValStartOffset 0 16235 NULL
116290 +lov_prep_brw_set_16246 lov_prep_brw_set 3 16246 NULL
116291 +i40e_dbg_dump_read_16247 i40e_dbg_dump_read 3 16247 NULL
116292 +il_dbgfs_disable_ht40_write_16249 il_dbgfs_disable_ht40_write 3 16249 NULL
116293 +SyS_fgetxattr_16254 SyS_fgetxattr 4 16254 NULL
116294 +reiserfs_acl_count_16265 reiserfs_acl_count 0-1 16265 NULL
116295 +ocfs2_xattr_bucket_value_truncate_16279 ocfs2_xattr_bucket_value_truncate 4 16279 NULL
116296 +nand_bch_init_16280 nand_bch_init 3-2 16280 NULL nohasharray
116297 +drbd_setsockopt_16280 drbd_setsockopt 5 16280 &nand_bch_init_16280
116298 +account_16283 account 0-4-2 16283 NULL nohasharray
116299 +mirror_status_16283 mirror_status 5 16283 &account_16283
116300 +jumpshot_read_data_16287 jumpshot_read_data 4 16287 NULL
116301 +mo_xattr_get_16288 mo_xattr_get 0 16288 NULL
116302 +stk_allocate_buffers_16291 stk_allocate_buffers 2 16291 NULL
116303 +rbd_segment_offset_16293 rbd_segment_offset 0-2 16293 NULL
116304 +rsc_mgr_init_16299 rsc_mgr_init 3 16299 NULL
116305 +kvm_handle_hva_range_16312 kvm_handle_hva_range 2-3 16312 NULL
116306 +sysfs_create_groups_16360 sysfs_create_groups 0 16360 NULL
116307 +total_ps_buffered_read_16365 total_ps_buffered_read 3 16365 NULL
116308 +xfs_inobt_lookup_16367 xfs_inobt_lookup 0 16367 NULL
116309 +iscsi_tcp_conn_setup_16376 iscsi_tcp_conn_setup 2 16376 NULL
116310 +gfs2_dinode_in_16378 gfs2_dinode_in 0 16378 NULL
116311 +i8042_create_kbd_port_16379 i8042_create_kbd_port 0 16379 NULL
116312 +iio_device_add_event_16412 iio_device_add_event 0 16412 NULL
116313 +xfs_btree_check_block_16419 xfs_btree_check_block 0 16419 NULL
116314 +ieee80211_if_read_tsf_16420 ieee80211_if_read_tsf 3 16420 NULL
116315 +rxrpc_server_keyring_16431 rxrpc_server_keyring 3 16431 NULL
116316 +__bio_add_page_16435 __bio_add_page 0-4 16435 NULL
116317 +cmdline_store_16442 cmdline_store 4 16442 NULL
116318 +sf1_read_16451 sf1_read 0 16451 NULL
116319 +btrfs_truncate_inode_items_16452 btrfs_truncate_inode_items 4 16452 NULL
116320 +ocfs2_expand_refcount_tree_16455 ocfs2_expand_refcount_tree 0 16455 NULL
116321 +netlink_change_ngroups_16457 netlink_change_ngroups 2 16457 NULL
116322 +req_capsule_get_size_16467 req_capsule_get_size 0 16467 NULL
116323 +ocfs2_block_group_set_bits_16488 ocfs2_block_group_set_bits 0 16488 NULL
116324 +tracing_readme_read_16493 tracing_readme_read 3 16493 NULL
116325 +KEY_OFFSET_16504 KEY_OFFSET 0 16504 NULL
116326 +mthca_map_cmd_16510 mthca_map_cmd 0 16510 NULL
116327 +start_this_handle_16519 start_this_handle 0 16519 NULL
116328 +ath10k_htc_wait_target_16526 ath10k_htc_wait_target 0 16526 NULL
116329 +snd_interval_max_16529 snd_interval_max 0 16529 NULL
116330 +raid10_resize_16537 raid10_resize 2 16537 NULL
116331 +lpfc_debugfs_read_16566 lpfc_debugfs_read 3 16566 NULL
116332 +p54_convert_output_limits_16575 p54_convert_output_limits 0 16575 NULL
116333 +agp_allocate_memory_wrap_16576 agp_allocate_memory_wrap 1 16576 NULL
116334 +lustre_msg_hdr_size_v2_16589 lustre_msg_hdr_size_v2 0 16589 NULL
116335 +gmux_index_read32_16604 gmux_index_read32 0 16604 NULL
116336 +palmas_irq_get_virq_16613 palmas_irq_get_virq 2 16613 NULL
116337 +compat_SyS_migrate_pages_16618 compat_SyS_migrate_pages 2 16618 NULL
116338 +rtw_set_wpa_ie_16633 rtw_set_wpa_ie 3 16633 NULL
116339 +solo_tw28_init_16634 solo_tw28_init 0 16634 NULL
116340 +btrfs_get_token_32_16651 btrfs_get_token_32 0 16651 NULL
116341 +__add_to_page_cache_locked_16659 __add_to_page_cache_locked 0 16659 NULL
116342 +mfd_add_devices_16668 mfd_add_devices 0 16668 NULL
116343 +__wa_populate_dto_urb_16699 __wa_populate_dto_urb 3-4 16699 NULL
116344 +nilfs_chunk_size_16706 nilfs_chunk_size 0 16706 NULL
116345 +mlx4_QUERY_FW_16715 mlx4_QUERY_FW 0 16715 NULL
116346 +__proc_lnet_buffers_16717 __proc_lnet_buffers 5 16717 NULL
116347 +videobuf_dvb_register_bus_16740 videobuf_dvb_register_bus 0 16740 NULL
116348 +__copy_to_user_swizzled_16748 __copy_to_user_swizzled 3-4 16748 NULL
116349 +cafe_smbus_setup_16749 cafe_smbus_setup 0 16749 NULL
116350 +arcmsr_adjust_disk_queue_depth_16756 arcmsr_adjust_disk_queue_depth 2 16756 NULL
116351 +blk_rq_map_user_iov_16772 blk_rq_map_user_iov 5 16772 NULL
116352 +generic_write_end_16782 generic_write_end 0-5 16782 NULL
116353 +i2o_parm_issue_16790 i2o_parm_issue 0 16790 NULL
116354 +get_server_iovec_16804 get_server_iovec 2 16804 NULL
116355 +register_miscdev_16828 register_miscdev 0 16828 NULL
116356 +drm_malloc_ab_16831 drm_malloc_ab 1-2 16831 NULL
116357 +scsi_mode_sense_16835 scsi_mode_sense 5 16835 NULL
116358 +hfsplus_min_io_size_16859 hfsplus_min_io_size 0 16859 NULL
116359 +xfs_dialloc_ag_16868 xfs_dialloc_ag 0 16868 NULL
116360 +alloc_idx_lebs_16872 alloc_idx_lebs 2 16872 NULL nohasharray
116361 +xfs_iget_16872 xfs_iget 0 16872 &alloc_idx_lebs_16872
116362 +carl9170_debugfs_ampdu_state_read_16873 carl9170_debugfs_ampdu_state_read 3 16873 NULL
116363 +st_write_16874 st_write 3 16874 NULL
116364 +__kfifo_peek_n_16877 __kfifo_peek_n 0 16877 NULL
116365 +snd_gf1_mem_proc_dump_16926 snd_gf1_mem_proc_dump 5 16926 NULL nohasharray
116366 +psb_unlocked_ioctl_16926 psb_unlocked_ioctl 2 16926 &snd_gf1_mem_proc_dump_16926
116367 +usb_enumerate_device_16941 usb_enumerate_device 0 16941 NULL
116368 +_sp2d_alloc_16944 _sp2d_alloc 1-2-3 16944 NULL
116369 +squashfs_read_table_16945 squashfs_read_table 3 16945 NULL
116370 +sis_alloc_suspend_16951 sis_alloc_suspend 0 16951 NULL
116371 +keyctl_instantiate_key_iov_16969 keyctl_instantiate_key_iov 3 16969 NULL
116372 +fnic_intr_alloc_16971 fnic_intr_alloc 0 16971 NULL
116373 +ocfs2_read_quota_phys_block_16990 ocfs2_read_quota_phys_block 0 16990 NULL
116374 +ceph_read_dir_17005 ceph_read_dir 3 17005 NULL
116375 +copy_counters_to_user_17027 copy_counters_to_user 5 17027 NULL
116376 +ath9k_hw_eeprom_init_17038 ath9k_hw_eeprom_init 0 17038 NULL
116377 +C_SYSC_keyctl_17041 C_SYSC_keyctl 4 17041 NULL
116378 +jffs2_trusted_setxattr_17048 jffs2_trusted_setxattr 4 17048 NULL
116379 +__arch_hweight32_17060 __arch_hweight32 0 17060 NULL
116380 +sddr55_read_data_17072 sddr55_read_data 4 17072 NULL
116381 +dvb_dvr_read_17073 dvb_dvr_read 3 17073 NULL
116382 +simple_transaction_read_17076 simple_transaction_read 3 17076 NULL
116383 +carl9170_debugfs_mem_usage_read_17084 carl9170_debugfs_mem_usage_read 3 17084 NULL
116384 +entry_length_17093 entry_length 0 17093 NULL
116385 +ocfs2_get_refcount_cpos_end_17113 ocfs2_get_refcount_cpos_end 0 17113 NULL
116386 +write_mem_17114 write_mem 3 17114 NULL
116387 +pvr2_hdw_state_report_17121 pvr2_hdw_state_report 3 17121 NULL
116388 +br_sysfs_renameif_17142 br_sysfs_renameif 0 17142 NULL
116389 +nouveau_instobj_create__17144 nouveau_instobj_create_ 4 17144 NULL
116390 +jumpshot_write_data_17151 jumpshot_write_data 4 17151 NULL
116391 +t4_fw_reset_17157 t4_fw_reset 0 17157 NULL
116392 +sep_read_17161 sep_read 3 17161 NULL
116393 +befs_nls2utf_17163 befs_nls2utf 3 17163 NULL
116394 +tx_tx_start_templates_read_17164 tx_tx_start_templates_read 3 17164 NULL
116395 +UniStrnlen_17169 UniStrnlen 0 17169 NULL
116396 +access_remote_vm_17189 access_remote_vm 0 17189 NULL nohasharray
116397 +iwl_dbgfs_txfifo_flush_write_17189 iwl_dbgfs_txfifo_flush_write 3 17189 &access_remote_vm_17189 nohasharray
116398 +ocfs2_flock_handle_signal_17189 ocfs2_flock_handle_signal 0 17189 &iwl_dbgfs_txfifo_flush_write_17189
116399 +iscsit_find_cmd_from_itt_or_dump_17194 iscsit_find_cmd_from_itt_or_dump 3 17194 NULL nohasharray
116400 +driver_state_read_17194 driver_state_read 3 17194 &iscsit_find_cmd_from_itt_or_dump_17194
116401 +sync_request_17208 sync_request 2 17208 NULL
116402 +dn_recvmsg_17213 dn_recvmsg 4 17213 NULL
116403 +qla24xx_enable_msix_17225 qla24xx_enable_msix 0 17225 NULL
116404 +lprocfs_read_frac_helper_17261 lprocfs_read_frac_helper 0 17261 NULL
116405 +error_error_frame_cts_nul_flid_read_17262 error_error_frame_cts_nul_flid_read 3 17262 NULL
116406 +alloc_ep_17269 alloc_ep 1 17269 NULL
116407 +pg_read_17276 pg_read 3 17276 NULL
116408 +raw_recvmsg_17277 raw_recvmsg 4 17277 NULL
116409 +hmac_sha256_17278 hmac_sha256 2 17278 NULL
116410 +neigh_hash_grow_17283 neigh_hash_grow 2 17283 NULL
116411 +check_board_id_and_rev_17288 check_board_id_and_rev 0 17288 NULL
116412 +minstrel_stats_read_17290 minstrel_stats_read 3 17290 NULL
116413 +ieee80211_if_fmt_dot11MeshForwarding_17301 ieee80211_if_fmt_dot11MeshForwarding 3 17301 NULL
116414 +mb_cache_create_17307 mb_cache_create 2 17307 NULL
116415 +gnttab_map_frames_v2_17314 gnttab_map_frames_v2 2 17314 NULL nohasharray
116416 +regmap_bulk_read_17314 regmap_bulk_read 0 17314 &gnttab_map_frames_v2_17314
116417 +SYSC_pread64_17337 SYSC_pread64 3 17337 NULL
116418 +ieee80211_if_read_dot11MeshHWMPperrMinInterval_17346 ieee80211_if_read_dot11MeshHWMPperrMinInterval 3 17346 NULL
116419 +ath6kl_wmi_send_mgmt_cmd_17347 ath6kl_wmi_send_mgmt_cmd 7 17347 NULL
116420 +uv_setup_irq_17362 uv_setup_irq 0 17362 NULL
116421 +mthca_SW2HW_EQ_17393 mthca_SW2HW_EQ 0 17393 NULL
116422 +snmp6_register_dev_17402 snmp6_register_dev 0 17402 NULL
116423 +mdc_import_seq_write_17409 mdc_import_seq_write 3 17409 NULL
116424 +mlx4_init_hca_17420 mlx4_init_hca 0 17420 NULL
116425 +qla4xxx_request_irqs_17423 qla4xxx_request_irqs 0 17423 NULL
116426 +lpfc_debugfs_dif_err_write_17424 lpfc_debugfs_dif_err_write 3 17424 NULL
116427 +sta_connected_time_read_17435 sta_connected_time_read 3 17435 NULL
116428 +libcfs_ipif_enumerate_17445 libcfs_ipif_enumerate 0 17445 NULL
116429 +xfs_btree_lshift_17448 xfs_btree_lshift 0 17448 NULL
116430 +nla_get_u32_17455 nla_get_u32 0 17455 NULL
116431 +__ref_totlen_17461 __ref_totlen 0 17461 NULL
116432 +probe_kernel_write_17481 probe_kernel_write 3 17481 NULL
116433 +TSS_rawhmac_17486 TSS_rawhmac 3 17486 NULL
116434 +lbs_highrssi_write_17515 lbs_highrssi_write 3 17515 NULL
116435 +ata_bmdma_port_start_17525 ata_bmdma_port_start 0 17525 NULL
116436 +qp_free_res_17541 qp_free_res 5 17541 NULL
116437 +__copy_to_user_17551 __copy_to_user 0-3 17551 NULL
116438 +copy_from_user_17559 copy_from_user 0-3 17559 NULL
116439 +snd_pcm_action_lock_irq_17569 snd_pcm_action_lock_irq 0 17569 NULL
116440 +hash_netport4_expire_17573 hash_netport4_expire 4 17573 NULL
116441 +acpi_ut_create_package_object_17594 acpi_ut_create_package_object 1 17594 NULL
116442 +neigh_hash_alloc_17595 neigh_hash_alloc 1 17595 NULL
116443 +wm8994_gpio_to_irq_17604 wm8994_gpio_to_irq 2 17604 NULL
116444 +osst_execute_17607 osst_execute 7-6 17607 NULL
116445 +ieee80211_if_read_dot11MeshHWMPactivePathToRootTimeout_17618 ieee80211_if_read_dot11MeshHWMPactivePathToRootTimeout 3 17618 NULL
116446 +dma_map_page_17628 dma_map_page 0 17628 NULL
116447 +ocfs2_rotate_subtree_left_17634 ocfs2_rotate_subtree_left 0 17634 NULL
116448 +twl4030_set_gpio_direction_17645 twl4030_set_gpio_direction 1 17645 NULL
116449 +SYSC_migrate_pages_17657 SYSC_migrate_pages 2 17657 NULL
116450 +packet_setsockopt_17662 packet_setsockopt 5 17662 NULL nohasharray
116451 +ubi_io_read_data_17662 ubi_io_read_data 0 17662 &packet_setsockopt_17662
116452 +kernel_write_17665 kernel_write 3 17665 NULL
116453 +t4_query_params_17668 t4_query_params 0 17668 NULL
116454 +pwr_enable_ps_read_17686 pwr_enable_ps_read 3 17686 NULL
116455 +filemap_fdatawait_17688 filemap_fdatawait 0 17688 NULL
116456 +venus_rename_17707 venus_rename 4-5 17707 NULL nohasharray
116457 +__einj_error_trigger_17707 __einj_error_trigger 0 17707 &venus_rename_17707
116458 +exofs_read_lookup_dev_table_17733 exofs_read_lookup_dev_table 3 17733 NULL
116459 +sctpprobe_read_17741 sctpprobe_read 3 17741 NULL
116460 +gpio_request_17750 gpio_request 0 17750 NULL
116461 +ubifs_leb_change_17789 ubifs_leb_change 0 17789 NULL
116462 +shrink_slab_node_17794 shrink_slab_node 3 17794 NULL
116463 +lpuart_copy_rx_to_tty_17801 lpuart_copy_rx_to_tty 3 17801 NULL
116464 +gnet_stats_copy_app_17821 gnet_stats_copy_app 3 17821 NULL
116465 +velocity_init_td_ring_17825 velocity_init_td_ring 0 17825 NULL
116466 +cipso_v4_gentag_rbm_17836 cipso_v4_gentag_rbm 0 17836 NULL
116467 +em28xx_audio_ep_packet_size_17844 em28xx_audio_ep_packet_size 0 17844 NULL
116468 +sysfs_rename_link_ns_17848 sysfs_rename_link_ns 0 17848 NULL
116469 +dm_stats_message_17863 dm_stats_message 5 17863 NULL
116470 +sisusb_send_bulk_msg_17864 sisusb_send_bulk_msg 3 17864 NULL
116471 +alloc_sja1000dev_17868 alloc_sja1000dev 1 17868 NULL
116472 +virtio_cread32_17873 virtio_cread32 0 17873 NULL
116473 +ray_cs_essid_proc_write_17875 ray_cs_essid_proc_write 3 17875 NULL
116474 +orinoco_set_key_17878 orinoco_set_key 5-7 17878 NULL nohasharray
116475 +i40e_align_l2obj_base_17878 i40e_align_l2obj_base 0-1 17878 &orinoco_set_key_17878
116476 +init_per_cpu_17880 init_per_cpu 1 17880 NULL
116477 +ieee80211_if_fmt_dot11MeshMaxPeerLinks_17883 ieee80211_if_fmt_dot11MeshMaxPeerLinks 3 17883 NULL
116478 +ieee80211_if_fmt_dot11MeshHWMPRootMode_17890 ieee80211_if_fmt_dot11MeshHWMPRootMode 3 17890 NULL
116479 +dev_pm_opp_get_opp_count_17911 dev_pm_opp_get_opp_count 0 17911 NULL
116480 +xfs_buf_associate_memory_17915 xfs_buf_associate_memory 3 17915 NULL
116481 +xfs_rtallocate_extent_near_17916 xfs_rtallocate_extent_near 0 17916 NULL
116482 +tipc_port_iovec_rcv_17921 tipc_port_iovec_rcv 3 17921 NULL
116483 +scsi_bufflen_17933 scsi_bufflen 0 17933 NULL
116484 +__mutex_lock_check_stamp_17947 __mutex_lock_check_stamp 0 17947 NULL
116485 +beacon_interval_write_17952 beacon_interval_write 3 17952 NULL
116486 +calc_nr_buckets_17976 calc_nr_buckets 0 17976 NULL
116487 +mtip_hw_init_17980 mtip_hw_init 0 17980 NULL
116488 +ext4_ext_calc_credits_for_single_extent_17983 ext4_ext_calc_credits_for_single_extent 0-2 17983 NULL
116489 +smk_write_cipso_17989 smk_write_cipso 3 17989 NULL
116490 +gnttab_max_grant_frames_17993 gnttab_max_grant_frames 0 17993 NULL
116491 +pvr2_v4l2_read_18006 pvr2_v4l2_read 3 18006 NULL
116492 +cpufreq_add_dev_symlink_18028 cpufreq_add_dev_symlink 0 18028 NULL
116493 +tps65912_i2c_write_18030 tps65912_i2c_write 3 18030 NULL
116494 +o2hb_highest_node_18034 o2hb_highest_node 0 18034 NULL
116495 +__posix_lock_file_18035 __posix_lock_file 0 18035 NULL
116496 +ocfs2_cache_cluster_dealloc_18043 ocfs2_cache_cluster_dealloc 0 18043 NULL
116497 +cryptd_alloc_instance_18048 cryptd_alloc_instance 2-3 18048 NULL
116498 +__btrfs_drop_extents_18049 __btrfs_drop_extents 5 18049 NULL
116499 +ddebug_proc_write_18055 ddebug_proc_write 3 18055 NULL
116500 +lua_sysfs_read_18062 lua_sysfs_read 6 18062 NULL
116501 +fpregs_get_18066 fpregs_get 4 18066 NULL
116502 +kvm_read_guest_page_18074 kvm_read_guest_page 5 18074 NULL
116503 +SYSC_pselect6_18076 SYSC_pselect6 1 18076 NULL
116504 +SYSC_semtimedop_18091 SYSC_semtimedop 3 18091 NULL
116505 +mpi_alloc_18094 mpi_alloc 1 18094 NULL
116506 +hfs_direct_IO_18104 hfs_direct_IO 4 18104 NULL
116507 +dfs_file_read_18116 dfs_file_read 3 18116 NULL
116508 +svc_getnl_18120 svc_getnl 0 18120 NULL
116509 +paging32_gpte_to_gfn_lvl_18131 paging32_gpte_to_gfn_lvl 0-2-1 18131 NULL
116510 +xfs_zero_eof_18134 xfs_zero_eof 0 18134 NULL
116511 +selinux_inode_setsecurity_18148 selinux_inode_setsecurity 4 18148 NULL
116512 +is_idx_node_in_use_18165 is_idx_node_in_use 0 18165 NULL
116513 +pccard_store_cis_18176 pccard_store_cis 6 18176 NULL
116514 +snd_pcm_hw_refine_user_18204 snd_pcm_hw_refine_user 0 18204 NULL
116515 +orinoco_add_extscan_result_18207 orinoco_add_extscan_result 3 18207 NULL
116516 +gsm_control_message_18209 gsm_control_message 4 18209 NULL
116517 +read_rindex_entry_18213 read_rindex_entry 0 18213 NULL
116518 +ocfs2_divide_leaf_refcount_block_18214 ocfs2_divide_leaf_refcount_block 0 18214 NULL
116519 +do_ipv6_setsockopt_18215 do_ipv6_setsockopt 5 18215 NULL
116520 +pcmcia_enable_device_18218 pcmcia_enable_device 0 18218 NULL
116521 +gnttab_alloc_grant_references_18240 gnttab_alloc_grant_references 1 18240 NULL nohasharray
116522 +tsi721_request_msix_18240 tsi721_request_msix 0 18240 &gnttab_alloc_grant_references_18240
116523 +alloc_trace_uprobe_18247 alloc_trace_uprobe 3 18247 NULL
116524 +rfcomm_sock_setsockopt_18254 rfcomm_sock_setsockopt 5 18254 NULL
116525 +qdisc_class_hash_alloc_18262 qdisc_class_hash_alloc 1 18262 NULL
116526 +tg3_bmcr_reset_18271 tg3_bmcr_reset 0 18271 NULL
116527 +gfs2_alloc_sort_buffer_18275 gfs2_alloc_sort_buffer 1 18275 NULL
116528 +alloc_ring_18278 alloc_ring 2-4 18278 NULL
116529 +find_dirty_idx_leb_18280 find_dirty_idx_leb 0 18280 NULL
116530 +bio_phys_segments_18281 bio_phys_segments 0 18281 NULL nohasharray
116531 +nouveau_subdev_create__18281 nouveau_subdev_create_ 7-0 18281 &bio_phys_segments_18281
116532 +lx_init_xilinx_test_18282 lx_init_xilinx_test 0 18282 NULL
116533 +ext4_readpages_18283 ext4_readpages 4 18283 NULL
116534 +mmc_send_bus_test_18285 mmc_send_bus_test 4 18285 NULL
116535 +um_idi_write_18293 um_idi_write 3 18293 NULL
116536 +tg3_request_irq_18303 tg3_request_irq 0 18303 NULL
116537 +nouveau_disp_create__18305 nouveau_disp_create_ 4-7 18305 NULL
116538 +vga_r_18310 vga_r 0 18310 NULL
116539 +class_add_profile_18315 class_add_profile 1-3-5 18315 NULL
116540 +csio_mem_read_18319 csio_mem_read 3 18319 NULL
116541 +alloc_and_copy_string_18321 alloc_and_copy_string 2 18321 NULL
116542 +ecryptfs_send_message_18322 ecryptfs_send_message 2 18322 NULL
116543 +bio_integrity_advance_18324 bio_integrity_advance 2 18324 NULL
116544 +copy_page_to_iter_18345 copy_page_to_iter 3-0 18345 NULL
116545 +lcd_proc_write_18351 lcd_proc_write 3 18351 NULL
116546 +pwr_power_save_off_read_18355 pwr_power_save_off_read 3 18355 NULL
116547 +SyS_process_vm_readv_18366 SyS_process_vm_readv 3-5 18366 NULL
116548 +ep_io_18367 ep_io 0 18367 NULL
116549 +qib_user_sdma_num_pages_18371 qib_user_sdma_num_pages 0 18371 NULL
116550 +sas_register_ports_18375 sas_register_ports 0 18375 NULL
116551 +__ceph_getxattr_18386 __ceph_getxattr 0 18386 NULL nohasharray
116552 +asd_create_dev_attrs_18386 asd_create_dev_attrs 0 18386 &__ceph_getxattr_18386
116553 +ci_role_write_18388 ci_role_write 3 18388 NULL nohasharray
116554 +irq_find_mapping_18388 irq_find_mapping 0-2 18388 &ci_role_write_18388
116555 +sf1_read_18393 sf1_read 0 18393 NULL
116556 +hdlc_empty_fifo_18397 hdlc_empty_fifo 2 18397 NULL
116557 +__video_register_device_18399 __video_register_device 0 18399 NULL
116558 +adis16136_show_serial_18402 adis16136_show_serial 3 18402 NULL
116559 +ixgbe_request_msix_irqs_18403 ixgbe_request_msix_irqs 0 18403 NULL
116560 +pci_save_pcix_state_18410 pci_save_pcix_state 0 18410 NULL
116561 +rtl8169_rx_fill_18416 rtl8169_rx_fill 0 18416 NULL
116562 +memblock_virt_alloc_node_nopanic_18431 memblock_virt_alloc_node_nopanic 1 18431 NULL
116563 +iscsi_create_flashnode_sess_18433 iscsi_create_flashnode_sess 4 18433 NULL
116564 +snd_hda_get_connections_18437 snd_hda_get_connections 0 18437 NULL
116565 +ide_pci_configure_18442 ide_pci_configure 0 18442 NULL
116566 +fuse_perform_write_18457 fuse_perform_write 4 18457 NULL
116567 +regset_tls_set_18459 regset_tls_set 4 18459 NULL
116568 +t3_wait_op_done_18469 t3_wait_op_done 0 18469 NULL
116569 +pci_vpd_lrdt_size_18479 pci_vpd_lrdt_size 0 18479 NULL nohasharray
116570 +mite_bytes_in_transit_18479 mite_bytes_in_transit 0 18479 &pci_vpd_lrdt_size_18479
116571 +udpv6_setsockopt_18487 udpv6_setsockopt 5 18487 NULL
116572 +btrfs_fiemap_18501 btrfs_fiemap 3 18501 NULL
116573 +__copy_user_zeroing_intel_18510 __copy_user_zeroing_intel 0-3 18510 NULL
116574 +__block_write_begin_18511 __block_write_begin 0 18511 NULL
116575 +snd_vx_inb_18514 snd_vx_inb 0 18514 NULL nohasharray
116576 +mlx5_debug_eq_add_18514 mlx5_debug_eq_add 0 18514 &snd_vx_inb_18514
116577 +snd_gus_dram_poke_18525 snd_gus_dram_poke 4 18525 NULL
116578 +nouveau_fifo_channel_create__18530 nouveau_fifo_channel_create_ 9 18530 NULL
116579 +tipc_send2port_18531 tipc_send2port 4 18531 NULL
116580 +t3_sge_init_flcntxt_18535 t3_sge_init_flcntxt 0 18535 NULL
116581 +seq_copy_in_user_18543 seq_copy_in_user 3 18543 NULL
116582 +sas_change_queue_depth_18555 sas_change_queue_depth 2 18555 NULL
116583 +smk_write_rules_list_18565 smk_write_rules_list 3 18565 NULL
116584 +asd_init_chip_18572 asd_init_chip 0 18572 NULL
116585 +debug_output_18575 debug_output 3 18575 NULL
116586 +xfs_btree_read_bufl_18597 xfs_btree_read_bufl 0 18597 NULL
116587 +filemap_fdatawait_range_18600 filemap_fdatawait_range 0 18600 NULL nohasharray
116588 +slabinfo_write_18600 slabinfo_write 3 18600 &filemap_fdatawait_range_18600
116589 +iowarrior_write_18604 iowarrior_write 3 18604 NULL
116590 +from_buffer_18625 from_buffer 3 18625 NULL
116591 +vnic_dev_cmd_18640 vnic_dev_cmd 0 18640 NULL
116592 +__dev_set_mtu_18647 __dev_set_mtu 0 18647 NULL
116593 +gpiod_request_18656 gpiod_request 0 18656 NULL
116594 +snd_pcm_oss_write3_18657 snd_pcm_oss_write3 0-3 18657 NULL
116595 +ieee80211_if_fmt_rssi_threshold_18664 ieee80211_if_fmt_rssi_threshold 3 18664 NULL
116596 +unmap_page_18665 unmap_page 2-3 18665 NULL
116597 +xfs_iext_insert_18667 xfs_iext_insert 3 18667 NULL
116598 +fnic_stats_debugfs_read_18688 fnic_stats_debugfs_read 3 18688 NULL
116599 +echo_client_prep_commit_18693 echo_client_prep_commit 8 18693 NULL
116600 +lbs_set_snmp_mib_18694 lbs_set_snmp_mib 0 18694 NULL
116601 +iwl_dbgfs_rx_handlers_read_18708 iwl_dbgfs_rx_handlers_read 3 18708 NULL
116602 +ceph_alloc_page_vector_18710 ceph_alloc_page_vector 1 18710 NULL
116603 +spu_read_u16_18713 spu_read_u16 0 18713 NULL
116604 +blk_rq_bytes_18715 blk_rq_bytes 0 18715 NULL
116605 +nfs4_init_callback_netid_18717 nfs4_init_callback_netid 3 18717 NULL
116606 +byt_gpio_to_irq_18721 byt_gpio_to_irq 2 18721 NULL
116607 +snd_als4k_gcr_read_addr_18741 snd_als4k_gcr_read_addr 0 18741 NULL
116608 +o2hb_debug_create_18744 o2hb_debug_create 4 18744 NULL
116609 +__erst_read_to_erange_from_nvram_18748 __erst_read_to_erange_from_nvram 0 18748 NULL
116610 +wep_packets_read_18751 wep_packets_read 3 18751 NULL
116611 +carm_init_wait_18763 carm_init_wait 0 18763 NULL
116612 +read_file_dump_nfcal_18766 read_file_dump_nfcal 3 18766 NULL
116613 +SyS_lsetxattr_18776 SyS_lsetxattr 4 18776 NULL
116614 +alloc_fcdev_18780 alloc_fcdev 1 18780 NULL
116615 +prealloc_18800 prealloc 0 18800 NULL
116616 +dm_stats_print_18815 dm_stats_print 7 18815 NULL
116617 +sys_modify_ldt_18824 sys_modify_ldt 3 18824 NULL
116618 +hid_connect_18828 hid_connect 0 18828 NULL
116619 +mtf_test_write_18844 mtf_test_write 3 18844 NULL
116620 +t3_sge_write_context_18852 t3_sge_write_context 0 18852 NULL
116621 +sctp_setsockopt_events_18862 sctp_setsockopt_events 3 18862 NULL
116622 +ieee80211_if_read_element_ttl_18869 ieee80211_if_read_element_ttl 3 18869 NULL
116623 +xlog_find_verify_log_record_18870 xlog_find_verify_log_record 2 18870 NULL
116624 +ceph_setxattr_18913 ceph_setxattr 4 18913 NULL
116625 +dma_set_mask_and_coherent_18926 dma_set_mask_and_coherent 0 18926 NULL
116626 +ieee80211_rx_mgmt_disassoc_18927 ieee80211_rx_mgmt_disassoc 3 18927 NULL
116627 +snapshot_write_next_18937 snapshot_write_next 0 18937 NULL
116628 +ida_get_new_18948 ida_get_new 0 18948 NULL
116629 +clean_journal_18955 clean_journal 0 18955 NULL
116630 +__nla_reserve_18974 __nla_reserve 3 18974 NULL
116631 +lx_init_ethersound_config_18976 lx_init_ethersound_config 0 18976 NULL
116632 +__blockdev_direct_IO_18977 __blockdev_direct_IO 0-6 18977 NULL
116633 +find_dirtiest_idx_leb_19001 find_dirtiest_idx_leb 0 19001 NULL
116634 +layout_in_gaps_19006 layout_in_gaps 2 19006 NULL
116635 +huge_page_size_19008 huge_page_size 0 19008 NULL
116636 +peak_pciec_write_pca9553_19010 peak_pciec_write_pca9553 0 19010 NULL
116637 +hash_netport6_expire_19013 hash_netport6_expire 4 19013 NULL
116638 +sysfs_create_dir_ns_19033 sysfs_create_dir_ns 0 19033 NULL
116639 +ocfs2_steal_resource_19036 ocfs2_steal_resource 0 19036 NULL nohasharray
116640 +peak_pciec_init_leds_19036 peak_pciec_init_leds 0 19036 &ocfs2_steal_resource_19036
116641 +revalidate_19043 revalidate 2 19043 NULL
116642 +afs_vnode_store_data_19048 afs_vnode_store_data 2-3-4-5 19048 NULL
116643 +osc_pinger_recov_seq_write_19056 osc_pinger_recov_seq_write 3 19056 NULL nohasharray
116644 +do_vm86_irq_handling_19056 do_vm86_irq_handling 2 19056 &osc_pinger_recov_seq_write_19056
116645 +get_log_header_19063 get_log_header 0 19063 NULL
116646 +create_gpadl_header_19064 create_gpadl_header 2-0 19064 NULL
116647 +ceph_create_snap_context_19082 ceph_create_snap_context 1 19082 NULL
116648 +dwc2_core_reset_19099 dwc2_core_reset 0 19099 NULL
116649 +sta_last_seq_ctrl_read_19106 sta_last_seq_ctrl_read 3 19106 NULL
116650 +cifs_readv_from_socket_19109 cifs_readv_from_socket 3 19109 NULL
116651 +pci_enable_pcie_error_reporting_19111 pci_enable_pcie_error_reporting 0 19111 NULL
116652 +cb710_register_slot_19121 cb710_register_slot 0 19121 NULL
116653 +skb_gro_offset_19123 skb_gro_offset 0 19123 NULL
116654 +snd_als4k_iobase_readl_19136 snd_als4k_iobase_readl 0 19136 NULL
116655 +tg3_phy_reset_chanpat_19137 tg3_phy_reset_chanpat 0 19137 NULL
116656 +alloc_irdadev_19140 alloc_irdadev 1 19140 NULL
116657 +spu_read_u32_19158 spu_read_u32 0 19158 NULL
116658 +sleep_auth_read_19159 sleep_auth_read 3 19159 NULL
116659 +smk_write_access2_19170 smk_write_access2 3 19170 NULL
116660 +iwl_dbgfs_reply_tx_error_read_19205 iwl_dbgfs_reply_tx_error_read 3 19205 NULL
116661 +__copy_to_user_inatomic_19214 __copy_to_user_inatomic 0-3 19214 NULL
116662 +dev_counters_read_19216 dev_counters_read 3 19216 NULL
116663 +wbcir_tx_19219 wbcir_tx 3 19219 NULL
116664 +snd_mask_max_19224 snd_mask_max 0 19224 NULL
116665 +snd_pcm_capture_rewind_19229 snd_pcm_capture_rewind 0-2 19229 NULL
116666 +vnic_dev_cmd_proxy_19232 vnic_dev_cmd_proxy 0 19232 NULL
116667 +bio_alloc_mddev_19238 bio_alloc_mddev 2 19238 NULL nohasharray
116668 +ata_pci_sff_activate_host_19238 ata_pci_sff_activate_host 0 19238 &bio_alloc_mddev_19238
116669 +ucma_query_19260 ucma_query 4 19260 NULL
116670 +il_dbgfs_rxon_filter_flags_read_19281 il_dbgfs_rxon_filter_flags_read 3 19281 NULL
116671 +batadv_tt_save_orig_buffer_19288 batadv_tt_save_orig_buffer 4 19288 NULL nohasharray
116672 +cfg80211_rx_unprot_mlme_mgmt_19288 cfg80211_rx_unprot_mlme_mgmt 3 19288 &batadv_tt_save_orig_buffer_19288
116673 +qc_capture_19298 qc_capture 3 19298 NULL
116674 +ocfs2_prepare_inode_for_refcount_19303 ocfs2_prepare_inode_for_refcount 3-4 19303 NULL
116675 +event_tx_stuck_read_19305 event_tx_stuck_read 3 19305 NULL
116676 +ntb_create_callbacks_19310 ntb_create_callbacks 0 19310 NULL
116677 +debug_read_19322 debug_read 3 19322 NULL
116678 +SYSC_sendfile64_19327 SYSC_sendfile64 4 19327 NULL
116679 +lbs_host_sleep_write_19332 lbs_host_sleep_write 3 19332 NULL nohasharray
116680 +cfg80211_inform_bss_19332 cfg80211_inform_bss 8 19332 &lbs_host_sleep_write_19332
116681 +closure_sub_19359 closure_sub 2 19359 NULL
116682 +firmware_data_write_19360 firmware_data_write 6-5 19360 NULL
116683 +read_zero_19366 read_zero 3 19366 NULL
116684 +of_spi_register_master_19374 of_spi_register_master 0 19374 NULL
116685 +interpret_user_input_19393 interpret_user_input 2 19393 NULL
116686 +sync_fill_pt_info_19397 sync_fill_pt_info 0 19397 NULL
116687 +pep_recvmsg_19402 pep_recvmsg 4 19402 NULL
116688 +hid_hw_raw_request_19408 hid_hw_raw_request 0 19408 NULL
116689 +dvbdmx_write_19423 dvbdmx_write 3 19423 NULL
116690 +__phys_addr_19434 __phys_addr 0 19434 NULL
116691 +SyS_sched_getaffinity_19444 SyS_sched_getaffinity 2 19444 NULL
116692 +xfrm_alg_auth_len_19454 xfrm_alg_auth_len 0 19454 NULL
116693 +gnet_stats_copy_19458 gnet_stats_copy 4 19458 NULL
116694 +gp2ap020a00f_get_thresh_reg_19468 gp2ap020a00f_get_thresh_reg 0 19468 NULL
116695 +sky2_read16_19475 sky2_read16 0 19475 NULL
116696 +lanai_pci_start_19481 lanai_pci_start 0 19481 NULL
116697 +__read_status_pciv2_19492 __read_status_pciv2 0 19492 NULL
116698 +kstrtoll_from_user_19500 kstrtoll_from_user 2 19500 NULL
116699 +vfio_vc_cap_len_19507 vfio_vc_cap_len 0 19507 NULL
116700 +ext4_add_new_descs_19509 ext4_add_new_descs 3 19509 NULL
116701 +batadv_tvlv_container_register_19520 batadv_tvlv_container_register 5 19520 NULL
116702 +apei_exec_pre_map_gars_19529 apei_exec_pre_map_gars 0 19529 NULL nohasharray
116703 +cfc_write_array_to_buffer_19529 cfc_write_array_to_buffer 3 19529 &apei_exec_pre_map_gars_19529
116704 +nfc_llcp_build_tlv_19536 nfc_llcp_build_tlv 3 19536 NULL
116705 +howmany_64_19548 howmany_64 2 19548 NULL
116706 +gfn_to_index_19558 gfn_to_index 0-1-3-2 19558 NULL
116707 +kernel_read_19559 kernel_read 0-4 19559 NULL
116708 +ocfs2_control_message_19564 ocfs2_control_message 3 19564 NULL
116709 +nfsd_read_19568 nfsd_read 5 19568 NULL
116710 +ieee80211_key_alloc_19575 ieee80211_key_alloc 3 19575 NULL
116711 +mnt_want_write_file_19579 mnt_want_write_file 0 19579 NULL
116712 +bm_status_read_19583 bm_status_read 3 19583 NULL
116713 +load_xattr_datum_19594 load_xattr_datum 0 19594 NULL
116714 +fallocate_chunk_19610 fallocate_chunk 0 19610 NULL
116715 +__mei_cl_recv_19636 __mei_cl_recv 3 19636 NULL
116716 +__zs_cpu_up_19647 __zs_cpu_up 0 19647 NULL
116717 +ipw_setup_deferred_work_19657 ipw_setup_deferred_work 0 19657 NULL
116718 +LoadBitmap_19658 LoadBitmap 2 19658 NULL
116719 +memblock_virt_alloc_low_nopanic_19714 memblock_virt_alloc_low_nopanic 1 19714 NULL
116720 +ocfs2_control_get_this_node_19721 ocfs2_control_get_this_node 0 19721 NULL
116721 +read_reg_19723 read_reg 0 19723 NULL
116722 +wm8350_block_write_19727 wm8350_block_write 2-3 19727 NULL
116723 +v4l2_device_register_19731 v4l2_device_register 0 19731 NULL
116724 +memcpy_toiovecend_19736 memcpy_toiovecend 3-4 19736 NULL
116725 +ata_pci_bmdma_init_one_19738 ata_pci_bmdma_init_one 0 19738 NULL
116726 +pci_read_vpd_19741 pci_read_vpd 0 19741 NULL
116727 +snd_es1968_get_dma_ptr_19747 snd_es1968_get_dma_ptr 0 19747 NULL
116728 +p9_client_read_19750 p9_client_read 5-0 19750 NULL
116729 +pnpbios_proc_write_19758 pnpbios_proc_write 3 19758 NULL
116730 +ocfs2_readpages_19759 ocfs2_readpages 4 19759 NULL
116731 +jffs2_acl_from_medium_19762 jffs2_acl_from_medium 2 19762 NULL
116732 +readhscx_19769 readhscx 0 19769 NULL
116733 +ocfs2_read_group_descriptor_19771 ocfs2_read_group_descriptor 0 19771 NULL
116734 +mxt_fw_write_19776 mxt_fw_write 3 19776 NULL
116735 +memory_isolate_notify_19808 memory_isolate_notify 0 19808 NULL
116736 +irda_setsockopt_19824 irda_setsockopt 5 19824 NULL
116737 +xfs_bmap_add_extent_hole_real_19828 xfs_bmap_add_extent_hole_real 0 19828 NULL
116738 +vfs_getxattr_19832 vfs_getxattr 0 19832 NULL
116739 +_regulator_disable_19841 _regulator_disable 0 19841 NULL
116740 +crypt_alloc_buffer_19846 crypt_alloc_buffer 2 19846 NULL
116741 +cfg80211_mlme_register_mgmt_19852 cfg80211_mlme_register_mgmt 5 19852 NULL
116742 +__nla_put_19857 __nla_put 3 19857 NULL
116743 +mrp_request_join_19882 mrp_request_join 4 19882 NULL
116744 +aes_decrypt_interrupt_read_19910 aes_decrypt_interrupt_read 3 19910 NULL
116745 +__ath_regd_init_19913 __ath_regd_init 0 19913 NULL
116746 +ps_upsd_max_apturn_read_19918 ps_upsd_max_apturn_read 3 19918 NULL
116747 +mangle_name_19923 mangle_name 0 19923 NULL
116748 +cgroup_task_count_19930 cgroup_task_count 0 19930 NULL
116749 +guest_read_tsc_19931 guest_read_tsc 0 19931 NULL
116750 +iwl_dbgfs_rx_queue_read_19943 iwl_dbgfs_rx_queue_read 3 19943 NULL
116751 +cfg80211_rx_assoc_resp_19944 cfg80211_rx_assoc_resp 4 19944 NULL
116752 +ll_xattr_cache_list_19954 ll_xattr_cache_list 0 19954 NULL
116753 +register_cpu_notifier_19969 register_cpu_notifier 0 19969 NULL
116754 +get_jack_mode_name_19976 get_jack_mode_name 4 19976 NULL
116755 +attach_hdlc_protocol_19986 attach_hdlc_protocol 3 19986 NULL
116756 +rtw_set_wps_probe_resp_19989 rtw_set_wps_probe_resp 3 19989 NULL nohasharray
116757 +i40e_reserve_msix_vectors_19989 i40e_reserve_msix_vectors 2 19989 &rtw_set_wps_probe_resp_19989
116758 +ib_register_device_19990 ib_register_device 0 19990 NULL
116759 +diva_um_idi_read_20003 diva_um_idi_read 0 20003 NULL
116760 +lov_stripe_md_size_20009 lov_stripe_md_size 0-1 20009 NULL nohasharray
116761 +event_trigger_write_20009 event_trigger_write 3 20009 &lov_stripe_md_size_20009
116762 +tree_mod_log_eb_move_20011 tree_mod_log_eb_move 5 20011 NULL nohasharray
116763 +if_spi_prog_helper_firmware_20011 if_spi_prog_helper_firmware 0 20011 &tree_mod_log_eb_move_20011
116764 +SYSC_fgetxattr_20027 SYSC_fgetxattr 4 20027 NULL
116765 +split_scan_timeout_read_20029 split_scan_timeout_read 3 20029 NULL
116766 +mwl8k_init_txqs_20042 mwl8k_init_txqs 0 20042 NULL
116767 +iwl_mvm_power_mac_dbgfs_read_20067 iwl_mvm_power_mac_dbgfs_read 4-0 20067 NULL
116768 +target_message_20072 target_message 2 20072 NULL
116769 +rawv6_sendmsg_20080 rawv6_sendmsg 4 20080 NULL
116770 +fuse_conn_limit_read_20084 fuse_conn_limit_read 3 20084 NULL
116771 +aat2870_reg_write_file_20086 aat2870_reg_write_file 3 20086 NULL
116772 +team_options_register_20091 team_options_register 3 20091 NULL
116773 +qla2x00_adjust_sdev_qdepth_up_20097 qla2x00_adjust_sdev_qdepth_up 2 20097 NULL
116774 +xfs_qm_dqget_20103 xfs_qm_dqget 0 20103 NULL
116775 +root_nfs_copy_20111 root_nfs_copy 3 20111 NULL
116776 +hptiop_adjust_disk_queue_depth_20122 hptiop_adjust_disk_queue_depth 2 20122 NULL
116777 +self_check_vid_hdr_20131 self_check_vid_hdr 0 20131 NULL
116778 +tomoyo_commit_ok_20167 tomoyo_commit_ok 2 20167 NULL
116779 +p54p_upload_firmware_20168 p54p_upload_firmware 0 20168 NULL
116780 +read_flush_pipefs_20171 read_flush_pipefs 3 20171 NULL
116781 +wep_addr_key_count_read_20174 wep_addr_key_count_read 3 20174 NULL
116782 +crystalhd_map_dio_20181 crystalhd_map_dio 3 20181 NULL
116783 +__radix_tree_create_20221 __radix_tree_create 0 20221 NULL
116784 +pvr2_ctrl_value_to_sym_20229 pvr2_ctrl_value_to_sym 5 20229 NULL
116785 +rose_sendmsg_20249 rose_sendmsg 4 20249 NULL
116786 +tm6000_i2c_send_regs_20250 tm6000_i2c_send_regs 5 20250 NULL
116787 +ssd1307fb_write_array_20258 ssd1307fb_write_array 3 20258 NULL
116788 +notifier_from_errno_20267 notifier_from_errno 0-1 20267 NULL
116789 +btrfs_header_nritems_20296 btrfs_header_nritems 0 20296 NULL
116790 +r10_sync_page_io_20307 r10_sync_page_io 3 20307 NULL
116791 +dm_get_reserved_bio_based_ios_20315 dm_get_reserved_bio_based_ios 0 20315 NULL
116792 +tx_tx_burst_programmed_read_20320 tx_tx_burst_programmed_read 3 20320 NULL nohasharray
116793 +register_blkdev_20320 register_blkdev 0 20320 &tx_tx_burst_programmed_read_20320
116794 +vx_send_msg_nolock_20322 vx_send_msg_nolock 0 20322 NULL
116795 +snd_cs4281_BA1_read_20323 snd_cs4281_BA1_read 5 20323 NULL
116796 +lbs_set_mac_control_sync_20333 lbs_set_mac_control_sync 0 20333 NULL
116797 +rsxx_dma_setup_20335 rsxx_dma_setup 0 20335 NULL
116798 +ocfs2_et_insert_check_20341 ocfs2_et_insert_check 0 20341 NULL
116799 +gfs2_glock_nq_m_20347 gfs2_glock_nq_m 1-0 20347 NULL
116800 +t3_seeprom_read_20349 t3_seeprom_read 0 20349 NULL
116801 +handle_arr_calc_size_20355 handle_arr_calc_size 0-1 20355 NULL
116802 +fw_load_from_user_helper_20360 fw_load_from_user_helper 0 20360 NULL
116803 +snd_pcm_stop_20376 snd_pcm_stop 0 20376 NULL
116804 +smk_set_cipso_20379 smk_set_cipso 3 20379 NULL
116805 +snd_nm256_readl_20394 snd_nm256_readl 0 20394 NULL
116806 +__kfifo_from_user_20399 __kfifo_from_user 3 20399 NULL nohasharray
116807 +SyS_get_mempolicy_20399 SyS_get_mempolicy 3 20399 &__kfifo_from_user_20399
116808 +ath9k_init_softc_20438 ath9k_init_softc 0 20438 NULL
116809 +compat_ipv6_setsockopt_20468 compat_ipv6_setsockopt 5 20468 NULL
116810 +read_buf_20469 read_buf 2 20469 NULL
116811 +bio_trim_20472 bio_trim 2 20472 NULL
116812 +btrfs_get_32_20476 btrfs_get_32 0 20476 NULL
116813 +pccard_loop_tuple_20513 pccard_loop_tuple 0 20513 NULL
116814 +thermal_throttle_add_dev_20516 thermal_throttle_add_dev 0 20516 NULL
116815 +xfs_iext_realloc_direct_20521 xfs_iext_realloc_direct 2 20521 NULL
116816 +drbd_bm_resize_20522 drbd_bm_resize 2 20522 NULL
116817 +amd_create_gatt_pages_20537 amd_create_gatt_pages 1 20537 NULL
116818 +scsi_report_opcode_20551 scsi_report_opcode 3 20551 NULL
116819 +venus_create_20555 venus_create 4 20555 NULL
116820 +btrfs_super_log_root_20565 btrfs_super_log_root 0 20565 NULL
116821 +crypto_ahash_reqsize_20569 crypto_ahash_reqsize 0 20569 NULL
116822 +xfs_bmap_isaeof_20570 xfs_bmap_isaeof 0 20570 NULL
116823 +ocfs2_cluster_lock_20588 ocfs2_cluster_lock 0 20588 NULL
116824 +kvm_test_age_hva_20593 kvm_test_age_hva 2 20593 NULL
116825 +set_secure_conn_20596 set_secure_conn 4 20596 NULL
116826 +sync_timeline_create_20601 sync_timeline_create 2 20601 NULL
116827 +lirc_write_20604 lirc_write 3 20604 NULL
116828 +qib_qsfp_write_20614 qib_qsfp_write 0-2-4 20614 NULL
116829 +snd_pcm_oss_prepare_20641 snd_pcm_oss_prepare 0 20641 NULL
116830 +get_extent_skip_holes_20642 get_extent_skip_holes 2 20642 NULL
116831 +kfifo_copy_to_user_20646 kfifo_copy_to_user 4-3 20646 NULL
116832 +ath9k_init_btcoex_20647 ath9k_init_btcoex 0 20647 NULL
116833 +cpulist_scnprintf_20648 cpulist_scnprintf 2-0 20648 NULL
116834 +oz_add_farewell_20652 oz_add_farewell 5 20652 NULL
116835 +oz_cdev_read_20659 oz_cdev_read 3 20659 NULL
116836 +snd_hdsp_playback_copy_20676 snd_hdsp_playback_copy 5 20676 NULL nohasharray
116837 +btrfs_qgroup_reserve_20676 btrfs_qgroup_reserve 0 20676 &snd_hdsp_playback_copy_20676
116838 +dvb_dmxdev_buffer_read_20682 dvb_dmxdev_buffer_read 0-4 20682 NULL
116839 +cpumask_size_20683 cpumask_size 0 20683 NULL
116840 +btrfs_node_blockptr_20685 btrfs_node_blockptr 0 20685 NULL
116841 +read_file_tgt_int_stats_20697 read_file_tgt_int_stats 3 20697 NULL
116842 +__maestro_read_20700 __maestro_read 0 20700 NULL
116843 +cipso_v4_gentag_rng_20703 cipso_v4_gentag_rng 0 20703 NULL
116844 +_snd_pcm_new_20708 _snd_pcm_new 0 20708 NULL
116845 +pcpu_page_first_chunk_20712 pcpu_page_first_chunk 1 20712 NULL
116846 +ocfs2_read_xattr_bucket_20722 ocfs2_read_xattr_bucket 0 20722 NULL
116847 +security_context_to_sid_force_20724 security_context_to_sid_force 2 20724 NULL
116848 +fb_prepare_logo_20743 fb_prepare_logo 0 20743 NULL
116849 +mlx4_cmd_use_events_20750 mlx4_cmd_use_events 0 20750 NULL
116850 +vol_cdev_direct_write_20751 vol_cdev_direct_write 3 20751 NULL
116851 +ocfs2_align_bytes_to_clusters_20754 ocfs2_align_bytes_to_clusters 2 20754 NULL
116852 +enic_set_niccfg_20757 enic_set_niccfg 0 20757 NULL
116853 +brcmf_p2p_escan_20763 brcmf_p2p_escan 2 20763 NULL nohasharray
116854 +mnt_clone_write_20763 mnt_clone_write 0 20763 &brcmf_p2p_escan_20763
116855 +ubi_io_read_20767 ubi_io_read 0 20767 NULL
116856 +fb_alloc_cmap_gfp_20792 fb_alloc_cmap_gfp 2 20792 NULL
116857 +iommu_range_alloc_20794 iommu_range_alloc 3 20794 NULL
116858 +iwl_dbgfs_rxon_flags_read_20795 iwl_dbgfs_rxon_flags_read 3 20795 NULL
116859 +lowpan_write_20800 lowpan_write 3 20800 NULL
116860 +sysfs_add_file_to_group_20814 sysfs_add_file_to_group 0 20814 NULL
116861 +strndup_user_20819 strndup_user 2 20819 NULL nohasharray
116862 +do_glock_20819 do_glock 0 20819 &strndup_user_20819
116863 +cp_alloc_rings_20823 cp_alloc_rings 0 20823 NULL
116864 +tipc_msg_build_20825 tipc_msg_build 3 20825 NULL
116865 +wl1271_format_buffer_20834 wl1271_format_buffer 2 20834 NULL
116866 +uvc_alloc_entity_20836 uvc_alloc_entity 3-4 20836 NULL
116867 +p9_tag_alloc_20845 p9_tag_alloc 3 20845 NULL
116868 +nvme_trans_supported_vpd_pages_20847 nvme_trans_supported_vpd_pages 4 20847 NULL
116869 +get_name_20855 get_name 4 20855 NULL
116870 +iwl_dbgfs_pm_params_read_20866 iwl_dbgfs_pm_params_read 3 20866 NULL
116871 +snd_pcm_capture_avail_20867 snd_pcm_capture_avail 0 20867 NULL
116872 +srq_free_res_20868 srq_free_res 5 20868 NULL
116873 +cfs_cpt_table_create_20884 cfs_cpt_table_create 1 20884 NULL
116874 +rb_simple_write_20890 rb_simple_write 3 20890 NULL nohasharray
116875 +asd_alloc_edbs_20890 asd_alloc_edbs 0 20890 &rb_simple_write_20890
116876 +sisusb_send_packet_20891 sisusb_send_packet 2 20891 NULL
116877 +key_icverrors_read_20895 key_icverrors_read 3 20895 NULL
116878 +vfio_msi_enable_20906 vfio_msi_enable 2 20906 NULL
116879 +lbs_rdbbp_write_20918 lbs_rdbbp_write 3 20918 NULL
116880 +htable_bits_20933 htable_bits 0 20933 NULL
116881 +sh_eth_phy_start_20943 sh_eth_phy_start 0 20943 NULL
116882 +altera_set_ir_post_20948 altera_set_ir_post 2 20948 NULL
116883 +rx_rx_phy_hdr_read_20950 rx_rx_phy_hdr_read 3 20950 NULL
116884 +rsxx_cram_read_20957 rsxx_cram_read 3 20957 NULL
116885 +nfs_map_name_to_uid_20962 nfs_map_name_to_uid 3 20962 NULL
116886 +snd_rme9652_playback_copy_20970 snd_rme9652_playback_copy 5 20970 NULL
116887 +alg_setsockopt_20985 alg_setsockopt 5 20985 NULL
116888 +bcm2048_set_rds_wline_20993 bcm2048_set_rds_wline 0 20993 NULL
116889 +qib_verbs_send_20999 qib_verbs_send 5-3 20999 NULL
116890 +btrfs_dirty_pages_21019 btrfs_dirty_pages 0 21019 NULL
116891 +btrfs_inode_ref_name_len_21024 btrfs_inode_ref_name_len 0 21024 NULL
116892 +xfs_btree_new_root_21028 xfs_btree_new_root 0 21028 NULL
116893 +rx_defrag_tkip_called_read_21031 rx_defrag_tkip_called_read 3 21031 NULL nohasharray
116894 +snd_pcm_lib_preallocate_pages_21031 snd_pcm_lib_preallocate_pages 0 21031 &rx_defrag_tkip_called_read_21031
116895 +srp_change_queue_depth_21038 srp_change_queue_depth 2 21038 NULL
116896 +fsl_edma_prep_dma_cyclic_21042 fsl_edma_prep_dma_cyclic 4-3 21042 NULL
116897 +lbs_threshold_read_21046 lbs_threshold_read 5 21046 NULL
116898 +reiserfs_direct_IO_21051 reiserfs_direct_IO 4 21051 NULL
116899 +proc_fault_inject_write_21058 proc_fault_inject_write 3 21058 NULL
116900 +qdisc_get_default_21072 qdisc_get_default 2 21072 NULL
116901 +event_calibration_read_21083 event_calibration_read 3 21083 NULL
116902 +ath5k_eeprom_read_modes_21088 ath5k_eeprom_read_modes 0 21088 NULL
116903 +bl_add_page_to_bio_21094 bl_add_page_to_bio 2 21094 NULL nohasharray
116904 +multipath_status_21094 multipath_status 5 21094 &bl_add_page_to_bio_21094 nohasharray
116905 +mthca_MAP_ICM_page_21094 mthca_MAP_ICM_page 0 21094 &multipath_status_21094
116906 +rate_control_pid_events_read_21099 rate_control_pid_events_read 3 21099 NULL
116907 +ath6kl_send_go_probe_resp_21113 ath6kl_send_go_probe_resp 3 21113 NULL
116908 +_efx_mcdi_rpc_async_21119 _efx_mcdi_rpc_async 4-5 21119 NULL
116909 +i2400m_rx_trace_21127 i2400m_rx_trace 3 21127 NULL
116910 +mei_dbgfs_read_active_21172 mei_dbgfs_read_active 3 21172 NULL
116911 +c2_rnic_open_21178 c2_rnic_open 0 21178 NULL
116912 +cx18_v4l2_read_21196 cx18_v4l2_read 3 21196 NULL
116913 +__generic_file_aio_write_21201 __generic_file_aio_write 0 21201 NULL
116914 +ipc_rcu_alloc_21208 ipc_rcu_alloc 1 21208 NULL
116915 +scsi_execute_req_flags_21215 scsi_execute_req_flags 5 21215 NULL
116916 +t4_wr_mbox_meat_21225 t4_wr_mbox_meat 0 21225 NULL
116917 +get_numpages_21227 get_numpages 0-2-1 21227 NULL
116918 +input_ff_create_21240 input_ff_create 2 21240 NULL
116919 +cfg80211_notify_new_peer_candidate_21242 cfg80211_notify_new_peer_candidate 4 21242 NULL
116920 +fru_length_21257 fru_length 0 21257 NULL
116921 +rtw_set_wps_beacon_21262 rtw_set_wps_beacon 3 21262 NULL
116922 +ocfs2_blocks_for_bytes_21268 ocfs2_blocks_for_bytes 0-2 21268 NULL
116923 +xfs_alloc_ag_vextent_size_21276 xfs_alloc_ag_vextent_size 0 21276 NULL
116924 +t4vf_wr_mbox_core_21291 t4vf_wr_mbox_core 0 21291 NULL
116925 +drm_universal_plane_init_21296 drm_universal_plane_init 6 21296 NULL
116926 +net_rx_queue_update_kobjects_21298 net_rx_queue_update_kobjects 0 21298 NULL
116927 +remove_qp_ok_21302 remove_qp_ok 0 21302 NULL
116928 +do_msg_fill_21307 do_msg_fill 3 21307 NULL
116929 +add_res_range_21310 add_res_range 4-0 21310 NULL
116930 +get_zeroed_page_21322 get_zeroed_page 0 21322 NULL
116931 +ftrace_profile_read_21327 ftrace_profile_read 3 21327 NULL
116932 +read_file_bool_bmps_21344 read_file_bool_bmps 3 21344 NULL
116933 +gfs2_ea_get_copy_21353 gfs2_ea_get_copy 0 21353 NULL
116934 +alloc_orinocodev_21371 alloc_orinocodev 1 21371 NULL
116935 +SYSC_rt_sigpending_21379 SYSC_rt_sigpending 2 21379 NULL
116936 +video_ioctl2_21380 video_ioctl2 2 21380 NULL
116937 +insert_ptr_21386 insert_ptr 6 21386 NULL
116938 +diva_get_driver_dbg_mask_21399 diva_get_driver_dbg_mask 0 21399 NULL
116939 +__clone_and_map_simple_bio_21404 __clone_and_map_simple_bio 4 21404 NULL
116940 +snd_m3_inw_21406 snd_m3_inw 0 21406 NULL
116941 +mlx4_init_slave_21414 mlx4_init_slave 0 21414 NULL
116942 +usnic_ib_dump_vf_hdr_21423 usnic_ib_dump_vf_hdr 3 21423 NULL
116943 +snapshot_read_next_21426 snapshot_read_next 0 21426 NULL
116944 +tcp_bound_to_half_wnd_21429 tcp_bound_to_half_wnd 0-2 21429 NULL
116945 +tracing_saved_cmdlines_read_21434 tracing_saved_cmdlines_read 3 21434 NULL
116946 +aggr_size_tx_agg_vs_rate_read_21438 aggr_size_tx_agg_vs_rate_read 3 21438 NULL
116947 +__ertm_hdr_size_21450 __ertm_hdr_size 0 21450 NULL
116948 +ReadISAR_21453 ReadISAR 0 21453 NULL
116949 +mei_nfc_send_21477 mei_nfc_send 3 21477 NULL nohasharray
116950 +regcache_write_21477 regcache_write 0 21477 &mei_nfc_send_21477
116951 +read_file_xmit_21487 read_file_xmit 3 21487 NULL
116952 +mmc_alloc_sg_21504 mmc_alloc_sg 1 21504 NULL
116953 +btrfs_file_aio_write_21520 btrfs_file_aio_write 4 21520 NULL
116954 +il_dbgfs_stations_read_21532 il_dbgfs_stations_read 3 21532 NULL
116955 +cipso_v4_map_cat_enum_hton_21540 cipso_v4_map_cat_enum_hton 0 21540 NULL
116956 +ath10k_push_board_ext_data_21547 ath10k_push_board_ext_data 0 21547 NULL
116957 +rxrpc_send_data_21553 rxrpc_send_data 5 21553 NULL
116958 +rx_rx_beacon_early_term_read_21559 rx_rx_beacon_early_term_read 3 21559 NULL
116959 +xfs_buf_read_uncached_21585 xfs_buf_read_uncached 3 21585 NULL
116960 +snd_es18xx_mixer_read_21586 snd_es18xx_mixer_read 0 21586 NULL
116961 +ocfs2_acl_from_xattr_21604 ocfs2_acl_from_xattr 2 21604 NULL
116962 +filemap_get_page_21606 filemap_get_page 2 21606 NULL
116963 +gfs2_glock_nq_init_21624 gfs2_glock_nq_init 0 21624 NULL
116964 +ocfs2_refcount_cow_hunk_21630 ocfs2_refcount_cow_hunk 3-4 21630 NULL
116965 +__jfs_getxattr_21631 __jfs_getxattr 0 21631 NULL
116966 +__irq_alloc_descs_21639 __irq_alloc_descs 0-3 21639 NULL
116967 +ocfs2_lock_refcount_allocators_21646 ocfs2_lock_refcount_allocators 0 21646 NULL
116968 +lpfc_sli4_cfg_post_extnts_21671 lpfc_sli4_cfg_post_extnts 0 21671 NULL
116969 +atalk_sendmsg_21677 atalk_sendmsg 4 21677 NULL
116970 +ocfs2_xattr_get_nolock_21678 ocfs2_xattr_get_nolock 0 21678 NULL
116971 +regmap_register_patch_21681 regmap_register_patch 3 21681 NULL
116972 +rtllib_alloc_txb_21687 rtllib_alloc_txb 1 21687 NULL
116973 +evdev_ioctl_handler_21705 evdev_ioctl_handler 2 21705 NULL
116974 +xfs_btree_insert_21712 xfs_btree_insert 0 21712 NULL
116975 +update_time_21719 update_time 0 21719 NULL
116976 +unix_skb_len_21722 unix_skb_len 0 21722 NULL
116977 +lprocfs_wr_import_21728 lprocfs_wr_import 3 21728 NULL
116978 +ocfs2_remove_rightmost_path_21729 ocfs2_remove_rightmost_path 0 21729 NULL
116979 +mthca_alloc_init_21754 mthca_alloc_init 2-0 21754 NULL
116980 +usbat_flash_read_data_21762 usbat_flash_read_data 4 21762 NULL
116981 +gen_pool_add_21776 gen_pool_add 3 21776 NULL
116982 +SyS_sendfile_21777 SyS_sendfile 4 21777 NULL
116983 +xfs_da_grow_inode_int_21785 xfs_da_grow_inode_int 3 21785 NULL
116984 +dvb_generic_ioctl_21810 dvb_generic_ioctl 2 21810 NULL
116985 +__ocfs2_cluster_lock_21812 __ocfs2_cluster_lock 0 21812 NULL
116986 +wm8994_request_irq_21822 wm8994_request_irq 2 21822 NULL
116987 +_iwl_dbgfs_sta_drain_write_21837 _iwl_dbgfs_sta_drain_write 3 21837 NULL
116988 +ieee80211_init_cipher_suites_21841 ieee80211_init_cipher_suites 0 21841 NULL
116989 +oom_adj_read_21847 oom_adj_read 3 21847 NULL
116990 +lpfc_idiag_extacc_avail_get_21865 lpfc_idiag_extacc_avail_get 0-3 21865 NULL
116991 +brcms_debugfs_hardware_read_21867 brcms_debugfs_hardware_read 3 21867 NULL
116992 +msix_capability_init_21870 msix_capability_init 0 21870 NULL
116993 +sisusbcon_bmove_21873 sisusbcon_bmove 6-5-7 21873 NULL
116994 +c_can_wait_for_ctrl_init_21874 c_can_wait_for_ctrl_init 0 21874 NULL
116995 +ldlm_lock_create_21888 ldlm_lock_create 7 21888 NULL
116996 +mlx4_init_mcg_table_21907 mlx4_init_mcg_table 0 21907 NULL
116997 +dbAllocCtl_21911 dbAllocCtl 0 21911 NULL
116998 +qsfp_1_read_21915 qsfp_1_read 3 21915 NULL
116999 +atl1_sw_init_21935 atl1_sw_init 0 21935 NULL
117000 +__ocfs2_claim_clusters_21936 __ocfs2_claim_clusters 0 21936 NULL
117001 +snd_card_saa7134_pcm_21938 snd_card_saa7134_pcm 0 21938 NULL
117002 +twl_i2c_write_u16_21953 twl_i2c_write_u16 3 21953 NULL
117003 +__build_xattrs_21979 __build_xattrs 0 21979 NULL
117004 +SYSC_prctl_21980 SYSC_prctl 4 21980 NULL
117005 +xen_bind_pirq_msi_to_irq_21986 xen_bind_pirq_msi_to_irq 4 21986 NULL
117006 +compat_rw_copy_check_uvector_22001 compat_rw_copy_check_uvector 3-0 22001 NULL nohasharray
117007 +rxpipe_descr_host_int_trig_rx_data_read_22001 rxpipe_descr_host_int_trig_rx_data_read 3 22001 &compat_rw_copy_check_uvector_22001
117008 +ocfs2_reserve_cluster_bitmap_bits_22016 ocfs2_reserve_cluster_bitmap_bits 0 22016 NULL
117009 +regcache_sync_block_raw_flush_22021 regcache_sync_block_raw_flush 3-4 22021 NULL
117010 +btrfs_get_16_22023 btrfs_get_16 0 22023 NULL
117011 +_sp2d_min_pg_22032 _sp2d_min_pg 0 22032 NULL
117012 +lookup_metapath_22039 lookup_metapath 0 22039 NULL
117013 +zd_usb_read_fw_22049 zd_usb_read_fw 4 22049 NULL
117014 +ieee80211_if_fmt_dropped_frames_ttl_22054 ieee80211_if_fmt_dropped_frames_ttl 3 22054 NULL nohasharray
117015 +skge_ring_alloc_22054 skge_ring_alloc 0 22054 &ieee80211_if_fmt_dropped_frames_ttl_22054
117016 +hpsa_find_cfg_addrs_22063 hpsa_find_cfg_addrs 0 22063 NULL
117017 +mlx4_multi_func_init_22066 mlx4_multi_func_init 0 22066 NULL
117018 +btrfs_reloc_clone_csums_22077 btrfs_reloc_clone_csums 2-3 22077 NULL
117019 +mem_rw_22085 mem_rw 3 22085 NULL
117020 +xfs_bmapi_reserve_delalloc_22086 xfs_bmapi_reserve_delalloc 0 22086 NULL
117021 +kstrtos32_from_user_22087 kstrtos32_from_user 2 22087 NULL
117022 +snd_pcm_xrun_22088 snd_pcm_xrun 0 22088 NULL
117023 +rt2x00debug_read_crypto_stats_22109 rt2x00debug_read_crypto_stats 3 22109 NULL
117024 +shmem_add_to_page_cache_22121 shmem_add_to_page_cache 0 22121 NULL nohasharray
117025 +rtsx_pci_init_hw_22121 rtsx_pci_init_hw 0 22121 &shmem_add_to_page_cache_22121
117026 +snd_hda_codec_read_22130 snd_hda_codec_read 0 22130 NULL
117027 +mwifiex_pcie_alloc_sleep_cookie_buf_22146 mwifiex_pcie_alloc_sleep_cookie_buf 0 22146 NULL
117028 +SyS_sched_setaffinity_22148 SyS_sched_setaffinity 2 22148 NULL
117029 +do_tcp_sendpages_22155 do_tcp_sendpages 4 22155 NULL
117030 +pci_request_region_22164 pci_request_region 0 22164 NULL
117031 +__kfifo_alloc_22173 __kfifo_alloc 3 22173 NULL
117032 +cmd_exec_22204 cmd_exec 0 22204 NULL
117033 +clear_sge_ctxt_22219 clear_sge_ctxt 0 22219 NULL
117034 +rfcomm_sock_recvmsg_22227 rfcomm_sock_recvmsg 4 22227 NULL
117035 +mem_write_22232 mem_write 3 22232 NULL
117036 +p9_virtio_zc_request_22240 p9_virtio_zc_request 6-5 22240 NULL
117037 +fsnotify_parent_22243 fsnotify_parent 0 22243 NULL
117038 +prepare_to_wait_event_22247 prepare_to_wait_event 0 22247 NULL
117039 +compat_process_vm_rw_22254 compat_process_vm_rw 3-5 22254 NULL
117040 +ping_common_sendmsg_22261 ping_common_sendmsg 5 22261 NULL
117041 +add_res_tree_22263 add_res_tree 7-0 22263 NULL
117042 +queue_max_sectors_22280 queue_max_sectors 0 22280 NULL
117043 +__tun_chr_ioctl_22300 __tun_chr_ioctl 4 22300 NULL nohasharray
117044 +pci_vpd_srdt_size_22300 pci_vpd_srdt_size 0 22300 &__tun_chr_ioctl_22300
117045 +mthca_tune_pci_22304 mthca_tune_pci 0 22304 NULL
117046 +mesh_table_alloc_22305 mesh_table_alloc 1 22305 NULL
117047 +lov_setstripe_22307 lov_setstripe 2 22307 NULL
117048 +check_range_22308 check_range 0 22308 NULL
117049 +udpv6_sendmsg_22316 udpv6_sendmsg 4 22316 NULL
117050 +C_SYSC_msgrcv_22320 C_SYSC_msgrcv 3 22320 NULL
117051 +page_cache_tree_insert_22331 page_cache_tree_insert 0 22331 NULL
117052 +do_migrate_range_22334 do_migrate_range 0 22334 NULL
117053 +atomic_read_22342 atomic_read 0 22342 NULL
117054 +ptn3460_read_bytes_22352 ptn3460_read_bytes 4 22352 NULL
117055 +ll_lazystatfs_seq_write_22353 ll_lazystatfs_seq_write 3 22353 NULL
117056 +c_can_chip_config_22357 c_can_chip_config 0 22357 NULL
117057 +snd_pcm_alsa_frames_22363 snd_pcm_alsa_frames 2 22363 NULL
117058 +tps6586x_gpio_to_irq_22365 tps6586x_gpio_to_irq 2 22365 NULL
117059 +evdev_ioctl_22371 evdev_ioctl 2 22371 NULL
117060 +alloc_large_system_hash_22391 alloc_large_system_hash 2 22391 NULL
117061 +ocfs2_assign_bh_22392 ocfs2_assign_bh 0 22392 NULL
117062 +mlx4_dev_cap_22395 mlx4_dev_cap 0 22395 NULL
117063 +zoran_write_22404 zoran_write 3 22404 NULL
117064 +queue_reply_22416 queue_reply 3 22416 NULL
117065 +__set_enter_print_fmt_22431 __set_enter_print_fmt 0 22431 NULL
117066 +queue_max_segments_22441 queue_max_segments 0 22441 NULL
117067 +handle_received_packet_22457 handle_received_packet 3 22457 NULL
117068 +snd_wss_new_22472 snd_wss_new 0 22472 NULL
117069 +comedi_pci_enable_22483 comedi_pci_enable 0 22483 NULL
117070 +ecryptfs_write_22488 ecryptfs_write 4-3 22488 NULL
117071 +qib_user_sdma_alloc_header_22490 qib_user_sdma_alloc_header 2 22490 NULL
117072 +cache_write_procfs_22491 cache_write_procfs 3 22491 NULL
117073 +mutex_lock_interruptible_22505 mutex_lock_interruptible 0 22505 NULL
117074 +trim_no_bitmap_22524 trim_no_bitmap 4-3 22524 NULL
117075 +ntb_setup_bwd_msix_22549 ntb_setup_bwd_msix 2-0 22549 NULL
117076 +ocfs2_read_extent_block_22550 ocfs2_read_extent_block 0 22550 NULL
117077 +agp_alloc_page_array_22554 agp_alloc_page_array 1 22554 NULL
117078 +mlx4_cmd_imm_22582 mlx4_cmd_imm 0 22582 NULL
117079 +dbFindCtl_22587 dbFindCtl 0 22587 NULL
117080 +snapshot_read_22601 snapshot_read 3 22601 NULL
117081 +ocfs2_get_refcount_block_22610 ocfs2_get_refcount_block 0 22610 NULL
117082 +sctp_setsockopt_connectx_old_22631 sctp_setsockopt_connectx_old 3 22631 NULL
117083 +ide_core_cp_entry_22636 ide_core_cp_entry 3 22636 NULL
117084 +wl1271_rx_filter_get_fields_size_22638 wl1271_rx_filter_get_fields_size 0 22638 NULL
117085 +pwr_wake_on_timer_exp_read_22640 pwr_wake_on_timer_exp_read 3 22640 NULL
117086 +iwl_dbgfs_calib_disabled_read_22649 iwl_dbgfs_calib_disabled_read 3 22649 NULL
117087 +compat_SyS_msgrcv_22661 compat_SyS_msgrcv 3 22661 NULL
117088 +call_netdevice_notifiers_22672 call_netdevice_notifiers 0 22672 NULL
117089 +ext4_ext_direct_IO_22679 ext4_ext_direct_IO 4 22679 NULL
117090 +fill_gap_22681 fill_gap 0 22681 NULL nohasharray
117091 +l2tp_ip_recvmsg_22681 l2tp_ip_recvmsg 4 22681 &fill_gap_22681
117092 +bch_dump_read_22685 bch_dump_read 3 22685 NULL
117093 +reg_umr_22686 reg_umr 5 22686 NULL
117094 +fnic_request_intr_22693 fnic_request_intr 0 22693 NULL
117095 +SYSC_vmsplice_22697 SYSC_vmsplice 3 22697 NULL
117096 +alloc_libipw_22708 alloc_libipw 1 22708 NULL
117097 +ecryptfs_write_metadata_to_contents_22721 ecryptfs_write_metadata_to_contents 3 22721 NULL
117098 +cx18_copy_buf_to_user_22735 cx18_copy_buf_to_user 4-0 22735 NULL nohasharray
117099 +__mlx4_cq_alloc_icm_22735 __mlx4_cq_alloc_icm 0 22735 &cx18_copy_buf_to_user_22735
117100 +ceph_decode_32_22738 ceph_decode_32 0 22738 NULL nohasharray
117101 +__mei_cl_send_22738 __mei_cl_send 3 22738 &ceph_decode_32_22738
117102 +__writeback_single_inode_22739 __writeback_single_inode 0 22739 NULL
117103 +iio_debugfs_write_reg_22742 iio_debugfs_write_reg 3 22742 NULL
117104 +mlx4_init_pd_table_22758 mlx4_init_pd_table 0 22758 NULL
117105 +qlcnic_sriov_init_22762 qlcnic_sriov_init 2 22762 NULL
117106 +si4713_write_property_22765 si4713_write_property 0 22765 NULL
117107 +t4_config_glbl_rss_22767 t4_config_glbl_rss 0 22767 NULL
117108 +print_frame_22769 print_frame 0 22769 NULL
117109 +ftrace_arch_read_dyn_info_22773 ftrace_arch_read_dyn_info 0 22773 NULL
117110 +ocfs2_block_group_alloc_22774 ocfs2_block_group_alloc 0 22774 NULL
117111 +__break_lease_22777 __break_lease 0 22777 NULL
117112 +bus_add_groups_22782 bus_add_groups 0 22782 NULL
117113 +vnic_dev_get_res_count_22791 vnic_dev_get_res_count 0 22791 NULL
117114 +pla_ocp_write_22802 pla_ocp_write 4 22802 NULL
117115 +__generic_copy_to_user_intel_22806 __generic_copy_to_user_intel 0-3 22806 NULL
117116 +create_attr_set_22861 create_attr_set 1 22861 NULL
117117 +hash_ip6_expire_22867 hash_ip6_expire 4 22867 NULL
117118 +vmw_execbuf_process_22885 vmw_execbuf_process 5 22885 NULL
117119 +usblp_new_writeurb_22894 usblp_new_writeurb 2 22894 NULL
117120 +mdc800_device_read_22896 mdc800_device_read 3 22896 NULL
117121 +ion_handle_test_kernel_22900 ion_handle_test_kernel 4-3 22900 NULL nohasharray
117122 +policy_emit_config_values_22900 policy_emit_config_values 3 22900 &ion_handle_test_kernel_22900
117123 +mwl8k_cmd_get_hw_spec_sta_22922 mwl8k_cmd_get_hw_spec_sta 0 22922 NULL
117124 +__set_xattr_22923 __set_xattr 0 22923 NULL nohasharray
117125 +mthca_QUERY_FW_22923 mthca_QUERY_FW 0 22923 &__set_xattr_22923
117126 +c67x00_ll_reset_22925 c67x00_ll_reset 0 22925 NULL
117127 +xstateregs_set_22932 xstateregs_set 4 22932 NULL
117128 +max8925_write_device_22937 max8925_write_device 3 22937 NULL
117129 +pcpu_mem_zalloc_22948 pcpu_mem_zalloc 1 22948 NULL
117130 +alloc_sglist_22960 alloc_sglist 2-3 22960 NULL
117131 +caif_seqpkt_sendmsg_22961 caif_seqpkt_sendmsg 4 22961 NULL
117132 +vme_get_size_22964 vme_get_size 0 22964 NULL
117133 +tx_frag_key_not_found_read_22971 tx_frag_key_not_found_read 3 22971 NULL
117134 +cached_dev_cache_miss_22979 cached_dev_cache_miss 4 22979 NULL
117135 +usb_get_langid_22983 usb_get_langid 0 22983 NULL
117136 +remote_settings_file_write_22987 remote_settings_file_write 3 22987 NULL
117137 +viafb_dvp0_proc_write_23023 viafb_dvp0_proc_write 3 23023 NULL
117138 +cifs_local_to_utf16_bytes_23025 cifs_local_to_utf16_bytes 0 23025 NULL
117139 +ocfs2_refcount_cow_xattr_23029 ocfs2_refcount_cow_xattr 6-7-0 23029 NULL
117140 +st_status_23032 st_status 5 23032 NULL
117141 +lx_dsp_get_mac_23037 lx_dsp_get_mac 0 23037 NULL
117142 +nv50_disp_chan_create__23056 nv50_disp_chan_create_ 5 23056 NULL
117143 +comedi_buf_write_n_available_23057 comedi_buf_write_n_available 0 23057 NULL
117144 +security_inode_killpriv_23060 security_inode_killpriv 0 23060 NULL
117145 +reiserfs_add_entry_23062 reiserfs_add_entry 4 23062 NULL nohasharray
117146 +unix_seqpacket_recvmsg_23062 unix_seqpacket_recvmsg 4 23062 &reiserfs_add_entry_23062
117147 +mei_cl_send_23068 mei_cl_send 3 23068 NULL
117148 +walk_system_ram_range_23073 walk_system_ram_range 0 23073 NULL
117149 +kvm_mmu_gva_to_gpa_write_23075 kvm_mmu_gva_to_gpa_write 0 23075 NULL
117150 +raw_sendmsg_23078 raw_sendmsg 4 23078 NULL
117151 +get_user_hdr_len_23079 get_user_hdr_len 0 23079 NULL
117152 +isr_tx_procs_read_23084 isr_tx_procs_read 3 23084 NULL
117153 +rt2x00debug_write_eeprom_23091 rt2x00debug_write_eeprom 3 23091 NULL
117154 +ntfs_ucstonls_23097 ntfs_ucstonls 3-5 23097 NULL
117155 +wiphy_register_23099 wiphy_register 0 23099 NULL
117156 +xfs_dir_ialloc_23100 xfs_dir_ialloc 0 23100 NULL
117157 +pipe_iov_copy_from_user_23102 pipe_iov_copy_from_user 3 23102 NULL
117158 +dgram_recvmsg_23104 dgram_recvmsg 4 23104 NULL
117159 +kernfs_rename_ns_23106 kernfs_rename_ns 0 23106 NULL
117160 +mwl8k_cmd_set_beacon_23110 mwl8k_cmd_set_beacon 4 23110 NULL
117161 +nl80211_send_rx_auth_23111 nl80211_send_rx_auth 4 23111 NULL nohasharray
117162 +bset_tree_bytes_23111 bset_tree_bytes 0 23111 &nl80211_send_rx_auth_23111
117163 +reset_card_23116 reset_card 0 23116 NULL
117164 +__clear_user_23118 __clear_user 0-2 23118 NULL
117165 +drm_mode_create_tv_properties_23122 drm_mode_create_tv_properties 2 23122 NULL
117166 +ata_scsi_change_queue_depth_23126 ata_scsi_change_queue_depth 2 23126 NULL
117167 +em28xx_write_regs_req_23138 em28xx_write_regs_req 0 23138 NULL
117168 +read_file_ani_23161 read_file_ani 3 23161 NULL
117169 +usblp_write_23178 usblp_write 3 23178 NULL
117170 +gss_pipe_downcall_23182 gss_pipe_downcall 3 23182 NULL
117171 +mpi_alloc_limb_space_23190 mpi_alloc_limb_space 1 23190 NULL
117172 +pm80x_free_irq_23210 pm80x_free_irq 2 23210 NULL
117173 +nft_hash_tbl_alloc_23224 nft_hash_tbl_alloc 1 23224 NULL
117174 +tty_buffer_request_room_23228 tty_buffer_request_room 2-0 23228 NULL
117175 +xlog_get_bp_23229 xlog_get_bp 2 23229 NULL nohasharray
117176 +__read_status_pci_23229 __read_status_pci 0 23229 &xlog_get_bp_23229
117177 +rxrpc_client_sendmsg_23236 rxrpc_client_sendmsg 5 23236 NULL
117178 +__gfn_to_rmap_23240 __gfn_to_rmap 2-1 23240 NULL
117179 +nv50_ram_create__23241 nv50_ram_create_ 4 23241 NULL
117180 +mlx4_write_mtt_23248 mlx4_write_mtt 0 23248 NULL
117181 +fnic_notify_set_23263 fnic_notify_set 0 23263 NULL
117182 +sctp_recvmsg_23265 sctp_recvmsg 4 23265 NULL
117183 +uwb_dev_addr_print_23282 uwb_dev_addr_print 2 23282 NULL
117184 +diva_get_trace_filter_23286 diva_get_trace_filter 0 23286 NULL
117185 +i2cdev_write_23310 i2cdev_write 3 23310 NULL
117186 +__aa_kvmalloc_23320 __aa_kvmalloc 1 23320 NULL
117187 +page_readlink_23346 page_readlink 3 23346 NULL
117188 +kmem_zalloc_large_23351 kmem_zalloc_large 1 23351 NULL
117189 +get_dst_timing_23358 get_dst_timing 0 23358 NULL nohasharray
117190 +write_inode_23358 write_inode 0 23358 &get_dst_timing_23358
117191 +fd_setup_write_same_buf_23369 fd_setup_write_same_buf 3 23369 NULL
117192 +pt1_init_tables_23377 pt1_init_tables 0 23377 NULL
117193 +iscsi_change_queue_depth_23416 iscsi_change_queue_depth 2 23416 NULL
117194 +vga_mm_r_23419 vga_mm_r 0 23419 NULL
117195 +gpiod_export_23427 gpiod_export 0 23427 NULL
117196 +ocfs2_zero_tail_23447 ocfs2_zero_tail 3 23447 NULL
117197 +hidraw_send_report_23449 hidraw_send_report 3 23449 NULL
117198 +__ata_change_queue_depth_23484 __ata_change_queue_depth 3 23484 NULL
117199 +linear_conf_23485 linear_conf 2 23485 NULL nohasharray
117200 +sync_mapping_buffers_23485 sync_mapping_buffers 0 23485 &linear_conf_23485
117201 +unmap_and_move_huge_page_23492 unmap_and_move_huge_page 0 23492 NULL
117202 +si4713_send_command_23493 si4713_send_command 0-4-6 23493 NULL
117203 +event_filter_read_23494 event_filter_read 3 23494 NULL
117204 +lustre_acl_xattr_merge2ext_23502 lustre_acl_xattr_merge2ext 2 23502 NULL
117205 +_request_firmware_load_23508 _request_firmware_load 0 23508 NULL
117206 +devm_iio_device_alloc_23511 devm_iio_device_alloc 2 23511 NULL
117207 +__proc_cpt_table_23516 __proc_cpt_table 5 23516 NULL
117208 +hash_ipmark6_expire_23518 hash_ipmark6_expire 4 23518 NULL
117209 +ima_show_measurements_count_23536 ima_show_measurements_count 3 23536 NULL
117210 +tcp_current_mss_23552 tcp_current_mss 0 23552 NULL
117211 +dbg_leb_change_23555 dbg_leb_change 0 23555 NULL
117212 +btrfs_super_bytenr_23561 btrfs_super_bytenr 0 23561 NULL
117213 +mwl8k_cmd_radio_control_23569 mwl8k_cmd_radio_control 0 23569 NULL
117214 +venus_symlink_23570 venus_symlink 6-4 23570 NULL
117215 +iwl_dbgfs_interrupt_read_23574 iwl_dbgfs_interrupt_read 3 23574 NULL
117216 +_regmap_select_page_23575 _regmap_select_page 0 23575 NULL
117217 +xfpregs_get_23586 xfpregs_get 4 23586 NULL
117218 +snd_interval_min_23590 snd_interval_min 0 23590 NULL
117219 +islpci_mgt_transaction_23610 islpci_mgt_transaction 5 23610 NULL
117220 +xfs_qm_dqread_23613 xfs_qm_dqread 0 23613 NULL
117221 +ocfs2_journal_access_23616 ocfs2_journal_access 0 23616 NULL
117222 +rt2x00mmio_alloc_queue_dma_23638 rt2x00mmio_alloc_queue_dma 0 23638 NULL
117223 +__i2400mu_send_barker_23652 __i2400mu_send_barker 3 23652 NULL
117224 +ath10k_init_hw_params_23656 ath10k_init_hw_params 0 23656 NULL
117225 +sInW_23663 sInW 0 23663 NULL
117226 +SyS_connect_23669 SyS_connect 3 23669 NULL
117227 +t4_sge_init_soft_23684 t4_sge_init_soft 0 23684 NULL
117228 +cx18_read_23699 cx18_read 3 23699 NULL
117229 +at_get_23708 at_get 0 23708 NULL
117230 +start_queue_23741 start_queue 0 23741 NULL
117231 +rx_rx_dropped_frame_read_23748 rx_rx_dropped_frame_read 3 23748 NULL
117232 +__kfifo_max_r_23768 __kfifo_max_r 0-2-1 23768 NULL
117233 +__build_packet_message_23778 __build_packet_message 4-10 23778 NULL
117234 +security_inode_getxattr_23781 security_inode_getxattr 0 23781 NULL
117235 +cfg80211_inform_bss_width_frame_23782 cfg80211_inform_bss_width_frame 5 23782 NULL
117236 +mpt_free_res_23793 mpt_free_res 5 23793 NULL
117237 +map_write_23795 map_write 3 23795 NULL
117238 +rx_path_reset_read_23801 rx_path_reset_read 3 23801 NULL
117239 +ocfs2_replace_cow_23803 ocfs2_replace_cow 0 23803 NULL
117240 +__earlyonly_bootmem_alloc_23824 __earlyonly_bootmem_alloc 2 23824 NULL
117241 +lustre_msg_buflen_23827 lustre_msg_buflen 0 23827 NULL
117242 +ceph_copy_page_vector_to_user_23829 ceph_copy_page_vector_to_user 0-4-3 23829 NULL
117243 +pgdat_end_pfn_23842 pgdat_end_pfn 0 23842 NULL
117244 +iwl_dbgfs_nvm_read_23845 iwl_dbgfs_nvm_read 3 23845 NULL
117245 +p54_init_common_23850 p54_init_common 1 23850 NULL
117246 +gart_alloc_coherent_23852 gart_alloc_coherent 2 23852 NULL
117247 +bin_to_hex_dup_23853 bin_to_hex_dup 2 23853 NULL
117248 +ocfs2_xattr_get_clusters_23857 ocfs2_xattr_get_clusters 0 23857 NULL
117249 +ieee80211_if_read_dot11MeshMaxPeerLinks_23878 ieee80211_if_read_dot11MeshMaxPeerLinks 3 23878 NULL
117250 +nouveau_clock_create__23881 nouveau_clock_create_ 5 23881 NULL nohasharray
117251 +writeback_single_inode_23881 writeback_single_inode 0 23881 &nouveau_clock_create__23881
117252 +__tg3_writephy_23889 __tg3_writephy 0 23889 NULL
117253 +tipc_snprintf_23893 tipc_snprintf 2-0 23893 NULL
117254 +add_new_gdb_meta_bg_23911 add_new_gdb_meta_bg 3 23911 NULL nohasharray
117255 +ieee80211_if_read_hw_queues_23911 ieee80211_if_read_hw_queues 3 23911 &add_new_gdb_meta_bg_23911
117256 +device_create_bin_file_23914 device_create_bin_file 0 23914 NULL
117257 +f2fs_getxattr_23917 f2fs_getxattr 0 23917 NULL
117258 +mpihelp_mul_karatsuba_case_23918 mpihelp_mul_karatsuba_case 5-3 23918 NULL nohasharray
117259 +ipath_reg_phys_mr_23918 ipath_reg_phys_mr 3 23918 &mpihelp_mul_karatsuba_case_23918
117260 +kvm_read_guest_23928 kvm_read_guest 4-2 23928 NULL
117261 +uvc_endpoint_max_bpi_23944 uvc_endpoint_max_bpi 0 23944 NULL
117262 +cifs_setxattr_23957 cifs_setxattr 4 23957 NULL
117263 +size_roundup_power2_23958 size_roundup_power2 0-1 23958 NULL
117264 +vfs_write_23971 vfs_write 3-0 23971 NULL
117265 +sddr55_write_data_23983 sddr55_write_data 4 23983 NULL
117266 +zd_usb_iowrite16v_async_23984 zd_usb_iowrite16v_async 3 23984 NULL
117267 +p54spi_request_eeprom_23985 p54spi_request_eeprom 0 23985 NULL
117268 +cxgb_alloc_mem_24007 cxgb_alloc_mem 1 24007 NULL
117269 +__at86rf230_read_subreg_24016 __at86rf230_read_subreg 0 24016 NULL
117270 +give_pages_24021 give_pages 3 24021 NULL
117271 +adis16400_show_serial_number_24037 adis16400_show_serial_number 3 24037 NULL
117272 +hmac_setkey_24043 hmac_setkey 3 24043 NULL
117273 +afs_cell_alloc_24052 afs_cell_alloc 2 24052 NULL
117274 +iwl_dbgfs_low_latency_read_24062 iwl_dbgfs_low_latency_read 3 24062 NULL
117275 +vb2_fop_read_24080 vb2_fop_read 3 24080 NULL
117276 +C_SYSC_process_vm_writev_24102 C_SYSC_process_vm_writev 3-5 24102 NULL
117277 +pipeline_post_proc_swi_read_24108 pipeline_post_proc_swi_read 3 24108 NULL
117278 +request_key_auth_read_24109 request_key_auth_read 3 24109 NULL
117279 +hv_ringbuffer_write_24114 hv_ringbuffer_write 0 24114 NULL nohasharray
117280 +tg3_test_dma_24114 tg3_test_dma 0 24114 &hv_ringbuffer_write_24114
117281 +lov_brw_24122 lov_brw 4 24122 NULL
117282 +mpu401_read_24126 mpu401_read 0-3 24126 NULL
117283 +_picolcd_flash_write_24134 _picolcd_flash_write 4 24134 NULL nohasharray
117284 +si4713_powerup_24134 si4713_powerup 0 24134 &_picolcd_flash_write_24134
117285 +irnet_ctrl_write_24139 irnet_ctrl_write 3 24139 NULL nohasharray
117286 +xfs_btree_increment_24139 xfs_btree_increment 0 24139 &irnet_ctrl_write_24139
117287 +SyS_sethostname_24150 SyS_sethostname 2 24150 NULL
117288 +trim_bitmaps_24158 trim_bitmaps 3 24158 NULL
117289 +adu_read_24177 adu_read 3 24177 NULL
117290 +safe_prepare_write_buffer_24187 safe_prepare_write_buffer 3 24187 NULL
117291 +irq_remapping_setup_msi_irqs_24194 irq_remapping_setup_msi_irqs 2 24194 NULL
117292 +ieee80211_if_read_dot11MeshHWMPpreqMinInterval_24208 ieee80211_if_read_dot11MeshHWMPpreqMinInterval 3 24208 NULL
117293 +efx_vf_size_24213 efx_vf_size 0 24213 NULL
117294 +p54_convert_rev1_24215 p54_convert_rev1 0 24215 NULL
117295 +SyS_sendfile64_24220 SyS_sendfile64 4 24220 NULL
117296 +tcpprobe_sprint_24222 tcpprobe_sprint 0-2 24222 NULL
117297 +mei_amthif_read_24224 mei_amthif_read 4 24224 NULL nohasharray
117298 +pcpu_embed_first_chunk_24224 pcpu_embed_first_chunk 3-2-1 24224 &mei_amthif_read_24224
117299 +pci_num_vf_24235 pci_num_vf 0 24235 NULL
117300 +sel_read_bool_24236 sel_read_bool 3 24236 NULL
117301 +xfs_bmap_rtalloc_24237 xfs_bmap_rtalloc 0 24237 NULL
117302 +em28xx_alloc_urbs_24260 em28xx_alloc_urbs 4-6 24260 NULL
117303 +mthca_QUERY_ADAPTER_24265 mthca_QUERY_ADAPTER 0 24265 NULL
117304 +crypto_register_ahash_24267 crypto_register_ahash 0 24267 NULL
117305 +calculate_sizes_24273 calculate_sizes 2 24273 NULL
117306 +thin_status_24278 thin_status 5 24278 NULL
117307 +msg_size_24288 msg_size 0 24288 NULL
117308 +ath10k_mac_register_24291 ath10k_mac_register 0 24291 NULL
117309 +i2c_smbus_check_pec_24297 i2c_smbus_check_pec 0 24297 NULL
117310 +map_page_24298 map_page 4-3 24298 NULL
117311 +gserial_connect_24302 gserial_connect 0 24302 NULL
117312 +btmrvl_pscmd_read_24308 btmrvl_pscmd_read 3 24308 NULL
117313 +reserve_metadata_bytes_24313 reserve_metadata_bytes 0 24313 NULL
117314 +ath6kl_add_bss_if_needed_24317 ath6kl_add_bss_if_needed 6 24317 NULL
117315 +pci_write_config_word_24318 pci_write_config_word 0 24318 NULL
117316 +si476x_radio_read_acf_blob_24336 si476x_radio_read_acf_blob 3 24336 NULL
117317 +C_SYSC_pwritev_24345 C_SYSC_pwritev 3 24345 NULL
117318 +prepare_pages_24349 prepare_pages 0 24349 NULL
117319 +kzalloc_node_24352 kzalloc_node 1 24352 NULL
117320 +dwc2_hcd_init_24359 dwc2_hcd_init 0 24359 NULL
117321 +qla2x00_handle_queue_full_24365 qla2x00_handle_queue_full 2 24365 NULL
117322 +cfi_read_pri_24366 cfi_read_pri 3 24366 NULL
117323 +btrfs_item_size_nr_24367 btrfs_item_size_nr 0 24367 NULL
117324 +igetword_24373 igetword 0 24373 NULL nohasharray
117325 +break_deleg_24373 break_deleg 0 24373 &igetword_24373
117326 +max_io_len_24384 max_io_len 0-1 24384 NULL
117327 +mpt_alloc_res_24387 mpt_alloc_res 5 24387 NULL
117328 +xfs_bmapi_read_24392 xfs_bmapi_read 0 24392 NULL
117329 +osc_cur_grant_bytes_seq_write_24396 osc_cur_grant_bytes_seq_write 3 24396 NULL
117330 +getxattr_24398 getxattr 4 24398 NULL nohasharray
117331 +pvr2_v4l2_ioctl_24398 pvr2_v4l2_ioctl 2 24398 &getxattr_24398
117332 +populate_msi_sysfs_24399 populate_msi_sysfs 0 24399 NULL
117333 +blk_update_bidi_request_24415 blk_update_bidi_request 3-4 24415 NULL
117334 +nvme_trans_log_supp_pages_24418 nvme_trans_log_supp_pages 3 24418 NULL
117335 +b43_debugfs_read_24425 b43_debugfs_read 3 24425 NULL
117336 +xenbus_file_read_24427 xenbus_file_read 3 24427 NULL
117337 +ieee80211_rx_mgmt_beacon_24430 ieee80211_rx_mgmt_beacon 3 24430 NULL
117338 +copy_and_ioctl_24434 copy_and_ioctl 4 24434 NULL
117339 +ixgbe_alloc_q_vector_24439 ixgbe_alloc_q_vector 4-6 24439 NULL
117340 +smk_user_access_24440 smk_user_access 3 24440 NULL nohasharray
117341 +rtw_set_wps_assoc_resp_24440 rtw_set_wps_assoc_resp 3 24440 &smk_user_access_24440
117342 +evdev_do_ioctl_24459 evdev_do_ioctl 2 24459 NULL
117343 +lbs_highsnr_write_24460 lbs_highsnr_write 3 24460 NULL
117344 +skb_copy_and_csum_datagram_iovec_24466 skb_copy_and_csum_datagram_iovec 2 24466 NULL
117345 +mlx4_map_cmd_24471 mlx4_map_cmd 0 24471 NULL
117346 +eeprom_read_24477 eeprom_read 0 24477 NULL
117347 +dut_mode_read_24489 dut_mode_read 3 24489 NULL
117348 +read_file_spec_scan_ctl_24491 read_file_spec_scan_ctl 3 24491 NULL
117349 +snd_at73c213_pcm_new_24493 snd_at73c213_pcm_new 0 24493 NULL
117350 +pd_video_read_24510 pd_video_read 3 24510 NULL
117351 +request_key_with_auxdata_24515 request_key_with_auxdata 4 24515 NULL
117352 +xfs_buf_get_map_24522 xfs_buf_get_map 3 24522 NULL
117353 +do_mpage_readpage_24536 do_mpage_readpage 3 24536 NULL
117354 +sta2x11_vip_init_controls_24549 sta2x11_vip_init_controls 0 24549 NULL
117355 +write_cache_pages_24562 write_cache_pages 0 24562 NULL
117356 +SyS_pselect6_24582 SyS_pselect6 1 24582 NULL
117357 +udf_compute_nr_groups_24594 udf_compute_nr_groups 0 24594 NULL
117358 +lpfc_sli_issue_mbox_wait_24596 lpfc_sli_issue_mbox_wait 0 24596 NULL
117359 +de_reset_mac_24598 de_reset_mac 0 24598 NULL
117360 +vfio_default_config_write_24602 vfio_default_config_write 0-3 24602 NULL
117361 +sensor_hub_get_physical_device_count_24605 sensor_hub_get_physical_device_count 0 24605 NULL nohasharray
117362 +lov_alloc_memmd_24605 lov_alloc_memmd 2 24605 &sensor_hub_get_physical_device_count_24605
117363 +SyS_poll_24620 SyS_poll 2 24620 NULL
117364 +context_alloc_24645 context_alloc 3 24645 NULL
117365 +blk_rq_err_bytes_24650 blk_rq_err_bytes 0 24650 NULL
117366 +btrfs_check_data_free_space_24692 btrfs_check_data_free_space 0 24692 NULL
117367 +datafab_write_data_24696 datafab_write_data 4 24696 NULL
117368 +ata_host_activate_24702 ata_host_activate 0 24702 NULL
117369 +intelfbhw_get_p1p2_24703 intelfbhw_get_p1p2 2 24703 NULL
117370 +simple_attr_read_24738 simple_attr_read 3 24738 NULL
117371 +qla2x00_change_queue_depth_24742 qla2x00_change_queue_depth 2 24742 NULL
117372 +get_dma_residue_24749 get_dma_residue 0 24749 NULL
117373 +fnic_cq_alloc_24750 fnic_cq_alloc 0 24750 NULL
117374 +ocfs2_cow_file_pos_24751 ocfs2_cow_file_pos 3 24751 NULL
117375 +kgdb_hex2mem_24755 kgdb_hex2mem 3 24755 NULL
117376 +ath9k_init_debug_24765 ath9k_init_debug 0 24765 NULL
117377 +ocfs2_read_blocks_24777 ocfs2_read_blocks 0 24777 NULL
117378 +em28xx_audio_setup_24778 em28xx_audio_setup 0 24778 NULL
117379 +datablob_hmac_verify_24786 datablob_hmac_verify 4 24786 NULL
117380 +cache_read_24790 cache_read 3 24790 NULL
117381 +__xfs_get_blocks_24791 __xfs_get_blocks 2 24791 NULL
117382 +user_regset_copyout_24796 user_regset_copyout 7 24796 NULL
117383 +bcm_kona_gpio_to_irq_24799 bcm_kona_gpio_to_irq 2 24799 NULL
117384 +kvm_read_guest_virt_helper_24804 kvm_read_guest_virt_helper 3-1 24804 NULL
117385 +ath6kl_fwlog_mask_write_24810 ath6kl_fwlog_mask_write 3 24810 NULL
117386 +net2272_read_24825 net2272_read 0 24825 NULL
117387 +snd_als4k_gcr_read_24840 snd_als4k_gcr_read 0 24840 NULL
117388 +snd_pcm_lib_buffer_bytes_24865 snd_pcm_lib_buffer_bytes 0 24865 NULL
117389 +l2cap_create_basic_pdu_24869 l2cap_create_basic_pdu 3 24869 NULL nohasharray
117390 +pnp_alloc_24869 pnp_alloc 1 24869 &l2cap_create_basic_pdu_24869
117391 +queues_read_24877 queues_read 3 24877 NULL
117392 +__vxge_hw_vp_initialize_24885 __vxge_hw_vp_initialize 2 24885 NULL
117393 +xfs_qm_dqattach_24898 xfs_qm_dqattach 0 24898 NULL
117394 +codec_list_read_file_24910 codec_list_read_file 3 24910 NULL
117395 +ngene_command_load_firmware_24916 ngene_command_load_firmware 0 24916 NULL
117396 +__btrfs_free_extent_24927 __btrfs_free_extent 7 24927 NULL nohasharray
117397 +v4l2_ctrl_new_24927 v4l2_ctrl_new 7 24927 &__btrfs_free_extent_24927
117398 +ocfs2_fiemap_24949 ocfs2_fiemap 3-4 24949 NULL
117399 +snd_wss_pcm_24951 snd_wss_pcm 0 24951 NULL
117400 +packet_sendmsg_24954 packet_sendmsg 4 24954 NULL
117401 +ipg_io_config_24957 ipg_io_config 0 24957 NULL
117402 +security_inode_rename_24971 security_inode_rename 0 24971 NULL
117403 +twl_i2c_write_u8_24976 twl_i2c_write_u8 3 24976 NULL
117404 +llc_ui_sendmsg_24987 llc_ui_sendmsg 4 24987 NULL
117405 +devm_spi_register_master_24995 devm_spi_register_master 0 24995 NULL
117406 +slot_get_24999 slot_get 0 24999 NULL
117407 +key_conf_hw_key_idx_read_25003 key_conf_hw_key_idx_read 3 25003 NULL
117408 +il_dbgfs_channels_read_25005 il_dbgfs_channels_read 3 25005 NULL nohasharray
117409 +mwl8k_encryption_set_cmd_info_25005 mwl8k_encryption_set_cmd_info 0 25005 &il_dbgfs_channels_read_25005
117410 +tg3_readphy_25017 tg3_readphy 0 25017 NULL
117411 +ni_660x_num_counters_25031 ni_660x_num_counters 0 25031 NULL
117412 +nfs_dns_resolve_name_25036 nfs_dns_resolve_name 3 25036 NULL
117413 +load_unaligned_zeropad_25050 load_unaligned_zeropad 0 25050 NULL
117414 +btrfs_stack_key_blockptr_25058 btrfs_stack_key_blockptr 0 25058 NULL
117415 +gs_buf_alloc_25067 gs_buf_alloc 2 25067 NULL
117416 +ll_track_pid_seq_write_25068 ll_track_pid_seq_write 3 25068 NULL
117417 +SYSC_listxattr_25072 SYSC_listxattr 3 25072 NULL
117418 +enic_set_intr_mode_25081 enic_set_intr_mode 0 25081 NULL
117419 +ima_appraise_measurement_25093 ima_appraise_measurement 6 25093 NULL
117420 +irq_cpu_rmap_add_25104 irq_cpu_rmap_add 0 25104 NULL
117421 +snd_rawmidi_kernel_write_25106 snd_rawmidi_kernel_write 3 25106 NULL
117422 +mlx4_cmd_poll_25112 mlx4_cmd_poll 0 25112 NULL
117423 +gfs2_quota_check_25130 gfs2_quota_check 0 25130 NULL
117424 +ipath_init_qp_table_25167 ipath_init_qp_table 2 25167 NULL
117425 +kvm_mmu_notifier_change_pte_25169 kvm_mmu_notifier_change_pte 3 25169 NULL nohasharray
117426 +_iwl_dbgfs_reduced_txp_write_25169 _iwl_dbgfs_reduced_txp_write 3 25169 &kvm_mmu_notifier_change_pte_25169
117427 +sctp_getsockopt_local_addrs_25178 sctp_getsockopt_local_addrs 2 25178 NULL
117428 +mon_stat_read_25238 mon_stat_read 3 25238 NULL
117429 +bma180_set_bw_25243 bma180_set_bw 0 25243 NULL
117430 +t4vf_read_rss_vi_config_25254 t4vf_read_rss_vi_config 0 25254 NULL
117431 +stripe_status_25259 stripe_status 5 25259 NULL
117432 +dvbdev_get_free_adapter_num_25271 dvbdev_get_free_adapter_num 0 25271 NULL
117433 +snd_pcm_start_25273 snd_pcm_start 0 25273 NULL
117434 +crypto_alloc_instance2_25277 crypto_alloc_instance2 3 25277 NULL
117435 +vfs_writev_25278 vfs_writev 3 25278 NULL
117436 +l2tp_session_create_25286 l2tp_session_create 1 25286 NULL
117437 +read8_reg_25307 read8_reg 0-4 25307 NULL
117438 +ath9k_debugfs_read_buf_25316 ath9k_debugfs_read_buf 3 25316 NULL
117439 +rng_buffer_size_25348 rng_buffer_size 0 25348 NULL
117440 +SYSC_kexec_load_25361 SYSC_kexec_load 2 25361 NULL
117441 +unix_mkname_25368 unix_mkname 0-2 25368 NULL
117442 +sel_read_mls_25369 sel_read_mls 3 25369 NULL
117443 +tc3589x_gpio_to_irq_25371 tc3589x_gpio_to_irq 2 25371 NULL
117444 +SyS_splice_25390 SyS_splice 5 25390 NULL
117445 +vsp1_entity_init_25407 vsp1_entity_init 3 25407 NULL
117446 +xfs_ialloc_pagi_init_25411 xfs_ialloc_pagi_init 0 25411 NULL
117447 +_gpiod_direction_output_raw_25414 _gpiod_direction_output_raw 0 25414 NULL
117448 +dai_list_read_file_25421 dai_list_read_file 3 25421 NULL
117449 +xfs_qm_dqtobp_25448 xfs_qm_dqtobp 0 25448 NULL
117450 +ipath_decode_err_25468 ipath_decode_err 3 25468 NULL
117451 +crypto_hash_digestsize_25469 crypto_hash_digestsize 0 25469 NULL
117452 +remove_mtt_ok_25486 remove_mtt_ok 0 25486 NULL
117453 +ivtv_buf_copy_from_user_25502 ivtv_buf_copy_from_user 4-0 25502 NULL
117454 +snd_pcm_plugin_build_25505 snd_pcm_plugin_build 5 25505 NULL
117455 +xfs_alloc_fix_freelist_25514 xfs_alloc_fix_freelist 0 25514 NULL
117456 +sb_permission_25523 sb_permission 0 25523 NULL
117457 +ext3_get_inode_loc_25542 ext3_get_inode_loc 0 25542 NULL
117458 +ieee80211_if_read_path_refresh_time_25545 ieee80211_if_read_path_refresh_time 3 25545 NULL
117459 +wimax_addr_scnprint_25548 wimax_addr_scnprint 2 25548 NULL
117460 +ht_print_chan_25556 ht_print_chan 0-3-4 25556 NULL
117461 +skb_tailroom_25567 skb_tailroom 0 25567 NULL
117462 +il4965_init_drv_25580 il4965_init_drv 0 25580 NULL
117463 +ping_recvmsg_25597 ping_recvmsg 4 25597 NULL
117464 +copy_user_generic_25611 copy_user_generic 0 25611 NULL
117465 +proc_coredump_filter_write_25625 proc_coredump_filter_write 3 25625 NULL
117466 +befs_utf2nls_25628 befs_utf2nls 3 25628 NULL nohasharray
117467 +__get_user_pages_25628 __get_user_pages 0 25628 &befs_utf2nls_25628
117468 +__direct_map_25647 __direct_map 5-6 25647 NULL
117469 +mlx4_init_uar_table_25661 mlx4_init_uar_table 0 25661 NULL
117470 +aircable_prepare_write_buffer_25669 aircable_prepare_write_buffer 3 25669 NULL
117471 +lpfc_idiag_cmd_get_25672 lpfc_idiag_cmd_get 2 25672 NULL
117472 +sta_inactive_ms_read_25690 sta_inactive_ms_read 3 25690 NULL
117473 +prom_early_alloc_25692 prom_early_alloc 1 25692 NULL
117474 +alloc_ring_25697 alloc_ring 0 25697 NULL
117475 +rx_filter_mc_filter_read_25712 rx_filter_mc_filter_read 3 25712 NULL
117476 +ibmasm_new_command_25714 ibmasm_new_command 2 25714 NULL
117477 +__alloc_bootmem_low_node_25726 __alloc_bootmem_low_node 2 25726 NULL nohasharray
117478 +sel_write_context_25726 sel_write_context 3 25726 &__alloc_bootmem_low_node_25726
117479 +cxgbi_device_portmap_create_25747 cxgbi_device_portmap_create 3 25747 NULL
117480 +fnic_dev_spec_25790 fnic_dev_spec 0 25790 NULL
117481 +event_rx_pool_read_25792 event_rx_pool_read 3 25792 NULL
117482 +sg_read_25799 sg_read 3 25799 NULL
117483 +xfs_alloc_ag_vextent_exact_25810 xfs_alloc_ag_vextent_exact 0 25810 NULL
117484 +system_enable_read_25815 system_enable_read 3 25815 NULL nohasharray
117485 +kset_register_25815 kset_register 0 25815 &system_enable_read_25815
117486 +realloc_buffer_25816 realloc_buffer 2 25816 NULL
117487 +pwr_missing_bcns_read_25824 pwr_missing_bcns_read 3 25824 NULL
117488 +cx18_prep_dev_25854 cx18_prep_dev 0 25854 NULL
117489 +parport_read_25855 parport_read 0 25855 NULL
117490 +xfs_dir2_sf_hdr_size_25858 xfs_dir2_sf_hdr_size 0 25858 NULL
117491 +key_attr_size_25865 key_attr_size 0 25865 NULL
117492 +ieee802154_register_device_25866 ieee802154_register_device 0 25866 NULL
117493 +ath6kl_regread_read_25884 ath6kl_regread_read 3 25884 NULL
117494 +run_delalloc_nocow_25896 run_delalloc_nocow 3-4 25896 NULL
117495 +sisusbcon_scroll_area_25899 sisusbcon_scroll_area 4-3 25899 NULL
117496 +lpfc_change_queue_depth_25905 lpfc_change_queue_depth 2 25905 NULL
117497 +tmiofb_hw_init_25906 tmiofb_hw_init 0 25906 NULL
117498 +nvme_trans_mode_page_create_25908 nvme_trans_mode_page_create 7-4 25908 NULL
117499 +do_jffs2_setxattr_25910 do_jffs2_setxattr 5 25910 NULL
117500 +rcname_read_25919 rcname_read 3 25919 NULL
117501 +snd_es1938_capture_copy_25930 snd_es1938_capture_copy 5 25930 NULL
117502 +key_flags_read_25931 key_flags_read 3 25931 NULL
117503 +copy_play_buf_25932 copy_play_buf 3 25932 NULL
117504 +iio_buffer_register_25952 iio_buffer_register 0 25952 NULL
117505 +flush_25957 flush 2 25957 NULL
117506 +mthca_ENABLE_LAM_25960 mthca_ENABLE_LAM 0 25960 NULL
117507 +_regmap_multi_reg_write_25967 _regmap_multi_reg_write 3 25967 NULL
117508 +video_register_device_25971 video_register_device 0 25971 NULL
117509 +udp_setsockopt_25985 udp_setsockopt 5 25985 NULL
117510 +lustre_msg_buflen_v2_25997 lustre_msg_buflen_v2 0 25997 NULL
117511 +SyS_process_vm_readv_26019 SyS_process_vm_readv 3-5 26019 NULL
117512 +irq_create_strict_mappings_26025 irq_create_strict_mappings 4 26025 NULL
117513 +mptscsih_change_queue_depth_26036 mptscsih_change_queue_depth 2 26036 NULL
117514 +selinux_inode_post_setxattr_26037 selinux_inode_post_setxattr 4 26037 NULL
117515 +ccp_init_26054 ccp_init 0 26054 NULL
117516 +keyctl_update_key_26061 keyctl_update_key 3 26061 NULL
117517 +pri_wm_latency_write_26063 pri_wm_latency_write 3 26063 NULL
117518 +pcim_iomap_regions_26084 pcim_iomap_regions 0 26084 NULL
117519 +rx_rx_wa_density_dropped_frame_read_26095 rx_rx_wa_density_dropped_frame_read 3 26095 NULL
117520 +mid_setup_dma_26097 mid_setup_dma 0 26097 NULL
117521 +i8042_pnp_id_to_string_26108 i8042_pnp_id_to_string 3 26108 NULL
117522 +read_sb_page_26119 read_sb_page 5 26119 NULL
117523 +mlx4_comm_cmd_wait_26138 mlx4_comm_cmd_wait 0 26138 NULL
117524 +ath9k_hw_name_26146 ath9k_hw_name 3 26146 NULL
117525 +copy_oldmem_page_26164 copy_oldmem_page 3 26164 NULL
117526 +gfs2_xattr_acl_get_26166 gfs2_xattr_acl_get 0 26166 NULL nohasharray
117527 +ath6kl_roam_table_read_26166 ath6kl_roam_table_read 3 26166 &gfs2_xattr_acl_get_26166
117528 +disk_devt_26180 disk_devt 0 26180 NULL
117529 +ieee80211_if_fmt_dot11MeshTTL_26198 ieee80211_if_fmt_dot11MeshTTL 3 26198 NULL
117530 +xfs_idata_realloc_26199 xfs_idata_realloc 2 26199 NULL
117531 +mce_write_26201 mce_write 3 26201 NULL
117532 +alloc_name_26202 alloc_name 0 26202 NULL
117533 +SyS_splice_26206 SyS_splice 5 26206 NULL
117534 +platform_device_register_26214 platform_device_register 0 26214 NULL
117535 +mwifiex_regrdwr_write_26225 mwifiex_regrdwr_write 3 26225 NULL
117536 +_scsih_change_queue_depth_26230 _scsih_change_queue_depth 2 26230 NULL
117537 +rxrpc_recvmsg_26233 rxrpc_recvmsg 4 26233 NULL
117538 +simple_setattr_26234 simple_setattr 0 26234 NULL
117539 +ecryptfs_read_lower_page_segment_26244 ecryptfs_read_lower_page_segment 4 26244 NULL
117540 +hv_ringbuffer_init_26246 hv_ringbuffer_init 0 26246 NULL
117541 +genwqe_ffdc_buff_size_26263 genwqe_ffdc_buff_size 0 26263 NULL
117542 +crypto_ctxsize_26278 crypto_ctxsize 0 26278 NULL
117543 +apei_resources_request_26279 apei_resources_request 0 26279 NULL
117544 +wacom_set_device_mode_26280 wacom_set_device_mode 3 26280 NULL
117545 +cx18_dvb_register_26282 cx18_dvb_register 0 26282 NULL
117546 +recursive_scan_26296 recursive_scan 0 26296 NULL
117547 +snd_pcm_plug_client_channels_buf_26309 snd_pcm_plug_client_channels_buf 0-3 26309 NULL
117548 +pwr_wake_on_host_read_26321 pwr_wake_on_host_read 3 26321 NULL
117549 +check_can_nocow_26336 check_can_nocow 2 26336 NULL
117550 +da903x_add_subdevs_26338 da903x_add_subdevs 0 26338 NULL
117551 +snd_vx_check_reg_bit_26344 snd_vx_check_reg_bit 0 26344 NULL
117552 +ocfs2_duplicate_clusters_by_page_26357 ocfs2_duplicate_clusters_by_page 6-3 26357 NULL
117553 +cifs_readdata_alloc_26360 cifs_readdata_alloc 1 26360 NULL
117554 +notifier_chain_register_26372 notifier_chain_register 0 26372 NULL
117555 +invalidate_inode_pages2_range_26403 invalidate_inode_pages2_range 0 26403 NULL
117556 +ntty_write_26404 ntty_write 3 26404 NULL
117557 +firmware_store_26408 firmware_store 4 26408 NULL
117558 +pagemap_read_26441 pagemap_read 3 26441 NULL
117559 +tower_read_26461 tower_read 3 26461 NULL nohasharray
117560 +enc_pools_add_pages_26461 enc_pools_add_pages 1 26461 &tower_read_26461
117561 +e100_alloc_cbs_26462 e100_alloc_cbs 0 26462 NULL
117562 +ib_alloc_device_26483 ib_alloc_device 1 26483 NULL
117563 +ulong_write_file_26485 ulong_write_file 3 26485 NULL
117564 +dvb_ca_en50221_io_ioctl_26490 dvb_ca_en50221_io_ioctl 2 26490 NULL
117565 +carmine_init_26495 carmine_init 0 26495 NULL
117566 +read_vmcore_26501 read_vmcore 3 26501 NULL
117567 +uhid_char_write_26502 uhid_char_write 3 26502 NULL
117568 +vfio_pci_set_msi_trigger_26507 vfio_pci_set_msi_trigger 4-3 26507 NULL
117569 +iwl_dbgfs_rf_reset_read_26512 iwl_dbgfs_rf_reset_read 3 26512 NULL
117570 +alloc_ep_req_26521 alloc_ep_req 3-2 26521 NULL
117571 +vnic_intr_alloc_26535 vnic_intr_alloc 0 26535 NULL
117572 +ath10k_htt_h2t_ver_req_msg_26537 ath10k_htt_h2t_ver_req_msg 0 26537 NULL
117573 +SyS_rt_sigpending_26538 SyS_rt_sigpending 2 26538 NULL
117574 +__vhost_add_used_n_26554 __vhost_add_used_n 3 26554 NULL
117575 +dio_new_bio_26562 dio_new_bio 0 26562 NULL
117576 +ath10k_htt_tx_inc_pending_26569 ath10k_htt_tx_inc_pending 0 26569 NULL
117577 +rts51x_read_mem_26577 rts51x_read_mem 4 26577 NULL
117578 +ath9k_init_device_26582 ath9k_init_device 0 26582 NULL
117579 +sas_register_phys_26586 sas_register_phys 0 26586 NULL
117580 +pci_set_cacheline_size_26598 pci_set_cacheline_size 0 26598 NULL
117581 +__unmap_single_26604 __unmap_single 2-3 26604 NULL
117582 +xfs_rtcheck_range_26614 xfs_rtcheck_range 0 26614 NULL
117583 +kernfs_name_locked_26617 kernfs_name_locked 3 26617 NULL
117584 +iommu_alloc_26621 iommu_alloc 4 26621 NULL
117585 +pwr_fix_tsf_ps_read_26627 pwr_fix_tsf_ps_read 3 26627 NULL
117586 +upload_dsp_code_26649 upload_dsp_code 0 26649 NULL
117587 +irq_alloc_generic_chip_26650 irq_alloc_generic_chip 2 26650 NULL nohasharray
117588 +inb_p_26650 inb_p 0 26650 &irq_alloc_generic_chip_26650
117589 +nouveau_volt_create__26654 nouveau_volt_create_ 4 26654 NULL
117590 +ath5k_hw_init_26657 ath5k_hw_init 0 26657 NULL
117591 +adnp_gpio_to_irq_26668 adnp_gpio_to_irq 2 26668 NULL
117592 +c_can_set_bittiming_26674 c_can_set_bittiming 0 26674 NULL
117593 +cipso_v4_map_cat_rbm_hton_26680 cipso_v4_map_cat_rbm_hton 0 26680 NULL
117594 +flowinfo_read_26683 flowinfo_read 3 26683 NULL
117595 +yellowfin_init_ring_26714 yellowfin_init_ring 0 26714 NULL
117596 +sysfs_add_file_26716 sysfs_add_file 0 26716 NULL
117597 +nouveau_namedb_create__26732 nouveau_namedb_create_ 7 26732 NULL
117598 +nilfs_rec_len_from_disk_26739 nilfs_rec_len_from_disk 0-1 26739 NULL
117599 +snd_rawmidi_new_26740 snd_rawmidi_new 0 26740 NULL
117600 +pipeline_tcp_rx_stat_fifo_int_read_26745 pipeline_tcp_rx_stat_fifo_int_read 3 26745 NULL
117601 +bos_desc_26752 bos_desc 0 26752 NULL
117602 +pci_bus_read_config_byte_26759 pci_bus_read_config_byte 0 26759 NULL
117603 +snd_hda_get_raw_connections_26762 snd_hda_get_raw_connections 0 26762 NULL
117604 +dma_map_single_attrs_26779 dma_map_single_attrs 0 26779 NULL
117605 +hcd_buffer_create_26787 hcd_buffer_create 0 26787 NULL
117606 +qlcnic_alloc_sds_rings_26795 qlcnic_alloc_sds_rings 2 26795 NULL
117607 +mfd_add_device_26810 mfd_add_device 0 26810 NULL
117608 +cipso_v4_genopt_26812 cipso_v4_genopt 0 26812 NULL
117609 +iwl_trans_read_mem32_26825 iwl_trans_read_mem32 0 26825 NULL nohasharray
117610 +lbs_setup_firmware_26825 lbs_setup_firmware 0 26825 &iwl_trans_read_mem32_26825
117611 +smk_write_load_26829 smk_write_load 3 26829 NULL
117612 +ibmasm_init_remote_input_dev_26833 ibmasm_init_remote_input_dev 0 26833 NULL
117613 +xfs_alloc_pagf_init_26834 xfs_alloc_pagf_init 0 26834 NULL
117614 +scnprint_id_26842 scnprint_id 3-0 26842 NULL
117615 +ecryptfs_miscdev_write_26847 ecryptfs_miscdev_write 3 26847 NULL
117616 +ss_alloc_ep_req_26848 ss_alloc_ep_req 2 26848 NULL
117617 +tipc_conn_sendmsg_26867 tipc_conn_sendmsg 5 26867 NULL
117618 +ath6kl_create_qos_write_26879 ath6kl_create_qos_write 3 26879 NULL
117619 +svc_print_xprts_26881 svc_print_xprts 0 26881 NULL
117620 +skb_zerocopy_headlen_26910 skb_zerocopy_headlen 0 26910 NULL
117621 +hhf_zalloc_26912 hhf_zalloc 1 26912 NULL
117622 +cfg80211_process_auth_26916 cfg80211_process_auth 3 26916 NULL
117623 +x25_asy_change_mtu_26928 x25_asy_change_mtu 2 26928 NULL
117624 +scsi_tgt_copy_sense_26933 scsi_tgt_copy_sense 3 26933 NULL
117625 +sctp_setsockopt_adaptation_layer_26935 sctp_setsockopt_adaptation_layer 3 26935 NULL nohasharray
117626 +pwr_ps_enter_read_26935 pwr_ps_enter_read 3 26935 &sctp_setsockopt_adaptation_layer_26935
117627 +hecubafb_write_26942 hecubafb_write 3 26942 NULL
117628 +extract_entropy_user_26952 extract_entropy_user 3 26952 NULL nohasharray
117629 +do_trimming_26952 do_trimming 3 26952 &extract_entropy_user_26952
117630 +do_direct_IO_26979 do_direct_IO 0 26979 NULL
117631 +shpc_indirect_read_26985 shpc_indirect_read 0 26985 NULL
117632 +mwl8k_fw_lock_26991 mwl8k_fw_lock 0 26991 NULL
117633 +i2c_smbus_xfer_27006 i2c_smbus_xfer 0 27006 NULL
117634 +xfs_filestream_associate_27030 xfs_filestream_associate 0 27030 NULL
117635 +snd_msnd_reset_dsp_27059 snd_msnd_reset_dsp 0 27059 NULL
117636 +__videobuf_alloc_vb_27062 __videobuf_alloc_vb 1 27062 NULL
117637 +ext4_convert_unwritten_extents_27064 ext4_convert_unwritten_extents 4-3-0 27064 NULL
117638 +snd_pcm_lib_period_bytes_27071 snd_pcm_lib_period_bytes 0 27071 NULL
117639 +paravirt_read_msr_27077 paravirt_read_msr 0 27077 NULL
117640 +alloc_fdmem_27083 alloc_fdmem 1 27083 NULL
117641 +find_first_bit_27088 find_first_bit 0 27088 NULL
117642 +btmrvl_hscmd_write_27089 btmrvl_hscmd_write 3 27089 NULL nohasharray
117643 +ath9k_hw_4k_dump_eeprom_27089 ath9k_hw_4k_dump_eeprom 5-4 27089 &btmrvl_hscmd_write_27089
117644 +__devcgroup_inode_permission_27108 __devcgroup_inode_permission 0 27108 NULL
117645 +get_kernel_page_27133 get_kernel_page 0 27133 NULL
117646 +drbd_get_capacity_27141 drbd_get_capacity 0 27141 NULL
117647 +pms_capture_27142 pms_capture 4 27142 NULL
117648 +btmrvl_hscfgcmd_write_27143 btmrvl_hscfgcmd_write 3 27143 NULL
117649 +snd_compr_calc_avail_27165 snd_compr_calc_avail 0 27165 NULL
117650 +ieee80211_if_read_rc_rateidx_mask_5ghz_27183 ieee80211_if_read_rc_rateidx_mask_5ghz 3 27183 NULL
117651 +__sg_alloc_table_27198 __sg_alloc_table 0 27198 NULL
117652 +write_kmem_27225 write_kmem 3 27225 NULL
117653 +dbAllocAG_27228 dbAllocAG 0 27228 NULL
117654 +rxrpc_request_key_27235 rxrpc_request_key 3 27235 NULL
117655 +solo_snd_pcm_init_27238 solo_snd_pcm_init 0 27238 NULL nohasharray
117656 +si476x_radio_init_debugfs_27238 si476x_radio_init_debugfs 0 27238 &solo_snd_pcm_init_27238
117657 +ocfs2_journal_access_path_27243 ocfs2_journal_access_path 0 27243 NULL
117658 +ds1374_check_rtc_status_27248 ds1374_check_rtc_status 0 27248 NULL
117659 +ll_track_gid_seq_write_27267 ll_track_gid_seq_write 3 27267 NULL
117660 +comedi_alloc_devpriv_27272 comedi_alloc_devpriv 2 27272 NULL
117661 +__dma_map_cont_27289 __dma_map_cont 5 27289 NULL
117662 +copy_from_buf_27308 copy_from_buf 2-4 27308 NULL
117663 +virtqueue_add_inbuf_27312 virtqueue_add_inbuf 3 27312 NULL
117664 +ntb_register_event_callback_27313 ntb_register_event_callback 0 27313 NULL
117665 +write_buf_27316 write_buf 3 27316 NULL
117666 +snd_pcm_oss_write2_27332 snd_pcm_oss_write2 3-0 27332 NULL
117667 +afs_cell_create_27346 afs_cell_create 2 27346 NULL
117668 +iwl_dbgfs_csr_write_27363 iwl_dbgfs_csr_write 3 27363 NULL
117669 +pcbit_stat_27364 pcbit_stat 2 27364 NULL
117670 +seq_read_27411 seq_read 3 27411 NULL
117671 +ib_dma_map_sg_27413 ib_dma_map_sg 0 27413 NULL
117672 +ieee80211_if_read_smps_27416 ieee80211_if_read_smps 3 27416 NULL
117673 +ocfs2_refcount_cal_cow_clusters_27422 ocfs2_refcount_cal_cow_clusters 3-4-0 27422 NULL
117674 +cypress_write_27423 cypress_write 4 27423 NULL
117675 +pt1_init_buffer_27430 pt1_init_buffer 0 27430 NULL
117676 +sddr09_read_data_27447 sddr09_read_data 3 27447 NULL
117677 +xfs_btree_lookup_get_block_27448 xfs_btree_lookup_get_block 0 27448 NULL
117678 +v4l2_ctrl_new_std_menu_items_27487 v4l2_ctrl_new_std_menu_items 4 27487 NULL
117679 +hcd_buffer_alloc_27495 hcd_buffer_alloc 2 27495 NULL
117680 +ip_set_get_h32_27498 ip_set_get_h32 0 27498 NULL
117681 +btrfs_get_64_27499 btrfs_get_64 0 27499 NULL
117682 +garmin_read_process_27509 garmin_read_process 3 27509 NULL
117683 +oti_alloc_cookies_27510 oti_alloc_cookies 2 27510 NULL
117684 +blocking_notifier_chain_register_27518 blocking_notifier_chain_register 0 27518 NULL
117685 +ib_copy_to_udata_27525 ib_copy_to_udata 3 27525 NULL
117686 +sky2_setup_irq_27538 sky2_setup_irq 0 27538 NULL
117687 +snd_sonicvibes_getdmaa_27552 snd_sonicvibes_getdmaa 0 27552 NULL
117688 +SyS_fgetxattr_27571 SyS_fgetxattr 4 27571 NULL
117689 +sco_sock_recvmsg_27572 sco_sock_recvmsg 4 27572 NULL
117690 +libipw_alloc_txb_27579 libipw_alloc_txb 1 27579 NULL
117691 +lbs_get_firmware_27609 lbs_get_firmware 0 27609 NULL
117692 +C_SYSC_mbind_27636 C_SYSC_mbind 5 27636 NULL
117693 +ocfs2_xattr_ibody_get_27642 ocfs2_xattr_ibody_get 0 27642 NULL nohasharray
117694 +read_flush_procfs_27642 read_flush_procfs 3 27642 &ocfs2_xattr_ibody_get_27642 nohasharray
117695 +nl80211_send_connect_result_27642 nl80211_send_connect_result 5-7 27642 &read_flush_procfs_27642 nohasharray
117696 +ocfs2_direct_IO_27642 ocfs2_direct_IO 4 27642 &nl80211_send_connect_result_27642 nohasharray
117697 +xfs_alloc_vextent_27642 xfs_alloc_vextent 0 27642 &ocfs2_direct_IO_27642
117698 +add_new_gdb_27643 add_new_gdb 3 27643 NULL
117699 +btrfs_fallocate_27647 btrfs_fallocate 3-4 27647 NULL
117700 +asd_download_seq_27653 asd_download_seq 0 27653 NULL
117701 +qnx6_readpages_27657 qnx6_readpages 4 27657 NULL
117702 +cdrom_read_cdda_old_27664 cdrom_read_cdda_old 4 27664 NULL
117703 +ath_tx_edma_init_27673 ath_tx_edma_init 0 27673 NULL
117704 +power_supply_create_gen_triggers_27685 power_supply_create_gen_triggers 0 27685 NULL
117705 +ocfs2_extend_dir_27695 ocfs2_extend_dir 4 27695 NULL
117706 +fs_path_add_from_extent_buffer_27702 fs_path_add_from_extent_buffer 4 27702 NULL
117707 +evm_write_key_27715 evm_write_key 3 27715 NULL
117708 +ieee80211_if_fmt_dot11MeshGateAnnouncementProtocol_27722 ieee80211_if_fmt_dot11MeshGateAnnouncementProtocol 3 27722 NULL
117709 +xfs_dir2_block_sfsize_27727 xfs_dir2_block_sfsize 0 27727 NULL
117710 +init_timers_cpu_27741 init_timers_cpu 0 27741 NULL
117711 +SyS_setsockopt_27759 SyS_setsockopt 5 27759 NULL
117712 +ipr_test_msi_27760 ipr_test_msi 0 27760 NULL
117713 +transport_init_session_tags_27776 transport_init_session_tags 1-2 27776 NULL nohasharray
117714 +gpiochip_export_27776 gpiochip_export 0 27776 &transport_init_session_tags_27776
117715 +__lov_setstripe_27782 __lov_setstripe 2 27782 NULL
117716 +snd_component_add_27784 snd_component_add 0 27784 NULL
117717 +twl4030_set_gpio_dataout_27792 twl4030_set_gpio_dataout 1 27792 NULL
117718 +SyS_readv_27804 SyS_readv 3 27804 NULL
117719 +mpihelp_mul_27805 mpihelp_mul 5-3 27805 NULL
117720 +hpt374_read_freq_27828 hpt374_read_freq 0 27828 NULL
117721 +init_header_complete_27833 init_header_complete 0 27833 NULL
117722 +read_profile_27859 read_profile 3 27859 NULL nohasharray
117723 +pcmcia_register_socket_27859 pcmcia_register_socket 0 27859 &read_profile_27859
117724 +sky2_pci_read16_27863 sky2_pci_read16 0 27863 NULL
117725 +ieee80211_if_read_dot11MeshHWMProotInterval_27873 ieee80211_if_read_dot11MeshHWMProotInterval 3 27873 NULL
117726 +unix_seqpacket_sendmsg_27893 unix_seqpacket_sendmsg 4 27893 NULL
117727 +driver_add_groups_27897 driver_add_groups 0 27897 NULL
117728 +mlx4_CONF_SPECIAL_QP_27915 mlx4_CONF_SPECIAL_QP 0 27915 NULL
117729 +i915_error_object_create_sized_27919 i915_error_object_create_sized 4 27919 NULL
117730 +t4_write_flash_27925 t4_write_flash 0 27925 NULL
117731 +t4vf_get_vfres_27935 t4vf_get_vfres 0 27935 NULL
117732 +unmap_and_move_27936 unmap_and_move 0 27936 NULL
117733 +check_mapped_name_27943 check_mapped_name 3 27943 NULL
117734 +tracing_clock_write_27961 tracing_clock_write 3 27961 NULL nohasharray
117735 +bio_next_split_27961 bio_next_split 2 27961 &tracing_clock_write_27961
117736 +enic_set_rss_nic_cfg_27966 enic_set_rss_nic_cfg 0 27966 NULL nohasharray
117737 +security_path_chown_27966 security_path_chown 0 27966 &enic_set_rss_nic_cfg_27966
117738 +tipc_media_addr_printf_27971 tipc_media_addr_printf 2 27971 NULL
117739 +device_register_27972 device_register 0 27972 NULL nohasharray
117740 +mic_rx_pkts_read_27972 mic_rx_pkts_read 3 27972 &device_register_27972
117741 +compat_SyS_set_mempolicy_27975 compat_SyS_set_mempolicy 3 27975 NULL nohasharray
117742 +xfs_alloc_fixup_trees_27975 xfs_alloc_fixup_trees 0 27975 &compat_SyS_set_mempolicy_27975
117743 +adm8211_hw_reset_27976 adm8211_hw_reset 0 27976 NULL
117744 +pci_enable_device_flags_27977 pci_enable_device_flags 0 27977 NULL nohasharray
117745 +__kernfs_setattr_27977 __kernfs_setattr 0 27977 &pci_enable_device_flags_27977
117746 +ipg_hw_init_27992 ipg_hw_init 0 27992 NULL
117747 +edt_ft5x06_debugfs_raw_data_read_28002 edt_ft5x06_debugfs_raw_data_read 3 28002 NULL
117748 +seq_get_buf_28006 seq_get_buf 0 28006 NULL
117749 +snd_rawmidi_write_28008 snd_rawmidi_write 3 28008 NULL
117750 +powercap_register_zone_28028 powercap_register_zone 6 28028 NULL
117751 +ath_mci_setup_28039 ath_mci_setup 0 28039 NULL
117752 +sctp_setsockopt_maxburst_28041 sctp_setsockopt_maxburst 3 28041 NULL
117753 +rts51x_xd_rw_28046 rts51x_xd_rw 3-4 28046 NULL
117754 +p9_fd_write_28050 p9_fd_write 3 28050 NULL
117755 +cx231xx_init_vbi_isoc_28053 cx231xx_init_vbi_isoc 3-2-4 28053 NULL
117756 +pool_status_28055 pool_status 5 28055 NULL
117757 +init_rs_non_canonical_28059 init_rs_non_canonical 1 28059 NULL nohasharray
117758 +sis_chip_init_28059 sis_chip_init 0 28059 &init_rs_non_canonical_28059
117759 +lpfc_idiag_mbxacc_read_28061 lpfc_idiag_mbxacc_read 3 28061 NULL
117760 +tea5764_i2c_read_28063 tea5764_i2c_read 0 28063 NULL
117761 +tx_frag_bad_mblk_num_read_28064 tx_frag_bad_mblk_num_read 3 28064 NULL
117762 +do_register_framebuffer_28067 do_register_framebuffer 0 28067 NULL
117763 +ib_query_port_28079 ib_query_port 0 28079 NULL
117764 +platform_get_irq_28088 platform_get_irq 0 28088 NULL
117765 +mmc_test_alloc_mem_28102 mmc_test_alloc_mem 3-2 28102 NULL
117766 +rx_defrag_need_defrag_read_28117 rx_defrag_need_defrag_read 3 28117 NULL
117767 +peak_pciec_probe_28118 peak_pciec_probe 0 28118 NULL
117768 +vgacon_adjust_height_28124 vgacon_adjust_height 2 28124 NULL
117769 +pluto_hw_init_28135 pluto_hw_init 0 28135 NULL
117770 +memblock_virt_alloc_from_nopanic_28146 memblock_virt_alloc_from_nopanic 1 28146 NULL
117771 +video_read_28148 video_read 3 28148 NULL
117772 +snd_midi_channel_alloc_set_28153 snd_midi_channel_alloc_set 1 28153 NULL
117773 +stats_dot11FCSErrorCount_read_28154 stats_dot11FCSErrorCount_read 3 28154 NULL
117774 +mi1_wr_addr_28156 mi1_wr_addr 0 28156 NULL
117775 +vread_28173 vread 0-3 28173 NULL
117776 +macvtap_get_user_28185 macvtap_get_user 4 28185 NULL
117777 +goldfish_tty_create_driver_28186 goldfish_tty_create_driver 0 28186 NULL
117778 +counter_free_res_28187 counter_free_res 5 28187 NULL
117779 +read_disk_sb_28188 read_disk_sb 2 28188 NULL
117780 +get_res_28191 get_res 0 28191 NULL
117781 +nouveau_mxm_create__28200 nouveau_mxm_create_ 4 28200 NULL
117782 +__qp_memcpy_from_queue_28220 __qp_memcpy_from_queue 3-4 28220 NULL
117783 +ocfs2_cow_sync_writeback_28221 ocfs2_cow_sync_writeback 0 28221 NULL
117784 +line6_alloc_sysex_buffer_28225 line6_alloc_sysex_buffer 4 28225 NULL
117785 +amd_nb_num_28228 amd_nb_num 0 28228 NULL
117786 +stex_common_handshake_28229 stex_common_handshake 0 28229 NULL
117787 +dwc2_gahbcfg_init_28266 dwc2_gahbcfg_init 0 28266 NULL
117788 +fuse_direct_IO_28275 fuse_direct_IO 4 28275 NULL
117789 +usemap_size_28281 usemap_size 0 28281 NULL
117790 +inline_xattr_size_28285 inline_xattr_size 0 28285 NULL
117791 +dma_map_sg_attrs_28289 dma_map_sg_attrs 0 28289 NULL
117792 +SyS_ppoll_28290 SyS_ppoll 2 28290 NULL
117793 +kstrtos16_from_user_28300 kstrtos16_from_user 2 28300 NULL
117794 +nouveau_compat_ioctl_28305 nouveau_compat_ioctl 2 28305 NULL
117795 +snd_pcm_oss_read_28317 snd_pcm_oss_read 3 28317 NULL
117796 +security_inode_link_28327 security_inode_link 0 28327 NULL
117797 +generic_write_checks_28329 generic_write_checks 0 28329 NULL
117798 +bm_entry_write_28338 bm_entry_write 3 28338 NULL
117799 +tcp_copy_to_iovec_28344 tcp_copy_to_iovec 3 28344 NULL
117800 +snapshot_write_28351 snapshot_write 3 28351 NULL
117801 +xfs_iomap_write_unwritten_28365 xfs_iomap_write_unwritten 3-2 28365 NULL
117802 +batadv_handle_tt_response_28370 batadv_handle_tt_response 4 28370 NULL
117803 +dlmfs_file_read_28385 dlmfs_file_read 3 28385 NULL
117804 +tx_frag_cache_miss_read_28394 tx_frag_cache_miss_read 3 28394 NULL
117805 +bypass_pwup_write_28416 bypass_pwup_write 3 28416 NULL
117806 +subdev_ioctl_28417 subdev_ioctl 2 28417 NULL
117807 +vfio_msi_cap_len_28424 vfio_msi_cap_len 0 28424 NULL
117808 +ksocknal_alloc_tx_28426 ksocknal_alloc_tx 2 28426 NULL
117809 +hid_hw_output_report_28429 hid_hw_output_report 0 28429 NULL
117810 +mpage_readpages_28436 mpage_readpages 3 28436 NULL
117811 +xfs_rtfind_back_28450 xfs_rtfind_back 0 28450 NULL
117812 +snd_emu10k1_efx_read_28452 snd_emu10k1_efx_read 2 28452 NULL
117813 +key_mic_failures_read_28457 key_mic_failures_read 3 28457 NULL
117814 +alloc_irq_cpu_rmap_28459 alloc_irq_cpu_rmap 1 28459 NULL
117815 +__filemap_fdatawrite_28485 __filemap_fdatawrite 0 28485 NULL
117816 +si4713_register_i2c_adapter_28515 si4713_register_i2c_adapter 0 28515 NULL
117817 +ps_poll_upsd_utilization_read_28519 ps_poll_upsd_utilization_read 3 28519 NULL
117818 +i2400m_tx_stats_read_28527 i2400m_tx_stats_read 3 28527 NULL
117819 +early_init_dt_alloc_memory_arch_28528 early_init_dt_alloc_memory_arch 1 28528 NULL
117820 +spu_set_bus_mode_28542 spu_set_bus_mode 0 28542 NULL
117821 +sel_read_policycap_28544 sel_read_policycap 3 28544 NULL
117822 +mptctl_getiocinfo_28545 mptctl_getiocinfo 2 28545 NULL nohasharray
117823 +aio_read_events_28545 aio_read_events 3 28545 &mptctl_getiocinfo_28545 nohasharray
117824 +run_delalloc_range_28545 run_delalloc_range 3-4 28545 &aio_read_events_28545
117825 +asd_init_phy_28547 asd_init_phy 0 28547 NULL
117826 +sysfs_create_bin_file_28551 sysfs_create_bin_file 0 28551 NULL
117827 +b43legacy_debugfs_write_28556 b43legacy_debugfs_write 3 28556 NULL
117828 +asymmetric_verify_28567 asymmetric_verify 3 28567 NULL
117829 +gfs2_meta_indirect_buffer_28573 gfs2_meta_indirect_buffer 0 28573 NULL
117830 +oxygen_read32_28582 oxygen_read32 0 28582 NULL
117831 +task_cgroup_path_28599 task_cgroup_path 3 28599 NULL
117832 +extract_entropy_28604 extract_entropy 5-3 28604 NULL
117833 +kfifo_unused_28612 kfifo_unused 0 28612 NULL
117834 +snd_nm256_capture_copy_28622 snd_nm256_capture_copy 3-5 28622 NULL
117835 +setup_usemap_28636 setup_usemap 3-4 28636 NULL
117836 +qib_handle_6120_hwerrors_28642 qib_handle_6120_hwerrors 3 28642 NULL
117837 +xfs_bmap_finish_28644 xfs_bmap_finish 0 28644 NULL nohasharray
117838 +myri10ge_load_hotplug_firmware_28644 myri10ge_load_hotplug_firmware 0 28644 &xfs_bmap_finish_28644
117839 +p9_fcall_alloc_28652 p9_fcall_alloc 1 28652 NULL
117840 +read_nic_io_byte_28654 read_nic_io_byte 0 28654 NULL
117841 +blk_queue_resize_tags_28670 blk_queue_resize_tags 2 28670 NULL
117842 +SyS_setgroups16_28686 SyS_setgroups16 1 28686 NULL
117843 +adau1701_register_size_28688 adau1701_register_size 0 28688 NULL
117844 +kvm_mmu_get_page_28692 kvm_mmu_get_page 2 28692 NULL
117845 +drm_plane_init_28731 drm_plane_init 6 28731 NULL
117846 +spi_execute_28736 spi_execute 5 28736 NULL
117847 +snd_pcm_aio_write_28738 snd_pcm_aio_write 3 28738 NULL
117848 +read_file_btcoex_28743 read_file_btcoex 3 28743 NULL
117849 +max_hw_blocks_28748 max_hw_blocks 0 28748 NULL
117850 +rpc_pipe_generic_upcall_28766 rpc_pipe_generic_upcall 4 28766 NULL
117851 +ath6kl_get_num_reg_28780 ath6kl_get_num_reg 0 28780 NULL
117852 +sel_write_member_28800 sel_write_member 3 28800 NULL
117853 +iwl_dbgfs_rxon_filter_flags_read_28832 iwl_dbgfs_rxon_filter_flags_read 3 28832 NULL
117854 +kernel_tree_alloc_28833 kernel_tree_alloc 1 28833 NULL
117855 +vp_request_msix_vectors_28849 vp_request_msix_vectors 2 28849 NULL
117856 +ssb_bus_powerup_28855 ssb_bus_powerup 0 28855 NULL
117857 +e100_self_test_28862 e100_self_test 0 28862 NULL
117858 +ipv6_renew_options_28867 ipv6_renew_options 5 28867 NULL
117859 +max_io_len_target_boundary_28879 max_io_len_target_boundary 0-1 28879 NULL
117860 +packet_sendmsg_spkt_28885 packet_sendmsg_spkt 4 28885 NULL
117861 +da9055_group_write_28904 da9055_group_write 2-3 28904 NULL
117862 +ps_upsd_timeouts_read_28924 ps_upsd_timeouts_read 3 28924 NULL
117863 +iwl_dbgfs_sleep_level_override_write_28925 iwl_dbgfs_sleep_level_override_write 3 28925 NULL
117864 +push_rx_28939 push_rx 3 28939 NULL
117865 +mxuport_prepare_write_buffer_28943 mxuport_prepare_write_buffer 3 28943 NULL
117866 +btrfs_trim_block_group_28963 btrfs_trim_block_group 3-4 28963 NULL
117867 +alloc_sched_domains_28972 alloc_sched_domains 1 28972 NULL
117868 +gfs2_dir_del_28977 gfs2_dir_del 0 28977 NULL
117869 +hash_net6_expire_28979 hash_net6_expire 4 28979 NULL
117870 +xfs_alloc_update_28982 xfs_alloc_update 0 28982 NULL
117871 +stex_request_irq_28992 stex_request_irq 0 28992 NULL
117872 +hci_sock_setsockopt_28993 hci_sock_setsockopt 5 28993 NULL
117873 +bin_uuid_28999 bin_uuid 3 28999 NULL
117874 +fd_execute_rw_29004 fd_execute_rw 3 29004 NULL
117875 +ieee80211_if_read_ht_opmode_29044 ieee80211_if_read_ht_opmode 3 29044 NULL
117876 +rxrpc_sendmsg_29049 rxrpc_sendmsg 4 29049 NULL
117877 +btrfs_root_bytenr_29058 btrfs_root_bytenr 0 29058 NULL
117878 +iso_packets_buffer_init_29061 iso_packets_buffer_init 3-4 29061 NULL
117879 +roundup_64_29066 roundup_64 2-0-1 29066 NULL
117880 +lpfc_idiag_extacc_drivr_get_29067 lpfc_idiag_extacc_drivr_get 0-3 29067 NULL
117881 +sctp_getsockopt_assoc_stats_29074 sctp_getsockopt_assoc_stats 2 29074 NULL
117882 +xfs_alloc_ag_vextent_small_29084 xfs_alloc_ag_vextent_small 0 29084 NULL
117883 +iwl_dbgfs_log_event_write_29088 iwl_dbgfs_log_event_write 3 29088 NULL
117884 +ccp_init_dm_workarea_29097 ccp_init_dm_workarea 3 29097 NULL
117885 +__compat_sys_preadv64_29103 __compat_sys_preadv64 3 29103 NULL
117886 +isdn_ppp_write_29109 isdn_ppp_write 4 29109 NULL
117887 +snprintf_29125 snprintf 0 29125 NULL
117888 +init_mac_29127 init_mac 0 29127 NULL
117889 +iov_shorten_29130 iov_shorten 0 29130 NULL
117890 +proc_scsi_write_29142 proc_scsi_write 3 29142 NULL
117891 +alloc_irqs_from_29152 alloc_irqs_from 0-2 29152 NULL
117892 +kvm_mmu_notifier_clear_flush_young_29154 kvm_mmu_notifier_clear_flush_young 3 29154 NULL
117893 +drm_property_create_enum_29201 drm_property_create_enum 5 29201 NULL
117894 +wusb_prf_256_29203 wusb_prf_256 7 29203 NULL
117895 +comedi_alloc_subdevices_29207 comedi_alloc_subdevices 0 29207 NULL
117896 +iwl_dbgfs_temperature_read_29224 iwl_dbgfs_temperature_read 3 29224 NULL
117897 +nvme_trans_copy_from_user_29227 nvme_trans_copy_from_user 3 29227 NULL
117898 +t4vf_wr_mbox_29233 t4vf_wr_mbox 0 29233 NULL
117899 +iio_device_register_debugfs_29234 iio_device_register_debugfs 0 29234 NULL
117900 +irq_domain_add_linear_29236 irq_domain_add_linear 2 29236 NULL
117901 +recover_peb_29238 recover_peb 0 29238 NULL
117902 +evdev_handle_get_val_29242 evdev_handle_get_val 5-6 29242 NULL
117903 +rw_verify_area_29243 rw_verify_area 0-4 29243 NULL
117904 +security_context_to_sid_core_29248 security_context_to_sid_core 2 29248 NULL
117905 +rbd_osd_req_create_29260 rbd_osd_req_create 3 29260 NULL
117906 +prism2_set_genericelement_29277 prism2_set_genericelement 3 29277 NULL
117907 +ext4_fiemap_29296 ext4_fiemap 4 29296 NULL
117908 +xfs_bmap_btree_to_extents_29297 xfs_bmap_btree_to_extents 0 29297 NULL
117909 +sn9c102_read_29305 sn9c102_read 3 29305 NULL
117910 +__fuse_get_req_29315 __fuse_get_req 2 29315 NULL
117911 +lprocfs_write_helper_29323 lprocfs_write_helper 2 29323 NULL
117912 +xfs_bmbt_change_owner_29325 xfs_bmbt_change_owner 0 29325 NULL
117913 +kvm_handle_hva_29326 kvm_handle_hva 2 29326 NULL
117914 +tun_put_user_29337 tun_put_user 5 29337 NULL
117915 +__alloc_ei_netdev_29338 __alloc_ei_netdev 1 29338 NULL
117916 +l2cap_sock_setsockopt_old_29346 l2cap_sock_setsockopt_old 4 29346 NULL
117917 +ext2_chunk_size_29354 ext2_chunk_size 0 29354 NULL
117918 +gpiochip_find_base_29366 gpiochip_find_base 0-1 29366 NULL
117919 +lx_pcm_create_29392 lx_pcm_create 0 29392 NULL
117920 +read_file_tx99_power_29405 read_file_tx99_power 3 29405 NULL
117921 +get_esi_asic_29417 get_esi_asic 0 29417 NULL
117922 +mempool_create_29437 mempool_create 1 29437 NULL
117923 +crypto_ahash_alignmask_29445 crypto_ahash_alignmask 0 29445 NULL
117924 +p9_client_prepare_req_29448 p9_client_prepare_req 3 29448 NULL
117925 +of_get_named_gpio_flags_29455 of_get_named_gpio_flags 0 29455 NULL
117926 +validate_scan_freqs_29462 validate_scan_freqs 0 29462 NULL
117927 +mlx4_init_srq_table_29470 mlx4_init_srq_table 0 29470 NULL
117928 +SyS_flistxattr_29474 SyS_flistxattr 3 29474 NULL
117929 +do_register_entry_29478 do_register_entry 4 29478 NULL
117930 +simple_strtoul_29480 simple_strtoul 0 29480 NULL
117931 +pci_enable_device_mem_29500 pci_enable_device_mem 0 29500 NULL
117932 +btmrvl_pscmd_write_29504 btmrvl_pscmd_write 3 29504 NULL
117933 +btrfs_file_extent_disk_bytenr_29505 btrfs_file_extent_disk_bytenr 0 29505 NULL
117934 +i2c_add_adapter_29507 i2c_add_adapter 0 29507 NULL
117935 +usnic_vnic_spec_dump_29508 usnic_vnic_spec_dump 2 29508 NULL
117936 +write_file_regidx_29517 write_file_regidx 3 29517 NULL
117937 +atk_debugfs_ggrp_read_29522 atk_debugfs_ggrp_read 3 29522 NULL
117938 +pci_enable_msix_29524 pci_enable_msix 0 29524 NULL
117939 +add_to_page_cache_lru_29534 add_to_page_cache_lru 0 29534 NULL
117940 +vfs_read_29543 vfs_read 0-3 29543 NULL
117941 +ftrace_write_29551 ftrace_write 3 29551 NULL
117942 +idetape_queue_rw_tail_29562 idetape_queue_rw_tail 3 29562 NULL
117943 +leaf_dealloc_29566 leaf_dealloc 3-2 29566 NULL
117944 +kvm_read_guest_virt_system_29569 kvm_read_guest_virt_system 4-2 29569 NULL
117945 +p9_fd_read_29570 p9_fd_read 3 29570 NULL
117946 +lbs_lowsnr_read_29571 lbs_lowsnr_read 3 29571 NULL
117947 +security_path_chmod_29578 security_path_chmod 0 29578 NULL
117948 +ext3_ordered_write_end_29584 ext3_ordered_write_end 5 29584 NULL
117949 +iwl_dbgfs_missed_beacon_write_29586 iwl_dbgfs_missed_beacon_write 3 29586 NULL
117950 +snd_device_new_29588 snd_device_new 0 29588 NULL
117951 +pvr2_hdw_report_unlocked_29589 pvr2_hdw_report_unlocked 4-0 29589 NULL
117952 +dio_set_defer_completion_29599 dio_set_defer_completion 0 29599 NULL
117953 +slots_per_page_29601 slots_per_page 0 29601 NULL
117954 +osc_cached_mb_seq_write_29610 osc_cached_mb_seq_write 3 29610 NULL
117955 +nla_get_u16_29624 nla_get_u16 0 29624 NULL
117956 +gfs2_alloc_blocks_29630 gfs2_alloc_blocks 0 29630 NULL
117957 +tx_frag_cache_hit_read_29639 tx_frag_cache_hit_read 3 29639 NULL
117958 +sctp_make_abort_user_29654 sctp_make_abort_user 3 29654 NULL nohasharray
117959 +spmi_controller_alloc_29654 spmi_controller_alloc 2 29654 &sctp_make_abort_user_29654
117960 +_regulator_do_enable_29656 _regulator_do_enable 0 29656 NULL
117961 +e100_phy_init_29662 e100_phy_init 0 29662 NULL
117962 +sisusb_write_mem_bulk_29678 sisusb_write_mem_bulk 4 29678 NULL
117963 +jbd2_journal_restart_29692 jbd2_journal_restart 0 29692 NULL
117964 +lustre_posix_acl_xattr_2ext_29693 lustre_posix_acl_xattr_2ext 2 29693 NULL
117965 +posix_acl_from_xattr_29708 posix_acl_from_xattr 3 29708 NULL
117966 +probes_write_29711 probes_write 3 29711 NULL
117967 +read_cis_cache_29735 read_cis_cache 4 29735 NULL
117968 +xfs_new_eof_29737 xfs_new_eof 2 29737 NULL
117969 +std_nic_write_29752 std_nic_write 3 29752 NULL
117970 +input_fujitsu_setup_29761 input_fujitsu_setup 0 29761 NULL
117971 +asd_seq_download_seqs_29767 asd_seq_download_seqs 0 29767 NULL
117972 +tg3_irq_count_29786 tg3_irq_count 0 29786 NULL
117973 +dbAlloc_29794 dbAlloc 0 29794 NULL
117974 +register_reboot_notifier_29796 register_reboot_notifier 0 29796 NULL
117975 +tcp_sendpage_29829 tcp_sendpage 4 29829 NULL
117976 +__probe_kernel_write_29842 __probe_kernel_write 3 29842 NULL
117977 +ath10k_wmi_cmd_init_29843 ath10k_wmi_cmd_init 0 29843 NULL
117978 +fnic_alloc_vnic_resources_29845 fnic_alloc_vnic_resources 0 29845 NULL
117979 +__raw_notifier_call_chain_29847 __raw_notifier_call_chain 0 29847 NULL
117980 +kvm_read_hva_atomic_29848 kvm_read_hva_atomic 3 29848 NULL
117981 +count_partial_29850 count_partial 0 29850 NULL
117982 +xfs_rtfind_forw_29866 xfs_rtfind_forw 0 29866 NULL
117983 +ath9k_hw_init_macaddr_29869 ath9k_hw_init_macaddr 0 29869 NULL
117984 +write_file_bool_bmps_29870 write_file_bool_bmps 3 29870 NULL
117985 +ipv6_setsockopt_29871 ipv6_setsockopt 5 29871 NULL
117986 +fnic_dev_notify_set_29874 fnic_dev_notify_set 0 29874 NULL
117987 +scsi_end_request_29876 scsi_end_request 3 29876 NULL
117988 +crypto_aead_alignmask_29885 crypto_aead_alignmask 0 29885 NULL
117989 +tc3589x_gpio_irq_get_irq_29889 tc3589x_gpio_irq_get_irq 2 29889 NULL
117990 +xfs_alloc_read_agf_29893 xfs_alloc_read_agf 0 29893 NULL
117991 +rtw_cfg80211_indicate_sta_assoc_29897 rtw_cfg80211_indicate_sta_assoc 3 29897 NULL
117992 +lov_ost_pool_extend_29914 lov_ost_pool_extend 2 29914 NULL
117993 +__mcam_cam_reset_29916 __mcam_cam_reset 0 29916 NULL
117994 +write_file_queue_29922 write_file_queue 3 29922 NULL
117995 +ahash_prepare_alg_29938 ahash_prepare_alg 0 29938 NULL
117996 +__btrfs_getxattr_29947 __btrfs_getxattr 0 29947 NULL nohasharray
117997 +ipv6_recv_error_29947 ipv6_recv_error 3 29947 &__btrfs_getxattr_29947
117998 +ath10k_core_fetch_firmware_api_1_29956 ath10k_core_fetch_firmware_api_1 0 29956 NULL
117999 +arch_setup_dmar_msi_29992 arch_setup_dmar_msi 0 29992 NULL
118000 +dev_mem_write_30028 dev_mem_write 3 30028 NULL
118001 +alloc_netdev_mqs_30030 alloc_netdev_mqs 1 30030 NULL
118002 +sysfs_add_file_mode_ns_30038 sysfs_add_file_mode_ns 0 30038 NULL
118003 +scsi_vpd_inquiry_30040 scsi_vpd_inquiry 0-4 30040 NULL
118004 +drp_wmove_30043 drp_wmove 4 30043 NULL
118005 +__pci_request_selected_regions_30058 __pci_request_selected_regions 0 30058 NULL
118006 +SyS_write_30059 SyS_write 3 30059 NULL
118007 +mthca_reset_30070 mthca_reset 0 30070 NULL
118008 +cxgbi_ddp_reserve_30091 cxgbi_ddp_reserve 4 30091 NULL
118009 +snd_midi_channel_init_set_30092 snd_midi_channel_init_set 1 30092 NULL
118010 +rx_filter_data_filter_read_30098 rx_filter_data_filter_read 3 30098 NULL
118011 +mlx5_cmd_exec_30102 mlx5_cmd_exec 0 30102 NULL
118012 +defragment_dma_buffer_30113 defragment_dma_buffer 0 30113 NULL
118013 +xfs_iget_cache_miss_30115 xfs_iget_cache_miss 0 30115 NULL
118014 +spi_async_locked_30117 spi_async_locked 0 30117 NULL
118015 +calgary_unmap_page_30130 calgary_unmap_page 2-3 30130 NULL
118016 +snd_pcm_stream_proc_init_30132 snd_pcm_stream_proc_init 0 30132 NULL
118017 +u_memcpya_30139 u_memcpya 3-2 30139 NULL
118018 +dbg_port_buf_30145 dbg_port_buf 2 30145 NULL
118019 +elfcorehdr_read_30159 elfcorehdr_read 2 30159 NULL
118020 +alloc_switch_ctx_30165 alloc_switch_ctx 2 30165 NULL
118021 +expand_inode_data_30169 expand_inode_data 2-3 30169 NULL
118022 +lis3lv02d_get_pwron_wait_30183 lis3lv02d_get_pwron_wait 0 30183 NULL
118023 +mempool_create_page_pool_30189 mempool_create_page_pool 1 30189 NULL
118024 +drm_property_create_bitmask_30195 drm_property_create_bitmask 5 30195 NULL
118025 +__genwqe_readq_30197 __genwqe_readq 0 30197 NULL
118026 +snd_pcm_playback_forward_30201 snd_pcm_playback_forward 0-2 30201 NULL
118027 +usblp_ioctl_30203 usblp_ioctl 2 30203 NULL
118028 +gfs2_stuffed_write_end_30204 gfs2_stuffed_write_end 0-5 30204 NULL
118029 +read_4k_modal_eeprom_30212 read_4k_modal_eeprom 3 30212 NULL
118030 +SyS_semop_30227 SyS_semop 3 30227 NULL
118031 +bitmap_file_set_bit_30228 bitmap_file_set_bit 2 30228 NULL
118032 +em28xx_write_reg_30239 em28xx_write_reg 0 30239 NULL
118033 +shmem_unuse_inode_30263 shmem_unuse_inode 0 30263 NULL
118034 +rawv6_recvmsg_30265 rawv6_recvmsg 4 30265 NULL
118035 +try_break_deleg_30271 try_break_deleg 0 30271 NULL nohasharray
118036 +isr_pci_pm_read_30271 isr_pci_pm_read 3 30271 &try_break_deleg_30271
118037 +compat_readv_30273 compat_readv 3 30273 NULL
118038 +dma_set_max_seg_size_30274 dma_set_max_seg_size 0 30274 NULL
118039 +skcipher_sendmsg_30290 skcipher_sendmsg 4 30290 NULL nohasharray
118040 +migrate_page_30290 migrate_page 0 30290 &skcipher_sendmsg_30290
118041 +pipeline_sec_frag_swi_read_30294 pipeline_sec_frag_swi_read 3 30294 NULL
118042 +tcp_sendmsg_30296 tcp_sendmsg 4 30296 NULL
118043 +osc_contention_seconds_seq_write_30305 osc_contention_seconds_seq_write 3 30305 NULL
118044 +ext4_acl_from_disk_30320 ext4_acl_from_disk 2 30320 NULL
118045 +i8254_read_30330 i8254_read 0 30330 NULL
118046 +resource_from_user_30341 resource_from_user 3 30341 NULL
118047 +o2nm_this_node_30342 o2nm_this_node 0 30342 NULL
118048 +ath5k_eeprom_init_30354 ath5k_eeprom_init 0 30354 NULL
118049 +gfs2_trans_begin_30359 gfs2_trans_begin 0 30359 NULL
118050 +kstrtou32_from_user_30361 kstrtou32_from_user 2 30361 NULL
118051 +pagecache_write_begin_30364 pagecache_write_begin 0 30364 NULL
118052 +pvscsi_change_queue_depth_30365 pvscsi_change_queue_depth 2 30365 NULL
118053 +C_SYSC_readv_30369 C_SYSC_readv 3 30369 NULL
118054 +device_init_wakeup_30387 device_init_wakeup 0 30387 NULL
118055 +blkdev_issue_zeroout_30392 blkdev_issue_zeroout 3 30392 NULL
118056 +c4iw_init_resource_30393 c4iw_init_resource 2-3 30393 NULL
118057 +get_kernel_pages_30397 get_kernel_pages 0 30397 NULL
118058 +vb2_fop_write_30420 vb2_fop_write 3 30420 NULL
118059 +mlx4_init_eq_table_30423 mlx4_init_eq_table 0 30423 NULL
118060 +tx_tx_template_prepared_read_30424 tx_tx_template_prepared_read 3 30424 NULL nohasharray
118061 +call_netdevice_notifier_30424 call_netdevice_notifier 0 30424 &tx_tx_template_prepared_read_30424
118062 +lstcon_session_info_30425 lstcon_session_info 6 30425 NULL
118063 +qt2160_write_30427 qt2160_write 0 30427 NULL
118064 +bma180_reset_intr_30432 bma180_reset_intr 0 30432 NULL
118065 +enable_write_30456 enable_write 3 30456 NULL
118066 +tx_tx_template_programmed_read_30461 tx_tx_template_programmed_read 3 30461 NULL
118067 +urandom_read_30462 urandom_read 3 30462 NULL
118068 +zoran_ioctl_30465 zoran_ioctl 2 30465 NULL
118069 +i2c_ctrl_read_30467 i2c_ctrl_read 0 30467 NULL
118070 +adu_write_30487 adu_write 3 30487 NULL
118071 +dtim_interval_write_30489 dtim_interval_write 3 30489 NULL
118072 +batadv_send_tt_request_30493 batadv_send_tt_request 5 30493 NULL
118073 +__send_duplicate_bios_30498 __send_duplicate_bios 4 30498 NULL
118074 +memblock_virt_alloc_node_30515 memblock_virt_alloc_node 1 30515 NULL
118075 +dwc3_testmode_write_30516 dwc3_testmode_write 3 30516 NULL
118076 +set_config_30526 set_config 0 30526 NULL nohasharray
118077 +debug_debug2_read_30526 debug_debug2_read 3 30526 &set_config_30526
118078 +mite_setup2_30530 mite_setup2 0 30530 NULL
118079 +si470x_start_usb_30536 si470x_start_usb 0 30536 NULL
118080 +asd_start_seqs_30544 asd_start_seqs 0 30544 NULL
118081 +ql_sem_spinlock_30547 ql_sem_spinlock 0 30547 NULL
118082 +xfs_sb_version_hasftype_30559 xfs_sb_version_hasftype 0 30559 NULL nohasharray
118083 +ixgbevf_acquire_msix_vectors_30559 ixgbevf_acquire_msix_vectors 2 30559 &xfs_sb_version_hasftype_30559
118084 +disk_expand_part_tbl_30561 disk_expand_part_tbl 2 30561 NULL
118085 +tg3_get_invariants_30577 tg3_get_invariants 0 30577 NULL
118086 +set_le_30581 set_le 4 30581 NULL
118087 +ntb_bwd_setup_30590 ntb_bwd_setup 0 30590 NULL
118088 +blk_init_tags_30592 blk_init_tags 1 30592 NULL
118089 +stmmac_hw_setup_30605 stmmac_hw_setup 0 30605 NULL
118090 +sgl_map_user_pages_30610 sgl_map_user_pages 2 30610 NULL nohasharray
118091 +cpufreq_get_global_kobject_30610 cpufreq_get_global_kobject 0 30610 &sgl_map_user_pages_30610
118092 +SyS_msgrcv_30611 SyS_msgrcv 3 30611 NULL
118093 +spu_write_30618 spu_write 0 30618 NULL
118094 +macvtap_sendmsg_30629 macvtap_sendmsg 4 30629 NULL
118095 +ieee80211_if_read_dot11MeshAwakeWindowDuration_30631 ieee80211_if_read_dot11MeshAwakeWindowDuration 3 30631 NULL
118096 +compat_raw_setsockopt_30634 compat_raw_setsockopt 5 30634 NULL
118097 +mlx5_ib_alloc_fast_reg_page_list_30638 mlx5_ib_alloc_fast_reg_page_list 2 30638 NULL
118098 +SyS_listxattr_30647 SyS_listxattr 3 30647 NULL
118099 +jffs2_flash_read_30667 jffs2_flash_read 0 30667 NULL
118100 +ni_ai_fifo_read_30681 ni_ai_fifo_read 3 30681 NULL
118101 +sst_hsw_get_dsp_position_30691 sst_hsw_get_dsp_position 0 30691 NULL
118102 +dccp_setsockopt_ccid_30701 dccp_setsockopt_ccid 4 30701 NULL nohasharray
118103 +xfs_bmap_add_extent_unwritten_real_30701 xfs_bmap_add_extent_unwritten_real 0 30701 &dccp_setsockopt_ccid_30701
118104 +lbs_wrbbp_write_30712 lbs_wrbbp_write 3 30712 NULL
118105 +ocfs2_find_cpos_for_left_leaf_30713 ocfs2_find_cpos_for_left_leaf 0 30713 NULL
118106 +lbs_debugfs_read_30721 lbs_debugfs_read 3 30721 NULL
118107 +snd_nm256_playback_silence_30727 snd_nm256_playback_silence 3-4 30727 NULL
118108 +pci_read_config_word_30732 pci_read_config_word 0 30732 NULL
118109 +snapshot_status_30744 snapshot_status 5 30744 NULL
118110 +fuse_conn_limit_write_30777 fuse_conn_limit_write 3 30777 NULL
118111 +SyS_pread64_30778 SyS_pread64 3 30778 NULL
118112 +__bio_alloc_30787 __bio_alloc 3 30787 NULL nohasharray
118113 +class_for_each_device_30787 class_for_each_device 0 30787 &__bio_alloc_30787
118114 +t4_sge_init_hard_30806 t4_sge_init_hard 0 30806 NULL
118115 +smk_read_doi_30813 smk_read_doi 3 30813 NULL
118116 +tg3_do_test_dma_30815 tg3_do_test_dma 0 30815 NULL
118117 +SYSC_splice_30820 SYSC_splice 5 30820 NULL
118118 +xlog_grant_head_wait_30829 xlog_grant_head_wait 0 30829 NULL
118119 +get_kobj_path_length_30831 get_kobj_path_length 0 30831 NULL
118120 +mlx4_load_fw_30833 mlx4_load_fw 0 30833 NULL
118121 +ath10k_write_fw_dbglog_30835 ath10k_write_fw_dbglog 3 30835 NULL
118122 +of_gpio_named_count_30841 of_gpio_named_count 0 30841 NULL
118123 +sctp_setsockopt_auth_chunk_30843 sctp_setsockopt_auth_chunk 3 30843 NULL
118124 +wd_autoreset_write_30862 wd_autoreset_write 3 30862 NULL
118125 +gpio_request_one_30881 gpio_request_one 0 30881 NULL
118126 +ieee80211_if_fmt_dropped_frames_no_route_30884 ieee80211_if_fmt_dropped_frames_no_route 3 30884 NULL
118127 +pn_recvmsg_30887 pn_recvmsg 4 30887 NULL nohasharray
118128 +__ei_open_30887 __ei_open 0 30887 &pn_recvmsg_30887
118129 +lpfc_sli4_alloc_resource_identifiers_30925 lpfc_sli4_alloc_resource_identifiers 0 30925 NULL
118130 +usnic_debugfs_buildinfo_read_30928 usnic_debugfs_buildinfo_read 3 30928 NULL
118131 +sctp_setsockopt_rtoinfo_30941 sctp_setsockopt_rtoinfo 3 30941 NULL
118132 +tty_insert_flip_string_flags_30969 tty_insert_flip_string_flags 4 30969 NULL
118133 +call_netdevice_notifiers_info_30980 call_netdevice_notifiers_info 0 30980 NULL
118134 +huge_page_mask_30981 huge_page_mask 0 30981 NULL
118135 +read_file_bt_ant_diversity_30983 read_file_bt_ant_diversity 3 30983 NULL nohasharray
118136 +add_probe_files_30983 add_probe_files 0 30983 &read_file_bt_ant_diversity_30983
118137 +lbs_host_sleep_read_31013 lbs_host_sleep_read 3 31013 NULL
118138 +ima_eventsig_init_31022 ima_eventsig_init 5 31022 NULL
118139 +template_fmt_size_31033 template_fmt_size 0 31033 NULL
118140 +do_setup_msi_irqs_31043 do_setup_msi_irqs 2 31043 NULL
118141 +stride_pg_count_31053 stride_pg_count 0-2-1-4-3-5 31053 NULL
118142 +lbs_failcount_read_31063 lbs_failcount_read 3 31063 NULL
118143 +sctp_setsockopt_context_31091 sctp_setsockopt_context 3 31091 NULL
118144 +proc_gid_map_write_31093 proc_gid_map_write 3 31093 NULL
118145 +depth_read_31112 depth_read 3 31112 NULL
118146 +hash_ipportnet6_expire_31118 hash_ipportnet6_expire 4 31118 NULL
118147 +tse_init_rx_buffer_31129 tse_init_rx_buffer 0 31129 NULL
118148 +kimage_normal_alloc_31140 kimage_normal_alloc 3 31140 NULL
118149 +size_inside_page_31141 size_inside_page 0 31141 NULL
118150 +w9966_v4l_read_31148 w9966_v4l_read 3 31148 NULL nohasharray
118151 +hpsa_kdump_soft_reset_31148 hpsa_kdump_soft_reset 0 31148 &w9966_v4l_read_31148
118152 +ch_do_scsi_31171 ch_do_scsi 4 31171 NULL
118153 +_regulator_do_disable_31175 _regulator_do_disable 0 31175 NULL
118154 +__gpiod_request_31195 __gpiod_request 0 31195 NULL
118155 +r592_read_fifo_pio_31198 r592_read_fifo_pio 3 31198 NULL
118156 +mtdchar_readoob_31200 mtdchar_readoob 4 31200 NULL
118157 +sh_eth_phy_init_31201 sh_eth_phy_init 0 31201 NULL
118158 +__btrfs_free_reserved_extent_31207 __btrfs_free_reserved_extent 2 31207 NULL
118159 +cpumask_weight_31215 cpumask_weight 0 31215 NULL
118160 +__read_reg_31216 __read_reg 0 31216 NULL
118161 +atm_get_addr_31221 atm_get_addr 3 31221 NULL
118162 +tcp_recvmsg_31238 tcp_recvmsg 4 31238 NULL
118163 +cyy_readb_31240 cyy_readb 0 31240 NULL
118164 +_create_sg_bios_31244 _create_sg_bios 4 31244 NULL
118165 +ieee80211_if_read_last_beacon_31257 ieee80211_if_read_last_beacon 3 31257 NULL
118166 +pch_spi_get_resources_31275 pch_spi_get_resources 0 31275 NULL
118167 +hash_netportnet4_expire_31290 hash_netportnet4_expire 4 31290 NULL
118168 +uvc_simplify_fraction_31303 uvc_simplify_fraction 3 31303 NULL
118169 +sisusbcon_scroll_31315 sisusbcon_scroll 5-2-3 31315 NULL
118170 +command_file_write_31318 command_file_write 3 31318 NULL
118171 +hwerr_crcbits_31334 hwerr_crcbits 4 31334 NULL
118172 +_regmap_raw_multi_reg_write_31336 _regmap_raw_multi_reg_write 3 31336 NULL nohasharray
118173 +radix_tree_insert_31336 radix_tree_insert 0 31336 &_regmap_raw_multi_reg_write_31336
118174 +em28xx_init_usb_xfer_31337 em28xx_init_usb_xfer 4-6 31337 NULL
118175 +platform_device_add_31340 platform_device_add 0 31340 NULL
118176 +outlen_write_31358 outlen_write 3 31358 NULL
118177 +ieee80211_rx_mgmt_auth_31366 ieee80211_rx_mgmt_auth 3 31366 NULL
118178 +mlx4_MAP_FA_31371 mlx4_MAP_FA 0 31371 NULL
118179 +xprt_rdma_allocate_31372 xprt_rdma_allocate 2 31372 NULL
118180 +vb2_vmalloc_get_userptr_31374 vb2_vmalloc_get_userptr 3-2 31374 NULL
118181 +trace_parser_get_init_31379 trace_parser_get_init 2 31379 NULL
118182 +inb_31388 inb 0 31388 NULL
118183 +ni_660x_allocate_private_31400 ni_660x_allocate_private 0 31400 NULL
118184 +key_ifindex_read_31411 key_ifindex_read 3 31411 NULL
118185 +_sp2d_max_pg_31422 _sp2d_max_pg 0 31422 NULL
118186 +TSS_checkhmac1_31429 TSS_checkhmac1 5 31429 NULL
118187 +snd_aw2_saa7146_get_hw_ptr_capture_31431 snd_aw2_saa7146_get_hw_ptr_capture 0 31431 NULL
118188 +sep_crypto_setup_31439 sep_crypto_setup 0 31439 NULL
118189 +transport_alloc_session_tags_31449 transport_alloc_session_tags 2-3 31449 NULL
118190 +opera1_xilinx_rw_31453 opera1_xilinx_rw 5 31453 NULL
118191 +_regmap_update_bits_31456 _regmap_update_bits 0 31456 NULL
118192 +xfs_btree_get_numrecs_31477 xfs_btree_get_numrecs 0 31477 NULL
118193 +alg_setkey_31485 alg_setkey 3 31485 NULL
118194 +rds_message_map_pages_31487 rds_message_map_pages 2 31487 NULL
118195 +cpuid_device_create_31489 cpuid_device_create 0 31489 NULL
118196 +qsfp_2_read_31491 qsfp_2_read 3 31491 NULL
118197 +__alloc_bootmem_31498 __alloc_bootmem 1 31498 NULL
118198 +hidraw_write_31536 hidraw_write 3 31536 NULL
118199 +snd_ac97_bus_31550 snd_ac97_bus 0 31550 NULL
118200 +usbvision_read_31555 usbvision_read 3 31555 NULL
118201 +snd_mpu401_uart_new_31565 snd_mpu401_uart_new 0 31565 NULL
118202 +tx_frag_tkip_called_read_31575 tx_frag_tkip_called_read 3 31575 NULL
118203 +get_max_inline_xattr_value_size_31578 get_max_inline_xattr_value_size 0 31578 NULL
118204 +osst_write_31581 osst_write 3 31581 NULL
118205 +snd_compr_get_avail_31584 snd_compr_get_avail 0 31584 NULL
118206 +kobject_set_name_31585 kobject_set_name 0 31585 NULL
118207 +flash_wait_op_31594 flash_wait_op 0 31594 NULL
118208 +usb_add_phy_31609 usb_add_phy 0 31609 NULL
118209 +iwl_dbgfs_ucode_tx_stats_read_31611 iwl_dbgfs_ucode_tx_stats_read 3 31611 NULL
118210 +arvo_sysfs_read_31617 arvo_sysfs_read 6 31617 NULL nohasharray
118211 +memblock_virt_alloc_nopanic_31617 memblock_virt_alloc_nopanic 1 31617 &arvo_sysfs_read_31617
118212 +usnic_ib_dump_vf_31623 usnic_ib_dump_vf 3 31623 NULL
118213 +videobuf_read_one_31637 videobuf_read_one 3 31637 NULL
118214 +t4vf_sge_init_31642 t4vf_sge_init 0 31642 NULL
118215 +pod_alloc_sysex_buffer_31651 pod_alloc_sysex_buffer 3 31651 NULL
118216 +device_wakeup_attach_31653 device_wakeup_attach 0 31653 NULL
118217 +xfer_secondary_pool_31661 xfer_secondary_pool 2 31661 NULL
118218 +__lgread_31668 __lgread 4 31668 NULL
118219 +copy_from_user_nmi_31672 copy_from_user_nmi 3-0 31672 NULL
118220 +forced_ps_read_31685 forced_ps_read 3 31685 NULL
118221 +fst_recover_rx_error_31687 fst_recover_rx_error 3 31687 NULL
118222 +sht15_transmission_start_31696 sht15_transmission_start 0 31696 NULL
118223 +gfs2_dir_check_31711 gfs2_dir_check 0 31711 NULL
118224 +rs_pretty_print_rate_31727 rs_pretty_print_rate 0 31727 NULL
118225 +ata_tport_add_31733 ata_tport_add 0 31733 NULL
118226 +utf16s_to_utf8s_31735 utf16s_to_utf8s 0 31735 NULL nohasharray
118227 +lu_buf_check_and_grow_31735 lu_buf_check_and_grow 2 31735 &utf16s_to_utf8s_31735
118228 +shmem_pwrite_slow_31741 shmem_pwrite_slow 3-2 31741 NULL
118229 +input_abs_get_max_31742 input_abs_get_max 0 31742 NULL nohasharray
118230 +NCR_700_change_queue_depth_31742 NCR_700_change_queue_depth 2 31742 &input_abs_get_max_31742
118231 +bcm_char_read_31750 bcm_char_read 3 31750 NULL
118232 +snd_seq_device_new_31753 snd_seq_device_new 4 31753 NULL
118233 +SyS_lsetxattr_31766 SyS_lsetxattr 4 31766 NULL
118234 +crypto_register_alg_31775 crypto_register_alg 0 31775 NULL
118235 +osync_buffers_list_31789 osync_buffers_list 0 31789 NULL
118236 +usblp_cache_device_id_string_31790 usblp_cache_device_id_string 0 31790 NULL
118237 +ecryptfs_send_message_locked_31801 ecryptfs_send_message_locked 2 31801 NULL
118238 +isr_rx_procs_read_31804 isr_rx_procs_read 3 31804 NULL
118239 +data_write_31805 data_write 3 31805 NULL
118240 +SyS_msgsnd_31814 SyS_msgsnd 3 31814 NULL
118241 +strnlen_user_31815 strnlen_user 0-2 31815 NULL
118242 +sta_last_signal_read_31818 sta_last_signal_read 3 31818 NULL
118243 +ssb_gige_get_phyaddr_31833 ssb_gige_get_phyaddr 0 31833 NULL
118244 +fsnotify_perm_31843 fsnotify_perm 0 31843 NULL
118245 +clone_bio_31854 clone_bio 4-3 31854 NULL nohasharray
118246 +velocity_init_rd_ring_31854 velocity_init_rd_ring 0 31854 &clone_bio_31854
118247 +SyS_ppoll_31855 SyS_ppoll 2 31855 NULL
118248 +foreach_descriptor_31873 foreach_descriptor 0 31873 NULL
118249 +iwl_dbgfs_disable_ht40_write_31876 iwl_dbgfs_disable_ht40_write 3 31876 NULL
118250 +drm_mode_crtc_set_gamma_size_31881 drm_mode_crtc_set_gamma_size 2 31881 NULL
118251 +ddb_output_write_31902 ddb_output_write 3-0 31902 NULL
118252 +xattr_permission_31907 xattr_permission 0 31907 NULL
118253 +lu_buf_realloc_31915 lu_buf_realloc 2 31915 NULL
118254 +new_dir_31919 new_dir 3 31919 NULL
118255 +kmem_alloc_31920 kmem_alloc 1 31920 NULL
118256 +era_status_31934 era_status 5 31934 NULL
118257 +SYSC_sethostname_31940 SYSC_sethostname 2 31940 NULL nohasharray
118258 +si4713_send_startup_command_31940 si4713_send_startup_command 0 31940 &SYSC_sethostname_31940
118259 +read_mem_31942 read_mem 3 31942 NULL nohasharray
118260 +iov_iter_copy_from_user_31942 iov_iter_copy_from_user 4-0 31942 &read_mem_31942
118261 +ext4_zero_range_31944 ext4_zero_range 3-2 31944 NULL
118262 +blocking_notifier_call_chain_31947 blocking_notifier_call_chain 0 31947 NULL
118263 +vb2_write_31948 vb2_write 3 31948 NULL
118264 +pvr2_ctrl_get_valname_31951 pvr2_ctrl_get_valname 4 31951 NULL
118265 +adm8211_init_rings_31955 adm8211_init_rings 0 31955 NULL
118266 +pch_gbe_sw_init_31962 pch_gbe_sw_init 0 31962 NULL
118267 +regcache_rbtree_sync_31964 regcache_rbtree_sync 2 31964 NULL
118268 +iwl_rx_packet_payload_len_31965 iwl_rx_packet_payload_len 0 31965 NULL
118269 +copy_from_user_toio_31966 copy_from_user_toio 3 31966 NULL
118270 +iblock_execute_rw_31982 iblock_execute_rw 3 31982 NULL nohasharray
118271 +vx_read_status_31982 vx_read_status 0 31982 &iblock_execute_rw_31982
118272 +find_next_zero_bit_31990 find_next_zero_bit 0 31990 NULL
118273 +lustre_acl_xattr_merge2posix_31992 lustre_acl_xattr_merge2posix 2 31992 NULL
118274 +sysfs_create_file_31996 sysfs_create_file 0 31996 NULL
118275 +calc_hmac_32010 calc_hmac 3 32010 NULL
118276 +si476x_radio_add_new_custom_32015 si476x_radio_add_new_custom 0 32015 NULL
118277 +aead_len_32021 aead_len 0 32021 NULL nohasharray
118278 +aer_init_32021 aer_init 0 32021 &aead_len_32021
118279 +ocfs2_remove_extent_32032 ocfs2_remove_extent 0 32032 NULL
118280 +stk_read_32038 stk_read 3 32038 NULL
118281 +ocfs2_update_edge_lengths_32046 ocfs2_update_edge_lengths 0 32046 NULL
118282 +SYSC_llistxattr_32061 SYSC_llistxattr 3 32061 NULL
118283 +proc_scsi_devinfo_write_32064 proc_scsi_devinfo_write 3 32064 NULL
118284 +xfs_buf_iowait_32068 xfs_buf_iowait 0 32068 NULL
118285 +cow_file_range_inline_32091 cow_file_range_inline 3 32091 NULL
118286 +bio_alloc_32095 bio_alloc 2 32095 NULL
118287 +alloc_pwms_32100 alloc_pwms 2 32100 NULL
118288 +ath6kl_fwlog_read_32101 ath6kl_fwlog_read 3 32101 NULL
118289 +disk_status_32120 disk_status 4 32120 NULL
118290 +devm_iio_device_register_32122 devm_iio_device_register 0 32122 NULL
118291 +kobject_add_internal_32133 kobject_add_internal 0 32133 NULL
118292 +rfkill_register_32137 rfkill_register 0 32137 NULL
118293 +i2c_smbus_write_byte_data_32162 i2c_smbus_write_byte_data 0 32162 NULL
118294 +venus_link_32165 venus_link 5 32165 NULL
118295 +do_writepages_32173 do_writepages 0 32173 NULL
118296 +del_ptr_32197 del_ptr 4 32197 NULL
118297 +wusb_ccm_mac_32199 wusb_ccm_mac 7 32199 NULL
118298 +__mem_cgroup_try_charge_swapin_32204 __mem_cgroup_try_charge_swapin 0 32204 NULL
118299 +asd_map_ha_32214 asd_map_ha 0 32214 NULL
118300 +riva_get_cmap_len_32218 riva_get_cmap_len 0 32218 NULL
118301 +caif_seqpkt_recvmsg_32241 caif_seqpkt_recvmsg 4 32241 NULL
118302 +lbs_lowrssi_read_32242 lbs_lowrssi_read 3 32242 NULL
118303 +ocfs2_xattr_find_entry_32260 ocfs2_xattr_find_entry 0 32260 NULL
118304 +si476x_cmd_tune_seek_freq_32310 si476x_cmd_tune_seek_freq 4-6 32310 NULL
118305 +kvm_set_spte_hva_32312 kvm_set_spte_hva 2 32312 NULL
118306 +cas_calc_tabort_32316 cas_calc_tabort 0 32316 NULL
118307 +SyS_select_32319 SyS_select 1 32319 NULL
118308 +nouveau_bar_create__32332 nouveau_bar_create_ 4 32332 NULL
118309 +nl80211_send_mlme_event_32337 nl80211_send_mlme_event 4 32337 NULL
118310 +xfs_bmap_extsize_align_32338 xfs_bmap_extsize_align 0 32338 NULL
118311 +t4_alloc_mem_32342 t4_alloc_mem 1 32342 NULL
118312 +gspca_input_connect_32353 gspca_input_connect 0 32353 NULL
118313 +dispatch_ioctl_32357 dispatch_ioctl 2 32357 NULL nohasharray
118314 +rx_streaming_always_write_32357 rx_streaming_always_write 3 32357 &dispatch_ioctl_32357
118315 +sel_read_initcon_32362 sel_read_initcon 3 32362 NULL nohasharray
118316 +ReadHDLCPCI_32362 ReadHDLCPCI 0 32362 &sel_read_initcon_32362
118317 +ocfs2_cancel_convert_32392 ocfs2_cancel_convert 0 32392 NULL
118318 +ll_setxattr_common_32398 ll_setxattr_common 4 32398 NULL
118319 +xfs_iext_add_indirect_multi_32400 xfs_iext_add_indirect_multi 3 32400 NULL
118320 +vnic_dev_set_ig_vlan_rewrite_mode_32402 vnic_dev_set_ig_vlan_rewrite_mode 0 32402 NULL
118321 +vmci_qp_alloc_32405 vmci_qp_alloc 5-3 32405 NULL
118322 +tsi721_request_irq_32419 tsi721_request_irq 0 32419 NULL
118323 +xfs_alloc_put_freelist_32437 xfs_alloc_put_freelist 0 32437 NULL
118324 +snd_pcm_sync_ptr_32461 snd_pcm_sync_ptr 0 32461 NULL
118325 +cache_status_32462 cache_status 5 32462 NULL
118326 +fill_readbuf_32464 fill_readbuf 3 32464 NULL
118327 +ide_driver_proc_write_32493 ide_driver_proc_write 3 32493 NULL
118328 +bypass_pwoff_write_32499 bypass_pwoff_write 3 32499 NULL
118329 +mdc_pinger_recov_seq_write_32510 mdc_pinger_recov_seq_write 3 32510 NULL
118330 +ctrl_std_val_to_sym_32516 ctrl_std_val_to_sym 5 32516 NULL
118331 +disconnect_32521 disconnect 4 32521 NULL
118332 +qsfp_read_32522 qsfp_read 0-2-4 32522 NULL
118333 +ocfs2_refresh_qinfo_32524 ocfs2_refresh_qinfo 0 32524 NULL
118334 +ilo_read_32531 ilo_read 3 32531 NULL
118335 +ieee80211_if_read_estab_plinks_32533 ieee80211_if_read_estab_plinks 3 32533 NULL
118336 +suni_init_32539 suni_init 0 32539 NULL
118337 +format_devstat_counter_32550 format_devstat_counter 3 32550 NULL
118338 +alloc_dma_desc_resources_32561 alloc_dma_desc_resources 0 32561 NULL
118339 +aes_encrypt_fail_read_32562 aes_encrypt_fail_read 3 32562 NULL
118340 +osc_iocontrol_32565 osc_iocontrol 3 32565 NULL
118341 +mem_swapout_entry_32586 mem_swapout_entry 3 32586 NULL
118342 +pipeline_tcp_tx_stat_fifo_int_read_32589 pipeline_tcp_tx_stat_fifo_int_read 3 32589 NULL
118343 +read_file_beacon_32595 read_file_beacon 3 32595 NULL
118344 +ieee80211_if_read_dropped_frames_congestion_32603 ieee80211_if_read_dropped_frames_congestion 3 32603 NULL
118345 +xfs_bmap_last_offset_32614 xfs_bmap_last_offset 0 32614 NULL
118346 +__pci_request_region_32618 __pci_request_region 0 32618 NULL
118347 +pci_request_selected_regions_exclusive_32622 pci_request_selected_regions_exclusive 0 32622 NULL
118348 +irda_recvmsg_dgram_32631 irda_recvmsg_dgram 4 32631 NULL
118349 +cfg80211_roamed_32632 cfg80211_roamed 5-7 32632 NULL
118350 +kvmalloc_32646 kvmalloc 1 32646 NULL
118351 +ib_sg_dma_len_32649 ib_sg_dma_len 0 32649 NULL
118352 +generic_readlink_32654 generic_readlink 3 32654 NULL
118353 +get_unaligned_be24_32667 get_unaligned_be24 0 32667 NULL
118354 +move_addr_to_kernel_32673 move_addr_to_kernel 2 32673 NULL
118355 +apei_res_add_32674 apei_res_add 0 32674 NULL nohasharray
118356 +cpuup_prepare_32674 cpuup_prepare 0 32674 &apei_res_add_32674
118357 +compat_SyS_preadv_32679 compat_SyS_preadv 3 32679 NULL
118358 +jfs_readpages_32702 jfs_readpages 4 32702 NULL
118359 +xfs_filestream_new_ag_32711 xfs_filestream_new_ag 0 32711 NULL
118360 +rt2x00debug_read_queue_dump_32712 rt2x00debug_read_queue_dump 3 32712 NULL
118361 +xfs_bmbt_update_32713 xfs_bmbt_update 0 32713 NULL
118362 +find_next_descriptor_32726 find_next_descriptor 0 32726 NULL
118363 +megasas_change_queue_depth_32747 megasas_change_queue_depth 2 32747 NULL
118364 +stats_read_ul_32751 stats_read_ul 3 32751 NULL
118365 +vmci_transport_dgram_dequeue_32775 vmci_transport_dgram_dequeue 4 32775 NULL
118366 +sctp_tsnmap_grow_32784 sctp_tsnmap_grow 2 32784 NULL
118367 +ocfs2_read_inode_block_full_32790 ocfs2_read_inode_block_full 0 32790 NULL
118368 +xfs_trans_read_buf_32795 xfs_trans_read_buf 0 32795 NULL
118369 +rproc_name_read_32805 rproc_name_read 3 32805 NULL
118370 +get_register_page_interruptible_32809 get_register_page_interruptible 5 32809 NULL
118371 +qt2160_register_leds_32849 qt2160_register_leds 0 32849 NULL
118372 +mtip_exec_internal_command_32859 mtip_exec_internal_command 0 32859 NULL
118373 +sta_tx_latency_stat_read_32862 sta_tx_latency_stat_read 3 32862 NULL
118374 +new_tape_buffer_32866 new_tape_buffer 2 32866 NULL
118375 +cifs_writedata_alloc_32880 cifs_writedata_alloc 1 32880 NULL nohasharray
118376 +ath6kl_usb_submit_ctrl_in_32880 ath6kl_usb_submit_ctrl_in 6 32880 &cifs_writedata_alloc_32880
118377 +vp702x_usb_inout_cmd_32884 vp702x_usb_inout_cmd 6-4 32884 NULL
118378 +ath5k_hw_set_power_mode_32901 ath5k_hw_set_power_mode 0 32901 NULL
118379 +tipc_link_iovec_xmit_fast_32913 tipc_link_iovec_xmit_fast 3 32913 NULL nohasharray
118380 +il_dbgfs_tx_stats_read_32913 il_dbgfs_tx_stats_read 3 32913 &tipc_link_iovec_xmit_fast_32913
118381 +zlib_inflate_workspacesize_32927 zlib_inflate_workspacesize 0 32927 NULL
118382 +rmap_recycle_32938 rmap_recycle 3 32938 NULL
118383 +irq_reserve_irqs_32946 irq_reserve_irqs 2 32946 NULL
118384 +xfs_log_reserve_32959 xfs_log_reserve 0-2 32959 NULL
118385 +mwl8k_cmd_set_hw_spec_32968 mwl8k_cmd_set_hw_spec 0 32968 NULL
118386 +sh_eth_dev_init_32971 sh_eth_dev_init 0 32971 NULL
118387 +saa7706h_i2c_send_32979 saa7706h_i2c_send 3 32979 NULL
118388 +compat_filldir_32999 compat_filldir 3 32999 NULL
118389 +SyS_syslog_33007 SyS_syslog 3 33007 NULL
118390 +br_multicast_set_hash_max_33012 br_multicast_set_hash_max 2 33012 NULL
118391 +write_file_bt_ant_diversity_33019 write_file_bt_ant_diversity 3 33019 NULL
118392 +pci_set_dma_mask_33033 pci_set_dma_mask 0 33033 NULL
118393 +snd_pcm_prepare_33036 snd_pcm_prepare 0 33036 NULL
118394 +mic_virtio_copy_to_user_33048 mic_virtio_copy_to_user 3 33048 NULL
118395 +SYSC_lgetxattr_33049 SYSC_lgetxattr 4 33049 NULL
118396 +pipeline_dec_packet_in_fifo_full_read_33052 pipeline_dec_packet_in_fifo_full_read 3 33052 NULL
118397 +ebt_compat_match_offset_33053 ebt_compat_match_offset 0-2 33053 NULL
118398 +bitmap_resize_33054 bitmap_resize 2 33054 NULL
118399 +stats_dot11RTSSuccessCount_read_33065 stats_dot11RTSSuccessCount_read 3 33065 NULL
118400 +sel_read_checkreqprot_33068 sel_read_checkreqprot 3 33068 NULL
118401 +gfs2_write_end_33073 gfs2_write_end 5 33073 NULL
118402 +alloc_tio_33077 alloc_tio 3 33077 NULL
118403 +acl_permission_check_33083 acl_permission_check 0 33083 NULL
118404 +__pci_assign_resource_33107 __pci_assign_resource 0 33107 NULL
118405 +vnic_dev_cmd_no_proxy_33109 vnic_dev_cmd_no_proxy 0 33109 NULL
118406 +fb_sys_write_33130 fb_sys_write 3 33130 NULL
118407 +asd_seq_unpause_lseq_33131 asd_seq_unpause_lseq 0 33131 NULL
118408 +notify_change_33143 notify_change 0 33143 NULL
118409 +SyS_poll_33152 SyS_poll 2 33152 NULL
118410 +_pci_add_cap_save_buffer_33153 _pci_add_cap_save_buffer 4 33153 NULL
118411 +attach_capi_ctr_33155 attach_capi_ctr 0 33155 NULL
118412 +debug_debug6_read_33168 debug_debug6_read 3 33168 NULL
118413 +dataflash_read_fact_otp_33204 dataflash_read_fact_otp 3-2 33204 NULL
118414 +pp_read_33210 pp_read 3 33210 NULL nohasharray
118415 +ax_open_33210 ax_open 0 33210 &pp_read_33210 nohasharray
118416 +xen_allocate_irqs_dynamic_33210 xen_allocate_irqs_dynamic 1 33210 &ax_open_33210
118417 +bcm2048_set_fm_deemphasis_33227 bcm2048_set_fm_deemphasis 0 33227 NULL
118418 +ata_pci_init_one_33231 ata_pci_init_one 0 33231 NULL
118419 +xfs_file_aio_write_33234 xfs_file_aio_write 4 33234 NULL
118420 +asd_init_hw_33249 asd_init_hw 0 33249 NULL
118421 +snd_pcm_plug_client_size_33267 snd_pcm_plug_client_size 0-2 33267 NULL
118422 +cachefiles_cook_key_33274 cachefiles_cook_key 2 33274 NULL
118423 +sync_pt_create_33282 sync_pt_create 2 33282 NULL
118424 +mcs7830_get_reg_33308 mcs7830_get_reg 3 33308 NULL
118425 +isku_sysfs_read_keys_easyzone_33318 isku_sysfs_read_keys_easyzone 6 33318 NULL
118426 +pci_set_dma_max_seg_size_33319 pci_set_dma_max_seg_size 0 33319 NULL
118427 +vx_send_irq_dsp_33329 vx_send_irq_dsp 0 33329 NULL
118428 +joydev_ioctl_33343 joydev_ioctl 2 33343 NULL
118429 +vfio_basic_config_write_33350 vfio_basic_config_write 3 33350 NULL
118430 +lov_stripesize_seq_write_33353 lov_stripesize_seq_write 3 33353 NULL
118431 +create_xattr_datum_33356 create_xattr_datum 5 33356 NULL nohasharray
118432 +irq_pkt_threshold_read_33356 irq_pkt_threshold_read 3 33356 &create_xattr_datum_33356
118433 +pvscsi_allocate_sg_33357 pvscsi_allocate_sg 0 33357 NULL
118434 +read_file_regidx_33370 read_file_regidx 3 33370 NULL
118435 +ieee80211_if_read_dropped_frames_no_route_33383 ieee80211_if_read_dropped_frames_no_route 3 33383 NULL
118436 +scsi_varlen_cdb_length_33385 scsi_varlen_cdb_length 0 33385 NULL
118437 +nvc0_ram_create__33391 nvc0_ram_create_ 5 33391 NULL
118438 +rsxx_setup_dev_33393 rsxx_setup_dev 0 33393 NULL nohasharray
118439 +e100_exec_cb_33393 e100_exec_cb 0 33393 &rsxx_setup_dev_33393
118440 +ocfs2_allocate_unwritten_extents_33394 ocfs2_allocate_unwritten_extents 2-3 33394 NULL
118441 +cfs_trace_copyin_string_33396 cfs_trace_copyin_string 4 33396 NULL
118442 +snd_pcm_capture_ioctl1_33408 snd_pcm_capture_ioctl1 0 33408 NULL
118443 +filemap_fdatawrite_33415 filemap_fdatawrite 0 33415 NULL
118444 +hash_netiface6_expire_33421 hash_netiface6_expire 4 33421 NULL
118445 +uvc_get_video_ctrl_33425 uvc_get_video_ctrl 0 33425 NULL
118446 +dis_tap_write_33426 dis_tap_write 3 33426 NULL
118447 +fnic_dev_cmd_33433 fnic_dev_cmd 0 33433 NULL
118448 +message_stats_list_33440 message_stats_list 5 33440 NULL
118449 +ovs_vport_alloc_33475 ovs_vport_alloc 1 33475 NULL
118450 +create_entry_33479 create_entry 2 33479 NULL
118451 +ip_setsockopt_33487 ip_setsockopt 5 33487 NULL
118452 +res_counter_read_33499 res_counter_read 4 33499 NULL
118453 +hash_netnet4_expire_33500 hash_netnet4_expire 4 33500 NULL
118454 +fb_read_33506 fb_read 3 33506 NULL
118455 +musb_test_mode_write_33518 musb_test_mode_write 3 33518 NULL
118456 +ahash_setkey_unaligned_33521 ahash_setkey_unaligned 3 33521 NULL
118457 +nes_alloc_fast_reg_page_list_33523 nes_alloc_fast_reg_page_list 2 33523 NULL
118458 +aggr_size_rx_size_read_33526 aggr_size_rx_size_read 3 33526 NULL
118459 +tomoyo_read_self_33539 tomoyo_read_self 3 33539 NULL nohasharray
118460 +osc_max_rpcs_in_flight_seq_write_33539 osc_max_rpcs_in_flight_seq_write 3 33539 &tomoyo_read_self_33539
118461 +count_subheaders_33591 count_subheaders 0 33591 NULL
118462 +scsi_execute_33596 scsi_execute 5 33596 NULL
118463 +comedi_buf_write_n_allocated_33604 comedi_buf_write_n_allocated 0 33604 NULL
118464 +niu_get_invariants_33607 niu_get_invariants 0 33607 NULL
118465 +xt_compat_target_offset_33608 xt_compat_target_offset 0 33608 NULL
118466 +usb_gstrings_attach_33615 usb_gstrings_attach 3 33615 NULL nohasharray
118467 +il_dbgfs_qos_read_33615 il_dbgfs_qos_read 3 33615 &usb_gstrings_attach_33615
118468 +xfs_btree_check_sblock_33618 xfs_btree_check_sblock 0 33618 NULL
118469 +do_sync_write_33624 do_sync_write 0 33624 NULL
118470 +stride_page_count_33641 stride_page_count 2 33641 NULL
118471 +irq_blk_threshold_read_33666 irq_blk_threshold_read 3 33666 NULL
118472 +p54spi_request_firmware_33667 p54spi_request_firmware 0 33667 NULL
118473 +inw_p_33668 inw_p 0 33668 NULL
118474 +arp_hdr_len_33671 arp_hdr_len 0 33671 NULL
118475 +i2c_hid_alloc_buffers_33673 i2c_hid_alloc_buffers 2 33673 NULL
118476 +submit_one_bio_33683 submit_one_bio 0 33683 NULL
118477 +nv50_disp_dmac_create__33696 nv50_disp_dmac_create_ 6 33696 NULL
118478 +netlink_sendmsg_33708 netlink_sendmsg 4 33708 NULL
118479 +tipc_link_stats_33716 tipc_link_stats 3 33716 NULL
118480 +pvr2_stream_buffer_count_33719 pvr2_stream_buffer_count 2 33719 NULL
118481 +write_file_spectral_count_33723 write_file_spectral_count 3 33723 NULL
118482 +read_file_node_recv_33729 read_file_node_recv 3 33729 NULL
118483 +solo_i2c_init_33731 solo_i2c_init 0 33731 NULL
118484 +__mutex_lock_interruptible_slowpath_33735 __mutex_lock_interruptible_slowpath 0 33735 NULL
118485 +rtw_cbuf_alloc23a_33740 rtw_cbuf_alloc23a 1 33740 NULL
118486 +sh_vou_hw_init_33757 sh_vou_hw_init 0 33757 NULL
118487 +ath10k_download_and_run_otp_33758 ath10k_download_and_run_otp 0 33758 NULL
118488 +vifs_state_read_33762 vifs_state_read 3 33762 NULL
118489 +hashtab_create_33769 hashtab_create 3 33769 NULL
118490 +i8042_create_aux_port_33777 i8042_create_aux_port 0 33777 NULL
118491 +ql_set_mac_addr_33797 ql_set_mac_addr 0 33797 NULL
118492 +if_sdio_read_rx_len_33800 if_sdio_read_rx_len 0 33800 NULL
118493 +filter_write_33819 filter_write 3 33819 NULL
118494 +c2_rnic_query_33824 c2_rnic_query 0 33824 NULL
118495 +sep_create_msgarea_context_33829 sep_create_msgarea_context 4 33829 NULL
118496 +scrub_setup_recheck_block_33831 scrub_setup_recheck_block 5-4 33831 NULL
118497 +ext4_journal_extend_33835 ext4_journal_extend 2 33835 NULL
118498 +snd_pcm_action_nonatomic_33844 snd_pcm_action_nonatomic 0 33844 NULL
118499 +calgary_alloc_coherent_33851 calgary_alloc_coherent 2 33851 NULL
118500 +oz_cdev_write_33852 oz_cdev_write 3 33852 NULL
118501 +pci_bus_alloc_resource_33872 pci_bus_alloc_resource 0 33872 NULL
118502 +bin_string_33884 bin_string 3-5 33884 NULL
118503 +sis190_init_ring_33895 sis190_init_ring 0 33895 NULL
118504 +get_user_pages_33908 get_user_pages 0 33908 NULL
118505 +sg_nents_33909 sg_nents 0 33909 NULL
118506 +ath6kl_roam_mode_write_33912 ath6kl_roam_mode_write 3 33912 NULL
118507 +queue_logical_block_size_33918 queue_logical_block_size 0 33918 NULL
118508 +sel_read_avc_cache_threshold_33942 sel_read_avc_cache_threshold 3 33942 NULL
118509 +lpfc_idiag_ctlacc_read_33943 lpfc_idiag_ctlacc_read 3 33943 NULL
118510 +read_file_tgt_rx_stats_33944 read_file_tgt_rx_stats 3 33944 NULL
118511 +__proc_dump_kernel_33954 __proc_dump_kernel 5 33954 NULL
118512 +ocfs2_create_new_meta_bhs_33955 ocfs2_create_new_meta_bhs 0 33955 NULL
118513 +btrfs_delalloc_reserve_metadata_33963 btrfs_delalloc_reserve_metadata 0 33963 NULL
118514 +vga_switcheroo_debugfs_write_33984 vga_switcheroo_debugfs_write 3 33984 NULL
118515 +lbs_lowrssi_write_34025 lbs_lowrssi_write 3 34025 NULL
118516 +ppp_write_34034 ppp_write 3 34034 NULL nohasharray
118517 +ccp_find_mmio_area_34034 ccp_find_mmio_area 0 34034 &ppp_write_34034
118518 +tty_insert_flip_string_34042 tty_insert_flip_string 3-0 34042 NULL
118519 +__domain_flush_pages_34045 __domain_flush_pages 2-3 34045 NULL
118520 +calc_linear_pos_34067 calc_linear_pos 0-4 34067 NULL
118521 +memcg_update_all_caches_34068 memcg_update_all_caches 1 34068 NULL
118522 +xfs_dialloc_34078 xfs_dialloc 0 34078 NULL
118523 +dw_dma_probe_34094 dw_dma_probe 0 34094 NULL
118524 +pipeline_pipeline_fifo_full_read_34095 pipeline_pipeline_fifo_full_read 3 34095 NULL
118525 +__irq_domain_add_34101 __irq_domain_add 2 34101 NULL
118526 +proc_scsi_host_write_34107 proc_scsi_host_write 3 34107 NULL
118527 +islpci_mgt_transmit_34133 islpci_mgt_transmit 5 34133 NULL nohasharray
118528 +typhoon_request_firmware_34133 typhoon_request_firmware 0 34133 &islpci_mgt_transmit_34133
118529 +ttm_dma_page_pool_free_34135 ttm_dma_page_pool_free 2-0 34135 NULL
118530 +ixgbe_dbg_netdev_ops_write_34141 ixgbe_dbg_netdev_ops_write 3 34141 NULL
118531 +shmem_pread_fast_34147 shmem_pread_fast 3 34147 NULL
118532 +ocfs2_xattr_list_entry_34165 ocfs2_xattr_list_entry 0 34165 NULL
118533 +skb_to_sgvec_34171 skb_to_sgvec 0 34171 NULL
118534 +rsi_debug_zone_write_34206 rsi_debug_zone_write 3 34206 NULL
118535 +xfs_bmapi_write_34208 xfs_bmapi_write 0 34208 NULL
118536 +ext4_da_write_begin_34215 ext4_da_write_begin 3-4 34215 NULL
118537 +bl_pipe_downcall_34264 bl_pipe_downcall 3 34264 NULL
118538 +ocfs2_dlm_lock_34265 ocfs2_dlm_lock 0 34265 NULL
118539 +pcf857x_to_irq_34273 pcf857x_to_irq 2 34273 NULL
118540 +device_private_init_34279 device_private_init 0 34279 NULL
118541 +ext4_get_groups_count_34324 ext4_get_groups_count 0 34324 NULL
118542 +iov_iter_single_seg_count_34326 iov_iter_single_seg_count 0 34326 NULL nohasharray
118543 +pcpu_need_to_extend_34326 pcpu_need_to_extend 0 34326 &iov_iter_single_seg_count_34326
118544 +bcma_gpio_to_irq_34343 bcma_gpio_to_irq 2 34343 NULL
118545 +write_rss_34360 write_rss 0 34360 NULL
118546 +crypto_ablkcipher_ivsize_34363 crypto_ablkcipher_ivsize 0 34363 NULL nohasharray
118547 +sync_page_io_34363 sync_page_io 3 34363 &crypto_ablkcipher_ivsize_34363
118548 +rngapi_reset_34366 rngapi_reset 3 34366 NULL
118549 +ea_read_34378 ea_read 0 34378 NULL nohasharray
118550 +_iwl_dbgfs_low_latency_write_34378 _iwl_dbgfs_low_latency_write 3 34378 &ea_read_34378
118551 +fuse_send_read_34379 fuse_send_read 4 34379 NULL
118552 +av7110_vbi_write_34384 av7110_vbi_write 3 34384 NULL
118553 +usbvision_v4l2_read_34386 usbvision_v4l2_read 3 34386 NULL
118554 +read_rbu_image_type_34387 read_rbu_image_type 6 34387 NULL
118555 +iwl_calib_set_34400 iwl_calib_set 3 34400 NULL nohasharray
118556 +ivtv_read_pos_34400 ivtv_read_pos 3 34400 &iwl_calib_set_34400
118557 +wd_exp_mode_write_34407 wd_exp_mode_write 3 34407 NULL
118558 +nl80211_send_disassoc_34424 nl80211_send_disassoc 4 34424 NULL
118559 +__extent_read_full_page_34437 __extent_read_full_page 0 34437 NULL
118560 +usbtest_alloc_urb_34446 usbtest_alloc_urb 3-5 34446 NULL
118561 +mwifiex_regrdwr_read_34472 mwifiex_regrdwr_read 3 34472 NULL
118562 +skcipher_sndbuf_34476 skcipher_sndbuf 0 34476 NULL
118563 +i2o_parm_field_get_34477 i2o_parm_field_get 5 34477 NULL
118564 +security_inode_permission_34488 security_inode_permission 0 34488 NULL
118565 +SyS_pwritev_34494 SyS_pwritev 3 34494 NULL
118566 +qp_alloc_res_34496 qp_alloc_res 5 34496 NULL
118567 +lu_buf_check_and_alloc_34505 lu_buf_check_and_alloc 2 34505 NULL
118568 +ext4_fallocate_34537 ext4_fallocate 4-3 34537 NULL nohasharray
118569 +tracing_stats_read_34537 tracing_stats_read 3 34537 &ext4_fallocate_34537
118570 +hugetlbfs_read_actor_34547 hugetlbfs_read_actor 4-5-2-0 34547 NULL
118571 +dbBackSplit_34561 dbBackSplit 0 34561 NULL
118572 +self_check_peb_ec_hdr_34564 self_check_peb_ec_hdr 0 34564 NULL nohasharray
118573 +alloc_ieee80211_rsl_34564 alloc_ieee80211_rsl 1 34564 &self_check_peb_ec_hdr_34564
118574 +mlx4_init_mr_table_34578 mlx4_init_mr_table 0 34578 NULL
118575 +lov_stripecount_seq_write_34582 lov_stripecount_seq_write 3 34582 NULL
118576 +init_send_hfcd_34586 init_send_hfcd 1 34586 NULL
118577 +inet6_ifla6_size_34591 inet6_ifla6_size 0 34591 NULL
118578 +ceph_msgpool_init_34599 ceph_msgpool_init 4 34599 NULL nohasharray
118579 +cw1200_queue_init_34599 cw1200_queue_init 4 34599 &ceph_msgpool_init_34599
118580 +bio_integrity_bytes_34602 bio_integrity_bytes 2 34602 NULL
118581 +ctrl_xmit_34606 ctrl_xmit 0 34606 NULL
118582 +__jffs2_ref_totlen_34609 __jffs2_ref_totlen 0 34609 NULL nohasharray
118583 +mtd_write_34609 mtd_write 0 34609 &__jffs2_ref_totlen_34609
118584 +apei_get_nvs_resources_34616 apei_get_nvs_resources 0 34616 NULL
118585 +__cfg80211_disconnected_34622 __cfg80211_disconnected 3 34622 NULL
118586 +cnic_alloc_dma_34641 cnic_alloc_dma 3 34641 NULL
118587 +register_sja1000dev_34648 register_sja1000dev 0 34648 NULL
118588 +kvm_set_spte_hva_34671 kvm_set_spte_hva 2 34671 NULL
118589 +sleep_auth_write_34676 sleep_auth_write 3 34676 NULL
118590 +isr_fiqs_read_34687 isr_fiqs_read 3 34687 NULL
118591 +batadv_tvlv_realloc_packet_buff_34688 batadv_tvlv_realloc_packet_buff 3-4 34688 NULL
118592 +adp5588_gpio_add_34698 adp5588_gpio_add 0 34698 NULL
118593 +port_print_34704 port_print 3 34704 NULL
118594 +ieee80211_if_read_num_sta_ps_34722 ieee80211_if_read_num_sta_ps 3 34722 NULL
118595 +platform_list_read_file_34734 platform_list_read_file 3 34734 NULL
118596 +reg_w_ixbuf_34736 reg_w_ixbuf 4 34736 NULL
118597 +lsm_alloc_plain_34755 lsm_alloc_plain 1 34755 NULL
118598 +bootmode_store_34762 bootmode_store 4 34762 NULL
118599 +device_add_34766 device_add 0 34766 NULL
118600 +xfs_iget_cache_hit_34767 xfs_iget_cache_hit 0 34767 NULL nohasharray
118601 +__iio_device_attr_init_34767 __iio_device_attr_init 0 34767 &xfs_iget_cache_hit_34767
118602 +gpio_request_array_34773 gpio_request_array 0 34773 NULL
118603 +qib_cdev_init_34778 qib_cdev_init 1 34778 NULL
118604 +SYSC_keyctl_34800 SYSC_keyctl 4 34800 NULL
118605 +can_nocow_extent_34801 can_nocow_extent 2 34801 NULL
118606 +drbd_get_max_capacity_34804 drbd_get_max_capacity 0 34804 NULL
118607 +ll_setxattr_34806 ll_setxattr 4 34806 NULL
118608 +file_page_index_34820 file_page_index 0-2 34820 NULL
118609 +bio_segments_34832 bio_segments 0 34832 NULL
118610 +b43_debugfs_write_34838 b43_debugfs_write 3 34838 NULL
118611 +nl_portid_hash_zalloc_34843 nl_portid_hash_zalloc 1 34843 NULL
118612 +acpi_system_write_wakeup_device_34853 acpi_system_write_wakeup_device 3 34853 NULL
118613 +usb_serial_generic_prepare_write_buffer_34857 usb_serial_generic_prepare_write_buffer 3 34857 NULL
118614 +asd_init_seqs_34858 asd_init_seqs 0 34858 NULL
118615 +ieee80211_if_read_txpower_34871 ieee80211_if_read_txpower 3 34871 NULL
118616 +msg_print_text_34889 msg_print_text 0 34889 NULL
118617 +ieee80211_if_write_34894 ieee80211_if_write 3 34894 NULL
118618 +pci_user_read_config_byte_34899 pci_user_read_config_byte 0 34899 NULL
118619 +asd_verify_lseq_34910 asd_verify_lseq 0 34910 NULL
118620 +gfs2_glock_wait_34913 gfs2_glock_wait 0 34913 NULL
118621 +si476x_radio_read_rsq_primary_blob_34916 si476x_radio_read_rsq_primary_blob 3 34916 NULL
118622 +ath10k_htc_connect_service_34924 ath10k_htc_connect_service 0 34924 NULL
118623 +btrfs_super_chunk_root_34925 btrfs_super_chunk_root 0 34925 NULL nohasharray
118624 +__inode_permission_34925 __inode_permission 0 34925 &btrfs_super_chunk_root_34925
118625 +ceph_aio_write_34930 ceph_aio_write 4 34930 NULL
118626 +sec_flags2str_34933 sec_flags2str 3 34933 NULL
118627 +snd_info_entry_read_34938 snd_info_entry_read 3 34938 NULL
118628 +compat_SyS_kexec_load_34947 compat_SyS_kexec_load 2 34947 NULL
118629 +i2c_transfer_34958 i2c_transfer 0 34958 NULL
118630 +do_add_page_to_bio_34974 do_add_page_to_bio 2-10 34974 NULL
118631 +snd_at73c213_write_reg_34987 snd_at73c213_write_reg 0 34987 NULL
118632 +schedule_erase_34996 schedule_erase 0 34996 NULL
118633 +print_message_35000 print_message 0 35000 NULL
118634 +rx_rx_hdr_overflow_read_35002 rx_rx_hdr_overflow_read 3 35002 NULL
118635 +l2cap_skbuff_fromiovec_35003 l2cap_skbuff_fromiovec 4-3 35003 NULL
118636 +rtw_cfg80211_rx_p2p_action_public_35010 rtw_cfg80211_rx_p2p_action_public 3 35010 NULL
118637 +sisusb_copy_memory_35016 sisusb_copy_memory 4 35016 NULL
118638 +setup_sge_qsets_35026 setup_sge_qsets 0 35026 NULL
118639 +coda_psdev_read_35029 coda_psdev_read 3 35029 NULL
118640 +mthca_cmd_post_35036 mthca_cmd_post 0 35036 NULL
118641 +xfs_rtallocate_extent_35052 xfs_rtallocate_extent 0 35052 NULL
118642 +pwr_connection_out_of_sync_read_35061 pwr_connection_out_of_sync_read 3 35061 NULL
118643 +dma_async_device_register_35079 dma_async_device_register 0 35079 NULL
118644 +ntfs_attr_extend_initialized_35084 ntfs_attr_extend_initialized 0 35084 NULL
118645 +mei_register_35089 mei_register 0 35089 NULL
118646 +uas_find_endpoints_35096 uas_find_endpoints 0 35096 NULL
118647 +__kfifo_uint_must_check_helper_35097 __kfifo_uint_must_check_helper 0-1 35097 NULL
118648 +capi_write_35104 capi_write 3 35104 NULL nohasharray
118649 +tx_tx_done_template_read_35104 tx_tx_done_template_read 3 35104 &capi_write_35104
118650 +ide_settings_proc_write_35110 ide_settings_proc_write 3 35110 NULL
118651 +ceph_osdc_start_request_35122 ceph_osdc_start_request 0 35122 NULL
118652 +enic_alloc_vnic_resources_35156 enic_alloc_vnic_resources 0 35156 NULL
118653 +message_stats_print_35158 message_stats_print 6 35158 NULL
118654 +iscsi_conn_setup_35159 iscsi_conn_setup 2 35159 NULL
118655 +ieee80211_if_read_bssid_35161 ieee80211_if_read_bssid 3 35161 NULL
118656 +il_init_channel_map_35165 il_init_channel_map 0 35165 NULL
118657 +solo_v4l2_init_35179 solo_v4l2_init 0 35179 NULL
118658 +compat_SyS_pselect6_35203 compat_SyS_pselect6 1 35203 NULL
118659 +unix_stream_recvmsg_35210 unix_stream_recvmsg 4 35210 NULL
118660 +security_key_getsecurity_35218 security_key_getsecurity 0 35218 NULL nohasharray
118661 +striped_read_35218 striped_read 0-2 35218 &security_key_getsecurity_35218
118662 +rx_rx_cmplt_task_read_35226 rx_rx_cmplt_task_read 3 35226 NULL nohasharray
118663 +video_register_device_no_warn_35226 video_register_device_no_warn 0 35226 &rx_rx_cmplt_task_read_35226
118664 +set_fd_set_35249 set_fd_set 1 35249 NULL nohasharray
118665 +be_cmd_enable_magic_wol_35249 be_cmd_enable_magic_wol 0 35249 &set_fd_set_35249
118666 +ioapic_setup_resources_35255 ioapic_setup_resources 1 35255 NULL
118667 +va1j5jf8007s_prepare_2_35257 va1j5jf8007s_prepare_2 0 35257 NULL
118668 +jbd2_journal_get_write_access_35263 jbd2_journal_get_write_access 0 35263 NULL
118669 +dis_disc_write_35265 dis_disc_write 3 35265 NULL
118670 +dma_show_regs_35266 dma_show_regs 3 35266 NULL
118671 +irda_recvmsg_stream_35280 irda_recvmsg_stream 4 35280 NULL
118672 +i2o_block_end_request_35282 i2o_block_end_request 3 35282 NULL
118673 +isr_rx_rdys_read_35283 isr_rx_rdys_read 3 35283 NULL
118674 +__btrfs_buffered_write_35311 __btrfs_buffered_write 3-0 35311 NULL nohasharray
118675 +brcmf_sdio_forensic_read_35311 brcmf_sdio_forensic_read 3 35311 &__btrfs_buffered_write_35311
118676 +tracing_read_pipe_35312 tracing_read_pipe 3 35312 NULL
118677 +asd_init_scbs_35316 asd_init_scbs 0 35316 NULL
118678 +sta_tx_latency_stat_write_35323 sta_tx_latency_stat_write 3 35323 NULL
118679 +xfs_btree_check_lblock_35333 xfs_btree_check_lblock 0 35333 NULL
118680 +ieee80211_if_fmt_ap_power_level_35347 ieee80211_if_fmt_ap_power_level 3 35347 NULL
118681 +nouveau_devinit_create__35348 nouveau_devinit_create_ 4 35348 NULL
118682 +ieee80211_rx_mgmt_deauth_35351 ieee80211_rx_mgmt_deauth 3 35351 NULL
118683 +compat_filldir64_35354 compat_filldir64 3 35354 NULL
118684 +read_kmem_35372 read_kmem 3 35372 NULL
118685 +ocfs2_journal_access_di_35393 ocfs2_journal_access_di 0 35393 NULL
118686 +SyS_getxattr_35408 SyS_getxattr 4 35408 NULL
118687 +rawv6_send_hdrinc_35425 rawv6_send_hdrinc 3 35425 NULL
118688 +iwl_dbgfs_drv_rx_stats_read_35430 iwl_dbgfs_drv_rx_stats_read 3 35430 NULL
118689 +C_SYSC_sendfile_35432 C_SYSC_sendfile 4 35432 NULL
118690 +buffer_to_user_35439 buffer_to_user 3 35439 NULL
118691 +efx_mcdi_rpc_async_quiet_35460 efx_mcdi_rpc_async_quiet 4-5 35460 NULL
118692 +macvtap_do_read_35475 macvtap_do_read 3 35475 NULL
118693 +fiemap_prepare_and_copy_exts_35494 fiemap_prepare_and_copy_exts 5 35494 NULL
118694 +btrfs_prealloc_file_range_trans_35500 btrfs_prealloc_file_range_trans 4 35500 NULL
118695 +async_setkey_35521 async_setkey 3 35521 NULL
118696 +__filemap_fdatawrite_range_35528 __filemap_fdatawrite_range 0 35528 NULL
118697 +iwl_dbgfs_bt_traffic_read_35534 iwl_dbgfs_bt_traffic_read 3 35534 NULL
118698 +pstore_mkfile_35536 pstore_mkfile 7 35536 NULL
118699 +rxpipe_tx_xfr_host_int_trig_rx_data_read_35538 rxpipe_tx_xfr_host_int_trig_rx_data_read 3 35538 NULL
118700 +ocfs2_write_zero_page_35539 ocfs2_write_zero_page 3 35539 NULL
118701 +ibnl_put_attr_35541 ibnl_put_attr 3 35541 NULL
118702 +ieee80211_if_write_smps_35550 ieee80211_if_write_smps 3 35550 NULL
118703 +adp5588_setup_35562 adp5588_setup 0 35562 NULL
118704 +C_SYSC_kexec_load_35565 C_SYSC_kexec_load 2 35565 NULL
118705 +cx18_create_in_workq_35567 cx18_create_in_workq 0 35567 NULL
118706 +dev_alloc_name_ns_35569 dev_alloc_name_ns 0 35569 NULL
118707 +ext4_blocks_for_truncate_35579 ext4_blocks_for_truncate 0 35579 NULL
118708 +ext2_acl_from_disk_35580 ext2_acl_from_disk 2 35580 NULL
118709 +spk_msg_set_35586 spk_msg_set 3 35586 NULL
118710 +fnic_dev_alloc_desc_ring_35589 fnic_dev_alloc_desc_ring 0 35589 NULL
118711 +kernel_readv_35617 kernel_readv 3 35617 NULL
118712 +reiserfs_readpages_35629 reiserfs_readpages 4 35629 NULL
118713 +pci_request_regions_35635 pci_request_regions 0 35635 NULL
118714 +ptlrpcd_steal_rqset_35637 ptlrpcd_steal_rqset 0 35637 NULL
118715 +spi_register_board_info_35651 spi_register_board_info 2 35651 NULL
118716 +rdmaltWithLock_35669 rdmaltWithLock 0 35669 NULL
118717 +SYSC_pwritev_35690 SYSC_pwritev 3 35690 NULL
118718 +rds_page_copy_user_35691 rds_page_copy_user 4 35691 NULL
118719 +md_super_write_35703 md_super_write 4 35703 NULL
118720 +myri10ge_reset_35719 myri10ge_reset 0 35719 NULL
118721 +pci_enable_sriov_35745 pci_enable_sriov 0 35745 NULL
118722 +iwl_dbgfs_disable_ht40_read_35761 iwl_dbgfs_disable_ht40_read 3 35761 NULL
118723 +udf_alloc_i_data_35786 udf_alloc_i_data 2 35786 NULL
118724 +__i2c_bit_add_bus_35812 __i2c_bit_add_bus 0 35812 NULL
118725 +pvr2_hdw_cpufw_get_35824 pvr2_hdw_cpufw_get 0-4-2 35824 NULL
118726 +tx_tx_cmplt_read_35854 tx_tx_cmplt_read 3 35854 NULL
118727 +vx_query_hbuffer_size_35859 vx_query_hbuffer_size 0 35859 NULL
118728 +mthca_buf_alloc_35861 mthca_buf_alloc 2 35861 NULL
118729 +fls64_35862 fls64 0 35862 NULL
118730 +lpfc_eq_create_35879 lpfc_eq_create 0 35879 NULL
118731 +kvm_dirty_bitmap_bytes_35886 kvm_dirty_bitmap_bytes 0 35886 NULL
118732 +ieee80211_if_fmt_dot11MeshRetryTimeout_35890 ieee80211_if_fmt_dot11MeshRetryTimeout 3 35890 NULL
118733 +uwb_rc_cmd_done_35892 uwb_rc_cmd_done 4 35892 NULL
118734 +SyS_set_mempolicy_35909 SyS_set_mempolicy 3 35909 NULL
118735 +kernel_setsockopt_35913 kernel_setsockopt 5 35913 NULL
118736 +rbio_nr_pages_35916 rbio_nr_pages 0-1-2 35916 NULL
118737 +sctp_tsnmap_mark_35929 sctp_tsnmap_mark 2 35929 NULL
118738 +rx_defrag_init_called_read_35935 rx_defrag_init_called_read 3 35935 NULL
118739 +put_cmsg_compat_35937 put_cmsg_compat 4 35937 NULL
118740 +ext_rts51x_sd_execute_write_data_35971 ext_rts51x_sd_execute_write_data 9 35971 NULL
118741 +ceph_buffer_new_35974 ceph_buffer_new 1 35974 NULL nohasharray
118742 +generic_ocp_read_35974 generic_ocp_read 3 35974 &ceph_buffer_new_35974
118743 +acl_alloc_35979 acl_alloc 1 35979 NULL
118744 +device_add_class_symlinks_35985 device_add_class_symlinks 0 35985 NULL
118745 +kuc_alloc_35998 kuc_alloc 1 35998 NULL nohasharray
118746 +write_file_antenna_35998 write_file_antenna 3 35998 &kuc_alloc_35998
118747 +locks_mandatory_area_35999 locks_mandatory_area 0 35999 NULL
118748 +il3945_ucode_tx_stats_read_36016 il3945_ucode_tx_stats_read 3 36016 NULL
118749 +ubi_eba_write_leb_36029 ubi_eba_write_leb 0 36029 NULL
118750 +__videobuf_alloc_36031 __videobuf_alloc 1 36031 NULL
118751 +account_shadowed_36048 account_shadowed 2 36048 NULL
118752 +gpio_power_read_36059 gpio_power_read 3 36059 NULL
118753 +snd_pcm_playback_hw_avail_36061 snd_pcm_playback_hw_avail 0 36061 NULL
118754 +write_emulate_36065 write_emulate 2-4 36065 NULL
118755 +stack_max_size_write_36068 stack_max_size_write 3 36068 NULL
118756 +radeon_vm_num_pdes_36070 radeon_vm_num_pdes 0 36070 NULL
118757 +ieee80211_if_fmt_peer_36071 ieee80211_if_fmt_peer 3 36071 NULL
118758 +dwc2_core_init_36072 dwc2_core_init 0 36072 NULL
118759 +ieee80211_if_write_tsf_36077 ieee80211_if_write_tsf 3 36077 NULL
118760 +snd_pcm_plug_read_transfer_36080 snd_pcm_plug_read_transfer 0-3 36080 NULL
118761 +mtip_hw_read_device_status_36082 mtip_hw_read_device_status 3 36082 NULL
118762 +zr364xx_board_init_36093 zr364xx_board_init 0 36093 NULL
118763 +usb_add_hcd_36108 usb_add_hcd 0 36108 NULL
118764 +vga_arb_write_36112 vga_arb_write 3 36112 NULL
118765 +simple_xattr_alloc_36118 simple_xattr_alloc 2 36118 NULL
118766 +ext3_readpages_36144 ext3_readpages 4 36144 NULL
118767 +twl_set_36154 twl_set 2 36154 NULL
118768 +b1_alloc_card_36155 b1_alloc_card 1 36155 NULL
118769 +snd_korg1212_copy_from_36169 snd_korg1212_copy_from 6 36169 NULL nohasharray
118770 +mlx4_status_to_errno_36169 mlx4_status_to_errno 0 36169 &snd_korg1212_copy_from_36169
118771 +SyS_kexec_load_36176 SyS_kexec_load 2 36176 NULL
118772 +ramoops_init_przs_36199 ramoops_init_przs 4 36199 NULL
118773 +p54_generate_channel_lists_36200 p54_generate_channel_lists 0 36200 NULL
118774 +skge_reset_36205 skge_reset 0 36205 NULL
118775 +SYSC_sched_getaffinity_36208 SYSC_sched_getaffinity 2 36208 NULL
118776 +va1j5jf8007s_init_frequency_36215 va1j5jf8007s_init_frequency 0 36215 NULL
118777 +SYSC_process_vm_readv_36216 SYSC_process_vm_readv 3-5 36216 NULL
118778 +atomic_stats_read_36228 atomic_stats_read 3 36228 NULL
118779 +__padata_remove_cpu_36235 __padata_remove_cpu 0 36235 NULL
118780 +rtw_cfg80211_set_wpa_ie_36236 rtw_cfg80211_set_wpa_ie 3 36236 NULL
118781 +viafb_iga1_odev_proc_write_36241 viafb_iga1_odev_proc_write 3 36241 NULL
118782 +SYSC_getxattr_36242 SYSC_getxattr 4 36242 NULL
118783 +vmsplice_to_user_36245 vmsplice_to_user 3 36245 NULL nohasharray
118784 +rproc_recovery_read_36245 rproc_recovery_read 3 36245 &vmsplice_to_user_36245
118785 +mlx4_init_port_info_36269 mlx4_init_port_info 0 36269 NULL
118786 +usb_buffer_alloc_36276 usb_buffer_alloc 2 36276 NULL nohasharray
118787 +cfs_hash_buckets_realloc_36276 cfs_hash_buckets_realloc 4 36276 &usb_buffer_alloc_36276 nohasharray
118788 +bus_for_each_dev_36276 bus_for_each_dev 0 36276 &cfs_hash_buckets_realloc_36276
118789 +codec_reg_read_file_36280 codec_reg_read_file 3 36280 NULL
118790 +crypto_shash_digestsize_36284 crypto_shash_digestsize 0 36284 NULL
118791 +lpfc_debugfs_dif_err_read_36303 lpfc_debugfs_dif_err_read 3 36303 NULL
118792 +cfg80211_rx_mlme_mgmt_36306 cfg80211_rx_mlme_mgmt 3 36306 NULL
118793 +ad7879_spi_xfer_36311 ad7879_spi_xfer 3 36311 NULL nohasharray
118794 +ath10k_htt_tx_attach_36311 ath10k_htt_tx_attach 0 36311 &ad7879_spi_xfer_36311
118795 +mthca_register_device_36325 mthca_register_device 0 36325 NULL
118796 +fat_compat_ioctl_filldir_36328 fat_compat_ioctl_filldir 3 36328 NULL nohasharray
118797 +__compat_sys_pwritev64_36328 __compat_sys_pwritev64 3 36328 &fat_compat_ioctl_filldir_36328
118798 +lc_create_36332 lc_create 4 36332 NULL
118799 +jbd2_journal_init_revoke_table_36336 jbd2_journal_init_revoke_table 1 36336 NULL
118800 +t4_config_rss_range_36340 t4_config_rss_range 0 36340 NULL
118801 +isku_sysfs_read_key_mask_36343 isku_sysfs_read_key_mask 6 36343 NULL
118802 +ath6kl_regwrite_write_36351 ath6kl_regwrite_write 3 36351 NULL
118803 +v9fs_file_readn_36353 v9fs_file_readn 4 36353 NULL
118804 +to_sector_36361 to_sector 0-1 36361 NULL
118805 +usb_register_bus_36362 usb_register_bus 0 36362 NULL
118806 +tunables_read_36385 tunables_read 3 36385 NULL nohasharray
118807 +bind_qsets_36385 bind_qsets 0 36385 &tunables_read_36385
118808 +asd_init_dl_36392 asd_init_dl 0 36392 NULL
118809 +afs_alloc_flat_call_36399 afs_alloc_flat_call 2-3 36399 NULL
118810 +sierra_write_36402 sierra_write 4 36402 NULL
118811 +qdsb_get_36409 qdsb_get 0 36409 NULL
118812 +il3945_init_drv_36411 il3945_init_drv 0 36411 NULL
118813 +SyS_sethostname_36417 SyS_sethostname 2 36417 NULL
118814 +snd_msnd_init_sma_36431 snd_msnd_init_sma 0 36431 NULL
118815 +ReadW6692B_36445 ReadW6692B 0 36445 NULL
118816 +sctp_tsnmap_init_36446 sctp_tsnmap_init 2 36446 NULL
118817 +alloc_etherdev_mqs_36450 alloc_etherdev_mqs 1 36450 NULL
118818 +SyS_process_vm_writev_36476 SyS_process_vm_writev 3-5 36476 NULL
118819 +lock_and_cleanup_extent_if_need_36480 lock_and_cleanup_extent_if_need 0 36480 NULL
118820 +b43_nphy_load_samples_36481 b43_nphy_load_samples 3 36481 NULL
118821 +ip6_append_data_36490 ip6_append_data 4 36490 NULL nohasharray
118822 +tx_tx_checksum_result_read_36490 tx_tx_checksum_result_read 3 36490 &ip6_append_data_36490
118823 +cmd_loop_36491 cmd_loop 0 36491 NULL
118824 +enic_dev_init_36496 enic_dev_init 0 36496 NULL
118825 +__hwahc_op_set_ptk_36510 __hwahc_op_set_ptk 5 36510 NULL
118826 +mcam_v4l_read_36513 mcam_v4l_read 3 36513 NULL
118827 +_iwl_dbgfs_fw_nmi_write_36515 _iwl_dbgfs_fw_nmi_write 3 36515 NULL
118828 +ibmasm_send_os_state_36516 ibmasm_send_os_state 0 36516 NULL
118829 +get_param_l_36518 get_param_l 0 36518 NULL
118830 +ieee80211_if_read_fwded_frames_36520 ieee80211_if_read_fwded_frames 3 36520 NULL
118831 +crypto_aead_authsize_36537 crypto_aead_authsize 0 36537 NULL
118832 +cpu_type_read_36540 cpu_type_read 3 36540 NULL
118833 +de_init_hw_36543 de_init_hw 0 36543 NULL
118834 +__kfifo_to_user_36555 __kfifo_to_user 3-0 36555 NULL
118835 +btrfs_get_token_64_36572 btrfs_get_token_64 0 36572 NULL
118836 +__erst_read_36579 __erst_read 0 36579 NULL
118837 +e100_exec_cmd_36583 e100_exec_cmd 0 36583 NULL
118838 +put_cmsg_36589 put_cmsg 4 36589 NULL
118839 +do_sendfile_36610 do_sendfile 4-5 36610 NULL
118840 +fat_ioctl_filldir_36621 fat_ioctl_filldir 3 36621 NULL
118841 +vxge_config_vpaths_36636 vxge_config_vpaths 0 36636 NULL
118842 +ath5k_eeprom_read_target_rate_pwr_info_36641 ath5k_eeprom_read_target_rate_pwr_info 0 36641 NULL
118843 +convert_extent_item_v0_36645 convert_extent_item_v0 4 36645 NULL
118844 +ced_ioctl_36647 ced_ioctl 2 36647 NULL
118845 +lpfc_idiag_extacc_alloc_get_36648 lpfc_idiag_extacc_alloc_get 0-3 36648 NULL
118846 +ath9k_hw_init_36649 ath9k_hw_init 0 36649 NULL
118847 +osd_req_list_collection_objects_36664 osd_req_list_collection_objects 5 36664 NULL
118848 +iscsi_host_alloc_36671 iscsi_host_alloc 2 36671 NULL
118849 +xillybus_read_36678 xillybus_read 3 36678 NULL
118850 +gsmtty_write_36702 gsmtty_write 3 36702 NULL
118851 +vfio_user_config_write_36712 vfio_user_config_write 0 36712 NULL
118852 +tg3_phy_auxctl_write_36713 tg3_phy_auxctl_write 0 36713 NULL
118853 +ocfs2_rotate_tree_right_36723 ocfs2_rotate_tree_right 0 36723 NULL
118854 +saa7134_i2c_eeprom_36729 saa7134_i2c_eeprom 3 36729 NULL
118855 +snd_rawmidi_kernel_read1_36740 snd_rawmidi_kernel_read1 4-0 36740 NULL
118856 +cxgbi_device_register_36746 cxgbi_device_register 1-2 36746 NULL
118857 +ps_poll_upsd_timeouts_read_36755 ps_poll_upsd_timeouts_read 3 36755 NULL
118858 +pci_write_config_dword_36790 pci_write_config_dword 0 36790 NULL
118859 +i40e_init_lan_hmc_36796 i40e_init_lan_hmc 2-3-4-5 36796 NULL
118860 +proc_fault_inject_read_36802 proc_fault_inject_read 3 36802 NULL
118861 +hiddev_ioctl_36816 hiddev_ioctl 2 36816 NULL
118862 +ocfs2_journal_access_rb_36823 ocfs2_journal_access_rb 0 36823 NULL
118863 +int_hardware_entry_36833 int_hardware_entry 3 36833 NULL
118864 +fc_change_queue_depth_36841 fc_change_queue_depth 2 36841 NULL
118865 +keyctl_describe_key_36853 keyctl_describe_key 3 36853 NULL
118866 +cm_write_36858 cm_write 3 36858 NULL
118867 +tipc_link_iovec_long_xmit_36871 tipc_link_iovec_long_xmit 3 36871 NULL nohasharray
118868 +tx_tx_data_programmed_read_36871 tx_tx_data_programmed_read 3 36871 &tipc_link_iovec_long_xmit_36871
118869 +svc_setsockopt_36876 svc_setsockopt 5 36876 NULL
118870 +raid56_parity_write_36877 raid56_parity_write 5 36877 NULL
118871 +__btrfs_map_block_36883 __btrfs_map_block 3 36883 NULL
118872 +ib_ucm_alloc_data_36885 ib_ucm_alloc_data 3 36885 NULL
118873 +selinux_inode_notifysecctx_36896 selinux_inode_notifysecctx 3 36896 NULL
118874 +tas5086_register_size_36899 tas5086_register_size 0 36899 NULL
118875 +OS_kmalloc_36909 OS_kmalloc 1 36909 NULL
118876 +ext4_da_write_end_36974 ext4_da_write_end 5 36974 NULL
118877 +ttm_bo_init_mm_36977 ttm_bo_init_mm 0 36977 NULL
118878 +il4965_rs_sta_dbgfs_scale_table_write_36979 il4965_rs_sta_dbgfs_scale_table_write 3 36979 NULL
118879 +xfs_btree_check_sptr_36984 xfs_btree_check_sptr 0 36984 NULL
118880 +drbd_new_dev_size_36998 drbd_new_dev_size 0-3 36998 NULL
118881 +auok190xfb_write_37001 auok190xfb_write 3 37001 NULL
118882 +setxattr_37006 setxattr 4 37006 NULL
118883 +vfio_msi_config_write_37022 vfio_msi_config_write 3 37022 NULL
118884 +ocfs2_dlm_unlock_37037 ocfs2_dlm_unlock 0 37037 NULL
118885 +command_file_read_37038 command_file_read 3 37038 NULL
118886 +figure_loop_size_37051 figure_loop_size 2-3 37051 NULL
118887 +ieee80211_if_read_drop_unencrypted_37053 ieee80211_if_read_drop_unencrypted 3 37053 NULL nohasharray
118888 +qp_broker_create_37053 qp_broker_create 6-5 37053 &ieee80211_if_read_drop_unencrypted_37053
118889 +_iwl_dbgfs_bcast_filters_macs_write_37069 _iwl_dbgfs_bcast_filters_macs_write 3 37069 NULL
118890 +SYSC_setxattr_37078 SYSC_setxattr 4 37078 NULL
118891 +parse_command_37079 parse_command 2 37079 NULL
118892 +pipeline_cs_rx_packet_in_read_37089 pipeline_cs_rx_packet_in_read 3 37089 NULL
118893 +tun_get_user_37094 tun_get_user 5 37094 NULL
118894 +xlog_grant_head_check_37116 xlog_grant_head_check 0 37116 NULL
118895 +has_wrprotected_page_37123 has_wrprotected_page 3-2 37123 NULL
118896 +snd_hda_get_conn_list_37132 snd_hda_get_conn_list 0 37132 NULL
118897 +mtt_free_res_37144 mtt_free_res 5 37144 NULL
118898 +msg_word_37164 msg_word 0 37164 NULL
118899 +f2fs_direct_IO_37167 f2fs_direct_IO 4 37167 NULL
118900 +vcc_recvmsg_37198 vcc_recvmsg 4 37198 NULL
118901 +ath10k_bmi_done_37201 ath10k_bmi_done 0 37201 NULL
118902 +forced_ps_write_37209 forced_ps_write 3 37209 NULL
118903 +crypto_shash_descsize_37212 crypto_shash_descsize 0 37212 NULL nohasharray
118904 +ext4_ind_direct_IO_37212 ext4_ind_direct_IO 4-0 37212 &crypto_shash_descsize_37212
118905 +bchannel_get_rxbuf_37213 bchannel_get_rxbuf 0-2 37213 NULL
118906 +regmap_access_read_file_37223 regmap_access_read_file 3 37223 NULL
118907 +__do_replace_37227 __do_replace 5 37227 NULL
118908 +produce_free_peb_37232 produce_free_peb 0 37232 NULL
118909 +iwl_dbgfs_d3_sram_read_37237 iwl_dbgfs_d3_sram_read 3 37237 NULL
118910 +rx_filter_dup_filter_read_37238 rx_filter_dup_filter_read 3 37238 NULL
118911 +iio_device_register_37256 iio_device_register 0 37256 NULL
118912 +xfs_reclaim_inode_37257 xfs_reclaim_inode 0 37257 NULL
118913 +prot_queue_del_37258 prot_queue_del 0 37258 NULL nohasharray
118914 +misc_register_37258 misc_register 0 37258 &prot_queue_del_37258
118915 +exofs_max_io_pages_37263 exofs_max_io_pages 0-2 37263 NULL
118916 +_iwl_dbgfs_fw_restart_write_37270 _iwl_dbgfs_fw_restart_write 3 37270 NULL
118917 +request_threaded_irq_37303 request_threaded_irq 0 37303 NULL
118918 +ieee80211_if_read_power_mode_37305 ieee80211_if_read_power_mode 3 37305 NULL
118919 +tda998x_write_if_37306 tda998x_write_if 5 37306 NULL
118920 +bma180_set_scale_37307 bma180_set_scale 0 37307 NULL
118921 +ext3_direct_IO_37308 ext3_direct_IO 4 37308 NULL
118922 +jffs2_write_dirent_37311 jffs2_write_dirent 5 37311 NULL
118923 +tipc_send_37315 tipc_send 3 37315 NULL
118924 +l2cap_create_connless_pdu_37327 l2cap_create_connless_pdu 3 37327 NULL nohasharray
118925 +bnx2x_vf_fill_fw_str_37327 bnx2x_vf_fill_fw_str 3 37327 &l2cap_create_connless_pdu_37327
118926 +scsi_mode_select_37330 scsi_mode_select 6 37330 NULL
118927 +rxrpc_server_sendmsg_37331 rxrpc_server_sendmsg 4 37331 NULL
118928 +t4vf_wait_dev_ready_37332 t4vf_wait_dev_ready 0 37332 NULL
118929 +xfs_iomap_write_allocate_37336 xfs_iomap_write_allocate 0 37336 NULL
118930 +security_inode_getsecurity_37354 security_inode_getsecurity 0 37354 NULL
118931 +hv_post_message_37383 hv_post_message 0 37383 NULL
118932 +iommu_num_pages_37391 iommu_num_pages 0-3-1-2 37391 NULL
118933 +hci_sock_sendmsg_37420 hci_sock_sendmsg 4 37420 NULL
118934 +acpi_os_allocate_zeroed_37422 acpi_os_allocate_zeroed 1 37422 NULL nohasharray
118935 +find_next_bit_37422 find_next_bit 0 37422 &acpi_os_allocate_zeroed_37422
118936 +ocfs2_insert_path_37425 ocfs2_insert_path 0 37425 NULL
118937 +pcie_set_readrq_37427 pcie_set_readrq 0 37427 NULL
118938 +tty_insert_flip_string_fixed_flag_37428 tty_insert_flip_string_fixed_flag 4-0 37428 NULL
118939 +iwl_print_last_event_logs_37433 iwl_print_last_event_logs 0-7-9 37433 NULL
118940 +fru_alloc_37442 fru_alloc 1 37442 NULL
118941 +tcp_established_options_37450 tcp_established_options 0 37450 NULL
118942 +xfs_btree_dec_cursor_37452 xfs_btree_dec_cursor 0 37452 NULL
118943 +brcmf_sdio_dump_console_37455 brcmf_sdio_dump_console 4 37455 NULL
118944 +ext4_write_end_37464 ext4_write_end 5 37464 NULL
118945 +get_est_timing_37484 get_est_timing 0 37484 NULL
118946 +ath10k_wmi_connect_htc_service_37487 ath10k_wmi_connect_htc_service 0 37487 NULL
118947 +kmem_realloc_37489 kmem_realloc 2 37489 NULL
118948 +regulator_register_notifier_37492 regulator_register_notifier 0 37492 NULL
118949 +mthca_MAP_FA_37493 mthca_MAP_FA 0 37493 NULL
118950 +bitmap_dirty_bits_37503 bitmap_dirty_bits 2 37503 NULL
118951 +osc_active_seq_write_37514 osc_active_seq_write 3 37514 NULL
118952 +bdev_writeseg_37519 bdev_writeseg 2-3 37519 NULL nohasharray
118953 +t4_memory_rw_37519 t4_memory_rw 0 37519 &bdev_writeseg_37519
118954 +xz_dec_test_write_37527 xz_dec_test_write 3 37527 NULL nohasharray
118955 +via_sensor_power_setup_37527 via_sensor_power_setup 0 37527 &xz_dec_test_write_37527
118956 +lpfc_cq_create_37530 lpfc_cq_create 0 37530 NULL
118957 +ad7606_register_ring_funcs_and_init_37533 ad7606_register_ring_funcs_and_init 0 37533 NULL
118958 +fault_inject_read_37534 fault_inject_read 3 37534 NULL
118959 +hdr_size_37536 hdr_size 0 37536 NULL
118960 +extent_map_end_37550 extent_map_end 0 37550 NULL
118961 +sep_create_dcb_dmatables_context_37551 sep_create_dcb_dmatables_context 6 37551 NULL
118962 +fat_cont_expand_37552 fat_cont_expand 0 37552 NULL
118963 +coralp_init_37568 coralp_init 0 37568 NULL
118964 +t4_prep_fw_37572 t4_prep_fw 0 37572 NULL
118965 +xhci_alloc_streams_37586 xhci_alloc_streams 5 37586 NULL
118966 +ocfs2_add_branch_37588 ocfs2_add_branch 0 37588 NULL
118967 +alloc_descs_37593 alloc_descs 0-1 37593 NULL
118968 +qla2x00_debounce_register_37597 qla2x00_debounce_register 0 37597 NULL
118969 +kvm_read_guest_page_mmu_37611 kvm_read_guest_page_mmu 6 37611 NULL
118970 +SYSC_mbind_37622 SYSC_mbind 5 37622 NULL nohasharray
118971 +ocfs2_split_refcount_rec_37622 ocfs2_split_refcount_rec 0 37622 &SYSC_mbind_37622
118972 +SyS_mbind_37638 SyS_mbind 5 37638 NULL
118973 +may_delete_37656 may_delete 0 37656 NULL
118974 +bio_copy_user_iov_37660 bio_copy_user_iov 4 37660 NULL
118975 +rfcomm_sock_sendmsg_37661 rfcomm_sock_sendmsg 4 37661 NULL nohasharray
118976 +vmw_framebuffer_dmabuf_dirty_37661 vmw_framebuffer_dmabuf_dirty 6 37661 &rfcomm_sock_sendmsg_37661
118977 +SYSC_get_mempolicy_37664 SYSC_get_mempolicy 3 37664 NULL
118978 +ipr_alloc_mem_37669 ipr_alloc_mem 0 37669 NULL
118979 +__wa_seg_calculate_isoc_frame_count_37672 __wa_seg_calculate_isoc_frame_count 0 37672 NULL
118980 +ieee80211_if_read_rc_rateidx_mcs_mask_2ghz_37675 ieee80211_if_read_rc_rateidx_mcs_mask_2ghz 3 37675 NULL
118981 +regmap_map_read_file_37685 regmap_map_read_file 3 37685 NULL
118982 +ioat3_irq_reinit_37692 ioat3_irq_reinit 0 37692 NULL
118983 +nametbl_header_37698 nametbl_header 2-0 37698 NULL
118984 +__le32_to_cpup_37702 __le32_to_cpup 0 37702 NULL
118985 +dynamic_ps_timeout_write_37713 dynamic_ps_timeout_write 3 37713 NULL
118986 +read_enabled_file_bool_37744 read_enabled_file_bool 3 37744 NULL
118987 +ql_set_routing_reg_37747 ql_set_routing_reg 0 37747 NULL
118988 +xfs_read_agf_37749 xfs_read_agf 0 37749 NULL
118989 +ocfs2_control_cfu_37750 ocfs2_control_cfu 2 37750 NULL
118990 +ipath_cdev_init_37752 ipath_cdev_init 1 37752 NULL
118991 +dccp_setsockopt_cscov_37766 dccp_setsockopt_cscov 2 37766 NULL
118992 +il4965_rs_sta_dbgfs_rate_scale_data_read_37792 il4965_rs_sta_dbgfs_rate_scale_data_read 3 37792 NULL
118993 +smk_read_logging_37804 smk_read_logging 3 37804 NULL
118994 +ocrdma_alloc_frmr_page_list_37815 ocrdma_alloc_frmr_page_list 2 37815 NULL
118995 +ath10k_core_check_chip_id_37819 ath10k_core_check_chip_id 0 37819 NULL
118996 +rx_decrypt_key_not_found_read_37820 rx_decrypt_key_not_found_read 3 37820 NULL
118997 +mlx4_cmd_post_37826 mlx4_cmd_post 0 37826 NULL
118998 +bitmap_find_next_zero_area_37827 bitmap_find_next_zero_area 0-4-5 37827 NULL
118999 +ad7606_request_gpios_37828 ad7606_request_gpios 0 37828 NULL
119000 +android_get_p2p_addr_37832 android_get_p2p_addr 0 37832 NULL
119001 +jbd2_journal_get_undo_access_37837 jbd2_journal_get_undo_access 0 37837 NULL
119002 +mthca_cmd_37841 mthca_cmd 0 37841 NULL
119003 +o2hb_debug_read_37851 o2hb_debug_read 3 37851 NULL
119004 +SYSC_pwrite64_37862 SYSC_pwrite64 3 37862 NULL
119005 +xfs_dir2_block_to_sf_37868 xfs_dir2_block_to_sf 3 37868 NULL
119006 +niu_init_mac_ipp_pcs_base_37880 niu_init_mac_ipp_pcs_base 0 37880 NULL
119007 +set_registers_37883 set_registers 4 37883 NULL
119008 +btrfs_stack_file_extent_disk_bytenr_37888 btrfs_stack_file_extent_disk_bytenr 0 37888 NULL
119009 +snd_at73c213_set_bitrate_37891 snd_at73c213_set_bitrate 0 37891 NULL
119010 +pkt_alloc_packet_data_37928 pkt_alloc_packet_data 1 37928 NULL nohasharray
119011 +_rtw_malloc_37928 _rtw_malloc 1 37928 &pkt_alloc_packet_data_37928
119012 +_pci_assign_resource_37930 _pci_assign_resource 0 37930 NULL
119013 +read_rbu_packet_size_37939 read_rbu_packet_size 6 37939 NULL
119014 +snd_opti9xx_configure_37942 snd_opti9xx_configure 0 37942 NULL
119015 +write_file_bool_37957 write_file_bool 3 37957 NULL nohasharray
119016 +lx_init_get_version_features_37957 lx_init_get_version_features 0 37957 &write_file_bool_37957
119017 +fifo_alloc_37961 fifo_alloc 1 37961 NULL
119018 +ath10k_do_pci_wake_37965 ath10k_do_pci_wake 0 37965 NULL
119019 +rds_rdma_extra_size_37990 rds_rdma_extra_size 0 37990 NULL
119020 +persistent_ram_old_size_37997 persistent_ram_old_size 0 37997 NULL
119021 +vfs_readv_38011 vfs_readv 3 38011 NULL
119022 +ufs_commit_chunk_38036 ufs_commit_chunk 3 38036 NULL
119023 +aggr_recv_addba_req_evt_38037 aggr_recv_addba_req_evt 4 38037 NULL
119024 +SyS_pwrite64_38041 SyS_pwrite64 3 38041 NULL
119025 +il_dbgfs_chain_noise_read_38044 il_dbgfs_chain_noise_read 3 38044 NULL nohasharray
119026 +klsi_105_prepare_write_buffer_38044 klsi_105_prepare_write_buffer 3 38044 &il_dbgfs_chain_noise_read_38044
119027 +SyS_llistxattr_38048 SyS_llistxattr 3 38048 NULL
119028 +sysfs_do_create_link_38051 sysfs_do_create_link 0 38051 NULL
119029 +_xfs_buf_alloc_38058 _xfs_buf_alloc 3 38058 NULL
119030 +nsm_create_handle_38060 nsm_create_handle 4 38060 NULL
119031 +alloc_ltalkdev_38071 alloc_ltalkdev 1 38071 NULL
119032 +xfs_buf_readahead_map_38081 xfs_buf_readahead_map 3 38081 NULL nohasharray
119033 +wcn36xx_smd_rsp_process_38081 wcn36xx_smd_rsp_process 3 38081 &xfs_buf_readahead_map_38081
119034 +uwb_mac_addr_print_38085 uwb_mac_addr_print 2 38085 NULL
119035 +request_key_auth_new_38092 request_key_auth_new 3 38092 NULL
119036 +proc_self_readlink_38094 proc_self_readlink 3 38094 NULL
119037 +ep0_read_38095 ep0_read 3 38095 NULL
119038 +sk_wmem_schedule_38096 sk_wmem_schedule 2 38096 NULL nohasharray
119039 +osc_checksum_seq_write_38096 osc_checksum_seq_write 3 38096 &sk_wmem_schedule_38096
119040 +o2hb_read_slots_38105 o2hb_read_slots 2 38105 NULL
119041 +snd_pcm_oss_write_38108 snd_pcm_oss_write 3 38108 NULL
119042 +snd_pcm_new_38111 snd_pcm_new 0 38111 NULL
119043 +vmw_kms_present_38130 vmw_kms_present 9 38130 NULL
119044 +mthca_init_hca_38140 mthca_init_hca 0 38140 NULL
119045 +__ntfs_copy_from_user_iovec_inatomic_38153 __ntfs_copy_from_user_iovec_inatomic 4-3-0 38153 NULL
119046 +btrfs_extent_same_38163 btrfs_extent_same 3-2 38163 NULL
119047 +kvm_clear_guest_38164 kvm_clear_guest 3-2 38164 NULL
119048 +ath5k_eeprom_init_header_38173 ath5k_eeprom_init_header 0 38173 NULL
119049 +cdev_add_38176 cdev_add 2-3-0 38176 NULL
119050 +rt2x00debug_write_rf_38195 rt2x00debug_write_rf 3 38195 NULL
119051 +led_trigger_register_38196 led_trigger_register 0 38196 NULL
119052 +get_ucode_user_38202 get_ucode_user 3 38202 NULL
119053 +osd_req_list_partition_collections_38223 osd_req_list_partition_collections 5 38223 NULL nohasharray
119054 +xfs_rtallocate_range_38223 xfs_rtallocate_range 0 38223 &osd_req_list_partition_collections_38223
119055 +palmas_gpio_to_irq_38235 palmas_gpio_to_irq 2 38235 NULL
119056 +ceph_decode_16_38239 ceph_decode_16 0 38239 NULL
119057 +spi_register_master_38240 spi_register_master 0 38240 NULL
119058 +__mlx4_cmd_38244 __mlx4_cmd 0 38244 NULL
119059 +_ipw_read_reg32_38245 _ipw_read_reg32 0 38245 NULL
119060 +t4_fw_halt_38247 t4_fw_halt 0 38247 NULL
119061 +snd_pcm_playback_rewind_38249 snd_pcm_playback_rewind 0-2 38249 NULL
119062 +xfs_qm_dqrepair_38262 xfs_qm_dqrepair 0 38262 NULL
119063 +mthca_alloc_icm_table_38268 mthca_alloc_icm_table 4-3 38268 NULL nohasharray
119064 +ieee80211_if_read_auto_open_plinks_38268 ieee80211_if_read_auto_open_plinks 3 38268 &mthca_alloc_icm_table_38268 nohasharray
119065 +SYSC_msgrcv_38268 SYSC_msgrcv 3 38268 &ieee80211_if_read_auto_open_plinks_38268
119066 +xfs_bmdr_to_bmbt_38275 xfs_bmdr_to_bmbt 5 38275 NULL nohasharray
119067 +xfs_bmbt_to_bmdr_38275 xfs_bmbt_to_bmdr 3 38275 &xfs_bmdr_to_bmbt_38275
119068 +ftdi_process_packet_38281 ftdi_process_packet 4 38281 NULL
119069 +C_SYSC_pselect6_38296 C_SYSC_pselect6 1 38296 NULL
119070 +p54_convert_rev0_38300 p54_convert_rev0 0 38300 NULL
119071 +ucma_query_path_38305 ucma_query_path 3 38305 NULL
119072 +hpsa_pci_init_38323 hpsa_pci_init 0 38323 NULL
119073 +isr_rx_headers_read_38325 isr_rx_headers_read 3 38325 NULL
119074 +ida_simple_get_38326 ida_simple_get 0 38326 NULL
119075 +ocfs2_rotate_rightmost_leaf_left_38330 ocfs2_rotate_rightmost_leaf_left 0 38330 NULL
119076 +__snd_gf1_look8_38333 __snd_gf1_look8 0 38333 NULL
119077 +ntb_transport_init_38338 ntb_transport_init 0 38338 NULL
119078 +ql_set_mac_addr_reg_38341 ql_set_mac_addr_reg 0 38341 NULL
119079 +ocfs2_replace_extent_rec_38357 ocfs2_replace_extent_rec 0 38357 NULL
119080 +btrfs_file_extent_disk_num_bytes_38363 btrfs_file_extent_disk_num_bytes 0 38363 NULL nohasharray
119081 +rtsx_pci_acquire_irq_38363 rtsx_pci_acquire_irq 0 38363 &btrfs_file_extent_disk_num_bytes_38363
119082 +xfs_free_file_space_38383 xfs_free_file_space 2-3 38383 NULL
119083 +dn_sendmsg_38390 dn_sendmsg 4 38390 NULL
119084 +ath10k_core_register_38414 ath10k_core_register 0 38414 NULL
119085 +ieee80211_if_read_dtim_count_38419 ieee80211_if_read_dtim_count 3 38419 NULL
119086 +read_port_table_lengths_38427 read_port_table_lengths 0 38427 NULL
119087 +pmcraid_copy_sglist_38431 pmcraid_copy_sglist 3 38431 NULL
119088 +dev_set_mtu_38447 dev_set_mtu 0 38447 NULL
119089 +kvm_write_guest_38454 kvm_write_guest 4-2 38454 NULL
119090 +_iwl_dbgfs_scan_ant_rxchain_write_38479 _iwl_dbgfs_scan_ant_rxchain_write 3 38479 NULL
119091 +blk_end_bidi_request_38482 blk_end_bidi_request 3-4 38482 NULL
119092 +dev_names_read_38509 dev_names_read 3 38509 NULL
119093 +iscsi_create_iface_38510 iscsi_create_iface 5 38510 NULL
119094 +event_rx_mismatch_read_38518 event_rx_mismatch_read 3 38518 NULL
119095 +set_queue_count_38519 set_queue_count 0 38519 NULL
119096 +ubifs_idx_node_sz_38546 ubifs_idx_node_sz 0-2 38546 NULL
119097 +btrfs_discard_extent_38547 btrfs_discard_extent 2 38547 NULL
119098 +kuc_len_38557 kuc_len 0-1 38557 NULL
119099 +irda_sendmsg_dgram_38563 irda_sendmsg_dgram 4 38563 NULL
119100 +il4965_rs_sta_dbgfs_scale_table_read_38564 il4965_rs_sta_dbgfs_scale_table_read 3 38564 NULL
119101 +_ipw_read32_38565 _ipw_read32 0 38565 NULL
119102 +snd_nm256_playback_copy_38567 snd_nm256_playback_copy 3-5 38567 NULL
119103 +copy_ctl_value_to_user_38587 copy_ctl_value_to_user 4 38587 NULL
119104 +rd_allocate_sgl_table_38607 rd_allocate_sgl_table 3 38607 NULL
119105 +icn_writecmd_38629 icn_writecmd 2 38629 NULL
119106 +write_enabled_file_bool_38630 write_enabled_file_bool 3 38630 NULL
119107 +ext2_readpages_38640 ext2_readpages 4 38640 NULL
119108 +audit_init_entry_38644 audit_init_entry 1 38644 NULL
119109 +qp_broker_alloc_38646 qp_broker_alloc 6-5 38646 NULL
119110 +mmc_send_cxd_data_38655 mmc_send_cxd_data 5 38655 NULL
119111 +nouveau_instmem_create__38664 nouveau_instmem_create_ 4 38664 NULL
119112 +snd_es1371_wait_src_ready_38673 snd_es1371_wait_src_ready 0 38673 NULL
119113 +nilfs_write_end_38674 nilfs_write_end 5 38674 NULL
119114 +iscsit_dump_data_payload_38683 iscsit_dump_data_payload 2 38683 NULL
119115 +ar5008_hw_rf_alloc_ext_banks_38689 ar5008_hw_rf_alloc_ext_banks 0 38689 NULL
119116 +validate_vid_hdr_38699 validate_vid_hdr 0 38699 NULL
119117 +rbio_add_io_page_38700 rbio_add_io_page 6 38700 NULL
119118 +cx18_streams_setup_38714 cx18_streams_setup 0 38714 NULL
119119 +zforce_send_wait_38720 zforce_send_wait 3 38720 NULL
119120 +w83977af_sir_interrupt_38738 w83977af_sir_interrupt 0 38738 NULL
119121 +udf_readpages_38761 udf_readpages 4 38761 NULL
119122 +si476x_core_i2c_xfer_38777 si476x_core_i2c_xfer 4 38777 NULL
119123 +iwl_dbgfs_thermal_throttling_read_38779 iwl_dbgfs_thermal_throttling_read 3 38779 NULL
119124 +bcache_device_init_38781 bcache_device_init 3 38781 NULL nohasharray
119125 +pt1_unlock_38781 pt1_unlock 0 38781 &bcache_device_init_38781
119126 +snd_gus_dram_write_38784 snd_gus_dram_write 4 38784 NULL
119127 +ican3_msg_connect_38785 ican3_msg_connect 0 38785 NULL
119128 +p54_set_leds_38787 p54_set_leds 0 38787 NULL
119129 +slab_order_38794 slab_order 0 38794 NULL
119130 +do_pci_enable_device_38802 do_pci_enable_device 0 38802 NULL
119131 +err_decode_38804 err_decode 2 38804 NULL
119132 +ipv6_renew_option_38813 ipv6_renew_option 3 38813 NULL
119133 +direct_entry_38836 direct_entry 3 38836 NULL
119134 +compat_udp_setsockopt_38840 compat_udp_setsockopt 5 38840 NULL
119135 +read_nic_io_word_38853 read_nic_io_word 0 38853 NULL
119136 +interfaces_38859 interfaces 2 38859 NULL
119137 +dbgfs_state_38894 dbgfs_state 3 38894 NULL
119138 +ei_open_38906 ei_open 0 38906 NULL
119139 +ntb_device_setup_38907 ntb_device_setup 0 38907 NULL
119140 +dev_set_name_38926 dev_set_name 0 38926 NULL
119141 +il_dbgfs_sram_write_38942 il_dbgfs_sram_write 3 38942 NULL
119142 +init_mediavision_38946 init_mediavision 0 38946 NULL
119143 +__ath6kl_wmi_send_mgmt_cmd_38971 __ath6kl_wmi_send_mgmt_cmd 7 38971 NULL
119144 +usb_maxpacket_38977 usb_maxpacket 0 38977 NULL nohasharray
119145 +C_SYSC_preadv64_38977 C_SYSC_preadv64 3 38977 &usb_maxpacket_38977
119146 +c2_alloc_mqsp_chunk_38982 c2_alloc_mqsp_chunk 0 38982 NULL
119147 +usb_parse_endpoint_38983 usb_parse_endpoint 0 38983 NULL
119148 +OSDSetBlock_38986 OSDSetBlock 2-4 38986 NULL
119149 +bio_clone_range_38997 bio_clone_range 2 38997 NULL
119150 +lpfc_idiag_extacc_write_38998 lpfc_idiag_extacc_write 3 38998 NULL
119151 +get_nodes_39012 get_nodes 3 39012 NULL
119152 +twl6030_interrupt_unmask_39013 twl6030_interrupt_unmask 2 39013 NULL
119153 +force_sc_support_read_39014 force_sc_support_read 3 39014 NULL
119154 +__blkdev_issue_zeroout_39020 __blkdev_issue_zeroout 3 39020 NULL
119155 +_zd_iowrite32v_async_locked_39034 _zd_iowrite32v_async_locked 3 39034 NULL
119156 +dwc2_phy_init_39049 dwc2_phy_init 0 39049 NULL
119157 +do_write_kmem_39051 do_write_kmem 0-1-3 39051 NULL
119158 +ReadHFC_39104 ReadHFC 0 39104 NULL
119159 +tomoyo_truncate_39105 tomoyo_truncate 0 39105 NULL
119160 +leb_write_lock_39111 leb_write_lock 0 39111 NULL
119161 +__kfifo_to_user_r_39123 __kfifo_to_user_r 5-3 39123 NULL
119162 +ea_foreach_39133 ea_foreach 0 39133 NULL
119163 +generic_permission_39150 generic_permission 0 39150 NULL
119164 +proc_coredump_filter_read_39153 proc_coredump_filter_read 3 39153 NULL
119165 +ath9k_hw_ar9003_dump_eeprom_39156 ath9k_hw_ar9003_dump_eeprom 5-4 39156 NULL
119166 +echo_client_kbrw_39170 echo_client_kbrw 6 39170 NULL
119167 +ext3_xattr_check_names_39174 ext3_xattr_check_names 0 39174 NULL
119168 +msr_device_create_39175 msr_device_create 0 39175 NULL
119169 +ubi_more_update_data_39189 ubi_more_update_data 4 39189 NULL nohasharray
119170 +ican3_startup_module_39189 ican3_startup_module 0 39189 &ubi_more_update_data_39189
119171 +qcam_read_bytes_39205 qcam_read_bytes 0 39205 NULL
119172 +v4l2_ctrl_handler_setup_39217 v4l2_ctrl_handler_setup 0 39217 NULL
119173 +ivtv_v4l2_write_39226 ivtv_v4l2_write 3 39226 NULL
119174 +posix_acl_to_xattr_39237 posix_acl_to_xattr 0 39237 NULL
119175 +snd_pcm_capture_forward_39248 snd_pcm_capture_forward 0-2 39248 NULL
119176 +r128_compat_ioctl_39250 r128_compat_ioctl 2 39250 NULL nohasharray
119177 +pwr_cont_miss_bcns_spread_read_39250 pwr_cont_miss_bcns_spread_read 3 39250 &r128_compat_ioctl_39250
119178 +i915_error_state_read_39254 i915_error_state_read 3 39254 NULL
119179 +rx_filter_protection_filter_read_39282 rx_filter_protection_filter_read 3 39282 NULL
119180 +_iwl_dbgfs_pm_params_write_39325 _iwl_dbgfs_pm_params_write 3 39325 NULL
119181 +__cfg80211_connect_result_39326 __cfg80211_connect_result 4-6 39326 NULL
119182 +insert_reserved_file_extent_39327 insert_reserved_file_extent 3 39327 NULL
119183 +xen_hvm_setup_msi_irqs_39342 xen_hvm_setup_msi_irqs 2 39342 NULL
119184 +wimax_msg_alloc_39343 wimax_msg_alloc 4 39343 NULL
119185 +ide_complete_rq_39354 ide_complete_rq 3 39354 NULL
119186 +gfs2_dir_write_data_39357 gfs2_dir_write_data 0-3-4 39357 NULL
119187 +do_write_log_from_user_39362 do_write_log_from_user 3-0 39362 NULL
119188 +vortex_wtdma_getlinearpos_39371 vortex_wtdma_getlinearpos 0 39371 NULL
119189 +regmap_name_read_file_39379 regmap_name_read_file 3 39379 NULL nohasharray
119190 +virtscsi_init_39379 virtscsi_init 0 39379 &regmap_name_read_file_39379
119191 +fnic_trace_debugfs_read_39380 fnic_trace_debugfs_read 3 39380 NULL
119192 +ps_poll_ps_poll_utilization_read_39383 ps_poll_ps_poll_utilization_read 3 39383 NULL
119193 +__send_to_port_39386 __send_to_port 3 39386 NULL
119194 +xfs_btree_dup_cursor_39394 xfs_btree_dup_cursor 0 39394 NULL
119195 +t4vf_fw_reset_39409 t4vf_fw_reset 0 39409 NULL
119196 +enic_dev_set_ig_vlan_rewrite_mode_39410 enic_dev_set_ig_vlan_rewrite_mode 0 39410 NULL
119197 +gfs2_internal_read_39413 gfs2_internal_read 0 39413 NULL
119198 +user_power_read_39414 user_power_read 3 39414 NULL
119199 +hash_ipmark4_expire_39419 hash_ipmark4_expire 4 39419 NULL
119200 +alloc_agpphysmem_i8xx_39427 alloc_agpphysmem_i8xx 1 39427 NULL
119201 +get_flash_params_39428 get_flash_params 0 39428 NULL
119202 +mic_desc_size_39464 mic_desc_size 0 39464 NULL
119203 +apei_resources_add_39470 apei_resources_add 0 39470 NULL
119204 +setkey_unaligned_39474 setkey_unaligned 3 39474 NULL
119205 +ieee80211_if_fmt_dot11MeshHWMPmaxPREQretries_39499 ieee80211_if_fmt_dot11MeshHWMPmaxPREQretries 3 39499 NULL
119206 +cl_req_alloc_39523 cl_req_alloc 4 39523 NULL
119207 +do_remove_conflicting_framebuffers_39527 do_remove_conflicting_framebuffers 0 39527 NULL nohasharray
119208 +bma180_set_new_data_intr_state_39527 bma180_set_new_data_intr_state 0 39527 &do_remove_conflicting_framebuffers_39527
119209 +ican3_new_send_msg_39533 ican3_new_send_msg 0 39533 NULL
119210 +int_proc_write_39542 int_proc_write 3 39542 NULL
119211 +ext4_alloc_file_blocks_39551 ext4_alloc_file_blocks 3 39551 NULL
119212 +pp_write_39554 pp_write 3 39554 NULL
119213 +service_buffer_allocate_39559 service_buffer_allocate 0 39559 NULL
119214 +datablob_format_39571 datablob_format 2 39571 NULL nohasharray
119215 +ieee80211_if_read_fwded_mcast_39571 ieee80211_if_read_fwded_mcast 3 39571 &datablob_format_39571
119216 +memblock_virt_alloc_internal_39600 memblock_virt_alloc_internal 1 39600 NULL
119217 +ipw_wdev_init_39604 ipw_wdev_init 0 39604 NULL
119218 +ext_depth_39607 ext_depth 0 39607 NULL
119219 +batadv_tt_tvlv_generate_39615 batadv_tt_tvlv_generate 4 39615 NULL
119220 +nfs_idmap_get_key_39616 nfs_idmap_get_key 2 39616 NULL
119221 +sdio_readb_39618 sdio_readb 0 39618 NULL
119222 +i2c_master_send_39619 i2c_master_send 0-3 39619 NULL
119223 +prepare_uptodate_page_39622 prepare_uptodate_page 0 39622 NULL
119224 +set_dev_class_39645 set_dev_class 4 39645 NULL
119225 +snd_rme32_capture_copy_39653 snd_rme32_capture_copy 5 39653 NULL
119226 +tcp_try_rmem_schedule_39657 tcp_try_rmem_schedule 3 39657 NULL
119227 +kvm_read_guest_cached_39666 kvm_read_guest_cached 4 39666 NULL
119228 +__dev_alloc_name_39670 __dev_alloc_name 0 39670 NULL
119229 +v4l_stk_read_39672 v4l_stk_read 3 39672 NULL
119230 +hsc_msg_len_get_39673 hsc_msg_len_get 0 39673 NULL
119231 +do_surface_dirty_sou_39678 do_surface_dirty_sou 7 39678 NULL
119232 +sd_completed_bytes_39705 sd_completed_bytes 0 39705 NULL
119233 +ftrace_pid_write_39710 ftrace_pid_write 3 39710 NULL
119234 +vnic_cq_alloc_39723 vnic_cq_alloc 0 39723 NULL
119235 +adt7316_spi_multi_read_39765 adt7316_spi_multi_read 3 39765 NULL
119236 +security_inode_listsecurity_39812 security_inode_listsecurity 0 39812 NULL
119237 +snd_pcm_oss_writev3_39818 snd_pcm_oss_writev3 3 39818 NULL nohasharray
119238 +iio_triggered_buffer_setup_39818 iio_triggered_buffer_setup 0 39818 &snd_pcm_oss_writev3_39818
119239 +ath10k_debug_create_39827 ath10k_debug_create 0 39827 NULL
119240 +get_priv_size_39828 get_priv_size 0-1 39828 NULL
119241 +ath5k_hw_set_capabilities_39847 ath5k_hw_set_capabilities 0 39847 NULL
119242 +tpkbd_probe_tp_39874 tpkbd_probe_tp 0 39874 NULL
119243 +pkt_add_39897 pkt_add 3 39897 NULL
119244 +read_file_modal_eeprom_39909 read_file_modal_eeprom 3 39909 NULL
119245 +gen_pool_add_virt_39913 gen_pool_add_virt 4 39913 NULL
119246 +dw210x_op_rw_39915 dw210x_op_rw 6 39915 NULL
119247 +__mnt_want_write_file_39917 __mnt_want_write_file 0 39917 NULL
119248 +aes_encrypt_interrupt_read_39919 aes_encrypt_interrupt_read 3 39919 NULL
119249 +oom_score_adj_read_39921 oom_score_adj_read 3 39921 NULL nohasharray
119250 +exofs_read_kern_39921 exofs_read_kern 6 39921 &oom_score_adj_read_39921
119251 +__spi_async_39932 __spi_async 0 39932 NULL
119252 +__get_order_39935 __get_order 0 39935 NULL
119253 +error_error_frame_read_39947 error_error_frame_read 3 39947 NULL
119254 +usb_get_device_descriptor_39951 usb_get_device_descriptor 0 39951 NULL
119255 +tty_prepare_flip_string_39955 tty_prepare_flip_string 3-0 39955 NULL
119256 +lstcon_group_list_39958 lstcon_group_list 2 39958 NULL
119257 +bio_chain_clone_range_39967 bio_chain_clone_range 3 39967 NULL
119258 +dma_push_rx_39973 dma_push_rx 2 39973 NULL
119259 +broadsheetfb_write_39976 broadsheetfb_write 3 39976 NULL
119260 +mthca_array_init_39987 mthca_array_init 2 39987 NULL
119261 +fw_device_op_read_39990 fw_device_op_read 3 39990 NULL
119262 +server_name2svname_39998 server_name2svname 4 39998 NULL
119263 +xen_hvm_config_40018 xen_hvm_config 2 40018 NULL
119264 +ivtvfb_write_40023 ivtvfb_write 3 40023 NULL
119265 +disc_pwup_write_40027 disc_pwup_write 3 40027 NULL
119266 +ea_foreach_i_40028 ea_foreach_i 0 40028 NULL
119267 +datablob_hmac_append_40038 datablob_hmac_append 3 40038 NULL
119268 +pci_set_consistent_dma_mask_40050 pci_set_consistent_dma_mask 0 40050 NULL
119269 +l2cap_create_iframe_pdu_40055 l2cap_create_iframe_pdu 3 40055 NULL nohasharray
119270 +add_tty_40055 add_tty 1 40055 &l2cap_create_iframe_pdu_40055
119271 +igb_request_msix_40067 igb_request_msix 0 40067 NULL
119272 +atomic_xchg_40070 atomic_xchg 0 40070 NULL
119273 +snd_pcm_sw_params_user_40095 snd_pcm_sw_params_user 0 40095 NULL
119274 +mpt_handshake_req_reply_wait_40097 mpt_handshake_req_reply_wait 0 40097 NULL
119275 +xfs_rtbuf_get_40107 xfs_rtbuf_get 0 40107 NULL
119276 +gen_pool_first_fit_40110 gen_pool_first_fit 4 40110 NULL
119277 +sctp_setsockopt_delayed_ack_40129 sctp_setsockopt_delayed_ack 3 40129 NULL
119278 +dwc2_max_desc_num_40132 dwc2_max_desc_num 0 40132 NULL nohasharray
119279 +reg_read_range_40132 reg_read_range 4 40132 &dwc2_max_desc_num_40132
119280 +rx_rx_frame_checksum_read_40140 rx_rx_frame_checksum_read 3 40140 NULL
119281 +ath10k_write_simulate_fw_crash_40143 ath10k_write_simulate_fw_crash 3 40143 NULL
119282 +iwch_alloc_fastreg_pbl_40153 iwch_alloc_fastreg_pbl 2 40153 NULL
119283 +asd_map_ioport_40157 asd_map_ioport 0 40157 NULL
119284 +pt_write_40159 pt_write 3 40159 NULL
119285 +lis3lv02d_poweron_40163 lis3lv02d_poweron 0 40163 NULL
119286 +scsi_sg_count_40182 scsi_sg_count 0 40182 NULL
119287 +ipr_alloc_ucode_buffer_40199 ipr_alloc_ucode_buffer 1 40199 NULL
119288 +allocate_probes_40204 allocate_probes 1 40204 NULL
119289 +sync_cached_firmware_buf_40217 sync_cached_firmware_buf 0 40217 NULL
119290 +au0828_v4l2_read_40220 au0828_v4l2_read 3 40220 NULL
119291 +compress_file_range_40225 compress_file_range 3-4 40225 NULL
119292 +ocrdma_dbgfs_ops_read_40232 ocrdma_dbgfs_ops_read 3 40232 NULL
119293 +osst_read_40237 osst_read 3 40237 NULL
119294 +lpage_info_slot_40243 lpage_info_slot 3-1 40243 NULL
119295 +ocfs2_zero_extend_get_range_40248 ocfs2_zero_extend_get_range 4-3 40248 NULL
119296 +of_get_child_count_40254 of_get_child_count 0 40254 NULL
119297 +rs_sta_dbgfs_scale_table_read_40262 rs_sta_dbgfs_scale_table_read 3 40262 NULL
119298 +ext2_fiemap_40271 ext2_fiemap 4 40271 NULL
119299 +snd_at73c213_chip_init_40274 snd_at73c213_chip_init 0 40274 NULL
119300 +usbnet_read_cmd_40275 usbnet_read_cmd 7 40275 NULL
119301 +rx_xfr_hint_trig_read_40283 rx_xfr_hint_trig_read 3 40283 NULL
119302 +SyS_bind_40303 SyS_bind 3 40303 NULL
119303 +ubi_io_write_data_40305 ubi_io_write_data 0 40305 NULL
119304 +ib_get_mad_data_offset_40336 ib_get_mad_data_offset 0 40336 NULL
119305 +of_irq_parse_raw_40339 of_irq_parse_raw 0 40339 NULL
119306 +mmio_read_40348 mmio_read 4 40348 NULL
119307 +event_rx_mem_empty_read_40363 event_rx_mem_empty_read 3 40363 NULL
119308 +ocfs2_check_range_for_refcount_40365 ocfs2_check_range_for_refcount 2-3 40365 NULL
119309 +mthca_map_eq_icm_40370 mthca_map_eq_icm 0 40370 NULL
119310 +get_chars_40373 get_chars 3 40373 NULL
119311 +_vnic_dev_cmd_40377 _vnic_dev_cmd 0 40377 NULL
119312 +asd_seq_start_lseq_40403 asd_seq_start_lseq 0 40403 NULL
119313 +ecryptfs_read_lower_40419 ecryptfs_read_lower 3 40419 NULL
119314 +fb_prepare_extra_logos_40429 fb_prepare_extra_logos 0-2 40429 NULL
119315 +vq_send_wr_40447 vq_send_wr 0 40447 NULL
119316 +il4965_request_firmware_40453 il4965_request_firmware 0 40453 NULL
119317 +tomoyo_update_policy_40458 tomoyo_update_policy 2 40458 NULL
119318 +zd_usb_scnprint_id_40459 zd_usb_scnprint_id 0-3 40459 NULL
119319 +gp2ap020a00f_write_event_threshold_40461 gp2ap020a00f_write_event_threshold 2 40461 NULL
119320 +SyS_writev_40467 SyS_writev 3 40467 NULL
119321 +SyS_select_40473 SyS_select 1 40473 NULL
119322 +spu_write_u16_40480 spu_write_u16 0 40480 NULL
119323 +afs_fs_store_data_40484 afs_fs_store_data 3-4-5-6 40484 NULL
119324 +batadv_hash_new_40491 batadv_hash_new 1 40491 NULL
119325 +devcgroup_inode_permission_40492 devcgroup_inode_permission 0 40492 NULL
119326 +ath5k_init_40493 ath5k_init 0 40493 NULL
119327 +sg_phys_40507 sg_phys 0 40507 NULL
119328 +xfs_iread_extents_40510 xfs_iread_extents 0 40510 NULL
119329 +__ethtool_get_sset_count_40511 __ethtool_get_sset_count 0 40511 NULL
119330 +TSS_checkhmac2_40520 TSS_checkhmac2 5-7 40520 NULL
119331 +slab_mem_going_offline_callback_40525 slab_mem_going_offline_callback 0 40525 NULL
119332 +ixgbe_dbg_reg_ops_read_40540 ixgbe_dbg_reg_ops_read 3 40540 NULL
119333 +ima_write_policy_40548 ima_write_policy 3 40548 NULL
119334 +esp_alloc_tmp_40558 esp_alloc_tmp 3-2 40558 NULL
119335 +ssb_pci_xtal_40581 ssb_pci_xtal 0 40581 NULL
119336 +b1_get_byte_40597 b1_get_byte 0 40597 NULL
119337 +get_priv_descr_and_size_40612 get_priv_descr_and_size 0 40612 NULL
119338 +i2c_register_adapter_40660 i2c_register_adapter 0 40660 NULL
119339 +twl4030_kpwrite_u8_40665 twl4030_kpwrite_u8 3 40665 NULL
119340 +__cfg80211_roamed_40668 __cfg80211_roamed 4-6 40668 NULL
119341 +pipeline_rx_complete_stat_fifo_int_read_40671 pipeline_rx_complete_stat_fifo_int_read 3 40671 NULL
119342 +fops_read_40672 fops_read 3 40672 NULL
119343 +idr_get_empty_slot_40674 idr_get_empty_slot 0 40674 NULL
119344 +alloc_rbio_40676 alloc_rbio 4 40676 NULL
119345 +videobuf_dma_init_user_locked_40678 videobuf_dma_init_user_locked 4-3 40678 NULL
119346 +pci_enable_resources_40680 pci_enable_resources 0 40680 NULL
119347 +regulator_enable_40689 regulator_enable 0 40689 NULL
119348 +nfc_hci_set_param_40697 nfc_hci_set_param 5 40697 NULL
119349 +__seq_open_private_40715 __seq_open_private 3 40715 NULL
119350 +ip_skb_dst_mtu_40718 ip_skb_dst_mtu 0 40718 NULL
119351 +set_extent_bit_40719 set_extent_bit 0 40719 NULL
119352 +of_pdt_build_one_prop_40735 of_pdt_build_one_prop 5 40735 NULL
119353 +fuse_readpages_40737 fuse_readpages 4 40737 NULL
119354 +xfs_iext_remove_direct_40744 xfs_iext_remove_direct 3 40744 NULL
119355 +security_inode_listxattr_40752 security_inode_listxattr 0 40752 NULL
119356 +card_send_command_40757 card_send_command 3 40757 NULL
119357 +ad1889_readl_40765 ad1889_readl 0 40765 NULL
119358 +pg_write_40766 pg_write 3 40766 NULL
119359 +kernfs_fop_read_40770 kernfs_fop_read 3 40770 NULL
119360 +show_list_40775 show_list 3-0 40775 NULL
119361 +kfifo_out_copy_r_40784 kfifo_out_copy_r 3-0 40784 NULL
119362 +bitmap_weight_40791 bitmap_weight 0-2 40791 NULL
119363 +pyra_sysfs_read_40795 pyra_sysfs_read 6 40795 NULL
119364 +amradio_send_cmd_40800 amradio_send_cmd 0 40800 NULL
119365 +rtw_add_beacon_40801 rtw_add_beacon 3-5 40801 NULL
119366 +add_action_40811 add_action 4 40811 NULL
119367 +nl80211_send_roamed_40825 nl80211_send_roamed 5-7 40825 NULL
119368 +SyS_mbind_40828 SyS_mbind 5 40828 NULL
119369 +__mlx4_qp_reserve_range_40847 __mlx4_qp_reserve_range 2-3 40847 NULL
119370 +nilfs_mdt_init_40849 nilfs_mdt_init 3 40849 NULL
119371 +va1j5jf8007t_init_frequency_40852 va1j5jf8007t_init_frequency 0 40852 NULL
119372 +v9fs_file_read_40858 v9fs_file_read 3 40858 NULL
119373 +read_file_queue_40895 read_file_queue 3 40895 NULL
119374 +waiters_read_40902 waiters_read 3 40902 NULL
119375 +isdn_add_channels_40905 isdn_add_channels 3 40905 NULL
119376 +gfs2_ea_find_40913 gfs2_ea_find 0 40913 NULL
119377 +vol_cdev_write_40915 vol_cdev_write 3 40915 NULL
119378 +snd_vx_create_40948 snd_vx_create 4 40948 NULL nohasharray
119379 +sg_alloc_table_40948 sg_alloc_table 0 40948 &snd_vx_create_40948
119380 +wm8994_free_irq_40951 wm8994_free_irq 2 40951 NULL
119381 +uaa_to_xfi_40965 uaa_to_xfi 0 40965 NULL
119382 +rds_sendmsg_40976 rds_sendmsg 4 40976 NULL
119383 +insert_old_idx_40987 insert_old_idx 0 40987 NULL
119384 +il_dbgfs_fh_reg_read_40993 il_dbgfs_fh_reg_read 3 40993 NULL
119385 +iwl_dbgfs_scan_ant_rxchain_read_40999 iwl_dbgfs_scan_ant_rxchain_read 3 40999 NULL nohasharray
119386 +bmp085_init_client_40999 bmp085_init_client 0 40999 &iwl_dbgfs_scan_ant_rxchain_read_40999
119387 +mac80211_format_buffer_41010 mac80211_format_buffer 2 41010 NULL
119388 +mtd_block_isbad_41015 mtd_block_isbad 0 41015 NULL
119389 +__proc_dobitmasks_41029 __proc_dobitmasks 5 41029 NULL
119390 +_req_append_segment_41031 _req_append_segment 2 41031 NULL
119391 +mISDN_sock_sendmsg_41035 mISDN_sock_sendmsg 4 41035 NULL
119392 +ocfs2_xattr_index_block_find_41040 ocfs2_xattr_index_block_find 0 41040 NULL
119393 +lprocfs_write_frac_helper_41050 lprocfs_write_frac_helper 2 41050 NULL
119394 +calculate_order_41061 calculate_order 0 41061 NULL
119395 +vfs_listxattr_41062 vfs_listxattr 0 41062 NULL nohasharray
119396 +beacon_filtering_write_41062 beacon_filtering_write 3 41062 &vfs_listxattr_41062
119397 +sc_only_mode_read_41076 sc_only_mode_read 3 41076 NULL
119398 +cfg80211_inform_bss_frame_41078 cfg80211_inform_bss_frame 4 41078 NULL
119399 +nvme_map_user_pages_41093 nvme_map_user_pages 4-3 41093 NULL nohasharray
119400 +roccat_read_41093 roccat_read 3 41093 &nvme_map_user_pages_41093
119401 +dma_attach_41094 dma_attach 5-6 41094 NULL
119402 +provide_user_output_41105 provide_user_output 3 41105 NULL
119403 +f_audio_buffer_alloc_41110 f_audio_buffer_alloc 1 41110 NULL
119404 +ath10k_read_wmi_services_41112 ath10k_read_wmi_services 3 41112 NULL
119405 +ocfs2_extend_trans_41116 ocfs2_extend_trans 0 41116 NULL
119406 +if_spi_init_card_41148 if_spi_init_card 0 41148 NULL
119407 +v4l2_ctrl_new_int_menu_41151 v4l2_ctrl_new_int_menu 4 41151 NULL
119408 +drm_global_item_ref_41157 drm_global_item_ref 0 41157 NULL
119409 +tx_frag_mpdu_alloc_failed_read_41167 tx_frag_mpdu_alloc_failed_read 3 41167 NULL
119410 +dvb_ca_write_41171 dvb_ca_write 3 41171 NULL
119411 +netif_get_num_default_rss_queues_41187 netif_get_num_default_rss_queues 0 41187 NULL
119412 +request_irq_41192 request_irq 0 41192 NULL
119413 +dfs_file_write_41196 dfs_file_write 3 41196 NULL
119414 +nfs_page_array_len_41219 nfs_page_array_len 0-2-1 41219 NULL
119415 +setup_rss_41225 setup_rss 0 41225 NULL
119416 +cfg80211_process_disassoc_41231 cfg80211_process_disassoc 3 41231 NULL
119417 +hiddev_compat_ioctl_41255 hiddev_compat_ioctl 2 41255 NULL
119418 +erst_read_41260 erst_read 0 41260 NULL
119419 +alloc_context_41283 alloc_context 1 41283 NULL
119420 +of_count_phandle_with_args_41291 of_count_phandle_with_args 0 41291 NULL
119421 +bcm2048_sysfs_register_properties_41337 bcm2048_sysfs_register_properties 0 41337 NULL
119422 +o2hb_setup_one_bio_41341 o2hb_setup_one_bio 4 41341 NULL
119423 +twl_change_queue_depth_41342 twl_change_queue_depth 2 41342 NULL
119424 +rtw_android_set_block_41347 rtw_android_set_block 0 41347 NULL
119425 +ceph_do_getattr_41349 ceph_do_getattr 0 41349 NULL
119426 +irq_expand_nr_irqs_41351 irq_expand_nr_irqs 0 41351 NULL
119427 +cnic_init_id_tbl_41354 cnic_init_id_tbl 2 41354 NULL
119428 +kmp_init_41373 kmp_init 2 41373 NULL
119429 +tifm_add_adapter_41390 tifm_add_adapter 0 41390 NULL
119430 +isr_commands_read_41398 isr_commands_read 3 41398 NULL
119431 +rx_defrag_decrypt_failed_read_41411 rx_defrag_decrypt_failed_read 3 41411 NULL
119432 +xfs_iext_add_41422 xfs_iext_add 3 41422 NULL
119433 +isdn_ppp_fill_rq_41428 isdn_ppp_fill_rq 2 41428 NULL
119434 +lbs_rdrf_read_41431 lbs_rdrf_read 3 41431 NULL
119435 +iio_device_alloc_41440 iio_device_alloc 1 41440 NULL
119436 +ntfs_file_buffered_write_41442 ntfs_file_buffered_write 6-4-0 41442 NULL
119437 +pcpu_build_alloc_info_41443 pcpu_build_alloc_info 1-2-3 41443 NULL
119438 +se_io_cb_41461 se_io_cb 3 41461 NULL
119439 +layout_leb_in_gaps_41470 layout_leb_in_gaps 0 41470 NULL
119440 +snd_pcm_status_41472 snd_pcm_status 0 41472 NULL
119441 +rt2x00debug_write_rfcsr_41473 rt2x00debug_write_rfcsr 3 41473 NULL
119442 +bl_alloc_init_bio_41478 bl_alloc_init_bio 1 41478 NULL
119443 +kvm_unmap_hva_range_41484 kvm_unmap_hva_range 2-3 41484 NULL
119444 +wep_interrupt_read_41492 wep_interrupt_read 3 41492 NULL
119445 +SyS_get_mempolicy_41495 SyS_get_mempolicy 3 41495 NULL
119446 +hpfs_translate_name_41497 hpfs_translate_name 3 41497 NULL
119447 +xfrm_hash_new_size_41505 xfrm_hash_new_size 0-1 41505 NULL
119448 +SyS_preadv_41523 SyS_preadv 3 41523 NULL
119449 +em28xx_is_ac97_ready_41524 em28xx_is_ac97_ready 0 41524 NULL
119450 +dm_get_reserved_rq_based_ios_41529 dm_get_reserved_rq_based_ios 0 41529 NULL
119451 +tx_tx_frame_checksum_read_41553 tx_tx_frame_checksum_read 3 41553 NULL
119452 +ath6kl_endpoint_stats_read_41554 ath6kl_endpoint_stats_read 3 41554 NULL
119453 +nr_status_frames_41559 nr_status_frames 0-1 41559 NULL nohasharray
119454 +si476x_radio_fops_read_41559 si476x_radio_fops_read 3 41559 &nr_status_frames_41559
119455 +t1_sge_configure_41576 t1_sge_configure 0 41576 NULL
119456 +rng_dev_read_41581 rng_dev_read 3 41581 NULL
119457 +batadv_tvlv_container_ogm_append_41588 batadv_tvlv_container_ogm_append 4 41588 NULL
119458 +__snd_device_register_41590 __snd_device_register 0 41590 NULL
119459 +vga_io_r_41609 vga_io_r 0 41609 NULL
119460 +tcp_hdrlen_41610 tcp_hdrlen 0 41610 NULL
119461 +lbs_bcnmiss_write_41613 lbs_bcnmiss_write 3 41613 NULL nohasharray
119462 +usb_endpoint_maxp_41613 usb_endpoint_maxp 0 41613 &lbs_bcnmiss_write_41613
119463 +a2mp_send_41615 a2mp_send 4 41615 NULL
119464 +lstcon_batch_list_41627 lstcon_batch_list 2 41627 NULL
119465 +mempool_create_kmalloc_pool_41650 mempool_create_kmalloc_pool 1 41650 NULL
119466 +rx_rx_pre_complt_read_41653 rx_rx_pre_complt_read 3 41653 NULL
119467 +get_std_timing_41654 get_std_timing 0 41654 NULL
119468 +ieee80211_if_fmt_bssid_41677 ieee80211_if_fmt_bssid 3 41677 NULL
119469 +raw_notifier_call_chain_41679 raw_notifier_call_chain 0 41679 NULL
119470 +fill_pcm_stream_name_41685 fill_pcm_stream_name 2 41685 NULL
119471 +lov_unpackmd_41701 lov_unpackmd 4 41701 NULL
119472 +apei_exec_for_each_entry_41717 apei_exec_for_each_entry 0 41717 NULL
119473 +pt1_sync_41718 pt1_sync 0 41718 NULL
119474 +fillonedir_41746 fillonedir 3 41746 NULL
119475 +bus_add_driver_41783 bus_add_driver 0 41783 NULL
119476 +iwl_dbgfs_bt_notif_read_41794 iwl_dbgfs_bt_notif_read 3 41794 NULL
119477 +mlx4_mtt_init_41798 mlx4_mtt_init 0 41798 NULL
119478 +hsi_alloc_controller_41802 hsi_alloc_controller 1 41802 NULL
119479 +rtw_android_get_macaddr_41812 rtw_android_get_macaddr 0 41812 NULL nohasharray
119480 +fat_write_end_41812 fat_write_end 5 41812 &rtw_android_get_macaddr_41812
119481 +da9052_enable_irq_41814 da9052_enable_irq 2 41814 NULL
119482 +sco_send_frame_41815 sco_send_frame 3 41815 NULL
119483 +lp_gpio_to_irq_41822 lp_gpio_to_irq 2 41822 NULL
119484 +ixgbe_dbg_netdev_ops_read_41839 ixgbe_dbg_netdev_ops_read 3 41839 NULL
119485 +do_ip_setsockopt_41852 do_ip_setsockopt 5 41852 NULL
119486 +keyctl_instantiate_key_41855 keyctl_instantiate_key 3 41855 NULL
119487 +carm_init_shm_41861 carm_init_shm 0 41861 NULL
119488 +xfs_rtget_summary_41864 xfs_rtget_summary 0 41864 NULL
119489 +pci_map_single_41869 pci_map_single 0 41869 NULL
119490 +usb_gadget_get_string_41871 usb_gadget_get_string 0 41871 NULL
119491 +mthca_mr_alloc_phys_41882 mthca_mr_alloc_phys 0 41882 NULL
119492 +mpt_do_ioc_recovery_41894 mpt_do_ioc_recovery 0 41894 NULL
119493 +v_APCI3120_InterruptDmaMoveBlock16bit_41914 v_APCI3120_InterruptDmaMoveBlock16bit 4 41914 NULL
119494 +get_fdb_entries_41916 get_fdb_entries 3 41916 NULL
119495 +build_inv_iotlb_pages_41922 build_inv_iotlb_pages 4-5 41922 NULL
119496 +ext4_da_write_inline_data_begin_41935 ext4_da_write_inline_data_begin 3-4 41935 NULL
119497 +sci_rxfill_41945 sci_rxfill 0 41945 NULL
119498 +read_gssp_41947 read_gssp 3 41947 NULL
119499 +ocfs2_xattr_bucket_get_name_value_41949 ocfs2_xattr_bucket_get_name_value 0 41949 NULL
119500 +portnames_read_41958 portnames_read 3 41958 NULL
119501 +ubi_self_check_all_ff_41959 ubi_self_check_all_ff 0 41959 NULL
119502 +dst_mtu_41969 dst_mtu 0 41969 NULL
119503 +cx24116_writeregN_41975 cx24116_writeregN 4 41975 NULL
119504 +load_firmware_41977 load_firmware 0 41977 NULL
119505 +ubi_io_is_bad_41983 ubi_io_is_bad 0 41983 NULL
119506 +xfs_qm_dqalloc_41985 xfs_qm_dqalloc 0 41985 NULL
119507 +em28xx_write_regs_41996 em28xx_write_regs 0 41996 NULL
119508 +be_process_mcc_42002 be_process_mcc 0 42002 NULL
119509 +pool_allocate_42012 pool_allocate 3 42012 NULL
119510 +spidev_sync_read_42014 spidev_sync_read 0 42014 NULL
119511 +rs_sta_dbgfs_scale_table_write_42017 rs_sta_dbgfs_scale_table_write 3 42017 NULL
119512 +acpi_ut_create_buffer_object_42030 acpi_ut_create_buffer_object 1 42030 NULL
119513 +ql_cam_route_initialize_42031 ql_cam_route_initialize 0 42031 NULL
119514 +__hwahc_op_set_gtk_42038 __hwahc_op_set_gtk 4 42038 NULL
119515 +alloc_trace_kprobe_42041 alloc_trace_kprobe 6 42041 NULL
119516 +irda_sendmsg_ultra_42047 irda_sendmsg_ultra 4 42047 NULL
119517 +jffs2_do_link_42048 jffs2_do_link 6 42048 NULL
119518 +ps_poll_upsd_max_ap_turn_read_42050 ps_poll_upsd_max_ap_turn_read 3 42050 NULL
119519 +InterfaceTransmitPacket_42058 InterfaceTransmitPacket 3 42058 NULL
119520 +ql_write_cfg_42074 ql_write_cfg 0 42074 NULL
119521 +si4713_powerdown_42078 si4713_powerdown 0 42078 NULL
119522 +cx18_stream_alloc_42084 cx18_stream_alloc 0 42084 NULL
119523 +scsi_execute_req_42088 scsi_execute_req 5 42088 NULL
119524 +sk_chk_filter_42095 sk_chk_filter 2 42095 NULL
119525 +sh_eth_reset_42097 sh_eth_reset 0 42097 NULL
119526 +submit_inquiry_42108 submit_inquiry 3 42108 NULL
119527 +dw_dma_cyclic_prep_42113 dw_dma_cyclic_prep 3-4 42113 NULL
119528 +mthca_MAD_IFC_42144 mthca_MAD_IFC 0 42144 NULL
119529 +blk_ioctl_zeroout_42160 blk_ioctl_zeroout 3 42160 NULL
119530 +mmc_align_data_size_42161 mmc_align_data_size 0-2 42161 NULL
119531 +hpsa_init_reset_devices_42162 hpsa_init_reset_devices 0 42162 NULL
119532 +asd_verify_seq_42165 asd_verify_seq 0 42165 NULL
119533 +read_file_base_eeprom_42168 read_file_base_eeprom 3 42168 NULL
119534 +oprofilefs_str_to_user_42182 oprofilefs_str_to_user 3 42182 NULL
119535 +write_file_beacon_42185 write_file_beacon 3 42185 NULL
119536 +get_znodes_to_commit_42201 get_znodes_to_commit 0 42201 NULL
119537 +detach_if_pending_42219 detach_if_pending 0 42219 NULL
119538 +pla_ocp_read_42235 pla_ocp_read 3 42235 NULL
119539 +pci_user_read_config_word_42240 pci_user_read_config_word 0 42240 NULL
119540 +xfs_rtfree_range_42244 xfs_rtfree_range 0 42244 NULL
119541 +rx_defrag_need_decrypt_read_42253 rx_defrag_need_decrypt_read 3 42253 NULL
119542 +find_last_bit_42260 find_last_bit 0 42260 NULL nohasharray
119543 +ar9002_hw_init_mode_regs_42260 ar9002_hw_init_mode_regs 0 42260 &find_last_bit_42260
119544 +__pcpu_size_to_slot_42271 __pcpu_size_to_slot 0 42271 NULL
119545 +__tty_buffer_request_room_42276 __tty_buffer_request_room 2-0 42276 NULL
119546 +snd_pcm_hw_param_value_max_42280 snd_pcm_hw_param_value_max 0 42280 NULL
119547 +__cpus_weight_42299 __cpus_weight 2-0 42299 NULL
119548 +sel_read_perm_42302 sel_read_perm 3 42302 NULL
119549 +sctp_setsockopt_del_key_42304 sctp_setsockopt_del_key 3 42304 NULL nohasharray
119550 +ulong_read_file_42304 ulong_read_file 3 42304 &sctp_setsockopt_del_key_42304
119551 +xfs_vm_readpages_42308 xfs_vm_readpages 4 42308 NULL
119552 +hysdn_conf_read_42324 hysdn_conf_read 3 42324 NULL nohasharray
119553 +lpfc_config_msi_42324 lpfc_config_msi 0 42324 &hysdn_conf_read_42324
119554 +tcp_sync_mss_42330 tcp_sync_mss 2-0 42330 NULL
119555 +ide_raw_taskfile_42355 ide_raw_taskfile 4 42355 NULL
119556 +drbd_md_last_sector_42378 drbd_md_last_sector 0 42378 NULL
119557 +il_dbgfs_disable_ht40_read_42386 il_dbgfs_disable_ht40_read 3 42386 NULL
119558 +msnd_fifo_read_42406 msnd_fifo_read 0-3 42406 NULL
119559 +krng_get_random_42420 krng_get_random 3 42420 NULL
119560 +__iio_add_chan_devattr_42434 __iio_add_chan_devattr 0 42434 NULL
119561 +gsm_data_alloc_42437 gsm_data_alloc 3 42437 NULL
119562 +spr_wm_latency_write_42441 spr_wm_latency_write 3 42441 NULL
119563 +key_conf_keyidx_read_42443 key_conf_keyidx_read 3 42443 NULL
119564 +gpio_direction_input_42445 gpio_direction_input 0 42445 NULL
119565 +snd_pcm_action_group_42452 snd_pcm_action_group 0 42452 NULL
119566 +tcm_loop_change_queue_depth_42454 tcm_loop_change_queue_depth 2 42454 NULL
119567 +kuc_free_42455 kuc_free 2 42455 NULL
119568 +__clk_enable_42456 __clk_enable 0 42456 NULL
119569 +cp2112_gpio_get_42467 cp2112_gpio_get 2 42467 NULL
119570 +__simple_xattr_set_42474 __simple_xattr_set 4 42474 NULL
119571 +omfs_readpages_42490 omfs_readpages 4 42490 NULL
119572 +bypass_write_42498 bypass_write 3 42498 NULL
119573 +SyS_mincore_42511 SyS_mincore 2-1 42511 NULL
119574 +kvm_write_wall_clock_42520 kvm_write_wall_clock 2 42520 NULL
119575 +dio_bio_complete_42524 dio_bio_complete 0 42524 NULL
119576 +smk_write_netlbladdr_42525 smk_write_netlbladdr 3 42525 NULL
119577 +self_check_ec_hdr_42528 self_check_ec_hdr 0 42528 NULL
119578 +dbAllocNear_42546 dbAllocNear 0 42546 NULL
119579 +ath6kl_wmi_proc_events_vif_42549 ath6kl_wmi_proc_events_vif 5 42549 NULL
119580 +request_firmware_42553 request_firmware 0 42553 NULL
119581 +udp_recvmsg_42558 udp_recvmsg 4 42558 NULL
119582 +iwl_print_event_log_42566 iwl_print_event_log 0-5-7 42566 NULL
119583 +ocfs2_reserve_suballoc_bits_42569 ocfs2_reserve_suballoc_bits 0 42569 NULL
119584 +xfrm_new_hash_mask_42579 xfrm_new_hash_mask 0-1 42579 NULL
119585 +t4_fw_upgrade_42586 t4_fw_upgrade 0 42586 NULL
119586 +oom_score_adj_write_42594 oom_score_adj_write 3 42594 NULL
119587 +p54_register_led_42634 p54_register_led 0 42634 NULL
119588 +ieee80211_if_fmt_dot11MeshHWMPactivePathTimeout_42635 ieee80211_if_fmt_dot11MeshHWMPactivePathTimeout 3 42635 NULL
119589 +scsi_activate_tcq_42640 scsi_activate_tcq 2 42640 NULL
119590 +br_mdb_rehash_42643 br_mdb_rehash 2 42643 NULL
119591 +parport_pc_compat_write_block_pio_42644 parport_pc_compat_write_block_pio 3 42644 NULL
119592 +_regmap_raw_write_42652 _regmap_raw_write 4-2 42652 NULL
119593 +ocfs2_search_chain_42655 ocfs2_search_chain 0 42655 NULL
119594 +request_key_and_link_42693 request_key_and_link 4 42693 NULL
119595 +vb2_read_42703 vb2_read 3 42703 NULL nohasharray
119596 +stex_ss_handshake_42703 stex_ss_handshake 0 42703 &vb2_read_42703
119597 +__ocfs2_decrease_refcount_42717 __ocfs2_decrease_refcount 0 42717 NULL
119598 +remove_fs_rule_ok_42720 remove_fs_rule_ok 0 42720 NULL
119599 +read_status_42722 read_status 0 42722 NULL
119600 +dvb_demux_ioctl_42733 dvb_demux_ioctl 2 42733 NULL nohasharray
119601 +fw_get_filesystem_firmware_42733 fw_get_filesystem_firmware 0 42733 &dvb_demux_ioctl_42733
119602 +set_aoe_iflist_42737 set_aoe_iflist 2 42737 NULL
119603 +ax25_setsockopt_42740 ax25_setsockopt 5 42740 NULL
119604 +dpm_sysfs_add_42756 dpm_sysfs_add 0 42756 NULL
119605 +ath10k_htt_verify_version_42776 ath10k_htt_verify_version 0 42776 NULL
119606 +x25_recvmsg_42777 x25_recvmsg 4 42777 NULL
119607 +snd_midi_event_decode_42780 snd_midi_event_decode 0 42780 NULL
119608 +cryptd_hash_setkey_42781 cryptd_hash_setkey 3 42781 NULL nohasharray
119609 +isku_sysfs_read_info_42781 isku_sysfs_read_info 6 42781 &cryptd_hash_setkey_42781
119610 +elfcorehdr_read_notes_42786 elfcorehdr_read_notes 2 42786 NULL
119611 +koneplus_sysfs_read_42792 koneplus_sysfs_read 6 42792 NULL
119612 +ntfs_attr_extend_allocation_42796 ntfs_attr_extend_allocation 0 42796 NULL
119613 +fw_device_op_compat_ioctl_42804 fw_device_op_compat_ioctl 2 42804 NULL nohasharray
119614 +bma180_soft_reset_42804 bma180_soft_reset 0 42804 &fw_device_op_compat_ioctl_42804
119615 +drm_ioctl_42813 drm_ioctl 2 42813 NULL
119616 +iwl_dbgfs_ucode_bt_stats_read_42820 iwl_dbgfs_ucode_bt_stats_read 3 42820 NULL
119617 +set_arg_42824 set_arg 3 42824 NULL
119618 +si476x_radio_read_rsq_blob_42827 si476x_radio_read_rsq_blob 3 42827 NULL
119619 +add_port_42840 add_port 0 42840 NULL
119620 +t4_sge_alloc_rxq_42871 t4_sge_alloc_rxq 0 42871 NULL nohasharray
119621 +snd_device_register_all_42871 snd_device_register_all 0 42871 &t4_sge_alloc_rxq_42871
119622 +ocfs2_clusters_for_bytes_42872 ocfs2_clusters_for_bytes 0-2 42872 NULL
119623 +nvme_trans_unit_serial_page_42879 nvme_trans_unit_serial_page 4 42879 NULL
119624 +xpc_kmalloc_cacheline_aligned_42895 xpc_kmalloc_cacheline_aligned 1 42895 NULL
119625 +ath10k_init_download_firmware_42899 ath10k_init_download_firmware 0 42899 NULL
119626 +hd_end_request_42904 hd_end_request 2 42904 NULL nohasharray
119627 +smsc911x_enable_resources_42904 smsc911x_enable_resources 0 42904 &hd_end_request_42904
119628 +sta_last_rx_rate_read_42909 sta_last_rx_rate_read 3 42909 NULL
119629 +mthca_make_profile_42919 mthca_make_profile 0 42919 NULL
119630 +snd_ctl_rename_id_42923 snd_ctl_rename_id 0 42923 NULL
119631 +xfs_bmapi_allocate_42938 xfs_bmapi_allocate 0 42938 NULL
119632 +sctp_getsockopt_maxburst_42941 sctp_getsockopt_maxburst 2 42941 NULL
119633 +vx_reset_chk_42946 vx_reset_chk 0 42946 NULL
119634 +blkdev_direct_IO_42962 blkdev_direct_IO 4 42962 NULL
119635 +ntb_setup_snb_msix_42971 ntb_setup_snb_msix 2-0 42971 NULL
119636 +compat_udpv6_setsockopt_42981 compat_udpv6_setsockopt 5 42981 NULL
119637 +pci_bus_read_config_word_42987 pci_bus_read_config_word 0 42987 NULL
119638 +nfs_idmap_get_desc_42990 nfs_idmap_get_desc 4-2 42990 NULL nohasharray
119639 +rtw_os_xmit_resource_alloc_42990 rtw_os_xmit_resource_alloc 3 42990 &nfs_idmap_get_desc_42990
119640 +mlx4_qp_reserve_range_43000 mlx4_qp_reserve_range 2-3 43000 NULL
119641 +xfs_da_read_buf_43008 xfs_da_read_buf 0 43008 NULL
119642 +setup_device_43016 setup_device 0 43016 NULL nohasharray
119643 +vfio_fill_vconfig_bytes_43016 vfio_fill_vconfig_bytes 0 43016 &setup_device_43016
119644 +isr_rx_mem_overflow_read_43025 isr_rx_mem_overflow_read 3 43025 NULL
119645 +wep_default_key_count_read_43035 wep_default_key_count_read 3 43035 NULL
119646 +power_supply_check_supplies_43052 power_supply_check_supplies 0 43052 NULL
119647 +fb_add_videomode_43057 fb_add_videomode 0 43057 NULL
119648 +t3_sge_alloc_qset_43061 t3_sge_alloc_qset 0 43061 NULL
119649 +nouveau_gpuobj_create__43072 nouveau_gpuobj_create_ 9 43072 NULL
119650 +nfs_map_group_to_gid_43082 nfs_map_group_to_gid 3 43082 NULL
119651 +ql_start_rx_ring_43085 ql_start_rx_ring 0 43085 NULL
119652 +_xfer_secondary_pool_43089 _xfer_secondary_pool 2 43089 NULL
119653 +t4_port_init_43092 t4_port_init 0 43092 NULL
119654 +sysfs_create_file_ns_43103 sysfs_create_file_ns 0 43103 NULL
119655 +stmmac_init_dma_engine_43104 stmmac_init_dma_engine 0 43104 NULL
119656 +ieee80211_if_fmt_drop_unencrypted_43107 ieee80211_if_fmt_drop_unencrypted 3 43107 NULL
119657 +gfs2_journaled_truncate_43108 gfs2_journaled_truncate 0 43108 NULL
119658 +mlx4_reset_43117 mlx4_reset 0 43117 NULL
119659 +calculate_node_totalpages_43118 calculate_node_totalpages 2-3 43118 NULL
119660 +e1000_request_msix_43134 e1000_request_msix 0 43134 NULL
119661 +read_file_dfs_43145 read_file_dfs 3 43145 NULL
119662 +gfs2_dir_write_stuffed_43147 gfs2_dir_write_stuffed 0-4 43147 NULL
119663 +cfs_cpt_table_alloc_43159 cfs_cpt_table_alloc 1 43159 NULL
119664 +usb_string_sub_43164 usb_string_sub 0 43164 NULL
119665 +il_dbgfs_power_save_status_read_43165 il_dbgfs_power_save_status_read 3 43165 NULL
119666 +ath6kl_set_assoc_req_ies_43185 ath6kl_set_assoc_req_ies 3 43185 NULL
119667 +ext4_xattr_ibody_get_43200 ext4_xattr_ibody_get 0 43200 NULL
119668 +uio_write_43202 uio_write 3 43202 NULL
119669 +iso_callback_43208 iso_callback 3 43208 NULL
119670 +ath10k_p2p_calc_noa_ie_len_43209 ath10k_p2p_calc_noa_ie_len 0 43209 NULL
119671 +f2fs_acl_from_disk_43210 f2fs_acl_from_disk 2 43210 NULL
119672 +ican3_reset_module_43213 ican3_reset_module 0 43213 NULL
119673 +atomic_long_add_return_43217 atomic_long_add_return 1-0 43217 NULL
119674 +inode_init_always_43225 inode_init_always 0 43225 NULL
119675 +batadv_tt_tvlv_unicast_handler_v1_43239 batadv_tt_tvlv_unicast_handler_v1 5 43239 NULL
119676 +vmemmap_alloc_block_43245 vmemmap_alloc_block 1 43245 NULL
119677 +ide_end_rq_43269 ide_end_rq 4 43269 NULL
119678 +nilfs_direct_IO_43271 nilfs_direct_IO 4 43271 NULL
119679 +evtchn_write_43278 evtchn_write 3 43278 NULL nohasharray
119680 +parport_pc_ecp_write_block_pio_43278 parport_pc_ecp_write_block_pio 3 43278 &evtchn_write_43278
119681 +filemap_write_and_wait_range_43279 filemap_write_and_wait_range 0 43279 NULL
119682 +mpage_alloc_43299 mpage_alloc 3 43299 NULL
119683 +em28xx_audio_analog_set_43312 em28xx_audio_analog_set 0 43312 NULL
119684 +mmu_set_spte_43327 mmu_set_spte 6-7 43327 NULL
119685 +__ext4_get_inode_loc_43332 __ext4_get_inode_loc 0 43332 NULL
119686 +xfs_log_regrant_43350 xfs_log_regrant 0 43350 NULL
119687 +gart_free_coherent_43362 gart_free_coherent 4-2 43362 NULL
119688 +gfs2_rgrp_bh_get_43375 gfs2_rgrp_bh_get 0 43375 NULL
119689 +__mlx4_qp_alloc_icm_43388 __mlx4_qp_alloc_icm 0 43388 NULL
119690 +xfs_btree_new_iroot_43392 xfs_btree_new_iroot 0 43392 NULL
119691 +xenfb_write_43412 xenfb_write 3 43412 NULL
119692 +__alloc_bootmem_low_43423 __alloc_bootmem_low 1 43423 NULL nohasharray
119693 +msi_capability_init_43423 msi_capability_init 0 43423 &__alloc_bootmem_low_43423
119694 +pt1_init_frontend_43429 pt1_init_frontend 0 43429 NULL
119695 +usb_alloc_urb_43436 usb_alloc_urb 1 43436 NULL
119696 +ath6kl_wmi_roam_tbl_event_rx_43440 ath6kl_wmi_roam_tbl_event_rx 3 43440 NULL
119697 +ocfs2_rotate_tree_left_43442 ocfs2_rotate_tree_left 0 43442 NULL
119698 +usb_string_43443 usb_string 0 43443 NULL nohasharray
119699 +usemap_size_43443 usemap_size 0-1-2 43443 &usb_string_43443
119700 +get_vm_area_size_43444 get_vm_area_size 0 43444 NULL
119701 +fs_path_prepare_for_add_43453 fs_path_prepare_for_add 2 43453 NULL
119702 +nvme_trans_device_id_page_43466 nvme_trans_device_id_page 4 43466 NULL
119703 +tx_tx_data_prepared_read_43497 tx_tx_data_prepared_read 3 43497 NULL
119704 +ieee80211_if_fmt_dot11MeshHWMPnetDiameterTraversalTime_43505 ieee80211_if_fmt_dot11MeshHWMPnetDiameterTraversalTime 3 43505 NULL
119705 +__unmap_and_move_43513 __unmap_and_move 0 43513 NULL
119706 +dvb_ca_en50221_io_write_43533 dvb_ca_en50221_io_write 3 43533 NULL
119707 +read_events_43534 read_events 3 43534 NULL
119708 +cachefiles_daemon_write_43535 cachefiles_daemon_write 3 43535 NULL
119709 +tx_frag_failed_read_43540 tx_frag_failed_read 3 43540 NULL
119710 +request_resource_43548 request_resource 0 43548 NULL
119711 +ath_rx_init_43564 ath_rx_init 0 43564 NULL
119712 +hpsa_wait_for_board_state_43572 hpsa_wait_for_board_state 0 43572 NULL
119713 +rpc_malloc_43573 rpc_malloc 2 43573 NULL
119714 +handle_frequent_errors_43599 handle_frequent_errors 4 43599 NULL
119715 +lpfc_idiag_drbacc_read_reg_43606 lpfc_idiag_drbacc_read_reg 0-3 43606 NULL
119716 +proc_read_43614 proc_read 3 43614 NULL
119717 +disable_dma_on_even_43618 disable_dma_on_even 0 43618 NULL
119718 +alloc_thread_groups_43625 alloc_thread_groups 2 43625 NULL
119719 +random_write_43656 random_write 3 43656 NULL
119720 +bio_integrity_tag_43658 bio_integrity_tag 3 43658 NULL
119721 +ext4_acl_count_43659 ext4_acl_count 0-1 43659 NULL
119722 +write_file_tx99_power_43670 write_file_tx99_power 3 43670 NULL
119723 +dmam_declare_coherent_memory_43679 dmam_declare_coherent_memory 4 43679 NULL
119724 +tg3_mdio_init_43683 tg3_mdio_init 0 43683 NULL
119725 +calgary_map_page_43686 calgary_map_page 4 43686 NULL
119726 +max77693_bulk_write_43698 max77693_bulk_write 2-3 43698 NULL
119727 +drbd_md_first_sector_43729 drbd_md_first_sector 0 43729 NULL
119728 +snd_rme32_playback_copy_43732 snd_rme32_playback_copy 5 43732 NULL
119729 +ocfs2_replace_clusters_43733 ocfs2_replace_clusters 0 43733 NULL
119730 +fuse_conn_congestion_threshold_write_43736 fuse_conn_congestion_threshold_write 3 43736 NULL
119731 +amradio_set_freq_43748 amradio_set_freq 0 43748 NULL
119732 +gigaset_initcs_43753 gigaset_initcs 2 43753 NULL
119733 +sctp_setsockopt_active_key_43755 sctp_setsockopt_active_key 3 43755 NULL
119734 +generic_file_direct_write_43770 generic_file_direct_write 0 43770 NULL
119735 +xfs_alloc_lookup_eq_43775 xfs_alloc_lookup_eq 0 43775 NULL
119736 +ocfs2_xattr_get_value_outside_43787 ocfs2_xattr_get_value_outside 0 43787 NULL nohasharray
119737 +byte_pos_43787 byte_pos 0 43787 &ocfs2_xattr_get_value_outside_43787 nohasharray
119738 +pci_user_write_config_byte_43787 pci_user_write_config_byte 0 43787 &byte_pos_43787
119739 +xfs_trans_reserve_quota_bydquots_43797 xfs_trans_reserve_quota_bydquots 0 43797 NULL
119740 +btrfs_copy_from_user_43806 btrfs_copy_from_user 3-1-0 43806 NULL
119741 +_xfs_filestream_update_ag_43824 _xfs_filestream_update_ag 0 43824 NULL
119742 +ieee80211_if_fmt_element_ttl_43825 ieee80211_if_fmt_element_ttl 3 43825 NULL
119743 +ieee80211_alloc_hw_43829 ieee80211_alloc_hw 1 43829 NULL
119744 +read_flush_43851 read_flush 3 43851 NULL
119745 +t4vf_alloc_vi_43859 t4vf_alloc_vi 0 43859 NULL
119746 +pm860x_bulk_write_43875 pm860x_bulk_write 2-3 43875 NULL
119747 +vmbus_post_msg_43887 vmbus_post_msg 0 43887 NULL
119748 +ec_dbgfs_cmd_write_43895 ec_dbgfs_cmd_write 3 43895 NULL
119749 +SendString_43928 SendString 3 43928 NULL
119750 +stats_dot11RTSFailureCount_read_43948 stats_dot11RTSFailureCount_read 3 43948 NULL
119751 +xfs_trans_dqresv_43960 xfs_trans_dqresv 0 43960 NULL
119752 +__get_required_blob_size_43980 __get_required_blob_size 0-3-2 43980 NULL
119753 +nla_reserve_43984 nla_reserve 3 43984 NULL
119754 +__clkdev_alloc_43990 __clkdev_alloc 1 43990 NULL
119755 +scsi_command_size_43992 scsi_command_size 0 43992 NULL nohasharray
119756 +kvm_read_guest_virt_43992 kvm_read_guest_virt 4-2 43992 &scsi_command_size_43992 nohasharray
119757 +bcm_recvmsg_43992 bcm_recvmsg 4 43992 &kvm_read_guest_virt_43992
119758 +ulist_add_43994 ulist_add 0 43994 NULL
119759 +emit_flags_44006 emit_flags 4-3 44006 NULL
119760 +write_flush_procfs_44011 write_flush_procfs 3 44011 NULL
119761 +ivtv_streams_register_44038 ivtv_streams_register 0 44038 NULL
119762 +fru_strlen_44046 fru_strlen 0 44046 NULL
119763 +ath9k_def_dump_modal_eeprom_44078 ath9k_def_dump_modal_eeprom 3-2-0 44078 NULL
119764 +SYSC_add_key_44079 SYSC_add_key 4 44079 NULL
119765 +ath10k_hif_tx_sg_44092 ath10k_hif_tx_sg 0 44092 NULL
119766 +pci_msix_vec_count_44093 pci_msix_vec_count 0 44093 NULL nohasharray
119767 +__vxge_hw_vpath_tim_configure_44093 __vxge_hw_vpath_tim_configure 2 44093 &pci_msix_vec_count_44093
119768 +xlog_recover_add_to_cont_trans_44102 xlog_recover_add_to_cont_trans 4 44102 NULL
119769 +skb_frag_dma_map_44112 skb_frag_dma_map 0 44112 NULL
119770 +file_remove_suid_44122 file_remove_suid 0 44122 NULL nohasharray
119771 +tracing_set_trace_read_44122 tracing_set_trace_read 3 44122 &file_remove_suid_44122
119772 +SyS_process_vm_writev_44129 SyS_process_vm_writev 3-5 44129 NULL
119773 +em28xx_read_reg_req_44130 em28xx_read_reg_req 0 44130 NULL
119774 +ttm_get_pages_44142 ttm_get_pages 2 44142 NULL
119775 +scsi_get_resid_44147 scsi_get_resid 0 44147 NULL
119776 +ubifs_find_dirty_idx_leb_44169 ubifs_find_dirty_idx_leb 0 44169 NULL
119777 +ocfs2_xattr_bucket_find_44174 ocfs2_xattr_bucket_find 0 44174 NULL
119778 +SYSC_set_mempolicy_44176 SYSC_set_mempolicy 3 44176 NULL
119779 +readreg_ipac_44186 readreg_ipac 0 44186 NULL
119780 +ath10k_wmi_cmd_send_nowait_44190 ath10k_wmi_cmd_send_nowait 0 44190 NULL
119781 +handle_eviocgbit_44193 handle_eviocgbit 3 44193 NULL
119782 +claim_ptd_buffers_44213 claim_ptd_buffers 3 44213 NULL
119783 +srp_alloc_iu_44227 srp_alloc_iu 2 44227 NULL
119784 +scsi_track_queue_full_44239 scsi_track_queue_full 2 44239 NULL nohasharray
119785 +kobject_rename_44239 kobject_rename 0 44239 &scsi_track_queue_full_44239
119786 +sigma_action_write_regmap_44240 sigma_action_write_regmap 3 44240 NULL
119787 +apei_resources_sub_44252 apei_resources_sub 0 44252 NULL
119788 +gpiod_direction_output_raw_44276 gpiod_direction_output_raw 0 44276 NULL
119789 +ican3_set_buserror_44279 ican3_set_buserror 0 44279 NULL
119790 +device_create_file_44285 device_create_file 0 44285 NULL
119791 +_request_firmware_prepare_44291 _request_firmware_prepare 0 44291 NULL
119792 +ath6kl_keepalive_read_44303 ath6kl_keepalive_read 3 44303 NULL
119793 +bitmap_scnprintf_44318 bitmap_scnprintf 0-2 44318 NULL
119794 +dispatch_proc_write_44320 dispatch_proc_write 3 44320 NULL
119795 +ccp_init_data_44324 ccp_init_data 5 44324 NULL
119796 +rs_init_44327 rs_init 1 44327 NULL
119797 +radix_tree_maybe_preload_44346 radix_tree_maybe_preload 0 44346 NULL
119798 +usb_get_configuration_44354 usb_get_configuration 0 44354 NULL
119799 +blk_queue_init_tags_44355 blk_queue_init_tags 2 44355 NULL nohasharray
119800 +nfs_fscache_get_super_cookie_44355 nfs_fscache_get_super_cookie 3 44355 &blk_queue_init_tags_44355
119801 +alloc_requests_44372 alloc_requests 0 44372 NULL
119802 +rts_threshold_read_44384 rts_threshold_read 3 44384 NULL
119803 +start_rx_44387 start_rx 0 44387 NULL
119804 +oxygen_mixer_init_44390 oxygen_mixer_init 0 44390 NULL
119805 +mtip_hw_read_flags_44396 mtip_hw_read_flags 3 44396 NULL
119806 +pcibios_err_to_errno_44397 pcibios_err_to_errno 0-1 44397 NULL
119807 +aoedev_flush_44398 aoedev_flush 2 44398 NULL
119808 +strlcpy_44400 strlcpy 3 44400 NULL
119809 +drm_buffer_alloc_44405 drm_buffer_alloc 2 44405 NULL
119810 +osst_do_scsi_44410 osst_do_scsi 4 44410 NULL nohasharray
119811 +e100_eeprom_load_44410 e100_eeprom_load 0 44410 &osst_do_scsi_44410
119812 +ieee80211_if_read_rc_rateidx_mcs_mask_5ghz_44423 ieee80211_if_read_rc_rateidx_mcs_mask_5ghz 3 44423 NULL
119813 +fs16_to_cpu_44435 fs16_to_cpu 0 44435 NULL
119814 +xfs_mod_incore_sb_44439 xfs_mod_incore_sb 0 44439 NULL
119815 +c2_adapter_init_44443 c2_adapter_init 0 44443 NULL
119816 +mwifiex_pcie_alloc_cmdrsp_buf_44466 mwifiex_pcie_alloc_cmdrsp_buf 0 44466 NULL
119817 +write_file_debug_44476 write_file_debug 3 44476 NULL
119818 +btrfs_chunk_item_size_44478 btrfs_chunk_item_size 0-1 44478 NULL nohasharray
119819 +t4vf_get_dev_params_44478 t4vf_get_dev_params 0 44478 &btrfs_chunk_item_size_44478
119820 +register_root_hub_44486 register_root_hub 0 44486 NULL
119821 +sdio_align_size_44489 sdio_align_size 0-2 44489 NULL
119822 +bio_advance_44496 bio_advance 2 44496 NULL
119823 +ieee80211_if_read_dropped_frames_ttl_44500 ieee80211_if_read_dropped_frames_ttl 3 44500 NULL
119824 +ac_register_board_44504 ac_register_board 3 44504 NULL
119825 +security_getprocattr_44505 security_getprocattr 0 44505 NULL nohasharray
119826 +iwl_dbgfs_sram_read_44505 iwl_dbgfs_sram_read 3 44505 &security_getprocattr_44505
119827 +spidev_write_44510 spidev_write 3 44510 NULL
119828 +SyS_io_getevents_44519 SyS_io_getevents 3 44519 NULL
119829 +ieee80211_rx_mgmt_assoc_resp_44525 ieee80211_rx_mgmt_assoc_resp 3 44525 NULL
119830 +oxygen_pcm_init_44535 oxygen_pcm_init 0 44535 NULL
119831 +comm_write_44537 comm_write 3 44537 NULL
119832 +xfs_log_calc_unit_res_44540 xfs_log_calc_unit_res 0-2 44540 NULL
119833 +snd_pcm_drop_44542 snd_pcm_drop 0 44542 NULL
119834 +ath10k_htt_rx_attach_44546 ath10k_htt_rx_attach 0 44546 NULL
119835 +dgrp_config_proc_write_44571 dgrp_config_proc_write 3 44571 NULL
119836 +il_eeprom_init_44574 il_eeprom_init 0 44574 NULL
119837 +btrfs_set_extent_delalloc_44587 btrfs_set_extent_delalloc 0 44587 NULL
119838 +nouveau_perfmon_create__44602 nouveau_perfmon_create_ 4 44602 NULL
119839 +mthca_init_tavor_44611 mthca_init_tavor 0 44611 NULL
119840 +xfs_bmapi_delay_44630 xfs_bmapi_delay 0 44630 NULL
119841 +lpfc_wq_create_44639 lpfc_wq_create 0 44639 NULL
119842 +alloc_ctrl_packet_44667 alloc_ctrl_packet 1 44667 NULL
119843 +mpi_resize_44674 mpi_resize 2 44674 NULL
119844 +sysfs_create_link_44685 sysfs_create_link 0 44685 NULL nohasharray
119845 +adp5588_write_44685 adp5588_write 0 44685 &sysfs_create_link_44685
119846 +ts_read_44687 ts_read 3 44687 NULL
119847 +lov_emerg_alloc_44698 lov_emerg_alloc 1 44698 NULL
119848 +C_SYSC_select_44701 C_SYSC_select 1 44701 NULL
119849 +__ocfs2_rotate_tree_left_44705 __ocfs2_rotate_tree_left 0 44705 NULL
119850 +__generic_block_fiemap_44713 __generic_block_fiemap 4 44713 NULL nohasharray
119851 +xfer_to_user_44713 xfer_to_user 3 44713 &__generic_block_fiemap_44713
119852 +_zd_iowrite32v_locked_44725 _zd_iowrite32v_locked 3 44725 NULL
119853 +clusterip_proc_write_44729 clusterip_proc_write 3 44729 NULL
119854 +fib_count_nexthops_44730 fib_count_nexthops 0 44730 NULL
119855 +efx_wanted_parallelism_44732 efx_wanted_parallelism 0 44732 NULL nohasharray
119856 +SyS_read_44732 SyS_read 3 44732 &efx_wanted_parallelism_44732
119857 +key_tx_rx_count_read_44742 key_tx_rx_count_read 3 44742 NULL
119858 +bch_bio_max_sectors_44755 bch_bio_max_sectors 0 44755 NULL
119859 +tnode_new_44757 tnode_new 3 44757 NULL nohasharray
119860 +pty_write_44757 pty_write 3 44757 &tnode_new_44757
119861 +__videobuf_copy_stream_44769 __videobuf_copy_stream 4-0 44769 NULL
119862 +handsfree_ramp_44777 handsfree_ramp 2 44777 NULL
119863 +irq_domain_add_legacy_44781 irq_domain_add_legacy 4-2 44781 NULL
119864 +sctp_setsockopt_44788 sctp_setsockopt 5 44788 NULL
119865 +rx_dropped_read_44799 rx_dropped_read 3 44799 NULL
119866 +qla4xxx_alloc_work_44813 qla4xxx_alloc_work 2 44813 NULL
119867 +force_static_address_write_44819 force_static_address_write 3 44819 NULL
119868 +mei_cl_read_start_44824 mei_cl_read_start 2 44824 NULL
119869 +rmap_write_protect_44833 rmap_write_protect 2 44833 NULL
119870 +sisusb_write_44834 sisusb_write 3 44834 NULL
119871 +kvm_read_hva_44847 kvm_read_hva 3 44847 NULL
119872 +qib_verbs_send_dma_44850 qib_verbs_send_dma 6 44850 NULL
119873 +copydesc_user_44855 copydesc_user 3 44855 NULL
119874 +set_advertising_44870 set_advertising 4 44870 NULL
119875 +init_rs_44873 init_rs 1 44873 NULL
119876 +skb_availroom_44883 skb_availroom 0 44883 NULL
119877 +snd_vortex_mixer_44889 snd_vortex_mixer 0 44889 NULL
119878 +ocfs2_wait_for_mask_44893 ocfs2_wait_for_mask 0 44893 NULL
119879 +do_tty_write_44896 do_tty_write 5 44896 NULL
119880 +asd_create_ha_caches_44901 asd_create_ha_caches 0 44901 NULL
119881 +regmap_spi_read_44921 regmap_spi_read 3-5 44921 NULL
119882 +tx_queue_status_read_44978 tx_queue_status_read 3 44978 NULL
119883 +mthca_RUN_FW_44993 mthca_RUN_FW 0 44993 NULL
119884 +bytepos_delta_45017 bytepos_delta 0 45017 NULL
119885 +ptrace_writedata_45021 ptrace_writedata 4 45021 NULL
119886 +dm_kvzalloc_45025 dm_kvzalloc 1 45025 NULL
119887 +vfio_ecap_init_45033 vfio_ecap_init 0 45033 NULL
119888 +nand_scan_tail_45048 nand_scan_tail 0 45048 NULL
119889 +sysfs_do_create_link_sd_45057 sysfs_do_create_link_sd 0 45057 NULL
119890 +sel_write_user_45060 sel_write_user 3 45060 NULL
119891 +snd_mixart_BA0_read_45069 snd_mixart_BA0_read 5 45069 NULL
119892 +register_candev_45078 register_candev 0 45078 NULL
119893 +ata_tdev_add_45079 ata_tdev_add 0 45079 NULL
119894 +sony_check_add_dev_list_45100 sony_check_add_dev_list 0 45100 NULL
119895 +snd_card_new_45104 snd_card_new 5-0 45104 NULL
119896 +kvm_mmu_page_get_gfn_45110 kvm_mmu_page_get_gfn 0-2 45110 NULL
119897 +pwr_missing_bcns_cnt_read_45113 pwr_missing_bcns_cnt_read 3 45113 NULL
119898 +usbdev_read_45114 usbdev_read 3 45114 NULL
119899 +send_to_tty_45141 send_to_tty 3 45141 NULL
119900 +cfs_trace_daemon_command_usrstr_45147 cfs_trace_daemon_command_usrstr 2 45147 NULL
119901 +gen_bitmask_string_45149 gen_bitmask_string 6 45149 NULL
119902 +device_write_45156 device_write 3 45156 NULL nohasharray
119903 +ocfs2_remove_inode_range_45156 ocfs2_remove_inode_range 3-4 45156 &device_write_45156
119904 +SYSC_write_45160 SYSC_write 3 45160 NULL
119905 +tomoyo_write_self_45161 tomoyo_write_self 3 45161 NULL
119906 +sta_agg_status_write_45164 sta_agg_status_write 3 45164 NULL
119907 +get_protocol_45172 get_protocol 0 45172 NULL
119908 +sctp_pack_cookie_45190 sctp_pack_cookie 6 45190 NULL nohasharray
119909 +snd_sb_csp_load_user_45190 snd_sb_csp_load_user 3 45190 &sctp_pack_cookie_45190
119910 +__radix_tree_preload_45197 __radix_tree_preload 0 45197 NULL
119911 +iso_alloc_urb_45206 iso_alloc_urb 4-5 45206 NULL
119912 +spi_alloc_master_45223 spi_alloc_master 2 45223 NULL
119913 +ieee80211_if_read_peer_45233 ieee80211_if_read_peer 3 45233 NULL
119914 +event_enable_write_45238 event_enable_write 3 45238 NULL
119915 +prism2_pda_proc_read_45246 prism2_pda_proc_read 3 45246 NULL
119916 +input_mt_init_slots_45279 input_mt_init_slots 2 45279 NULL
119917 +gfs2_fiemap_45282 gfs2_fiemap 4 45282 NULL
119918 +snd_pcm_oss_sync1_45298 snd_pcm_oss_sync1 2 45298 NULL
119919 +xfs_alert_fsblock_zero_45304 xfs_alert_fsblock_zero 0 45304 NULL
119920 +e1000_tx_map_45309 e1000_tx_map 5 45309 NULL
119921 +ufshcd_memory_alloc_45311 ufshcd_memory_alloc 0 45311 NULL
119922 +copy_vm86_regs_from_user_45340 copy_vm86_regs_from_user 3 45340 NULL
119923 +brcmf_sdio_died_dump_45359 brcmf_sdio_died_dump 3 45359 NULL
119924 +null_alloc_repbuf_45375 null_alloc_repbuf 3 45375 NULL
119925 +snd_ctl_add_45389 snd_ctl_add 0 45389 NULL
119926 +count_skb_frag_slots_45395 count_skb_frag_slots 0 45395 NULL
119927 +sock_recv_errqueue_45412 sock_recv_errqueue 3 45412 NULL
119928 +sht15_wait_for_response_45419 sht15_wait_for_response 0 45419 NULL
119929 +ieee80211_if_fmt_dot11MeshHWMProotInterval_45421 ieee80211_if_fmt_dot11MeshHWMProotInterval 3 45421 NULL nohasharray
119930 +mthca_INIT_HCA_45421 mthca_INIT_HCA 0 45421 &ieee80211_if_fmt_dot11MeshHWMProotInterval_45421
119931 +ll_iocontrol_register_45430 ll_iocontrol_register 2 45430 NULL
119932 +tty_buffer_alloc_45437 tty_buffer_alloc 2 45437 NULL nohasharray
119933 +hpsa_kdump_hard_reset_controller_45437 hpsa_kdump_hard_reset_controller 0 45437 &tty_buffer_alloc_45437
119934 +__node_remap_45458 __node_remap 4 45458 NULL
119935 +rds_ib_set_wr_signal_state_45463 rds_ib_set_wr_signal_state 0 45463 NULL
119936 +tracing_read_dyn_info_45468 tracing_read_dyn_info 3 45468 NULL nohasharray
119937 +register_netdev_45468 register_netdev 0 45468 &tracing_read_dyn_info_45468
119938 +__calc_request_pg_45470 __calc_request_pg 0 45470 NULL
119939 +xfs_btree_block_change_owner_45476 xfs_btree_block_change_owner 0 45476 NULL
119940 +snd_pcm_hwsync_45479 snd_pcm_hwsync 0 45479 NULL
119941 +arizona_init_fll_45503 arizona_init_fll 5 45503 NULL
119942 +vnic_rq_alloc_45507 vnic_rq_alloc 0 45507 NULL
119943 +rds_message_copy_from_user_45510 rds_message_copy_from_user 3 45510 NULL
119944 +dvb_register_45530 dvb_register 0 45530 NULL
119945 +copy_macs_45534 copy_macs 4 45534 NULL
119946 +nla_attr_size_45545 nla_attr_size 0-1 45545 NULL
119947 +v9fs_direct_read_45546 v9fs_direct_read 3 45546 NULL
119948 +cx18_copy_mdl_to_user_45549 cx18_copy_mdl_to_user 4 45549 NULL
119949 +stats_dot11ACKFailureCount_read_45558 stats_dot11ACKFailureCount_read 3 45558 NULL
119950 +_regmap_bus_raw_write_45559 _regmap_bus_raw_write 2 45559 NULL
119951 +posix_acl_xattr_size_45561 posix_acl_xattr_size 0-1 45561 NULL
119952 +venus_rmdir_45564 venus_rmdir 4 45564 NULL
119953 +ath6kl_keepalive_write_45600 ath6kl_keepalive_write 3 45600 NULL
119954 +hidraw_get_report_45609 hidraw_get_report 3 45609 NULL
119955 +ip_dst_mtu_maybe_forward_45627 ip_dst_mtu_maybe_forward 0 45627 NULL
119956 +pci_enable_device_io_45662 pci_enable_device_io 0 45662 NULL
119957 +dma_map_cont_45668 dma_map_cont 5 45668 NULL
119958 +compat_mpctl_ioctl_45671 compat_mpctl_ioctl 2 45671 NULL
119959 +dgram_sendmsg_45679 dgram_sendmsg 4 45679 NULL
119960 +smk_write_ambient_45691 smk_write_ambient 3 45691 NULL
119961 +unix_dgram_sendmsg_45699 unix_dgram_sendmsg 4 45699 NULL nohasharray
119962 +bscnl_emit_45699 bscnl_emit 2-5-0 45699 &unix_dgram_sendmsg_45699
119963 +sg_proc_write_adio_45704 sg_proc_write_adio 3 45704 NULL
119964 +uas_configure_endpoints_45724 uas_configure_endpoints 0 45724 NULL
119965 +snd_cs46xx_io_read_45734 snd_cs46xx_io_read 5 45734 NULL
119966 +rw_copy_check_uvector_45748 rw_copy_check_uvector 3-0 45748 NULL nohasharray
119967 +v4l2_ctrl_new_std_45748 v4l2_ctrl_new_std 5 45748 &rw_copy_check_uvector_45748
119968 +lkdtm_debugfs_read_45752 lkdtm_debugfs_read 3 45752 NULL
119969 +alloc_ts_config_45775 alloc_ts_config 1 45775 NULL
119970 +osc_checksum_type_seq_write_45785 osc_checksum_type_seq_write 3 45785 NULL
119971 +raw_setsockopt_45800 raw_setsockopt 5 45800 NULL
119972 +rds_tcp_inc_copy_to_user_45804 rds_tcp_inc_copy_to_user 3 45804 NULL
119973 +lbs_rdbbp_read_45805 lbs_rdbbp_read 3 45805 NULL
119974 +pcpu_alloc_alloc_info_45813 pcpu_alloc_alloc_info 1-2 45813 NULL
119975 +ll_max_readahead_mb_seq_write_45815 ll_max_readahead_mb_seq_write 3 45815 NULL
119976 +memcg_update_cache_size_45828 memcg_update_cache_size 2 45828 NULL
119977 +ipv6_recv_rxpmtu_45830 ipv6_recv_rxpmtu 3 45830 NULL
119978 +insert_state_45848 insert_state 0 45848 NULL
119979 +x509_process_extension_45854 x509_process_extension 5 45854 NULL
119980 +efx_tx_queue_insert_45859 efx_tx_queue_insert 2 45859 NULL
119981 +isdn_write_45863 isdn_write 3 45863 NULL
119982 +tpm_config_in_45880 tpm_config_in 0 45880 NULL
119983 +get_rdac_req_45882 get_rdac_req 3 45882 NULL
119984 +ocfs2_xattr_block_find_45891 ocfs2_xattr_block_find 0 45891 NULL
119985 +online_page_cgroup_45894 online_page_cgroup 0 45894 NULL
119986 +cfs_cpt_weight_45903 cfs_cpt_weight 0 45903 NULL
119987 +wm_adsp_region_to_reg_45915 wm_adsp_region_to_reg 0-2 45915 NULL
119988 +dbgfs_frame_45917 dbgfs_frame 3 45917 NULL
119989 +asd_verify_cseq_45925 asd_verify_cseq 0 45925 NULL
119990 +btree_keys_cachelines_45928 btree_keys_cachelines 0 45928 NULL
119991 +alloc_mr_45935 alloc_mr 1 45935 NULL
119992 +remove_counter_ok_45936 remove_counter_ok 0 45936 NULL
119993 +copy_to_45969 copy_to 3 45969 NULL
119994 +rb_simple_read_45972 rb_simple_read 3 45972 NULL
119995 +ioat2_dca_count_dca_slots_45984 ioat2_dca_count_dca_slots 0 45984 NULL nohasharray
119996 +ngene_load_firm_45984 ngene_load_firm 0 45984 &ioat2_dca_count_dca_slots_45984
119997 +kobject_init_and_add_46003 kobject_init_and_add 0 46003 NULL
119998 +sierra_setup_urb_46029 sierra_setup_urb 5 46029 NULL
119999 +fnic_reset_stats_read_46030 fnic_reset_stats_read 3 46030 NULL nohasharray
120000 +get_free_entries_46030 get_free_entries 1 46030 &fnic_reset_stats_read_46030 nohasharray
120001 +iio_device_register_eventset_46030 iio_device_register_eventset 0 46030 &get_free_entries_46030
120002 +__access_remote_vm_46031 __access_remote_vm 0 46031 NULL
120003 +snd_emu10k1x_ptr_read_46049 snd_emu10k1x_ptr_read 0 46049 NULL
120004 +__ocfs2_move_extent_46060 __ocfs2_move_extent 3-4 46060 NULL nohasharray
120005 +dma_tx_errors_read_46060 dma_tx_errors_read 3 46060 &__ocfs2_move_extent_46060
120006 +sel_commit_bools_write_46077 sel_commit_bools_write 3 46077 NULL
120007 +snd_vortex_new_pcm_46093 snd_vortex_new_pcm 0 46093 NULL
120008 +arizona_set_irq_wake_46101 arizona_set_irq_wake 2 46101 NULL
120009 +il3945_ucode_general_stats_read_46111 il3945_ucode_general_stats_read 3 46111 NULL nohasharray
120010 +memcg_update_array_size_46111 memcg_update_array_size 1 46111 &il3945_ucode_general_stats_read_46111
120011 +C_SYSC_writev_46113 C_SYSC_writev 3 46113 NULL
120012 +sysfs_rename_link_46118 sysfs_rename_link 0 46118 NULL
120013 +mlx4_ib_alloc_fast_reg_page_list_46119 mlx4_ib_alloc_fast_reg_page_list 2 46119 NULL
120014 +rtw_buf_update_46138 rtw_buf_update 4 46138 NULL
120015 +vb2_dma_sg_get_userptr_46146 vb2_dma_sg_get_userptr 3-2 46146 NULL
120016 +__netlink_change_ngroups_46156 __netlink_change_ngroups 2 46156 NULL
120017 +si470x_set_register_46160 si470x_set_register 0 46160 NULL
120018 +rsxx_hw_buffers_init_46164 rsxx_hw_buffers_init 0 46164 NULL
120019 +twl_direction_out_46182 twl_direction_out 2 46182 NULL
120020 +vxge_os_dma_malloc_46184 vxge_os_dma_malloc 2 46184 NULL
120021 +fq_resize_46195 fq_resize 2 46195 NULL
120022 +add_conn_list_46197 add_conn_list 3-0 46197 NULL
120023 +typhoon_issue_command_46204 typhoon_issue_command 0 46204 NULL
120024 +i2400m_op_msg_from_user_46213 i2400m_op_msg_from_user 4 46213 NULL
120025 +tm6000_i2c_recv_regs_46215 tm6000_i2c_recv_regs 5 46215 NULL
120026 +dsp_write_46218 dsp_write 2 46218 NULL
120027 +hash_netiface4_expire_46226 hash_netiface4_expire 4 46226 NULL
120028 +write_driver_ver_to_cfgtable_46239 write_driver_ver_to_cfgtable 0 46239 NULL
120029 +xen_setup_msi_irqs_46245 xen_setup_msi_irqs 2 46245 NULL
120030 +mpi_read_raw_data_46248 mpi_read_raw_data 2 46248 NULL
120031 +gfs2_block_truncate_page_46252 gfs2_block_truncate_page 0 46252 NULL
120032 +ReadReg_46277 ReadReg 0 46277 NULL
120033 +dvb_net_init_46291 dvb_net_init 0 46291 NULL
120034 +zs_cpu_notifier_46295 zs_cpu_notifier 0 46295 NULL
120035 +sg_proc_write_dressz_46316 sg_proc_write_dressz 3 46316 NULL
120036 +C_SYSC_ppoll_46319 C_SYSC_ppoll 2 46319 NULL
120037 +__hwahc_dev_set_key_46328 __hwahc_dev_set_key 5 46328 NULL nohasharray
120038 +compat_SyS_readv_46328 compat_SyS_readv 3 46328 &__hwahc_dev_set_key_46328
120039 +iwl_dbgfs_chain_noise_read_46355 iwl_dbgfs_chain_noise_read 3 46355 NULL
120040 +smk_write_direct_46363 smk_write_direct 3 46363 NULL
120041 +flow_cache_cpu_prepare_46367 flow_cache_cpu_prepare 0 46367 NULL
120042 +fuse_file_aio_write_46399 fuse_file_aio_write 4 46399 NULL
120043 +crypto_ablkcipher_reqsize_46411 crypto_ablkcipher_reqsize 0 46411 NULL
120044 +ttm_page_pool_get_pages_46431 ttm_page_pool_get_pages 0-5 46431 NULL
120045 +cfs_power2_roundup_46433 cfs_power2_roundup 0-1 46433 NULL
120046 +pci_enable_msi_exact_46436 pci_enable_msi_exact 2 46436 NULL
120047 +nilfs_commit_chunk_46445 nilfs_commit_chunk 4-3 46445 NULL
120048 +cp210x_set_config_46447 cp210x_set_config 4 46447 NULL
120049 +parport_pc_fifo_write_block_46455 parport_pc_fifo_write_block 3 46455 NULL
120050 +il_dbgfs_clear_traffic_stats_write_46458 il_dbgfs_clear_traffic_stats_write 3 46458 NULL
120051 +mlx4_SW2HW_EQ_46463 mlx4_SW2HW_EQ 0 46463 NULL
120052 +register_framebuffer_46464 register_framebuffer 0 46464 NULL
120053 +filldir64_46469 filldir64 3 46469 NULL
120054 +ocfs2_reserve_clusters_with_limit_46479 ocfs2_reserve_clusters_with_limit 0 46479 NULL
120055 +fill_in_write_vector_46498 fill_in_write_vector 0 46498 NULL
120056 +pin_code_reply_46510 pin_code_reply 4 46510 NULL
120057 +mthca_alloc_cq_buf_46512 mthca_alloc_cq_buf 3 46512 NULL
120058 +kmsg_read_46514 kmsg_read 3 46514 NULL nohasharray
120059 +nouveau_drm_ioctl_46514 nouveau_drm_ioctl 2 46514 &kmsg_read_46514
120060 +nl80211_send_rx_assoc_46538 nl80211_send_rx_assoc 4 46538 NULL
120061 +assign_firmware_buf_46554 assign_firmware_buf 0 46554 NULL
120062 +ican3_msg_fasthostif_46560 ican3_msg_fasthostif 0 46560 NULL
120063 +dn_current_mss_46574 dn_current_mss 0 46574 NULL
120064 +serverworks_create_gatt_pages_46582 serverworks_create_gatt_pages 1 46582 NULL
120065 +snd_compr_write_data_46592 snd_compr_write_data 3 46592 NULL
120066 +niu_determine_phy_disposition_46597 niu_determine_phy_disposition 0 46597 NULL
120067 +il3945_stats_flag_46606 il3945_stats_flag 0-3 46606 NULL
120068 +tg3_phy_reset_5703_4_5_46612 tg3_phy_reset_5703_4_5 0 46612 NULL
120069 +vscnprintf_46617 vscnprintf 0-2 46617 NULL
120070 +__kfifo_out_r_46623 __kfifo_out_r 3-0 46623 NULL
120071 +request_key_async_with_auxdata_46624 request_key_async_with_auxdata 4 46624 NULL
120072 +regmap_read_46634 regmap_read 0 46634 NULL
120073 +pci_enable_device_46642 pci_enable_device 0 46642 NULL
120074 +vfs_getxattr_alloc_46649 vfs_getxattr_alloc 0 46649 NULL
120075 +e1000_tx_map_46672 e1000_tx_map 4 46672 NULL
120076 +l2cap_create_le_flowctl_pdu_46682 l2cap_create_le_flowctl_pdu 3 46682 NULL
120077 +alloc_data_packet_46698 alloc_data_packet 1 46698 NULL
120078 +__ilog2_u32_46706 __ilog2_u32 0 46706 NULL
120079 +il_init_geos_46709 il_init_geos 0 46709 NULL
120080 +erst_dbg_write_46715 erst_dbg_write 3 46715 NULL
120081 +wl1271_rx_filter_alloc_field_46721 wl1271_rx_filter_alloc_field 5 46721 NULL
120082 +irq_domain_add_simple_46734 irq_domain_add_simple 2 46734 NULL
120083 +read_file_tx99_46741 read_file_tx99 3 46741 NULL
120084 +ext4_count_free_46754 ext4_count_free 2 46754 NULL
120085 +hest_ghes_dev_register_46766 hest_ghes_dev_register 1 46766 NULL
120086 +int_hw_irq_en_46776 int_hw_irq_en 3 46776 NULL
120087 +_xfs_buf_get_pages_46811 _xfs_buf_get_pages 2 46811 NULL
120088 +xfs_iroot_realloc_46826 xfs_iroot_realloc 2 46826 NULL
120089 +shmem_pwrite_fast_46842 shmem_pwrite_fast 3 46842 NULL
120090 +readreg_46845 readreg 0 46845 NULL
120091 +spi_async_46857 spi_async 0 46857 NULL
120092 +vsnprintf_46863 vsnprintf 0 46863 NULL nohasharray
120093 +SyS_move_pages_46863 SyS_move_pages 2 46863 &vsnprintf_46863
120094 +nvme_alloc_queue_46865 nvme_alloc_queue 3 46865 NULL
120095 +regulatory_hint_46868 regulatory_hint 0 46868 NULL
120096 +qp_memcpy_from_queue_iov_46874 qp_memcpy_from_queue_iov 5-4 46874 NULL
120097 +lov_iocontrol_46876 lov_iocontrol 3 46876 NULL
120098 +ixgbe_dbg_reg_ops_write_46895 ixgbe_dbg_reg_ops_write 3 46895 NULL
120099 +sk_mem_pages_46896 sk_mem_pages 0-1 46896 NULL
120100 +ieee80211_if_fmt_power_mode_46906 ieee80211_if_fmt_power_mode 3 46906 NULL
120101 +wlcore_alloc_hw_46917 wlcore_alloc_hw 1-3 46917 NULL
120102 +vortex_up_46921 vortex_up 0 46921 NULL
120103 +fb_write_46924 fb_write 3 46924 NULL
120104 +__sctp_setsockopt_connectx_46949 __sctp_setsockopt_connectx 3 46949 NULL
120105 +qla4xxx_post_aen_work_46953 qla4xxx_post_aen_work 3 46953 NULL nohasharray
120106 +ntfs_truncate_46953 ntfs_truncate 0 46953 &qla4xxx_post_aen_work_46953
120107 +SYSC_poll_46965 SYSC_poll 2 46965 NULL
120108 +crypto_tfm_alg_alignmask_46971 crypto_tfm_alg_alignmask 0 46971 NULL
120109 +mgmt_pending_add_46976 mgmt_pending_add 5 46976 NULL
120110 +strlcat_46985 strlcat 3 46985 NULL
120111 +bitmap_file_clear_bit_46990 bitmap_file_clear_bit 2 46990 NULL
120112 +sel_write_bool_46996 sel_write_bool 3 46996 NULL
120113 +blk_rq_map_kern_47004 blk_rq_map_kern 4 47004 NULL
120114 +__map_single_47020 __map_single 4-3-0 47020 NULL
120115 +cx231xx_init_bulk_47024 cx231xx_init_bulk 3-2-4 47024 NULL
120116 +sram_test_word_47038 sram_test_word 0 47038 NULL
120117 +fs_path_len_47060 fs_path_len 0 47060 NULL
120118 +event_trigger_regex_write_47067 event_trigger_regex_write 3 47067 NULL
120119 +ext4_xattr_list_entries_47070 ext4_xattr_list_entries 0 47070 NULL
120120 +pipeline_dec_packet_in_read_47076 pipeline_dec_packet_in_read 3 47076 NULL
120121 +scsi_deactivate_tcq_47086 scsi_deactivate_tcq 2 47086 NULL
120122 +iwl_dump_nic_event_log_47089 iwl_dump_nic_event_log 0 47089 NULL
120123 +ptlrpc_lprocfs_threads_max_seq_write_47104 ptlrpc_lprocfs_threads_max_seq_write 3 47104 NULL nohasharray
120124 +ath9k_hw_fill_cap_info_47104 ath9k_hw_fill_cap_info 0 47104 &ptlrpc_lprocfs_threads_max_seq_write_47104
120125 +mousedev_read_47123 mousedev_read 3 47123 NULL
120126 +ath5k_eeprom_read_spur_chans_47125 ath5k_eeprom_read_spur_chans 0 47125 NULL
120127 +upcall_msg_size_47141 upcall_msg_size 2 47141 NULL
120128 +acpi_ut_initialize_buffer_47143 acpi_ut_initialize_buffer 2 47143 NULL nohasharray
120129 +ses_recv_diag_47143 ses_recv_diag 4 47143 &acpi_ut_initialize_buffer_47143
120130 +mxms_headerlen_47161 mxms_headerlen 0 47161 NULL
120131 +rs_sta_dbgfs_rate_scale_data_read_47165 rs_sta_dbgfs_rate_scale_data_read 3 47165 NULL
120132 +rts51x_ms_rw_47171 rts51x_ms_rw 3-4 47171 NULL
120133 +xfs_btree_get_buf_block_47197 xfs_btree_get_buf_block 0 47197 NULL
120134 +nobh_write_end_47214 nobh_write_end 5 47214 NULL
120135 +tg3_phy_auxctl_read_47216 tg3_phy_auxctl_read 0 47216 NULL
120136 +options_write_47243 options_write 3 47243 NULL
120137 +portcntrs_1_read_47253 portcntrs_1_read 3 47253 NULL
120138 +da9052_disable_irq_nosync_47260 da9052_disable_irq_nosync 2 47260 NULL
120139 +nq_m_sync_47264 nq_m_sync 0 47264 NULL
120140 +ablkcipher_next_slow_47274 ablkcipher_next_slow 4-3 47274 NULL
120141 +gfs2_readpages_47285 gfs2_readpages 4 47285 NULL
120142 +vsnprintf_47291 vsnprintf 0 47291 NULL
120143 +SYSC_semop_47292 SYSC_semop 3 47292 NULL
120144 +tx_internal_desc_overflow_read_47300 tx_internal_desc_overflow_read 3 47300 NULL
120145 +xfs_trans_reserve_quota_nblks_47313 xfs_trans_reserve_quota_nblks 0 47313 NULL
120146 +nouveau_fb_create__47316 nouveau_fb_create_ 4 47316 NULL
120147 +ieee80211_if_read_dot11MeshHoldingTimeout_47356 ieee80211_if_read_dot11MeshHoldingTimeout 3 47356 NULL
120148 +gfs2_replay_read_block_47357 gfs2_replay_read_block 0 47357 NULL
120149 +avc_get_hash_stats_47359 avc_get_hash_stats 0 47359 NULL
120150 +kvm_arch_create_memslot_47364 kvm_arch_create_memslot 3 47364 NULL nohasharray
120151 +__output_copy_user_47364 __output_copy_user 3 47364 &kvm_arch_create_memslot_47364
120152 +__bio_map_kern_47379 __bio_map_kern 3 47379 NULL
120153 +trace_options_core_read_47390 trace_options_core_read 3 47390 NULL nohasharray
120154 +nv_rd32_47390 nv_rd32 0 47390 &trace_options_core_read_47390
120155 +nametbl_list_47391 nametbl_list 2 47391 NULL
120156 +dgrp_net_write_47392 dgrp_net_write 3 47392 NULL
120157 +pfkey_sendmsg_47394 pfkey_sendmsg 4 47394 NULL
120158 +lbs_wrmac_write_47400 lbs_wrmac_write 3 47400 NULL
120159 +sta_vht_capa_read_47409 sta_vht_capa_read 3 47409 NULL
120160 +crypto_ablkcipher_alignmask_47410 crypto_ablkcipher_alignmask 0 47410 NULL
120161 +lbs_wrrf_write_47418 lbs_wrrf_write 3 47418 NULL
120162 +C_SYSC_set_mempolicy_47466 C_SYSC_set_mempolicy 3 47466 NULL
120163 +usermodehelper_read_trylock_47478 usermodehelper_read_trylock 0 47478 NULL
120164 +nvme_trans_send_fw_cmd_47479 nvme_trans_send_fw_cmd 4 47479 NULL
120165 +newpart_47485 newpart 6-4 47485 NULL
120166 +mcp23s17_read_regs_47491 mcp23s17_read_regs 4 47491 NULL
120167 +core_sys_select_47494 core_sys_select 1 47494 NULL
120168 +as3722_block_write_47503 as3722_block_write 2-3 47503 NULL
120169 +alloc_arraycache_47505 alloc_arraycache 2 47505 NULL
120170 +unlink_simple_47506 unlink_simple 3 47506 NULL
120171 +pstore_decompress_47510 pstore_decompress 0 47510 NULL
120172 +__proc_lnet_portal_rotor_47529 __proc_lnet_portal_rotor 5 47529 NULL
120173 +snd_pcm_resume_47530 snd_pcm_resume 0 47530 NULL
120174 +process_vm_rw_47533 process_vm_rw 3-5 47533 NULL nohasharray
120175 +vscnprintf_47533 vscnprintf 0-2 47533 &process_vm_rw_47533
120176 +einj_check_trigger_header_47534 einj_check_trigger_header 0 47534 NULL
120177 +ieee80211_if_fmt_min_discovery_timeout_47539 ieee80211_if_fmt_min_discovery_timeout 3 47539 NULL
120178 +rtw_cfg80211_set_assoc_resp_wpsp2pie_47558 rtw_cfg80211_set_assoc_resp_wpsp2pie 3 47558 NULL
120179 +read_ldt_47570 read_ldt 2 47570 NULL
120180 +isku_sysfs_read_last_set_47572 isku_sysfs_read_last_set 6 47572 NULL
120181 +btrfs_stack_header_bytenr_47589 btrfs_stack_header_bytenr 0 47589 NULL
120182 +ext4_kvzalloc_47605 ext4_kvzalloc 1 47605 NULL
120183 +sctp_ssnmap_new_47608 sctp_ssnmap_new 2-1 47608 NULL
120184 +cache_read_pipefs_47615 cache_read_pipefs 3 47615 NULL
120185 +twl4030_clear_set_47624 twl4030_clear_set 4 47624 NULL
120186 +ccp_sha_setkey_47633 ccp_sha_setkey 3 47633 NULL
120187 +get_size_47644 get_size 1-2 47644 NULL
120188 +snd_pcm_info_47699 snd_pcm_info 0 47699 NULL
120189 +packet_recvmsg_47700 packet_recvmsg 4 47700 NULL nohasharray
120190 +ipath_format_hwmsg_47700 ipath_format_hwmsg 2 47700 &packet_recvmsg_47700
120191 +save_microcode_47717 save_microcode 3 47717 NULL
120192 +bits_to_user_47733 bits_to_user 3-2 47733 NULL
120193 +carl9170_debugfs_read_47738 carl9170_debugfs_read 3 47738 NULL
120194 +ir_prepare_write_buffer_47747 ir_prepare_write_buffer 3 47747 NULL
120195 +hpfs_write_end_47748 hpfs_write_end 5 47748 NULL
120196 +mvumi_alloc_mem_resource_47750 mvumi_alloc_mem_resource 3 47750 NULL
120197 +alloc_sched_domains_47756 alloc_sched_domains 1 47756 NULL
120198 +spk_serial_in_47760 spk_serial_in 0 47760 NULL
120199 +uwb_ie_dump_hex_47774 uwb_ie_dump_hex 4 47774 NULL
120200 +SyS_setgroups16_47780 SyS_setgroups16 1 47780 NULL
120201 +error_error_numll_frame_cts_start_read_47781 error_error_numll_frame_cts_start_read 3 47781 NULL
120202 +posix_acl_fix_xattr_from_user_47793 posix_acl_fix_xattr_from_user 2 47793 NULL
120203 +W6692_empty_Bfifo_47804 W6692_empty_Bfifo 2 47804 NULL
120204 +lov_packmd_47810 lov_packmd 0 47810 NULL
120205 +tree_mod_log_insert_move_47823 tree_mod_log_insert_move 5 47823 NULL
120206 +pinconf_dbg_config_write_47835 pinconf_dbg_config_write 3 47835 NULL
120207 +alloc_ringdesc_47843 alloc_ringdesc 0 47843 NULL
120208 +mthca_cmd_post_hcr_47846 mthca_cmd_post_hcr 0 47846 NULL
120209 +t4_mem_win_rw_47852 t4_mem_win_rw 0 47852 NULL
120210 +KEY_SIZE_47855 KEY_SIZE 0 47855 NULL
120211 +vhci_read_47878 vhci_read 3 47878 NULL
120212 +e100_load_ucode_wait_47882 e100_load_ucode_wait 0 47882 NULL
120213 +ubi_wl_put_peb_47886 ubi_wl_put_peb 0 47886 NULL
120214 +keyctl_instantiate_key_common_47889 keyctl_instantiate_key_common 4 47889 NULL
120215 +cfs_percpt_alloc_47918 cfs_percpt_alloc 2 47918 NULL
120216 +comedi_write_47926 comedi_write 3 47926 NULL
120217 +nvme_trans_get_blk_desc_len_47946 nvme_trans_get_blk_desc_len 0-2 47946 NULL
120218 +arch_setup_msi_irq_47959 arch_setup_msi_irq 0 47959 NULL
120219 +gether_get_ifname_47972 gether_get_ifname 3 47972 NULL
120220 +mempool_resize_47983 mempool_resize 2 47983 NULL nohasharray
120221 +iwl_dbgfs_ucode_tracing_read_47983 iwl_dbgfs_ucode_tracing_read 3 47983 &mempool_resize_47983
120222 +dbg_port_buf_47990 dbg_port_buf 2 47990 NULL
120223 +ib_umad_write_47993 ib_umad_write 3 47993 NULL
120224 +ata_pci_sff_init_host_48000 ata_pci_sff_init_host 0 48000 NULL
120225 +ocfs2_find_refcount_split_pos_48001 ocfs2_find_refcount_split_pos 0 48001 NULL
120226 +lustre_cfg_len_48002 lustre_cfg_len 0 48002 NULL
120227 +gdm_tty_recv_complete_48011 gdm_tty_recv_complete 2 48011 NULL
120228 +bio_integrity_set_tag_48035 bio_integrity_set_tag 3 48035 NULL
120229 +pppoe_sendmsg_48039 pppoe_sendmsg 4 48039 NULL
120230 +SYSC_writev_48040 SYSC_writev 3 48040 NULL
120231 +tps6507x_i2c_write_device_48046 tps6507x_i2c_write_device 3 48046 NULL
120232 +wpan_phy_alloc_48056 wpan_phy_alloc 1 48056 NULL
120233 +ocfs2_change_refcount_rec_48059 ocfs2_change_refcount_rec 0 48059 NULL
120234 +t3_wait_op_done_val_48061 t3_wait_op_done_val 0 48061 NULL
120235 +posix_acl_alloc_48063 posix_acl_alloc 1 48063 NULL
120236 +palmas_bulk_write_48068 palmas_bulk_write 2-3-5 48068 NULL
120237 +disc_write_48070 disc_write 3 48070 NULL
120238 +nv_device_get_irq_48075 nv_device_get_irq 0 48075 NULL
120239 +mmc_alloc_host_48097 mmc_alloc_host 1 48097 NULL
120240 +xfs_read_agi_48100 xfs_read_agi 0 48100 NULL
120241 +skb_copy_datagram_const_iovec_48102 skb_copy_datagram_const_iovec 4-2-5 48102 NULL
120242 +wm_latency_write_48125 wm_latency_write 3 48125 NULL
120243 +vmw_framebuffer_surface_dirty_48132 vmw_framebuffer_surface_dirty 6 48132 NULL
120244 +set_discoverable_48141 set_discoverable 4 48141 NULL
120245 +lpfc_sli4_alloc_extent_48144 lpfc_sli4_alloc_extent 0 48144 NULL
120246 +dn_fib_count_nhs_48145 dn_fib_count_nhs 0 48145 NULL
120247 +SyS_vmsplice_48150 SyS_vmsplice 3 48150 NULL
120248 +_add_to_r4w_48152 _add_to_r4w 4 48152 NULL
120249 +isr_dma1_done_read_48159 isr_dma1_done_read 3 48159 NULL
120250 +c4iw_id_table_alloc_48163 c4iw_id_table_alloc 3 48163 NULL
120251 +rbd_obj_method_sync_48170 rbd_obj_method_sync 8 48170 NULL
120252 +bcm2048_set_fm_automatic_stereo_mono_48178 bcm2048_set_fm_automatic_stereo_mono 0 48178 NULL
120253 +alloc_cc770dev_48186 alloc_cc770dev 1 48186 NULL
120254 +cfg80211_process_deauth_48200 cfg80211_process_deauth 3 48200 NULL
120255 +ext4_index_trans_blocks_48205 ext4_index_trans_blocks 0-2 48205 NULL
120256 +snd_seq_dump_var_event_48209 snd_seq_dump_var_event 0 48209 NULL
120257 +ll_direct_IO_26_48216 ll_direct_IO_26 4 48216 NULL
120258 +uv_blade_nr_possible_cpus_48226 uv_blade_nr_possible_cpus 0 48226 NULL
120259 +nilfs_readpages_48229 nilfs_readpages 4 48229 NULL
120260 +read_file_recv_48232 read_file_recv 3 48232 NULL
120261 +unaccount_shadowed_48233 unaccount_shadowed 2 48233 NULL
120262 +nouveau_i2c_port_create__48240 nouveau_i2c_port_create_ 7 48240 NULL
120263 +pm_qos_add_notifier_48241 pm_qos_add_notifier 0 48241 NULL
120264 +nfsctl_transaction_read_48250 nfsctl_transaction_read 3 48250 NULL
120265 +batadv_socket_read_48257 batadv_socket_read 3 48257 NULL
120266 +cache_write_pipefs_48270 cache_write_pipefs 3 48270 NULL
120267 +trace_options_write_48275 trace_options_write 3 48275 NULL
120268 +send_set_info_48288 send_set_info 7 48288 NULL
120269 +lpfc_idiag_extacc_read_48301 lpfc_idiag_extacc_read 3 48301 NULL
120270 +timblogiw_read_48305 timblogiw_read 3 48305 NULL
120271 +hash_setkey_48310 hash_setkey 3 48310 NULL
120272 +kvm_mmu_pte_write_48340 kvm_mmu_pte_write 2 48340 NULL
120273 +__tg3_readphy_48347 __tg3_readphy 0 48347 NULL
120274 +skb_add_data_48363 skb_add_data 3 48363 NULL
120275 +tx_frag_init_called_read_48377 tx_frag_init_called_read 3 48377 NULL
120276 +lbs_debugfs_write_48413 lbs_debugfs_write 3 48413 NULL
120277 +uhid_event_from_user_48417 uhid_event_from_user 2 48417 NULL
120278 +div64_u64_rem_48418 div64_u64_rem 0-1-2 48418 NULL
120279 +snd_power_wait_48422 snd_power_wait 0 48422 NULL
120280 +pwr_tx_without_ps_read_48423 pwr_tx_without_ps_read 3 48423 NULL
120281 +print_filtered_48442 print_filtered 2-0 48442 NULL
120282 +tun_recvmsg_48463 tun_recvmsg 4 48463 NULL
120283 +compat_SyS_preadv64_48469 compat_SyS_preadv64 3 48469 NULL
120284 +_iwl_dbgfs_bt_tx_prio_write_48473 _iwl_dbgfs_bt_tx_prio_write 3 48473 NULL
120285 +ipath_format_hwerrors_48487 ipath_format_hwerrors 5 48487 NULL
120286 +r8712_usbctrl_vendorreq_48489 r8712_usbctrl_vendorreq 6 48489 NULL
120287 +ocfs2_refcount_cow_48495 ocfs2_refcount_cow 3 48495 NULL
120288 +send_control_msg_48498 send_control_msg 6 48498 NULL
120289 +count_masked_bytes_48507 count_masked_bytes 0-1 48507 NULL
120290 +diva_os_copy_to_user_48508 diva_os_copy_to_user 4 48508 NULL
120291 +brcmf_sdio_trap_info_48510 brcmf_sdio_trap_info 4 48510 NULL
120292 +phantom_get_free_48514 phantom_get_free 0 48514 NULL
120293 +drbd_bm_capacity_48530 drbd_bm_capacity 0 48530 NULL
120294 +raid10_size_48571 raid10_size 0-2-3 48571 NULL
120295 +__mod_timer_48578 __mod_timer 0 48578 NULL
120296 +llog_data_len_48607 llog_data_len 1 48607 NULL
120297 +mlx4_init_steering_48623 mlx4_init_steering 0 48623 NULL
120298 +fnic_dev_init_48629 fnic_dev_init 0 48629 NULL
120299 +do_ip_vs_set_ctl_48641 do_ip_vs_set_ctl 4 48641 NULL
120300 +ll_rw_extents_stats_pp_seq_write_48651 ll_rw_extents_stats_pp_seq_write 3 48651 NULL
120301 +mtd_read_48655 mtd_read 0 48655 NULL
120302 +tg3_phy_toggle_auxctl_smdsp_48661 tg3_phy_toggle_auxctl_smdsp 0 48661 NULL
120303 +cx18_av_probe_48663 cx18_av_probe 0 48663 NULL
120304 +aes_encrypt_packets_read_48666 aes_encrypt_packets_read 3 48666 NULL
120305 +sm501_create_subdev_48668 sm501_create_subdev 3-4 48668 NULL
120306 +ubi_eba_unmap_leb_48671 ubi_eba_unmap_leb 0 48671 NULL
120307 +security_inode_setattr_48689 security_inode_setattr 0 48689 NULL
120308 +hysdn_log_write_48694 hysdn_log_write 3 48694 NULL
120309 +altera_drscan_48698 altera_drscan 2 48698 NULL
120310 +kvm_set_irq_routing_48704 kvm_set_irq_routing 3 48704 NULL
120311 +mwl8k_cmd_update_mac_addr_48706 mwl8k_cmd_update_mac_addr 0 48706 NULL
120312 +lpfc_idiag_drbacc_write_48712 lpfc_idiag_drbacc_write 3 48712 NULL
120313 +sysfs_rename_dir_ns_48717 sysfs_rename_dir_ns 0 48717 NULL
120314 +SyS_lgetxattr_48719 SyS_lgetxattr 4 48719 NULL
120315 +sht15_soft_reset_48724 sht15_soft_reset 0 48724 NULL
120316 +balloon_page_migrate_48740 balloon_page_migrate 0 48740 NULL
120317 +ath6kl_usb_bmi_read_48745 ath6kl_usb_bmi_read 3 48745 NULL
120318 +ath6kl_regwrite_read_48747 ath6kl_regwrite_read 3 48747 NULL
120319 +l2cap_segment_sdu_48772 l2cap_segment_sdu 4 48772 NULL nohasharray
120320 +lx_dsp_get_clock_frequency_48772 lx_dsp_get_clock_frequency 0 48772 &l2cap_segment_sdu_48772
120321 +gfs2_direct_IO_48774 gfs2_direct_IO 4 48774 NULL
120322 +tg3_phy_init_48799 tg3_phy_init 0 48799 NULL
120323 +il3945_sta_dbgfs_stats_table_read_48802 il3945_sta_dbgfs_stats_table_read 3 48802 NULL
120324 +twa_change_queue_depth_48808 twa_change_queue_depth 2 48808 NULL
120325 +atomic_counters_read_48827 atomic_counters_read 3 48827 NULL
120326 +azx_get_position_48841 azx_get_position 0 48841 NULL
120327 +vc_do_resize_48842 vc_do_resize 3-4 48842 NULL
120328 +comedi_buf_write_alloc_48846 comedi_buf_write_alloc 0-2 48846 NULL
120329 +suspend_dtim_interval_write_48854 suspend_dtim_interval_write 3 48854 NULL
120330 +C_SYSC_pwritev64_48864 C_SYSC_pwritev64 3 48864 NULL nohasharray
120331 +viafb_dvp1_proc_write_48864 viafb_dvp1_proc_write 3 48864 &C_SYSC_pwritev64_48864
120332 +__ffs_ep0_read_events_48868 __ffs_ep0_read_events 3 48868 NULL
120333 +__platform_driver_register_48882 __platform_driver_register 0 48882 NULL
120334 +devm_regulator_register_supply_alias_48888 devm_regulator_register_supply_alias 0 48888 NULL
120335 +crypto_cipher_ctxsize_48890 crypto_cipher_ctxsize 0 48890 NULL
120336 +joydev_handle_JSIOCSAXMAP_48898 joydev_handle_JSIOCSAXMAP 3 48898 NULL nohasharray
120337 +adap_init0_no_config_48898 adap_init0_no_config 0 48898 &joydev_handle_JSIOCSAXMAP_48898
120338 +xdi_copy_to_user_48900 xdi_copy_to_user 4 48900 NULL
120339 +msg_hdr_sz_48908 msg_hdr_sz 0 48908 NULL
120340 +snd_pcm_update_hw_ptr_48925 snd_pcm_update_hw_ptr 0 48925 NULL
120341 +sep_crypto_dma_48937 sep_crypto_dma 0 48937 NULL
120342 +si5351_write_parameters_48940 si5351_write_parameters 2 48940 NULL
120343 +event_heart_beat_read_48961 event_heart_beat_read 3 48961 NULL
120344 +nand_ecc_test_run_48966 nand_ecc_test_run 1 48966 NULL
120345 +vmci_handle_arr_create_48971 vmci_handle_arr_create 1 48971 NULL
120346 +myri10ge_send_cmd_48980 myri10ge_send_cmd 0 48980 NULL
120347 +xfs_trans_commit_48982 xfs_trans_commit 0 48982 NULL
120348 +gfs2_dir_add_48987 gfs2_dir_add 0 48987 NULL
120349 +mlx4_uar_alloc_48992 mlx4_uar_alloc 0 48992 NULL
120350 +rds_rm_size_48996 rds_rm_size 0-2 48996 NULL
120351 +sel_write_enforce_48998 sel_write_enforce 3 48998 NULL
120352 +null_alloc_rs_49019 null_alloc_rs 2 49019 NULL nohasharray
120353 +mlx4_RUN_FW_49019 mlx4_RUN_FW 0 49019 &null_alloc_rs_49019
120354 +filemap_check_errors_49022 filemap_check_errors 0 49022 NULL
120355 +transient_status_49027 transient_status 4 49027 NULL
120356 +ll_xattr_cache_add_49032 ll_xattr_cache_add 4-0 49032 NULL
120357 +sta2x11_vip_init_buffer_49091 sta2x11_vip_init_buffer 0 49091 NULL
120358 +scsi_register_49094 scsi_register 2 49094 NULL
120359 +compat_do_readv_writev_49102 compat_do_readv_writev 4 49102 NULL
120360 +gfs2_diradd_alloc_required_49105 gfs2_diradd_alloc_required 0 49105 NULL
120361 +xfrm_replay_state_esn_len_49119 xfrm_replay_state_esn_len 0 49119 NULL
120362 +ll_max_cached_mb_seq_write_49122 ll_max_cached_mb_seq_write 3 49122 NULL
120363 +pt_read_49136 pt_read 3 49136 NULL nohasharray
120364 +netxen_setup_msi_interrupts_49136 netxen_setup_msi_interrupts 2 49136 &pt_read_49136
120365 +read_file_49137 read_file 4 49137 NULL
120366 +ipwireless_tty_received_49154 ipwireless_tty_received 3 49154 NULL
120367 +f2fs_acl_count_49155 f2fs_acl_count 0-1 49155 NULL
120368 +ipw_queue_tx_init_49161 ipw_queue_tx_init 3 49161 NULL
120369 +__jfs_setxattr_49175 __jfs_setxattr 5 49175 NULL
120370 +ath6kl_bgscan_int_write_49178 ath6kl_bgscan_int_write 3 49178 NULL
120371 +dvb_dvr_ioctl_49182 dvb_dvr_ioctl 2 49182 NULL
120372 +print_queue_49191 print_queue 4-0 49191 NULL
120373 +root_nfs_cat_49192 root_nfs_cat 3 49192 NULL
120374 +iwl_dbgfs_ucode_general_stats_read_49199 iwl_dbgfs_ucode_general_stats_read 3 49199 NULL
120375 +asd_init_post_escbs_49200 asd_init_post_escbs 0 49200 NULL
120376 +il4965_rs_sta_dbgfs_stats_table_read_49206 il4965_rs_sta_dbgfs_stats_table_read 3 49206 NULL
120377 +do_jffs2_getxattr_49210 do_jffs2_getxattr 0 49210 NULL
120378 +nouveau_therm_create__49228 nouveau_therm_create_ 4 49228 NULL
120379 +ieee80211_if_read_rssi_threshold_49260 ieee80211_if_read_rssi_threshold 3 49260 NULL
120380 +isku_sysfs_read_keys_media_49268 isku_sysfs_read_keys_media 6 49268 NULL
120381 +ptlrpc_check_set_49277 ptlrpc_check_set 0 49277 NULL
120382 +rx_filter_beacon_filter_read_49279 rx_filter_beacon_filter_read 3 49279 NULL
120383 +viafb_dfph_proc_write_49288 viafb_dfph_proc_write 3 49288 NULL
120384 +uio_read_49300 uio_read 3 49300 NULL
120385 +isku_sysfs_read_keys_macro_49312 isku_sysfs_read_keys_macro 6 49312 NULL
120386 +SYSC_mincore_49319 SYSC_mincore 2-1 49319 NULL
120387 +fwtty_port_handler_49327 fwtty_port_handler 9 49327 NULL
120388 +srpt_alloc_ioctx_ring_49330 srpt_alloc_ioctx_ring 2-4-3 49330 NULL
120389 +myri10ge_get_firmware_capabilities_49339 myri10ge_get_firmware_capabilities 0 49339 NULL
120390 +joydev_ioctl_common_49359 joydev_ioctl_common 2 49359 NULL
120391 +ipr_probe_ioa_part2_49365 ipr_probe_ioa_part2 0 49365 NULL
120392 +iscsi_alloc_session_49390 iscsi_alloc_session 3 49390 NULL
120393 +ext4_ext_index_trans_blocks_49396 ext4_ext_index_trans_blocks 0 49396 NULL
120394 +rx_streaming_always_read_49401 rx_streaming_always_read 3 49401 NULL
120395 +tnode_alloc_49407 tnode_alloc 1 49407 NULL
120396 +acpi_check_resource_conflict_49420 acpi_check_resource_conflict 0 49420 NULL
120397 +samples_to_bytes_49426 samples_to_bytes 0-2 49426 NULL
120398 +compat_do_msg_fill_49440 compat_do_msg_fill 3 49440 NULL
120399 +ocfs2_merge_rec_left_49455 ocfs2_merge_rec_left 0 49455 NULL
120400 +__hfsplus_getxattr_49460 __hfsplus_getxattr 0 49460 NULL
120401 +be_mcc_compl_process_49462 be_mcc_compl_process 0 49462 NULL
120402 +agp_3_5_isochronous_node_enable_49465 agp_3_5_isochronous_node_enable 3 49465 NULL
120403 +xfs_iformat_local_49472 xfs_iformat_local 4-0 49472 NULL
120404 +isr_decrypt_done_read_49490 isr_decrypt_done_read 3 49490 NULL
120405 +iwl_dbgfs_disable_power_off_read_49517 iwl_dbgfs_disable_power_off_read 3 49517 NULL
120406 +SyS_listxattr_49519 SyS_listxattr 3 49519 NULL
120407 +emulator_write_phys_49520 emulator_write_phys 2-4 49520 NULL
120408 +rx_queue_add_kobject_49559 rx_queue_add_kobject 0 49559 NULL
120409 +smk_write_access_49561 smk_write_access 3 49561 NULL
120410 +alloc_chunk_49575 alloc_chunk 1 49575 NULL
120411 +sctp_setsockopt_default_send_param_49578 sctp_setsockopt_default_send_param 3 49578 NULL
120412 +readfifo_49583 readfifo 1 49583 NULL
120413 +gfs2_quota_lock_49587 gfs2_quota_lock 0 49587 NULL
120414 +evm_inode_setattr_49594 evm_inode_setattr 0 49594 NULL
120415 +tap_write_49595 tap_write 3 49595 NULL
120416 +mem_cgroup_charge_file_49596 mem_cgroup_charge_file 0 49596 NULL
120417 +isr_wakeups_read_49607 isr_wakeups_read 3 49607 NULL
120418 +btrfs_mksubvol_49616 btrfs_mksubvol 3 49616 NULL
120419 +heap_init_49617 heap_init 2 49617 NULL
120420 +smk_write_doi_49621 smk_write_doi 3 49621 NULL nohasharray
120421 +ath10k_htc_init_49621 ath10k_htc_init 0 49621 &smk_write_doi_49621
120422 +port_fops_read_49626 port_fops_read 3 49626 NULL
120423 +btrfsic_cmp_log_and_dev_bytenr_49628 btrfsic_cmp_log_and_dev_bytenr 2 49628 NULL
120424 +xfs_ialloc_get_rec_49648 xfs_ialloc_get_rec 0 49648 NULL
120425 +mthca_cmd_poll_49664 mthca_cmd_poll 0 49664 NULL
120426 +aa_simple_write_to_buffer_49683 aa_simple_write_to_buffer 4-3 49683 NULL
120427 +ath9k_hw_post_init_49686 ath9k_hw_post_init 0 49686 NULL
120428 +SyS_pwritev_49688 SyS_pwritev 3 49688 NULL
120429 +__setup_irq_49696 __setup_irq 0 49696 NULL
120430 +__copy_from_user_nocheck_49699 __copy_from_user_nocheck 0-3 49699 NULL
120431 +cx2341x_ctrl_new_menu_49700 cx2341x_ctrl_new_menu 3 49700 NULL
120432 +get_key_haup_common_49709 get_key_haup_common 4 49709 NULL
120433 +do_splice_to_49714 do_splice_to 4 49714 NULL
120434 +write_pool_49718 write_pool 3 49718 NULL
120435 +kvm_mmu_notifier_invalidate_page_49723 kvm_mmu_notifier_invalidate_page 3 49723 NULL
120436 +mlx4_QUERY_HCA_49727 mlx4_QUERY_HCA 0 49727 NULL
120437 +sep_create_dcb_dmatables_context_kernel_49728 sep_create_dcb_dmatables_context_kernel 6 49728 NULL
120438 +zd_usb_iowrite16v_49744 zd_usb_iowrite16v 3 49744 NULL
120439 +btrfs_chunk_num_stripes_49751 btrfs_chunk_num_stripes 0 49751 NULL
120440 +fuse_wr_pages_49753 fuse_wr_pages 0-2-1 49753 NULL
120441 +key_conf_keylen_read_49758 key_conf_keylen_read 3 49758 NULL
120442 +fuse_conn_waiting_read_49762 fuse_conn_waiting_read 3 49762 NULL
120443 +w83977af_fir_interrupt_49775 w83977af_fir_interrupt 0 49775 NULL
120444 +ceph_osdc_readpages_49789 ceph_osdc_readpages 0 49789 NULL
120445 +nfs4_acl_new_49806 nfs4_acl_new 1 49806 NULL
120446 +__of_parse_phandle_with_args_49807 __of_parse_phandle_with_args 0 49807 NULL
120447 +asd_init_phys_49814 asd_init_phys 0 49814 NULL
120448 +ntfs_copy_from_user_iovec_49829 ntfs_copy_from_user_iovec 6-3-0 49829 NULL
120449 +add_uuid_49831 add_uuid 4 49831 NULL
120450 +mlx4_QUERY_ADAPTER_49838 mlx4_QUERY_ADAPTER 0 49838 NULL
120451 +iraw_loop_49842 iraw_loop 0-1 49842 NULL
120452 +lm8323_write_49845 lm8323_write 2 49845 NULL
120453 +twl4030_write_49846 twl4030_write 2 49846 NULL
120454 +scsi_dispatch_cmd_entry_49848 scsi_dispatch_cmd_entry 3 49848 NULL
120455 +timeradd_entry_49850 timeradd_entry 3 49850 NULL
120456 +fiemap_count_to_size_49869 fiemap_count_to_size 0-1 49869 NULL
120457 +sctp_setsockopt_bindx_49870 sctp_setsockopt_bindx 3 49870 NULL
120458 +osc_brw_49896 osc_brw 4 49896 NULL
120459 +mvumi_init_fw_49929 mvumi_init_fw 0 49929 NULL
120460 +config_ep_by_speed_49939 config_ep_by_speed 0 49939 NULL
120461 +xfs_ialloc_ag_alloc_49960 xfs_ialloc_ag_alloc 0 49960 NULL
120462 +ieee80211_if_fmt_dtim_count_49987 ieee80211_if_fmt_dtim_count 3 49987 NULL
120463 +drm_buffer_copy_from_user_49990 drm_buffer_copy_from_user 3 49990 NULL
120464 +l2cap_chan_send_49995 l2cap_chan_send 3 49995 NULL
120465 +dn_mss_from_pmtu_50011 dn_mss_from_pmtu 0-2 50011 NULL
120466 +xfs_ialloc_inode_init_50015 xfs_ialloc_inode_init 0 50015 NULL
120467 +register_inetaddr_notifier_50016 register_inetaddr_notifier 0 50016 NULL
120468 +security_context_to_sid_50019 security_context_to_sid 2 50019 NULL
120469 +isdn_read_50021 isdn_read 3 50021 NULL
120470 +mdc_rename_pack_50023 mdc_rename_pack 4-6 50023 NULL nohasharray
120471 +move_to_new_page_50023 move_to_new_page 0 50023 &mdc_rename_pack_50023
120472 +brcmf_debugfs_chipinfo_read_50033 brcmf_debugfs_chipinfo_read 3 50033 NULL
120473 +ioread8_50049 ioread8 0 50049 NULL
120474 +fuse_conn_max_background_write_50061 fuse_conn_max_background_write 3 50061 NULL
120475 +__kfifo_dma_in_prepare_50081 __kfifo_dma_in_prepare 4 50081 NULL
120476 +dev_set_alias_50084 dev_set_alias 3 50084 NULL
120477 +libcfs_ioctl_popdata_50087 libcfs_ioctl_popdata 3 50087 NULL
120478 +sock_setsockopt_50088 sock_setsockopt 5 50088 NULL
120479 +altera_swap_dr_50090 altera_swap_dr 2 50090 NULL
120480 +android_set_cntry_50100 android_set_cntry 0 50100 NULL
120481 +read_file_slot_50111 read_file_slot 3 50111 NULL
120482 +rx_streaming_interval_write_50120 rx_streaming_interval_write 3 50120 NULL
120483 +jfs_direct_IO_50125 jfs_direct_IO 4 50125 NULL nohasharray
120484 +ocfs2_search_one_group_50125 ocfs2_search_one_group 0 50125 &jfs_direct_IO_50125
120485 +SYSC_preadv_50134 SYSC_preadv 3 50134 NULL
120486 +clk_round_rate_50144 clk_round_rate 0 50144 NULL
120487 +tx_frag_need_fragmentation_read_50153 tx_frag_need_fragmentation_read 3 50153 NULL
120488 +xfs_bwrite_50154 xfs_bwrite 0 50154 NULL
120489 +kmalloc_node_50163 kmalloc_node 1 50163 NULL
120490 +rx_filter_ibss_filter_read_50167 rx_filter_ibss_filter_read 3 50167 NULL
120491 +ahd_probe_stack_size_50168 ahd_probe_stack_size 0 50168 NULL
120492 +odev_update_50169 odev_update 2 50169 NULL
120493 +ubi_resize_volume_50172 ubi_resize_volume 2 50172 NULL nohasharray
120494 +ieee80211_if_fmt_dot11MeshHWMPRannInterval_50172 ieee80211_if_fmt_dot11MeshHWMPRannInterval 3 50172 &ubi_resize_volume_50172 nohasharray
120495 +xfs_get_blocks_direct_50172 xfs_get_blocks_direct 2 50172 &ieee80211_if_fmt_dot11MeshHWMPRannInterval_50172
120496 +cfg80211_roamed_bss_50198 cfg80211_roamed_bss 4-6 50198 NULL
120497 +cyttsp4_probe_50201 cyttsp4_probe 4 50201 NULL
120498 +rx_rx_timeout_wa_read_50204 rx_rx_timeout_wa_read 3 50204 NULL
120499 +mthca_buddy_init_50206 mthca_buddy_init 2 50206 NULL nohasharray
120500 +compat_SyS_sendfile_50206 compat_SyS_sendfile 4 50206 &mthca_buddy_init_50206
120501 +l2cap_sock_setsockopt_50207 l2cap_sock_setsockopt 5 50207 NULL
120502 +mon_bin_compat_ioctl_50234 mon_bin_compat_ioctl 3 50234 NULL
120503 +sg_kmalloc_50240 sg_kmalloc 1 50240 NULL
120504 +adpt_detect_50252 adpt_detect 0 50252 NULL
120505 +igb_init_interrupt_scheme_50262 igb_init_interrupt_scheme 0 50262 NULL
120506 +rxrpc_setsockopt_50286 rxrpc_setsockopt 5 50286 NULL
120507 +soc_codec_reg_show_50302 soc_codec_reg_show 0-3 50302 NULL
120508 +SYSC_flistxattr_50307 SYSC_flistxattr 3 50307 NULL
120509 +SYSC_sched_setaffinity_50310 SYSC_sched_setaffinity 2 50310 NULL
120510 +soc_camera_read_50319 soc_camera_read 3 50319 NULL
120511 +do_launder_page_50329 do_launder_page 0 50329 NULL
120512 +nouveau_engine_create__50331 nouveau_engine_create_ 7 50331 NULL
120513 +lpfc_idiag_pcicfg_read_50334 lpfc_idiag_pcicfg_read 3 50334 NULL
120514 +snd_pcm_lib_writev_50337 snd_pcm_lib_writev 0-3 50337 NULL
120515 +tpm_read_50344 tpm_read 3 50344 NULL
120516 +isdn_ppp_read_50356 isdn_ppp_read 4 50356 NULL
120517 +iwl_dbgfs_echo_test_write_50362 iwl_dbgfs_echo_test_write 3 50362 NULL nohasharray
120518 +ocfs2_figure_insert_type_50362 ocfs2_figure_insert_type 0 50362 &iwl_dbgfs_echo_test_write_50362
120519 +xfrm_send_migrate_50365 xfrm_send_migrate 5 50365 NULL nohasharray
120520 +snd_vortex_midi_50365 snd_vortex_midi 0 50365 &xfrm_send_migrate_50365
120521 +roccat_common2_receive_50369 roccat_common2_receive 4 50369 NULL
120522 +ath10k_core_start_50376 ath10k_core_start 0 50376 NULL
120523 +sl_alloc_bufs_50380 sl_alloc_bufs 2 50380 NULL
120524 +l2tp_ip_sendmsg_50411 l2tp_ip_sendmsg 4 50411 NULL
120525 +iscsi_create_conn_50425 iscsi_create_conn 2 50425 NULL
120526 +validate_acl_mac_addrs_50429 validate_acl_mac_addrs 0 50429 NULL
120527 +uvc_video_init_50433 uvc_video_init 0 50433 NULL
120528 +xfs_alloc_update_counters_50441 xfs_alloc_update_counters 0 50441 NULL
120529 +btrfs_error_discard_extent_50444 btrfs_error_discard_extent 2 50444 NULL nohasharray
120530 +ecryptfs_write_lower_page_segment_50444 ecryptfs_write_lower_page_segment 4 50444 &btrfs_error_discard_extent_50444
120531 +mlx4_init_icm_50447 mlx4_init_icm 0 50447 NULL
120532 +pgctrl_write_50453 pgctrl_write 3 50453 NULL
120533 +usb_amradio_init_50455 usb_amradio_init 0 50455 NULL
120534 +device_create_sys_dev_entry_50458 device_create_sys_dev_entry 0 50458 NULL
120535 +cfs_size_round_50472 cfs_size_round 0-1 50472 NULL
120536 +cdrom_read_cdda_50478 cdrom_read_cdda 4 50478 NULL
120537 +t3_mgmt_tx_50484 t3_mgmt_tx 0 50484 NULL
120538 +xfs_iformat_extents_50486 xfs_iformat_extents 0 50486 NULL
120539 +gfs2_block_map_50492 gfs2_block_map 0 50492 NULL
120540 +mei_io_cb_alloc_req_buf_50493 mei_io_cb_alloc_req_buf 2 50493 NULL
120541 +of_irq_parse_one_50494 of_irq_parse_one 0 50494 NULL
120542 +pwr_rcvd_awake_beacons_read_50505 pwr_rcvd_awake_beacons_read 3 50505 NULL
120543 +be_msix_register_50512 be_msix_register 0 50512 NULL
120544 +ath10k_wmi_10x_cmd_init_50518 ath10k_wmi_10x_cmd_init 0 50518 NULL
120545 +lpfc_rq_create_50524 lpfc_rq_create 0 50524 NULL
120546 +velocity_init_rings_50538 velocity_init_rings 0 50538 NULL
120547 +ath6kl_set_ap_probe_resp_ies_50539 ath6kl_set_ap_probe_resp_ies 3 50539 NULL
120548 +bh_get_50543 bh_get 0 50543 NULL
120549 +gfs2_meta_inode_buffer_50544 gfs2_meta_inode_buffer 0 50544 NULL
120550 +usbat_flash_write_data_50553 usbat_flash_write_data 4 50553 NULL
120551 +self_check_peb_vid_hdr_50563 self_check_peb_vid_hdr 0 50563 NULL
120552 +fat_readpages_50582 fat_readpages 4 50582 NULL
120553 +iwl_dbgfs_missed_beacon_read_50584 iwl_dbgfs_missed_beacon_read 3 50584 NULL
120554 +build_inv_iommu_pages_50589 build_inv_iommu_pages 2-3 50589 NULL
120555 +xillybus_write_50605 xillybus_write 3 50605 NULL
120556 +rx_rx_checksum_result_read_50617 rx_rx_checksum_result_read 3 50617 NULL
120557 +ocfs2_split_extent_50618 ocfs2_split_extent 0 50618 NULL
120558 +sparse_early_usemaps_alloc_node_50623 sparse_early_usemaps_alloc_node 4 50623 NULL
120559 +simple_transaction_get_50633 simple_transaction_get 3 50633 NULL
120560 +gfs2_unstuff_dinode_50644 gfs2_unstuff_dinode 0 50644 NULL
120561 +ocfs2_do_insert_extent_50658 ocfs2_do_insert_extent 0 50658 NULL
120562 +ath6kl_tm_rx_event_50664 ath6kl_tm_rx_event 3 50664 NULL
120563 +bnad_debugfs_read_50665 bnad_debugfs_read 3 50665 NULL
120564 +__mlx4_counter_alloc_50677 __mlx4_counter_alloc 0 50677 NULL
120565 +prism2_read_fid_reg_50689 prism2_read_fid_reg 0 50689 NULL nohasharray
120566 +i2c_smbus_read_byte_data_50689 i2c_smbus_read_byte_data 0 50689 &prism2_read_fid_reg_50689
120567 +xfs_growfs_get_hdr_buf_50697 xfs_growfs_get_hdr_buf 3 50697 NULL
120568 +dev_mem_read_50706 dev_mem_read 3 50706 NULL
120569 +blk_check_plugged_50736 blk_check_plugged 3 50736 NULL
120570 +xen_initdom_setup_msi_irqs_50737 xen_initdom_setup_msi_irqs 2 50737 NULL
120571 +__ext3_get_inode_loc_50744 __ext3_get_inode_loc 0 50744 NULL
120572 +ocfs2_xattr_block_get_50773 ocfs2_xattr_block_get 0 50773 NULL
120573 +tm6000_read_write_usb_50774 tm6000_read_write_usb 7 50774 NULL
120574 +bio_alloc_map_data_50782 bio_alloc_map_data 2 50782 NULL
120575 +ixgbe_acquire_msix_vectors_50789 ixgbe_acquire_msix_vectors 2 50789 NULL
120576 +tpm_write_50798 tpm_write 3 50798 NULL
120577 +tun_do_read_50800 tun_do_read 4 50800 NULL
120578 +write_flush_50803 write_flush 3 50803 NULL
120579 +dvb_play_50814 dvb_play 3 50814 NULL
120580 +btrfs_stack_file_extent_disk_num_bytes_50825 btrfs_stack_file_extent_disk_num_bytes 0 50825 NULL
120581 +dpcm_show_state_50827 dpcm_show_state 0 50827 NULL nohasharray
120582 +init_rx_ring_50827 init_rx_ring 0 50827 &dpcm_show_state_50827
120583 +SetArea_50835 SetArea 4 50835 NULL
120584 +videobuf_dma_init_user_50839 videobuf_dma_init_user 4-3 50839 NULL
120585 +self_check_write_50856 self_check_write 0 50856 NULL
120586 +carl9170_debugfs_write_50857 carl9170_debugfs_write 3 50857 NULL
120587 +v4l2_ctrl_add_handler_50888 v4l2_ctrl_add_handler 0 50888 NULL
120588 +SyS_lgetxattr_50889 SyS_lgetxattr 4 50889 NULL
120589 +mlx5_cmd_status_to_err_50891 mlx5_cmd_status_to_err 0 50891 NULL
120590 +netlbl_secattr_catmap_walk_rng_50894 netlbl_secattr_catmap_walk_rng 0-2 50894 NULL
120591 +__bdev_writeseg_50903 __bdev_writeseg 4 50903 NULL
120592 +xfs_alloc_get_freelist_50906 xfs_alloc_get_freelist 0 50906 NULL
120593 +xfs_iext_remove_50909 xfs_iext_remove 3 50909 NULL
120594 +blk_rq_cur_sectors_50910 blk_rq_cur_sectors 0 50910 NULL
120595 +hash_recvmsg_50924 hash_recvmsg 4 50924 NULL
120596 +chd_dec_fetch_cdata_50926 chd_dec_fetch_cdata 3 50926 NULL
120597 +show_device_status_50947 show_device_status 0 50947 NULL
120598 +irq_timeout_write_50950 irq_timeout_write 3 50950 NULL
120599 +virtio_cread16_50951 virtio_cread16 0 50951 NULL
120600 +sdio_uart_write_50954 sdio_uart_write 3 50954 NULL
120601 +SyS_setxattr_50957 SyS_setxattr 4 50957 NULL
120602 +typhoon_start_runtime_50974 typhoon_start_runtime 0 50974 NULL
120603 +of_modalias_node_50975 of_modalias_node 3 50975 NULL
120604 +iwl_statistics_flag_50981 iwl_statistics_flag 0-3 50981 NULL
120605 +timeout_write_50991 timeout_write 3 50991 NULL
120606 +asd_seq_start_cseq_51001 asd_seq_start_cseq 0 51001 NULL
120607 +proc_write_51003 proc_write 3 51003 NULL
120608 +jbd2_journal_extend_51012 jbd2_journal_extend 2 51012 NULL
120609 +lbs_dev_info_51023 lbs_dev_info 3 51023 NULL
120610 +fuse_conn_congestion_threshold_read_51028 fuse_conn_congestion_threshold_read 3 51028 NULL
120611 +BcmGetSectionValEndOffset_51039 BcmGetSectionValEndOffset 0 51039 NULL
120612 +dump_midi_51040 dump_midi 3 51040 NULL
120613 +usb_get_descriptor_51041 usb_get_descriptor 0 51041 NULL
120614 +srpt_alloc_ioctx_51042 srpt_alloc_ioctx 2-3 51042 NULL
120615 +get_first_leaf_51044 get_first_leaf 0 51044 NULL
120616 +do_arpt_set_ctl_51053 do_arpt_set_ctl 4 51053 NULL
120617 +wusb_prf_64_51065 wusb_prf_64 7 51065 NULL
120618 +jbd2_journal_init_revoke_51088 jbd2_journal_init_revoke 2 51088 NULL
120619 +solo_enc_v4l2_init_51094 solo_enc_v4l2_init 0 51094 NULL
120620 +__ocfs2_find_path_51096 __ocfs2_find_path 0 51096 NULL
120621 +ti_recv_51110 ti_recv 3 51110 NULL
120622 +__atomic_notifier_call_chain_51130 __atomic_notifier_call_chain 0 51130 NULL
120623 +alloc_rtllib_51136 alloc_rtllib 1 51136 NULL
120624 +ath10k_bmi_write_memory_51137 ath10k_bmi_write_memory 0 51137 NULL
120625 +simple_xattr_set_51140 simple_xattr_set 4 51140 NULL
120626 +xfs_trans_get_efd_51148 xfs_trans_get_efd 3 51148 NULL
120627 +driver_attach_51156 driver_attach 0 51156 NULL
120628 +asd_chip_hardrst_51191 asd_chip_hardrst 0 51191 NULL
120629 +snd_pcm_unlink_51210 snd_pcm_unlink 0 51210 NULL
120630 +ath5k_hw_post_51224 ath5k_hw_post 0 51224 NULL
120631 +iwl_dbgfs_bcast_filters_macs_read_51231 iwl_dbgfs_bcast_filters_macs_read 3 51231 NULL
120632 +nf_ct_ext_create_51232 nf_ct_ext_create 3 51232 NULL
120633 +snd_pcm_write_51235 snd_pcm_write 3 51235 NULL
120634 +drm_property_create_51239 drm_property_create 4 51239 NULL
120635 +ath10k_bmi_fast_download_51242 ath10k_bmi_fast_download 0 51242 NULL
120636 +lx_init_xilinx_reset_51245 lx_init_xilinx_reset 0 51245 NULL
120637 +st_read_51251 st_read 3 51251 NULL
120638 +compat_dccp_setsockopt_51263 compat_dccp_setsockopt 5 51263 NULL
120639 +target_alloc_sgl_51264 target_alloc_sgl 3 51264 NULL
120640 +dvb_audio_write_51275 dvb_audio_write 3 51275 NULL
120641 +ipwireless_network_packet_received_51277 ipwireless_network_packet_received 4 51277 NULL
120642 +pvr2_std_id_to_str_51288 pvr2_std_id_to_str 2 51288 NULL
120643 +bnad_debugfs_read_regrd_51308 bnad_debugfs_read_regrd 3 51308 NULL
120644 +init_map_ipmac_51317 init_map_ipmac 5 51317 NULL
120645 +ocfs2_read_inode_block_51319 ocfs2_read_inode_block 0 51319 NULL
120646 +alloc_hippi_dev_51320 alloc_hippi_dev 1 51320 NULL
120647 +ext2_xattr_get_51327 ext2_xattr_get 0 51327 NULL
120648 +alloc_smp_req_51337 alloc_smp_req 1 51337 NULL
120649 +hpsa_controller_hard_reset_51338 hpsa_controller_hard_reset 0 51338 NULL
120650 +ipw_get_event_log_len_51341 ipw_get_event_log_len 0 51341 NULL
120651 +ieee80211_if_fmt_estab_plinks_51370 ieee80211_if_fmt_estab_plinks 3 51370 NULL
120652 +radeon_kms_compat_ioctl_51371 radeon_kms_compat_ioctl 2 51371 NULL
120653 +mlx4_cmd_init_51403 mlx4_cmd_init 0 51403 NULL
120654 +rtl8180_init_hw_51409 rtl8180_init_hw 0 51409 NULL
120655 +blk_register_region_51424 blk_register_region 1-2 51424 NULL
120656 +mwifiex_rdeeprom_read_51429 mwifiex_rdeeprom_read 3 51429 NULL
120657 +hfsplus_brec_read_51436 hfsplus_brec_read 0 51436 NULL
120658 +xfs_mod_incore_sb_unlocked_51439 xfs_mod_incore_sb_unlocked 0 51439 NULL
120659 +ieee80211_if_read_dot11MeshHWMPRootMode_51441 ieee80211_if_read_dot11MeshHWMPRootMode 3 51441 NULL
120660 +print_devstats_dot11ACKFailureCount_51443 print_devstats_dot11ACKFailureCount 3 51443 NULL
120661 +dvb_register_frontend_51453 dvb_register_frontend 0 51453 NULL
120662 +vmxnet3_acquire_msix_vectors_51462 vmxnet3_acquire_msix_vectors 2 51462 NULL
120663 +____alloc_ei_netdev_51475 ____alloc_ei_netdev 1 51475 NULL
120664 +xfs_buf_get_uncached_51477 xfs_buf_get_uncached 2 51477 NULL
120665 +lpfc_sli4_read_rev_51480 lpfc_sli4_read_rev 0 51480 NULL
120666 +kvm_fetch_guest_virt_51493 kvm_fetch_guest_virt 4-2 51493 NULL
120667 +ieee80211_if_write_uapsd_queues_51526 ieee80211_if_write_uapsd_queues 3 51526 NULL
120668 +vortex_core_init_51535 vortex_core_init 0 51535 NULL
120669 +__alloc_eip_netdev_51549 __alloc_eip_netdev 1 51549 NULL
120670 +batadv_tt_prepare_tvlv_local_data_51568 batadv_tt_prepare_tvlv_local_data 0 51568 NULL
120671 +va1j5jf8007s_prepare_1_51575 va1j5jf8007s_prepare_1 0 51575 NULL
120672 +ixgb_get_eeprom_len_51586 ixgb_get_eeprom_len 0 51586 NULL nohasharray
120673 +snd_msndmix_new_51586 snd_msndmix_new 0 51586 &ixgb_get_eeprom_len_51586
120674 +aac_convert_sgraw2_51598 aac_convert_sgraw2 4 51598 NULL
120675 +table_size_to_number_of_entries_51613 table_size_to_number_of_entries 0-1 51613 NULL
120676 +extent_fiemap_51621 extent_fiemap 3 51621 NULL
120677 +ath10k_core_probe_fw_51628 ath10k_core_probe_fw 0 51628 NULL
120678 +mlx4_INIT_HCA_51640 mlx4_INIT_HCA 0 51640 NULL
120679 +sctp_auth_create_key_51641 sctp_auth_create_key 1 51641 NULL
120680 +iscsi_create_session_51647 iscsi_create_session 3 51647 NULL
120681 +xfs_iformat_btree_51651 xfs_iformat_btree 0 51651 NULL
120682 +ps_upsd_utilization_read_51669 ps_upsd_utilization_read 3 51669 NULL
120683 +sctp_setsockopt_associnfo_51684 sctp_setsockopt_associnfo 3 51684 NULL
120684 +rtw_os_xmit_resource_alloc23a_51693 rtw_os_xmit_resource_alloc23a 3 51693 NULL
120685 +host_mapping_level_51696 host_mapping_level 0 51696 NULL
120686 +atomic_notifier_chain_register_51697 atomic_notifier_chain_register 0 51697 NULL
120687 +sel_write_access_51704 sel_write_access 3 51704 NULL
120688 +tty_cdev_add_51714 tty_cdev_add 2-4 51714 NULL
120689 +v9fs_alloc_rdir_buf_51716 v9fs_alloc_rdir_buf 2 51716 NULL
120690 +drm_compat_ioctl_51717 drm_compat_ioctl 2 51717 NULL
120691 +sg_read_oxfer_51724 sg_read_oxfer 3 51724 NULL
120692 +cm4040_read_51732 cm4040_read 3 51732 NULL
120693 +get_user_pages_fast_51751 get_user_pages_fast 0 51751 NULL
120694 +ifx_spi_insert_flip_string_51752 ifx_spi_insert_flip_string 3 51752 NULL
120695 +if_write_51756 if_write 3 51756 NULL
120696 +res_tracker_insert_51757 res_tracker_insert 0 51757 NULL
120697 +iio_buffer_add_channel_sysfs_51766 iio_buffer_add_channel_sysfs 0 51766 NULL
120698 +ican3_set_termination_51769 ican3_set_termination 0 51769 NULL
120699 +ssd1307fb_alloc_array_51788 ssd1307fb_alloc_array 1 51788 NULL
120700 +qib_alloc_devdata_51819 qib_alloc_devdata 2 51819 NULL
120701 +buffer_from_user_51826 buffer_from_user 3 51826 NULL
120702 +topology_add_dev_51831 topology_add_dev 0 51831 NULL
120703 +ioread32_51847 ioread32 0 51847 NULL nohasharray
120704 +read_file_tgt_tx_stats_51847 read_file_tgt_tx_stats 3 51847 &ioread32_51847
120705 +do_readv_writev_51849 do_readv_writev 4 51849 NULL
120706 +SYSC_sendto_51852 SYSC_sendto 6 51852 NULL
120707 +bm_page_io_async_51858 bm_page_io_async 2 51858 NULL
120708 +pointer_size_read_51863 pointer_size_read 3 51863 NULL
120709 +get_indirect_ea_51869 get_indirect_ea 4 51869 NULL
120710 +user_read_51881 user_read 3 51881 NULL
120711 +dbAdjCtl_51888 dbAdjCtl 0 51888 NULL
120712 +SyS_mq_timedsend_51896 SyS_mq_timedsend 3 51896 NULL nohasharray
120713 +virt_to_phys_51896 virt_to_phys 0 51896 &SyS_mq_timedsend_51896
120714 +wmi_set_ie_51919 wmi_set_ie 3 51919 NULL
120715 +dbg_status_buf_51930 dbg_status_buf 2 51930 NULL
120716 +__tcp_mtu_to_mss_51938 __tcp_mtu_to_mss 0-2 51938 NULL
120717 +xfrm_alg_len_51940 xfrm_alg_len 0 51940 NULL nohasharray
120718 +remove_xrcdn_ok_51940 remove_xrcdn_ok 0 51940 &xfrm_alg_len_51940
120719 +scsi_get_vpd_page_51951 scsi_get_vpd_page 4 51951 NULL nohasharray
120720 +solo_enc_init_51951 solo_enc_init 0 51951 &scsi_get_vpd_page_51951
120721 +snd_mask_min_51969 snd_mask_min 0 51969 NULL nohasharray
120722 +arizona_free_irq_51969 arizona_free_irq 2 51969 &snd_mask_min_51969
120723 +__blkdev_get_51972 __blkdev_get 0 51972 NULL nohasharray
120724 +read_page_51972 read_page 2 51972 &__blkdev_get_51972
120725 +get_zone_51981 get_zone 0-1 51981 NULL
120726 +ath6kl_sdio_alloc_prep_scat_req_51986 ath6kl_sdio_alloc_prep_scat_req 2 51986 NULL
120727 +_c4iw_write_mem_dma_51991 _c4iw_write_mem_dma 3 51991 NULL
120728 +__detect_osd_51993 __detect_osd 0 51993 NULL
120729 +dwc3_mode_write_51997 dwc3_mode_write 3 51997 NULL
120730 +scsi_sysfs_add_host_52010 scsi_sysfs_add_host 0 52010 NULL
120731 +skb_copy_datagram_from_iovec_52014 skb_copy_datagram_from_iovec 4-2-5 52014 NULL
120732 +rdmalt_52022 rdmalt 0 52022 NULL
120733 +override_release_52032 override_release 2 52032 NULL
120734 +mlx4_QUERY_FUNC_CAP_52041 mlx4_QUERY_FUNC_CAP 0 52041 NULL
120735 +end_port_52042 end_port 0 52042 NULL
120736 +dma_rx_errors_read_52045 dma_rx_errors_read 3 52045 NULL
120737 +msnd_fifo_write_52052 msnd_fifo_write 0-3 52052 NULL
120738 +dvb_ringbuffer_avail_52057 dvb_ringbuffer_avail 0 52057 NULL
120739 +regulator_disable_52058 regulator_disable 0 52058 NULL
120740 +__fuse_request_alloc_52060 __fuse_request_alloc 1 52060 NULL
120741 +isofs_readpages_52067 isofs_readpages 4 52067 NULL
120742 +mxuport_process_read_urb_data_52072 mxuport_process_read_urb_data 3 52072 NULL
120743 +nsm_get_handle_52089 nsm_get_handle 4 52089 NULL
120744 +ulist_add_merge_52096 ulist_add_merge 0 52096 NULL
120745 +o2net_debug_read_52105 o2net_debug_read 3 52105 NULL nohasharray
120746 +__mlx4_srq_alloc_icm_52105 __mlx4_srq_alloc_icm 0 52105 &o2net_debug_read_52105
120747 +split_scan_timeout_write_52128 split_scan_timeout_write 3 52128 NULL
120748 +retry_count_read_52129 retry_count_read 3 52129 NULL
120749 +snd_pcm_channel_info_user_52135 snd_pcm_channel_info_user 0 52135 NULL
120750 +xfs_btree_change_owner_52137 xfs_btree_change_owner 0 52137 NULL
120751 +gdm_usb_hci_send_52138 gdm_usb_hci_send 3 52138 NULL
120752 +sub_alloc_52140 sub_alloc 0 52140 NULL
120753 +hysdn_conf_write_52145 hysdn_conf_write 3 52145 NULL
120754 +htable_size_52148 htable_size 0-1 52148 NULL
120755 +gfs2_rs_alloc_52152 gfs2_rs_alloc 0 52152 NULL
120756 +smk_write_load2_52155 smk_write_load2 3 52155 NULL
120757 +SendEventNotification_52160 SendEventNotification 0 52160 NULL
120758 +ieee80211_if_read_dot11MeshRetryTimeout_52168 ieee80211_if_read_dot11MeshRetryTimeout 3 52168 NULL
120759 +mga_compat_ioctl_52170 mga_compat_ioctl 2 52170 NULL
120760 +ppa_init_52174 ppa_init 0 52174 NULL
120761 +print_prefix_52176 print_prefix 0 52176 NULL
120762 +proc_pid_readlink_52186 proc_pid_readlink 3 52186 NULL
120763 +reiserfs_posix_acl_from_disk_52191 reiserfs_posix_acl_from_disk 2 52191 NULL
120764 +vmci_qp_broker_alloc_52216 vmci_qp_broker_alloc 6-5 52216 NULL
120765 +de_init_rings_52222 de_init_rings 0 52222 NULL
120766 +mlx4_get_ownership_52227 mlx4_get_ownership 0 52227 NULL
120767 +ntb_bus_init_52228 ntb_bus_init 0 52228 NULL
120768 +fuse_request_alloc_52243 fuse_request_alloc 1 52243 NULL nohasharray
120769 +xfs_iomap_eof_align_last_fsb_52243 xfs_iomap_eof_align_last_fsb 0-3 52243 &fuse_request_alloc_52243
120770 +ocfs2_try_to_merge_extent_52244 ocfs2_try_to_merge_extent 0 52244 NULL
120771 +pm80x_request_irq_52250 pm80x_request_irq 2 52250 NULL
120772 +mdiobus_alloc_size_52259 mdiobus_alloc_size 1 52259 NULL
120773 +shrink_slab_52261 shrink_slab 2 52261 NULL
120774 +sisusbcon_do_font_op_52271 sisusbcon_do_font_op 9 52271 NULL
120775 +handle_supp_msgs_52284 handle_supp_msgs 4 52284 NULL
120776 +bcm2048_checkrev_52286 bcm2048_checkrev 0 52286 NULL
120777 +kobject_set_name_vargs_52309 kobject_set_name_vargs 0 52309 NULL
120778 +read_file_reset_52310 read_file_reset 3 52310 NULL
120779 +ssd1307fb_write_52315 ssd1307fb_write 3 52315 NULL
120780 +request_asymmetric_key_52317 request_asymmetric_key 2-4 52317 NULL
120781 +hwflags_read_52318 hwflags_read 3 52318 NULL
120782 +t3_sge_init_rspcntxt_52321 t3_sge_init_rspcntxt 0 52321 NULL
120783 +snd_pcm_hw_free_52327 snd_pcm_hw_free 0 52327 NULL
120784 +si470x_set_chan_52329 si470x_set_chan 0 52329 NULL
120785 +test_unaligned_bulk_52333 test_unaligned_bulk 3 52333 NULL
120786 +hur_len_52339 hur_len 0 52339 NULL
120787 +bytes_to_frames_52362 bytes_to_frames 0-2 52362 NULL nohasharray
120788 +cap_inode_killpriv_52362 cap_inode_killpriv 0 52362 &bytes_to_frames_52362
120789 +copy_entries_to_user_52367 copy_entries_to_user 1 52367 NULL
120790 +iwl_dump_fh_52371 iwl_dump_fh 0 52371 NULL
120791 +hfsplus_find_attr_52374 hfsplus_find_attr 0 52374 NULL
120792 +ocfs2_journal_access_eb_52377 ocfs2_journal_access_eb 0 52377 NULL
120793 +mq_emit_config_values_52378 mq_emit_config_values 3 52378 NULL
120794 +isdn_writebuf_stub_52383 isdn_writebuf_stub 4 52383 NULL
120795 +jfs_setxattr_52389 jfs_setxattr 4 52389 NULL
120796 +aer_inject_write_52399 aer_inject_write 3 52399 NULL
120797 +cyz_load_fw_52409 cyz_load_fw 0 52409 NULL nohasharray
120798 +get_device_info_52409 get_device_info 0 52409 &cyz_load_fw_52409
120799 +line6_midibuf_init_52425 line6_midibuf_init 2 52425 NULL
120800 +hso_serial_common_create_52428 hso_serial_common_create 4 52428 NULL
120801 +delay_status_52431 delay_status 5 52431 NULL
120802 +ath6kl_delete_qos_write_52435 ath6kl_delete_qos_write 3 52435 NULL
120803 +ieee80211_if_fmt_num_sta_ps_52438 ieee80211_if_fmt_num_sta_ps 3 52438 NULL
120804 +acpi_nvs_for_each_region_52448 acpi_nvs_for_each_region 0 52448 NULL
120805 +alauda_read_data_52452 alauda_read_data 3 52452 NULL
120806 +mlx4_register_device_52470 mlx4_register_device 0 52470 NULL
120807 +ieee80211_alloc_txb_52477 ieee80211_alloc_txb 1 52477 NULL
120808 +usb_tranzport_write_52479 usb_tranzport_write 3 52479 NULL
120809 +ocfs2_extend_no_holes_52483 ocfs2_extend_no_holes 3-4 52483 NULL
120810 +fd_do_rw_52495 fd_do_rw 3 52495 NULL
120811 +myri10ge_adopt_running_firmware_52498 myri10ge_adopt_running_firmware 0 52498 NULL
120812 +int_tasklet_entry_52500 int_tasklet_entry 3 52500 NULL
120813 +xfs_alloc_get_rec_52502 xfs_alloc_get_rec 0 52502 NULL
120814 +stex_handshake_52503 stex_handshake 0 52503 NULL
120815 +lmv_get_easize_52504 lmv_get_easize 0 52504 NULL
120816 +pm_qos_power_write_52513 pm_qos_power_write 3 52513 NULL
120817 +bt_sock_stream_recvmsg_52518 bt_sock_stream_recvmsg 4 52518 NULL
120818 +dup_variable_bug_52525 dup_variable_bug 3 52525 NULL
120819 +raw_recvmsg_52529 raw_recvmsg 4 52529 NULL
120820 +SyS_vmsplice_52540 SyS_vmsplice 3 52540 NULL nohasharray
120821 +mvumi_alloc_cmds_52540 mvumi_alloc_cmds 0 52540 &SyS_vmsplice_52540
120822 +dccpprobe_read_52549 dccpprobe_read 3 52549 NULL
120823 +ntfs_prepare_pages_for_non_resident_write_52556 ntfs_prepare_pages_for_non_resident_write 0 52556 NULL
120824 +debug_level_proc_write_52572 debug_level_proc_write 3 52572 NULL
120825 +kernfs_setattr_52583 kernfs_setattr 0 52583 NULL
120826 +isku_sysfs_read_macro_52587 isku_sysfs_read_macro 6 52587 NULL
120827 +snd_pcm_sw_params_52594 snd_pcm_sw_params 0 52594 NULL
120828 +SyS_setsockopt_52610 SyS_setsockopt 5 52610 NULL
120829 +ll_sa_entry_alloc_52611 ll_sa_entry_alloc 4 52611 NULL
120830 +vq_init_52634 vq_init 0 52634 NULL
120831 +tps80031_writes_52638 tps80031_writes 3-4 52638 NULL
120832 +brcmf_sdio_assert_info_52653 brcmf_sdio_assert_info 4 52653 NULL
120833 +nvme_queue_extra_52661 nvme_queue_extra 0-1 52661 NULL
120834 +SYSC_gethostname_52677 SYSC_gethostname 2 52677 NULL
120835 +reg_write_range_52690 reg_write_range 4 52690 NULL
120836 +nvd0_disp_pioc_create__52693 nvd0_disp_pioc_create_ 5 52693 NULL
120837 +nouveau_client_create__52715 nouveau_client_create_ 5 52715 NULL
120838 +__dm_stat_bio_52722 __dm_stat_bio 3 52722 NULL
120839 +cx25840_ir_rx_read_52724 cx25840_ir_rx_read 3 52724 NULL
120840 +blkcipher_next_slow_52733 blkcipher_next_slow 3-4 52733 NULL
120841 +pch_gbe_hal_read_mac_addr_52734 pch_gbe_hal_read_mac_addr 0 52734 NULL
120842 +relay_alloc_page_array_52735 relay_alloc_page_array 1 52735 NULL
120843 +hfcsusb_rx_frame_52745 hfcsusb_rx_frame 3 52745 NULL
120844 +snd_card_proc_new_52754 snd_card_proc_new 0 52754 NULL
120845 +carl9170_debugfs_vif_dump_read_52755 carl9170_debugfs_vif_dump_read 3 52755 NULL
120846 +ieee80211_if_read_beacon_timeout_52756 ieee80211_if_read_beacon_timeout 3 52756 NULL
120847 +nvme_trans_ext_inq_page_52776 nvme_trans_ext_inq_page 3 52776 NULL
120848 +pwr_rcvd_beacons_read_52836 pwr_rcvd_beacons_read 3 52836 NULL
120849 +lb_alloc_ep_req_52837 lb_alloc_ep_req 2 52837 NULL
120850 +mon_bin_get_event_52863 mon_bin_get_event 6-4 52863 NULL
120851 +twl6030_gpadc_write_52867 twl6030_gpadc_write 1 52867 NULL
120852 +qib_decode_6120_err_52876 qib_decode_6120_err 3 52876 NULL
120853 +twlreg_write_52880 twlreg_write 3 52880 NULL
120854 +pvr2_ctrl_value_to_sym_internal_52881 pvr2_ctrl_value_to_sym_internal 5 52881 NULL
120855 +cache_read_procfs_52882 cache_read_procfs 3 52882 NULL
120856 +kvm_kvzalloc_52894 kvm_kvzalloc 1 52894 NULL
120857 +arizona_request_irq_52908 arizona_request_irq 2 52908 NULL
120858 +dio_bio_reap_52913 dio_bio_reap 0 52913 NULL
120859 +__kfifo_out_peek_r_52919 __kfifo_out_peek_r 3 52919 NULL
120860 +iblock_get_bio_52936 iblock_get_bio 3 52936 NULL
120861 +__nodes_remap_52951 __nodes_remap 5 52951 NULL
120862 +ieee80211_if_fmt_fwded_mcast_52961 ieee80211_if_fmt_fwded_mcast 3 52961 NULL
120863 +ipg_reset_52970 ipg_reset 0 52970 NULL
120864 +niu_serdes_init_52980 niu_serdes_init 0 52980 NULL
120865 +lx_message_send_atomic_52981 lx_message_send_atomic 0 52981 NULL
120866 +tx_tx_exch_read_52986 tx_tx_exch_read 3 52986 NULL
120867 +num_node_state_52989 num_node_state 0 52989 NULL
120868 +efivarfs_file_write_53000 efivarfs_file_write 3 53000 NULL
120869 +btrfs_free_and_pin_reserved_extent_53016 btrfs_free_and_pin_reserved_extent 2 53016 NULL
120870 +tx_tx_exch_pending_read_53018 tx_tx_exch_pending_read 3 53018 NULL
120871 +xfs_rtfree_extent_53024 xfs_rtfree_extent 0 53024 NULL
120872 +ocfs2_new_leaf_refcount_block_53036 ocfs2_new_leaf_refcount_block 0 53036 NULL
120873 +bio_cur_bytes_53037 bio_cur_bytes 0 53037 NULL
120874 +videobuf_dvb_register_adapter_53054 videobuf_dvb_register_adapter 0 53054 NULL
120875 +regcache_lzo_block_count_53056 regcache_lzo_block_count 0 53056 NULL
120876 +cfi_read_query_53066 cfi_read_query 0 53066 NULL
120877 +iwl_dbgfs_interrupt_write_53069 iwl_dbgfs_interrupt_write 3 53069 NULL
120878 +mwifiex_debug_read_53074 mwifiex_debug_read 3 53074 NULL
120879 +mlx4_comm_cmd_53076 mlx4_comm_cmd 0 53076 NULL
120880 +vmci_check_host_caps_53087 vmci_check_host_caps 0 53087 NULL
120881 +mic_virtio_copy_from_user_53107 mic_virtio_copy_from_user 3 53107 NULL
120882 +il3945_setup_mac_53110 il3945_setup_mac 0 53110 NULL
120883 +verity_status_53120 verity_status 5 53120 NULL
120884 +brcmf_usb_dl_cmd_53130 brcmf_usb_dl_cmd 4 53130 NULL
120885 +inode_newsize_ok_53140 inode_newsize_ok 0 53140 NULL nohasharray
120886 +ps_poll_ps_poll_max_ap_turn_read_53140 ps_poll_ps_poll_max_ap_turn_read 3 53140 &inode_newsize_ok_53140
120887 +ieee80211_bss_info_update_53170 ieee80211_bss_info_update 4 53170 NULL
120888 +btrfs_io_bio_alloc_53179 btrfs_io_bio_alloc 2 53179 NULL
120889 +find_good_lh_53183 find_good_lh 0 53183 NULL
120890 +clear_capture_buf_53192 clear_capture_buf 2 53192 NULL
120891 +xfs_btree_updkey_53195 xfs_btree_updkey 0 53195 NULL
120892 +tx_tx_start_data_read_53219 tx_tx_start_data_read 3 53219 NULL
120893 +mlx4_master_process_vhcr_53239 mlx4_master_process_vhcr 0 53239 NULL
120894 +ptlrpc_lprocfs_req_history_max_seq_write_53243 ptlrpc_lprocfs_req_history_max_seq_write 3 53243 NULL
120895 +xfs_trans_read_buf_map_53258 xfs_trans_read_buf_map 5-0 53258 NULL
120896 +wil_write_file_ssid_53266 wil_write_file_ssid 3 53266 NULL
120897 +btrfs_file_extent_num_bytes_53269 btrfs_file_extent_num_bytes 0 53269 NULL
120898 +scsi_add_device_53316 scsi_add_device 0 53316 NULL
120899 +ftrace_profile_write_53327 ftrace_profile_write 3 53327 NULL
120900 +find_nr_power_limit_53330 find_nr_power_limit 0 53330 NULL
120901 +gsm_control_reply_53333 gsm_control_reply 4 53333 NULL
120902 +btree_keys_bytes_53348 btree_keys_bytes 0 53348 NULL
120903 +sock_setbindtodevice_53369 sock_setbindtodevice 3 53369 NULL
120904 +get_random_bytes_arch_53370 get_random_bytes_arch 2 53370 NULL
120905 +pci_user_write_config_word_53375 pci_user_write_config_word 0 53375 NULL
120906 +xfs_imap_53389 xfs_imap 0 53389 NULL
120907 +bcm2048_get_rds_wline_53393 bcm2048_get_rds_wline 0 53393 NULL
120908 +isolate_lru_page_53417 isolate_lru_page 0 53417 NULL
120909 +isr_cmd_cmplt_read_53439 isr_cmd_cmplt_read 3 53439 NULL
120910 +mwifiex_info_read_53447 mwifiex_info_read 3 53447 NULL
120911 +apei_exec_run_optional_53452 apei_exec_run_optional 0 53452 NULL
120912 +paging64_prefetch_gpte_53468 paging64_prefetch_gpte 4 53468 NULL
120913 +ima_write_template_field_data_53475 ima_write_template_field_data 2 53475 NULL nohasharray
120914 +create_trace_kprobe_53475 create_trace_kprobe 1 53475 &ima_write_template_field_data_53475
120915 +iowarrior_read_53483 iowarrior_read 3 53483 NULL
120916 +osd_req_write_kern_53486 osd_req_write_kern 5 53486 NULL
120917 +memory_notify_53496 memory_notify 0 53496 NULL
120918 +do_verify_xattr_datum_53499 do_verify_xattr_datum 0 53499 NULL
120919 +snd_pcm_format_physical_width_53505 snd_pcm_format_physical_width 0 53505 NULL
120920 +dbAllocNext_53506 dbAllocNext 0 53506 NULL
120921 +force_sc_support_write_53512 force_sc_support_write 3 53512 NULL nohasharray
120922 +check_acl_53512 check_acl 0 53512 &force_sc_support_write_53512
120923 +nft_data_dump_53549 nft_data_dump 5 53549 NULL
120924 +rem_res_range_53551 rem_res_range 0 53551 NULL
120925 +snd_pcm_new_stream_53581 snd_pcm_new_stream 0 53581 NULL
120926 +SYSC_bind_53582 SYSC_bind 3 53582 NULL
120927 +e1000_sw_init_53587 e1000_sw_init 0 53587 NULL
120928 +cifs_utf16_bytes_53593 cifs_utf16_bytes 0 53593 NULL
120929 +proc_uid_map_write_53596 proc_uid_map_write 3 53596 NULL
120930 +pfkey_recvmsg_53604 pfkey_recvmsg 4 53604 NULL
120931 +___alloc_bootmem_nopanic_53626 ___alloc_bootmem_nopanic 1 53626 NULL
120932 +xd_write_multiple_pages_53633 xd_write_multiple_pages 6-5 53633 NULL
120933 +ccid_getsockopt_builtin_ccids_53634 ccid_getsockopt_builtin_ccids 2 53634 NULL
120934 +if_spi_prog_main_firmware_check_len_53637 if_spi_prog_main_firmware_check_len 0 53637 NULL
120935 +nr_sendmsg_53656 nr_sendmsg 4 53656 NULL
120936 +fuse_fill_write_pages_53682 fuse_fill_write_pages 4-0 53682 NULL
120937 +v4l2_event_subscribe_53687 v4l2_event_subscribe 3 53687 NULL
120938 +bdev_logical_block_size_53690 bdev_logical_block_size 0 53690 NULL nohasharray
120939 +igb_alloc_q_vector_53690 igb_alloc_q_vector 4-6 53690 &bdev_logical_block_size_53690
120940 +hwrng_register_53692 hwrng_register 0 53692 NULL
120941 +ipw2100_up_53706 ipw2100_up 0 53706 NULL
120942 +find_overflow_devnum_53711 find_overflow_devnum 0 53711 NULL
120943 +reset_dsp_53728 reset_dsp 0 53728 NULL
120944 +__proc_debug_mb_53732 __proc_debug_mb 5 53732 NULL
120945 +wdm_write_53735 wdm_write 3 53735 NULL
120946 +da9052_disable_irq_53745 da9052_disable_irq 2 53745 NULL
120947 +pci_read_config_byte_53754 pci_read_config_byte 0 53754 NULL
120948 +lpfc_idiag_queacc_read_qe_53755 lpfc_idiag_queacc_read_qe 0-2 53755 NULL nohasharray
120949 +amdtp_out_stream_get_max_payload_53755 amdtp_out_stream_get_max_payload 0 53755 &lpfc_idiag_queacc_read_qe_53755
120950 +wa_populate_buf_in_urb_53758 wa_populate_buf_in_urb 3-4 53758 NULL
120951 +ext2_acl_count_53773 ext2_acl_count 0-1 53773 NULL
120952 +__kfifo_dma_in_prepare_r_53792 __kfifo_dma_in_prepare_r 4-5 53792 NULL
120953 +block_write_end_53795 block_write_end 0-5 53795 NULL
120954 +qp_alloc_host_work_53798 qp_alloc_host_work 5-3 53798 NULL
120955 +regmap_raw_write_53803 regmap_raw_write 2-4 53803 NULL
120956 +lpfc_idiag_ctlacc_read_reg_53809 lpfc_idiag_ctlacc_read_reg 0-3 53809 NULL
120957 +nls_nullsize_53815 nls_nullsize 0 53815 NULL
120958 +radio_tea5777_set_freq_53817 radio_tea5777_set_freq 0 53817 NULL
120959 +setup_data_read_53822 setup_data_read 3 53822 NULL
120960 +pms_read_53873 pms_read 3 53873 NULL
120961 +pci_write_config_byte_53874 pci_write_config_byte 0 53874 NULL
120962 +ieee80211_if_fmt_dropped_frames_congestion_53883 ieee80211_if_fmt_dropped_frames_congestion 3 53883 NULL
120963 +tlan_init_53888 tlan_init 0 53888 NULL
120964 +SyS_setgroups_53900 SyS_setgroups 1 53900 NULL
120965 +posix_acl_chmod_53904 posix_acl_chmod 0 53904 NULL
120966 +batadv_tt_tvlv_ogm_handler_v1_53909 batadv_tt_tvlv_ogm_handler_v1 5 53909 NULL
120967 +azx_via_get_position_53916 azx_via_get_position 0 53916 NULL
120968 +usb_serial_generic_write_53927 usb_serial_generic_write 4 53927 NULL
120969 +ocfs2_make_clusters_writable_53938 ocfs2_make_clusters_writable 0 53938 NULL
120970 +ilo_map_device_53946 ilo_map_device 0 53946 NULL
120971 +niu_init_link_53964 niu_init_link 0 53964 NULL
120972 +idetape_chrdev_write_53976 idetape_chrdev_write 3 53976 NULL
120973 +macvtap_get_minor_53980 macvtap_get_minor 0 53980 NULL
120974 +__ocfs2_xattr_set_value_outside_53981 __ocfs2_xattr_set_value_outside 5 53981 NULL
120975 +ieee80211_if_fmt_dot11MeshHWMPperrMinInterval_53998 ieee80211_if_fmt_dot11MeshHWMPperrMinInterval 3 53998 NULL
120976 +hfsplus_attr_build_key_54013 hfsplus_attr_build_key 0 54013 NULL
120977 +snd_pcm_lib_write_transfer_54018 snd_pcm_lib_write_transfer 5-2-4 54018 NULL
120978 +mdc_kuc_write_54019 mdc_kuc_write 3 54019 NULL
120979 +ipxrtr_route_packet_54036 ipxrtr_route_packet 4 54036 NULL
120980 +batadv_tt_update_orig_54049 batadv_tt_update_orig 6-4 54049 NULL
120981 +pipeline_dec_packet_out_read_54052 pipeline_dec_packet_out_read 3 54052 NULL
120982 +nl80211_send_disconnected_54056 nl80211_send_disconnected 5 54056 NULL
120983 +rproc_state_read_54057 rproc_state_read 3 54057 NULL
120984 +set_ac97_input_54069 set_ac97_input 0 54069 NULL
120985 +_malloc_54077 _malloc 1 54077 NULL
120986 +bitmap_bitremap_54096 bitmap_bitremap 4 54096 NULL
120987 +altera_set_ir_pre_54103 altera_set_ir_pre 2 54103 NULL nohasharray
120988 +lustre_posix_acl_xattr_filter_54103 lustre_posix_acl_xattr_filter 2 54103 &altera_set_ir_pre_54103
120989 +__comedi_buf_write_alloc_54112 __comedi_buf_write_alloc 0-2 54112 NULL
120990 +strn_len_54122 strn_len 0 54122 NULL
120991 +isku_receive_54130 isku_receive 4 54130 NULL nohasharray
120992 +vnic_rq_alloc_bufs_54130 vnic_rq_alloc_bufs 0 54130 &isku_receive_54130
120993 +isr_host_acknowledges_read_54136 isr_host_acknowledges_read 3 54136 NULL
120994 +irq_blk_threshold_write_54138 irq_blk_threshold_write 3 54138 NULL
120995 +sas_init_events_54144 sas_init_events 0 54144 NULL
120996 +memcpy_toiovec_54166 memcpy_toiovec 3 54166 NULL
120997 +nouveau_falcon_create__54169 nouveau_falcon_create_ 8 54169 NULL
120998 +p9_client_prepare_req_54175 p9_client_prepare_req 3 54175 NULL
120999 +devm_request_threaded_irq_54215 devm_request_threaded_irq 0 54215 NULL
121000 +do_sys_poll_54221 do_sys_poll 2 54221 NULL
121001 +__register_chrdev_54223 __register_chrdev 2-3 54223 NULL
121002 +pi_read_regr_54231 pi_read_regr 0 54231 NULL
121003 +vnic_wq_alloc_bufs_54246 vnic_wq_alloc_bufs 0 54246 NULL nohasharray
121004 +mcp23s08_read_regs_54246 mcp23s08_read_regs 4 54246 &vnic_wq_alloc_bufs_54246
121005 +reada_add_block_54247 reada_add_block 2 54247 NULL
121006 +jbd2__journal_restart_54249 jbd2__journal_restart 0 54249 NULL
121007 +xfs_dir2_sf_addname_hard_54254 xfs_dir2_sf_addname_hard 3 54254 NULL
121008 +t4_load_fw_54256 t4_load_fw 0 54256 NULL
121009 +ceph_msgpool_get_54258 ceph_msgpool_get 2 54258 NULL
121010 +audio_write_54261 audio_write 4 54261 NULL nohasharray
121011 +wusb_prf_54261 wusb_prf 7 54261 &audio_write_54261
121012 +mwifiex_getlog_read_54269 mwifiex_getlog_read 3 54269 NULL
121013 +kstrtou16_from_user_54274 kstrtou16_from_user 2 54274 NULL
121014 +altera_set_dr_post_54291 altera_set_dr_post 2 54291 NULL
121015 +dlm_alloc_pagevec_54296 dlm_alloc_pagevec 1 54296 NULL
121016 +reclaim_pages_54301 reclaim_pages 3 54301 NULL
121017 +sprintf_54306 sprintf 0 54306 NULL
121018 +bio_add_pc_page_54319 bio_add_pc_page 4 54319 NULL
121019 +br_fdb_fillbuf_54339 br_fdb_fillbuf 0 54339 NULL
121020 +__alloc_dev_table_54343 __alloc_dev_table 2 54343 NULL
121021 +ath10k_core_fetch_firmware_files_54345 ath10k_core_fetch_firmware_files 0 54345 NULL
121022 +__get_free_pages_54352 __get_free_pages 0 54352 NULL
121023 +readlink_copy_54366 readlink_copy 2 54366 NULL
121024 +read_file_credit_dist_stats_54367 read_file_credit_dist_stats 3 54367 NULL
121025 +do_dccp_setsockopt_54377 do_dccp_setsockopt 5 54377 NULL nohasharray
121026 +intel_sdvo_write_cmd_54377 intel_sdvo_write_cmd 4 54377 &do_dccp_setsockopt_54377
121027 +ah_alloc_tmp_54378 ah_alloc_tmp 3-2 54378 NULL
121028 +gart_unmap_page_54379 gart_unmap_page 2-3 54379 NULL
121029 +snd_pcm_oss_read2_54387 snd_pcm_oss_read2 0-3 54387 NULL
121030 +iwl_dbgfs_power_save_status_read_54392 iwl_dbgfs_power_save_status_read 3 54392 NULL
121031 +snd_pcm_add_chmap_ctls_54404 snd_pcm_add_chmap_ctls 0 54404 NULL
121032 +ll_ra_count_get_54410 ll_ra_count_get 3 54410 NULL
121033 +iio_trigger_register_54412 iio_trigger_register 0 54412 NULL
121034 +copy_gadget_strings_54417 copy_gadget_strings 2-3 54417 NULL
121035 +sparse_early_mem_maps_alloc_node_54485 sparse_early_mem_maps_alloc_node 4 54485 NULL
121036 +simple_strtoull_54493 simple_strtoull 0 54493 NULL
121037 +swiotlb_tbl_map_single_54495 swiotlb_tbl_map_single 0 54495 NULL
121038 +vfio_raw_config_read_54500 vfio_raw_config_read 3 54500 NULL
121039 +btrfs_ordered_sum_size_54509 btrfs_ordered_sum_size 0-2 54509 NULL
121040 +sst_byt_get_dsp_position_54513 sst_byt_get_dsp_position 0-3 54513 NULL
121041 +rfc4106_set_key_54519 rfc4106_set_key 3 54519 NULL
121042 +vmci_transport_dgram_enqueue_54525 vmci_transport_dgram_enqueue 4 54525 NULL
121043 +viacam_read_54526 viacam_read 3 54526 NULL
121044 +unix_dgram_connect_54535 unix_dgram_connect 3 54535 NULL
121045 +setsockopt_54539 setsockopt 5 54539 NULL
121046 +lbs_lowsnr_write_54549 lbs_lowsnr_write 3 54549 NULL
121047 +SYSC_setsockopt_54561 SYSC_setsockopt 5 54561 NULL
121048 +sht15_send_cmd_54567 sht15_send_cmd 0 54567 NULL
121049 +nfsd_vfs_write_54577 nfsd_vfs_write 6 54577 NULL
121050 +fw_iso_buffer_init_54582 fw_iso_buffer_init 3 54582 NULL
121051 +nvme_npages_54601 nvme_npages 0-1 54601 NULL
121052 +irq_pkt_threshold_write_54605 irq_pkt_threshold_write 3 54605 NULL
121053 +port_fops_write_54627 port_fops_write 3 54627 NULL
121054 +ext2_write_end_54636 ext2_write_end 5 54636 NULL
121055 +tipc_send_stream_54648 tipc_send_stream 4 54648 NULL
121056 +irq_timeout_read_54653 irq_timeout_read 3 54653 NULL nohasharray
121057 +ath10k_bmi_get_target_info_54653 ath10k_bmi_get_target_info 0 54653 &irq_timeout_read_54653
121058 +_regulator_enable_54655 _regulator_enable 0 54655 NULL
121059 +dns_resolver_read_54658 dns_resolver_read 3 54658 NULL
121060 +twl6030_interrupt_mask_54659 twl6030_interrupt_mask 2 54659 NULL
121061 +tdp_page_fault_54663 tdp_page_fault 2 54663 NULL
121062 +bus_add_device_54665 bus_add_device 0 54665 NULL
121063 +cw1200_queue_stats_init_54670 cw1200_queue_stats_init 2 54670 NULL
121064 +bio_kmalloc_54672 bio_kmalloc 2 54672 NULL nohasharray
121065 +ath9k_init_queues_54672 ath9k_init_queues 0 54672 &bio_kmalloc_54672
121066 +evm_read_key_54674 evm_read_key 3 54674 NULL
121067 +ath10k_wmi_attach_54680 ath10k_wmi_attach 0 54680 NULL
121068 +platform_get_irq_byname_54700 platform_get_irq_byname 0 54700 NULL
121069 +__btrfs_inc_extent_ref_54706 __btrfs_inc_extent_ref 7 54706 NULL
121070 +rfkill_fop_read_54711 rfkill_fop_read 3 54711 NULL
121071 +mwl8k_txq_init_54724 mwl8k_txq_init 0 54724 NULL
121072 +ocfs2_control_write_54737 ocfs2_control_write 3 54737 NULL
121073 +kzalloc_54740 kzalloc 1 54740 NULL
121074 +wep_iv_read_54744 wep_iv_read 3 54744 NULL
121075 +lpfc_idiag_pcicfg_write_54749 lpfc_idiag_pcicfg_write 3 54749 NULL
121076 +crystalhd_user_data_54754 crystalhd_user_data 3 54754 NULL
121077 +iio_event_chrdev_read_54757 iio_event_chrdev_read 3 54757 NULL
121078 +adis16480_show_firmware_date_54762 adis16480_show_firmware_date 3 54762 NULL
121079 +ldsem_atomic_update_54774 ldsem_atomic_update 1 54774 NULL
121080 +gpiochip_add_54781 gpiochip_add 0 54781 NULL
121081 +xfs_rtallocate_extent_block_54791 xfs_rtallocate_extent_block 0 54791 NULL
121082 +flexcop_device_kmalloc_54793 flexcop_device_kmalloc 1 54793 NULL
121083 +nfsd_write_54809 nfsd_write 6 54809 NULL
121084 +ar9287_dump_modal_eeprom_54814 ar9287_dump_modal_eeprom 3-2 54814 NULL
121085 +crypto_tfm_ctx_alignment_54815 crypto_tfm_ctx_alignment 0 54815 NULL nohasharray
121086 +kvzalloc_54815 kvzalloc 1 54815 &crypto_tfm_ctx_alignment_54815 nohasharray
121087 +aes_decrypt_fail_read_54815 aes_decrypt_fail_read 3 54815 &kvzalloc_54815
121088 +generic_perform_write_54832 generic_perform_write 3-0 54832 NULL
121089 +write_rio_54837 write_rio 3 54837 NULL
121090 +ext3_acl_from_disk_54839 ext3_acl_from_disk 2 54839 NULL nohasharray
121091 +nouveau_engctx_create__54839 nouveau_engctx_create_ 8 54839 &ext3_acl_from_disk_54839
121092 +scsi_add_host_54847 scsi_add_host 0 54847 NULL
121093 +ufx_ops_write_54848 ufx_ops_write 3 54848 NULL
121094 +printer_read_54851 printer_read 3 54851 NULL
121095 +assign_irq_vector_54852 assign_irq_vector 0 54852 NULL
121096 +broadsheet_spiflash_rewrite_sector_54864 broadsheet_spiflash_rewrite_sector 2 54864 NULL
121097 +prism_build_supp_rates_54865 prism_build_supp_rates 0 54865 NULL
121098 +xfs_alloc_read_agfl_54879 xfs_alloc_read_agfl 0 54879 NULL
121099 +ath9k_hw_attach_ops_54883 ath9k_hw_attach_ops 0 54883 NULL
121100 +iscsi_pool_init_54913 iscsi_pool_init 2-4 54913 NULL nohasharray
121101 +kobject_set_name_vargs_54913 kobject_set_name_vargs 0 54913 &iscsi_pool_init_54913
121102 +btrfs_stack_chunk_num_stripes_54923 btrfs_stack_chunk_num_stripes 0 54923 NULL
121103 +bio_add_page_54933 bio_add_page 0-3 54933 NULL
121104 +mxms_structlen_54939 mxms_structlen 0 54939 NULL
121105 +add_port_54941 add_port 2 54941 NULL
121106 +tipc_send2name_54946 tipc_send2name 5 54946 NULL
121107 +ath9k_dump_btcoex_54949 ath9k_dump_btcoex 3-0 54949 NULL nohasharray
121108 +amb_init_54949 amb_init 0 54949 &ath9k_dump_btcoex_54949
121109 +alauda_write_data_54967 alauda_write_data 3 54967 NULL
121110 +c4_add_card_54968 c4_add_card 3 54968 NULL
121111 +igb_alloc_q_vectors_54977 igb_alloc_q_vectors 0 54977 NULL
121112 +ext3_xattr_get_54989 ext3_xattr_get 0 54989 NULL
121113 +cx231xx_v4l2_read_55014 cx231xx_v4l2_read 3 55014 NULL
121114 +error_error_null_Frame_tx_start_read_55024 error_error_null_Frame_tx_start_read 3 55024 NULL
121115 +apei_exec_run_55075 apei_exec_run 0 55075 NULL
121116 +bitmap_storage_alloc_55077 bitmap_storage_alloc 2 55077 NULL
121117 +snd_pcm_capture_hw_avail_55086 snd_pcm_capture_hw_avail 0 55086 NULL nohasharray
121118 +read_dma_55086 read_dma 3 55086 &snd_pcm_capture_hw_avail_55086
121119 +rxpipe_beacon_buffer_thres_host_int_trig_rx_data_read_55106 rxpipe_beacon_buffer_thres_host_int_trig_rx_data_read 3 55106 NULL
121120 +crypto_ahash_setkey_55134 crypto_ahash_setkey 3 55134 NULL
121121 +filldir_55137 filldir 3 55137 NULL nohasharray
121122 +ocfs2_prepare_refcount_change_for_del_55137 ocfs2_prepare_refcount_change_for_del 0 55137 &filldir_55137
121123 +ocfs2_truncate_file_55148 ocfs2_truncate_file 3 55148 NULL
121124 +xfs_check_agi_freecount_55149 xfs_check_agi_freecount 0 55149 NULL nohasharray
121125 +npages_to_npools_55149 npages_to_npools 0-1 55149 &xfs_check_agi_freecount_55149
121126 +ieee80211_if_read_uapsd_queues_55150 ieee80211_if_read_uapsd_queues 3 55150 NULL
121127 +xfs_icsb_modify_counters_55156 xfs_icsb_modify_counters 0 55156 NULL
121128 +gfs2_ri_update_55185 gfs2_ri_update 0 55185 NULL
121129 +sel_write_relabel_55195 sel_write_relabel 3 55195 NULL
121130 +compat_SyS_ppoll_55196 compat_SyS_ppoll 2 55196 NULL
121131 +sched_feat_write_55202 sched_feat_write 3 55202 NULL
121132 +ht40allow_map_read_55209 ht40allow_map_read 3 55209 NULL
121133 +__kfifo_dma_out_prepare_r_55211 __kfifo_dma_out_prepare_r 4-5 55211 NULL
121134 +do_raw_setsockopt_55215 do_raw_setsockopt 5 55215 NULL
121135 +qxl_alloc_client_monitors_config_55216 qxl_alloc_client_monitors_config 2 55216 NULL
121136 +nouveau_mc_create__55217 nouveau_mc_create_ 4 55217 NULL
121137 +dbAllocDmap_55227 dbAllocDmap 0 55227 NULL
121138 +memcpy_fromiovec_55247 memcpy_fromiovec 3 55247 NULL
121139 +lbs_failcount_write_55276 lbs_failcount_write 3 55276 NULL
121140 +persistent_ram_new_55286 persistent_ram_new 2-1 55286 NULL
121141 +rx_streaming_interval_read_55291 rx_streaming_interval_read 3 55291 NULL
121142 +lov_get_stripecnt_55297 lov_get_stripecnt 0-3 55297 NULL
121143 +gsm_control_modem_55303 gsm_control_modem 3 55303 NULL
121144 +wimax_msg_len_55304 wimax_msg_len 0 55304 NULL
121145 +compat_SyS_process_vm_readv_55305 compat_SyS_process_vm_readv 3-5 55305 NULL nohasharray
121146 +qp_alloc_guest_work_55305 qp_alloc_guest_work 5-3 55305 &compat_SyS_process_vm_readv_55305
121147 +init_sma_55311 init_sma 0 55311 NULL
121148 +gfs2_dir_read_data_55327 gfs2_dir_read_data 3 55327 NULL
121149 +__vxge_hw_vpath_initialize_55328 __vxge_hw_vpath_initialize 2 55328 NULL
121150 +compat_SyS_mbind_55329 compat_SyS_mbind 5 55329 NULL
121151 +vme_user_read_55338 vme_user_read 3 55338 NULL
121152 +__wa_xfer_setup_sizes_55342 __wa_xfer_setup_sizes 0 55342 NULL nohasharray
121153 +sctp_datamsg_from_user_55342 sctp_datamsg_from_user 4 55342 &__wa_xfer_setup_sizes_55342
121154 +cw1200_sdio_align_size_55391 cw1200_sdio_align_size 2 55391 NULL
121155 +iwl_dbgfs_plcp_delta_read_55407 iwl_dbgfs_plcp_delta_read 3 55407 NULL
121156 +sysfs_chmod_file_55408 sysfs_chmod_file 0 55408 NULL
121157 +nouveau_cli_create_55425 nouveau_cli_create 3 55425 NULL
121158 +si476x_radio_read_rds_blckcnt_blob_55427 si476x_radio_read_rds_blckcnt_blob 3 55427 NULL
121159 +SyS_read_55449 SyS_read 3 55449 NULL
121160 +__vxge_hw_channel_allocate_55462 __vxge_hw_channel_allocate 3 55462 NULL
121161 +snd_tea575x_hw_init_55467 snd_tea575x_hw_init 0 55467 NULL
121162 +cx23888_ir_rx_read_55473 cx23888_ir_rx_read 3 55473 NULL
121163 +snd_pcm_lib_write_55483 snd_pcm_lib_write 0-3 55483 NULL
121164 +i2o_pool_alloc_55485 i2o_pool_alloc 4 55485 NULL
121165 +batadv_tt_entries_55487 batadv_tt_entries 0-1 55487 NULL
121166 +rtl8180_init_tx_ring_55496 rtl8180_init_tx_ring 0 55496 NULL
121167 +ras_stride_increase_window_55501 ras_stride_increase_window 3 55501 NULL
121168 +tx_tx_done_int_template_read_55511 tx_tx_done_int_template_read 3 55511 NULL
121169 +xfs_btree_split_55515 xfs_btree_split 0 55515 NULL
121170 +ea_get_55522 ea_get 3-0 55522 NULL
121171 +mthca_init_icm_55530 mthca_init_icm 0 55530 NULL
121172 +buffer_size_55534 buffer_size 0 55534 NULL
121173 +regulator_bulk_disable_55535 regulator_bulk_disable 0 55535 NULL
121174 +set_msr_interception_55538 set_msr_interception 2 55538 NULL
121175 +tty_port_register_device_55543 tty_port_register_device 3 55543 NULL
121176 +hash_ipport6_expire_55549 hash_ipport6_expire 4 55549 NULL
121177 +_regulator_is_enabled_55550 _regulator_is_enabled 0 55550 NULL
121178 +dm_stats_list_55551 dm_stats_list 4 55551 NULL
121179 +compat_SyS_setsockopt_55581 compat_SyS_setsockopt 5 55581 NULL
121180 +add_partition_55588 add_partition 2 55588 NULL
121181 +kstrtou8_from_user_55599 kstrtou8_from_user 2 55599 NULL
121182 +mlx4_make_profile_55601 mlx4_make_profile 0 55601 NULL
121183 +SyS_keyctl_55602 SyS_keyctl 4 55602 NULL
121184 +mthca_init_node_data_55607 mthca_init_node_data 0 55607 NULL
121185 +macvtap_put_user_55609 macvtap_put_user 4 55609 NULL
121186 +selinux_setprocattr_55611 selinux_setprocattr 4 55611 NULL
121187 +edge_tty_recv_55622 edge_tty_recv 3 55622 NULL
121188 +pktgen_if_write_55628 pktgen_if_write 3 55628 NULL nohasharray
121189 +reiserfs_xattr_get_55628 reiserfs_xattr_get 0 55628 &pktgen_if_write_55628
121190 +osc_obd_max_pages_per_rpc_seq_write_55636 osc_obd_max_pages_per_rpc_seq_write 3 55636 NULL
121191 +xfs_bmbt_maxrecs_55649 xfs_bmbt_maxrecs 0-2 55649 NULL
121192 +lpfc_idiag_queinfo_read_55662 lpfc_idiag_queinfo_read 3 55662 NULL
121193 +il_dbgfs_tx_queue_read_55668 il_dbgfs_tx_queue_read 3 55668 NULL
121194 +get_info_55681 get_info 3 55681 NULL
121195 +iwl_dbgfs_plcp_delta_write_55682 iwl_dbgfs_plcp_delta_write 3 55682 NULL
121196 +usb_get_bos_descriptor_55686 usb_get_bos_descriptor 0 55686 NULL
121197 +genl_allocate_reserve_groups_55705 genl_allocate_reserve_groups 1 55705 NULL
121198 +pm8001_store_update_fw_55716 pm8001_store_update_fw 4 55716 NULL
121199 +ocfs2_lock_refcount_tree_55719 ocfs2_lock_refcount_tree 0 55719 NULL
121200 +tap_pwup_write_55723 tap_pwup_write 3 55723 NULL nohasharray
121201 +typhoon_wakeup_55723 typhoon_wakeup 0 55723 &tap_pwup_write_55723
121202 +__iio_allocate_kfifo_55738 __iio_allocate_kfifo 2 55738 NULL
121203 +set_local_name_55757 set_local_name 4 55757 NULL
121204 +strlen_55778 strlen 0 55778 NULL nohasharray
121205 +is_idx_node_in_tnc_55778 is_idx_node_in_tnc 0 55778 &strlen_55778
121206 +set_spte_55783 set_spte 4-5 55783 NULL
121207 +req_bio_endio_55786 req_bio_endio 3 55786 NULL nohasharray
121208 +conf_read_55786 conf_read 3 55786 &req_bio_endio_55786
121209 +uwb_rc_neh_grok_event_55799 uwb_rc_neh_grok_event 3 55799 NULL
121210 +sb16_copy_from_user_55836 sb16_copy_from_user 10-6-7 55836 NULL
121211 +ip_hdrlen_55849 ip_hdrlen 0 55849 NULL
121212 +hcd_alloc_coherent_55862 hcd_alloc_coherent 5 55862 NULL
121213 +pcie_capability_clear_and_set_word_55863 pcie_capability_clear_and_set_word 0 55863 NULL
121214 +shmem_setxattr_55867 shmem_setxattr 4 55867 NULL
121215 +hsc_write_55875 hsc_write 3 55875 NULL
121216 +ramdisk_store_55885 ramdisk_store 4 55885 NULL nohasharray
121217 +r6040_mii_probe_55885 r6040_mii_probe 0 55885 &ramdisk_store_55885
121218 +pm_qos_power_read_55891 pm_qos_power_read 3 55891 NULL
121219 +storvsc_channel_init_55905 storvsc_channel_init 0 55905 NULL
121220 +hash_ip4_expire_55911 hash_ip4_expire 4 55911 NULL
121221 +snd_pcm_hw_param_value_min_55917 snd_pcm_hw_param_value_min 0 55917 NULL
121222 +ext2_direct_IO_55932 ext2_direct_IO 4 55932 NULL
121223 +kvm_write_guest_virt_system_55944 kvm_write_guest_virt_system 4-2 55944 NULL
121224 +sel_read_policy_55947 sel_read_policy 3 55947 NULL
121225 +ceph_get_direct_page_vector_55956 ceph_get_direct_page_vector 2 55956 NULL
121226 +simple_read_from_buffer_55957 simple_read_from_buffer 5-2 55957 NULL
121227 +tx_tx_imm_resp_read_55964 tx_tx_imm_resp_read 3 55964 NULL
121228 +btrfs_clone_55977 btrfs_clone 5-3 55977 NULL
121229 +mlx4_init_xrcd_table_55989 mlx4_init_xrcd_table 0 55989 NULL
121230 +wa_xfer_create_subset_sg_55992 wa_xfer_create_subset_sg 3-2 55992 NULL
121231 +cp_init_rings_56021 cp_init_rings 0 56021 NULL
121232 +mlx4_init_counters_table_56023 mlx4_init_counters_table 0 56023 NULL
121233 +nvme_alloc_iod_56027 nvme_alloc_iod 1-2 56027 NULL
121234 +rtl8169_init_ring_56028 rtl8169_init_ring 0 56028 NULL nohasharray
121235 +snd_msnd_pcm_56028 snd_msnd_pcm 0 56028 &rtl8169_init_ring_56028
121236 +usb_ocp_write_56047 usb_ocp_write 4 56047 NULL
121237 +rdev_change_virtual_intf_56057 rdev_change_virtual_intf 0 56057 NULL
121238 +dccp_sendmsg_56058 dccp_sendmsg 4 56058 NULL
121239 +gpio_direction_output_56094 gpio_direction_output 0 56094 NULL
121240 +pci_user_write_config_dword_56099 pci_user_write_config_dword 0 56099 NULL
121241 +pscsi_get_bio_56103 pscsi_get_bio 1 56103 NULL
121242 +em28xx_write_reg_bits_56107 em28xx_write_reg_bits 0 56107 NULL
121243 +usb_alloc_stream_buffers_56123 usb_alloc_stream_buffers 3 56123 NULL
121244 +sel_read_handle_status_56139 sel_read_handle_status 3 56139 NULL
121245 +write_file_frameerrors_56145 write_file_frameerrors 3 56145 NULL
121246 +__i2c_transfer_56162 __i2c_transfer 0 56162 NULL
121247 +rawv6_setsockopt_56165 rawv6_setsockopt 5 56165 NULL
121248 +create_irq_nr_56180 create_irq_nr 0 56180 NULL
121249 +ath9k_dump_legacy_btcoex_56194 ath9k_dump_legacy_btcoex 3-0 56194 NULL
121250 +niu_get_and_validate_port_56203 niu_get_and_validate_port 0 56203 NULL
121251 +ocfs2_journal_access_gd_56209 ocfs2_journal_access_gd 0 56209 NULL
121252 +vring_add_indirect_56222 vring_add_indirect 4 56222 NULL
121253 +ocfs2_find_xe_in_bucket_56224 ocfs2_find_xe_in_bucket 0 56224 NULL
121254 +do_ipt_set_ctl_56238 do_ipt_set_ctl 4 56238 NULL
121255 +fd_copyin_56247 fd_copyin 3 56247 NULL
121256 +sk_rmem_schedule_56255 sk_rmem_schedule 3 56255 NULL
121257 +spu_set_interrupt_mode_56261 spu_set_interrupt_mode 0 56261 NULL
121258 +clk_enable_56265 clk_enable 0 56265 NULL
121259 +acpi_ex_get_serial_access_length_56275 acpi_ex_get_serial_access_length 0-2 56275 NULL
121260 +il4965_ucode_general_stats_read_56277 il4965_ucode_general_stats_read 3 56277 NULL
121261 +ieee80211_if_fmt_user_power_level_56283 ieee80211_if_fmt_user_power_level 3 56283 NULL
121262 +RESIZE_IF_NEEDED_56286 RESIZE_IF_NEEDED 2 56286 NULL
121263 +skd_acquire_irq_56295 skd_acquire_irq 0 56295 NULL
121264 +dvb_aplay_56296 dvb_aplay 3 56296 NULL
121265 +btmrvl_hscfgcmd_read_56303 btmrvl_hscfgcmd_read 3 56303 NULL
121266 +speakup_file_write_56310 speakup_file_write 3 56310 NULL
121267 +pipeline_pre_to_defrag_swi_read_56321 pipeline_pre_to_defrag_swi_read 3 56321 NULL
121268 +journal_init_revoke_table_56331 journal_init_revoke_table 1 56331 NULL
121269 +snd_rawmidi_read_56337 snd_rawmidi_read 3 56337 NULL
121270 +vxge_os_dma_malloc_async_56348 vxge_os_dma_malloc_async 3 56348 NULL
121271 +mite_device_bytes_transferred_56355 mite_device_bytes_transferred 0 56355 NULL
121272 +qd_get_56365 qd_get 0 56365 NULL nohasharray
121273 +regmap_i2c_write_56365 regmap_i2c_write 3 56365 &qd_get_56365
121274 +iov_iter_copy_from_user_atomic_56368 iov_iter_copy_from_user_atomic 4-0 56368 NULL
121275 +dev_read_56369 dev_read 3 56369 NULL
121276 +ath10k_read_simulate_fw_crash_56371 ath10k_read_simulate_fw_crash 3 56371 NULL
121277 +iio_device_add_info_mask_type_56373 iio_device_add_info_mask_type 0 56373 NULL
121278 +si4713_initialize_56378 si4713_initialize 0 56378 NULL
121279 +snd_pcm_common_ioctl1_56382 snd_pcm_common_ioctl1 0 56382 NULL
121280 +write_gssp_56404 write_gssp 3 56404 NULL
121281 +ocfs2_control_read_56405 ocfs2_control_read 3 56405 NULL
121282 +do_get_write_access_56410 do_get_write_access 0 56410 NULL
121283 +store_msg_56417 store_msg 3 56417 NULL
121284 +pppol2tp_sendmsg_56420 pppol2tp_sendmsg 4 56420 NULL
121285 +l2cap_segment_le_sdu_56426 l2cap_segment_le_sdu 4 56426 NULL
121286 +ec_dbgfs_cmd_read_56431 ec_dbgfs_cmd_read 3 56431 NULL
121287 +fl_create_56435 fl_create 5 56435 NULL
121288 +gnttab_map_56439 gnttab_map 2 56439 NULL
121289 +ata_scsi_add_hosts_56448 ata_scsi_add_hosts 0 56448 NULL
121290 +cx231xx_init_isoc_56453 cx231xx_init_isoc 3-2-4 56453 NULL
121291 +set_connectable_56458 set_connectable 4 56458 NULL
121292 +osd_req_list_partition_objects_56464 osd_req_list_partition_objects 5 56464 NULL
121293 +putused_user_56467 putused_user 3 56467 NULL
121294 +ocfs2_zero_extend_range_56468 ocfs2_zero_extend_range 3-2 56468 NULL
121295 +lbs_rdmac_write_56471 lbs_rdmac_write 3 56471 NULL
121296 +crypto_shash_alignmask_56486 crypto_shash_alignmask 0 56486 NULL
121297 +bsp_check_56487 bsp_check 0 56487 NULL
121298 +ieee80211_rx_mgmt_probe_beacon_56491 ieee80211_rx_mgmt_probe_beacon 3 56491 NULL
121299 +memblock_virt_alloc_56501 memblock_virt_alloc 1 56501 NULL
121300 +t4_fw_restart_56503 t4_fw_restart 0 56503 NULL
121301 +init_map_ip_56508 init_map_ip 5 56508 NULL
121302 +sf1_write_56510 sf1_write 0 56510 NULL
121303 +lustre_posix_acl_xattr_reduce_space_56512 lustre_posix_acl_xattr_reduce_space 3 56512 NULL
121304 +cfg80211_connect_result_56515 cfg80211_connect_result 4-6 56515 NULL
121305 +cfg80211_can_change_interface_56520 cfg80211_can_change_interface 0 56520 NULL
121306 +ip_options_get_56538 ip_options_get 4 56538 NULL
121307 +ll_wr_track_id_56544 ll_wr_track_id 2 56544 NULL
121308 +alloc_apertures_56561 alloc_apertures 1 56561 NULL nohasharray
121309 +lx_init_dsp_56561 lx_init_dsp 0 56561 &alloc_apertures_56561
121310 +rs_sta_dbgfs_stats_table_read_56573 rs_sta_dbgfs_stats_table_read 3 56573 NULL
121311 +portcntrs_2_read_56586 portcntrs_2_read 3 56586 NULL
121312 +gro_pull_from_frag0_56593 gro_pull_from_frag0 2 56593 NULL
121313 +event_filter_write_56609 event_filter_write 3 56609 NULL
121314 +nvme_trans_log_temperature_56613 nvme_trans_log_temperature 3 56613 NULL
121315 +edac_device_create_block_56619 edac_device_create_block 0 56619 NULL
121316 +mthca_QUERY_DDR_56640 mthca_QUERY_DDR 0 56640 NULL
121317 +gather_array_56641 gather_array 3 56641 NULL
121318 +lookup_extent_backref_56644 lookup_extent_backref 9 56644 NULL
121319 +snd_card_register_56648 snd_card_register 0 56648 NULL
121320 +uvc_debugfs_stats_read_56651 uvc_debugfs_stats_read 3 56651 NULL
121321 +tg3_nvram_write_block_56666 tg3_nvram_write_block 3 56666 NULL
121322 +snd_gus_dram_read_56686 snd_gus_dram_read 4 56686 NULL nohasharray
121323 +da9055_gpio_to_irq_56686 da9055_gpio_to_irq 2 56686 &snd_gus_dram_read_56686
121324 +dvb_ringbuffer_read_user_56702 dvb_ringbuffer_read_user 3-0 56702 NULL
121325 +sta_flags_read_56710 sta_flags_read 3 56710 NULL
121326 +ipv6_getsockopt_sticky_56711 ipv6_getsockopt_sticky 5 56711 NULL
121327 +lx_proc_create_56715 lx_proc_create 0 56715 NULL
121328 +xfs_btree_decrement_56718 xfs_btree_decrement 0 56718 NULL
121329 +__wa_xfer_setup_segs_56725 __wa_xfer_setup_segs 2 56725 NULL
121330 +__copy_from_user_ll_56738 __copy_from_user_ll 0-3 56738 NULL
121331 +drm_agp_bind_pages_56748 drm_agp_bind_pages 3 56748 NULL
121332 +btrfsic_map_block_56751 btrfsic_map_block 2 56751 NULL
121333 +pcie_capability_set_word_56764 pcie_capability_set_word 0 56764 NULL
121334 +init_dma_desc_rings_56769 init_dma_desc_rings 0 56769 NULL
121335 +alloc_iommu_56778 alloc_iommu 2-3-0 56778 NULL
121336 +ttm_alloc_new_pages_56792 ttm_alloc_new_pages 5 56792 NULL
121337 +ion_ioctl_56806 ion_ioctl 2 56806 NULL
121338 +do_syslog_56807 do_syslog 3 56807 NULL
121339 +mtdchar_write_56831 mtdchar_write 3 56831 NULL
121340 +snd_rawmidi_kernel_write1_56847 snd_rawmidi_kernel_write1 4-0 56847 NULL
121341 +mlx5_buf_alloc_56848 mlx5_buf_alloc 0 56848 NULL
121342 +si476x_radio_read_agc_blob_56849 si476x_radio_read_agc_blob 3 56849 NULL
121343 +ext3_xattr_ibody_get_56880 ext3_xattr_ibody_get 0 56880 NULL
121344 +pvr2_debugifc_print_status_56890 pvr2_debugifc_print_status 3 56890 NULL
121345 +debug_debug3_read_56894 debug_debug3_read 3 56894 NULL
121346 +batadv_tt_update_changes_56895 batadv_tt_update_changes 3 56895 NULL nohasharray
121347 +le_auto_conn_write_56895 le_auto_conn_write 3 56895 &batadv_tt_update_changes_56895
121348 +hfsplus_find_cat_56899 hfsplus_find_cat 0 56899 NULL
121349 +strcspn_56913 strcspn 0 56913 NULL
121350 +bcm2048_probe_56919 bcm2048_probe 0 56919 NULL
121351 +__kfifo_out_56927 __kfifo_out 0-3 56927 NULL
121352 +journal_init_revoke_56933 journal_init_revoke 2 56933 NULL
121353 +pcie_capability_read_dword_56940 pcie_capability_read_dword 0 56940 NULL
121354 +xfs_alloc_ag_vextent_56943 xfs_alloc_ag_vextent 0 56943 NULL
121355 +nouveau_xtensa_create__56952 nouveau_xtensa_create_ 8 56952 NULL
121356 +diva_get_driver_info_56967 diva_get_driver_info 0 56967 NULL
121357 +sptlrpc_secflags2str_56995 sptlrpc_secflags2str 3 56995 NULL
121358 +vlsi_alloc_ring_57003 vlsi_alloc_ring 3-4 57003 NULL
121359 +btrfs_super_csum_size_57004 btrfs_super_csum_size 0 57004 NULL
121360 +aircable_process_packet_57027 aircable_process_packet 4 57027 NULL
121361 +ieee80211_if_fmt_state_57043 ieee80211_if_fmt_state 3 57043 NULL nohasharray
121362 +skb_network_offset_57043 skb_network_offset 0 57043 &ieee80211_if_fmt_state_57043
121363 +bytes_to_samples_57049 bytes_to_samples 0-2 57049 NULL
121364 +xfs_buf_read_map_57053 xfs_buf_read_map 3 57053 NULL
121365 +__wl_get_peb_57058 __wl_get_peb 0 57058 NULL
121366 +cx2341x_ctrl_new_std_57061 cx2341x_ctrl_new_std 4 57061 NULL
121367 +sca3000_read_data_57064 sca3000_read_data 4 57064 NULL
121368 +pcmcia_replace_cis_57066 pcmcia_replace_cis 3 57066 NULL
121369 +tracing_set_trace_write_57096 tracing_set_trace_write 3 57096 NULL
121370 +altera_get_note_57099 altera_get_note 6 57099 NULL
121371 +hpfs_readpages_57106 hpfs_readpages 4 57106 NULL
121372 +snd_pcm_hw_params_old_user_57108 snd_pcm_hw_params_old_user 0 57108 NULL
121373 +crypto_compress_ctxsize_57109 crypto_compress_ctxsize 0 57109 NULL
121374 +mwl8k_tx_wait_empty_57118 mwl8k_tx_wait_empty 0 57118 NULL nohasharray
121375 +mlx4_slave_cap_57118 mlx4_slave_cap 0 57118 &mwl8k_tx_wait_empty_57118
121376 +cipso_v4_gentag_loc_57119 cipso_v4_gentag_loc 0 57119 NULL
121377 +ima_show_htable_value_57136 ima_show_htable_value 2 57136 NULL nohasharray
121378 +rds_ib_sub_signaled_57136 rds_ib_sub_signaled 2 57136 &ima_show_htable_value_57136 nohasharray
121379 +nl80211_send_deauth_57136 nl80211_send_deauth 4 57136 &rds_ib_sub_signaled_57136
121380 +mlx4_cmd_57138 mlx4_cmd 0 57138 NULL
121381 +snd_sonicvibes_getdmac_57140 snd_sonicvibes_getdmac 0 57140 NULL
121382 +_iwl_dbgfs_bf_params_write_57141 _iwl_dbgfs_bf_params_write 3 57141 NULL
121383 +dvb_register_device_57152 dvb_register_device 0 57152 NULL
121384 +udl_prime_create_57159 udl_prime_create 2 57159 NULL
121385 +bus_register_57165 bus_register 0 57165 NULL
121386 +stk_prepare_sio_buffers_57168 stk_prepare_sio_buffers 2 57168 NULL
121387 +rx_hw_stuck_read_57179 rx_hw_stuck_read 3 57179 NULL
121388 +hash_netnet6_expire_57191 hash_netnet6_expire 4 57191 NULL
121389 +ocfs2_claim_metadata_57192 ocfs2_claim_metadata 0 57192 NULL
121390 +tt3650_ci_msg_57219 tt3650_ci_msg 4 57219 NULL
121391 +dma_fifo_alloc_57236 dma_fifo_alloc 5-3-2 57236 NULL
121392 +flush_space_57241 flush_space 0 57241 NULL
121393 +rsxx_cram_write_57244 rsxx_cram_write 3 57244 NULL
121394 +ieee80211_if_fmt_tsf_57249 ieee80211_if_fmt_tsf 3 57249 NULL
121395 +oprofilefs_ulong_from_user_57251 oprofilefs_ulong_from_user 3 57251 NULL
121396 +alloc_flex_gd_57259 alloc_flex_gd 1 57259 NULL
121397 +usb_parse_configuration_57270 usb_parse_configuration 0 57270 NULL
121398 +lbs_sleepparams_write_57283 lbs_sleepparams_write 3 57283 NULL
121399 +pstore_file_read_57288 pstore_file_read 3 57288 NULL
121400 +snd_pcm_read_57289 snd_pcm_read 3 57289 NULL
121401 +fw_file_size_57307 fw_file_size 0 57307 NULL
121402 +ftdi_elan_write_57309 ftdi_elan_write 3 57309 NULL
121403 +xfs_iread_57313 xfs_iread 0 57313 NULL nohasharray
121404 +write_file_regval_57313 write_file_regval 3 57313 &xfs_iread_57313
121405 +__mxt_write_reg_57326 __mxt_write_reg 3 57326 NULL
121406 +usblp_read_57342 usblp_read 3 57342 NULL
121407 +print_devstats_dot11RTSFailureCount_57347 print_devstats_dot11RTSFailureCount 3 57347 NULL
121408 +dio_send_cur_page_57348 dio_send_cur_page 0 57348 NULL
121409 +mpt_attach_57370 mpt_attach 0 57370 NULL
121410 +tipc_bclink_stats_57372 tipc_bclink_stats 2 57372 NULL
121411 +tty_register_device_attr_57381 tty_register_device_attr 2 57381 NULL
121412 +read_file_blob_57406 read_file_blob 3 57406 NULL
121413 +enclosure_register_57412 enclosure_register 3 57412 NULL
121414 +compat_keyctl_instantiate_key_iov_57431 compat_keyctl_instantiate_key_iov 3 57431 NULL
121415 +copy_to_user_fromio_57432 copy_to_user_fromio 3 57432 NULL
121416 +solo_gpio_init_57446 solo_gpio_init 0 57446 NULL
121417 +usb_add_gadget_udc_release_57449 usb_add_gadget_udc_release 0 57449 NULL
121418 +ath5k_eeprom_init_modes_57455 ath5k_eeprom_init_modes 0 57455 NULL
121419 +__roundup_pow_of_two_57461 __roundup_pow_of_two 0 57461 NULL
121420 +sisusb_clear_vram_57466 sisusb_clear_vram 2-3 57466 NULL
121421 +ieee80211_if_read_flags_57470 ieee80211_if_read_flags 3 57470 NULL
121422 +bnad_debugfs_write_regwr_57500 bnad_debugfs_write_regwr 3 57500 NULL
121423 +skb_headlen_57501 skb_headlen 0 57501 NULL
121424 +copy_in_user_57502 copy_in_user 3 57502 NULL
121425 +ckhdid_printf_57505 ckhdid_printf 2 57505 NULL nohasharray
121426 +gfs2_quota_hold_57505 gfs2_quota_hold 0 57505 &ckhdid_printf_57505
121427 +ath10k_init_connect_htc_57509 ath10k_init_connect_htc 0 57509 NULL
121428 +init_tag_map_57515 init_tag_map 3 57515 NULL
121429 +il_dbgfs_force_reset_read_57517 il_dbgfs_force_reset_read 3 57517 NULL nohasharray
121430 +wil_read_file_ssid_57517 wil_read_file_ssid 3 57517 &il_dbgfs_force_reset_read_57517
121431 +cmm_read_57520 cmm_read 3 57520 NULL nohasharray
121432 +do_hypercall_57520 do_hypercall 0 57520 &cmm_read_57520
121433 +inode_permission_57531 inode_permission 0 57531 NULL
121434 +acpi_dev_get_resources_57534 acpi_dev_get_resources 0 57534 NULL
121435 +ptlrpc_lprocfs_hp_ratio_seq_write_57537 ptlrpc_lprocfs_hp_ratio_seq_write 3 57537 NULL nohasharray
121436 +usb_new_device_57537 usb_new_device 0 57537 &ptlrpc_lprocfs_hp_ratio_seq_write_57537
121437 +driver_register_57538 driver_register 0 57538 NULL
121438 +compat_SyS_process_vm_writev_57542 compat_SyS_process_vm_writev 3-5 57542 NULL
121439 +ReadHDLCPnP_57559 ReadHDLCPnP 0 57559 NULL
121440 +obd_unpackmd_57563 obd_unpackmd 0 57563 NULL
121441 +snd_pcm_playback_ioctl1_57569 snd_pcm_playback_ioctl1 0 57569 NULL
121442 +pn544_hci_i2c_fw_write_cmd_57572 pn544_hci_i2c_fw_write_cmd 4 57572 NULL
121443 +get_bridge_ifindices_57579 get_bridge_ifindices 0 57579 NULL nohasharray
121444 +ili210x_read_reg_57579 ili210x_read_reg 0 57579 &get_bridge_ifindices_57579
121445 +ldlm_cli_enqueue_local_57582 ldlm_cli_enqueue_local 11 57582 NULL
121446 +il_dbgfs_interrupt_write_57591 il_dbgfs_interrupt_write 3 57591 NULL
121447 +read_file_spectral_fft_period_57593 read_file_spectral_fft_period 3 57593 NULL
121448 +mthca_map_eq_regs_57598 mthca_map_eq_regs 0 57598 NULL
121449 +wm831x_gpio_to_irq_57614 wm831x_gpio_to_irq 2 57614 NULL
121450 +tx_tx_retry_template_read_57623 tx_tx_retry_template_read 3 57623 NULL
121451 +sisusbcon_putcs_57630 sisusbcon_putcs 3 57630 NULL
121452 +mem_read_57631 mem_read 3 57631 NULL
121453 +pci_enable_msi_block_57632 pci_enable_msi_block 0 57632 NULL
121454 +msi_compose_msg_57637 msi_compose_msg 0 57637 NULL
121455 +xfs_alloc_ag_vextent_near_57653 xfs_alloc_ag_vextent_near 0 57653 NULL
121456 +c_can_start_57654 c_can_start 0 57654 NULL nohasharray
121457 +get_vpd_params_57654 get_vpd_params 0 57654 &c_can_start_57654
121458 +t4vf_sge_alloc_eth_txq_57656 t4vf_sge_alloc_eth_txq 0 57656 NULL
121459 +r3964_write_57662 r3964_write 4 57662 NULL
121460 +proc_ns_readlink_57664 proc_ns_readlink 3 57664 NULL
121461 +__lgwrite_57669 __lgwrite 4 57669 NULL
121462 +f1x_match_to_this_node_57695 f1x_match_to_this_node 3 57695 NULL
121463 +i2400m_rx_stats_read_57706 i2400m_rx_stats_read 3 57706 NULL nohasharray
121464 +snd_es1688_probe_57706 snd_es1688_probe 0 57706 &i2400m_rx_stats_read_57706
121465 +ieee80211_if_read_dot11MeshHWMPconfirmationInterval_57722 ieee80211_if_read_dot11MeshHWMPconfirmationInterval 3 57722 NULL
121466 +vm_find_vqs_57729 vm_find_vqs 0 57729 NULL
121467 +imm_init_57732 imm_init 0 57732 NULL
121468 +nouveau_gpio_create__57735 nouveau_gpio_create_ 4-5 57735 NULL
121469 +pppol2tp_recvmsg_57742 pppol2tp_recvmsg 4 57742 NULL
121470 +ieee80211_if_fmt_dot11MeshHWMPpreqMinInterval_57762 ieee80211_if_fmt_dot11MeshHWMPpreqMinInterval 3 57762 NULL
121471 +SYSC_process_vm_writev_57776 SYSC_process_vm_writev 3-5 57776 NULL
121472 +ivtv_gpio_init_57781 ivtv_gpio_init 0 57781 NULL
121473 +apei_exec_collect_resources_57788 apei_exec_collect_resources 0 57788 NULL
121474 +security_inode_unlink_57791 security_inode_unlink 0 57791 NULL
121475 +ld2_57794 ld2 0 57794 NULL
121476 +ivtv_read_57796 ivtv_read 3 57796 NULL
121477 +ion_test_ioctl_57799 ion_test_ioctl 2 57799 NULL
121478 +bfad_debugfs_read_regrd_57830 bfad_debugfs_read_regrd 3 57830 NULL
121479 +copy_to_user_57835 copy_to_user 3-0 57835 NULL
121480 +mwl8k_rxq_init_57838 mwl8k_rxq_init 0 57838 NULL
121481 +flash_read_57843 flash_read 3 57843 NULL nohasharray
121482 +xfs_rtpick_extent_57843 xfs_rtpick_extent 0 57843 &flash_read_57843
121483 +kiblnd_create_tx_pool_57846 kiblnd_create_tx_pool 2 57846 NULL
121484 +radeon_ttm_gtt_read_57879 radeon_ttm_gtt_read 3 57879 NULL
121485 +xt_alloc_table_info_57903 xt_alloc_table_info 1 57903 NULL
121486 +iio_read_first_n_kfifo_57910 iio_read_first_n_kfifo 2 57910 NULL
121487 +ll_xattr_find_get_lock_57912 ll_xattr_find_get_lock 0 57912 NULL
121488 +memcg_caches_array_size_57918 memcg_caches_array_size 0-1 57918 NULL
121489 +twl_i2c_write_57923 twl_i2c_write 3-4 57923 NULL
121490 +__snd_gf1_look16_57925 __snd_gf1_look16 0 57925 NULL
121491 +sel_read_handle_unknown_57933 sel_read_handle_unknown 3 57933 NULL
121492 +xfs_inode_item_format_convert_57937 xfs_inode_item_format_convert 0 57937 NULL
121493 +ath_regd_init_57938 ath_regd_init 0 57938 NULL
121494 +xfs_mru_cache_create_57943 xfs_mru_cache_create 3 57943 NULL
121495 +key_algorithm_read_57946 key_algorithm_read 3 57946 NULL
121496 +ip_set_alloc_57953 ip_set_alloc 1 57953 NULL nohasharray
121497 +ioat3_dca_count_dca_slots_57953 ioat3_dca_count_dca_slots 0 57953 &ip_set_alloc_57953
121498 +do_rx_dma_57996 do_rx_dma 5 57996 NULL
121499 +cb710_pci_configure_57999 cb710_pci_configure 0 57999 NULL
121500 +rx_reset_counter_read_58001 rx_reset_counter_read 3 58001 NULL
121501 +iwl_dbgfs_ucode_rx_stats_read_58023 iwl_dbgfs_ucode_rx_stats_read 3 58023 NULL nohasharray
121502 +si4713_set_power_state_58023 si4713_set_power_state 0 58023 &iwl_dbgfs_ucode_rx_stats_read_58023
121503 +io_playback_transfer_58030 io_playback_transfer 4 58030 NULL nohasharray
121504 +asd_unpause_cseq_58030 asd_unpause_cseq 0 58030 &io_playback_transfer_58030
121505 +snd_info_card_create_58055 snd_info_card_create 0 58055 NULL
121506 +mce_async_out_58056 mce_async_out 3 58056 NULL
121507 +bq32k_write_58057 bq32k_write 4 58057 NULL
121508 +ocfs2_find_leaf_58065 ocfs2_find_leaf 0 58065 NULL
121509 +dt3155_alloc_coherent_58073 dt3155_alloc_coherent 2 58073 NULL nohasharray
121510 +rfkill_led_trigger_register_58073 rfkill_led_trigger_register 0 58073 &dt3155_alloc_coherent_58073
121511 +cm4040_write_58079 cm4040_write 3 58079 NULL nohasharray
121512 +usb_stor_acquire_resources_58079 usb_stor_acquire_resources 0 58079 &cm4040_write_58079
121513 +regulator_register_supply_alias_58081 regulator_register_supply_alias 0 58081 NULL
121514 +ntb_xeon_setup_58098 ntb_xeon_setup 0 58098 NULL
121515 +hpsa_enter_simple_mode_58108 hpsa_enter_simple_mode 0 58108 NULL
121516 +ipv6_flowlabel_opt_58135 ipv6_flowlabel_opt 3 58135 NULL nohasharray
121517 +slhc_init_58135 slhc_init 1-2 58135 &ipv6_flowlabel_opt_58135
121518 +ql_clear_routing_entries_58143 ql_clear_routing_entries 0 58143 NULL
121519 +xfs_bmap_add_extent_delay_real_58151 xfs_bmap_add_extent_delay_real 0 58151 NULL
121520 +ocfs2_reserve_clusters_58164 ocfs2_reserve_clusters 0 58164 NULL
121521 +spu_wait_for_u32_58166 spu_wait_for_u32 0 58166 NULL
121522 +xfs_btree_update_58167 xfs_btree_update 0 58167 NULL
121523 +cx18_init_struct1_58169 cx18_init_struct1 0 58169 NULL
121524 +garmin_write_bulk_58191 garmin_write_bulk 3 58191 NULL
121525 +ieee80211_if_fmt_flags_58205 ieee80211_if_fmt_flags 3 58205 NULL
121526 +i40evf_allocate_virt_mem_d_58210 i40evf_allocate_virt_mem_d 3 58210 NULL
121527 +btrfsic_create_link_to_next_block_58246 btrfsic_create_link_to_next_block 4 58246 NULL nohasharray
121528 +regmap_raw_read_58246 regmap_raw_read 0 58246 &btrfsic_create_link_to_next_block_58246
121529 +read_file_debug_58256 read_file_debug 3 58256 NULL
121530 +osc_max_dirty_mb_seq_write_58263 osc_max_dirty_mb_seq_write 3 58263 NULL
121531 +cfg80211_mgmt_tx_status_58266 cfg80211_mgmt_tx_status 4 58266 NULL
121532 +profile_load_58267 profile_load 3 58267 NULL
121533 +kstrtos8_from_user_58268 kstrtos8_from_user 2 58268 NULL
121534 +acpi_ds_build_internal_package_obj_58271 acpi_ds_build_internal_package_obj 3 58271 NULL
121535 +iscsi_decode_text_input_58292 iscsi_decode_text_input 4 58292 NULL
121536 +tg3_get_device_address_58298 tg3_get_device_address 0 58298 NULL
121537 +ieee80211_if_read_dot11MeshTTL_58307 ieee80211_if_read_dot11MeshTTL 3 58307 NULL
121538 +tx_tx_start_int_templates_read_58324 tx_tx_start_int_templates_read 3 58324 NULL
121539 +ext4_ext_truncate_extend_restart_58331 ext4_ext_truncate_extend_restart 3 58331 NULL
121540 +__copy_from_user_swizzled_58337 __copy_from_user_swizzled 2-4 58337 NULL
121541 +SyS_migrate_pages_58348 SyS_migrate_pages 2 58348 NULL
121542 +brcmf_debugfs_sdio_counter_read_58369 brcmf_debugfs_sdio_counter_read 3 58369 NULL
121543 +il_dbgfs_status_read_58388 il_dbgfs_status_read 3 58388 NULL
121544 +_drbd_md_sync_page_io_58403 _drbd_md_sync_page_io 6 58403 NULL
121545 +kvm_mmu_write_protect_pt_masked_58406 kvm_mmu_write_protect_pt_masked 3 58406 NULL nohasharray
121546 +idetape_pad_zeros_58406 idetape_pad_zeros 2 58406 &kvm_mmu_write_protect_pt_masked_58406
121547 +xfs_btree_get_rec_58410 xfs_btree_get_rec 0 58410 NULL
121548 +i2400m_pld_size_58415 i2400m_pld_size 0 58415 NULL
121549 +pci_bus_write_config_byte_58451 pci_bus_write_config_byte 0 58451 NULL
121550 +capabilities_read_58457 capabilities_read 3 58457 NULL
121551 +usnic_vnic_get_resources_58462 usnic_vnic_get_resources 3 58462 NULL
121552 +compat_do_ipt_set_ctl_58466 compat_do_ipt_set_ctl 4 58466 NULL nohasharray
121553 +lpfc_idiag_baracc_read_58466 lpfc_idiag_baracc_read 3 58466 &compat_do_ipt_set_ctl_58466
121554 +nv_rd08_58472 nv_rd08 0 58472 NULL
121555 +p54_register_common_58476 p54_register_common 0 58476 NULL
121556 +acpi_tables_sysfs_init_58477 acpi_tables_sysfs_init 0 58477 NULL
121557 +mthca_status_to_errno_58482 mthca_status_to_errno 0 58482 NULL
121558 +snd_gf1_read_addr_58483 snd_gf1_read_addr 0 58483 NULL
121559 +snd_rme96_capture_copy_58484 snd_rme96_capture_copy 5 58484 NULL
121560 +btrfs_cont_expand_58498 btrfs_cont_expand 2-3-0 58498 NULL
121561 +tcf_hash_create_58507 tcf_hash_create 4 58507 NULL
121562 +gfs2_dir_get_new_buffer_58509 gfs2_dir_get_new_buffer 0 58509 NULL
121563 +rndis_add_response_58544 rndis_add_response 2 58544 NULL
121564 +wep_decrypt_fail_read_58567 wep_decrypt_fail_read 3 58567 NULL
121565 +scnprint_mac_oui_58578 scnprint_mac_oui 3-0 58578 NULL
121566 +cur_wm_latency_write_58581 cur_wm_latency_write 3 58581 NULL
121567 +get_rhf_errstring_58582 get_rhf_errstring 3 58582 NULL
121568 +ea_read_inline_58589 ea_read_inline 0 58589 NULL
121569 +isku_sysfs_read_keys_thumbster_58590 isku_sysfs_read_keys_thumbster 6 58590 NULL
121570 +xip_file_read_58592 xip_file_read 3 58592 NULL
121571 +ecryptfs_write_end_58594 ecryptfs_write_end 5-3 58594 NULL
121572 +radeon_bo_size_58606 radeon_bo_size 0 58606 NULL
121573 +skb_copy_to_page_nocache_58624 skb_copy_to_page_nocache 6 58624 NULL
121574 +ath10k_bmi_read_memory_58628 ath10k_bmi_read_memory 0 58628 NULL
121575 +filemap_fdatawrite_range_58630 filemap_fdatawrite_range 0 58630 NULL
121576 +tx_tx_start_fw_gen_read_58648 tx_tx_start_fw_gen_read 3 58648 NULL
121577 +iwl_dbgfs_rx_handlers_write_58655 iwl_dbgfs_rx_handlers_write 3 58655 NULL
121578 +find_zero_58685 find_zero 0-1 58685 NULL
121579 +uwb_bce_print_IEs_58686 uwb_bce_print_IEs 4 58686 NULL
121580 +tps6586x_writes_58689 tps6586x_writes 2-3 58689 NULL
121581 +adap_init0_58694 adap_init0 0 58694 NULL
121582 +scsi_setup_command_freelist_58703 scsi_setup_command_freelist 0 58703 NULL
121583 +vx_send_msg_58711 vx_send_msg 0 58711 NULL
121584 +da9052_gpio_to_irq_58729 da9052_gpio_to_irq 2 58729 NULL
121585 +csum_exist_in_range_58730 csum_exist_in_range 2-3 58730 NULL
121586 +frames_to_bytes_58741 frames_to_bytes 0-2 58741 NULL
121587 +ieee80211_if_write_tkip_mic_test_58748 ieee80211_if_write_tkip_mic_test 3 58748 NULL
121588 +agp_allocate_memory_58761 agp_allocate_memory 2 58761 NULL
121589 +regmap_calc_reg_len_58795 regmap_calc_reg_len 0 58795 NULL
121590 +sep_register_driver_with_fs_58802 sep_register_driver_with_fs 0 58802 NULL
121591 +raw_send_hdrinc_58803 raw_send_hdrinc 4 58803 NULL
121592 +isku_sysfs_read_58806 isku_sysfs_read 5 58806 NULL
121593 +write_file_58812 write_file 4 58812 NULL
121594 +ep_read_58813 ep_read 3 58813 NULL
121595 +command_write_58841 command_write 3 58841 NULL
121596 +__ath9k_hw_init_58848 __ath9k_hw_init 0 58848 NULL
121597 +ocfs2_truncate_log_append_58850 ocfs2_truncate_log_append 0 58850 NULL
121598 +ath6kl_wmi_send_action_cmd_58860 ath6kl_wmi_send_action_cmd 7 58860 NULL
121599 +i2c_atmel_send_58870 i2c_atmel_send 3 58870 NULL
121600 +gs_alloc_req_58883 gs_alloc_req 2 58883 NULL
121601 +esas2r_change_queue_depth_58886 esas2r_change_queue_depth 2 58886 NULL
121602 +sd_format_disk_name_58907 sd_format_disk_name 0 58907 NULL
121603 +lprocfs_wr_pinger_recov_58914 lprocfs_wr_pinger_recov 3 58914 NULL
121604 +print_devstats_dot11FCSErrorCount_58919 print_devstats_dot11FCSErrorCount 3 58919 NULL
121605 +pipeline_cs_rx_packet_out_read_58926 pipeline_cs_rx_packet_out_read 3 58926 NULL
121606 +ntb_transport_init_queue_58929 ntb_transport_init_queue 0 58929 NULL
121607 +t4vf_config_rss_range_58930 t4vf_config_rss_range 0 58930 NULL
121608 +SyS_pread64_58935 SyS_pread64 3 58935 NULL
121609 +xfs_bmap_read_extents_58936 xfs_bmap_read_extents 0 58936 NULL
121610 +vip_gpio_reserve_58943 vip_gpio_reserve 0 58943 NULL
121611 +wait_table_hash_nr_entries_58962 wait_table_hash_nr_entries 0 58962 NULL
121612 +ieee80211_if_fmt_dot11MeshHWMPactivePathToRootTimeout_58965 ieee80211_if_fmt_dot11MeshHWMPactivePathToRootTimeout 3 58965 NULL
121613 +crypto_aead_ivsize_58970 crypto_aead_ivsize 0 58970 NULL
121614 +usbhs_mod_gadget_probe_58987 usbhs_mod_gadget_probe 0 58987 NULL
121615 +init_list_set_59005 init_list_set 3 59005 NULL
121616 +ep_write_59008 ep_write 3 59008 NULL
121617 +lpfc_idiag_baracc_write_59014 lpfc_idiag_baracc_write 3 59014 NULL
121618 +SyS_preadv_59029 SyS_preadv 3 59029 NULL
121619 +init_pci_cap_msi_perm_59033 init_pci_cap_msi_perm 2-0 59033 NULL
121620 +selinux_transaction_write_59038 selinux_transaction_write 3 59038 NULL
121621 +crypto_aead_reqsize_59039 crypto_aead_reqsize 0 59039 NULL
121622 +regmap_bulk_write_59049 regmap_bulk_write 2-4 59049 NULL nohasharray
121623 +i8042_enable_kbd_port_59049 i8042_enable_kbd_port 0 59049 &regmap_bulk_write_59049
121624 +fnic_dev_stats_dump_59091 fnic_dev_stats_dump 0 59091 NULL
121625 +mmc_sd_num_wr_blocks_59112 mmc_sd_num_wr_blocks 0 59112 NULL nohasharray
121626 +asd_post_escb_list_59112 asd_post_escb_list 0 59112 &mmc_sd_num_wr_blocks_59112
121627 +sta_tx_latency_stat_table_59122 sta_tx_latency_stat_table 0-4-5 59122 NULL nohasharray
121628 +scsi_io_completion_59122 scsi_io_completion 2 59122 &sta_tx_latency_stat_table_59122
121629 +nfc_llcp_send_i_frame_59130 nfc_llcp_send_i_frame 3 59130 NULL
121630 +__iio_add_event_config_attrs_59136 __iio_add_event_config_attrs 0 59136 NULL
121631 +print_devstats_dot11RTSSuccessCount_59145 print_devstats_dot11RTSSuccessCount 3 59145 NULL nohasharray
121632 +framebuffer_alloc_59145 framebuffer_alloc 1 59145 &print_devstats_dot11RTSSuccessCount_59145
121633 +ocfs2_claim_local_alloc_bits_59147 ocfs2_claim_local_alloc_bits 0 59147 NULL
121634 +radeon_compat_ioctl_59150 radeon_compat_ioctl 2 59150 NULL
121635 +pvr2_hdw_report_clients_59152 pvr2_hdw_report_clients 3 59152 NULL
121636 +mthca_create_eq_59157 mthca_create_eq 0 59157 NULL
121637 +ksize_59176 ksize 0 59176 NULL
121638 +rtsx_pci_write_register_59177 rtsx_pci_write_register 0 59177 NULL
121639 +setup_window_59178 setup_window 4-2-5-7 59178 NULL
121640 +ocfs2_move_extent_59187 ocfs2_move_extent 2-5 59187 NULL
121641 +xfs_ialloc_next_rec_59193 xfs_ialloc_next_rec 0 59193 NULL
121642 +p54_parse_firmware_59195 p54_parse_firmware 0 59195 NULL
121643 +xfs_iext_realloc_indirect_59211 xfs_iext_realloc_indirect 2 59211 NULL
121644 +spu_init_59215 spu_init 0 59215 NULL
121645 +check_mapped_selector_name_59216 check_mapped_selector_name 5 59216 NULL
121646 +dt3155_read_59226 dt3155_read 3 59226 NULL
121647 +paging64_gpte_to_gfn_lvl_59229 paging64_gpte_to_gfn_lvl 0-2-1 59229 NULL nohasharray
121648 +ql_adapter_initialize_59229 ql_adapter_initialize 0 59229 &paging64_gpte_to_gfn_lvl_59229
121649 +lpfc_sli4_queue_setup_59242 lpfc_sli4_queue_setup 0 59242 NULL
121650 +init_queue_59250 init_queue 0 59250 NULL
121651 +nla_len_59258 nla_len 0 59258 NULL
121652 +drbd_bm_write_page_59290 drbd_bm_write_page 2 59290 NULL
121653 +netdev_queue_update_kobjects_59301 netdev_queue_update_kobjects 0 59301 NULL
121654 +btrfs_insert_dir_item_59304 btrfs_insert_dir_item 4 59304 NULL
121655 +xfs_iformat_fork_59312 xfs_iformat_fork 0 59312 NULL
121656 +fd_copyout_59323 fd_copyout 3 59323 NULL
121657 +ipr_probe_ioa_59326 ipr_probe_ioa 0 59326 NULL
121658 +read_9287_modal_eeprom_59327 read_9287_modal_eeprom 3 59327 NULL
121659 +set_state_private_59336 set_state_private 0 59336 NULL
121660 +rx_defrag_in_process_called_read_59338 rx_defrag_in_process_called_read 3 59338 NULL
121661 +xfs_attrmulti_attr_set_59346 xfs_attrmulti_attr_set 4 59346 NULL nohasharray
121662 +xfs_alloc_lookup_le_59346 xfs_alloc_lookup_le 0 59346 &xfs_attrmulti_attr_set_59346
121663 +__map_request_59350 __map_request 0 59350 NULL
121664 +gfs2_quota_lock_check_59353 gfs2_quota_lock_check 0 59353 NULL
121665 +hardware_init_port_59375 hardware_init_port 0 59375 NULL
121666 +adp5588_read_59376 adp5588_read 0 59376 NULL
121667 +f2fs_fallocate_59377 f2fs_fallocate 3-4 59377 NULL
121668 +pvr2_debugifc_print_info_59380 pvr2_debugifc_print_info 3 59380 NULL
121669 +journal_init_dev_59384 journal_init_dev 5 59384 NULL
121670 +__net_get_random_once_59389 __net_get_random_once 2 59389 NULL
121671 +isku_sysfs_read_keys_function_59412 isku_sysfs_read_keys_function 6 59412 NULL
121672 +pci_ctrl_read_59424 pci_ctrl_read 0 59424 NULL
121673 +vxge_hw_ring_rxds_per_block_get_59425 vxge_hw_ring_rxds_per_block_get 0 59425 NULL
121674 +snd_pcm_tstamp_59431 snd_pcm_tstamp 0 59431 NULL
121675 +SyS_sched_setaffinity_59442 SyS_sched_setaffinity 2 59442 NULL
121676 +fs_path_ensure_buf_59445 fs_path_ensure_buf 2 59445 NULL
121677 +tipc_recv_stream_59456 tipc_recv_stream 4 59456 NULL
121678 +t4vf_get_vpd_params_59484 t4vf_get_vpd_params 0 59484 NULL
121679 +_iwl_dbgfs_bcast_filters_write_59491 _iwl_dbgfs_bcast_filters_write 3 59491 NULL
121680 +rtw_cfg80211_set_mgnt_wpsp2pie_59497 rtw_cfg80211_set_mgnt_wpsp2pie 3 59497 NULL
121681 +ath10k_htc_send_59498 ath10k_htc_send 0 59498 NULL
121682 +ib_copy_from_udata_59502 ib_copy_from_udata 3 59502 NULL
121683 +C_SYSC_get_mempolicy_59516 C_SYSC_get_mempolicy 3 59516 NULL
121684 +mic_vringh_copy_59523 mic_vringh_copy 4 59523 NULL
121685 +ipw2100_wdev_init_59533 ipw2100_wdev_init 0 59533 NULL
121686 +msix_setup_entries_59545 msix_setup_entries 0 59545 NULL nohasharray
121687 +idr_alloc_59545 idr_alloc 0 59545 &msix_setup_entries_59545
121688 +mpi_get_nbits_59551 mpi_get_nbits 0 59551 NULL
121689 +ath9k_cmn_init_channels_rates_59557 ath9k_cmn_init_channels_rates 0 59557 NULL
121690 +tunables_write_59563 tunables_write 3 59563 NULL
121691 +bio_split_59564 bio_split 2 59564 NULL
121692 +__copy_from_user_ll_nozero_59571 __copy_from_user_ll_nozero 0-3 59571 NULL
121693 +ext2_rec_len_from_disk_59581 ext2_rec_len_from_disk 0-1 59581 NULL
121694 +write_pbl_59583 write_pbl 4 59583 NULL
121695 +memdup_user_59590 memdup_user 2 59590 NULL
121696 +max8925_bulk_write_59597 max8925_bulk_write 3 59597 NULL
121697 +tps6586x_irq_get_virq_59601 tps6586x_irq_get_virq 2 59601 NULL
121698 +xrcdn_free_res_59616 xrcdn_free_res 5 59616 NULL nohasharray
121699 +mem_fwlog_free_mem_blks_read_59616 mem_fwlog_free_mem_blks_read 3 59616 &xrcdn_free_res_59616
121700 +ath6kl_endpoint_stats_write_59621 ath6kl_endpoint_stats_write 3 59621 NULL
121701 +mtrr_write_59622 mtrr_write 3 59622 NULL
121702 +ocfs2_adjust_rightmost_branch_59623 ocfs2_adjust_rightmost_branch 0 59623 NULL
121703 +fnic_alloc_rq_frame_59634 fnic_alloc_rq_frame 0 59634 NULL
121704 +find_first_zero_bit_59636 find_first_zero_bit 0 59636 NULL
121705 +SyS_setdomainname_59646 SyS_setdomainname 2 59646 NULL
121706 +file_update_time_59647 file_update_time 0 59647 NULL
121707 +hidraw_read_59650 hidraw_read 3 59650 NULL
121708 +v9fs_xattr_set_acl_59651 v9fs_xattr_set_acl 4 59651 NULL
121709 +__devcgroup_check_permission_59665 __devcgroup_check_permission 0 59665 NULL
121710 +iwl_dbgfs_mac_params_read_59666 iwl_dbgfs_mac_params_read 3 59666 NULL
121711 +alloc_dca_provider_59670 alloc_dca_provider 2 59670 NULL
121712 +sriov_enable_59689 sriov_enable 0 59689 NULL
121713 +mic_calc_failure_read_59700 mic_calc_failure_read 3 59700 NULL
121714 +ioperm_get_59701 ioperm_get 4-3 59701 NULL
121715 +snd_pcm_info_user_59711 snd_pcm_info_user 0 59711 NULL
121716 +prism2_info_scanresults_59729 prism2_info_scanresults 3 59729 NULL
121717 +ieee80211_if_read_fwded_unicast_59740 ieee80211_if_read_fwded_unicast 3 59740 NULL
121718 +fat_direct_IO_59741 fat_direct_IO 4 59741 NULL
121719 +qib_decode_7220_sdma_errs_59745 qib_decode_7220_sdma_errs 4 59745 NULL
121720 +strnlen_59746 strnlen 0 59746 NULL
121721 +ext3_acl_count_59754 ext3_acl_count 0-1 59754 NULL
121722 +ioat2_reset_sync_59756 ioat2_reset_sync 0 59756 NULL
121723 +long_retry_limit_read_59766 long_retry_limit_read 3 59766 NULL nohasharray
121724 +cap_inode_need_killpriv_59766 cap_inode_need_killpriv 0 59766 &long_retry_limit_read_59766
121725 +venus_remove_59781 venus_remove 4 59781 NULL
121726 +mei_nfc_recv_59784 mei_nfc_recv 3 59784 NULL
121727 +pt1_init_table_59798 pt1_init_table 0 59798 NULL
121728 +C_SYSC_preadv_59801 C_SYSC_preadv 3 59801 NULL
121729 +ipw_write_59807 ipw_write 3 59807 NULL
121730 +scsi_init_shared_tag_map_59812 scsi_init_shared_tag_map 2 59812 NULL
121731 +ieee80211_if_read_dot11MeshHWMPmaxPREQretries_59829 ieee80211_if_read_dot11MeshHWMPmaxPREQretries 3 59829 NULL
121732 +gspca_dev_probe2_59833 gspca_dev_probe2 4 59833 NULL
121733 +regmap_raw_write_async_59849 regmap_raw_write_async 2-4 59849 NULL
121734 +pvr2_ioread_set_sync_key_59882 pvr2_ioread_set_sync_key 3 59882 NULL
121735 +l2cap_sock_recvmsg_59886 l2cap_sock_recvmsg 4 59886 NULL
121736 +mlx4_table_get_59887 mlx4_table_get 0 59887 NULL
121737 +ffs_prepare_buffer_59892 ffs_prepare_buffer 2 59892 NULL
121738 +ocfs2_extend_rotate_transaction_59894 ocfs2_extend_rotate_transaction 0 59894 NULL
121739 +kvm_mmu_notifier_invalidate_range_start_59944 kvm_mmu_notifier_invalidate_range_start 3-4 59944 NULL
121740 +ocfs2_expand_inline_ref_root_59945 ocfs2_expand_inline_ref_root 0 59945 NULL
121741 +ath10k_read_dfs_stats_59949 ath10k_read_dfs_stats 3 59949 NULL
121742 +dapm_widget_power_read_file_59950 dapm_widget_power_read_file 3 59950 NULL nohasharray
121743 +il_dbgfs_rxon_flags_read_59950 il_dbgfs_rxon_flags_read 3 59950 &dapm_widget_power_read_file_59950
121744 +il_dbgfs_missed_beacon_read_59956 il_dbgfs_missed_beacon_read 3 59956 NULL
121745 +__arch_hweight16_59975 __arch_hweight16 0 59975 NULL
121746 +raw_notifier_chain_register_59977 raw_notifier_chain_register 0 59977 NULL
121747 +phy_record_59981 phy_record 0 59981 NULL
121748 +asd_map_memio_59988 asd_map_memio 0 59988 NULL
121749 +osd_req_read_kern_59990 osd_req_read_kern 5 59990 NULL
121750 +ghash_async_setkey_60001 ghash_async_setkey 3 60001 NULL
121751 +ieee80211_if_fmt_dot11MeshAwakeWindowDuration_60006 ieee80211_if_fmt_dot11MeshAwakeWindowDuration 3 60006 NULL
121752 +copy_items_60009 copy_items 7 60009 NULL
121753 +rawsock_sendmsg_60010 rawsock_sendmsg 4 60010 NULL
121754 +mthca_init_cq_60011 mthca_init_cq 2 60011 NULL
121755 +osd_req_list_dev_partitions_60027 osd_req_list_dev_partitions 4 60027 NULL
121756 +xlog_bread_offset_60030 xlog_bread_offset 3 60030 NULL
121757 +xfs_imap_to_bp_60034 xfs_imap_to_bp 0 60034 NULL
121758 +skd_acquire_msix_60037 skd_acquire_msix 0 60037 NULL
121759 +bio_integrity_hw_sectors_60039 bio_integrity_hw_sectors 0-2 60039 NULL
121760 +do_ip6t_set_ctl_60040 do_ip6t_set_ctl 4 60040 NULL
121761 +vcs_size_60050 vcs_size 0 60050 NULL
121762 +gru_alloc_gts_60056 gru_alloc_gts 3-2 60056 NULL
121763 +compat_writev_60063 compat_writev 3 60063 NULL
121764 +ath6kl_listen_int_write_60066 ath6kl_listen_int_write 3 60066 NULL
121765 +c4iw_num_stags_60073 c4iw_num_stags 0 60073 NULL
121766 +rxrpc_kernel_send_data_60083 rxrpc_kernel_send_data 3 60083 NULL
121767 +ieee80211_if_fmt_fwded_frames_60103 ieee80211_if_fmt_fwded_frames 3 60103 NULL
121768 +pci_save_state_60109 pci_save_state 0 60109 NULL
121769 +SYSC_msgsnd_60113 SYSC_msgsnd 3 60113 NULL
121770 +nfs_idmap_request_key_60124 nfs_idmap_request_key 2 60124 NULL
121771 +__mutex_lock_common_60134 __mutex_lock_common 0 60134 NULL
121772 +spu_wait_for_u16_60142 spu_wait_for_u16 0 60142 NULL
121773 +solo_disp_init_60146 solo_disp_init 0 60146 NULL
121774 +ld_usb_read_60156 ld_usb_read 3 60156 NULL
121775 +jmb38x_ms_count_slots_60164 jmb38x_ms_count_slots 0 60164 NULL
121776 +init_state_60165 init_state 2 60165 NULL
121777 +jffs2_alloc_full_dirent_60179 jffs2_alloc_full_dirent 1 60179 NULL nohasharray
121778 +sg_build_sgat_60179 sg_build_sgat 3 60179 &jffs2_alloc_full_dirent_60179
121779 +fuse_async_req_send_60183 fuse_async_req_send 0-3 60183 NULL
121780 +rx_rx_tkip_replays_read_60193 rx_rx_tkip_replays_read 3 60193 NULL nohasharray
121781 +arch_setup_msi_irqs_60193 arch_setup_msi_irqs 0 60193 &rx_rx_tkip_replays_read_60193
121782 +qib_reg_phys_mr_60202 qib_reg_phys_mr 3 60202 NULL
121783 +btrfs_get_token_16_60220 btrfs_get_token_16 0 60220 NULL
121784 +arizona_map_irq_60230 arizona_map_irq 2 60230 NULL
121785 +wm831x_irq_60254 wm831x_irq 2 60254 NULL
121786 +irq_alloc_domain_generic_chips_60264 irq_alloc_domain_generic_chips 2-3 60264 NULL
121787 +mlx4_ACCESS_MEM_60265 mlx4_ACCESS_MEM 0 60265 NULL
121788 +display_crc_ctl_write_60273 display_crc_ctl_write 3 60273 NULL
121789 +printer_write_60276 printer_write 3 60276 NULL
121790 +remove_srq_ok_60280 remove_srq_ok 0 60280 NULL
121791 +do_xip_mapping_read_60297 do_xip_mapping_read 5 60297 NULL
121792 +getDataLength_60301 getDataLength 0 60301 NULL
121793 +bch_subtract_dirty_60306 bch_subtract_dirty 3-4 60306 NULL
121794 +mlx4_slave_cmd_60337 mlx4_slave_cmd 0 60337 NULL
121795 +usb_alphatrack_write_60341 usb_alphatrack_write 3 60341 NULL
121796 +__kfifo_from_user_r_60345 __kfifo_from_user_r 5-3 60345 NULL
121797 +dccp_setsockopt_60367 dccp_setsockopt 5 60367 NULL
121798 +ubi_eba_atomic_leb_change_60379 ubi_eba_atomic_leb_change 0 60379 NULL
121799 +mthca_alloc_resize_buf_60394 mthca_alloc_resize_buf 3 60394 NULL
121800 +ocfs2_zero_extend_60396 ocfs2_zero_extend 3 60396 NULL
121801 +tveeprom_read_60397 tveeprom_read 3 60397 NULL
121802 +driver_names_read_60399 driver_names_read 3 60399 NULL
121803 +simple_alloc_urb_60420 simple_alloc_urb 3 60420 NULL
121804 +excessive_retries_read_60425 excessive_retries_read 3 60425 NULL
121805 +kmalloc_60432 kmalloc 1 60432 NULL nohasharray
121806 +tstats_write_60432 tstats_write 3 60432 &kmalloc_60432
121807 +t4_wait_op_done_60444 t4_wait_op_done 0 60444 NULL
121808 +snd_hda_get_num_raw_conns_60462 snd_hda_get_num_raw_conns 0 60462 NULL
121809 +ivtv_streams_setup_60463 ivtv_streams_setup 0 60463 NULL
121810 +rtsx_pci_init_chip_60470 rtsx_pci_init_chip 0 60470 NULL
121811 +crypto_shash_setkey_60483 crypto_shash_setkey 3 60483 NULL
121812 +lustre_msg_early_size_60496 lustre_msg_early_size 0 60496 NULL
121813 +psy_register_thermal_60507 psy_register_thermal 0 60507 NULL
121814 +xfs_btree_make_block_unfull_60511 xfs_btree_make_block_unfull 0 60511 NULL
121815 +ath_tx_init_60515 ath_tx_init 0 60515 NULL
121816 +lx_dsp_reg_read_60524 lx_dsp_reg_read 0 60524 NULL
121817 +compat_SyS_get_mempolicy_60527 compat_SyS_get_mempolicy 3 60527 NULL
121818 +v9fs_fid_readn_60544 v9fs_fid_readn 4 60544 NULL
121819 +nonpaging_map_60551 nonpaging_map 4 60551 NULL
121820 +osc_lockless_truncate_seq_write_60553 osc_lockless_truncate_seq_write 3 60553 NULL
121821 +solo_sysfs_init_60561 solo_sysfs_init 0 60561 NULL
121822 +em28xx_write_ac97_60562 em28xx_write_ac97 0 60562 NULL
121823 +tracing_entries_write_60563 tracing_entries_write 3 60563 NULL
121824 +memblock_virt_alloc_try_nid_nopanic_60604 memblock_virt_alloc_try_nid_nopanic 1 60604 NULL
121825 +inode_change_ok_60614 inode_change_ok 0 60614 NULL
121826 +ath10k_wmi_pdev_set_param_60615 ath10k_wmi_pdev_set_param 0 60615 NULL
121827 +skb_transport_offset_60619 skb_transport_offset 0 60619 NULL
121828 +wl1273_fm_fops_write_60621 wl1273_fm_fops_write 3 60621 NULL
121829 +acl_alloc_stack_init_60630 acl_alloc_stack_init 1 60630 NULL
121830 +ath10k_hif_power_up_60645 ath10k_hif_power_up 0 60645 NULL
121831 +__proc_lnet_stats_60647 __proc_lnet_stats 5 60647 NULL
121832 +ibmasm_send_driver_vpd_60648 ibmasm_send_driver_vpd 0 60648 NULL
121833 +get_and_reset_irq_60653 get_and_reset_irq 0 60653 NULL
121834 +if_sdio_host_to_card_60666 if_sdio_host_to_card 4 60666 NULL
121835 +ieee80211_if_read_dot11MeshConfirmTimeout_60670 ieee80211_if_read_dot11MeshConfirmTimeout 3 60670 NULL
121836 +pci_bus_alloc_from_region_60687 pci_bus_alloc_from_region 0 60687 NULL
121837 +vga_rcrt_60731 vga_rcrt 0 60731 NULL
121838 +snd_ice1712_ds_read_60754 snd_ice1712_ds_read 0 60754 NULL
121839 +raid_status_60755 raid_status 5 60755 NULL
121840 +dwc2_fs_phy_init_60759 dwc2_fs_phy_init 0 60759 NULL
121841 +sel_write_checkreqprot_60774 sel_write_checkreqprot 3 60774 NULL
121842 +opticon_write_60775 opticon_write 4 60775 NULL
121843 +acl_alloc_num_60778 acl_alloc_num 1-2 60778 NULL
121844 +snd_pcm_oss_readv3_60792 snd_pcm_oss_readv3 3 60792 NULL
121845 +gfs2_bmap_alloc_60822 gfs2_bmap_alloc 0 60822 NULL
121846 +dma_set_coherent_mask_60828 dma_set_coherent_mask 0 60828 NULL
121847 +pwr_tx_with_ps_read_60851 pwr_tx_with_ps_read 3 60851 NULL
121848 +__clone_and_map_data_bio_60861 __clone_and_map_data_bio 4-3 60861 NULL nohasharray
121849 +usb_bulk_msg_60861 usb_bulk_msg 0 60861 &__clone_and_map_data_bio_60861
121850 +alloc_buf_60864 alloc_buf 3-2 60864 NULL
121851 +generic_writepages_60871 generic_writepages 0 60871 NULL
121852 +ubifs_read_one_lp_60882 ubifs_read_one_lp 0 60882 NULL
121853 +ext4_update_inline_data_60888 ext4_update_inline_data 3 60888 NULL
121854 +iio_debugfs_read_reg_60908 iio_debugfs_read_reg 3 60908 NULL
121855 +libcfs_sock_ioctl_60915 libcfs_sock_ioctl 0 60915 NULL
121856 +mgt_set_varlen_60916 mgt_set_varlen 4 60916 NULL
121857 +submit_extent_page_60928 submit_extent_page 5 60928 NULL
121858 +xfs_rtallocate_extent_size_60939 xfs_rtallocate_extent_size 0 60939 NULL
121859 +send_pktsched_cmd_60957 send_pktsched_cmd 0 60957 NULL
121860 +pti_char_write_60960 pti_char_write 3 60960 NULL
121861 +mwifiex_alloc_sdio_mpa_buffers_60961 mwifiex_alloc_sdio_mpa_buffers 2-3 60961 NULL
121862 +__a2mp_build_60987 __a2mp_build 3 60987 NULL
121863 +hsc_msg_alloc_60990 hsc_msg_alloc 1 60990 NULL
121864 +ath6kl_lrssi_roam_read_61022 ath6kl_lrssi_roam_read 3 61022 NULL
121865 +graph_depth_write_61024 graph_depth_write 3 61024 NULL
121866 +sdhci_pltfm_register_61031 sdhci_pltfm_register 3 61031 NULL
121867 +pccard_get_first_tuple_61036 pccard_get_first_tuple 0 61036 NULL
121868 +lpfc_idiag_queacc_write_61043 lpfc_idiag_queacc_write 3 61043 NULL
121869 +psy_register_cooler_61047 psy_register_cooler 0 61047 NULL
121870 +symtab_init_61050 symtab_init 2 61050 NULL
121871 +fuse_send_write_61053 fuse_send_write 0-4 61053 NULL
121872 +snd_pcm_pause_61054 snd_pcm_pause 0 61054 NULL
121873 +bitmap_scnlistprintf_61062 bitmap_scnlistprintf 2-0 61062 NULL
121874 +ahash_align_buffer_size_61070 ahash_align_buffer_size 0-1-2 61070 NULL
121875 +snd_pcm_update_hw_ptr0_61084 snd_pcm_update_hw_ptr0 0 61084 NULL
121876 +xfs_dabuf_map_61093 xfs_dabuf_map 0 61093 NULL
121877 +get_derived_key_61100 get_derived_key 4 61100 NULL
121878 +i40e_calculate_l2fpm_size_61104 i40e_calculate_l2fpm_size 0-1-2-3-4 61104 NULL
121879 +alloc_chrdev_region_61112 alloc_chrdev_region 0 61112 NULL
121880 +__probe_kernel_read_61119 __probe_kernel_read 3 61119 NULL
121881 +vmemmap_alloc_block_buf_61126 vmemmap_alloc_block_buf 1 61126 NULL
121882 +afs_proc_cells_write_61139 afs_proc_cells_write 3 61139 NULL
121883 +beiscsi_process_mcc_61141 beiscsi_process_mcc 0 61141 NULL
121884 +sram_test_pass_61148 sram_test_pass 0 61148 NULL nohasharray
121885 +v4l2_device_register_subdev_61148 v4l2_device_register_subdev 0 61148 &sram_test_pass_61148
121886 +pair_device_61175 pair_device 4 61175 NULL nohasharray
121887 +event_oom_late_read_61175 event_oom_late_read 3 61175 &pair_device_61175
121888 +dio_bio_add_page_61178 dio_bio_add_page 0 61178 NULL
121889 +SyS_prctl_61202 SyS_prctl 4 61202 NULL
121890 +bt878_mem_alloc_61208 bt878_mem_alloc 0 61208 NULL
121891 +arch_hibernation_header_save_61212 arch_hibernation_header_save 0 61212 NULL
121892 +smk_read_ambient_61220 smk_read_ambient 3 61220 NULL
121893 +dt3155_init_board_61231 dt3155_init_board 0 61231 NULL
121894 +v9fs_mmap_file_read_61262 v9fs_mmap_file_read 3 61262 NULL
121895 +t3_sge_init_ecntxt_61269 t3_sge_init_ecntxt 0 61269 NULL
121896 +btrfs_bio_alloc_61270 btrfs_bio_alloc 3 61270 NULL nohasharray
121897 +find_get_pages_tag_61270 find_get_pages_tag 0 61270 &btrfs_bio_alloc_61270 nohasharray
121898 +ifalias_store_61270 ifalias_store 4 61270 &find_get_pages_tag_61270
121899 +vortex_adbdma_getlinearpos_61283 vortex_adbdma_getlinearpos 0 61283 NULL nohasharray
121900 +hfsplus_getxattr_finder_info_61283 hfsplus_getxattr_finder_info 0 61283 &vortex_adbdma_getlinearpos_61283
121901 +nvme_trans_copy_to_user_61288 nvme_trans_copy_to_user 3 61288 NULL
121902 +power_supply_create_triggers_61295 power_supply_create_triggers 0 61295 NULL
121903 +xfer_from_user_61307 xfer_from_user 3 61307 NULL
121904 +xfrm_user_sec_ctx_size_61320 xfrm_user_sec_ctx_size 0 61320 NULL
121905 +C_SYSC_msgsnd_61330 C_SYSC_msgsnd 3 61330 NULL
121906 +write_file_spectral_short_repeat_61335 write_file_spectral_short_repeat 3 61335 NULL
121907 +st5481_setup_isocpipes_61340 st5481_setup_isocpipes 6-4 61340 NULL
121908 +rx_rx_wa_ba_not_expected_read_61341 rx_rx_wa_ba_not_expected_read 3 61341 NULL nohasharray
121909 +do_splice_direct_61341 do_splice_direct 5 61341 &rx_rx_wa_ba_not_expected_read_61341
121910 +__dm_get_reserved_ios_61342 __dm_get_reserved_ios 0-3-2 61342 NULL
121911 +f1x_map_sysaddr_to_csrow_61344 f1x_map_sysaddr_to_csrow 2 61344 NULL
121912 +debug_debug4_read_61367 debug_debug4_read 3 61367 NULL
121913 +system_enable_write_61396 system_enable_write 3 61396 NULL
121914 +xfs_zero_remaining_bytes_61423 xfs_zero_remaining_bytes 3 61423 NULL
121915 +dma_ops_area_alloc_61440 dma_ops_area_alloc 3-4-0 61440 NULL
121916 +unix_stream_sendmsg_61455 unix_stream_sendmsg 4 61455 NULL
121917 +snd_pcm_lib_writev_transfer_61483 snd_pcm_lib_writev_transfer 5-4-2 61483 NULL
121918 +btrfs_item_size_61485 btrfs_item_size 0 61485 NULL
121919 +ocfs2_get_refcount_rec_61514 ocfs2_get_refcount_rec 0 61514 NULL
121920 +erst_errno_61526 erst_errno 0 61526 NULL
121921 +compat_SyS_select_61542 compat_SyS_select 1 61542 NULL
121922 +trace_options_core_write_61551 trace_options_core_write 3 61551 NULL
121923 +dvb_net_ioctl_61559 dvb_net_ioctl 2 61559 NULL
121924 +parport_pc_fifo_write_block_dma_61568 parport_pc_fifo_write_block_dma 3 61568 NULL
121925 +fan_proc_write_61569 fan_proc_write 3 61569 NULL
121926 +ieee80211_if_read_rc_rateidx_mask_2ghz_61570 ieee80211_if_read_rc_rateidx_mask_2ghz 3 61570 NULL
121927 +ldlm_pool_rw_atomic_seq_write_61572 ldlm_pool_rw_atomic_seq_write 3 61572 NULL
121928 +seq_open_private_61589 seq_open_private 3 61589 NULL
121929 +ept_gpte_to_gfn_lvl_61591 ept_gpte_to_gfn_lvl 0-2-1 61591 NULL
121930 +netlink_recvmsg_61600 netlink_recvmsg 4 61600 NULL
121931 +nfs4_init_uniform_client_string_61601 nfs4_init_uniform_client_string 3 61601 NULL nohasharray
121932 +cx2341x_handler_init_61601 cx2341x_handler_init 0 61601 &nfs4_init_uniform_client_string_61601
121933 +configfs_write_file_61621 configfs_write_file 3 61621 NULL
121934 +ieee80211_if_fmt_hw_queues_61629 ieee80211_if_fmt_hw_queues 3 61629 NULL
121935 +i2o_parm_table_get_61635 i2o_parm_table_get 6 61635 NULL
121936 +snd_pcm_oss_read3_61643 snd_pcm_oss_read3 0-3 61643 NULL nohasharray
121937 +tcf_hashinfo_init_61643 tcf_hashinfo_init 2 61643 &snd_pcm_oss_read3_61643
121938 +resize_stripes_61650 resize_stripes 2 61650 NULL
121939 +ttm_page_pool_free_61661 ttm_page_pool_free 2-0 61661 NULL
121940 +pci_read_config_dword_61662 pci_read_config_dword 0 61662 NULL
121941 +insert_one_name_61668 insert_one_name 7 61668 NULL
121942 +snd_pcm_playback_avail_61671 snd_pcm_playback_avail 0 61671 NULL
121943 +qib_format_hwmsg_61679 qib_format_hwmsg 2 61679 NULL
121944 +lock_loop_61681 lock_loop 1 61681 NULL
121945 +__do_tune_cpucache_61684 __do_tune_cpucache 2 61684 NULL
121946 +ipr_request_other_msi_irqs_61689 ipr_request_other_msi_irqs 0 61689 NULL
121947 +filter_read_61692 filter_read 3 61692 NULL
121948 +prog_page_61711 prog_page 2 61711 NULL
121949 +iov_length_61716 iov_length 0 61716 NULL
121950 +fragmentation_threshold_read_61718 fragmentation_threshold_read 3 61718 NULL
121951 +null_alloc_reqbuf_61719 null_alloc_reqbuf 3 61719 NULL
121952 +asd_register_sas_ha_61730 asd_register_sas_ha 0 61730 NULL
121953 +read_file_interrupt_61742 read_file_interrupt 3 61742 NULL nohasharray
121954 +read_file_regval_61742 read_file_regval 3 61742 &read_file_interrupt_61742
121955 +velocity_init_dma_rings_61759 velocity_init_dma_rings 0 61759 NULL
121956 +SyS_sendto_61763 SyS_sendto 6 61763 NULL
121957 +va1j5jf8007s_prepare_61764 va1j5jf8007s_prepare 0 61764 NULL
121958 +gfs2_meta_wait_61773 gfs2_meta_wait 0 61773 NULL
121959 +mthca_cmd_box_61791 mthca_cmd_box 0 61791 NULL
121960 +xfs_file_dio_aio_write_61801 xfs_file_dio_aio_write 0 61801 NULL
121961 +enic_dev_wait_61803 enic_dev_wait 0 61803 NULL
121962 +mls_compute_context_len_61812 mls_compute_context_len 0 61812 NULL
121963 +bfad_debugfs_write_regwr_61841 bfad_debugfs_write_regwr 3 61841 NULL
121964 +regcache_sync_block_61846 regcache_sync_block 5-4 61846 NULL
121965 +t4vf_sge_alloc_rxq_61850 t4vf_sge_alloc_rxq 0 61850 NULL
121966 +ath9k_hw_def_dump_eeprom_61853 ath9k_hw_def_dump_eeprom 5-4 61853 NULL
121967 +evdev_compute_buffer_size_61863 evdev_compute_buffer_size 0 61863 NULL
121968 +SYSC_lsetxattr_61869 SYSC_lsetxattr 4 61869 NULL
121969 +get_fw_name_61874 get_fw_name 3 61874 NULL
121970 +btrfs_ioctl_clone_61886 btrfs_ioctl_clone 3-4-5 61886 NULL
121971 +lprocfs_write_frac_u64_helper_61897 lprocfs_write_frac_u64_helper 2 61897 NULL
121972 +lov_mds_md_stripecnt_61899 lov_mds_md_stripecnt 0-1 61899 NULL
121973 +clear_refs_write_61904 clear_refs_write 3 61904 NULL
121974 +kernfs_name_61910 kernfs_name 3 61910 NULL
121975 +rx_filter_arp_filter_read_61914 rx_filter_arp_filter_read 3 61914 NULL
121976 +au0828_init_isoc_61917 au0828_init_isoc 3-2-4 61917 NULL
121977 +sctp_sendmsg_61919 sctp_sendmsg 4 61919 NULL nohasharray
121978 +adap_init0_config_61919 adap_init0_config 0 61919 &sctp_sendmsg_61919
121979 +ath10k_download_fw_61925 ath10k_download_fw 0 61925 NULL
121980 +ocfs2_reserve_new_metadata_blocks_61926 ocfs2_reserve_new_metadata_blocks 0 61926 NULL
121981 +be_mcc_notify_wait_61936 be_mcc_notify_wait 0 61936 NULL
121982 +edac_device_create_instance_61940 edac_device_create_instance 0 61940 NULL
121983 +SyS_kexec_load_61946 SyS_kexec_load 2 61946 NULL
121984 +il4965_ucode_rx_stats_read_61948 il4965_ucode_rx_stats_read 3 61948 NULL
121985 +rssd_disk_name_format_61952 rssd_disk_name_format 0 61952 NULL
121986 +squashfs_read_id_index_table_61961 squashfs_read_id_index_table 4 61961 NULL
121987 +fix_read_error_61965 fix_read_error 4 61965 NULL
121988 +hid_open_report_61971 hid_open_report 0 61971 NULL
121989 +ocfs2_quota_write_61972 ocfs2_quota_write 4-5 61972 NULL
121990 +fd_locked_ioctl_61978 fd_locked_ioctl 3 61978 NULL
121991 +cow_file_range_61979 cow_file_range 3 61979 NULL
121992 +set_extent_delalloc_61982 set_extent_delalloc 0 61982 NULL
121993 +dequeue_event_62000 dequeue_event 3 62000 NULL nohasharray
121994 +si470x_start_62000 si470x_start 0 62000 &dequeue_event_62000
121995 +pt1_reset_ram_62009 pt1_reset_ram 0 62009 NULL
121996 +xt_compat_match_offset_62011 xt_compat_match_offset 0 62011 NULL
121997 +SyS_setxattr_62019 SyS_setxattr 4 62019 NULL
121998 +jffs2_do_unlink_62020 jffs2_do_unlink 4 62020 NULL
121999 +SYSC_select_62024 SYSC_select 1 62024 NULL
122000 +pmcraid_build_passthrough_ioadls_62034 pmcraid_build_passthrough_ioadls 2 62034 NULL
122001 +sctp_user_addto_chunk_62047 sctp_user_addto_chunk 2-3 62047 NULL
122002 +do_pselect_62061 do_pselect 1 62061 NULL
122003 +pcpu_alloc_bootmem_62074 pcpu_alloc_bootmem 2 62074 NULL
122004 +_xfs_log_force_lsn_62083 _xfs_log_force_lsn 0 62083 NULL
122005 +fat_setattr_62084 fat_setattr 0 62084 NULL
122006 +mwifiex_pcie_create_txbd_ring_62103 mwifiex_pcie_create_txbd_ring 0 62103 NULL
122007 +jffs2_security_setxattr_62107 jffs2_security_setxattr 4 62107 NULL
122008 +pt1_do_enable_ram_62110 pt1_do_enable_ram 0 62110 NULL
122009 +btrfs_direct_IO_62114 btrfs_direct_IO 4 62114 NULL
122010 +ip_recv_error_62117 ip_recv_error 3 62117 NULL
122011 +generic_block_fiemap_62122 generic_block_fiemap 4 62122 NULL
122012 +llc_ui_header_len_62131 llc_ui_header_len 0 62131 NULL
122013 +qib_diag_write_62133 qib_diag_write 3 62133 NULL nohasharray
122014 +kobject_add_varg_62133 kobject_add_varg 0 62133 &qib_diag_write_62133
122015 +ql_status_62135 ql_status 5 62135 NULL nohasharray
122016 +device_add_attrs_62135 device_add_attrs 0 62135 &ql_status_62135
122017 +video_usercopy_62151 video_usercopy 2 62151 NULL
122018 +SyS_getxattr_62166 SyS_getxattr 4 62166 NULL
122019 +dac33_hard_power_62168 dac33_hard_power 0 62168 NULL
122020 +ipr_save_pcix_cmd_reg_62171 ipr_save_pcix_cmd_reg 0 62171 NULL
122021 +prism54_wpa_bss_ie_get_62173 prism54_wpa_bss_ie_get 0 62173 NULL
122022 +write_file_dfs_62180 write_file_dfs 3 62180 NULL
122023 +alloc_upcall_62186 alloc_upcall 2 62186 NULL
122024 +sock_kmalloc_62205 sock_kmalloc 2 62205 NULL
122025 +smk_read_syslog_62227 smk_read_syslog 3 62227 NULL
122026 +SYSC_setgroups16_62232 SYSC_setgroups16 1 62232 NULL
122027 +nfsd_read_file_62241 nfsd_read_file 6 62241 NULL
122028 +ion_handle_test_dma_62262 ion_handle_test_dma 4-5 62262 NULL
122029 +frontend_init_62272 frontend_init 0 62272 NULL
122030 +security_file_permission_62278 security_file_permission 0 62278 NULL
122031 +get_random_int_62279 get_random_int 0 62279 NULL
122032 +initialize_62283 initialize 0 62283 NULL
122033 +il_dbgfs_sram_read_62296 il_dbgfs_sram_read 3 62296 NULL
122034 +sparse_early_usemaps_alloc_pgdat_section_62304 sparse_early_usemaps_alloc_pgdat_section 2 62304 NULL
122035 +subsystem_filter_read_62310 subsystem_filter_read 3 62310 NULL
122036 +Wb35Reg_BurstWrite_62327 Wb35Reg_BurstWrite 4 62327 NULL
122037 +subseq_list_62332 subseq_list 3-0 62332 NULL
122038 +ll_statahead_max_seq_write_62333 ll_statahead_max_seq_write 3 62333 NULL
122039 +flash_write_62354 flash_write 3 62354 NULL
122040 +xfpregs_set_62363 xfpregs_set 4 62363 NULL
122041 +register_netdevice_62374 register_netdevice 0 62374 NULL
122042 +rx_rx_timeout_read_62389 rx_rx_timeout_read 3 62389 NULL
122043 +altera_irscan_62396 altera_irscan 2 62396 NULL
122044 +set_ssp_62411 set_ssp 4 62411 NULL
122045 +udf_expand_file_adinicb_62470 udf_expand_file_adinicb 0 62470 NULL
122046 +ext_rts51x_sd_execute_read_data_62501 ext_rts51x_sd_execute_read_data 9 62501 NULL
122047 +ocfs2_path_bh_journal_access_62504 ocfs2_path_bh_journal_access 0 62504 NULL
122048 +pep_sendmsg_62524 pep_sendmsg 4 62524 NULL
122049 +test_iso_queue_62534 test_iso_queue 5 62534 NULL
122050 +debugfs_read_62535 debugfs_read 3 62535 NULL
122051 +sco_sock_sendmsg_62542 sco_sock_sendmsg 4 62542 NULL
122052 +qib_refresh_qsfp_cache_62547 qib_refresh_qsfp_cache 0 62547 NULL
122053 +compute_bitstructs_62570 compute_bitstructs 0 62570 NULL
122054 +xfrm_user_policy_62573 xfrm_user_policy 4 62573 NULL
122055 +compat_SyS_rt_sigpending_62580 compat_SyS_rt_sigpending 2 62580 NULL
122056 +get_subdir_62581 get_subdir 3 62581 NULL
122057 +amradio_set_mute_62597 amradio_set_mute 0 62597 NULL
122058 +nfsd_vfs_read_62605 nfsd_vfs_read 6 62605 NULL
122059 +t4_fw_initialize_62618 t4_fw_initialize 0 62618 NULL
122060 +iommu_area_alloc_62619 iommu_area_alloc 4-7-0 62619 NULL
122061 +dut_mode_write_62630 dut_mode_write 3 62630 NULL
122062 +vfs_fsync_range_62635 vfs_fsync_range 0 62635 NULL
122063 +lpfc_sli4_queue_alloc_62646 lpfc_sli4_queue_alloc 3 62646 NULL
122064 +at86rf230_irq_polarity_62649 at86rf230_irq_polarity 0 62649 NULL
122065 +ocfs2_wait_for_mask_interruptible_62675 ocfs2_wait_for_mask_interruptible 0 62675 NULL
122066 +printer_req_alloc_62687 printer_req_alloc 2 62687 NULL
122067 +adxl34x_i2c_read_block_62691 adxl34x_i2c_read_block 3 62691 NULL
122068 +bioset_integrity_create_62708 bioset_integrity_create 2 62708 NULL
122069 +gfs2_log_write_62717 gfs2_log_write 3 62717 NULL
122070 +rdm_62719 rdm 0 62719 NULL
122071 +wiphy_verify_combinations_62738 wiphy_verify_combinations 0 62738 NULL
122072 +obd_ioctl_popdata_62741 obd_ioctl_popdata 3 62741 NULL
122073 +key_replays_read_62746 key_replays_read 3 62746 NULL
122074 +lov_verify_lmm_62747 lov_verify_lmm 2 62747 NULL
122075 +mwifiex_rdeeprom_write_62754 mwifiex_rdeeprom_write 3 62754 NULL
122076 +ax25_sendmsg_62770 ax25_sendmsg 4 62770 NULL
122077 +C_SYSC_ipc_62776 C_SYSC_ipc 3 62776 NULL
122078 +SyS_sched_getaffinity_62786 SyS_sched_getaffinity 2 62786 NULL
122079 +dm_stats_account_io_62787 dm_stats_account_io 3 62787 NULL
122080 +bma180_set_ee_writing_state_62810 bma180_set_ee_writing_state 0 62810 NULL
122081 +t4_alloc_vi_62813 t4_alloc_vi 0 62813 NULL
122082 +crypto_register_instance_62816 crypto_register_instance 0 62816 NULL
122083 +tracing_total_entries_read_62817 tracing_total_entries_read 3 62817 NULL
122084 +__rounddown_pow_of_two_62836 __rounddown_pow_of_two 0 62836 NULL
122085 +bio_get_nr_vecs_62838 bio_get_nr_vecs 0 62838 NULL nohasharray
122086 +notifier_to_errno_62838 notifier_to_errno 0-1 62838 &bio_get_nr_vecs_62838
122087 +xlog_recover_add_to_trans_62839 xlog_recover_add_to_trans 4 62839 NULL
122088 +rx_fcs_err_read_62844 rx_fcs_err_read 3 62844 NULL
122089 +read_nic_io_dword_62859 read_nic_io_dword 0 62859 NULL
122090 +l2tp_ip6_recvmsg_62874 l2tp_ip6_recvmsg 4 62874 NULL
122091 +typhoon_download_firmware_62875 typhoon_download_firmware 0 62875 NULL
122092 +xfs_rtmodify_range_62877 xfs_rtmodify_range 0 62877 NULL
122093 +aoechr_write_62883 aoechr_write 3 62883 NULL
122094 +if_spi_host_to_card_62890 if_spi_host_to_card 4 62890 NULL
122095 +ocfs2_validate_gd_parent_62905 ocfs2_validate_gd_parent 0 62905 NULL
122096 +mempool_create_slab_pool_62907 mempool_create_slab_pool 1 62907 NULL
122097 +getdqbuf_62908 getdqbuf 1 62908 NULL
122098 +ll_statahead_agl_seq_write_62928 ll_statahead_agl_seq_write 3 62928 NULL nohasharray
122099 +t4_memory_write_62928 t4_memory_write 0 62928 &ll_statahead_agl_seq_write_62928
122100 +media_device_register_entity_62935 media_device_register_entity 0 62935 NULL
122101 +pt1_enable_ram_62945 pt1_enable_ram 0 62945 NULL
122102 +agp_create_user_memory_62955 agp_create_user_memory 1 62955 NULL
122103 +mthca_init_arbel_62975 mthca_init_arbel 0 62975 NULL
122104 +kstrtoull_from_user_63026 kstrtoull_from_user 2 63026 NULL nohasharray
122105 +xfs_trans_reserve_63026 xfs_trans_reserve 0 63026 &kstrtoull_from_user_63026
122106 +__vb2_perform_fileio_63033 __vb2_perform_fileio 3 63033 NULL
122107 +pipeline_defrag_to_csum_swi_read_63037 pipeline_defrag_to_csum_swi_read 3 63037 NULL
122108 +scsi_host_alloc_63041 scsi_host_alloc 2 63041 NULL
122109 +unlink1_63059 unlink1 3 63059 NULL
122110 +xen_set_nslabs_63066 xen_set_nslabs 0 63066 NULL
122111 +iwl_dbgfs_fw_rx_stats_read_63070 iwl_dbgfs_fw_rx_stats_read 3 63070 NULL
122112 +ocfs2_decrease_refcount_63078 ocfs2_decrease_refcount 0 63078 NULL
122113 +sep_prepare_input_output_dma_table_in_dcb_63087 sep_prepare_input_output_dma_table_in_dcb 4-5 63087 NULL
122114 +__ocfs2_flush_truncate_log_63097 __ocfs2_flush_truncate_log 0 63097 NULL
122115 +iwl_dbgfs_sensitivity_read_63116 iwl_dbgfs_sensitivity_read 3 63116 NULL
122116 +ext4_chunk_trans_blocks_63123 ext4_chunk_trans_blocks 0-2 63123 NULL
122117 +bma180_set_bits_63133 bma180_set_bits 0 63133 NULL
122118 +snd_pcm_status_user_63140 snd_pcm_status_user 0 63140 NULL
122119 +tsi721_setup_mport_63156 tsi721_setup_mport 0 63156 NULL
122120 +ubifs_change_one_lp_63157 ubifs_change_one_lp 0 63157 NULL
122121 +dma_set_mask_63172 dma_set_mask 0 63172 NULL
122122 +smk_write_revoke_subj_63173 smk_write_revoke_subj 3 63173 NULL
122123 +SyS_syslog_63178 SyS_syslog 3 63178 NULL
122124 +vme_master_read_63221 vme_master_read 0 63221 NULL
122125 +SyS_gethostname_63227 SyS_gethostname 2 63227 NULL
122126 +mwl8k_cmd_get_hw_spec_ap_63234 mwl8k_cmd_get_hw_spec_ap 0 63234 NULL
122127 +ptp_read_63251 ptp_read 4 63251 NULL
122128 +ipr_set_pcix_cmd_reg_63253 ipr_set_pcix_cmd_reg 0 63253 NULL
122129 +xfs_dir2_leaf_getdents_63262 xfs_dir2_leaf_getdents 3 63262 NULL
122130 +iwl_dbgfs_fw_error_dump_read_63263 iwl_dbgfs_fw_error_dump_read 3 63263 NULL
122131 +asd_init_sw_63305 asd_init_sw 0 63305 NULL
122132 +raid5_resize_63306 raid5_resize 2 63306 NULL
122133 +ath10k_read_fw_dbglog_63323 ath10k_read_fw_dbglog 3 63323 NULL
122134 +recv_data_63327 recv_data 3 63327 NULL
122135 +i2c_dw_init_63329 i2c_dw_init 0 63329 NULL
122136 +proc_info_read_63344 proc_info_read 3 63344 NULL
122137 +__at86rf230_write_63356 __at86rf230_write 0 63356 NULL
122138 +ps_upsd_max_sptime_read_63362 ps_upsd_max_sptime_read 3 63362 NULL
122139 +idmouse_read_63374 idmouse_read 3 63374 NULL
122140 +usbnet_read_cmd_nopm_63388 usbnet_read_cmd_nopm 7 63388 NULL nohasharray
122141 +edac_pci_alloc_ctl_info_63388 edac_pci_alloc_ctl_info 1 63388 &usbnet_read_cmd_nopm_63388
122142 +rxpipe_missed_beacon_host_int_trig_rx_data_read_63405 rxpipe_missed_beacon_host_int_trig_rx_data_read 3 63405 NULL
122143 +nouveau_event_create_63411 nouveau_event_create 1 63411 NULL
122144 +carm_init_host_63412 carm_init_host 0 63412 NULL
122145 +l2cap_sock_sendmsg_63427 l2cap_sock_sendmsg 4 63427 NULL
122146 +pcie_capability_read_word_63429 pcie_capability_read_word 0 63429 NULL
122147 +upload_dsp_code_63437 upload_dsp_code 0 63437 NULL
122148 +nfsd_symlink_63442 nfsd_symlink 6 63442 NULL
122149 +of_irq_get_63443 of_irq_get 0 63443 NULL
122150 +ath10k_wmi_cmd_send_63462 ath10k_wmi_cmd_send 0 63462 NULL
122151 +si5351_bulk_write_63468 si5351_bulk_write 2-3 63468 NULL
122152 +snd_info_entry_write_63474 snd_info_entry_write 3 63474 NULL
122153 +do_work_63483 do_work 0 63483 NULL
122154 +reada_find_extent_63486 reada_find_extent 2 63486 NULL
122155 +read_kcore_63488 read_kcore 3 63488 NULL
122156 +iwl_dbgfs_bcast_filters_read_63489 iwl_dbgfs_bcast_filters_read 3 63489 NULL
122157 +dwapb_gpio_to_irq_63493 dwapb_gpio_to_irq 2 63493 NULL
122158 +snd_pcm_plug_write_transfer_63503 snd_pcm_plug_write_transfer 0-3 63503 NULL
122159 +migrate_pages_63525 migrate_pages 0 63525 NULL
122160 +efx_mcdi_rpc_async_63529 efx_mcdi_rpc_async 4-5 63529 NULL
122161 +ubi_more_leb_change_data_63534 ubi_more_leb_change_data 4 63534 NULL nohasharray
122162 +generic_cont_expand_simple_63534 generic_cont_expand_simple 0 63534 &ubi_more_leb_change_data_63534
122163 +write_file_spectral_period_63536 write_file_spectral_period 3 63536 NULL
122164 +if_sdio_read_scratch_63540 if_sdio_read_scratch 0 63540 NULL
122165 +append_to_buffer_63550 append_to_buffer 3 63550 NULL
122166 +kvm_write_guest_page_63555 kvm_write_guest_page 5 63555 NULL
122167 +request_dma_63556 request_dma 0 63556 NULL
122168 +cy_init_card_63567 cy_init_card 0 63567 NULL
122169 +rproc_alloc_63577 rproc_alloc 5 63577 NULL
122170 +mod_timer_63594 mod_timer 0 63594 NULL
122171 +write_debug_level_63613 write_debug_level 3 63613 NULL
122172 +__spi_validate_63618 __spi_validate 0 63618 NULL
122173 +symbol_build_supp_rates_63634 symbol_build_supp_rates 0 63634 NULL
122174 +hid_report_len_63637 hid_report_len 0 63637 NULL
122175 +proc_loginuid_write_63648 proc_loginuid_write 3 63648 NULL
122176 +ValidateDSDParamsChecksum_63654 ValidateDSDParamsChecksum 3 63654 NULL
122177 +pci_save_pcie_state_63656 pci_save_pcie_state 0 63656 NULL
122178 +ldlm_cli_enqueue_63657 ldlm_cli_enqueue 8 63657 NULL
122179 +hidraw_ioctl_63658 hidraw_ioctl 2 63658 NULL
122180 +vbi_read_63673 vbi_read 3 63673 NULL
122181 +write_file_spectral_fft_period_63696 write_file_spectral_fft_period 3 63696 NULL
122182 +spi_start_queue_63711 spi_start_queue 0 63711 NULL
122183 +ocfs2_et_root_journal_access_63713 ocfs2_et_root_journal_access 0 63713 NULL
122184 +nouveau_object_create__63715 nouveau_object_create_ 5-0 63715 NULL
122185 +btrfs_insert_delayed_dir_index_63720 btrfs_insert_delayed_dir_index 4 63720 NULL
122186 +sh_eth_ring_init_63735 sh_eth_ring_init 0 63735 NULL
122187 +selinux_secctx_to_secid_63744 selinux_secctx_to_secid 2 63744 NULL
122188 +snd_pcm_oss_read1_63771 snd_pcm_oss_read1 3 63771 NULL
122189 +snd_pcm_link_63772 snd_pcm_link 0 63772 NULL
122190 +snd_opl4_mem_proc_read_63774 snd_opl4_mem_proc_read 5 63774 NULL
122191 +spidev_compat_ioctl_63778 spidev_compat_ioctl 2 63778 NULL
122192 +mwifiex_11n_create_rx_reorder_tbl_63806 mwifiex_11n_create_rx_reorder_tbl 4 63806 NULL
122193 +copy_nodes_to_user_63807 copy_nodes_to_user 2 63807 NULL
122194 +C_SYSC_process_vm_readv_63811 C_SYSC_process_vm_readv 3-5 63811 NULL
122195 +regmap_multi_reg_write_63826 regmap_multi_reg_write 3 63826 NULL nohasharray
122196 +prepare_copy_63826 prepare_copy 2 63826 &regmap_multi_reg_write_63826
122197 +sel_write_load_63830 sel_write_load 3 63830 NULL
122198 +niu_probe_ports_63833 niu_probe_ports 0 63833 NULL
122199 +dsp_full_reset_63835 dsp_full_reset 0 63835 NULL
122200 +proc_pid_attr_write_63845 proc_pid_attr_write 3 63845 NULL
122201 +rtsx_pci_send_cmd_63870 rtsx_pci_send_cmd 0 63870 NULL
122202 +at86rf230_read_subreg_63890 at86rf230_read_subreg 0 63890 NULL
122203 +ar9002_hw_rf_claim_63891 ar9002_hw_rf_claim 0 63891 NULL
122204 +xhci_alloc_stream_info_63902 xhci_alloc_stream_info 3 63902 NULL
122205 +uvc_alloc_urb_buffers_63922 uvc_alloc_urb_buffers 0-2-3 63922 NULL
122206 +snd_compr_write_63923 snd_compr_write 3 63923 NULL
122207 +afs_send_simple_reply_63940 afs_send_simple_reply 3 63940 NULL
122208 +__team_options_register_63941 __team_options_register 3 63941 NULL
122209 +sky2_init_63948 sky2_init 0 63948 NULL
122210 +macvtap_recvmsg_63949 macvtap_recvmsg 4 63949 NULL
122211 +xfs_iflush_63956 xfs_iflush 0 63956 NULL
122212 +remove_eq_ok_63958 remove_eq_ok 0 63958 NULL
122213 +set_bredr_63975 set_bredr 4 63975 NULL
122214 +construct_key_and_link_63985 construct_key_and_link 3 63985 NULL
122215 +rs_extent_to_bm_page_63996 rs_extent_to_bm_page 0-1 63996 NULL
122216 +read_file_frameerrors_64001 read_file_frameerrors 3 64001 NULL
122217 +C_SYSC_sendfile64_64017 C_SYSC_sendfile64 4 64017 NULL
122218 +SyS_rt_sigpending_64018 SyS_rt_sigpending 2 64018 NULL
122219 +dbAllocDmapLev_64030 dbAllocDmapLev 0 64030 NULL
122220 +r6040_alloc_rxbufs_64037 r6040_alloc_rxbufs 0 64037 NULL
122221 +SyS_fsetxattr_64039 SyS_fsetxattr 4 64039 NULL
122222 +power_supply_create_bat_triggers_64046 power_supply_create_bat_triggers 0 64046 NULL
122223 +get_u8_64076 get_u8 0 64076 NULL
122224 +xilly_malloc_64077 xilly_malloc 2 64077 NULL
122225 +sl_realloc_bufs_64086 sl_realloc_bufs 2 64086 NULL
122226 +vmci_handle_arr_get_size_64088 vmci_handle_arr_get_size 0 64088 NULL
122227 +lbs_highrssi_read_64089 lbs_highrssi_read 3 64089 NULL
122228 +SyS_set_mempolicy_64096 SyS_set_mempolicy 3 64096 NULL nohasharray
122229 +gfs2_inplace_reserve_64096 gfs2_inplace_reserve 0 64096 &SyS_set_mempolicy_64096
122230 +to_bytes_64103 to_bytes 0-1 64103 NULL
122231 +SyS_mq_timedsend_64107 SyS_mq_timedsend 3 64107 NULL
122232 +rdma_addr_size_64116 rdma_addr_size 0 64116 NULL
122233 +wpan_phy_register_64117 wpan_phy_register 0 64117 NULL nohasharray
122234 +associate_dev_64117 associate_dev 0 64117 &wpan_phy_register_64117
122235 +do_load_xattr_datum_64118 do_load_xattr_datum 0 64118 NULL
122236 +bypass_wd_write_64120 bypass_wd_write 3 64120 NULL
122237 +ext4_prepare_inline_data_64124 ext4_prepare_inline_data 3 64124 NULL
122238 +init_bch_64130 init_bch 1-2 64130 NULL
122239 +ablkcipher_copy_iv_64140 ablkcipher_copy_iv 3 64140 NULL
122240 +dlfb_ops_write_64150 dlfb_ops_write 3 64150 NULL
122241 +snd_card_saa7134_new_mixer_64152 snd_card_saa7134_new_mixer 0 64152 NULL
122242 +bnx2x_vf_mcast_64166 bnx2x_vf_mcast 4 64166 NULL
122243 +register_inet6addr_notifier_64167 register_inet6addr_notifier 0 64167 NULL
122244 +cpumask_scnprintf_64170 cpumask_scnprintf 0-2 64170 NULL
122245 +ocfs2_reserve_blocks_for_rec_trunc_64206 ocfs2_reserve_blocks_for_rec_trunc 0 64206 NULL
122246 +kernfs_iop_setxattr_64220 kernfs_iop_setxattr 4 64220 NULL
122247 +xfs_vm_direct_IO_64223 xfs_vm_direct_IO 4 64223 NULL
122248 +read_pulse_64227 read_pulse 0-3 64227 NULL
122249 +ea_len_64229 ea_len 0 64229 NULL
122250 +xfs_rtmodify_summary_64265 xfs_rtmodify_summary 0 64265 NULL
122251 +io_capture_transfer_64276 io_capture_transfer 4 64276 NULL
122252 +btrfs_file_extent_offset_64278 btrfs_file_extent_offset 0 64278 NULL
122253 +sta_current_tx_rate_read_64286 sta_current_tx_rate_read 3 64286 NULL
122254 +xfs_dir_cilookup_result_64288 xfs_dir_cilookup_result 3-0 64288 NULL nohasharray
122255 +event_id_read_64288 event_id_read 3 64288 &xfs_dir_cilookup_result_64288
122256 +solo_p2m_init_64291 solo_p2m_init 0 64291 NULL
122257 +snd_es1688_init_64295 snd_es1688_init 0 64295 NULL
122258 +ocfs2_block_check_validate_bhs_64302 ocfs2_block_check_validate_bhs 0 64302 NULL
122259 +snd_hda_get_sub_nodes_64304 snd_hda_get_sub_nodes 0 64304 NULL
122260 +error_error_bar_retry_read_64305 error_error_bar_retry_read 3 64305 NULL
122261 +irq_create_of_mapping_64324 irq_create_of_mapping 0 64324 NULL
122262 +sisusbcon_clear_64329 sisusbcon_clear 4-3-5 64329 NULL
122263 +ts_write_64336 ts_write 3 64336 NULL
122264 +usbtmc_write_64340 usbtmc_write 3 64340 NULL
122265 +ath10k_htt_htc_attach_64341 ath10k_htt_htc_attach 0 64341 NULL
122266 +qlcnic_82xx_calculate_msix_vector_64354 qlcnic_82xx_calculate_msix_vector 0 64354 NULL
122267 +user_regset_copyin_64360 user_regset_copyin 7 64360 NULL
122268 +wlc_phy_loadsampletable_nphy_64367 wlc_phy_loadsampletable_nphy 3 64367 NULL
122269 +reg_create_64372 reg_create 5 64372 NULL nohasharray
122270 +bnx2_enable_msix_64372 bnx2_enable_msix 2 64372 &reg_create_64372
122271 +ilo_write_64378 ilo_write 3 64378 NULL
122272 +btrfs_map_block_64379 btrfs_map_block 3 64379 NULL
122273 +vmcs_readl_64381 vmcs_readl 0 64381 NULL
122274 +nilfs_alloc_seg_bio_64383 nilfs_alloc_seg_bio 3 64383 NULL
122275 +ir_lirc_transmit_ir_64403 ir_lirc_transmit_ir 3 64403 NULL nohasharray
122276 +pcim_enable_device_64403 pcim_enable_device 0 64403 &ir_lirc_transmit_ir_64403 nohasharray
122277 +pci_bus_write_config_dword_64403 pci_bus_write_config_dword 0 64403 &pcim_enable_device_64403
122278 +pidlist_allocate_64404 pidlist_allocate 1 64404 NULL
122279 +rx_hdr_overflow_read_64407 rx_hdr_overflow_read 3 64407 NULL
122280 +keyctl_get_security_64418 keyctl_get_security 3 64418 NULL
122281 +oom_adj_write_64428 oom_adj_write 3 64428 NULL
122282 +read_file_spectral_short_repeat_64431 read_file_spectral_short_repeat 3 64431 NULL
122283 +t4_read_flash_64432 t4_read_flash 0 64432 NULL
122284 +ax25_recvmsg_64441 ax25_recvmsg 4 64441 NULL
122285 +__i2c_add_numbered_adapter_64445 __i2c_add_numbered_adapter 0 64445 NULL
122286 +stmmac_init_phy_64449 stmmac_init_phy 0 64449 NULL
122287 +single_open_size_64483 single_open_size 4 64483 NULL
122288 +p54_parse_rssical_64493 p54_parse_rssical 3-0 64493 NULL nohasharray
122289 +xfs_inode_ag_walk_64493 xfs_inode_ag_walk 0 64493 &p54_parse_rssical_64493
122290 +msg_data_sz_64503 msg_data_sz 0 64503 NULL
122291 +remove_uuid_64505 remove_uuid 4 64505 NULL
122292 +opera1_usb_i2c_msgxfer_64521 opera1_usb_i2c_msgxfer 4 64521 NULL
122293 +iwl_dbgfs_ucode_tracing_write_64524 iwl_dbgfs_ucode_tracing_write 3 64524 NULL
122294 +ses_send_diag_64527 ses_send_diag 4 64527 NULL
122295 +prctl_set_mm_64538 prctl_set_mm 3 64538 NULL
122296 +SyS_bind_64544 SyS_bind 3 64544 NULL
122297 +lm8323_read_64547 lm8323_read 4 64547 NULL
122298 +rbd_obj_read_sync_64554 rbd_obj_read_sync 3-4 64554 NULL
122299 +__btrfs_prealloc_file_range_64557 __btrfs_prealloc_file_range 3 64557 NULL
122300 +__spi_sync_64561 __spi_sync 0 64561 NULL nohasharray
122301 +ll_max_rw_chunk_seq_write_64561 ll_max_rw_chunk_seq_write 3 64561 &__spi_sync_64561
122302 +__apei_exec_run_64563 __apei_exec_run 0 64563 NULL
122303 +kstrtoul_from_user_64569 kstrtoul_from_user 2 64569 NULL
122304 +do_erase_64574 do_erase 4 64574 NULL
122305 +ioat_dma_setup_interrupts_64587 ioat_dma_setup_interrupts 0 64587 NULL
122306 +vb2_queue_init_64607 vb2_queue_init 0 64607 NULL
122307 +pcmcia_request_irq_64617 pcmcia_request_irq 0 64617 NULL
122308 +fanotify_write_64623 fanotify_write 3 64623 NULL
122309 +ocfs2_remove_refcount_extent_64631 ocfs2_remove_refcount_extent 0 64631 NULL
122310 +_iwl_dbgfs_d0i3_refs_write_64642 _iwl_dbgfs_d0i3_refs_write 3 64642 NULL nohasharray
122311 +bus_create_file_64642 bus_create_file 0 64642 &_iwl_dbgfs_d0i3_refs_write_64642
122312 +regmap_read_debugfs_64658 regmap_read_debugfs 5 64658 NULL
122313 +ocfs2_read_xattr_block_64661 ocfs2_read_xattr_block 0 64661 NULL nohasharray
122314 +tlbflush_read_file_64661 tlbflush_read_file 3 64661 &ocfs2_read_xattr_block_64661
122315 +efx_tsoh_get_buffer_64664 efx_tsoh_get_buffer 3 64664 NULL
122316 +rx_rx_out_of_mpdu_nodes_read_64668 rx_rx_out_of_mpdu_nodes_read 3 64668 NULL
122317 +nr_free_zone_pages_64680 nr_free_zone_pages 0 64680 NULL
122318 +snd_pcm_oss_capture_position_fixup_64713 snd_pcm_oss_capture_position_fixup 0 64713 NULL
122319 +dapm_bias_read_file_64715 dapm_bias_read_file 3 64715 NULL
122320 +atomic_add_return_64720 atomic_add_return 0-1 64720 NULL
122321 +i2400m_msg_to_dev_64722 i2400m_msg_to_dev 3 64722 NULL
122322 +AscGetChipVersion_64737 AscGetChipVersion 0 64737 NULL
122323 +squashfs_read_inode_lookup_table_64739 squashfs_read_inode_lookup_table 4 64739 NULL
122324 +bio_map_kern_64751 bio_map_kern 3 64751 NULL
122325 +rt2x00debug_write_csr_64753 rt2x00debug_write_csr 3 64753 NULL
122326 +message_for_md_64777 message_for_md 5 64777 NULL
122327 +isr_low_rssi_read_64789 isr_low_rssi_read 3 64789 NULL
122328 +i40e_vsi_request_irq_msix_64791 i40e_vsi_request_irq_msix 0 64791 NULL
122329 +regmap_reg_ranges_read_file_64798 regmap_reg_ranges_read_file 3 64798 NULL
122330 +nfsctl_transaction_write_64800 nfsctl_transaction_write 3 64800 NULL
122331 +rfkill_fop_write_64808 rfkill_fop_write 3 64808 NULL
122332 +proc_projid_map_write_64810 proc_projid_map_write 3 64810 NULL
122333 +megaraid_change_queue_depth_64815 megaraid_change_queue_depth 2 64815 NULL
122334 +ecryptfs_send_miscdev_64816 ecryptfs_send_miscdev 2 64816 NULL
122335 +do_kimage_alloc_64827 do_kimage_alloc 3 64827 NULL
122336 +em28xx_read_reg_64839 em28xx_read_reg 0 64839 NULL
122337 +altera_set_dr_pre_64862 altera_set_dr_pre 2 64862 NULL
122338 +pci_vc_do_save_buffer_64876 pci_vc_do_save_buffer 0 64876 NULL
122339 +lprocfs_write_u64_helper_64880 lprocfs_write_u64_helper 2 64880 NULL
122340 +xfs_imap_lookup_64906 xfs_imap_lookup 0 64906 NULL
122341 +ieee80211_if_read_ave_beacon_64924 ieee80211_if_read_ave_beacon 3 64924 NULL nohasharray
122342 +get_transport_64924 get_transport 0 64924 &ieee80211_if_read_ave_beacon_64924
122343 +ql_wait_cfg_64933 ql_wait_cfg 0 64933 NULL
122344 +ip_options_get_from_user_64958 ip_options_get_from_user 4 64958 NULL nohasharray
122345 +tipc_port_iovec_reject_64958 tipc_port_iovec_reject 4 64958 &ip_options_get_from_user_64958
122346 +traceprobe_probes_write_64969 traceprobe_probes_write 3 64969 NULL
122347 +suspend_dtim_interval_read_64971 suspend_dtim_interval_read 3 64971 NULL
122348 +crypto_ahash_digestsize_65014 crypto_ahash_digestsize 0 65014 NULL
122349 +bma180_chip_init_65032 bma180_chip_init 0 65032 NULL
122350 +insert_dent_65034 insert_dent 7 65034 NULL
122351 +snd_hda_get_pin_label_65035 snd_hda_get_pin_label 5 65035 NULL
122352 +pci_enable_msi_range_65043 pci_enable_msi_range 0-3 65043 NULL
122353 +gfs2_dir_mvino_65046 gfs2_dir_mvino 0 65046 NULL
122354 +ext4_ind_trans_blocks_65053 ext4_ind_trans_blocks 0-2 65053 NULL nohasharray
122355 +v4l2_ctrl_handler_init_class_65053 v4l2_ctrl_handler_init_class 0 65053 &ext4_ind_trans_blocks_65053
122356 +pcibios_enable_device_65059 pcibios_enable_device 0 65059 NULL
122357 +make_idx_node_65068 make_idx_node 0 65068 NULL
122358 +fw_write_65069 fw_write 3 65069 NULL
122359 +__alloc_bootmem_node_high_65076 __alloc_bootmem_node_high 2 65076 NULL
122360 +batadv_socket_write_65083 batadv_socket_write 3 65083 NULL
122361 +ocfs2_truncate_cluster_pages_65086 ocfs2_truncate_cluster_pages 2 65086 NULL
122362 +ath9k_dump_mci_btcoex_65090 ath9k_dump_mci_btcoex 3-0 65090 NULL
122363 +scsi_add_host_with_dma_65093 scsi_add_host_with_dma 0 65093 NULL
122364 +generic_ocp_write_65107 generic_ocp_write 4 65107 NULL
122365 +__xfs_bmapi_allocate_65142 __xfs_bmapi_allocate 0 65142 NULL
122366 +i2c_smbus_xfer_emulated_65183 i2c_smbus_xfer_emulated 0 65183 NULL
122367 +lbs_update_hw_spec_65208 lbs_update_hw_spec 0 65208 NULL
122368 +remove_cq_ok_65214 remove_cq_ok 0 65214 NULL
122369 +rx_rx_done_read_65217 rx_rx_done_read 3 65217 NULL
122370 +print_endpoint_stat_65232 print_endpoint_stat 3-4-0 65232 NULL
122371 +tg3_phydsp_write_65240 tg3_phydsp_write 0 65240 NULL
122372 +whci_n_caps_65247 whci_n_caps 0 65247 NULL
122373 +handler_new_ref_65275 handler_new_ref 0 65275 NULL
122374 +kmalloc_parameter_65279 kmalloc_parameter 1 65279 NULL
122375 +xfs_btree_check_ptr_65281 xfs_btree_check_ptr 0 65281 NULL
122376 +sas_register_ha_65282 sas_register_ha 0 65282 NULL
122377 +pccard_get_next_tuple_65284 pccard_get_next_tuple 0 65284 NULL
122378 +compat_core_sys_select_65285 compat_core_sys_select 1 65285 NULL
122379 +mpi_set_buffer_65294 mpi_set_buffer 3 65294 NULL
122380 +redirected_tty_write_65297 redirected_tty_write 3 65297 NULL
122381 +t4_prep_adapter_65299 t4_prep_adapter 0 65299 NULL
122382 +get_var_len_65304 get_var_len 0 65304 NULL
122383 +unpack_array_65318 unpack_array 0 65318 NULL
122384 +fnic_wq_alloc_65321 fnic_wq_alloc 0 65321 NULL
122385 +pci_vpd_find_tag_65325 pci_vpd_find_tag 0-2 65325 NULL
122386 +dccp_setsockopt_service_65336 dccp_setsockopt_service 4 65336 NULL
122387 +dma_rx_requested_read_65354 dma_rx_requested_read 3 65354 NULL nohasharray
122388 +vnic_wq_copy_alloc_65354 vnic_wq_copy_alloc 0 65354 &dma_rx_requested_read_65354
122389 +sxgbe_init_dma_engine_65358 sxgbe_init_dma_engine 0 65358 NULL
122390 +alloc_cpu_rmap_65363 alloc_cpu_rmap 1 65363 NULL
122391 +SyS_writev_65372 SyS_writev 3 65372 NULL
122392 +ath10k_htt_attach_65388 ath10k_htt_attach 0 65388 NULL
122393 +__alloc_bootmem_nopanic_65397 __alloc_bootmem_nopanic 1 65397 NULL
122394 +trace_seq_to_user_65398 trace_seq_to_user 3 65398 NULL
122395 +__read_vmcore_65402 __read_vmcore 2 65402 NULL
122396 +usb_ep_enable_65405 usb_ep_enable 0 65405 NULL
122397 +iio_device_add_channel_sysfs_65406 iio_device_add_channel_sysfs 0 65406 NULL
122398 +ocfs2_write_begin_nolock_65410 ocfs2_write_begin_nolock 3-4 65410 NULL
122399 +device_add_groups_65423 device_add_groups 0 65423 NULL
122400 +__at86rf230_detect_device_65427 __at86rf230_detect_device 0 65427 NULL
122401 +xpc_kzalloc_cacheline_aligned_65433 xpc_kzalloc_cacheline_aligned 1 65433 NULL
122402 +usb_alloc_coherent_65444 usb_alloc_coherent 2 65444 NULL
122403 +mlx4_comm_cmd_poll_65445 mlx4_comm_cmd_poll 0 65445 NULL
122404 +sky2_test_msi_65453 sky2_test_msi 0 65453 NULL
122405 +il_dbgfs_wd_timeout_write_65464 il_dbgfs_wd_timeout_write 3 65464 NULL
122406 +clear_user_65470 clear_user 2 65470 NULL
122407 +xfs_alloc_lookup_ge_65481 xfs_alloc_lookup_ge 0 65481 NULL
122408 +ath_rx_edma_init_65483 ath_rx_edma_init 0 65483 NULL
122409 +dpcm_state_read_file_65489 dpcm_state_read_file 3 65489 NULL
122410 +lookup_inline_extent_backref_65493 lookup_inline_extent_backref 9 65493 NULL
122411 +nvme_trans_standard_inquiry_page_65526 nvme_trans_standard_inquiry_page 4 65526 NULL
122412 +tree_mod_log_eb_copy_65535 tree_mod_log_eb_copy 6 65535 NULL
122413 diff --git a/tools/gcc/size_overflow_plugin/size_overflow_hash_aux.data b/tools/gcc/size_overflow_plugin/size_overflow_hash_aux.data
122414 new file mode 100644
122415 index 0000000..560cd7b
122416 --- /dev/null
122417 +++ b/tools/gcc/size_overflow_plugin/size_overflow_hash_aux.data
122418 @@ -0,0 +1,92 @@
122419 +spa_set_aux_vdevs_746 spa_set_aux_vdevs 3 746 NULL
122420 +zfs_lookup_2144 zfs_lookup 0 2144 NULL
122421 +mappedread_2627 mappedread 2 2627 NULL
122422 +vdev_disk_dio_alloc_2957 vdev_disk_dio_alloc 1 2957 NULL
122423 +nv_alloc_pushpage_spl_4286 nv_alloc_pushpage_spl 2 4286 NULL
122424 +zpl_xattr_get_4574 zpl_xattr_get 0 4574 NULL
122425 +sa_replace_all_by_template_5699 sa_replace_all_by_template 3 5699 NULL
122426 +dmu_write_6048 dmu_write 4-3 6048 NULL
122427 +dmu_buf_hold_array_6095 dmu_buf_hold_array 4-3 6095 NULL
122428 +update_pages_6225 update_pages 2-3 6225 NULL
122429 +bio_nr_pages_7117 bio_nr_pages 0-2 7117 NULL
122430 +dmu_buf_hold_array_by_bonus_8562 dmu_buf_hold_array_by_bonus 3-2 8562 NULL
122431 +zpios_dmu_write_8858 zpios_dmu_write 4-5 8858 NULL
122432 +ddi_copyout_9401 ddi_copyout 3 9401 NULL
122433 +avl_numnodes_12384 avl_numnodes 0 12384 NULL
122434 +dmu_write_uio_dnode_12473 dmu_write_uio_dnode 3 12473 NULL
122435 +dmu_xuio_init_12866 dmu_xuio_init 2 12866 NULL
122436 +zpl_read_common_14389 zpl_read_common 0 14389 NULL
122437 +dmu_snapshot_realname_14632 dmu_snapshot_realname 4 14632 NULL
122438 +kmem_alloc_debug_14852 kmem_alloc_debug 1 14852 NULL
122439 +kmalloc_node_nofail_15151 kmalloc_node_nofail 1 15151 NULL
122440 +dmu_write_uio_16351 dmu_write_uio 4 16351 NULL
122441 +zfs_log_write_16524 zfs_log_write 6-5 16524 NULL
122442 +sa_build_layouts_16910 sa_build_layouts 3 16910 NULL
122443 +dsl_dir_namelen_17053 dsl_dir_namelen 0 17053 NULL
122444 +kcopy_copy_to_user_17336 kcopy_copy_to_user 5 17336 NULL
122445 +sa_add_layout_entry_17507 sa_add_layout_entry 3 17507 NULL
122446 +sa_attr_table_setup_18029 sa_attr_table_setup 3 18029 NULL
122447 +uiocopy_18680 uiocopy 2 18680 NULL
122448 +dmu_buf_hold_array_by_dnode_19125 dmu_buf_hold_array_by_dnode 2-3 19125 NULL
122449 +zpl_acl_from_xattr_21141 zpl_acl_from_xattr 2 21141 NULL
122450 +dsl_pool_tx_assign_init_22518 dsl_pool_tx_assign_init 2 22518 NULL
122451 +nvlist_lookup_byte_array_22527 nvlist_lookup_byte_array 0 22527 NULL
122452 +sa_replace_all_by_template_locked_22533 sa_replace_all_by_template_locked 3 22533 NULL
122453 +tsd_hash_table_init_22559 tsd_hash_table_init 1 22559 NULL
122454 +spa_vdev_remove_aux_23966 spa_vdev_remove_aux 4 23966 NULL
122455 +zpl_xattr_acl_set_access_24129 zpl_xattr_acl_set_access 4 24129 NULL
122456 +dmu_assign_arcbuf_24622 dmu_assign_arcbuf 2 24622 NULL
122457 +zap_lookup_norm_25166 zap_lookup_norm 9 25166 NULL
122458 +dmu_prealloc_25456 dmu_prealloc 4-3 25456 NULL
122459 +kmalloc_nofail_26347 kmalloc_nofail 1 26347 NULL
122460 +zfsctl_snapshot_zpath_27578 zfsctl_snapshot_zpath 2 27578 NULL
122461 +zpios_dmu_read_30015 zpios_dmu_read 4-5 30015 NULL
122462 +splat_write_30943 splat_write 3 30943 NULL
122463 +zpl_xattr_get_sa_31183 zpl_xattr_get_sa 0 31183 NULL
122464 +dmu_read_uio_31467 dmu_read_uio 4 31467 NULL
122465 +zfs_replay_fuids_31479 zfs_replay_fuids 4 31479 NULL
122466 +spa_history_log_to_phys_31632 spa_history_log_to_phys 0-1 31632 NULL
122467 +__zpl_xattr_get_32601 __zpl_xattr_get 0 32601 NULL
122468 +proc_copyout_string_34049 proc_copyout_string 2 34049 NULL
122469 +nv_alloc_sleep_spl_34544 nv_alloc_sleep_spl 2 34544 NULL
122470 +nv_alloc_nosleep_spl_34761 nv_alloc_nosleep_spl 2 34761 NULL
122471 +zap_leaf_array_match_36922 zap_leaf_array_match 4 36922 NULL
122472 +copyinstr_36980 copyinstr 3 36980 NULL
122473 +zpl_xattr_acl_set_default_37864 zpl_xattr_acl_set_default 4 37864 NULL
122474 +splat_read_38116 splat_read 3 38116 NULL
122475 +sa_setup_38756 sa_setup 4 38756 NULL
122476 +vdev_disk_physio_39898 vdev_disk_physio 3 39898 NULL
122477 +arc_buf_size_39982 arc_buf_size 0 39982 NULL
122478 +kzalloc_nofail_40719 kzalloc_nofail 1 40719 NULL
122479 +fuidstr_to_sid_40777 fuidstr_to_sid 4 40777 NULL
122480 +vdev_raidz_matrix_reconstruct_40852 vdev_raidz_matrix_reconstruct 2-3 40852 NULL
122481 +sa_find_layout_40892 sa_find_layout 4 40892 NULL
122482 +zpl_xattr_get_dir_41918 zpl_xattr_get_dir 0 41918 NULL
122483 +zfs_sa_get_xattr_42600 zfs_sa_get_xattr 0 42600 NULL
122484 +zpl_xattr_acl_set_42808 zpl_xattr_acl_set 4 42808 NULL
122485 +xdr_dec_array_43091 xdr_dec_array 5 43091 NULL
122486 +dsl_dataset_namelen_43136 dsl_dataset_namelen 0 43136 NULL
122487 +kcopy_write_43683 kcopy_write 3 43683 NULL
122488 +uiomove_44355 uiomove 2 44355 NULL
122489 +dmu_read_44418 dmu_read 4-3 44418 NULL
122490 +ddi_copyin_44846 ddi_copyin 3 44846 NULL
122491 +kcopy_do_get_45061 kcopy_do_get 5 45061 NULL
122492 +copyin_45945 copyin 3 45945 NULL
122493 +zil_itx_create_46555 zil_itx_create 2 46555 NULL
122494 +dmu_write_uio_dbuf_48064 dmu_write_uio_dbuf 3 48064 NULL
122495 +blk_rq_pos_48233 blk_rq_pos 0 48233 NULL
122496 +spa_history_write_49650 spa_history_write 3 49650 NULL
122497 +kcopy_copy_pages_to_user_49823 kcopy_copy_pages_to_user 3-4 49823 NULL
122498 +zfs_log_write_50162 zfs_log_write 6-5 50162 NULL
122499 +i_fm_alloc_51038 i_fm_alloc 2 51038 NULL
122500 +copyout_51409 copyout 3 51409 NULL
122501 +zvol_log_write_54898 zvol_log_write 4-3 54898 NULL
122502 +zfs_acl_node_alloc_55641 zfs_acl_node_alloc 1 55641 NULL
122503 +get_nvlist_56685 get_nvlist 2 56685 NULL
122504 +zprop_get_numprops_56820 zprop_get_numprops 0 56820 NULL
122505 +splat_taskq_test4_common_59829 splat_taskq_test4_common 5 59829 NULL
122506 +zfs_replay_domain_cnt_61399 zfs_replay_domain_cnt 0 61399 NULL
122507 +zpios_write_61823 zpios_write 3 61823 NULL
122508 +proc_copyin_string_62019 proc_copyin_string 4 62019 NULL
122509 +random_get_pseudo_bytes_64611 random_get_pseudo_bytes 2 64611 NULL
122510 +zpios_read_64734 zpios_read 3 64734 NULL
122511 diff --git a/tools/gcc/size_overflow_plugin/size_overflow_plugin.c b/tools/gcc/size_overflow_plugin/size_overflow_plugin.c
122512 new file mode 100644
122513 index 0000000..e6fe17b
122514 --- /dev/null
122515 +++ b/tools/gcc/size_overflow_plugin/size_overflow_plugin.c
122516 @@ -0,0 +1,259 @@
122517 +/*
122518 + * Copyright 2011-2014 by Emese Revfy <re.emese@gmail.com>
122519 + * Licensed under the GPL v2, or (at your option) v3
122520 + *
122521 + * Homepage:
122522 + * http://www.grsecurity.net/~ephox/overflow_plugin/
122523 + *
122524 + * Documentation:
122525 + * http://forums.grsecurity.net/viewtopic.php?f=7&t=3043
122526 + *
122527 + * This plugin recomputes expressions of function arguments marked by a size_overflow attribute
122528 + * with double integer precision (DImode/TImode for 32/64 bit integer types).
122529 + * The recomputed argument is checked against TYPE_MAX and an event is logged on overflow and the triggering process is killed.
122530 + *
122531 + * Usage:
122532 + * $ make
122533 + * $ make run
122534 + */
122535 +
122536 +#include "gcc-common.h"
122537 +#include "size_overflow.h"
122538 +
122539 +int plugin_is_GPL_compatible;
122540 +
122541 +tree report_size_overflow_decl;
122542 +
122543 +tree size_overflow_type_HI;
122544 +tree size_overflow_type_SI;
122545 +tree size_overflow_type_DI;
122546 +tree size_overflow_type_TI;
122547 +
122548 +static struct plugin_info size_overflow_plugin_info = {
122549 + .version = "20140517",
122550 + .help = "no-size-overflow\tturn off size overflow checking\n",
122551 +};
122552 +
122553 +static tree handle_size_overflow_attribute(tree *node, tree __unused name, tree args, int __unused flags, bool *no_add_attrs)
122554 +{
122555 + unsigned int arg_count;
122556 + enum tree_code code = TREE_CODE(*node);
122557 +
122558 + switch (code) {
122559 + case FUNCTION_DECL:
122560 + arg_count = type_num_arguments(TREE_TYPE(*node));
122561 + break;
122562 + case FUNCTION_TYPE:
122563 + case METHOD_TYPE:
122564 + arg_count = type_num_arguments(*node);
122565 + break;
122566 + default:
122567 + *no_add_attrs = true;
122568 + error("%s: %qE attribute only applies to functions", __func__, name);
122569 + return NULL_TREE;
122570 + }
122571 +
122572 + for (; args; args = TREE_CHAIN(args)) {
122573 + tree position = TREE_VALUE(args);
122574 + if (TREE_CODE(position) != INTEGER_CST || TREE_INT_CST_LOW(position) > arg_count ) {
122575 + error("%s: parameter %u is outside range.", __func__, (unsigned int)TREE_INT_CST_LOW(position));
122576 + *no_add_attrs = true;
122577 + }
122578 + }
122579 + return NULL_TREE;
122580 +}
122581 +
122582 +static tree handle_intentional_overflow_attribute(tree *node, tree __unused name, tree args, int __unused flags, bool *no_add_attrs)
122583 +{
122584 + unsigned int arg_count;
122585 + enum tree_code code = TREE_CODE(*node);
122586 +
122587 + switch (code) {
122588 + case FUNCTION_DECL:
122589 + arg_count = type_num_arguments(TREE_TYPE(*node));
122590 + break;
122591 + case FUNCTION_TYPE:
122592 + case METHOD_TYPE:
122593 + arg_count = type_num_arguments(*node);
122594 + break;
122595 + case FIELD_DECL:
122596 + return NULL_TREE;
122597 + default:
122598 + *no_add_attrs = true;
122599 + error("%qE attribute only applies to functions", name);
122600 + return NULL_TREE;
122601 + }
122602 +
122603 + if (TREE_INT_CST_HIGH(TREE_VALUE(args)) != 0)
122604 + return NULL_TREE;
122605 +
122606 + for (; args; args = TREE_CHAIN(args)) {
122607 + tree position = TREE_VALUE(args);
122608 + if (TREE_CODE(position) != INTEGER_CST || TREE_INT_CST_LOW(position) > arg_count ) {
122609 + error("%s: parameter %u is outside range.", __func__, (unsigned int)TREE_INT_CST_LOW(position));
122610 + *no_add_attrs = true;
122611 + }
122612 + }
122613 + return NULL_TREE;
122614 +}
122615 +
122616 +static struct attribute_spec size_overflow_attr = {
122617 + .name = "size_overflow",
122618 + .min_length = 1,
122619 + .max_length = -1,
122620 + .decl_required = true,
122621 + .type_required = false,
122622 + .function_type_required = false,
122623 + .handler = handle_size_overflow_attribute,
122624 +#if BUILDING_GCC_VERSION >= 4007
122625 + .affects_type_identity = false
122626 +#endif
122627 +};
122628 +
122629 +static struct attribute_spec intentional_overflow_attr = {
122630 + .name = "intentional_overflow",
122631 + .min_length = 1,
122632 + .max_length = -1,
122633 + .decl_required = true,
122634 + .type_required = false,
122635 + .function_type_required = false,
122636 + .handler = handle_intentional_overflow_attribute,
122637 +#if BUILDING_GCC_VERSION >= 4007
122638 + .affects_type_identity = false
122639 +#endif
122640 +};
122641 +
122642 +static void register_attributes(void __unused *event_data, void __unused *data)
122643 +{
122644 + register_attribute(&size_overflow_attr);
122645 + register_attribute(&intentional_overflow_attr);
122646 +}
122647 +
122648 +static tree create_typedef(tree type, const char* ident)
122649 +{
122650 + tree new_type, decl;
122651 +
122652 + new_type = build_variant_type_copy(type);
122653 + decl = build_decl(BUILTINS_LOCATION, TYPE_DECL, get_identifier(ident), new_type);
122654 + DECL_ORIGINAL_TYPE(decl) = type;
122655 + TYPE_NAME(new_type) = decl;
122656 + return new_type;
122657 +}
122658 +
122659 +// Create the noreturn report_size_overflow() function decl.
122660 +static void size_overflow_start_unit(void __unused *gcc_data, void __unused *user_data)
122661 +{
122662 + tree const_char_ptr_type_node;
122663 + tree fntype;
122664 +
122665 + const_char_ptr_type_node = build_pointer_type(build_type_variant(char_type_node, 1, 0));
122666 +
122667 + size_overflow_type_HI = create_typedef(intHI_type_node, "size_overflow_type_HI");
122668 + size_overflow_type_SI = create_typedef(intSI_type_node, "size_overflow_type_SI");
122669 + size_overflow_type_DI = create_typedef(intDI_type_node, "size_overflow_type_DI");
122670 + size_overflow_type_TI = create_typedef(intTI_type_node, "size_overflow_type_TI");
122671 +
122672 + // void report_size_overflow(const char *loc_file, unsigned int loc_line, const char *current_func, const char *ssa_var)
122673 + fntype = build_function_type_list(void_type_node,
122674 + const_char_ptr_type_node,
122675 + unsigned_type_node,
122676 + const_char_ptr_type_node,
122677 + const_char_ptr_type_node,
122678 + NULL_TREE);
122679 + report_size_overflow_decl = build_fn_decl("report_size_overflow", fntype);
122680 +
122681 + DECL_ASSEMBLER_NAME(report_size_overflow_decl);
122682 + TREE_PUBLIC(report_size_overflow_decl) = 1;
122683 + DECL_EXTERNAL(report_size_overflow_decl) = 1;
122684 + DECL_ARTIFICIAL(report_size_overflow_decl) = 1;
122685 + TREE_THIS_VOLATILE(report_size_overflow_decl) = 1;
122686 +}
122687 +
122688 +
122689 +extern struct gimple_opt_pass pass_dce;
122690 +
122691 +static struct opt_pass *make_dce_pass(void)
122692 +{
122693 +#if BUILDING_GCC_VERSION >= 4009
122694 + return make_pass_dce(g);
122695 +#else
122696 + return &pass_dce.pass;
122697 +#endif
122698 +}
122699 +
122700 +
122701 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
122702 +{
122703 + int i;
122704 + const char * const plugin_name = plugin_info->base_name;
122705 + const int argc = plugin_info->argc;
122706 + const struct plugin_argument * const argv = plugin_info->argv;
122707 + bool enable = true;
122708 + struct register_pass_info insert_size_overflow_asm_pass_info;
122709 + struct register_pass_info __unused dump_before_pass_info;
122710 + struct register_pass_info __unused dump_after_pass_info;
122711 + struct register_pass_info insert_size_overflow_check_info;
122712 + struct register_pass_info dce_pass_info;
122713 + static const struct ggc_root_tab gt_ggc_r_gt_size_overflow[] = {
122714 + {
122715 + .base = &report_size_overflow_decl,
122716 + .nelt = 1,
122717 + .stride = sizeof(report_size_overflow_decl),
122718 + .cb = &gt_ggc_mx_tree_node,
122719 + .pchw = &gt_pch_nx_tree_node
122720 + },
122721 + LAST_GGC_ROOT_TAB
122722 + };
122723 +
122724 + insert_size_overflow_asm_pass_info.pass = make_insert_size_overflow_asm_pass();
122725 + insert_size_overflow_asm_pass_info.reference_pass_name = "ssa";
122726 + insert_size_overflow_asm_pass_info.ref_pass_instance_number = 1;
122727 + insert_size_overflow_asm_pass_info.pos_op = PASS_POS_INSERT_AFTER;
122728 +
122729 + dump_before_pass_info.pass = make_dump_pass();
122730 + dump_before_pass_info.reference_pass_name = "increase_alignment";
122731 + dump_before_pass_info.ref_pass_instance_number = 1;
122732 + dump_before_pass_info.pos_op = PASS_POS_INSERT_BEFORE;
122733 +
122734 + insert_size_overflow_check_info.pass = make_insert_size_overflow_check();
122735 + insert_size_overflow_check_info.reference_pass_name = "increase_alignment";
122736 + insert_size_overflow_check_info.ref_pass_instance_number = 1;
122737 + insert_size_overflow_check_info.pos_op = PASS_POS_INSERT_BEFORE;
122738 +
122739 + dump_after_pass_info.pass = make_dump_pass();
122740 + dump_after_pass_info.reference_pass_name = "increase_alignment";
122741 + dump_after_pass_info.ref_pass_instance_number = 1;
122742 + dump_after_pass_info.pos_op = PASS_POS_INSERT_BEFORE;
122743 +
122744 + dce_pass_info.pass = make_dce_pass();
122745 + dce_pass_info.reference_pass_name = "vrp";
122746 + dce_pass_info.ref_pass_instance_number = 1;
122747 + dce_pass_info.pos_op = PASS_POS_INSERT_AFTER;
122748 +
122749 + if (!plugin_default_version_check(version, &gcc_version)) {
122750 + error(G_("incompatible gcc/plugin versions"));
122751 + return 1;
122752 + }
122753 +
122754 + for (i = 0; i < argc; ++i) {
122755 + if (!strcmp(argv[i].key, "no-size-overflow")) {
122756 + enable = false;
122757 + continue;
122758 + }
122759 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
122760 + }
122761 +
122762 + register_callback(plugin_name, PLUGIN_INFO, NULL, &size_overflow_plugin_info);
122763 + if (enable) {
122764 + register_callback(plugin_name, PLUGIN_START_UNIT, &size_overflow_start_unit, NULL);
122765 + register_callback(plugin_name, PLUGIN_REGISTER_GGC_ROOTS, NULL, (void *)&gt_ggc_r_gt_size_overflow);
122766 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &insert_size_overflow_asm_pass_info);
122767 +// register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &dump_before_pass_info);
122768 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &insert_size_overflow_check_info);
122769 +// register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &dump_after_pass_info);
122770 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &dce_pass_info);
122771 + }
122772 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
122773 +
122774 + return 0;
122775 +}
122776 diff --git a/tools/gcc/size_overflow_plugin/size_overflow_plugin_hash.c b/tools/gcc/size_overflow_plugin/size_overflow_plugin_hash.c
122777 new file mode 100644
122778 index 0000000..0888f6c
122779 --- /dev/null
122780 +++ b/tools/gcc/size_overflow_plugin/size_overflow_plugin_hash.c
122781 @@ -0,0 +1,364 @@
122782 +/*
122783 + * Copyright 2011-2014 by Emese Revfy <re.emese@gmail.com>
122784 + * Licensed under the GPL v2, or (at your option) v3
122785 + *
122786 + * Homepage:
122787 + * http://www.grsecurity.net/~ephox/overflow_plugin/
122788 + *
122789 + * Documentation:
122790 + * http://forums.grsecurity.net/viewtopic.php?f=7&t=3043
122791 + *
122792 + * This plugin recomputes expressions of function arguments marked by a size_overflow attribute
122793 + * with double integer precision (DImode/TImode for 32/64 bit integer types).
122794 + * The recomputed argument is checked against TYPE_MAX and an event is logged on overflow and the triggering process is killed.
122795 + *
122796 + * Usage:
122797 + * $ make
122798 + * $ make run
122799 + */
122800 +
122801 +#include "gcc-common.h"
122802 +#include "size_overflow.h"
122803 +
122804 +#include "size_overflow_hash.h"
122805 +#include "size_overflow_hash_aux.h"
122806 +
122807 +#define CODES_LIMIT 32
122808 +
122809 +static unsigned char get_tree_code(const_tree type)
122810 +{
122811 + switch (TREE_CODE(type)) {
122812 + case ARRAY_TYPE:
122813 + return 0;
122814 + case BOOLEAN_TYPE:
122815 + return 1;
122816 + case ENUMERAL_TYPE:
122817 + return 2;
122818 + case FUNCTION_TYPE:
122819 + return 3;
122820 + case INTEGER_TYPE:
122821 + return 4;
122822 + case POINTER_TYPE:
122823 + return 5;
122824 + case RECORD_TYPE:
122825 + return 6;
122826 + case UNION_TYPE:
122827 + return 7;
122828 + case VOID_TYPE:
122829 + return 8;
122830 + case REAL_TYPE:
122831 + return 9;
122832 + case VECTOR_TYPE:
122833 + return 10;
122834 + case REFERENCE_TYPE:
122835 + return 11;
122836 + case OFFSET_TYPE:
122837 + return 12;
122838 + case COMPLEX_TYPE:
122839 + return 13;
122840 + default:
122841 + debug_tree((tree)type);
122842 + gcc_unreachable();
122843 + }
122844 +}
122845 +
122846 +struct function_hash {
122847 + size_t tree_codes_len;
122848 + unsigned char tree_codes[CODES_LIMIT];
122849 + const_tree fndecl;
122850 + unsigned int hash;
122851 +};
122852 +
122853 +// http://www.team5150.com/~andrew/noncryptohashzoo2~/CrapWow.html
122854 +static unsigned int CrapWow(const char *key, unsigned int len, unsigned int seed)
122855 +{
122856 +#define cwfold( a, b, lo, hi ) { p = (unsigned int)(a) * (unsigned long long)(b); lo ^= (unsigned int)p; hi ^= (unsigned int)(p >> 32); }
122857 +#define cwmixa( in ) { cwfold( in, m, k, h ); }
122858 +#define cwmixb( in ) { cwfold( in, n, h, k ); }
122859 +
122860 + unsigned int m = 0x57559429;
122861 + unsigned int n = 0x5052acdb;
122862 + const unsigned int *key4 = (const unsigned int *)key;
122863 + unsigned int h = len;
122864 + unsigned int k = len + seed + n;
122865 + unsigned long long p;
122866 +
122867 + while (len >= 8) {
122868 + cwmixb(key4[0]) cwmixa(key4[1]) key4 += 2;
122869 + len -= 8;
122870 + }
122871 + if (len >= 4) {
122872 + cwmixb(key4[0]) key4 += 1;
122873 + len -= 4;
122874 + }
122875 + if (len)
122876 + cwmixa(key4[0] & ((1 << (len * 8)) - 1 ));
122877 + cwmixb(h ^ (k + n));
122878 + return k ^ h;
122879 +
122880 +#undef cwfold
122881 +#undef cwmixa
122882 +#undef cwmixb
122883 +}
122884 +
122885 +static void set_hash(const char *fn_name, struct function_hash *fn_hash_data)
122886 +{
122887 + unsigned int fn, codes, seed = 0;
122888 +
122889 + fn = CrapWow(fn_name, strlen(fn_name), seed) & 0xffff;
122890 + codes = CrapWow((const char*)fn_hash_data->tree_codes, fn_hash_data->tree_codes_len, seed) & 0xffff;
122891 +
122892 + fn_hash_data->hash = fn ^ codes;
122893 +}
122894 +
122895 +static void set_node_codes(const_tree type, struct function_hash *fn_hash_data)
122896 +{
122897 + gcc_assert(type != NULL_TREE);
122898 + gcc_assert(TREE_CODE_CLASS(TREE_CODE(type)) == tcc_type);
122899 +
122900 + while (type && fn_hash_data->tree_codes_len < CODES_LIMIT) {
122901 + fn_hash_data->tree_codes[fn_hash_data->tree_codes_len] = get_tree_code(type);
122902 + fn_hash_data->tree_codes_len++;
122903 + type = TREE_TYPE(type);
122904 + }
122905 +}
122906 +
122907 +static void set_result_codes(const_tree node, struct function_hash *fn_hash_data)
122908 +{
122909 + const_tree result;
122910 +
122911 + gcc_assert(node != NULL_TREE);
122912 +
122913 + if (DECL_P(node)) {
122914 + result = DECL_RESULT(node);
122915 + if (result != NULL_TREE)
122916 + return set_node_codes(TREE_TYPE(result), fn_hash_data);
122917 + return set_result_codes(TREE_TYPE(node), fn_hash_data);
122918 + }
122919 +
122920 + gcc_assert(TYPE_P(node));
122921 +
122922 + if (TREE_CODE(node) == FUNCTION_TYPE)
122923 + return set_result_codes(TREE_TYPE(node), fn_hash_data);
122924 +
122925 + return set_node_codes(node, fn_hash_data);
122926 +}
122927 +
122928 +static void set_function_codes(struct function_hash *fn_hash_data)
122929 +{
122930 + const_tree arg, type = TREE_TYPE(fn_hash_data->fndecl);
122931 + enum tree_code code = TREE_CODE(type);
122932 +
122933 + gcc_assert(code == FUNCTION_TYPE || code == METHOD_TYPE);
122934 +
122935 + set_result_codes(fn_hash_data->fndecl, fn_hash_data);
122936 +
122937 + for (arg = TYPE_ARG_TYPES(type); arg != NULL_TREE && fn_hash_data->tree_codes_len < CODES_LIMIT; arg = TREE_CHAIN(arg))
122938 + set_node_codes(TREE_VALUE(arg), fn_hash_data);
122939 +}
122940 +
122941 +static const struct size_overflow_hash *get_proper_hash_chain(const struct size_overflow_hash *entry, const char *func_name)
122942 +{
122943 + while (entry) {
122944 + if (!strcmp(entry->name, func_name))
122945 + return entry;
122946 + entry = entry->next;
122947 + }
122948 + return NULL;
122949 +}
122950 +
122951 +const struct size_overflow_hash *get_function_hash(const_tree fndecl)
122952 +{
122953 + const struct size_overflow_hash *entry;
122954 + struct function_hash fn_hash_data;
122955 + const char *func_name;
122956 +
122957 + // skip builtins __builtin_constant_p
122958 + if (DECL_BUILT_IN(fndecl))
122959 + return NULL;
122960 +
122961 + fn_hash_data.fndecl = fndecl;
122962 + fn_hash_data.tree_codes_len = 0;
122963 +
122964 + set_function_codes(&fn_hash_data);
122965 + gcc_assert(fn_hash_data.tree_codes_len != 0);
122966 +
122967 + func_name = DECL_NAME_POINTER(fn_hash_data.fndecl);
122968 + set_hash(func_name, &fn_hash_data);
122969 +
122970 + entry = size_overflow_hash[fn_hash_data.hash];
122971 + entry = get_proper_hash_chain(entry, func_name);
122972 + if (entry)
122973 + return entry;
122974 + entry = size_overflow_hash_aux[fn_hash_data.hash];
122975 + return get_proper_hash_chain(entry, func_name);
122976 +}
122977 +
122978 +static void print_missing_msg(const_tree func, unsigned int argnum)
122979 +{
122980 + location_t loc;
122981 + const char *curfunc;
122982 + struct function_hash fn_hash_data;
122983 +
122984 + fn_hash_data.fndecl = DECL_ORIGIN(func);
122985 + fn_hash_data.tree_codes_len = 0;
122986 +
122987 + loc = DECL_SOURCE_LOCATION(fn_hash_data.fndecl);
122988 + curfunc = DECL_NAME_POINTER(fn_hash_data.fndecl);
122989 +
122990 + set_function_codes(&fn_hash_data);
122991 + set_hash(curfunc, &fn_hash_data);
122992 +
122993 + inform(loc, "Function %s is missing from the size_overflow hash table +%s+%u+%u+", curfunc, curfunc, argnum, fn_hash_data.hash);
122994 +}
122995 +
122996 +unsigned int find_arg_number_tree(const_tree arg, const_tree func)
122997 +{
122998 + tree var;
122999 + unsigned int argnum = 1;
123000 +
123001 + if (TREE_CODE(arg) == SSA_NAME)
123002 + arg = SSA_NAME_VAR(arg);
123003 +
123004 + for (var = DECL_ARGUMENTS(func); var; var = TREE_CHAIN(var), argnum++) {
123005 + if (!operand_equal_p(arg, var, 0) && strcmp(DECL_NAME_POINTER(var), DECL_NAME_POINTER(arg)))
123006 + continue;
123007 + if (!skip_types(var))
123008 + return argnum;
123009 + }
123010 +
123011 + return CANNOT_FIND_ARG;
123012 +}
123013 +
123014 +static const char *get_asm_string(const_gimple stmt)
123015 +{
123016 + if (!stmt)
123017 + return NULL;
123018 + if (gimple_code(stmt) != GIMPLE_ASM)
123019 + return NULL;
123020 +
123021 + return gimple_asm_string(stmt);
123022 +}
123023 +
123024 +bool is_size_overflow_intentional_asm_turn_off(const_gimple stmt)
123025 +{
123026 + const char *str;
123027 +
123028 + str = get_asm_string(stmt);
123029 + if (!str)
123030 + return false;
123031 + return !strncmp(str, TURN_OFF_ASM_STR, sizeof(TURN_OFF_ASM_STR) - 1);
123032 +}
123033 +
123034 +bool is_size_overflow_intentional_asm_yes(const_gimple stmt)
123035 +{
123036 + const char *str;
123037 +
123038 + str = get_asm_string(stmt);
123039 + if (!str)
123040 + return false;
123041 + return !strncmp(str, YES_ASM_STR, sizeof(YES_ASM_STR) - 1);
123042 +}
123043 +
123044 +bool is_size_overflow_asm(const_gimple stmt)
123045 +{
123046 + const char *str;
123047 +
123048 + str = get_asm_string(stmt);
123049 + if (!str)
123050 + return false;
123051 + return !strncmp(str, OK_ASM_STR, sizeof(OK_ASM_STR) - 1);
123052 +}
123053 +
123054 +bool is_a_return_check(const_tree node)
123055 +{
123056 + if (TREE_CODE(node) == FUNCTION_DECL)
123057 + return true;
123058 +
123059 + gcc_assert(TREE_CODE(node) == PARM_DECL);
123060 + return false;
123061 +}
123062 +
123063 +// Get the argnum of a function decl, if node is a return then the argnum is 0
123064 +unsigned int get_function_num(const_tree node, const_tree orig_fndecl)
123065 +{
123066 + if (is_a_return_check(node))
123067 + return 0;
123068 + else
123069 + return find_arg_number_tree(node, orig_fndecl);
123070 +}
123071 +
123072 +unsigned int get_correct_arg_count(unsigned int argnum, const_tree fndecl)
123073 +{
123074 + const struct size_overflow_hash *hash;
123075 + unsigned int new_argnum;
123076 + tree arg;
123077 + const_tree origarg;
123078 +
123079 + if (argnum == 0)
123080 + return argnum;
123081 +
123082 + hash = get_function_hash(fndecl);
123083 + if (hash && hash->param & (1U << argnum))
123084 + return argnum;
123085 +
123086 + if (DECL_EXTERNAL(fndecl))
123087 + return argnum;
123088 +
123089 + origarg = DECL_ARGUMENTS(DECL_ORIGIN(fndecl));
123090 + argnum--;
123091 + while (origarg && argnum) {
123092 + origarg = TREE_CHAIN(origarg);
123093 + argnum--;
123094 + }
123095 + gcc_assert(argnum == 0);
123096 + gcc_assert(origarg != NULL_TREE);
123097 +
123098 + for (arg = DECL_ARGUMENTS(fndecl), new_argnum = 1; arg; arg = TREE_CHAIN(arg), new_argnum++)
123099 + if (operand_equal_p(origarg, arg, 0) || !strcmp(DECL_NAME_POINTER(origarg), DECL_NAME_POINTER(arg)))
123100 + return new_argnum;
123101 +
123102 + return CANNOT_FIND_ARG;
123103 +}
123104 +
123105 +static bool is_in_hash_table(const_tree fndecl, unsigned int num)
123106 +{
123107 + const struct size_overflow_hash *hash;
123108 +
123109 + hash = get_function_hash(fndecl);
123110 + if (hash && (hash->param & (1U << num)))
123111 + return true;
123112 + return false;
123113 +}
123114 +
123115 +/* Check if the function has a size_overflow attribute or it is in the size_overflow hash table.
123116 + * If the function is missing everywhere then print the missing message into stderr.
123117 + */
123118 +bool is_missing_function(const_tree orig_fndecl, unsigned int num)
123119 +{
123120 + switch (DECL_FUNCTION_CODE(orig_fndecl)) {
123121 +#if BUILDING_GCC_VERSION >= 4008
123122 + case BUILT_IN_BSWAP16:
123123 +#endif
123124 + case BUILT_IN_BSWAP32:
123125 + case BUILT_IN_BSWAP64:
123126 + case BUILT_IN_EXPECT:
123127 + case BUILT_IN_MEMCMP:
123128 + return false;
123129 + default:
123130 + break;
123131 + }
123132 +
123133 + // skip test.c
123134 + if (strcmp(DECL_NAME_POINTER(current_function_decl), "coolmalloc")) {
123135 + if (lookup_attribute("size_overflow", DECL_ATTRIBUTES(orig_fndecl)))
123136 + warning(0, "unnecessary size_overflow attribute on: %s\n", DECL_NAME_POINTER(orig_fndecl));
123137 + }
123138 +
123139 + if (is_in_hash_table(orig_fndecl, num))
123140 + return false;
123141 +
123142 + print_missing_msg(orig_fndecl, num);
123143 + return true;
123144 +}
123145 +
123146 diff --git a/tools/gcc/stackleak_plugin.c b/tools/gcc/stackleak_plugin.c
123147 new file mode 100644
123148 index 0000000..dd94983
123149 --- /dev/null
123150 +++ b/tools/gcc/stackleak_plugin.c
123151 @@ -0,0 +1,376 @@
123152 +/*
123153 + * Copyright 2011-2014 by the PaX Team <pageexec@freemail.hu>
123154 + * Licensed under the GPL v2
123155 + *
123156 + * Note: the choice of the license means that the compilation process is
123157 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
123158 + * but for the kernel it doesn't matter since it doesn't link against
123159 + * any of the gcc libraries
123160 + *
123161 + * gcc plugin to help implement various PaX features
123162 + *
123163 + * - track lowest stack pointer
123164 + *
123165 + * TODO:
123166 + * - initialize all local variables
123167 + *
123168 + * BUGS:
123169 + * - none known
123170 + */
123171 +
123172 +#include "gcc-common.h"
123173 +
123174 +int plugin_is_GPL_compatible;
123175 +
123176 +static int track_frame_size = -1;
123177 +static const char track_function[] = "pax_track_stack";
123178 +static const char check_function[] = "pax_check_alloca";
123179 +static tree track_function_decl, check_function_decl;
123180 +static bool init_locals;
123181 +
123182 +static struct plugin_info stackleak_plugin_info = {
123183 + .version = "201402131920",
123184 + .help = "track-lowest-sp=nn\ttrack sp in functions whose frame size is at least nn bytes\n"
123185 +// "initialize-locals\t\tforcibly initialize all stack frames\n"
123186 +};
123187 +
123188 +static void stackleak_check_alloca(gimple_stmt_iterator *gsi)
123189 +{
123190 + gimple check_alloca;
123191 + tree alloca_size;
123192 +
123193 + // insert call to void pax_check_alloca(unsigned long size)
123194 + alloca_size = gimple_call_arg(gsi_stmt(*gsi), 0);
123195 + check_alloca = gimple_build_call(check_function_decl, 1, alloca_size);
123196 + gsi_insert_before(gsi, check_alloca, GSI_SAME_STMT);
123197 +}
123198 +
123199 +static void stackleak_add_instrumentation(gimple_stmt_iterator *gsi)
123200 +{
123201 + gimple track_stack;
123202 +
123203 + // insert call to void pax_track_stack(void)
123204 + track_stack = gimple_build_call(track_function_decl, 0);
123205 + gsi_insert_after(gsi, track_stack, GSI_CONTINUE_LINKING);
123206 +}
123207 +
123208 +static bool is_alloca(gimple stmt)
123209 +{
123210 + if (gimple_call_builtin_p(stmt, BUILT_IN_ALLOCA))
123211 + return true;
123212 +
123213 +#if BUILDING_GCC_VERSION >= 4007
123214 + if (gimple_call_builtin_p(stmt, BUILT_IN_ALLOCA_WITH_ALIGN))
123215 + return true;
123216 +#endif
123217 +
123218 + return false;
123219 +}
123220 +
123221 +static unsigned int execute_stackleak_tree_instrument(void)
123222 +{
123223 + basic_block bb, entry_bb;
123224 + bool prologue_instrumented = false, is_leaf = true;
123225 +
123226 + entry_bb = ENTRY_BLOCK_PTR_FOR_FN(cfun)->next_bb;
123227 +
123228 + // 1. loop through BBs and GIMPLE statements
123229 + FOR_EACH_BB_FN(bb, cfun) {
123230 + gimple_stmt_iterator gsi;
123231 +
123232 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
123233 + gimple stmt;
123234 +
123235 + stmt = gsi_stmt(gsi);
123236 +
123237 + if (is_gimple_call(stmt))
123238 + is_leaf = false;
123239 +
123240 + // gimple match: align 8 built-in BUILT_IN_NORMAL:BUILT_IN_ALLOCA attributes <tree_list 0xb7576450>
123241 + if (!is_alloca(stmt))
123242 + continue;
123243 +
123244 + // 2. insert stack overflow check before each __builtin_alloca call
123245 + stackleak_check_alloca(&gsi);
123246 +
123247 + // 3. insert track call after each __builtin_alloca call
123248 + stackleak_add_instrumentation(&gsi);
123249 + if (bb == entry_bb)
123250 + prologue_instrumented = true;
123251 + }
123252 + }
123253 +
123254 + // special cases for some bad linux code: taking the address of static inline functions will materialize them
123255 + // but we mustn't instrument some of them as the resulting stack alignment required by the function call ABI
123256 + // will break other assumptions regarding the expected (but not otherwise enforced) register clobbering ABI.
123257 + // case in point: native_save_fl on amd64 when optimized for size clobbers rdx if it were instrumented here.
123258 + if (is_leaf && !TREE_PUBLIC(current_function_decl) && DECL_DECLARED_INLINE_P(current_function_decl))
123259 + return 0;
123260 + if (is_leaf && !strncmp(IDENTIFIER_POINTER(DECL_NAME(current_function_decl)), "_paravirt_", 10))
123261 + return 0;
123262 +
123263 + // 4. insert track call at the beginning
123264 + if (!prologue_instrumented) {
123265 + gimple_stmt_iterator gsi;
123266 +
123267 + bb = split_block_after_labels(ENTRY_BLOCK_PTR_FOR_FN(cfun))->dest;
123268 + if (dom_info_available_p(CDI_DOMINATORS))
123269 + set_immediate_dominator(CDI_DOMINATORS, bb, ENTRY_BLOCK_PTR_FOR_FN(cfun));
123270 + gsi = gsi_start_bb(bb);
123271 + stackleak_add_instrumentation(&gsi);
123272 + }
123273 +
123274 + return 0;
123275 +}
123276 +
123277 +static unsigned int execute_stackleak_final(void)
123278 +{
123279 + rtx insn, next;
123280 +
123281 + if (cfun->calls_alloca)
123282 + return 0;
123283 +
123284 + // keep calls only if function frame is big enough
123285 + if (get_frame_size() >= track_frame_size)
123286 + return 0;
123287 +
123288 + // 1. find pax_track_stack calls
123289 + for (insn = get_insns(); insn; insn = next) {
123290 + // 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))
123291 + rtx body;
123292 +
123293 + next = NEXT_INSN(insn);
123294 + if (!CALL_P(insn))
123295 + continue;
123296 + body = PATTERN(insn);
123297 + if (GET_CODE(body) != CALL)
123298 + continue;
123299 + body = XEXP(body, 0);
123300 + if (GET_CODE(body) != MEM)
123301 + continue;
123302 + body = XEXP(body, 0);
123303 + if (GET_CODE(body) != SYMBOL_REF)
123304 + continue;
123305 +// if (strcmp(XSTR(body, 0), track_function))
123306 + if (SYMBOL_REF_DECL(body) != track_function_decl)
123307 + continue;
123308 +// warning(0, "track_frame_size: %d %ld %d", cfun->calls_alloca, get_frame_size(), track_frame_size);
123309 + // 2. delete call
123310 + delete_insn_and_edges(insn);
123311 +#if BUILDING_GCC_VERSION >= 4007
123312 + if (GET_CODE(next) == NOTE && NOTE_KIND(next) == NOTE_INSN_CALL_ARG_LOCATION) {
123313 + insn = next;
123314 + next = NEXT_INSN(insn);
123315 + delete_insn_and_edges(insn);
123316 + }
123317 +#endif
123318 + }
123319 +
123320 +// print_simple_rtl(stderr, get_insns());
123321 +// print_rtl(stderr, get_insns());
123322 +// warning(0, "track_frame_size: %d %ld %d", cfun->calls_alloca, get_frame_size(), track_frame_size);
123323 +
123324 + return 0;
123325 +}
123326 +
123327 +static bool gate_stackleak_track_stack(void)
123328 +{
123329 + return track_frame_size >= 0;
123330 +}
123331 +
123332 +static void stackleak_start_unit(void *gcc_data, void *user_data)
123333 +{
123334 + tree fntype;
123335 +
123336 + // void pax_track_stack(void)
123337 + fntype = build_function_type_list(void_type_node, NULL_TREE);
123338 + track_function_decl = build_fn_decl(track_function, fntype);
123339 + DECL_ASSEMBLER_NAME(track_function_decl); // for LTO
123340 + TREE_PUBLIC(track_function_decl) = 1;
123341 + DECL_EXTERNAL(track_function_decl) = 1;
123342 + DECL_ARTIFICIAL(track_function_decl) = 1;
123343 +
123344 + // void pax_check_alloca(unsigned long)
123345 + fntype = build_function_type_list(void_type_node, long_unsigned_type_node, NULL_TREE);
123346 + check_function_decl = build_fn_decl(check_function, fntype);
123347 + DECL_ASSEMBLER_NAME(check_function_decl); // for LTO
123348 + TREE_PUBLIC(check_function_decl) = 1;
123349 + DECL_EXTERNAL(check_function_decl) = 1;
123350 + DECL_ARTIFICIAL(check_function_decl) = 1;
123351 +}
123352 +
123353 +#if BUILDING_GCC_VERSION >= 4009
123354 +static const struct pass_data stackleak_tree_instrument_pass_data = {
123355 +#else
123356 +static struct gimple_opt_pass stackleak_tree_instrument_pass = {
123357 + .pass = {
123358 +#endif
123359 + .type = GIMPLE_PASS,
123360 + .name = "stackleak_tree_instrument",
123361 +#if BUILDING_GCC_VERSION >= 4008
123362 + .optinfo_flags = OPTGROUP_NONE,
123363 +#endif
123364 +#if BUILDING_GCC_VERSION >= 4009
123365 + .has_gate = true,
123366 + .has_execute = true,
123367 +#else
123368 + .gate = gate_stackleak_track_stack,
123369 + .execute = execute_stackleak_tree_instrument,
123370 + .sub = NULL,
123371 + .next = NULL,
123372 + .static_pass_number = 0,
123373 +#endif
123374 + .tv_id = TV_NONE,
123375 + .properties_required = PROP_gimple_leh | PROP_cfg,
123376 + .properties_provided = 0,
123377 + .properties_destroyed = 0,
123378 + .todo_flags_start = 0, //TODO_verify_ssa | TODO_verify_flow | TODO_verify_stmts,
123379 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_update_ssa | TODO_rebuild_cgraph_edges
123380 +#if BUILDING_GCC_VERSION < 4009
123381 + }
123382 +#endif
123383 +};
123384 +
123385 +#if BUILDING_GCC_VERSION >= 4009
123386 +static const struct pass_data stackleak_final_rtl_opt_pass_data = {
123387 +#else
123388 +static struct rtl_opt_pass stackleak_final_rtl_opt_pass = {
123389 + .pass = {
123390 +#endif
123391 + .type = RTL_PASS,
123392 + .name = "stackleak_final",
123393 +#if BUILDING_GCC_VERSION >= 4008
123394 + .optinfo_flags = OPTGROUP_NONE,
123395 +#endif
123396 +#if BUILDING_GCC_VERSION >= 4009
123397 + .has_gate = true,
123398 + .has_execute = true,
123399 +#else
123400 + .gate = gate_stackleak_track_stack,
123401 + .execute = execute_stackleak_final,
123402 + .sub = NULL,
123403 + .next = NULL,
123404 + .static_pass_number = 0,
123405 +#endif
123406 + .tv_id = TV_NONE,
123407 + .properties_required = 0,
123408 + .properties_provided = 0,
123409 + .properties_destroyed = 0,
123410 + .todo_flags_start = 0,
123411 + .todo_flags_finish = TODO_dump_func
123412 +#if BUILDING_GCC_VERSION < 4009
123413 + }
123414 +#endif
123415 +};
123416 +
123417 +#if BUILDING_GCC_VERSION >= 4009
123418 +namespace {
123419 +class stackleak_tree_instrument_pass : public gimple_opt_pass {
123420 +public:
123421 + stackleak_tree_instrument_pass() : gimple_opt_pass(stackleak_tree_instrument_pass_data, g) {}
123422 + bool gate() { return gate_stackleak_track_stack(); }
123423 + unsigned int execute() { return execute_stackleak_tree_instrument(); }
123424 +};
123425 +
123426 +class stackleak_final_rtl_opt_pass : public rtl_opt_pass {
123427 +public:
123428 + stackleak_final_rtl_opt_pass() : rtl_opt_pass(stackleak_final_rtl_opt_pass_data, g) {}
123429 + bool gate() { return gate_stackleak_track_stack(); }
123430 + unsigned int execute() { return execute_stackleak_final(); }
123431 +};
123432 +}
123433 +
123434 +static opt_pass *make_stackleak_tree_instrument_pass(void)
123435 +{
123436 + return new stackleak_tree_instrument_pass();
123437 +}
123438 +
123439 +static opt_pass *make_stackleak_final_rtl_opt_pass(void)
123440 +{
123441 + return new stackleak_final_rtl_opt_pass();
123442 +}
123443 +#else
123444 +static struct opt_pass *make_stackleak_tree_instrument_pass(void)
123445 +{
123446 + return &stackleak_tree_instrument_pass.pass;
123447 +}
123448 +
123449 +static struct opt_pass *make_stackleak_final_rtl_opt_pass(void)
123450 +{
123451 + return &stackleak_final_rtl_opt_pass.pass;
123452 +}
123453 +#endif
123454 +
123455 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
123456 +{
123457 + const char * const plugin_name = plugin_info->base_name;
123458 + const int argc = plugin_info->argc;
123459 + const struct plugin_argument * const argv = plugin_info->argv;
123460 + int i;
123461 + struct register_pass_info stackleak_tree_instrument_pass_info;
123462 + struct register_pass_info stackleak_final_pass_info;
123463 + static const struct ggc_root_tab gt_ggc_r_gt_stackleak[] = {
123464 + {
123465 + .base = &track_function_decl,
123466 + .nelt = 1,
123467 + .stride = sizeof(track_function_decl),
123468 + .cb = &gt_ggc_mx_tree_node,
123469 + .pchw = &gt_pch_nx_tree_node
123470 + },
123471 + {
123472 + .base = &check_function_decl,
123473 + .nelt = 1,
123474 + .stride = sizeof(check_function_decl),
123475 + .cb = &gt_ggc_mx_tree_node,
123476 + .pchw = &gt_pch_nx_tree_node
123477 + },
123478 + LAST_GGC_ROOT_TAB
123479 + };
123480 +
123481 + stackleak_tree_instrument_pass_info.pass = make_stackleak_tree_instrument_pass();
123482 +// stackleak_tree_instrument_pass_info.reference_pass_name = "tree_profile";
123483 + stackleak_tree_instrument_pass_info.reference_pass_name = "optimized";
123484 + stackleak_tree_instrument_pass_info.ref_pass_instance_number = 1;
123485 + stackleak_tree_instrument_pass_info.pos_op = PASS_POS_INSERT_BEFORE;
123486 +
123487 + stackleak_final_pass_info.pass = make_stackleak_final_rtl_opt_pass();
123488 + stackleak_final_pass_info.reference_pass_name = "final";
123489 + stackleak_final_pass_info.ref_pass_instance_number = 1;
123490 + stackleak_final_pass_info.pos_op = PASS_POS_INSERT_BEFORE;
123491 +
123492 + if (!plugin_default_version_check(version, &gcc_version)) {
123493 + error(G_("incompatible gcc/plugin versions"));
123494 + return 1;
123495 + }
123496 +
123497 + register_callback(plugin_name, PLUGIN_INFO, NULL, &stackleak_plugin_info);
123498 +
123499 + for (i = 0; i < argc; ++i) {
123500 + if (!strcmp(argv[i].key, "track-lowest-sp")) {
123501 + if (!argv[i].value) {
123502 + error(G_("no value supplied for option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
123503 + continue;
123504 + }
123505 + track_frame_size = atoi(argv[i].value);
123506 + if (argv[i].value[0] < '0' || argv[i].value[0] > '9' || track_frame_size < 0)
123507 + error(G_("invalid option argument '-fplugin-arg-%s-%s=%s'"), plugin_name, argv[i].key, argv[i].value);
123508 + continue;
123509 + }
123510 + if (!strcmp(argv[i].key, "initialize-locals")) {
123511 + if (argv[i].value) {
123512 + error(G_("invalid option argument '-fplugin-arg-%s-%s=%s'"), plugin_name, argv[i].key, argv[i].value);
123513 + continue;
123514 + }
123515 + init_locals = true;
123516 + continue;
123517 + }
123518 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
123519 + }
123520 +
123521 + register_callback(plugin_name, PLUGIN_START_UNIT, &stackleak_start_unit, NULL);
123522 + register_callback(plugin_name, PLUGIN_REGISTER_GGC_ROOTS, NULL, (void *)&gt_ggc_r_gt_stackleak);
123523 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &stackleak_tree_instrument_pass_info);
123524 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &stackleak_final_pass_info);
123525 +
123526 + return 0;
123527 +}
123528 diff --git a/tools/gcc/structleak_plugin.c b/tools/gcc/structleak_plugin.c
123529 new file mode 100644
123530 index 0000000..4ee2231
123531 --- /dev/null
123532 +++ b/tools/gcc/structleak_plugin.c
123533 @@ -0,0 +1,274 @@
123534 +/*
123535 + * Copyright 2013-2014 by PaX Team <pageexec@freemail.hu>
123536 + * Licensed under the GPL v2
123537 + *
123538 + * Note: the choice of the license means that the compilation process is
123539 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
123540 + * but for the kernel it doesn't matter since it doesn't link against
123541 + * any of the gcc libraries
123542 + *
123543 + * gcc plugin to forcibly initialize certain local variables that could
123544 + * otherwise leak kernel stack to userland if they aren't properly initialized
123545 + * by later code
123546 + *
123547 + * Homepage: http://pax.grsecurity.net/
123548 + *
123549 + * Usage:
123550 + * $ # for 4.5/4.6/C based 4.7
123551 + * $ 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
123552 + * $ # for C++ based 4.7/4.8+
123553 + * $ 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
123554 + * $ gcc -fplugin=./structleak_plugin.so test.c -O2
123555 + *
123556 + * TODO: eliminate redundant initializers
123557 + * increase type coverage
123558 + */
123559 +
123560 +#include "gcc-common.h"
123561 +
123562 +// unused C type flag in all versions 4.5-4.9
123563 +#define TYPE_USERSPACE(TYPE) TYPE_LANG_FLAG_3(TYPE)
123564 +
123565 +int plugin_is_GPL_compatible;
123566 +
123567 +static struct plugin_info structleak_plugin_info = {
123568 + .version = "201401260140",
123569 + .help = "disable\tdo not activate plugin\n",
123570 +};
123571 +
123572 +static tree handle_user_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
123573 +{
123574 + *no_add_attrs = true;
123575 +
123576 + // check for types? for now accept everything linux has to offer
123577 + if (TREE_CODE(*node) != FIELD_DECL)
123578 + return NULL_TREE;
123579 +
123580 + *no_add_attrs = false;
123581 + return NULL_TREE;
123582 +}
123583 +
123584 +static struct attribute_spec user_attr = {
123585 + .name = "user",
123586 + .min_length = 0,
123587 + .max_length = 0,
123588 + .decl_required = false,
123589 + .type_required = false,
123590 + .function_type_required = false,
123591 + .handler = handle_user_attribute,
123592 +#if BUILDING_GCC_VERSION >= 4007
123593 + .affects_type_identity = true
123594 +#endif
123595 +};
123596 +
123597 +static void register_attributes(void *event_data, void *data)
123598 +{
123599 + register_attribute(&user_attr);
123600 +// register_attribute(&force_attr);
123601 +}
123602 +
123603 +static tree get_field_type(tree field)
123604 +{
123605 + return strip_array_types(TREE_TYPE(field));
123606 +}
123607 +
123608 +static bool is_userspace_type(tree type)
123609 +{
123610 + tree field;
123611 +
123612 + for (field = TYPE_FIELDS(type); field; field = TREE_CHAIN(field)) {
123613 + tree fieldtype = get_field_type(field);
123614 + enum tree_code code = TREE_CODE(fieldtype);
123615 +
123616 + if (code == RECORD_TYPE || code == UNION_TYPE)
123617 + if (is_userspace_type(fieldtype))
123618 + return true;
123619 +
123620 + if (lookup_attribute("user", DECL_ATTRIBUTES(field)))
123621 + return true;
123622 + }
123623 + return false;
123624 +}
123625 +
123626 +static void finish_type(void *event_data, void *data)
123627 +{
123628 + tree type = (tree)event_data;
123629 +
123630 + if (TYPE_USERSPACE(type))
123631 + return;
123632 +
123633 + if (is_userspace_type(type))
123634 + TYPE_USERSPACE(type) = 1;
123635 +}
123636 +
123637 +static void initialize(tree var)
123638 +{
123639 + basic_block bb;
123640 + gimple_stmt_iterator gsi;
123641 + tree initializer;
123642 + gimple init_stmt;
123643 +
123644 + // this is the original entry bb before the forced split
123645 + // TODO: check further BBs in case more splits occured before us
123646 + bb = ENTRY_BLOCK_PTR_FOR_FN(cfun)->next_bb->next_bb;
123647 +
123648 + // first check if the variable is already initialized, warn otherwise
123649 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
123650 + gimple stmt = gsi_stmt(gsi);
123651 + tree rhs1;
123652 +
123653 + // we're looking for an assignment of a single rhs...
123654 + if (!gimple_assign_single_p(stmt))
123655 + continue;
123656 + rhs1 = gimple_assign_rhs1(stmt);
123657 +#if BUILDING_GCC_VERSION >= 4007
123658 + // ... of a non-clobbering expression...
123659 + if (TREE_CLOBBER_P(rhs1))
123660 + continue;
123661 +#endif
123662 + // ... to our variable...
123663 + if (gimple_get_lhs(stmt) != var)
123664 + continue;
123665 + // if it's an initializer then we're good
123666 + if (TREE_CODE(rhs1) == CONSTRUCTOR)
123667 + return;
123668 + }
123669 +
123670 + // these aren't the 0days you're looking for
123671 +// inform(DECL_SOURCE_LOCATION(var), "userspace variable will be forcibly initialized");
123672 +
123673 + // build the initializer expression
123674 + initializer = build_constructor(TREE_TYPE(var), NULL);
123675 +
123676 + // build the initializer stmt
123677 + init_stmt = gimple_build_assign(var, initializer);
123678 + gsi = gsi_start_bb(ENTRY_BLOCK_PTR_FOR_FN(cfun)->next_bb);
123679 + gsi_insert_before(&gsi, init_stmt, GSI_NEW_STMT);
123680 + update_stmt(init_stmt);
123681 +}
123682 +
123683 +static unsigned int handle_function(void)
123684 +{
123685 + basic_block bb;
123686 + unsigned int ret = 0;
123687 + tree var;
123688 + unsigned int i;
123689 +
123690 + // split the first bb where we can put the forced initializers
123691 + bb = split_block_after_labels(ENTRY_BLOCK_PTR_FOR_FN(cfun))->dest;
123692 + if (dom_info_available_p(CDI_DOMINATORS))
123693 + set_immediate_dominator(CDI_DOMINATORS, bb, ENTRY_BLOCK_PTR_FOR_FN(cfun));
123694 +
123695 + // enumarate all local variables and forcibly initialize our targets
123696 + FOR_EACH_LOCAL_DECL(cfun, i, var) {
123697 + tree type = TREE_TYPE(var);
123698 +
123699 + gcc_assert(DECL_P(var));
123700 + if (!auto_var_in_fn_p(var, current_function_decl))
123701 + continue;
123702 +
123703 + // only care about structure types
123704 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE)
123705 + continue;
123706 +
123707 + // if the type is of interest, examine the variable
123708 + if (TYPE_USERSPACE(type))
123709 + initialize(var);
123710 + }
123711 +
123712 + return ret;
123713 +}
123714 +
123715 +#if BUILDING_GCC_VERSION >= 4009
123716 +static const struct pass_data structleak_pass_data = {
123717 +#else
123718 +static struct gimple_opt_pass structleak_pass = {
123719 + .pass = {
123720 +#endif
123721 + .type = GIMPLE_PASS,
123722 + .name = "structleak",
123723 +#if BUILDING_GCC_VERSION >= 4008
123724 + .optinfo_flags = OPTGROUP_NONE,
123725 +#endif
123726 +#if BUILDING_GCC_VERSION >= 4009
123727 + .has_gate = false,
123728 + .has_execute = true,
123729 +#else
123730 + .gate = NULL,
123731 + .execute = handle_function,
123732 + .sub = NULL,
123733 + .next = NULL,
123734 + .static_pass_number = 0,
123735 +#endif
123736 + .tv_id = TV_NONE,
123737 + .properties_required = PROP_cfg,
123738 + .properties_provided = 0,
123739 + .properties_destroyed = 0,
123740 + .todo_flags_start = 0,
123741 + .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
123742 +#if BUILDING_GCC_VERSION < 4009
123743 + }
123744 +#endif
123745 +};
123746 +
123747 +#if BUILDING_GCC_VERSION >= 4009
123748 +namespace {
123749 +class structleak_pass : public gimple_opt_pass {
123750 +public:
123751 + structleak_pass() : gimple_opt_pass(structleak_pass_data, g) {}
123752 + unsigned int execute() { return handle_function(); }
123753 +};
123754 +}
123755 +
123756 +static opt_pass *make_structleak_pass(void)
123757 +{
123758 + return new structleak_pass();
123759 +}
123760 +#else
123761 +static struct opt_pass *make_structleak_pass(void)
123762 +{
123763 + return &structleak_pass.pass;
123764 +}
123765 +#endif
123766 +
123767 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
123768 +{
123769 + int i;
123770 + const char * const plugin_name = plugin_info->base_name;
123771 + const int argc = plugin_info->argc;
123772 + const struct plugin_argument * const argv = plugin_info->argv;
123773 + bool enable = true;
123774 + struct register_pass_info structleak_pass_info;
123775 +
123776 + structleak_pass_info.pass = make_structleak_pass();
123777 + structleak_pass_info.reference_pass_name = "ssa";
123778 + structleak_pass_info.ref_pass_instance_number = 1;
123779 + structleak_pass_info.pos_op = PASS_POS_INSERT_AFTER;
123780 +
123781 + if (!plugin_default_version_check(version, &gcc_version)) {
123782 + error(G_("incompatible gcc/plugin versions"));
123783 + return 1;
123784 + }
123785 +
123786 + if (strcmp(lang_hooks.name, "GNU C")) {
123787 + inform(UNKNOWN_LOCATION, G_("%s supports C only"), plugin_name);
123788 + enable = false;
123789 + }
123790 +
123791 + for (i = 0; i < argc; ++i) {
123792 + if (!strcmp(argv[i].key, "disable")) {
123793 + enable = false;
123794 + continue;
123795 + }
123796 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
123797 + }
123798 +
123799 + register_callback(plugin_name, PLUGIN_INFO, NULL, &structleak_plugin_info);
123800 + if (enable) {
123801 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &structleak_pass_info);
123802 + register_callback(plugin_name, PLUGIN_FINISH_TYPE, finish_type, NULL);
123803 + }
123804 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
123805 +
123806 + return 0;
123807 +}
123808 diff --git a/tools/include/linux/compiler.h b/tools/include/linux/compiler.h
123809 index fbc6665..5e9ce79 100644
123810 --- a/tools/include/linux/compiler.h
123811 +++ b/tools/include/linux/compiler.h
123812 @@ -35,4 +35,12 @@
123813 # define unlikely(x) __builtin_expect(!!(x), 0)
123814 #endif
123815
123816 +#ifndef __size_overflow
123817 +# define __size_overflow(...)
123818 +#endif
123819 +
123820 +#ifndef __intentional_overflow
123821 +# define __intentional_overflow(...)
123822 +#endif
123823 +
123824 #endif /* _TOOLS_LINUX_COMPILER_H */
123825 diff --git a/tools/lib/api/Makefile b/tools/lib/api/Makefile
123826 index ce00f7e..0aca5e4 100644
123827 --- a/tools/lib/api/Makefile
123828 +++ b/tools/lib/api/Makefile
123829 @@ -16,7 +16,7 @@ LIB_OBJS += $(OUTPUT)fs/fs.o
123830
123831 LIBFILE = libapikfs.a
123832
123833 -CFLAGS = -ggdb3 -Wall -Wextra -std=gnu99 -Werror -O6 -D_FORTIFY_SOURCE=2 $(EXTRA_WARNINGS) $(EXTRA_CFLAGS) -fPIC
123834 +CFLAGS = -ggdb3 -Wall -Wextra -std=gnu99 -Werror -O6 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 $(EXTRA_WARNINGS) $(EXTRA_CFLAGS) -fPIC
123835 EXTLIBS = -lelf -lpthread -lrt -lm
123836 ALL_CFLAGS = $(CFLAGS) $(BASIC_CFLAGS) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64
123837 ALL_LDFLAGS = $(LDFLAGS)
123838 diff --git a/tools/perf/util/include/asm/alternative-asm.h b/tools/perf/util/include/asm/alternative-asm.h
123839 index 6789d788..4afd019e 100644
123840 --- a/tools/perf/util/include/asm/alternative-asm.h
123841 +++ b/tools/perf/util/include/asm/alternative-asm.h
123842 @@ -5,4 +5,7 @@
123843
123844 #define altinstruction_entry #
123845
123846 + .macro pax_force_retaddr rip=0, reload=0
123847 + .endm
123848 +
123849 #endif
123850 diff --git a/tools/virtio/linux/uaccess.h b/tools/virtio/linux/uaccess.h
123851 index 0a578fe..b81f62d 100644
123852 --- a/tools/virtio/linux/uaccess.h
123853 +++ b/tools/virtio/linux/uaccess.h
123854 @@ -13,7 +13,7 @@ static inline void __chk_user_ptr(const volatile void *p, size_t size)
123855 ({ \
123856 typeof(ptr) __pu_ptr = (ptr); \
123857 __chk_user_ptr(__pu_ptr, sizeof(*__pu_ptr)); \
123858 - ACCESS_ONCE(*(__pu_ptr)) = x; \
123859 + ACCESS_ONCE_RW(*(__pu_ptr)) = x; \
123860 0; \
123861 })
123862
123863 diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
123864 index 56baae8..2c889c2 100644
123865 --- a/virt/kvm/kvm_main.c
123866 +++ b/virt/kvm/kvm_main.c
123867 @@ -76,12 +76,17 @@ LIST_HEAD(vm_list);
123868
123869 static cpumask_var_t cpus_hardware_enabled;
123870 static int kvm_usage_count = 0;
123871 -static atomic_t hardware_enable_failed;
123872 +static atomic_unchecked_t hardware_enable_failed;
123873
123874 struct kmem_cache *kvm_vcpu_cache;
123875 EXPORT_SYMBOL_GPL(kvm_vcpu_cache);
123876
123877 -static __read_mostly struct preempt_ops kvm_preempt_ops;
123878 +static void kvm_sched_in(struct preempt_notifier *pn, int cpu);
123879 +static void kvm_sched_out(struct preempt_notifier *pn, struct task_struct *next);
123880 +static struct preempt_ops kvm_preempt_ops = {
123881 + .sched_in = kvm_sched_in,
123882 + .sched_out = kvm_sched_out,
123883 +};
123884
123885 struct dentry *kvm_debugfs_dir;
123886
123887 @@ -755,7 +760,7 @@ int __kvm_set_memory_region(struct kvm *kvm,
123888 /* We can read the guest memory with __xxx_user() later on. */
123889 if ((mem->slot < KVM_USER_MEM_SLOTS) &&
123890 ((mem->userspace_addr & (PAGE_SIZE - 1)) ||
123891 - !access_ok(VERIFY_WRITE,
123892 + !access_ok_noprefault(VERIFY_WRITE,
123893 (void __user *)(unsigned long)mem->userspace_addr,
123894 mem->memory_size)))
123895 goto out;
123896 @@ -1612,9 +1617,17 @@ EXPORT_SYMBOL_GPL(kvm_read_guest_cached);
123897
123898 int kvm_clear_guest_page(struct kvm *kvm, gfn_t gfn, int offset, int len)
123899 {
123900 - const void *zero_page = (const void *) __va(page_to_phys(ZERO_PAGE(0)));
123901 + int r;
123902 + unsigned long addr;
123903
123904 - return kvm_write_guest_page(kvm, gfn, zero_page, offset, len);
123905 + addr = gfn_to_hva(kvm, gfn);
123906 + if (kvm_is_error_hva(addr))
123907 + return -EFAULT;
123908 + r = __clear_user((void __user *)addr + offset, len);
123909 + if (r)
123910 + return -EFAULT;
123911 + mark_page_dirty(kvm, gfn);
123912 + return 0;
123913 }
123914 EXPORT_SYMBOL_GPL(kvm_clear_guest_page);
123915
123916 @@ -1864,7 +1877,7 @@ static int kvm_vcpu_release(struct inode *inode, struct file *filp)
123917 return 0;
123918 }
123919
123920 -static struct file_operations kvm_vcpu_fops = {
123921 +static file_operations_no_const kvm_vcpu_fops __read_only = {
123922 .release = kvm_vcpu_release,
123923 .unlocked_ioctl = kvm_vcpu_ioctl,
123924 #ifdef CONFIG_COMPAT
123925 @@ -2534,7 +2547,7 @@ out:
123926 }
123927 #endif
123928
123929 -static struct file_operations kvm_vm_fops = {
123930 +static file_operations_no_const kvm_vm_fops __read_only = {
123931 .release = kvm_vm_release,
123932 .unlocked_ioctl = kvm_vm_ioctl,
123933 #ifdef CONFIG_COMPAT
123934 @@ -2634,7 +2647,7 @@ out:
123935 return r;
123936 }
123937
123938 -static struct file_operations kvm_chardev_ops = {
123939 +static file_operations_no_const kvm_chardev_ops __read_only = {
123940 .unlocked_ioctl = kvm_dev_ioctl,
123941 .compat_ioctl = kvm_dev_ioctl,
123942 .llseek = noop_llseek,
123943 @@ -2660,7 +2673,7 @@ static void hardware_enable_nolock(void *junk)
123944
123945 if (r) {
123946 cpumask_clear_cpu(cpu, cpus_hardware_enabled);
123947 - atomic_inc(&hardware_enable_failed);
123948 + atomic_inc_unchecked(&hardware_enable_failed);
123949 printk(KERN_INFO "kvm: enabling virtualization on "
123950 "CPU%d failed\n", cpu);
123951 }
123952 @@ -2716,10 +2729,10 @@ static int hardware_enable_all(void)
123953
123954 kvm_usage_count++;
123955 if (kvm_usage_count == 1) {
123956 - atomic_set(&hardware_enable_failed, 0);
123957 + atomic_set_unchecked(&hardware_enable_failed, 0);
123958 on_each_cpu(hardware_enable_nolock, NULL, 1);
123959
123960 - if (atomic_read(&hardware_enable_failed)) {
123961 + if (atomic_read_unchecked(&hardware_enable_failed)) {
123962 hardware_disable_all_nolock();
123963 r = -EBUSY;
123964 }
123965 @@ -3123,7 +3136,7 @@ static void kvm_sched_out(struct preempt_notifier *pn,
123966 kvm_arch_vcpu_put(vcpu);
123967 }
123968
123969 -int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
123970 +int kvm_init(const void *opaque, unsigned vcpu_size, unsigned vcpu_align,
123971 struct module *module)
123972 {
123973 int r;
123974 @@ -3170,7 +3183,7 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
123975 if (!vcpu_align)
123976 vcpu_align = __alignof__(struct kvm_vcpu);
123977 kvm_vcpu_cache = kmem_cache_create("kvm_vcpu", vcpu_size, vcpu_align,
123978 - 0, NULL);
123979 + SLAB_USERCOPY, NULL);
123980 if (!kvm_vcpu_cache) {
123981 r = -ENOMEM;
123982 goto out_free_3;
123983 @@ -3180,9 +3193,11 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
123984 if (r)
123985 goto out_free;
123986
123987 + pax_open_kernel();
123988 kvm_chardev_ops.owner = module;
123989 kvm_vm_fops.owner = module;
123990 kvm_vcpu_fops.owner = module;
123991 + pax_close_kernel();
123992
123993 r = misc_register(&kvm_dev);
123994 if (r) {
123995 @@ -3192,9 +3207,6 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
123996
123997 register_syscore_ops(&kvm_syscore_ops);
123998
123999 - kvm_preempt_ops.sched_in = kvm_sched_in;
124000 - kvm_preempt_ops.sched_out = kvm_sched_out;
124001 -
124002 r = kvm_init_debug();
124003 if (r) {
124004 printk(KERN_ERR "kvm: create debugfs files failed\n");